aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJens Axboe <jaxboe@fusionio.com>2011-05-20 14:33:15 -0400
committerJens Axboe <jaxboe@fusionio.com>2011-05-20 14:33:15 -0400
commit698567f3fa790fea37509a54dea855302dd88331 (patch)
tree7a1df976a0eb12cab03e82c18809a30d5482fee4 /drivers
parentd70d0711edd8076ec2ce0ed109106e2df950681b (diff)
parent61c4f2c81c61f73549928dfd9f3e8f26aa36a8cf (diff)
Merge commit 'v2.6.39' into for-2.6.40/core
Since for-2.6.40/core was forked off the 2.6.39 devel tree, we've had churn in the core area that makes it difficult to handle patches for eg cfq or blk-throttle. Instead of requiring that they be based in older versions with bugs that have been fixed later in the rc cycle, merge in 2.6.39 final. Also fixes up conflicts in the below files. Conflicts: drivers/block/paride/pcd.c drivers/cdrom/viocd.c drivers/ide/ide-cd.c Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/scan.c4
-rw-r--r--drivers/ata/ahci.c8
-rw-r--r--drivers/ata/ahci.h4
-rw-r--r--drivers/ata/ata_piix.c8
-rw-r--r--drivers/ata/libahci.c39
-rw-r--r--drivers/ata/libata-core.c3
-rw-r--r--drivers/ata/libata-eh.c6
-rw-r--r--drivers/ata/pata_at91.c22
-rw-r--r--drivers/atm/fore200e.c7
-rw-r--r--drivers/base/power/main.c1
-rw-r--r--drivers/base/power/wakeup.c2
-rw-r--r--drivers/base/syscore.c2
-rw-r--r--drivers/block/DAC960.c1
-rw-r--r--drivers/block/amiflop.c1
-rw-r--r--drivers/block/ataflop.c1
-rw-r--r--drivers/block/floppy.c1
-rw-r--r--drivers/block/paride/pd.c1
-rw-r--r--drivers/block/paride/pf.c1
-rw-r--r--drivers/block/rbd.c181
-rw-r--r--drivers/block/swim.c1
-rw-r--r--drivers/block/swim3.c1
-rw-r--r--drivers/block/ub.c1
-rw-r--r--drivers/block/xsysace.c1
-rw-r--r--drivers/cdrom/gdrom.c1
-rw-r--r--drivers/char/agp/generic.c19
-rw-r--r--drivers/char/hw_random/n2-drv.c7
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c7
-rw-r--r--drivers/char/virtio_console.c11
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.c14
-rw-r--r--drivers/clk/clkdev.c19
-rw-r--r--drivers/connector/connector.c1
-rw-r--r--drivers/edac/amd64_edac.c88
-rw-r--r--drivers/edac/amd64_edac.h3
-rw-r--r--drivers/edac/edac_mc_sysfs.c11
-rw-r--r--drivers/edac/ppc4xx_edac.c2
-rw-r--r--drivers/firewire/ohci.c39
-rw-r--r--drivers/gpu/drm/Kconfig1
-rw-r--r--drivers/gpu/drm/drm_fb_helper.c53
-rw-r--r--drivers/gpu/drm/drm_irq.c23
-rw-r--r--drivers/gpu/drm/drm_mm.c6
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c2
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c2
-rw-r--r--drivers/gpu/drm/i915/intel_display.c81
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c17
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h1
-rw-r--r--drivers/gpu/drm/i915/intel_fb.c10
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c3
-rw-r--r--drivers/gpu/drm/i915/intel_tv.c9
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_dma.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.h3
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_fbcon.c4
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_mem.c4
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_notifier.c11
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_object.c10
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_sgdma.c8
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_state.c6
-rw-r--r--drivers/gpu/drm/nouveau/nv50_instmem.c10
-rw-r--r--drivers/gpu/drm/nouveau/nv50_vm.c5
-rw-r--r--drivers/gpu/drm/nouveau/nvc0_vm.c5
-rw-r--r--drivers/gpu/drm/radeon/atom.c6
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c6
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c113
-rw-r--r--drivers/gpu/drm/radeon/evergreend.h6
-rw-r--r--drivers/gpu/drm/radeon/ni.c18
-rw-r--r--drivers/gpu/drm/radeon/r600.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_atombios.c23
-rw-r--r--drivers/gpu/drm/radeon/radeon_atpx_handler.c29
-rw-r--r--drivers/gpu/drm/radeon/radeon_connectors.c29
-rw-r--r--drivers/gpu/drm/radeon/radeon_cursor.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_gart.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_i2c.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_kms.c16
-rw-r--r--drivers/gpu/drm/radeon/reg_srcs/cayman1
-rw-r--r--drivers/gpu/drm/radeon/reg_srcs/evergreen1
-rw-r--r--drivers/gpu/drm/radeon/reg_srcs/r6001
-rw-r--r--drivers/gpu/vga/vga_switcheroo.c6
-rw-r--r--drivers/hwmon/Kconfig11
-rw-r--r--drivers/hwmon/lm85.c6
-rw-r--r--drivers/hwmon/lm90.c22
-rw-r--r--drivers/hwmon/pmbus_core.c1
-rw-r--r--drivers/hwmon/twl4030-madc-hwmon.c3
-rw-r--r--drivers/i2c/busses/i2c-i801.c5
-rw-r--r--drivers/i2c/busses/i2c-mpc.c9
-rw-r--r--drivers/i2c/busses/i2c-parport.c27
-rw-r--r--drivers/i2c/busses/i2c-pnx.c2
-rw-r--r--drivers/ide/ide-cd_ioctl.c6
-rw-r--r--drivers/ide/ide-gd.c7
-rw-r--r--drivers/infiniband/hw/qib/qib_iba6120.c2
-rw-r--r--drivers/infiniband/hw/qib/qib_iba7220.c2
-rw-r--r--drivers/infiniband/hw/qib/qib_iba7322.c2
-rw-r--r--drivers/input/touchscreen/ads7846.c13
-rw-r--r--drivers/input/touchscreen/wm831x-ts.c75
-rw-r--r--drivers/leds/leds-lm3530.c1
-rw-r--r--drivers/md/md.c1
-rw-r--r--drivers/md/raid5.c5
-rw-r--r--drivers/media/common/tuners/tda18271-common.c11
-rw-r--r--drivers/media/common/tuners/tda18271-fe.c21
-rw-r--r--drivers/media/common/tuners/tda18271-maps.c12
-rw-r--r--drivers/media/dvb/b2c2/flexcop-pci.c2
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig6
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_devices.c6
-rw-r--r--drivers/media/dvb/ngene/ngene-core.c1
-rw-r--r--drivers/media/media-entity.c8
-rw-r--r--drivers/media/radio/radio-sf16fmr2.c2
-rw-r--r--drivers/media/radio/saa7706h.c2
-rw-r--r--drivers/media/radio/tef6862.c2
-rw-r--r--drivers/media/rc/imon.c31
-rw-r--r--drivers/media/rc/ite-cir.c1
-rw-r--r--drivers/media/rc/mceusb.c2
-rw-r--r--drivers/media/rc/rc-main.c4
-rw-r--r--drivers/media/video/Kconfig2
-rw-r--r--drivers/media/video/cx18/cx18-streams.c10
-rw-r--r--drivers/media/video/cx23885/Kconfig1
-rw-r--r--drivers/media/video/cx88/cx88-input.c2
-rw-r--r--drivers/media/video/imx074.c2
-rw-r--r--drivers/media/video/m52790.c2
-rw-r--r--drivers/media/video/omap3isp/isp.c34
-rw-r--r--drivers/media/video/omap3isp/isp.h12
-rw-r--r--drivers/media/video/omap3isp/ispccdc.c37
-rw-r--r--drivers/media/video/omap3isp/isppreview.c2
-rw-r--r--drivers/media/video/omap3isp/ispqueue.c6
-rw-r--r--drivers/media/video/omap3isp/ispresizer.c75
-rw-r--r--drivers/media/video/omap3isp/ispstat.h6
-rw-r--r--drivers/media/video/omap3isp/ispvideo.c108
-rw-r--r--drivers/media/video/omap3isp/ispvideo.h3
-rw-r--r--drivers/media/video/s5p-fimc/fimc-capture.c8
-rw-r--r--drivers/media/video/s5p-fimc/fimc-core.c74
-rw-r--r--drivers/media/video/sh_mobile_ceu_camera.c10
-rw-r--r--drivers/media/video/sh_mobile_csi2.c11
-rw-r--r--drivers/media/video/soc_camera.c55
-rw-r--r--drivers/media/video/tda9840.c2
-rw-r--r--drivers/media/video/tea6415c.c2
-rw-r--r--drivers/media/video/tea6420.c2
-rw-r--r--drivers/media/video/upd64031a.c2
-rw-r--r--drivers/media/video/upd64083.c2
-rw-r--r--drivers/media/video/v4l2-dev.c15
-rw-r--r--drivers/media/video/v4l2-device.c5
-rw-r--r--drivers/media/video/v4l2-subdev.c14
-rw-r--r--drivers/media/video/videobuf-dma-contig.c2
-rw-r--r--drivers/media/video/videobuf2-core.c17
-rw-r--r--drivers/media/video/videobuf2-dma-contig.c2
-rw-r--r--drivers/message/i2o/i2o_block.c1
-rw-r--r--drivers/mfd/asic3.c2
-rw-r--r--drivers/mfd/omap-usb-host.c17
-rw-r--r--drivers/mfd/twl4030-power.c3
-rw-r--r--drivers/mmc/core/bus.c1
-rw-r--r--drivers/mmc/host/omap.c2
-rw-r--r--drivers/mmc/host/sdhci-of-core.c7
-rw-r--r--drivers/mmc/host/sdhci-pci.c1
-rw-r--r--drivers/mmc/host/sdhci.c9
-rw-r--r--drivers/mmc/host/tmio_mmc_pio.c10
-rw-r--r--drivers/mtd/maps/physmap_of.c7
-rw-r--r--drivers/mtd/nand/diskonchip.c2
-rw-r--r--drivers/net/Kconfig8
-rw-r--r--drivers/net/Makefile6
-rw-r--r--drivers/net/amd8111e.c2
-rw-r--r--drivers/net/arm/etherh.c4
-rw-r--r--drivers/net/atl1c/atl1c.h6
-rw-r--r--drivers/net/atl1c/atl1c_main.c14
-rw-r--r--drivers/net/benet/be.h2
-rw-r--r--drivers/net/benet/be_cmds.c2
-rw-r--r--drivers/net/benet/be_main.c19
-rw-r--r--drivers/net/bna/bfa_ioc.c31
-rw-r--r--drivers/net/bna/bfa_ioc.h1
-rw-r--r--drivers/net/bna/bfa_ioc_ct.c28
-rw-r--r--drivers/net/bna/bfi.h6
-rw-r--r--drivers/net/bna/bnad.c1
-rw-r--r--drivers/net/bnx2.c2
-rw-r--r--drivers/net/bnx2x/bnx2x_cmn.c34
-rw-r--r--drivers/net/bnx2x/bnx2x_ethtool.c9
-rw-r--r--drivers/net/bonding/bond_3ad.c7
-rw-r--r--drivers/net/bonding/bond_3ad.h10
-rw-r--r--drivers/net/bonding/bond_alb.c6
-rw-r--r--drivers/net/bonding/bond_alb.h4
-rw-r--r--drivers/net/can/mscan/mpc5xxx_can.c7
-rw-r--r--drivers/net/can/sja1000/sja1000.c2
-rw-r--r--drivers/net/can/slcan.c4
-rw-r--r--drivers/net/ehea/ehea_ethtool.c21
-rw-r--r--drivers/net/ehea/ehea_main.c15
-rw-r--r--drivers/net/fs_enet/fs_enet-main.c9
-rw-r--r--drivers/net/fs_enet/mac-fec.c8
-rw-r--r--drivers/net/fs_enet/mii-fec.c7
-rw-r--r--drivers/net/ftmac100.c8
-rw-r--r--drivers/net/hydra.c14
-rw-r--r--drivers/net/loopback.c3
-rw-r--r--drivers/net/mii.c4
-rw-r--r--drivers/net/natsemi.c3
-rw-r--r--drivers/net/ne-h8300.c16
-rw-r--r--drivers/net/netconsole.c8
-rw-r--r--drivers/net/netxen/netxen_nic.h4
-rw-r--r--drivers/net/netxen/netxen_nic_main.c17
-rw-r--r--drivers/net/pch_gbe/pch_gbe_main.c23
-rw-r--r--drivers/net/qlcnic/qlcnic.h1
-rw-r--r--drivers/net/qlcnic/qlcnic_main.c14
-rw-r--r--drivers/net/r8169.c99
-rw-r--r--drivers/net/sfc/efx.c6
-rw-r--r--drivers/net/sfc/io.h2
-rw-r--r--drivers/net/sfc/mcdi.c49
-rw-r--r--drivers/net/sfc/net_driver.h2
-rw-r--r--drivers/net/sfc/nic.c29
-rw-r--r--drivers/net/sfc/nic.h3
-rw-r--r--drivers/net/sfc/selftest.c25
-rw-r--r--drivers/net/sfc/siena.c25
-rw-r--r--drivers/net/sfc/tx.c3
-rw-r--r--drivers/net/sis900.c23
-rw-r--r--drivers/net/slip.c4
-rw-r--r--drivers/net/stmmac/dwmac_lib.c28
-rw-r--r--drivers/net/stmmac/stmmac_main.c49
-rw-r--r--drivers/net/sunhme.c7
-rw-r--r--drivers/net/tg3.c8
-rw-r--r--drivers/net/tokenring/3c359.c4
-rw-r--r--drivers/net/tokenring/lanstreamer.c2
-rw-r--r--drivers/net/tokenring/olympic.c2
-rw-r--r--drivers/net/usb/cdc_ether.c16
-rw-r--r--drivers/net/usb/cdc_ncm.c4
-rw-r--r--drivers/net/usb/ipheth.c14
-rw-r--r--drivers/net/usb/smsc95xx.c2
-rw-r--r--drivers/net/usb/usbnet.c18
-rw-r--r--drivers/net/veth.c12
-rw-r--r--drivers/net/vmxnet3/vmxnet3_drv.c10
-rw-r--r--drivers/net/vmxnet3/vmxnet3_ethtool.c3
-rw-r--r--drivers/net/wireless/ath/ath9k/hif_usb.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c9
-rw-r--r--drivers/net/wireless/ath/ath9k/mac.c25
-rw-r--r--drivers/net/wireless/ath/ath9k/mac.h2
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c20
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c6
-rw-r--r--drivers/net/wireless/ath/regd_common.h1
-rw-r--r--drivers/net/wireless/b43/main.c1
-rw-r--r--drivers/net/wireless/iwlegacy/Kconfig9
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-3945-hw.h2
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965-hw.h3
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965-tx.c28
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-core.c24
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-dev.h6
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-eeprom.c7
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-led.c20
-rw-r--r--drivers/net/wireless/iwlegacy/iwl3945-base.c4
-rw-r--r--drivers/net/wireless/iwlegacy/iwl4965-base.c14
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rxon.c7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-tx.c27
-rw-r--r--drivers/net/wireless/libertas/cmd.c6
-rw-r--r--drivers/net/wireless/mwl8k.c9
-rw-r--r--drivers/net/wireless/p54/txrx.c2
-rw-r--r--drivers/net/zorro8390.c12
-rw-r--r--drivers/parport/parport_pc.c8
-rw-r--r--drivers/pci/Kconfig4
-rw-r--r--drivers/pci/Makefile4
-rw-r--r--drivers/pci/intel-iommu.c55
-rw-r--r--drivers/pci/setup-bus.c4
-rw-r--r--drivers/pcmcia/pcmcia_resource.c2
-rw-r--r--drivers/platform/x86/eeepc-laptop.c57
-rw-r--r--drivers/platform/x86/sony-laptop.c130
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c6
-rw-r--r--drivers/rapidio/switches/idt_gen2.c9
-rw-r--r--drivers/rapidio/switches/idtcps.c6
-rw-r--r--drivers/rapidio/switches/tsi57x.c6
-rw-r--r--drivers/rtc/rtc-coh901331.c4
-rw-r--r--drivers/rtc/rtc-davinci.c5
-rw-r--r--drivers/rtc/rtc-ds1286.c2
-rw-r--r--drivers/rtc/rtc-ep93xx.c5
-rw-r--r--drivers/rtc/rtc-m41t80.c5
-rw-r--r--drivers/rtc/rtc-max8925.c8
-rw-r--r--drivers/rtc/rtc-max8998.c5
-rw-r--r--drivers/rtc/rtc-mc13xxx.c8
-rw-r--r--drivers/rtc/rtc-msm6242.c3
-rw-r--r--drivers/rtc/rtc-mxc.c19
-rw-r--r--drivers/rtc/rtc-omap.c2
-rw-r--r--drivers/rtc/rtc-pcap.c4
-rw-r--r--drivers/rtc/rtc-rp5c01.c5
-rw-r--r--drivers/rtc/rtc-s3c.c13
-rw-r--r--drivers/s390/block/dasd.c51
-rw-r--r--drivers/s390/block/dasd_devmap.c30
-rw-r--r--drivers/s390/block/dasd_diag.c2
-rw-r--r--drivers/s390/block/dasd_eckd.c5
-rw-r--r--drivers/s390/block/dasd_genhd.c2
-rw-r--r--drivers/s390/block/dasd_int.h3
-rw-r--r--drivers/s390/block/dasd_ioctl.c128
-rw-r--r--drivers/s390/char/sclp_cmd.c2
-rw-r--r--drivers/s390/char/tape_block.c1
-rw-r--r--drivers/s390/cio/qdio_main.c17
-rw-r--r--drivers/s390/kvm/kvm_virtio.c2
-rw-r--r--drivers/scsi/device_handler/scsi_dh.c9
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_ctl.c23
-rw-r--r--drivers/scsi/pmcraid.c3
-rw-r--r--drivers/scsi/qlogicpti.c7
-rw-r--r--drivers/scsi/scsi_lib.c32
-rw-r--r--drivers/scsi/scsi_scan.c2
-rw-r--r--drivers/scsi/scsi_sysfs.c16
-rw-r--r--drivers/scsi/scsi_transport_fc.c19
-rw-r--r--drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c4
-rw-r--r--drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c3
-rw-r--r--drivers/staging/gma500/Kconfig2
-rw-r--r--drivers/staging/intel_sst/intelmid_v1_control.c1
-rw-r--r--drivers/staging/intel_sst/intelmid_v2_control.c1
-rw-r--r--drivers/staging/olpc_dcon/olpc_dcon_xo_1.c1
-rw-r--r--drivers/staging/rt2860/common/cmm_data_pci.c2
-rw-r--r--drivers/staging/rt2860/common/cmm_data_usb.c2
-rw-r--r--drivers/staging/rts_pstor/debug.h2
-rw-r--r--drivers/staging/rts_pstor/ms.c1
-rw-r--r--drivers/staging/rts_pstor/rtsx_chip.c5
-rw-r--r--drivers/staging/rts_pstor/rtsx_scsi.c1
-rw-r--r--drivers/staging/rts_pstor/sd.c4
-rw-r--r--drivers/staging/rts_pstor/trace.h2
-rw-r--r--drivers/staging/rts_pstor/xd.c1
-rw-r--r--drivers/staging/solo6x10/Kconfig1
-rw-r--r--drivers/staging/spectra/ffsport.c2
-rw-r--r--drivers/staging/tidspbridge/dynload/cload.c2
-rw-r--r--drivers/staging/tty/specialix.c2
-rw-r--r--drivers/staging/usbip/vhci_hcd.c11
-rw-r--r--drivers/staging/usbip/vhci_sysfs.c7
-rw-r--r--drivers/staging/wlan-ng/cfg80211.c2
-rw-r--r--drivers/tty/n_gsm.c8
-rw-r--r--drivers/tty/serial/imx.c3
-rw-r--r--drivers/tty/serial/of_serial.c7
-rw-r--r--drivers/usb/gadget/fsl_qe_udc.c7
-rw-r--r--drivers/usb/host/ehci-omap.c20
-rw-r--r--drivers/usb/host/isp1760-hcd.c1
-rw-r--r--drivers/usb/host/xhci-hub.c19
-rw-r--r--drivers/usb/musb/musb_gadget.c6
-rw-r--r--drivers/usb/musb/omap2430.c2
-rw-r--r--drivers/video/acornfb.c26
-rw-r--r--drivers/video/fbmem.c223
-rw-r--r--drivers/virtio/virtio_pci.c15
-rw-r--r--drivers/virtio/virtio_ring.c1
-rw-r--r--drivers/watchdog/iTCO_wdt.c97
-rw-r--r--drivers/watchdog/mpc8xxx_wdt.c7
-rw-r--r--drivers/xen/manage.c9
329 files changed, 3020 insertions, 1281 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index b136c9c1e531..449c556274c0 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -943,6 +943,10 @@ static int acpi_bus_get_flags(struct acpi_device *device)
943 if (ACPI_SUCCESS(status)) 943 if (ACPI_SUCCESS(status))
944 device->flags.lockable = 1; 944 device->flags.lockable = 1;
945 945
946 /* Power resources cannot be power manageable. */
947 if (device->device_type == ACPI_BUS_TYPE_POWER)
948 return 0;
949
946 /* Presence of _PS0|_PR0 indicates 'power manageable' */ 950 /* Presence of _PS0|_PR0 indicates 'power manageable' */
947 status = acpi_get_handle(device->handle, "_PS0", &temp); 951 status = acpi_get_handle(device->handle, "_PS0", &temp);
948 if (ACPI_FAILURE(status)) 952 if (ACPI_FAILURE(status))
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 39d829cd82dd..71afe0371311 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -150,7 +150,7 @@ static const struct ata_port_info ahci_port_info[] = {
150 { 150 {
151 AHCI_HFLAGS (AHCI_HFLAG_NO_FPDMA_AA | AHCI_HFLAG_NO_PMP | 151 AHCI_HFLAGS (AHCI_HFLAG_NO_FPDMA_AA | AHCI_HFLAG_NO_PMP |
152 AHCI_HFLAG_YES_NCQ), 152 AHCI_HFLAG_YES_NCQ),
153 .flags = AHCI_FLAG_COMMON, 153 .flags = AHCI_FLAG_COMMON | ATA_FLAG_NO_DIPM,
154 .pio_mask = ATA_PIO4, 154 .pio_mask = ATA_PIO4,
155 .udma_mask = ATA_UDMA6, 155 .udma_mask = ATA_UDMA6,
156 .port_ops = &ahci_ops, 156 .port_ops = &ahci_ops,
@@ -261,6 +261,12 @@ static const struct pci_device_id ahci_pci_tbl[] = {
261 { PCI_VDEVICE(INTEL, 0x1d06), board_ahci }, /* PBG RAID */ 261 { PCI_VDEVICE(INTEL, 0x1d06), board_ahci }, /* PBG RAID */
262 { PCI_VDEVICE(INTEL, 0x2826), board_ahci }, /* PBG RAID */ 262 { PCI_VDEVICE(INTEL, 0x2826), board_ahci }, /* PBG RAID */
263 { PCI_VDEVICE(INTEL, 0x2323), board_ahci }, /* DH89xxCC AHCI */ 263 { PCI_VDEVICE(INTEL, 0x2323), board_ahci }, /* DH89xxCC AHCI */
264 { PCI_VDEVICE(INTEL, 0x1e02), board_ahci }, /* Panther Point AHCI */
265 { PCI_VDEVICE(INTEL, 0x1e03), board_ahci }, /* Panther Point AHCI */
266 { PCI_VDEVICE(INTEL, 0x1e04), board_ahci }, /* Panther Point RAID */
267 { PCI_VDEVICE(INTEL, 0x1e05), board_ahci }, /* Panther Point RAID */
268 { PCI_VDEVICE(INTEL, 0x1e06), board_ahci }, /* Panther Point RAID */
269 { PCI_VDEVICE(INTEL, 0x1e07), board_ahci }, /* Panther Point RAID */
264 270
265 /* JMicron 360/1/3/5/6, match class to avoid IDE function */ 271 /* JMicron 360/1/3/5/6, match class to avoid IDE function */
266 { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 272 { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index 39865009c251..12c5282e7fca 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -229,6 +229,10 @@ enum {
229 EM_CTL_ALHD = (1 << 26), /* Activity LED */ 229 EM_CTL_ALHD = (1 << 26), /* Activity LED */
230 EM_CTL_XMT = (1 << 25), /* Transmit Only */ 230 EM_CTL_XMT = (1 << 25), /* Transmit Only */
231 EM_CTL_SMB = (1 << 24), /* Single Message Buffer */ 231 EM_CTL_SMB = (1 << 24), /* Single Message Buffer */
232 EM_CTL_SGPIO = (1 << 19), /* SGPIO messages supported */
233 EM_CTL_SES = (1 << 18), /* SES-2 messages supported */
234 EM_CTL_SAFTE = (1 << 17), /* SAF-TE messages supported */
235 EM_CTL_LED = (1 << 16), /* LED messages supported */
232 236
233 /* em message type */ 237 /* em message type */
234 EM_MSG_TYPE_LED = (1 << 0), /* LED */ 238 EM_MSG_TYPE_LED = (1 << 0), /* LED */
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 0bc3fd6c3fdb..6f6e7718b05c 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -309,6 +309,14 @@ static const struct pci_device_id piix_pci_tbl[] = {
309 { 0x8086, 0x1d00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, 309 { 0x8086, 0x1d00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
310 /* SATA Controller IDE (PBG) */ 310 /* SATA Controller IDE (PBG) */
311 { 0x8086, 0x1d08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, 311 { 0x8086, 0x1d08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
312 /* SATA Controller IDE (Panther Point) */
313 { 0x8086, 0x1e00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
314 /* SATA Controller IDE (Panther Point) */
315 { 0x8086, 0x1e01, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
316 /* SATA Controller IDE (Panther Point) */
317 { 0x8086, 0x1e08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
318 /* SATA Controller IDE (Panther Point) */
319 { 0x8086, 0x1e09, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
312 { } /* terminate list */ 320 { } /* terminate list */
313}; 321};
314 322
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 26d452339e98..d38c40fe4ddb 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -109,6 +109,8 @@ static ssize_t ahci_read_em_buffer(struct device *dev,
109static ssize_t ahci_store_em_buffer(struct device *dev, 109static ssize_t ahci_store_em_buffer(struct device *dev,
110 struct device_attribute *attr, 110 struct device_attribute *attr,
111 const char *buf, size_t size); 111 const char *buf, size_t size);
112static ssize_t ahci_show_em_supported(struct device *dev,
113 struct device_attribute *attr, char *buf);
112 114
113static DEVICE_ATTR(ahci_host_caps, S_IRUGO, ahci_show_host_caps, NULL); 115static DEVICE_ATTR(ahci_host_caps, S_IRUGO, ahci_show_host_caps, NULL);
114static DEVICE_ATTR(ahci_host_cap2, S_IRUGO, ahci_show_host_cap2, NULL); 116static DEVICE_ATTR(ahci_host_cap2, S_IRUGO, ahci_show_host_cap2, NULL);
@@ -116,6 +118,7 @@ static DEVICE_ATTR(ahci_host_version, S_IRUGO, ahci_show_host_version, NULL);
116static DEVICE_ATTR(ahci_port_cmd, S_IRUGO, ahci_show_port_cmd, NULL); 118static DEVICE_ATTR(ahci_port_cmd, S_IRUGO, ahci_show_port_cmd, NULL);
117static DEVICE_ATTR(em_buffer, S_IWUSR | S_IRUGO, 119static DEVICE_ATTR(em_buffer, S_IWUSR | S_IRUGO,
118 ahci_read_em_buffer, ahci_store_em_buffer); 120 ahci_read_em_buffer, ahci_store_em_buffer);
121static DEVICE_ATTR(em_message_supported, S_IRUGO, ahci_show_em_supported, NULL);
119 122
120struct device_attribute *ahci_shost_attrs[] = { 123struct device_attribute *ahci_shost_attrs[] = {
121 &dev_attr_link_power_management_policy, 124 &dev_attr_link_power_management_policy,
@@ -126,6 +129,7 @@ struct device_attribute *ahci_shost_attrs[] = {
126 &dev_attr_ahci_host_version, 129 &dev_attr_ahci_host_version,
127 &dev_attr_ahci_port_cmd, 130 &dev_attr_ahci_port_cmd,
128 &dev_attr_em_buffer, 131 &dev_attr_em_buffer,
132 &dev_attr_em_message_supported,
129 NULL 133 NULL
130}; 134};
131EXPORT_SYMBOL_GPL(ahci_shost_attrs); 135EXPORT_SYMBOL_GPL(ahci_shost_attrs);
@@ -343,6 +347,24 @@ static ssize_t ahci_store_em_buffer(struct device *dev,
343 return size; 347 return size;
344} 348}
345 349
350static ssize_t ahci_show_em_supported(struct device *dev,
351 struct device_attribute *attr, char *buf)
352{
353 struct Scsi_Host *shost = class_to_shost(dev);
354 struct ata_port *ap = ata_shost_to_port(shost);
355 struct ahci_host_priv *hpriv = ap->host->private_data;
356 void __iomem *mmio = hpriv->mmio;
357 u32 em_ctl;
358
359 em_ctl = readl(mmio + HOST_EM_CTL);
360
361 return sprintf(buf, "%s%s%s%s\n",
362 em_ctl & EM_CTL_LED ? "led " : "",
363 em_ctl & EM_CTL_SAFTE ? "saf-te " : "",
364 em_ctl & EM_CTL_SES ? "ses-2 " : "",
365 em_ctl & EM_CTL_SGPIO ? "sgpio " : "");
366}
367
346/** 368/**
347 * ahci_save_initial_config - Save and fixup initial config values 369 * ahci_save_initial_config - Save and fixup initial config values
348 * @dev: target AHCI device 370 * @dev: target AHCI device
@@ -1897,7 +1919,17 @@ static void ahci_pmp_attach(struct ata_port *ap)
1897 ahci_enable_fbs(ap); 1919 ahci_enable_fbs(ap);
1898 1920
1899 pp->intr_mask |= PORT_IRQ_BAD_PMP; 1921 pp->intr_mask |= PORT_IRQ_BAD_PMP;
1900 writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK); 1922
1923 /*
1924 * We must not change the port interrupt mask register if the
1925 * port is marked frozen, the value in pp->intr_mask will be
1926 * restored later when the port is thawed.
1927 *
1928 * Note that during initialization, the port is marked as
1929 * frozen since the irq handler is not yet registered.
1930 */
1931 if (!(ap->pflags & ATA_PFLAG_FROZEN))
1932 writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
1901} 1933}
1902 1934
1903static void ahci_pmp_detach(struct ata_port *ap) 1935static void ahci_pmp_detach(struct ata_port *ap)
@@ -1913,7 +1945,10 @@ static void ahci_pmp_detach(struct ata_port *ap)
1913 writel(cmd, port_mmio + PORT_CMD); 1945 writel(cmd, port_mmio + PORT_CMD);
1914 1946
1915 pp->intr_mask &= ~PORT_IRQ_BAD_PMP; 1947 pp->intr_mask &= ~PORT_IRQ_BAD_PMP;
1916 writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK); 1948
1949 /* see comment above in ahci_pmp_attach() */
1950 if (!(ap->pflags & ATA_PFLAG_FROZEN))
1951 writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK);
1917} 1952}
1918 1953
1919int ahci_port_resume(struct ata_port *ap) 1954int ahci_port_resume(struct ata_port *ap)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 423c0a6952b2..76c3c15cb1e6 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4139,6 +4139,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
4139 */ 4139 */
4140 { "PIONEER DVD-RW DVRTD08", "1.00", ATA_HORKAGE_NOSETXFER }, 4140 { "PIONEER DVD-RW DVRTD08", "1.00", ATA_HORKAGE_NOSETXFER },
4141 { "PIONEER DVD-RW DVR-212D", "1.28", ATA_HORKAGE_NOSETXFER }, 4141 { "PIONEER DVD-RW DVR-212D", "1.28", ATA_HORKAGE_NOSETXFER },
4142 { "PIONEER DVD-RW DVR-216D", "1.08", ATA_HORKAGE_NOSETXFER },
4142 4143
4143 /* End Marker */ 4144 /* End Marker */
4144 { } 4145 { }
@@ -5480,7 +5481,7 @@ struct ata_port *ata_port_alloc(struct ata_host *host)
5480 if (!ap) 5481 if (!ap)
5481 return NULL; 5482 return NULL;
5482 5483
5483 ap->pflags |= ATA_PFLAG_INITIALIZING; 5484 ap->pflags |= ATA_PFLAG_INITIALIZING | ATA_PFLAG_FROZEN;
5484 ap->lock = &host->lock; 5485 ap->lock = &host->lock;
5485 ap->print_id = -1; 5486 ap->print_id = -1;
5486 ap->host = host; 5487 ap->host = host;
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 88cd22fa65cd..dad9fd660f37 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -3316,6 +3316,7 @@ static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
3316 struct ata_eh_context *ehc = &link->eh_context; 3316 struct ata_eh_context *ehc = &link->eh_context;
3317 struct ata_device *dev, *link_dev = NULL, *lpm_dev = NULL; 3317 struct ata_device *dev, *link_dev = NULL, *lpm_dev = NULL;
3318 enum ata_lpm_policy old_policy = link->lpm_policy; 3318 enum ata_lpm_policy old_policy = link->lpm_policy;
3319 bool no_dipm = link->ap->flags & ATA_FLAG_NO_DIPM;
3319 unsigned int hints = ATA_LPM_EMPTY | ATA_LPM_HIPM; 3320 unsigned int hints = ATA_LPM_EMPTY | ATA_LPM_HIPM;
3320 unsigned int err_mask; 3321 unsigned int err_mask;
3321 int rc; 3322 int rc;
@@ -3332,7 +3333,7 @@ static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
3332 */ 3333 */
3333 ata_for_each_dev(dev, link, ENABLED) { 3334 ata_for_each_dev(dev, link, ENABLED) {
3334 bool hipm = ata_id_has_hipm(dev->id); 3335 bool hipm = ata_id_has_hipm(dev->id);
3335 bool dipm = ata_id_has_dipm(dev->id); 3336 bool dipm = ata_id_has_dipm(dev->id) && !no_dipm;
3336 3337
3337 /* find the first enabled and LPM enabled devices */ 3338 /* find the first enabled and LPM enabled devices */
3338 if (!link_dev) 3339 if (!link_dev)
@@ -3389,7 +3390,8 @@ static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
3389 3390
3390 /* host config updated, enable DIPM if transitioning to MIN_POWER */ 3391 /* host config updated, enable DIPM if transitioning to MIN_POWER */
3391 ata_for_each_dev(dev, link, ENABLED) { 3392 ata_for_each_dev(dev, link, ENABLED) {
3392 if (policy == ATA_LPM_MIN_POWER && ata_id_has_dipm(dev->id)) { 3393 if (policy == ATA_LPM_MIN_POWER && !no_dipm &&
3394 ata_id_has_dipm(dev->id)) {
3393 err_mask = ata_dev_set_feature(dev, 3395 err_mask = ata_dev_set_feature(dev,
3394 SETFEATURES_SATA_ENABLE, SATA_DIPM); 3396 SETFEATURES_SATA_ENABLE, SATA_DIPM);
3395 if (err_mask && err_mask != AC_ERR_DEV) { 3397 if (err_mask && err_mask != AC_ERR_DEV) {
diff --git a/drivers/ata/pata_at91.c b/drivers/ata/pata_at91.c
index 0da0dcc7dd08..a5fdbdcb0faf 100644
--- a/drivers/ata/pata_at91.c
+++ b/drivers/ata/pata_at91.c
@@ -33,11 +33,12 @@
33 33
34 34
35#define DRV_NAME "pata_at91" 35#define DRV_NAME "pata_at91"
36#define DRV_VERSION "0.1" 36#define DRV_VERSION "0.2"
37 37
38#define CF_IDE_OFFSET 0x00c00000 38#define CF_IDE_OFFSET 0x00c00000
39#define CF_ALT_IDE_OFFSET 0x00e00000 39#define CF_ALT_IDE_OFFSET 0x00e00000
40#define CF_IDE_RES_SIZE 0x08 40#define CF_IDE_RES_SIZE 0x08
41#define NCS_RD_PULSE_LIMIT 0x3f /* maximal value for pulse bitfields */
41 42
42struct at91_ide_info { 43struct at91_ide_info {
43 unsigned long mode; 44 unsigned long mode;
@@ -49,8 +50,18 @@ struct at91_ide_info {
49 void __iomem *alt_addr; 50 void __iomem *alt_addr;
50}; 51};
51 52
52static const struct ata_timing initial_timing = 53static const struct ata_timing initial_timing = {
53 {XFER_PIO_0, 70, 290, 240, 600, 165, 150, 600, 0}; 54 .mode = XFER_PIO_0,
55 .setup = 70,
56 .act8b = 290,
57 .rec8b = 240,
58 .cyc8b = 600,
59 .active = 165,
60 .recover = 150,
61 .dmack_hold = 0,
62 .cycle = 600,
63 .udma = 0
64};
54 65
55static unsigned long calc_mck_cycles(unsigned long ns, unsigned long mck_hz) 66static unsigned long calc_mck_cycles(unsigned long ns, unsigned long mck_hz)
56{ 67{
@@ -109,6 +120,11 @@ static void set_smc_timing(struct device *dev,
109 /* (CS0, CS1, DIR, OE) <= (CFCE1, CFCE2, CFRNW, NCSX) timings */ 120 /* (CS0, CS1, DIR, OE) <= (CFCE1, CFCE2, CFRNW, NCSX) timings */
110 ncs_read_setup = 1; 121 ncs_read_setup = 1;
111 ncs_read_pulse = read_cycle - 2; 122 ncs_read_pulse = read_cycle - 2;
123 if (ncs_read_pulse > NCS_RD_PULSE_LIMIT) {
124 ncs_read_pulse = NCS_RD_PULSE_LIMIT;
125 dev_warn(dev, "ncs_read_pulse limited to maximal value %lu\n",
126 ncs_read_pulse);
127 }
112 128
113 /* Write timings same as read timings */ 129 /* Write timings same as read timings */
114 write_cycle = read_cycle; 130 write_cycle = read_cycle;
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
index bdd2719f3f68..bc9e702186dd 100644
--- a/drivers/atm/fore200e.c
+++ b/drivers/atm/fore200e.c
@@ -2643,16 +2643,19 @@ fore200e_init(struct fore200e* fore200e, struct device *parent)
2643} 2643}
2644 2644
2645#ifdef CONFIG_SBUS 2645#ifdef CONFIG_SBUS
2646static const struct of_device_id fore200e_sba_match[];
2646static int __devinit fore200e_sba_probe(struct platform_device *op) 2647static int __devinit fore200e_sba_probe(struct platform_device *op)
2647{ 2648{
2649 const struct of_device_id *match;
2648 const struct fore200e_bus *bus; 2650 const struct fore200e_bus *bus;
2649 struct fore200e *fore200e; 2651 struct fore200e *fore200e;
2650 static int index = 0; 2652 static int index = 0;
2651 int err; 2653 int err;
2652 2654
2653 if (!op->dev.of_match) 2655 match = of_match_device(fore200e_sba_match, &op->dev);
2656 if (!match)
2654 return -EINVAL; 2657 return -EINVAL;
2655 bus = op->dev.of_match->data; 2658 bus = match->data;
2656 2659
2657 fore200e = kzalloc(sizeof(struct fore200e), GFP_KERNEL); 2660 fore200e = kzalloc(sizeof(struct fore200e), GFP_KERNEL);
2658 if (!fore200e) 2661 if (!fore200e)
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index fbc5b6e7c591..abe3ab709e87 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -63,6 +63,7 @@ void device_pm_init(struct device *dev)
63 dev->power.wakeup = NULL; 63 dev->power.wakeup = NULL;
64 spin_lock_init(&dev->power.lock); 64 spin_lock_init(&dev->power.lock);
65 pm_runtime_init(dev); 65 pm_runtime_init(dev);
66 INIT_LIST_HEAD(&dev->power.entry);
66} 67}
67 68
68/** 69/**
diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index 4573c83df6dd..abbbd33e8d8a 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -258,7 +258,7 @@ void device_set_wakeup_capable(struct device *dev, bool capable)
258 if (!!dev->power.can_wakeup == !!capable) 258 if (!!dev->power.can_wakeup == !!capable)
259 return; 259 return;
260 260
261 if (device_is_registered(dev)) { 261 if (device_is_registered(dev) && !list_empty(&dev->power.entry)) {
262 if (capable) { 262 if (capable) {
263 if (wakeup_sysfs_add(dev)) 263 if (wakeup_sysfs_add(dev))
264 return; 264 return;
diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
index 90af2943f9e4..c126db3cb7d1 100644
--- a/drivers/base/syscore.c
+++ b/drivers/base/syscore.c
@@ -73,6 +73,7 @@ int syscore_suspend(void)
73 73
74 return ret; 74 return ret;
75} 75}
76EXPORT_SYMBOL_GPL(syscore_suspend);
76 77
77/** 78/**
78 * syscore_resume - Execute all the registered system core resume callbacks. 79 * syscore_resume - Execute all the registered system core resume callbacks.
@@ -95,6 +96,7 @@ void syscore_resume(void)
95 "Interrupts enabled after %pF\n", ops->resume); 96 "Interrupts enabled after %pF\n", ops->resume);
96 } 97 }
97} 98}
99EXPORT_SYMBOL_GPL(syscore_resume);
98#endif /* CONFIG_PM_SLEEP */ 100#endif /* CONFIG_PM_SLEEP */
99 101
100/** 102/**
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 8066d086578a..e086fbbbe853 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -2547,7 +2547,6 @@ static bool DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller)
2547 disk->major = MajorNumber; 2547 disk->major = MajorNumber;
2548 disk->first_minor = n << DAC960_MaxPartitionsBits; 2548 disk->first_minor = n << DAC960_MaxPartitionsBits;
2549 disk->fops = &DAC960_BlockDeviceOperations; 2549 disk->fops = &DAC960_BlockDeviceOperations;
2550 disk->events = DISK_EVENT_MEDIA_CHANGE;
2551 } 2550 }
2552 /* 2551 /*
2553 Indicate the Block Device Registration completed successfully, 2552 Indicate the Block Device Registration completed successfully,
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 456c0cc90dcf..8eba86bba599 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -1736,7 +1736,6 @@ static int __init fd_probe_drives(void)
1736 disk->major = FLOPPY_MAJOR; 1736 disk->major = FLOPPY_MAJOR;
1737 disk->first_minor = drive; 1737 disk->first_minor = drive;
1738 disk->fops = &floppy_fops; 1738 disk->fops = &floppy_fops;
1739 disk->events = DISK_EVENT_MEDIA_CHANGE;
1740 sprintf(disk->disk_name, "fd%d", drive); 1739 sprintf(disk->disk_name, "fd%d", drive);
1741 disk->private_data = &unit[drive]; 1740 disk->private_data = &unit[drive];
1742 set_capacity(disk, 880*2); 1741 set_capacity(disk, 880*2);
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index c871eae14120..ede16c64ff07 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -1964,7 +1964,6 @@ static int __init atari_floppy_init (void)
1964 unit[i].disk->first_minor = i; 1964 unit[i].disk->first_minor = i;
1965 sprintf(unit[i].disk->disk_name, "fd%d", i); 1965 sprintf(unit[i].disk->disk_name, "fd%d", i);
1966 unit[i].disk->fops = &floppy_fops; 1966 unit[i].disk->fops = &floppy_fops;
1967 unit[i].disk->events = DISK_EVENT_MEDIA_CHANGE;
1968 unit[i].disk->private_data = &unit[i]; 1967 unit[i].disk->private_data = &unit[i];
1969 unit[i].disk->queue = blk_init_queue(do_fd_request, 1968 unit[i].disk->queue = blk_init_queue(do_fd_request,
1970 &ataflop_lock); 1969 &ataflop_lock);
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 301d7a9a41a6..db8f88586c8d 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4205,7 +4205,6 @@ static int __init floppy_init(void)
4205 disks[dr]->major = FLOPPY_MAJOR; 4205 disks[dr]->major = FLOPPY_MAJOR;
4206 disks[dr]->first_minor = TOMINOR(dr); 4206 disks[dr]->first_minor = TOMINOR(dr);
4207 disks[dr]->fops = &floppy_fops; 4207 disks[dr]->fops = &floppy_fops;
4208 disks[dr]->events = DISK_EVENT_MEDIA_CHANGE;
4209 sprintf(disks[dr]->disk_name, "fd%d", dr); 4208 sprintf(disks[dr]->disk_name, "fd%d", dr);
4210 4209
4211 init_timer(&motor_off_timer[dr]); 4210 init_timer(&motor_off_timer[dr]);
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c
index 21dfdb776869..869e7676d46f 100644
--- a/drivers/block/paride/pd.c
+++ b/drivers/block/paride/pd.c
@@ -837,7 +837,6 @@ static void pd_probe_drive(struct pd_unit *disk)
837 p->fops = &pd_fops; 837 p->fops = &pd_fops;
838 p->major = major; 838 p->major = major;
839 p->first_minor = (disk - pd) << PD_BITS; 839 p->first_minor = (disk - pd) << PD_BITS;
840 p->events = DISK_EVENT_MEDIA_CHANGE;
841 disk->gd = p; 840 disk->gd = p;
842 p->private_data = disk; 841 p->private_data = disk;
843 p->queue = pd_queue; 842 p->queue = pd_queue;
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index 7adeb1edbf43..f21b520ef419 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -294,7 +294,6 @@ static void __init pf_init_units(void)
294 disk->first_minor = unit; 294 disk->first_minor = unit;
295 strcpy(disk->disk_name, pf->name); 295 strcpy(disk->disk_name, pf->name);
296 disk->fops = &pf_fops; 296 disk->fops = &pf_fops;
297 disk->events = DISK_EVENT_MEDIA_CHANGE;
298 if (!(*drives[unit])[D_PRT]) 297 if (!(*drives[unit])[D_PRT])
299 pf_drive_count++; 298 pf_drive_count++;
300 } 299 }
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 16dc3645291c..9712fad82bc6 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -92,6 +92,8 @@ struct rbd_client {
92 struct list_head node; 92 struct list_head node;
93}; 93};
94 94
95struct rbd_req_coll;
96
95/* 97/*
96 * a single io request 98 * a single io request
97 */ 99 */
@@ -100,6 +102,24 @@ struct rbd_request {
100 struct bio *bio; /* cloned bio */ 102 struct bio *bio; /* cloned bio */
101 struct page **pages; /* list of used pages */ 103 struct page **pages; /* list of used pages */
102 u64 len; 104 u64 len;
105 int coll_index;
106 struct rbd_req_coll *coll;
107};
108
109struct rbd_req_status {
110 int done;
111 int rc;
112 u64 bytes;
113};
114
115/*
116 * a collection of requests
117 */
118struct rbd_req_coll {
119 int total;
120 int num_done;
121 struct kref kref;
122 struct rbd_req_status status[0];
103}; 123};
104 124
105struct rbd_snap { 125struct rbd_snap {
@@ -416,6 +436,17 @@ static void rbd_put_client(struct rbd_device *rbd_dev)
416 rbd_dev->client = NULL; 436 rbd_dev->client = NULL;
417} 437}
418 438
439/*
440 * Destroy requests collection
441 */
442static void rbd_coll_release(struct kref *kref)
443{
444 struct rbd_req_coll *coll =
445 container_of(kref, struct rbd_req_coll, kref);
446
447 dout("rbd_coll_release %p\n", coll);
448 kfree(coll);
449}
419 450
420/* 451/*
421 * Create a new header structure, translate header format from the on-disk 452 * Create a new header structure, translate header format from the on-disk
@@ -590,6 +621,14 @@ static u64 rbd_get_segment(struct rbd_image_header *header,
590 return len; 621 return len;
591} 622}
592 623
624static int rbd_get_num_segments(struct rbd_image_header *header,
625 u64 ofs, u64 len)
626{
627 u64 start_seg = ofs >> header->obj_order;
628 u64 end_seg = (ofs + len - 1) >> header->obj_order;
629 return end_seg - start_seg + 1;
630}
631
593/* 632/*
594 * bio helpers 633 * bio helpers
595 */ 634 */
@@ -735,6 +774,50 @@ static void rbd_destroy_ops(struct ceph_osd_req_op *ops)
735 kfree(ops); 774 kfree(ops);
736} 775}
737 776
777static void rbd_coll_end_req_index(struct request *rq,
778 struct rbd_req_coll *coll,
779 int index,
780 int ret, u64 len)
781{
782 struct request_queue *q;
783 int min, max, i;
784
785 dout("rbd_coll_end_req_index %p index %d ret %d len %lld\n",
786 coll, index, ret, len);
787
788 if (!rq)
789 return;
790
791 if (!coll) {
792 blk_end_request(rq, ret, len);
793 return;
794 }
795
796 q = rq->q;
797
798 spin_lock_irq(q->queue_lock);
799 coll->status[index].done = 1;
800 coll->status[index].rc = ret;
801 coll->status[index].bytes = len;
802 max = min = coll->num_done;
803 while (max < coll->total && coll->status[max].done)
804 max++;
805
806 for (i = min; i<max; i++) {
807 __blk_end_request(rq, coll->status[i].rc,
808 coll->status[i].bytes);
809 coll->num_done++;
810 kref_put(&coll->kref, rbd_coll_release);
811 }
812 spin_unlock_irq(q->queue_lock);
813}
814
815static void rbd_coll_end_req(struct rbd_request *req,
816 int ret, u64 len)
817{
818 rbd_coll_end_req_index(req->rq, req->coll, req->coll_index, ret, len);
819}
820
738/* 821/*
739 * Send ceph osd request 822 * Send ceph osd request
740 */ 823 */
@@ -749,6 +832,8 @@ static int rbd_do_request(struct request *rq,
749 int flags, 832 int flags,
750 struct ceph_osd_req_op *ops, 833 struct ceph_osd_req_op *ops,
751 int num_reply, 834 int num_reply,
835 struct rbd_req_coll *coll,
836 int coll_index,
752 void (*rbd_cb)(struct ceph_osd_request *req, 837 void (*rbd_cb)(struct ceph_osd_request *req,
753 struct ceph_msg *msg), 838 struct ceph_msg *msg),
754 struct ceph_osd_request **linger_req, 839 struct ceph_osd_request **linger_req,
@@ -763,12 +848,20 @@ static int rbd_do_request(struct request *rq,
763 struct ceph_osd_request_head *reqhead; 848 struct ceph_osd_request_head *reqhead;
764 struct rbd_image_header *header = &dev->header; 849 struct rbd_image_header *header = &dev->header;
765 850
766 ret = -ENOMEM;
767 req_data = kzalloc(sizeof(*req_data), GFP_NOIO); 851 req_data = kzalloc(sizeof(*req_data), GFP_NOIO);
768 if (!req_data) 852 if (!req_data) {
769 goto done; 853 if (coll)
854 rbd_coll_end_req_index(rq, coll, coll_index,
855 -ENOMEM, len);
856 return -ENOMEM;
857 }
770 858
771 dout("rbd_do_request len=%lld ofs=%lld\n", len, ofs); 859 if (coll) {
860 req_data->coll = coll;
861 req_data->coll_index = coll_index;
862 }
863
864 dout("rbd_do_request obj=%s ofs=%lld len=%lld\n", obj, len, ofs);
772 865
773 down_read(&header->snap_rwsem); 866 down_read(&header->snap_rwsem);
774 867
@@ -777,9 +870,9 @@ static int rbd_do_request(struct request *rq,
777 ops, 870 ops,
778 false, 871 false,
779 GFP_NOIO, pages, bio); 872 GFP_NOIO, pages, bio);
780 if (IS_ERR(req)) { 873 if (!req) {
781 up_read(&header->snap_rwsem); 874 up_read(&header->snap_rwsem);
782 ret = PTR_ERR(req); 875 ret = -ENOMEM;
783 goto done_pages; 876 goto done_pages;
784 } 877 }
785 878
@@ -828,7 +921,8 @@ static int rbd_do_request(struct request *rq,
828 ret = ceph_osdc_wait_request(&dev->client->osdc, req); 921 ret = ceph_osdc_wait_request(&dev->client->osdc, req);
829 if (ver) 922 if (ver)
830 *ver = le64_to_cpu(req->r_reassert_version.version); 923 *ver = le64_to_cpu(req->r_reassert_version.version);
831 dout("reassert_ver=%lld\n", le64_to_cpu(req->r_reassert_version.version)); 924 dout("reassert_ver=%lld\n",
925 le64_to_cpu(req->r_reassert_version.version));
832 ceph_osdc_put_request(req); 926 ceph_osdc_put_request(req);
833 } 927 }
834 return ret; 928 return ret;
@@ -837,10 +931,8 @@ done_err:
837 bio_chain_put(req_data->bio); 931 bio_chain_put(req_data->bio);
838 ceph_osdc_put_request(req); 932 ceph_osdc_put_request(req);
839done_pages: 933done_pages:
934 rbd_coll_end_req(req_data, ret, len);
840 kfree(req_data); 935 kfree(req_data);
841done:
842 if (rq)
843 blk_end_request(rq, ret, len);
844 return ret; 936 return ret;
845} 937}
846 938
@@ -874,7 +966,7 @@ static void rbd_req_cb(struct ceph_osd_request *req, struct ceph_msg *msg)
874 bytes = req_data->len; 966 bytes = req_data->len;
875 } 967 }
876 968
877 blk_end_request(req_data->rq, rc, bytes); 969 rbd_coll_end_req(req_data, rc, bytes);
878 970
879 if (req_data->bio) 971 if (req_data->bio)
880 bio_chain_put(req_data->bio); 972 bio_chain_put(req_data->bio);
@@ -934,6 +1026,7 @@ static int rbd_req_sync_op(struct rbd_device *dev,
934 flags, 1026 flags,
935 ops, 1027 ops,
936 2, 1028 2,
1029 NULL, 0,
937 NULL, 1030 NULL,
938 linger_req, ver); 1031 linger_req, ver);
939 if (ret < 0) 1032 if (ret < 0)
@@ -959,7 +1052,9 @@ static int rbd_do_op(struct request *rq,
959 u64 snapid, 1052 u64 snapid,
960 int opcode, int flags, int num_reply, 1053 int opcode, int flags, int num_reply,
961 u64 ofs, u64 len, 1054 u64 ofs, u64 len,
962 struct bio *bio) 1055 struct bio *bio,
1056 struct rbd_req_coll *coll,
1057 int coll_index)
963{ 1058{
964 char *seg_name; 1059 char *seg_name;
965 u64 seg_ofs; 1060 u64 seg_ofs;
@@ -995,7 +1090,10 @@ static int rbd_do_op(struct request *rq,
995 flags, 1090 flags,
996 ops, 1091 ops,
997 num_reply, 1092 num_reply,
1093 coll, coll_index,
998 rbd_req_cb, 0, NULL); 1094 rbd_req_cb, 0, NULL);
1095
1096 rbd_destroy_ops(ops);
999done: 1097done:
1000 kfree(seg_name); 1098 kfree(seg_name);
1001 return ret; 1099 return ret;
@@ -1008,13 +1106,15 @@ static int rbd_req_write(struct request *rq,
1008 struct rbd_device *rbd_dev, 1106 struct rbd_device *rbd_dev,
1009 struct ceph_snap_context *snapc, 1107 struct ceph_snap_context *snapc,
1010 u64 ofs, u64 len, 1108 u64 ofs, u64 len,
1011 struct bio *bio) 1109 struct bio *bio,
1110 struct rbd_req_coll *coll,
1111 int coll_index)
1012{ 1112{
1013 return rbd_do_op(rq, rbd_dev, snapc, CEPH_NOSNAP, 1113 return rbd_do_op(rq, rbd_dev, snapc, CEPH_NOSNAP,
1014 CEPH_OSD_OP_WRITE, 1114 CEPH_OSD_OP_WRITE,
1015 CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, 1115 CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK,
1016 2, 1116 2,
1017 ofs, len, bio); 1117 ofs, len, bio, coll, coll_index);
1018} 1118}
1019 1119
1020/* 1120/*
@@ -1024,14 +1124,16 @@ static int rbd_req_read(struct request *rq,
1024 struct rbd_device *rbd_dev, 1124 struct rbd_device *rbd_dev,
1025 u64 snapid, 1125 u64 snapid,
1026 u64 ofs, u64 len, 1126 u64 ofs, u64 len,
1027 struct bio *bio) 1127 struct bio *bio,
1128 struct rbd_req_coll *coll,
1129 int coll_index)
1028{ 1130{
1029 return rbd_do_op(rq, rbd_dev, NULL, 1131 return rbd_do_op(rq, rbd_dev, NULL,
1030 (snapid ? snapid : CEPH_NOSNAP), 1132 (snapid ? snapid : CEPH_NOSNAP),
1031 CEPH_OSD_OP_READ, 1133 CEPH_OSD_OP_READ,
1032 CEPH_OSD_FLAG_READ, 1134 CEPH_OSD_FLAG_READ,
1033 2, 1135 2,
1034 ofs, len, bio); 1136 ofs, len, bio, coll, coll_index);
1035} 1137}
1036 1138
1037/* 1139/*
@@ -1063,7 +1165,9 @@ static int rbd_req_sync_notify_ack(struct rbd_device *dev,
1063{ 1165{
1064 struct ceph_osd_req_op *ops; 1166 struct ceph_osd_req_op *ops;
1065 struct page **pages = NULL; 1167 struct page **pages = NULL;
1066 int ret = rbd_create_rw_ops(&ops, 1, CEPH_OSD_OP_NOTIFY_ACK, 0); 1168 int ret;
1169
1170 ret = rbd_create_rw_ops(&ops, 1, CEPH_OSD_OP_NOTIFY_ACK, 0);
1067 if (ret < 0) 1171 if (ret < 0)
1068 return ret; 1172 return ret;
1069 1173
@@ -1077,6 +1181,7 @@ static int rbd_req_sync_notify_ack(struct rbd_device *dev,
1077 CEPH_OSD_FLAG_READ, 1181 CEPH_OSD_FLAG_READ,
1078 ops, 1182 ops,
1079 1, 1183 1,
1184 NULL, 0,
1080 rbd_simple_req_cb, 0, NULL); 1185 rbd_simple_req_cb, 0, NULL);
1081 1186
1082 rbd_destroy_ops(ops); 1187 rbd_destroy_ops(ops);
@@ -1274,6 +1379,20 @@ static int rbd_req_sync_exec(struct rbd_device *dev,
1274 return ret; 1379 return ret;
1275} 1380}
1276 1381
1382static struct rbd_req_coll *rbd_alloc_coll(int num_reqs)
1383{
1384 struct rbd_req_coll *coll =
1385 kzalloc(sizeof(struct rbd_req_coll) +
1386 sizeof(struct rbd_req_status) * num_reqs,
1387 GFP_ATOMIC);
1388
1389 if (!coll)
1390 return NULL;
1391 coll->total = num_reqs;
1392 kref_init(&coll->kref);
1393 return coll;
1394}
1395
1277/* 1396/*
1278 * block device queue callback 1397 * block device queue callback
1279 */ 1398 */
@@ -1291,6 +1410,8 @@ static void rbd_rq_fn(struct request_queue *q)
1291 bool do_write; 1410 bool do_write;
1292 int size, op_size = 0; 1411 int size, op_size = 0;
1293 u64 ofs; 1412 u64 ofs;
1413 int num_segs, cur_seg = 0;
1414 struct rbd_req_coll *coll;
1294 1415
1295 /* peek at request from block layer */ 1416 /* peek at request from block layer */
1296 if (!rq) 1417 if (!rq)
@@ -1321,6 +1442,14 @@ static void rbd_rq_fn(struct request_queue *q)
1321 do_write ? "write" : "read", 1442 do_write ? "write" : "read",
1322 size, blk_rq_pos(rq) * 512ULL); 1443 size, blk_rq_pos(rq) * 512ULL);
1323 1444
1445 num_segs = rbd_get_num_segments(&rbd_dev->header, ofs, size);
1446 coll = rbd_alloc_coll(num_segs);
1447 if (!coll) {
1448 spin_lock_irq(q->queue_lock);
1449 __blk_end_request_all(rq, -ENOMEM);
1450 goto next;
1451 }
1452
1324 do { 1453 do {
1325 /* a bio clone to be passed down to OSD req */ 1454 /* a bio clone to be passed down to OSD req */
1326 dout("rq->bio->bi_vcnt=%d\n", rq->bio->bi_vcnt); 1455 dout("rq->bio->bi_vcnt=%d\n", rq->bio->bi_vcnt);
@@ -1328,35 +1457,41 @@ static void rbd_rq_fn(struct request_queue *q)
1328 rbd_dev->header.block_name, 1457 rbd_dev->header.block_name,
1329 ofs, size, 1458 ofs, size,
1330 NULL, NULL); 1459 NULL, NULL);
1460 kref_get(&coll->kref);
1331 bio = bio_chain_clone(&rq_bio, &next_bio, &bp, 1461 bio = bio_chain_clone(&rq_bio, &next_bio, &bp,
1332 op_size, GFP_ATOMIC); 1462 op_size, GFP_ATOMIC);
1333 if (!bio) { 1463 if (!bio) {
1334 spin_lock_irq(q->queue_lock); 1464 rbd_coll_end_req_index(rq, coll, cur_seg,
1335 __blk_end_request_all(rq, -ENOMEM); 1465 -ENOMEM, op_size);
1336 goto next; 1466 goto next_seg;
1337 } 1467 }
1338 1468
1469
1339 /* init OSD command: write or read */ 1470 /* init OSD command: write or read */
1340 if (do_write) 1471 if (do_write)
1341 rbd_req_write(rq, rbd_dev, 1472 rbd_req_write(rq, rbd_dev,
1342 rbd_dev->header.snapc, 1473 rbd_dev->header.snapc,
1343 ofs, 1474 ofs,
1344 op_size, bio); 1475 op_size, bio,
1476 coll, cur_seg);
1345 else 1477 else
1346 rbd_req_read(rq, rbd_dev, 1478 rbd_req_read(rq, rbd_dev,
1347 cur_snap_id(rbd_dev), 1479 cur_snap_id(rbd_dev),
1348 ofs, 1480 ofs,
1349 op_size, bio); 1481 op_size, bio,
1482 coll, cur_seg);
1350 1483
1484next_seg:
1351 size -= op_size; 1485 size -= op_size;
1352 ofs += op_size; 1486 ofs += op_size;
1353 1487
1488 cur_seg++;
1354 rq_bio = next_bio; 1489 rq_bio = next_bio;
1355 } while (size > 0); 1490 } while (size > 0);
1491 kref_put(&coll->kref, rbd_coll_release);
1356 1492
1357 if (bp) 1493 if (bp)
1358 bio_pair_release(bp); 1494 bio_pair_release(bp);
1359
1360 spin_lock_irq(q->queue_lock); 1495 spin_lock_irq(q->queue_lock);
1361next: 1496next:
1362 rq = blk_fetch_request(q); 1497 rq = blk_fetch_request(q);
diff --git a/drivers/block/swim.c b/drivers/block/swim.c
index 24a482f2fbd6..fd5adcd55944 100644
--- a/drivers/block/swim.c
+++ b/drivers/block/swim.c
@@ -858,7 +858,6 @@ static int __devinit swim_floppy_init(struct swim_priv *swd)
858 swd->unit[drive].disk->first_minor = drive; 858 swd->unit[drive].disk->first_minor = drive;
859 sprintf(swd->unit[drive].disk->disk_name, "fd%d", drive); 859 sprintf(swd->unit[drive].disk->disk_name, "fd%d", drive);
860 swd->unit[drive].disk->fops = &floppy_fops; 860 swd->unit[drive].disk->fops = &floppy_fops;
861 swd->unit[drive].disk->events = DISK_EVENT_MEDIA_CHANGE;
862 swd->unit[drive].disk->private_data = &swd->unit[drive]; 861 swd->unit[drive].disk->private_data = &swd->unit[drive];
863 swd->unit[drive].disk->queue = swd->queue; 862 swd->unit[drive].disk->queue = swd->queue;
864 set_capacity(swd->unit[drive].disk, 2880); 863 set_capacity(swd->unit[drive].disk, 2880);
diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c
index 4c10f56facbf..773bfa792777 100644
--- a/drivers/block/swim3.c
+++ b/drivers/block/swim3.c
@@ -1163,7 +1163,6 @@ static int __devinit swim3_attach(struct macio_dev *mdev, const struct of_device
1163 disk->major = FLOPPY_MAJOR; 1163 disk->major = FLOPPY_MAJOR;
1164 disk->first_minor = i; 1164 disk->first_minor = i;
1165 disk->fops = &floppy_fops; 1165 disk->fops = &floppy_fops;
1166 disk->events = DISK_EVENT_MEDIA_CHANGE;
1167 disk->private_data = &floppy_states[i]; 1166 disk->private_data = &floppy_states[i];
1168 disk->queue = swim3_queue; 1167 disk->queue = swim3_queue;
1169 disk->flags |= GENHD_FL_REMOVABLE; 1168 disk->flags |= GENHD_FL_REMOVABLE;
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index 68b9430c7cfe..0e376d46bdd1 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -2334,7 +2334,6 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum)
2334 disk->major = UB_MAJOR; 2334 disk->major = UB_MAJOR;
2335 disk->first_minor = lun->id * UB_PARTS_PER_LUN; 2335 disk->first_minor = lun->id * UB_PARTS_PER_LUN;
2336 disk->fops = &ub_bd_fops; 2336 disk->fops = &ub_bd_fops;
2337 disk->events = DISK_EVENT_MEDIA_CHANGE;
2338 disk->private_data = lun; 2337 disk->private_data = lun;
2339 disk->driverfs_dev = &sc->intf->dev; 2338 disk->driverfs_dev = &sc->intf->dev;
2340 2339
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
index 645ff765cd12..6c7fd7db6dff 100644
--- a/drivers/block/xsysace.c
+++ b/drivers/block/xsysace.c
@@ -1005,7 +1005,6 @@ static int __devinit ace_setup(struct ace_device *ace)
1005 ace->gd->major = ace_major; 1005 ace->gd->major = ace_major;
1006 ace->gd->first_minor = ace->id * ACE_NUM_MINORS; 1006 ace->gd->first_minor = ace->id * ACE_NUM_MINORS;
1007 ace->gd->fops = &ace_fops; 1007 ace->gd->fops = &ace_fops;
1008 ace->gd->events = DISK_EVENT_MEDIA_CHANGE;
1009 ace->gd->queue = ace->queue; 1008 ace->gd->queue = ace->queue;
1010 ace->gd->private_data = ace; 1009 ace->gd->private_data = ace;
1011 snprintf(ace->gd->disk_name, 32, "xs%c", ace->id + 'a'); 1010 snprintf(ace->gd->disk_name, 32, "xs%c", ace->id + 'a');
diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
index b2b034fea34e..3ceaf006e7f0 100644
--- a/drivers/cdrom/gdrom.c
+++ b/drivers/cdrom/gdrom.c
@@ -803,7 +803,6 @@ static int __devinit probe_gdrom(struct platform_device *devptr)
803 goto probe_fail_cdrom_register; 803 goto probe_fail_cdrom_register;
804 } 804 }
805 gd.disk->fops = &gdrom_bdops; 805 gd.disk->fops = &gdrom_bdops;
806 gd.disk->events = DISK_EVENT_MEDIA_CHANGE;
807 /* latch on to the interrupt */ 806 /* latch on to the interrupt */
808 err = gdrom_set_interrupt_handlers(); 807 err = gdrom_set_interrupt_handlers();
809 if (err) 808 if (err)
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index 012cba0d6d96..b072648dc3f6 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -115,6 +115,9 @@ static struct agp_memory *agp_create_user_memory(unsigned long num_agp_pages)
115 struct agp_memory *new; 115 struct agp_memory *new;
116 unsigned long alloc_size = num_agp_pages*sizeof(struct page *); 116 unsigned long alloc_size = num_agp_pages*sizeof(struct page *);
117 117
118 if (INT_MAX/sizeof(struct page *) < num_agp_pages)
119 return NULL;
120
118 new = kzalloc(sizeof(struct agp_memory), GFP_KERNEL); 121 new = kzalloc(sizeof(struct agp_memory), GFP_KERNEL);
119 if (new == NULL) 122 if (new == NULL)
120 return NULL; 123 return NULL;
@@ -234,11 +237,14 @@ struct agp_memory *agp_allocate_memory(struct agp_bridge_data *bridge,
234 int scratch_pages; 237 int scratch_pages;
235 struct agp_memory *new; 238 struct agp_memory *new;
236 size_t i; 239 size_t i;
240 int cur_memory;
237 241
238 if (!bridge) 242 if (!bridge)
239 return NULL; 243 return NULL;
240 244
241 if ((atomic_read(&bridge->current_memory_agp) + page_count) > bridge->max_memory_agp) 245 cur_memory = atomic_read(&bridge->current_memory_agp);
246 if ((cur_memory + page_count > bridge->max_memory_agp) ||
247 (cur_memory + page_count < page_count))
242 return NULL; 248 return NULL;
243 249
244 if (type >= AGP_USER_TYPES) { 250 if (type >= AGP_USER_TYPES) {
@@ -1089,8 +1095,8 @@ int agp_generic_insert_memory(struct agp_memory * mem, off_t pg_start, int type)
1089 return -EINVAL; 1095 return -EINVAL;
1090 } 1096 }
1091 1097
1092 /* AK: could wrap */ 1098 if (((pg_start + mem->page_count) > num_entries) ||
1093 if ((pg_start + mem->page_count) > num_entries) 1099 ((pg_start + mem->page_count) < pg_start))
1094 return -EINVAL; 1100 return -EINVAL;
1095 1101
1096 j = pg_start; 1102 j = pg_start;
@@ -1124,7 +1130,7 @@ int agp_generic_remove_memory(struct agp_memory *mem, off_t pg_start, int type)
1124{ 1130{
1125 size_t i; 1131 size_t i;
1126 struct agp_bridge_data *bridge; 1132 struct agp_bridge_data *bridge;
1127 int mask_type; 1133 int mask_type, num_entries;
1128 1134
1129 bridge = mem->bridge; 1135 bridge = mem->bridge;
1130 if (!bridge) 1136 if (!bridge)
@@ -1136,6 +1142,11 @@ int agp_generic_remove_memory(struct agp_memory *mem, off_t pg_start, int type)
1136 if (type != mem->type) 1142 if (type != mem->type)
1137 return -EINVAL; 1143 return -EINVAL;
1138 1144
1145 num_entries = agp_num_entries();
1146 if (((pg_start + mem->page_count) > num_entries) ||
1147 ((pg_start + mem->page_count) < pg_start))
1148 return -EINVAL;
1149
1139 mask_type = bridge->driver->agp_type_to_mask_type(bridge, type); 1150 mask_type = bridge->driver->agp_type_to_mask_type(bridge, type);
1140 if (mask_type != 0) { 1151 if (mask_type != 0) {
1141 /* The generic routines know nothing of memory types */ 1152 /* The generic routines know nothing of memory types */
diff --git a/drivers/char/hw_random/n2-drv.c b/drivers/char/hw_random/n2-drv.c
index 43ac61978d8b..ac6739e085e3 100644
--- a/drivers/char/hw_random/n2-drv.c
+++ b/drivers/char/hw_random/n2-drv.c
@@ -619,15 +619,18 @@ static void __devinit n2rng_driver_version(void)
619 pr_info("%s", version); 619 pr_info("%s", version);
620} 620}
621 621
622static const struct of_device_id n2rng_match[];
622static int __devinit n2rng_probe(struct platform_device *op) 623static int __devinit n2rng_probe(struct platform_device *op)
623{ 624{
625 const struct of_device_id *match;
624 int victoria_falls; 626 int victoria_falls;
625 int err = -ENOMEM; 627 int err = -ENOMEM;
626 struct n2rng *np; 628 struct n2rng *np;
627 629
628 if (!op->dev.of_match) 630 match = of_match_device(n2rng_match, &op->dev);
631 if (!match)
629 return -EINVAL; 632 return -EINVAL;
630 victoria_falls = (op->dev.of_match->data != NULL); 633 victoria_falls = (match->data != NULL);
631 634
632 n2rng_driver_version(); 635 n2rng_driver_version();
633 np = kzalloc(sizeof(*np), GFP_KERNEL); 636 np = kzalloc(sizeof(*np), GFP_KERNEL);
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index cc6c9b2546a3..64c6b8530615 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -2554,9 +2554,11 @@ static struct pci_driver ipmi_pci_driver = {
2554}; 2554};
2555#endif /* CONFIG_PCI */ 2555#endif /* CONFIG_PCI */
2556 2556
2557static struct of_device_id ipmi_match[];
2557static int __devinit ipmi_probe(struct platform_device *dev) 2558static int __devinit ipmi_probe(struct platform_device *dev)
2558{ 2559{
2559#ifdef CONFIG_OF 2560#ifdef CONFIG_OF
2561 const struct of_device_id *match;
2560 struct smi_info *info; 2562 struct smi_info *info;
2561 struct resource resource; 2563 struct resource resource;
2562 const __be32 *regsize, *regspacing, *regshift; 2564 const __be32 *regsize, *regspacing, *regshift;
@@ -2566,7 +2568,8 @@ static int __devinit ipmi_probe(struct platform_device *dev)
2566 2568
2567 dev_info(&dev->dev, "probing via device tree\n"); 2569 dev_info(&dev->dev, "probing via device tree\n");
2568 2570
2569 if (!dev->dev.of_match) 2571 match = of_match_device(ipmi_match, &dev->dev);
2572 if (!match)
2570 return -EINVAL; 2573 return -EINVAL;
2571 2574
2572 ret = of_address_to_resource(np, 0, &resource); 2575 ret = of_address_to_resource(np, 0, &resource);
@@ -2601,7 +2604,7 @@ static int __devinit ipmi_probe(struct platform_device *dev)
2601 return -ENOMEM; 2604 return -ENOMEM;
2602 } 2605 }
2603 2606
2604 info->si_type = (enum si_type) dev->dev.of_match->data; 2607 info->si_type = (enum si_type) match->data;
2605 info->addr_source = SI_DEVICETREE; 2608 info->addr_source = SI_DEVICETREE;
2606 info->irq_setup = std_irq_setup; 2609 info->irq_setup = std_irq_setup;
2607 2610
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 84b164d1eb2b..838568a7dbf5 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1280,18 +1280,7 @@ static void unplug_port(struct port *port)
1280 spin_lock_irq(&pdrvdata_lock); 1280 spin_lock_irq(&pdrvdata_lock);
1281 list_del(&port->cons.list); 1281 list_del(&port->cons.list);
1282 spin_unlock_irq(&pdrvdata_lock); 1282 spin_unlock_irq(&pdrvdata_lock);
1283#if 0
1284 /*
1285 * hvc_remove() not called as removing one hvc port
1286 * results in other hvc ports getting frozen.
1287 *
1288 * Once this is resolved in hvc, this functionality
1289 * will be enabled. Till that is done, the -EPIPE
1290 * return from get_chars() above will help
1291 * hvc_console.c to clean up on ports we remove here.
1292 */
1293 hvc_remove(port->cons.hvc); 1283 hvc_remove(port->cons.hvc);
1294#endif
1295 } 1284 }
1296 1285
1297 /* Remove unused data this port might have received. */ 1286 /* Remove unused data this port might have received. */
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
index d6412c16385f..39ccdeada791 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
@@ -715,13 +715,13 @@ static int __devexit hwicap_remove(struct device *dev)
715} 715}
716 716
717#ifdef CONFIG_OF 717#ifdef CONFIG_OF
718static int __devinit hwicap_of_probe(struct platform_device *op) 718static int __devinit hwicap_of_probe(struct platform_device *op,
719 const struct hwicap_driver_config *config)
719{ 720{
720 struct resource res; 721 struct resource res;
721 const unsigned int *id; 722 const unsigned int *id;
722 const char *family; 723 const char *family;
723 int rc; 724 int rc;
724 const struct hwicap_driver_config *config = op->dev.of_match->data;
725 const struct config_registers *regs; 725 const struct config_registers *regs;
726 726
727 727
@@ -751,20 +751,24 @@ static int __devinit hwicap_of_probe(struct platform_device *op)
751 regs); 751 regs);
752} 752}
753#else 753#else
754static inline int hwicap_of_probe(struct platform_device *op) 754static inline int hwicap_of_probe(struct platform_device *op,
755 const struct hwicap_driver_config *config)
755{ 756{
756 return -EINVAL; 757 return -EINVAL;
757} 758}
758#endif /* CONFIG_OF */ 759#endif /* CONFIG_OF */
759 760
761static const struct of_device_id __devinitconst hwicap_of_match[];
760static int __devinit hwicap_drv_probe(struct platform_device *pdev) 762static int __devinit hwicap_drv_probe(struct platform_device *pdev)
761{ 763{
764 const struct of_device_id *match;
762 struct resource *res; 765 struct resource *res;
763 const struct config_registers *regs; 766 const struct config_registers *regs;
764 const char *family; 767 const char *family;
765 768
766 if (pdev->dev.of_match) 769 match = of_match_device(hwicap_of_match, &pdev->dev);
767 return hwicap_of_probe(pdev); 770 if (match)
771 return hwicap_of_probe(pdev, match->data);
768 772
769 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 773 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
770 if (!res) 774 if (!res)
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 0fc0a79852de..6db161f64ae0 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -32,10 +32,9 @@ static DEFINE_MUTEX(clocks_mutex);
32 * Then we take the most specific entry - with the following 32 * Then we take the most specific entry - with the following
33 * order of precedence: dev+con > dev only > con only. 33 * order of precedence: dev+con > dev only > con only.
34 */ 34 */
35static struct clk *clk_find(const char *dev_id, const char *con_id) 35static struct clk_lookup *clk_find(const char *dev_id, const char *con_id)
36{ 36{
37 struct clk_lookup *p; 37 struct clk_lookup *p, *cl = NULL;
38 struct clk *clk = NULL;
39 int match, best = 0; 38 int match, best = 0;
40 39
41 list_for_each_entry(p, &clocks, node) { 40 list_for_each_entry(p, &clocks, node) {
@@ -52,27 +51,27 @@ static struct clk *clk_find(const char *dev_id, const char *con_id)
52 } 51 }
53 52
54 if (match > best) { 53 if (match > best) {
55 clk = p->clk; 54 cl = p;
56 if (match != 3) 55 if (match != 3)
57 best = match; 56 best = match;
58 else 57 else
59 break; 58 break;
60 } 59 }
61 } 60 }
62 return clk; 61 return cl;
63} 62}
64 63
65struct clk *clk_get_sys(const char *dev_id, const char *con_id) 64struct clk *clk_get_sys(const char *dev_id, const char *con_id)
66{ 65{
67 struct clk *clk; 66 struct clk_lookup *cl;
68 67
69 mutex_lock(&clocks_mutex); 68 mutex_lock(&clocks_mutex);
70 clk = clk_find(dev_id, con_id); 69 cl = clk_find(dev_id, con_id);
71 if (clk && !__clk_get(clk)) 70 if (cl && !__clk_get(cl->clk))
72 clk = NULL; 71 cl = NULL;
73 mutex_unlock(&clocks_mutex); 72 mutex_unlock(&clocks_mutex);
74 73
75 return clk ? clk : ERR_PTR(-ENOENT); 74 return cl ? cl->clk : ERR_PTR(-ENOENT);
76} 75}
77EXPORT_SYMBOL(clk_get_sys); 76EXPORT_SYMBOL(clk_get_sys);
78 77
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index d77005849af8..219d88a0eeae 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -142,6 +142,7 @@ static int cn_call_callback(struct sk_buff *skb)
142 cbq->callback(msg, nsp); 142 cbq->callback(msg, nsp);
143 kfree_skb(skb); 143 kfree_skb(skb);
144 cn_queue_release_callback(cbq); 144 cn_queue_release_callback(cbq);
145 err = 0;
145 } 146 }
146 147
147 return err; 148 return err;
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 31e71c4fc831..9a8bebcf6b17 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -211,8 +211,6 @@ static int amd64_get_scrub_rate(struct mem_ctl_info *mci)
211 211
212 scrubval = scrubval & 0x001F; 212 scrubval = scrubval & 0x001F;
213 213
214 amd64_debug("pci-read, sdram scrub control value: %d\n", scrubval);
215
216 for (i = 0; i < ARRAY_SIZE(scrubrates); i++) { 214 for (i = 0; i < ARRAY_SIZE(scrubrates); i++) {
217 if (scrubrates[i].scrubval == scrubval) { 215 if (scrubrates[i].scrubval == scrubval) {
218 retval = scrubrates[i].bandwidth; 216 retval = scrubrates[i].bandwidth;
@@ -933,25 +931,74 @@ static int k8_early_channel_count(struct amd64_pvt *pvt)
933/* On F10h and later ErrAddr is MC4_ADDR[47:1] */ 931/* On F10h and later ErrAddr is MC4_ADDR[47:1] */
934static u64 get_error_address(struct mce *m) 932static u64 get_error_address(struct mce *m)
935{ 933{
934 struct cpuinfo_x86 *c = &boot_cpu_data;
935 u64 addr;
936 u8 start_bit = 1; 936 u8 start_bit = 1;
937 u8 end_bit = 47; 937 u8 end_bit = 47;
938 938
939 if (boot_cpu_data.x86 == 0xf) { 939 if (c->x86 == 0xf) {
940 start_bit = 3; 940 start_bit = 3;
941 end_bit = 39; 941 end_bit = 39;
942 } 942 }
943 943
944 return m->addr & GENMASK(start_bit, end_bit); 944 addr = m->addr & GENMASK(start_bit, end_bit);
945
946 /*
947 * Erratum 637 workaround
948 */
949 if (c->x86 == 0x15) {
950 struct amd64_pvt *pvt;
951 u64 cc6_base, tmp_addr;
952 u32 tmp;
953 u8 mce_nid, intlv_en;
954
955 if ((addr & GENMASK(24, 47)) >> 24 != 0x00fdf7)
956 return addr;
957
958 mce_nid = amd_get_nb_id(m->extcpu);
959 pvt = mcis[mce_nid]->pvt_info;
960
961 amd64_read_pci_cfg(pvt->F1, DRAM_LOCAL_NODE_LIM, &tmp);
962 intlv_en = tmp >> 21 & 0x7;
963
964 /* add [47:27] + 3 trailing bits */
965 cc6_base = (tmp & GENMASK(0, 20)) << 3;
966
967 /* reverse and add DramIntlvEn */
968 cc6_base |= intlv_en ^ 0x7;
969
970 /* pin at [47:24] */
971 cc6_base <<= 24;
972
973 if (!intlv_en)
974 return cc6_base | (addr & GENMASK(0, 23));
975
976 amd64_read_pci_cfg(pvt->F1, DRAM_LOCAL_NODE_BASE, &tmp);
977
978 /* faster log2 */
979 tmp_addr = (addr & GENMASK(12, 23)) << __fls(intlv_en + 1);
980
981 /* OR DramIntlvSel into bits [14:12] */
982 tmp_addr |= (tmp & GENMASK(21, 23)) >> 9;
983
984 /* add remaining [11:0] bits from original MC4_ADDR */
985 tmp_addr |= addr & GENMASK(0, 11);
986
987 return cc6_base | tmp_addr;
988 }
989
990 return addr;
945} 991}
946 992
947static void read_dram_base_limit_regs(struct amd64_pvt *pvt, unsigned range) 993static void read_dram_base_limit_regs(struct amd64_pvt *pvt, unsigned range)
948{ 994{
995 struct cpuinfo_x86 *c = &boot_cpu_data;
949 int off = range << 3; 996 int off = range << 3;
950 997
951 amd64_read_pci_cfg(pvt->F1, DRAM_BASE_LO + off, &pvt->ranges[range].base.lo); 998 amd64_read_pci_cfg(pvt->F1, DRAM_BASE_LO + off, &pvt->ranges[range].base.lo);
952 amd64_read_pci_cfg(pvt->F1, DRAM_LIMIT_LO + off, &pvt->ranges[range].lim.lo); 999 amd64_read_pci_cfg(pvt->F1, DRAM_LIMIT_LO + off, &pvt->ranges[range].lim.lo);
953 1000
954 if (boot_cpu_data.x86 == 0xf) 1001 if (c->x86 == 0xf)
955 return; 1002 return;
956 1003
957 if (!dram_rw(pvt, range)) 1004 if (!dram_rw(pvt, range))
@@ -959,6 +1006,31 @@ static void read_dram_base_limit_regs(struct amd64_pvt *pvt, unsigned range)
959 1006
960 amd64_read_pci_cfg(pvt->F1, DRAM_BASE_HI + off, &pvt->ranges[range].base.hi); 1007 amd64_read_pci_cfg(pvt->F1, DRAM_BASE_HI + off, &pvt->ranges[range].base.hi);
961 amd64_read_pci_cfg(pvt->F1, DRAM_LIMIT_HI + off, &pvt->ranges[range].lim.hi); 1008 amd64_read_pci_cfg(pvt->F1, DRAM_LIMIT_HI + off, &pvt->ranges[range].lim.hi);
1009
1010 /* Factor in CC6 save area by reading dst node's limit reg */
1011 if (c->x86 == 0x15) {
1012 struct pci_dev *f1 = NULL;
1013 u8 nid = dram_dst_node(pvt, range);
1014 u32 llim;
1015
1016 f1 = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(0x18 + nid, 1));
1017 if (WARN_ON(!f1))
1018 return;
1019
1020 amd64_read_pci_cfg(f1, DRAM_LOCAL_NODE_LIM, &llim);
1021
1022 pvt->ranges[range].lim.lo &= GENMASK(0, 15);
1023
1024 /* {[39:27],111b} */
1025 pvt->ranges[range].lim.lo |= ((llim & 0x1fff) << 3 | 0x7) << 16;
1026
1027 pvt->ranges[range].lim.hi &= GENMASK(0, 7);
1028
1029 /* [47:40] */
1030 pvt->ranges[range].lim.hi |= llim >> 13;
1031
1032 pci_dev_put(f1);
1033 }
962} 1034}
963 1035
964static void k8_map_sysaddr_to_csrow(struct mem_ctl_info *mci, u64 sys_addr, 1036static void k8_map_sysaddr_to_csrow(struct mem_ctl_info *mci, u64 sys_addr,
@@ -1403,12 +1475,8 @@ static int f1x_match_to_this_node(struct amd64_pvt *pvt, unsigned range,
1403 return -EINVAL; 1475 return -EINVAL;
1404 } 1476 }
1405 1477
1406 if (intlv_en && 1478 if (intlv_en && (intlv_sel != ((sys_addr >> 12) & intlv_en)))
1407 (intlv_sel != ((sys_addr >> 12) & intlv_en))) {
1408 amd64_warn("Botched intlv bits, en: 0x%x, sel: 0x%x\n",
1409 intlv_en, intlv_sel);
1410 return -EINVAL; 1479 return -EINVAL;
1411 }
1412 1480
1413 sys_addr = f1x_swap_interleaved_region(pvt, sys_addr); 1481 sys_addr = f1x_swap_interleaved_region(pvt, sys_addr);
1414 1482
diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h
index 11be36a311eb..9a666cb985b2 100644
--- a/drivers/edac/amd64_edac.h
+++ b/drivers/edac/amd64_edac.h
@@ -196,6 +196,9 @@
196 196
197#define DCT_CFG_SEL 0x10C 197#define DCT_CFG_SEL 0x10C
198 198
199#define DRAM_LOCAL_NODE_BASE 0x120
200#define DRAM_LOCAL_NODE_LIM 0x124
201
199#define DRAM_BASE_HI 0x140 202#define DRAM_BASE_HI 0x140
200#define DRAM_LIMIT_HI 0x144 203#define DRAM_LIMIT_HI 0x144
201 204
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 26343fd46596..29ffa350bfbe 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -458,13 +458,13 @@ static ssize_t mci_sdram_scrub_rate_store(struct mem_ctl_info *mci,
458 return -EINVAL; 458 return -EINVAL;
459 459
460 new_bw = mci->set_sdram_scrub_rate(mci, bandwidth); 460 new_bw = mci->set_sdram_scrub_rate(mci, bandwidth);
461 if (new_bw >= 0) { 461 if (new_bw < 0) {
462 edac_printk(KERN_DEBUG, EDAC_MC, "Scrub rate set to %d\n", new_bw); 462 edac_printk(KERN_WARNING, EDAC_MC,
463 return count; 463 "Error setting scrub rate to: %lu\n", bandwidth);
464 return -EINVAL;
464 } 465 }
465 466
466 edac_printk(KERN_DEBUG, EDAC_MC, "Error setting scrub rate to: %lu\n", bandwidth); 467 return count;
467 return -EINVAL;
468} 468}
469 469
470/* 470/*
@@ -483,7 +483,6 @@ static ssize_t mci_sdram_scrub_rate_show(struct mem_ctl_info *mci, char *data)
483 return bandwidth; 483 return bandwidth;
484 } 484 }
485 485
486 edac_printk(KERN_DEBUG, EDAC_MC, "Read scrub rate: %d\n", bandwidth);
487 return sprintf(data, "%d\n", bandwidth); 486 return sprintf(data, "%d\n", bandwidth);
488} 487}
489 488
diff --git a/drivers/edac/ppc4xx_edac.c b/drivers/edac/ppc4xx_edac.c
index c1f0045ceb8e..af8e7b1aa290 100644
--- a/drivers/edac/ppc4xx_edac.c
+++ b/drivers/edac/ppc4xx_edac.c
@@ -1019,7 +1019,7 @@ ppc4xx_edac_mc_init(struct mem_ctl_info *mci,
1019 struct ppc4xx_edac_pdata *pdata = NULL; 1019 struct ppc4xx_edac_pdata *pdata = NULL;
1020 const struct device_node *np = op->dev.of_node; 1020 const struct device_node *np = op->dev.of_node;
1021 1021
1022 if (op->dev.of_match == NULL) 1022 if (of_match_device(ppc4xx_edac_match, &op->dev) == NULL)
1023 return -EINVAL; 1023 return -EINVAL;
1024 1024
1025 /* Initial driver pointers and private data */ 1025 /* Initial driver pointers and private data */
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index f903d7b6f34a..23d1468ad253 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -2199,7 +2199,6 @@ static int ohci_set_config_rom(struct fw_card *card,
2199{ 2199{
2200 struct fw_ohci *ohci; 2200 struct fw_ohci *ohci;
2201 unsigned long flags; 2201 unsigned long flags;
2202 int ret = -EBUSY;
2203 __be32 *next_config_rom; 2202 __be32 *next_config_rom;
2204 dma_addr_t uninitialized_var(next_config_rom_bus); 2203 dma_addr_t uninitialized_var(next_config_rom_bus);
2205 2204
@@ -2240,22 +2239,37 @@ static int ohci_set_config_rom(struct fw_card *card,
2240 2239
2241 spin_lock_irqsave(&ohci->lock, flags); 2240 spin_lock_irqsave(&ohci->lock, flags);
2242 2241
2242 /*
2243 * If there is not an already pending config_rom update,
2244 * push our new allocation into the ohci->next_config_rom
2245 * and then mark the local variable as null so that we
2246 * won't deallocate the new buffer.
2247 *
2248 * OTOH, if there is a pending config_rom update, just
2249 * use that buffer with the new config_rom data, and
2250 * let this routine free the unused DMA allocation.
2251 */
2252
2243 if (ohci->next_config_rom == NULL) { 2253 if (ohci->next_config_rom == NULL) {
2244 ohci->next_config_rom = next_config_rom; 2254 ohci->next_config_rom = next_config_rom;
2245 ohci->next_config_rom_bus = next_config_rom_bus; 2255 ohci->next_config_rom_bus = next_config_rom_bus;
2256 next_config_rom = NULL;
2257 }
2246 2258
2247 copy_config_rom(ohci->next_config_rom, config_rom, length); 2259 copy_config_rom(ohci->next_config_rom, config_rom, length);
2248 2260
2249 ohci->next_header = config_rom[0]; 2261 ohci->next_header = config_rom[0];
2250 ohci->next_config_rom[0] = 0; 2262 ohci->next_config_rom[0] = 0;
2251 2263
2252 reg_write(ohci, OHCI1394_ConfigROMmap, 2264 reg_write(ohci, OHCI1394_ConfigROMmap, ohci->next_config_rom_bus);
2253 ohci->next_config_rom_bus);
2254 ret = 0;
2255 }
2256 2265
2257 spin_unlock_irqrestore(&ohci->lock, flags); 2266 spin_unlock_irqrestore(&ohci->lock, flags);
2258 2267
2268 /* If we didn't use the DMA allocation, delete it. */
2269 if (next_config_rom != NULL)
2270 dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE,
2271 next_config_rom, next_config_rom_bus);
2272
2259 /* 2273 /*
2260 * Now initiate a bus reset to have the changes take 2274 * Now initiate a bus reset to have the changes take
2261 * effect. We clean up the old config rom memory and DMA 2275 * effect. We clean up the old config rom memory and DMA
@@ -2263,13 +2277,10 @@ static int ohci_set_config_rom(struct fw_card *card,
2263 * controller could need to access it before the bus reset 2277 * controller could need to access it before the bus reset
2264 * takes effect. 2278 * takes effect.
2265 */ 2279 */
2266 if (ret == 0)
2267 fw_schedule_bus_reset(&ohci->card, true, true);
2268 else
2269 dma_free_coherent(ohci->card.device, CONFIG_ROM_SIZE,
2270 next_config_rom, next_config_rom_bus);
2271 2280
2272 return ret; 2281 fw_schedule_bus_reset(&ohci->card, true, true);
2282
2283 return 0;
2273} 2284}
2274 2285
2275static void ohci_send_request(struct fw_card *card, struct fw_packet *packet) 2286static void ohci_send_request(struct fw_card *card, struct fw_packet *packet)
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index c58f691ec3ce..b493663c7ba7 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -24,6 +24,7 @@ config DRM_KMS_HELPER
24 depends on DRM 24 depends on DRM
25 select FB 25 select FB
26 select FRAMEBUFFER_CONSOLE if !EXPERT 26 select FRAMEBUFFER_CONSOLE if !EXPERT
27 select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE
27 help 28 help
28 FB and CRTC helpers for KMS drivers. 29 FB and CRTC helpers for KMS drivers.
29 30
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 950720473967..140b9525b48a 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -342,9 +342,22 @@ int drm_fb_helper_debug_leave(struct fb_info *info)
342} 342}
343EXPORT_SYMBOL(drm_fb_helper_debug_leave); 343EXPORT_SYMBOL(drm_fb_helper_debug_leave);
344 344
345bool drm_fb_helper_restore_fbdev_mode(struct drm_fb_helper *fb_helper)
346{
347 bool error = false;
348 int i, ret;
349 for (i = 0; i < fb_helper->crtc_count; i++) {
350 struct drm_mode_set *mode_set = &fb_helper->crtc_info[i].mode_set;
351 ret = drm_crtc_helper_set_config(mode_set);
352 if (ret)
353 error = true;
354 }
355 return error;
356}
357EXPORT_SYMBOL(drm_fb_helper_restore_fbdev_mode);
358
345bool drm_fb_helper_force_kernel_mode(void) 359bool drm_fb_helper_force_kernel_mode(void)
346{ 360{
347 int i = 0;
348 bool ret, error = false; 361 bool ret, error = false;
349 struct drm_fb_helper *helper; 362 struct drm_fb_helper *helper;
350 363
@@ -352,12 +365,12 @@ bool drm_fb_helper_force_kernel_mode(void)
352 return false; 365 return false;
353 366
354 list_for_each_entry(helper, &kernel_fb_helper_list, kernel_fb_list) { 367 list_for_each_entry(helper, &kernel_fb_helper_list, kernel_fb_list) {
355 for (i = 0; i < helper->crtc_count; i++) { 368 if (helper->dev->switch_power_state == DRM_SWITCH_POWER_OFF)
356 struct drm_mode_set *mode_set = &helper->crtc_info[i].mode_set; 369 continue;
357 ret = drm_crtc_helper_set_config(mode_set); 370
358 if (ret) 371 ret = drm_fb_helper_restore_fbdev_mode(helper);
359 error = true; 372 if (ret)
360 } 373 error = true;
361 } 374 }
362 return error; 375 return error;
363} 376}
@@ -1503,17 +1516,33 @@ bool drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel)
1503} 1516}
1504EXPORT_SYMBOL(drm_fb_helper_initial_config); 1517EXPORT_SYMBOL(drm_fb_helper_initial_config);
1505 1518
1506bool drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper) 1519/**
1520 * drm_fb_helper_hotplug_event - respond to a hotplug notification by
1521 * probing all the outputs attached to the fb.
1522 * @fb_helper: the drm_fb_helper
1523 *
1524 * LOCKING:
1525 * Called at runtime, must take mode config lock.
1526 *
1527 * Scan the connectors attached to the fb_helper and try to put together a
1528 * setup after *notification of a change in output configuration.
1529 *
1530 * RETURNS:
1531 * 0 on success and a non-zero error code otherwise.
1532 */
1533int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper)
1507{ 1534{
1535 struct drm_device *dev = fb_helper->dev;
1508 int count = 0; 1536 int count = 0;
1509 u32 max_width, max_height, bpp_sel; 1537 u32 max_width, max_height, bpp_sel;
1510 bool bound = false, crtcs_bound = false; 1538 bool bound = false, crtcs_bound = false;
1511 struct drm_crtc *crtc; 1539 struct drm_crtc *crtc;
1512 1540
1513 if (!fb_helper->fb) 1541 if (!fb_helper->fb)
1514 return false; 1542 return 0;
1515 1543
1516 list_for_each_entry(crtc, &fb_helper->dev->mode_config.crtc_list, head) { 1544 mutex_lock(&dev->mode_config.mutex);
1545 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
1517 if (crtc->fb) 1546 if (crtc->fb)
1518 crtcs_bound = true; 1547 crtcs_bound = true;
1519 if (crtc->fb == fb_helper->fb) 1548 if (crtc->fb == fb_helper->fb)
@@ -1522,7 +1551,8 @@ bool drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper)
1522 1551
1523 if (!bound && crtcs_bound) { 1552 if (!bound && crtcs_bound) {
1524 fb_helper->delayed_hotplug = true; 1553 fb_helper->delayed_hotplug = true;
1525 return false; 1554 mutex_unlock(&dev->mode_config.mutex);
1555 return 0;
1526 } 1556 }
1527 DRM_DEBUG_KMS("\n"); 1557 DRM_DEBUG_KMS("\n");
1528 1558
@@ -1533,6 +1563,7 @@ bool drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper)
1533 count = drm_fb_helper_probe_connector_modes(fb_helper, max_width, 1563 count = drm_fb_helper_probe_connector_modes(fb_helper, max_width,
1534 max_height); 1564 max_height);
1535 drm_setup_crtcs(fb_helper); 1565 drm_setup_crtcs(fb_helper);
1566 mutex_unlock(&dev->mode_config.mutex);
1536 1567
1537 return drm_fb_helper_single_fb_probe(fb_helper, bpp_sel); 1568 return drm_fb_helper_single_fb_probe(fb_helper, bpp_sel);
1538} 1569}
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 741457bd1c46..a1f12cb043de 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -932,11 +932,34 @@ EXPORT_SYMBOL(drm_vblank_put);
932 932
933void drm_vblank_off(struct drm_device *dev, int crtc) 933void drm_vblank_off(struct drm_device *dev, int crtc)
934{ 934{
935 struct drm_pending_vblank_event *e, *t;
936 struct timeval now;
935 unsigned long irqflags; 937 unsigned long irqflags;
938 unsigned int seq;
936 939
937 spin_lock_irqsave(&dev->vbl_lock, irqflags); 940 spin_lock_irqsave(&dev->vbl_lock, irqflags);
938 vblank_disable_and_save(dev, crtc); 941 vblank_disable_and_save(dev, crtc);
939 DRM_WAKEUP(&dev->vbl_queue[crtc]); 942 DRM_WAKEUP(&dev->vbl_queue[crtc]);
943
944 /* Send any queued vblank events, lest the natives grow disquiet */
945 seq = drm_vblank_count_and_time(dev, crtc, &now);
946 list_for_each_entry_safe(e, t, &dev->vblank_event_list, base.link) {
947 if (e->pipe != crtc)
948 continue;
949 DRM_DEBUG("Sending premature vblank event on disable: \
950 wanted %d, current %d\n",
951 e->event.sequence, seq);
952
953 e->event.sequence = seq;
954 e->event.tv_sec = now.tv_sec;
955 e->event.tv_usec = now.tv_usec;
956 drm_vblank_put(dev, e->pipe);
957 list_move_tail(&e->base.link, &e->base.file_priv->event_list);
958 wake_up_interruptible(&e->base.file_priv->event_wait);
959 trace_drm_vblank_event_delivered(e->base.pid, e->pipe,
960 e->event.sequence);
961 }
962
940 spin_unlock_irqrestore(&dev->vbl_lock, irqflags); 963 spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
941} 964}
942EXPORT_SYMBOL(drm_vblank_off); 965EXPORT_SYMBOL(drm_vblank_off);
diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index 5d00b0fc0d91..959186cbf328 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -431,7 +431,7 @@ EXPORT_SYMBOL(drm_mm_search_free_in_range);
431void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new) 431void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new)
432{ 432{
433 list_replace(&old->node_list, &new->node_list); 433 list_replace(&old->node_list, &new->node_list);
434 list_replace(&old->node_list, &new->hole_stack); 434 list_replace(&old->hole_stack, &new->hole_stack);
435 new->hole_follows = old->hole_follows; 435 new->hole_follows = old->hole_follows;
436 new->mm = old->mm; 436 new->mm = old->mm;
437 new->start = old->start; 437 new->start = old->start;
@@ -699,8 +699,8 @@ int drm_mm_dump_table(struct seq_file *m, struct drm_mm *mm)
699 entry->size); 699 entry->size);
700 total_used += entry->size; 700 total_used += entry->size;
701 if (entry->hole_follows) { 701 if (entry->hole_follows) {
702 hole_start = drm_mm_hole_node_start(&mm->head_node); 702 hole_start = drm_mm_hole_node_start(entry);
703 hole_end = drm_mm_hole_node_end(&mm->head_node); 703 hole_end = drm_mm_hole_node_end(entry);
704 hole_size = hole_end - hole_start; 704 hole_size = hole_end - hole_start;
705 seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: free\n", 705 seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: free\n",
706 hole_start, hole_end, hole_size); 706 hole_start, hole_end, hole_size);
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 72730377a01b..12876f2795d2 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -2207,7 +2207,7 @@ void i915_driver_lastclose(struct drm_device * dev)
2207 drm_i915_private_t *dev_priv = dev->dev_private; 2207 drm_i915_private_t *dev_priv = dev->dev_private;
2208 2208
2209 if (!dev_priv || drm_core_check_feature(dev, DRIVER_MODESET)) { 2209 if (!dev_priv || drm_core_check_feature(dev, DRIVER_MODESET)) {
2210 drm_fb_helper_restore(); 2210 intel_fb_restore_mode(dev);
2211 vga_switcheroo_process_delayed_switch(); 2211 vga_switcheroo_process_delayed_switch();
2212 return; 2212 return;
2213 } 2213 }
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index c34a8dd31d02..32d1b3e829c8 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -49,7 +49,7 @@ module_param_named(panel_ignore_lid, i915_panel_ignore_lid, int, 0600);
49unsigned int i915_powersave = 1; 49unsigned int i915_powersave = 1;
50module_param_named(powersave, i915_powersave, int, 0600); 50module_param_named(powersave, i915_powersave, int, 0600);
51 51
52unsigned int i915_semaphores = 1; 52unsigned int i915_semaphores = 0;
53module_param_named(semaphores, i915_semaphores, int, 0600); 53module_param_named(semaphores, i915_semaphores, int, 0600);
54 54
55unsigned int i915_enable_rc6 = 0; 55unsigned int i915_enable_rc6 = 0;
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 432fc04c6bff..2166ee071ddb 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -3771,8 +3771,11 @@ static bool g4x_compute_wm0(struct drm_device *dev,
3771 int entries, tlb_miss; 3771 int entries, tlb_miss;
3772 3772
3773 crtc = intel_get_crtc_for_plane(dev, plane); 3773 crtc = intel_get_crtc_for_plane(dev, plane);
3774 if (crtc->fb == NULL || !crtc->enabled) 3774 if (crtc->fb == NULL || !crtc->enabled) {
3775 *cursor_wm = cursor->guard_size;
3776 *plane_wm = display->guard_size;
3775 return false; 3777 return false;
3778 }
3776 3779
3777 htotal = crtc->mode.htotal; 3780 htotal = crtc->mode.htotal;
3778 hdisplay = crtc->mode.hdisplay; 3781 hdisplay = crtc->mode.hdisplay;
@@ -5602,9 +5605,9 @@ static int intel_crtc_clock_get(struct drm_device *dev, struct drm_crtc *crtc)
5602 intel_clock_t clock; 5605 intel_clock_t clock;
5603 5606
5604 if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0) 5607 if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0)
5605 fp = FP0(pipe); 5608 fp = I915_READ(FP0(pipe));
5606 else 5609 else
5607 fp = FP1(pipe); 5610 fp = I915_READ(FP1(pipe));
5608 5611
5609 clock.m1 = (fp & FP_M1_DIV_MASK) >> FP_M1_DIV_SHIFT; 5612 clock.m1 = (fp & FP_M1_DIV_MASK) >> FP_M1_DIV_SHIFT;
5610 if (IS_PINEVIEW(dev)) { 5613 if (IS_PINEVIEW(dev)) {
@@ -6215,36 +6218,6 @@ cleanup_work:
6215 return ret; 6218 return ret;
6216} 6219}
6217 6220
6218static void intel_crtc_reset(struct drm_crtc *crtc)
6219{
6220 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
6221
6222 /* Reset flags back to the 'unknown' status so that they
6223 * will be correctly set on the initial modeset.
6224 */
6225 intel_crtc->dpms_mode = -1;
6226}
6227
6228static struct drm_crtc_helper_funcs intel_helper_funcs = {
6229 .dpms = intel_crtc_dpms,
6230 .mode_fixup = intel_crtc_mode_fixup,
6231 .mode_set = intel_crtc_mode_set,
6232 .mode_set_base = intel_pipe_set_base,
6233 .mode_set_base_atomic = intel_pipe_set_base_atomic,
6234 .load_lut = intel_crtc_load_lut,
6235 .disable = intel_crtc_disable,
6236};
6237
6238static const struct drm_crtc_funcs intel_crtc_funcs = {
6239 .reset = intel_crtc_reset,
6240 .cursor_set = intel_crtc_cursor_set,
6241 .cursor_move = intel_crtc_cursor_move,
6242 .gamma_set = intel_crtc_gamma_set,
6243 .set_config = drm_crtc_helper_set_config,
6244 .destroy = intel_crtc_destroy,
6245 .page_flip = intel_crtc_page_flip,
6246};
6247
6248static void intel_sanitize_modesetting(struct drm_device *dev, 6221static void intel_sanitize_modesetting(struct drm_device *dev,
6249 int pipe, int plane) 6222 int pipe, int plane)
6250{ 6223{
@@ -6281,6 +6254,42 @@ static void intel_sanitize_modesetting(struct drm_device *dev,
6281 intel_disable_pipe(dev_priv, pipe); 6254 intel_disable_pipe(dev_priv, pipe);
6282} 6255}
6283 6256
6257static void intel_crtc_reset(struct drm_crtc *crtc)
6258{
6259 struct drm_device *dev = crtc->dev;
6260 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
6261
6262 /* Reset flags back to the 'unknown' status so that they
6263 * will be correctly set on the initial modeset.
6264 */
6265 intel_crtc->dpms_mode = -1;
6266
6267 /* We need to fix up any BIOS configuration that conflicts with
6268 * our expectations.
6269 */
6270 intel_sanitize_modesetting(dev, intel_crtc->pipe, intel_crtc->plane);
6271}
6272
6273static struct drm_crtc_helper_funcs intel_helper_funcs = {
6274 .dpms = intel_crtc_dpms,
6275 .mode_fixup = intel_crtc_mode_fixup,
6276 .mode_set = intel_crtc_mode_set,
6277 .mode_set_base = intel_pipe_set_base,
6278 .mode_set_base_atomic = intel_pipe_set_base_atomic,
6279 .load_lut = intel_crtc_load_lut,
6280 .disable = intel_crtc_disable,
6281};
6282
6283static const struct drm_crtc_funcs intel_crtc_funcs = {
6284 .reset = intel_crtc_reset,
6285 .cursor_set = intel_crtc_cursor_set,
6286 .cursor_move = intel_crtc_cursor_move,
6287 .gamma_set = intel_crtc_gamma_set,
6288 .set_config = drm_crtc_helper_set_config,
6289 .destroy = intel_crtc_destroy,
6290 .page_flip = intel_crtc_page_flip,
6291};
6292
6284static void intel_crtc_init(struct drm_device *dev, int pipe) 6293static void intel_crtc_init(struct drm_device *dev, int pipe)
6285{ 6294{
6286 drm_i915_private_t *dev_priv = dev->dev_private; 6295 drm_i915_private_t *dev_priv = dev->dev_private;
@@ -6330,8 +6339,6 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)
6330 6339
6331 setup_timer(&intel_crtc->idle_timer, intel_crtc_idle_timer, 6340 setup_timer(&intel_crtc->idle_timer, intel_crtc_idle_timer,
6332 (unsigned long)intel_crtc); 6341 (unsigned long)intel_crtc);
6333
6334 intel_sanitize_modesetting(dev, intel_crtc->pipe, intel_crtc->plane);
6335} 6342}
6336 6343
6337int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data, 6344int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
@@ -6572,8 +6579,10 @@ intel_user_framebuffer_create(struct drm_device *dev,
6572 return ERR_PTR(-ENOENT); 6579 return ERR_PTR(-ENOENT);
6573 6580
6574 intel_fb = kzalloc(sizeof(*intel_fb), GFP_KERNEL); 6581 intel_fb = kzalloc(sizeof(*intel_fb), GFP_KERNEL);
6575 if (!intel_fb) 6582 if (!intel_fb) {
6583 drm_gem_object_unreference_unlocked(&obj->base);
6576 return ERR_PTR(-ENOMEM); 6584 return ERR_PTR(-ENOMEM);
6585 }
6577 6586
6578 ret = intel_framebuffer_init(dev, intel_fb, mode_cmd, obj); 6587 ret = intel_framebuffer_init(dev, intel_fb, mode_cmd, obj);
6579 if (ret) { 6588 if (ret) {
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index cb8578b7e443..a4d80314e7f8 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -1470,7 +1470,8 @@ intel_dp_link_down(struct intel_dp *intel_dp)
1470 1470
1471 if (!HAS_PCH_CPT(dev) && 1471 if (!HAS_PCH_CPT(dev) &&
1472 I915_READ(intel_dp->output_reg) & DP_PIPEB_SELECT) { 1472 I915_READ(intel_dp->output_reg) & DP_PIPEB_SELECT) {
1473 struct intel_crtc *intel_crtc = to_intel_crtc(intel_dp->base.base.crtc); 1473 struct drm_crtc *crtc = intel_dp->base.base.crtc;
1474
1474 /* Hardware workaround: leaving our transcoder select 1475 /* Hardware workaround: leaving our transcoder select
1475 * set to transcoder B while it's off will prevent the 1476 * set to transcoder B while it's off will prevent the
1476 * corresponding HDMI output on transcoder A. 1477 * corresponding HDMI output on transcoder A.
@@ -1485,7 +1486,19 @@ intel_dp_link_down(struct intel_dp *intel_dp)
1485 /* Changes to enable or select take place the vblank 1486 /* Changes to enable or select take place the vblank
1486 * after being written. 1487 * after being written.
1487 */ 1488 */
1488 intel_wait_for_vblank(dev, intel_crtc->pipe); 1489 if (crtc == NULL) {
1490 /* We can arrive here never having been attached
1491 * to a CRTC, for instance, due to inheriting
1492 * random state from the BIOS.
1493 *
1494 * If the pipe is not running, play safe and
1495 * wait for the clocks to stabilise before
1496 * continuing.
1497 */
1498 POSTING_READ(intel_dp->output_reg);
1499 msleep(50);
1500 } else
1501 intel_wait_for_vblank(dev, to_intel_crtc(crtc)->pipe);
1489 } 1502 }
1490 1503
1491 I915_WRITE(intel_dp->output_reg, DP & ~DP_PORT_EN); 1504 I915_WRITE(intel_dp->output_reg, DP & ~DP_PORT_EN);
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index f5b0d8306d83..1d20712d527f 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -338,4 +338,5 @@ extern int intel_overlay_attrs(struct drm_device *dev, void *data,
338 struct drm_file *file_priv); 338 struct drm_file *file_priv);
339 339
340extern void intel_fb_output_poll_changed(struct drm_device *dev); 340extern void intel_fb_output_poll_changed(struct drm_device *dev);
341extern void intel_fb_restore_mode(struct drm_device *dev);
341#endif /* __INTEL_DRV_H__ */ 342#endif /* __INTEL_DRV_H__ */
diff --git a/drivers/gpu/drm/i915/intel_fb.c b/drivers/gpu/drm/i915/intel_fb.c
index 512782728e51..ec49bae73382 100644
--- a/drivers/gpu/drm/i915/intel_fb.c
+++ b/drivers/gpu/drm/i915/intel_fb.c
@@ -264,3 +264,13 @@ void intel_fb_output_poll_changed(struct drm_device *dev)
264 drm_i915_private_t *dev_priv = dev->dev_private; 264 drm_i915_private_t *dev_priv = dev->dev_private;
265 drm_fb_helper_hotplug_event(&dev_priv->fbdev->helper); 265 drm_fb_helper_hotplug_event(&dev_priv->fbdev->helper);
266} 266}
267
268void intel_fb_restore_mode(struct drm_device *dev)
269{
270 int ret;
271 drm_i915_private_t *dev_priv = dev->dev_private;
272
273 ret = drm_fb_helper_restore_fbdev_mode(&dev_priv->fbdev->helper);
274 if (ret)
275 DRM_DEBUG("failed to restore crtc mode\n");
276}
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index a562bd2648c7..67cb076d271b 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -539,6 +539,9 @@ static int intel_lid_notify(struct notifier_block *nb, unsigned long val,
539 struct drm_device *dev = dev_priv->dev; 539 struct drm_device *dev = dev_priv->dev;
540 struct drm_connector *connector = dev_priv->int_lvds_connector; 540 struct drm_connector *connector = dev_priv->int_lvds_connector;
541 541
542 if (dev->switch_power_state != DRM_SWITCH_POWER_ON)
543 return NOTIFY_OK;
544
542 /* 545 /*
543 * check and update the status of LVDS connector after receiving 546 * check and update the status of LVDS connector after receiving
544 * the LID nofication event. 547 * the LID nofication event.
diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c
index 4256b8ef3947..6b22c1dcc015 100644
--- a/drivers/gpu/drm/i915/intel_tv.c
+++ b/drivers/gpu/drm/i915/intel_tv.c
@@ -1151,10 +1151,10 @@ intel_tv_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode,
1151 (video_levels->blank << TV_BLANK_LEVEL_SHIFT))); 1151 (video_levels->blank << TV_BLANK_LEVEL_SHIFT)));
1152 { 1152 {
1153 int pipeconf_reg = PIPECONF(pipe); 1153 int pipeconf_reg = PIPECONF(pipe);
1154 int dspcntr_reg = DSPCNTR(pipe); 1154 int dspcntr_reg = DSPCNTR(intel_crtc->plane);
1155 int pipeconf = I915_READ(pipeconf_reg); 1155 int pipeconf = I915_READ(pipeconf_reg);
1156 int dspcntr = I915_READ(dspcntr_reg); 1156 int dspcntr = I915_READ(dspcntr_reg);
1157 int dspbase_reg = DSPADDR(pipe); 1157 int dspbase_reg = DSPADDR(intel_crtc->plane);
1158 int xpos = 0x0, ypos = 0x0; 1158 int xpos = 0x0, ypos = 0x0;
1159 unsigned int xsize, ysize; 1159 unsigned int xsize, ysize;
1160 /* Pipe must be off here */ 1160 /* Pipe must be off here */
@@ -1378,7 +1378,9 @@ intel_tv_detect(struct drm_connector *connector, bool force)
1378 if (type < 0) 1378 if (type < 0)
1379 return connector_status_disconnected; 1379 return connector_status_disconnected;
1380 1380
1381 intel_tv->type = type;
1381 intel_tv_find_better_format(connector); 1382 intel_tv_find_better_format(connector);
1383
1382 return connector_status_connected; 1384 return connector_status_connected;
1383} 1385}
1384 1386
@@ -1670,8 +1672,7 @@ intel_tv_init(struct drm_device *dev)
1670 * 1672 *
1671 * More recent chipsets favour HDMI rather than integrated S-Video. 1673 * More recent chipsets favour HDMI rather than integrated S-Video.
1672 */ 1674 */
1673 connector->polled = 1675 connector->polled = DRM_CONNECTOR_POLL_CONNECT;
1674 DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT;
1675 1676
1676 drm_connector_init(dev, connector, &intel_tv_connector_funcs, 1677 drm_connector_init(dev, connector, &intel_tv_connector_funcs,
1677 DRM_MODE_CONNECTOR_SVIDEO); 1678 DRM_MODE_CONNECTOR_SVIDEO);
diff --git a/drivers/gpu/drm/nouveau/nouveau_dma.c b/drivers/gpu/drm/nouveau/nouveau_dma.c
index ce38e97b9428..568caedd7216 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dma.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dma.c
@@ -83,7 +83,7 @@ nouveau_dma_init(struct nouveau_channel *chan)
83 return ret; 83 return ret;
84 84
85 /* NV_MEMORY_TO_MEMORY_FORMAT requires a notifier object */ 85 /* NV_MEMORY_TO_MEMORY_FORMAT requires a notifier object */
86 ret = nouveau_notifier_alloc(chan, NvNotify0, 32, 0xfd0, 0x1000, 86 ret = nouveau_notifier_alloc(chan, NvNotify0, 32, 0xfe0, 0x1000,
87 &chan->m2mf_ntfy); 87 &chan->m2mf_ntfy);
88 if (ret) 88 if (ret)
89 return ret; 89 return ret;
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 856d56a98d1e..a76514a209b3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -682,6 +682,9 @@ struct drm_nouveau_private {
682 /* For PFIFO and PGRAPH. */ 682 /* For PFIFO and PGRAPH. */
683 spinlock_t context_switch_lock; 683 spinlock_t context_switch_lock;
684 684
685 /* VM/PRAMIN flush, legacy PRAMIN aperture */
686 spinlock_t vm_lock;
687
685 /* RAMIN configuration, RAMFC, RAMHT and RAMRO offsets */ 688 /* RAMIN configuration, RAMFC, RAMHT and RAMRO offsets */
686 struct nouveau_ramht *ramht; 689 struct nouveau_ramht *ramht;
687 struct nouveau_gpuobj *ramfc; 690 struct nouveau_gpuobj *ramfc;
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 889c4454682e..39aee6d4daf8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -181,13 +181,13 @@ nouveau_fbcon_sync(struct fb_info *info)
181 OUT_RING (chan, 0); 181 OUT_RING (chan, 0);
182 } 182 }
183 183
184 nouveau_bo_wr32(chan->notifier_bo, chan->m2mf_ntfy + 3, 0xffffffff); 184 nouveau_bo_wr32(chan->notifier_bo, chan->m2mf_ntfy/4 + 3, 0xffffffff);
185 FIRE_RING(chan); 185 FIRE_RING(chan);
186 mutex_unlock(&chan->mutex); 186 mutex_unlock(&chan->mutex);
187 187
188 ret = -EBUSY; 188 ret = -EBUSY;
189 for (i = 0; i < 100000; i++) { 189 for (i = 0; i < 100000; i++) {
190 if (!nouveau_bo_rd32(chan->notifier_bo, chan->m2mf_ntfy + 3)) { 190 if (!nouveau_bo_rd32(chan->notifier_bo, chan->m2mf_ntfy/4 + 3)) {
191 ret = 0; 191 ret = 0;
192 break; 192 break;
193 } 193 }
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
index 78f467fe30be..c3e953b08992 100644
--- a/drivers/gpu/drm/nouveau/nouveau_mem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_mem.c
@@ -152,8 +152,6 @@ nouveau_mem_vram_fini(struct drm_device *dev)
152{ 152{
153 struct drm_nouveau_private *dev_priv = dev->dev_private; 153 struct drm_nouveau_private *dev_priv = dev->dev_private;
154 154
155 nouveau_bo_ref(NULL, &dev_priv->vga_ram);
156
157 ttm_bo_device_release(&dev_priv->ttm.bdev); 155 ttm_bo_device_release(&dev_priv->ttm.bdev);
158 156
159 nouveau_ttm_global_release(dev_priv); 157 nouveau_ttm_global_release(dev_priv);
@@ -398,7 +396,7 @@ nouveau_mem_vram_init(struct drm_device *dev)
398 dma_bits = 40; 396 dma_bits = 40;
399 } else 397 } else
400 if (drm_pci_device_is_pcie(dev) && 398 if (drm_pci_device_is_pcie(dev) &&
401 dev_priv->chipset != 0x40 && 399 dev_priv->chipset > 0x40 &&
402 dev_priv->chipset != 0x45) { 400 dev_priv->chipset != 0x45) {
403 if (pci_dma_supported(dev->pdev, DMA_BIT_MASK(39))) 401 if (pci_dma_supported(dev->pdev, DMA_BIT_MASK(39)))
404 dma_bits = 39; 402 dma_bits = 39;
diff --git a/drivers/gpu/drm/nouveau/nouveau_notifier.c b/drivers/gpu/drm/nouveau/nouveau_notifier.c
index 7ba3fc0b30c1..5b39718ae1f8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_notifier.c
+++ b/drivers/gpu/drm/nouveau/nouveau_notifier.c
@@ -35,19 +35,22 @@ nouveau_notifier_init_channel(struct nouveau_channel *chan)
35{ 35{
36 struct drm_device *dev = chan->dev; 36 struct drm_device *dev = chan->dev;
37 struct nouveau_bo *ntfy = NULL; 37 struct nouveau_bo *ntfy = NULL;
38 uint32_t flags; 38 uint32_t flags, ttmpl;
39 int ret; 39 int ret;
40 40
41 if (nouveau_vram_notify) 41 if (nouveau_vram_notify) {
42 flags = NOUVEAU_GEM_DOMAIN_VRAM; 42 flags = NOUVEAU_GEM_DOMAIN_VRAM;
43 else 43 ttmpl = TTM_PL_FLAG_VRAM;
44 } else {
44 flags = NOUVEAU_GEM_DOMAIN_GART; 45 flags = NOUVEAU_GEM_DOMAIN_GART;
46 ttmpl = TTM_PL_FLAG_TT;
47 }
45 48
46 ret = nouveau_gem_new(dev, NULL, PAGE_SIZE, 0, flags, 0, 0, &ntfy); 49 ret = nouveau_gem_new(dev, NULL, PAGE_SIZE, 0, flags, 0, 0, &ntfy);
47 if (ret) 50 if (ret)
48 return ret; 51 return ret;
49 52
50 ret = nouveau_bo_pin(ntfy, flags); 53 ret = nouveau_bo_pin(ntfy, ttmpl);
51 if (ret) 54 if (ret)
52 goto out_err; 55 goto out_err;
53 56
diff --git a/drivers/gpu/drm/nouveau/nouveau_object.c b/drivers/gpu/drm/nouveau/nouveau_object.c
index 4f00c87ed86e..67a16e01ffa6 100644
--- a/drivers/gpu/drm/nouveau/nouveau_object.c
+++ b/drivers/gpu/drm/nouveau/nouveau_object.c
@@ -1039,19 +1039,20 @@ nv_ro32(struct nouveau_gpuobj *gpuobj, u32 offset)
1039{ 1039{
1040 struct drm_nouveau_private *dev_priv = gpuobj->dev->dev_private; 1040 struct drm_nouveau_private *dev_priv = gpuobj->dev->dev_private;
1041 struct drm_device *dev = gpuobj->dev; 1041 struct drm_device *dev = gpuobj->dev;
1042 unsigned long flags;
1042 1043
1043 if (gpuobj->pinst == ~0 || !dev_priv->ramin_available) { 1044 if (gpuobj->pinst == ~0 || !dev_priv->ramin_available) {
1044 u64 ptr = gpuobj->vinst + offset; 1045 u64 ptr = gpuobj->vinst + offset;
1045 u32 base = ptr >> 16; 1046 u32 base = ptr >> 16;
1046 u32 val; 1047 u32 val;
1047 1048
1048 spin_lock(&dev_priv->ramin_lock); 1049 spin_lock_irqsave(&dev_priv->vm_lock, flags);
1049 if (dev_priv->ramin_base != base) { 1050 if (dev_priv->ramin_base != base) {
1050 dev_priv->ramin_base = base; 1051 dev_priv->ramin_base = base;
1051 nv_wr32(dev, 0x001700, dev_priv->ramin_base); 1052 nv_wr32(dev, 0x001700, dev_priv->ramin_base);
1052 } 1053 }
1053 val = nv_rd32(dev, 0x700000 + (ptr & 0xffff)); 1054 val = nv_rd32(dev, 0x700000 + (ptr & 0xffff));
1054 spin_unlock(&dev_priv->ramin_lock); 1055 spin_unlock_irqrestore(&dev_priv->vm_lock, flags);
1055 return val; 1056 return val;
1056 } 1057 }
1057 1058
@@ -1063,18 +1064,19 @@ nv_wo32(struct nouveau_gpuobj *gpuobj, u32 offset, u32 val)
1063{ 1064{
1064 struct drm_nouveau_private *dev_priv = gpuobj->dev->dev_private; 1065 struct drm_nouveau_private *dev_priv = gpuobj->dev->dev_private;
1065 struct drm_device *dev = gpuobj->dev; 1066 struct drm_device *dev = gpuobj->dev;
1067 unsigned long flags;
1066 1068
1067 if (gpuobj->pinst == ~0 || !dev_priv->ramin_available) { 1069 if (gpuobj->pinst == ~0 || !dev_priv->ramin_available) {
1068 u64 ptr = gpuobj->vinst + offset; 1070 u64 ptr = gpuobj->vinst + offset;
1069 u32 base = ptr >> 16; 1071 u32 base = ptr >> 16;
1070 1072
1071 spin_lock(&dev_priv->ramin_lock); 1073 spin_lock_irqsave(&dev_priv->vm_lock, flags);
1072 if (dev_priv->ramin_base != base) { 1074 if (dev_priv->ramin_base != base) {
1073 dev_priv->ramin_base = base; 1075 dev_priv->ramin_base = base;
1074 nv_wr32(dev, 0x001700, dev_priv->ramin_base); 1076 nv_wr32(dev, 0x001700, dev_priv->ramin_base);
1075 } 1077 }
1076 nv_wr32(dev, 0x700000 + (ptr & 0xffff), val); 1078 nv_wr32(dev, 0x700000 + (ptr & 0xffff), val);
1077 spin_unlock(&dev_priv->ramin_lock); 1079 spin_unlock_irqrestore(&dev_priv->vm_lock, flags);
1078 return; 1080 return;
1079 } 1081 }
1080 1082
diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
index a33fe4019286..c77111eca6ac 100644
--- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
+++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
@@ -42,7 +42,8 @@ nouveau_sgdma_populate(struct ttm_backend *be, unsigned long num_pages,
42 42
43 nvbe->nr_pages = 0; 43 nvbe->nr_pages = 0;
44 while (num_pages--) { 44 while (num_pages--) {
45 if (dma_addrs[nvbe->nr_pages] != DMA_ERROR_CODE) { 45 /* this code path isn't called and is incorrect anyways */
46 if (0) { /*dma_addrs[nvbe->nr_pages] != DMA_ERROR_CODE)*/
46 nvbe->pages[nvbe->nr_pages] = 47 nvbe->pages[nvbe->nr_pages] =
47 dma_addrs[nvbe->nr_pages]; 48 dma_addrs[nvbe->nr_pages];
48 nvbe->ttm_alloced[nvbe->nr_pages] = true; 49 nvbe->ttm_alloced[nvbe->nr_pages] = true;
@@ -55,6 +56,7 @@ nouveau_sgdma_populate(struct ttm_backend *be, unsigned long num_pages,
55 be->func->clear(be); 56 be->func->clear(be);
56 return -EFAULT; 57 return -EFAULT;
57 } 58 }
59 nvbe->ttm_alloced[nvbe->nr_pages] = false;
58 } 60 }
59 61
60 nvbe->nr_pages++; 62 nvbe->nr_pages++;
@@ -427,7 +429,7 @@ nouveau_sgdma_init(struct drm_device *dev)
427 u32 aper_size, align; 429 u32 aper_size, align;
428 int ret; 430 int ret;
429 431
430 if (dev_priv->card_type >= NV_50 || drm_pci_device_is_pcie(dev)) 432 if (dev_priv->card_type >= NV_40 && drm_pci_device_is_pcie(dev))
431 aper_size = 512 * 1024 * 1024; 433 aper_size = 512 * 1024 * 1024;
432 else 434 else
433 aper_size = 64 * 1024 * 1024; 435 aper_size = 64 * 1024 * 1024;
@@ -457,7 +459,7 @@ nouveau_sgdma_init(struct drm_device *dev)
457 dev_priv->gart_info.func = &nv50_sgdma_backend; 459 dev_priv->gart_info.func = &nv50_sgdma_backend;
458 } else 460 } else
459 if (drm_pci_device_is_pcie(dev) && 461 if (drm_pci_device_is_pcie(dev) &&
460 dev_priv->chipset != 0x40 && dev_priv->chipset != 0x45) { 462 dev_priv->chipset > 0x40 && dev_priv->chipset != 0x45) {
461 if (nv44_graph_class(dev)) { 463 if (nv44_graph_class(dev)) {
462 dev_priv->gart_info.func = &nv44_sgdma_backend; 464 dev_priv->gart_info.func = &nv44_sgdma_backend;
463 align = 512 * 1024; 465 align = 512 * 1024;
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c
index 6e2b1a6caa2d..915fbce89595 100644
--- a/drivers/gpu/drm/nouveau/nouveau_state.c
+++ b/drivers/gpu/drm/nouveau/nouveau_state.c
@@ -608,6 +608,7 @@ nouveau_card_init(struct drm_device *dev)
608 spin_lock_init(&dev_priv->channels.lock); 608 spin_lock_init(&dev_priv->channels.lock);
609 spin_lock_init(&dev_priv->tile.lock); 609 spin_lock_init(&dev_priv->tile.lock);
610 spin_lock_init(&dev_priv->context_switch_lock); 610 spin_lock_init(&dev_priv->context_switch_lock);
611 spin_lock_init(&dev_priv->vm_lock);
611 612
612 /* Make the CRTCs and I2C buses accessible */ 613 /* Make the CRTCs and I2C buses accessible */
613 ret = engine->display.early_init(dev); 614 ret = engine->display.early_init(dev);
@@ -767,6 +768,11 @@ static void nouveau_card_takedown(struct drm_device *dev)
767 engine->mc.takedown(dev); 768 engine->mc.takedown(dev);
768 engine->display.late_takedown(dev); 769 engine->display.late_takedown(dev);
769 770
771 if (dev_priv->vga_ram) {
772 nouveau_bo_unpin(dev_priv->vga_ram);
773 nouveau_bo_ref(NULL, &dev_priv->vga_ram);
774 }
775
770 mutex_lock(&dev->struct_mutex); 776 mutex_lock(&dev->struct_mutex);
771 ttm_bo_clean_mm(&dev_priv->ttm.bdev, TTM_PL_VRAM); 777 ttm_bo_clean_mm(&dev_priv->ttm.bdev, TTM_PL_VRAM);
772 ttm_bo_clean_mm(&dev_priv->ttm.bdev, TTM_PL_TT); 778 ttm_bo_clean_mm(&dev_priv->ttm.bdev, TTM_PL_TT);
diff --git a/drivers/gpu/drm/nouveau/nv50_instmem.c b/drivers/gpu/drm/nouveau/nv50_instmem.c
index a6f8aa651fc6..4f95a1e5822e 100644
--- a/drivers/gpu/drm/nouveau/nv50_instmem.c
+++ b/drivers/gpu/drm/nouveau/nv50_instmem.c
@@ -404,23 +404,25 @@ void
404nv50_instmem_flush(struct drm_device *dev) 404nv50_instmem_flush(struct drm_device *dev)
405{ 405{
406 struct drm_nouveau_private *dev_priv = dev->dev_private; 406 struct drm_nouveau_private *dev_priv = dev->dev_private;
407 unsigned long flags;
407 408
408 spin_lock(&dev_priv->ramin_lock); 409 spin_lock_irqsave(&dev_priv->vm_lock, flags);
409 nv_wr32(dev, 0x00330c, 0x00000001); 410 nv_wr32(dev, 0x00330c, 0x00000001);
410 if (!nv_wait(dev, 0x00330c, 0x00000002, 0x00000000)) 411 if (!nv_wait(dev, 0x00330c, 0x00000002, 0x00000000))
411 NV_ERROR(dev, "PRAMIN flush timeout\n"); 412 NV_ERROR(dev, "PRAMIN flush timeout\n");
412 spin_unlock(&dev_priv->ramin_lock); 413 spin_unlock_irqrestore(&dev_priv->vm_lock, flags);
413} 414}
414 415
415void 416void
416nv84_instmem_flush(struct drm_device *dev) 417nv84_instmem_flush(struct drm_device *dev)
417{ 418{
418 struct drm_nouveau_private *dev_priv = dev->dev_private; 419 struct drm_nouveau_private *dev_priv = dev->dev_private;
420 unsigned long flags;
419 421
420 spin_lock(&dev_priv->ramin_lock); 422 spin_lock_irqsave(&dev_priv->vm_lock, flags);
421 nv_wr32(dev, 0x070000, 0x00000001); 423 nv_wr32(dev, 0x070000, 0x00000001);
422 if (!nv_wait(dev, 0x070000, 0x00000002, 0x00000000)) 424 if (!nv_wait(dev, 0x070000, 0x00000002, 0x00000000))
423 NV_ERROR(dev, "PRAMIN flush timeout\n"); 425 NV_ERROR(dev, "PRAMIN flush timeout\n");
424 spin_unlock(&dev_priv->ramin_lock); 426 spin_unlock_irqrestore(&dev_priv->vm_lock, flags);
425} 427}
426 428
diff --git a/drivers/gpu/drm/nouveau/nv50_vm.c b/drivers/gpu/drm/nouveau/nv50_vm.c
index 4fd3432b5b8d..6c2694490741 100644
--- a/drivers/gpu/drm/nouveau/nv50_vm.c
+++ b/drivers/gpu/drm/nouveau/nv50_vm.c
@@ -174,10 +174,11 @@ void
174nv50_vm_flush_engine(struct drm_device *dev, int engine) 174nv50_vm_flush_engine(struct drm_device *dev, int engine)
175{ 175{
176 struct drm_nouveau_private *dev_priv = dev->dev_private; 176 struct drm_nouveau_private *dev_priv = dev->dev_private;
177 unsigned long flags;
177 178
178 spin_lock(&dev_priv->ramin_lock); 179 spin_lock_irqsave(&dev_priv->vm_lock, flags);
179 nv_wr32(dev, 0x100c80, (engine << 16) | 1); 180 nv_wr32(dev, 0x100c80, (engine << 16) | 1);
180 if (!nv_wait(dev, 0x100c80, 0x00000001, 0x00000000)) 181 if (!nv_wait(dev, 0x100c80, 0x00000001, 0x00000000))
181 NV_ERROR(dev, "vm flush timeout: engine %d\n", engine); 182 NV_ERROR(dev, "vm flush timeout: engine %d\n", engine);
182 spin_unlock(&dev_priv->ramin_lock); 183 spin_unlock_irqrestore(&dev_priv->vm_lock, flags);
183} 184}
diff --git a/drivers/gpu/drm/nouveau/nvc0_vm.c b/drivers/gpu/drm/nouveau/nvc0_vm.c
index a0a2a0277f73..a179e6c55afb 100644
--- a/drivers/gpu/drm/nouveau/nvc0_vm.c
+++ b/drivers/gpu/drm/nouveau/nvc0_vm.c
@@ -104,11 +104,12 @@ nvc0_vm_flush(struct nouveau_vm *vm)
104 struct nouveau_instmem_engine *pinstmem = &dev_priv->engine.instmem; 104 struct nouveau_instmem_engine *pinstmem = &dev_priv->engine.instmem;
105 struct drm_device *dev = vm->dev; 105 struct drm_device *dev = vm->dev;
106 struct nouveau_vm_pgd *vpgd; 106 struct nouveau_vm_pgd *vpgd;
107 unsigned long flags;
107 u32 engine = (dev_priv->chan_vm == vm) ? 1 : 5; 108 u32 engine = (dev_priv->chan_vm == vm) ? 1 : 5;
108 109
109 pinstmem->flush(vm->dev); 110 pinstmem->flush(vm->dev);
110 111
111 spin_lock(&dev_priv->ramin_lock); 112 spin_lock_irqsave(&dev_priv->vm_lock, flags);
112 list_for_each_entry(vpgd, &vm->pgd_list, head) { 113 list_for_each_entry(vpgd, &vm->pgd_list, head) {
113 /* looks like maybe a "free flush slots" counter, the 114 /* looks like maybe a "free flush slots" counter, the
114 * faster you write to 0x100cbc to more it decreases 115 * faster you write to 0x100cbc to more it decreases
@@ -125,5 +126,5 @@ nvc0_vm_flush(struct nouveau_vm *vm)
125 nv_rd32(dev, 0x100c80), engine); 126 nv_rd32(dev, 0x100c80), engine);
126 } 127 }
127 } 128 }
128 spin_unlock(&dev_priv->ramin_lock); 129 spin_unlock_irqrestore(&dev_priv->vm_lock, flags);
129} 130}
diff --git a/drivers/gpu/drm/radeon/atom.c b/drivers/gpu/drm/radeon/atom.c
index d71d375149f8..7bd745689097 100644
--- a/drivers/gpu/drm/radeon/atom.c
+++ b/drivers/gpu/drm/radeon/atom.c
@@ -135,7 +135,7 @@ static uint32_t atom_iio_execute(struct atom_context *ctx, int base,
135 case ATOM_IIO_MOVE_INDEX: 135 case ATOM_IIO_MOVE_INDEX:
136 temp &= 136 temp &=
137 ~((0xFFFFFFFF >> (32 - CU8(base + 1))) << 137 ~((0xFFFFFFFF >> (32 - CU8(base + 1))) <<
138 CU8(base + 2)); 138 CU8(base + 3));
139 temp |= 139 temp |=
140 ((index >> CU8(base + 2)) & 140 ((index >> CU8(base + 2)) &
141 (0xFFFFFFFF >> (32 - CU8(base + 1)))) << CU8(base + 141 (0xFFFFFFFF >> (32 - CU8(base + 1)))) << CU8(base +
@@ -145,7 +145,7 @@ static uint32_t atom_iio_execute(struct atom_context *ctx, int base,
145 case ATOM_IIO_MOVE_DATA: 145 case ATOM_IIO_MOVE_DATA:
146 temp &= 146 temp &=
147 ~((0xFFFFFFFF >> (32 - CU8(base + 1))) << 147 ~((0xFFFFFFFF >> (32 - CU8(base + 1))) <<
148 CU8(base + 2)); 148 CU8(base + 3));
149 temp |= 149 temp |=
150 ((data >> CU8(base + 2)) & 150 ((data >> CU8(base + 2)) &
151 (0xFFFFFFFF >> (32 - CU8(base + 1)))) << CU8(base + 151 (0xFFFFFFFF >> (32 - CU8(base + 1)))) << CU8(base +
@@ -155,7 +155,7 @@ static uint32_t atom_iio_execute(struct atom_context *ctx, int base,
155 case ATOM_IIO_MOVE_ATTR: 155 case ATOM_IIO_MOVE_ATTR:
156 temp &= 156 temp &=
157 ~((0xFFFFFFFF >> (32 - CU8(base + 1))) << 157 ~((0xFFFFFFFF >> (32 - CU8(base + 1))) <<
158 CU8(base + 2)); 158 CU8(base + 3));
159 temp |= 159 temp |=
160 ((ctx-> 160 ((ctx->
161 io_attr >> CU8(base + 2)) & (0xFFFFFFFF >> (32 - 161 io_attr >> CU8(base + 2)) & (0xFFFFFFFF >> (32 -
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 9d516a8c4dfa..529a3a704731 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -532,10 +532,7 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
532 else 532 else
533 pll->flags |= RADEON_PLL_PREFER_LOW_REF_DIV; 533 pll->flags |= RADEON_PLL_PREFER_LOW_REF_DIV;
534 534
535 if ((rdev->family == CHIP_R600) || 535 if (rdev->family < CHIP_RV770)
536 (rdev->family == CHIP_RV610) ||
537 (rdev->family == CHIP_RV630) ||
538 (rdev->family == CHIP_RV670))
539 pll->flags |= RADEON_PLL_PREFER_MINM_OVER_MAXP; 536 pll->flags |= RADEON_PLL_PREFER_MINM_OVER_MAXP;
540 } else { 537 } else {
541 pll->flags |= RADEON_PLL_LEGACY; 538 pll->flags |= RADEON_PLL_LEGACY;
@@ -565,7 +562,6 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
565 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { 562 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
566 if (ss_enabled) { 563 if (ss_enabled) {
567 if (ss->refdiv) { 564 if (ss->refdiv) {
568 pll->flags |= RADEON_PLL_PREFER_MINM_OVER_MAXP;
569 pll->flags |= RADEON_PLL_USE_REF_DIV; 565 pll->flags |= RADEON_PLL_USE_REF_DIV;
570 pll->reference_div = ss->refdiv; 566 pll->reference_div = ss->refdiv;
571 if (ASIC_IS_AVIVO(rdev)) 567 if (ASIC_IS_AVIVO(rdev))
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index 3453910ee0f3..9073e3bfb08c 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -353,7 +353,7 @@ static u32 evergreen_line_buffer_adjust(struct radeon_device *rdev,
353 struct drm_display_mode *mode, 353 struct drm_display_mode *mode,
354 struct drm_display_mode *other_mode) 354 struct drm_display_mode *other_mode)
355{ 355{
356 u32 tmp = 0; 356 u32 tmp;
357 /* 357 /*
358 * Line Buffer Setup 358 * Line Buffer Setup
359 * There are 3 line buffers, each one shared by 2 display controllers. 359 * There are 3 line buffers, each one shared by 2 display controllers.
@@ -363,64 +363,63 @@ static u32 evergreen_line_buffer_adjust(struct radeon_device *rdev,
363 * first display controller 363 * first display controller
364 * 0 - first half of lb (3840 * 2) 364 * 0 - first half of lb (3840 * 2)
365 * 1 - first 3/4 of lb (5760 * 2) 365 * 1 - first 3/4 of lb (5760 * 2)
366 * 2 - whole lb (7680 * 2) 366 * 2 - whole lb (7680 * 2), other crtc must be disabled
367 * 3 - first 1/4 of lb (1920 * 2) 367 * 3 - first 1/4 of lb (1920 * 2)
368 * second display controller 368 * second display controller
369 * 4 - second half of lb (3840 * 2) 369 * 4 - second half of lb (3840 * 2)
370 * 5 - second 3/4 of lb (5760 * 2) 370 * 5 - second 3/4 of lb (5760 * 2)
371 * 6 - whole lb (7680 * 2) 371 * 6 - whole lb (7680 * 2), other crtc must be disabled
372 * 7 - last 1/4 of lb (1920 * 2) 372 * 7 - last 1/4 of lb (1920 * 2)
373 */ 373 */
374 if (mode && other_mode) { 374 /* this can get tricky if we have two large displays on a paired group
375 if (mode->hdisplay > other_mode->hdisplay) { 375 * of crtcs. Ideally for multiple large displays we'd assign them to
376 if (mode->hdisplay > 2560) 376 * non-linked crtcs for maximum line buffer allocation.
377 tmp = 1; /* 3/4 */ 377 */
378 else 378 if (radeon_crtc->base.enabled && mode) {
379 tmp = 0; /* 1/2 */ 379 if (other_mode)
380 } else if (other_mode->hdisplay > mode->hdisplay) {
381 if (other_mode->hdisplay > 2560)
382 tmp = 3; /* 1/4 */
383 else
384 tmp = 0; /* 1/2 */
385 } else
386 tmp = 0; /* 1/2 */ 380 tmp = 0; /* 1/2 */
387 } else if (mode) 381 else
388 tmp = 2; /* whole */ 382 tmp = 2; /* whole */
389 else if (other_mode) 383 } else
390 tmp = 3; /* 1/4 */ 384 tmp = 0;
391 385
392 /* second controller of the pair uses second half of the lb */ 386 /* second controller of the pair uses second half of the lb */
393 if (radeon_crtc->crtc_id % 2) 387 if (radeon_crtc->crtc_id % 2)
394 tmp += 4; 388 tmp += 4;
395 WREG32(DC_LB_MEMORY_SPLIT + radeon_crtc->crtc_offset, tmp); 389 WREG32(DC_LB_MEMORY_SPLIT + radeon_crtc->crtc_offset, tmp);
396 390
397 switch (tmp) { 391 if (radeon_crtc->base.enabled && mode) {
398 case 0: 392 switch (tmp) {
399 case 4: 393 case 0:
400 default: 394 case 4:
401 if (ASIC_IS_DCE5(rdev)) 395 default:
402 return 4096 * 2; 396 if (ASIC_IS_DCE5(rdev))
403 else 397 return 4096 * 2;
404 return 3840 * 2; 398 else
405 case 1: 399 return 3840 * 2;
406 case 5: 400 case 1:
407 if (ASIC_IS_DCE5(rdev)) 401 case 5:
408 return 6144 * 2; 402 if (ASIC_IS_DCE5(rdev))
409 else 403 return 6144 * 2;
410 return 5760 * 2; 404 else
411 case 2: 405 return 5760 * 2;
412 case 6: 406 case 2:
413 if (ASIC_IS_DCE5(rdev)) 407 case 6:
414 return 8192 * 2; 408 if (ASIC_IS_DCE5(rdev))
415 else 409 return 8192 * 2;
416 return 7680 * 2; 410 else
417 case 3: 411 return 7680 * 2;
418 case 7: 412 case 3:
419 if (ASIC_IS_DCE5(rdev)) 413 case 7:
420 return 2048 * 2; 414 if (ASIC_IS_DCE5(rdev))
421 else 415 return 2048 * 2;
422 return 1920 * 2; 416 else
417 return 1920 * 2;
418 }
423 } 419 }
420
421 /* controller not enabled, so no lb used */
422 return 0;
424} 423}
425 424
426static u32 evergreen_get_number_of_dram_channels(struct radeon_device *rdev) 425static u32 evergreen_get_number_of_dram_channels(struct radeon_device *rdev)
@@ -863,9 +862,15 @@ int evergreen_pcie_gart_enable(struct radeon_device *rdev)
863 SYSTEM_ACCESS_MODE_NOT_IN_SYS | 862 SYSTEM_ACCESS_MODE_NOT_IN_SYS |
864 SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU | 863 SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU |
865 EFFECTIVE_L1_TLB_SIZE(5) | EFFECTIVE_L1_QUEUE_SIZE(5); 864 EFFECTIVE_L1_TLB_SIZE(5) | EFFECTIVE_L1_QUEUE_SIZE(5);
866 WREG32(MC_VM_MD_L1_TLB0_CNTL, tmp); 865 if (rdev->flags & RADEON_IS_IGP) {
867 WREG32(MC_VM_MD_L1_TLB1_CNTL, tmp); 866 WREG32(FUS_MC_VM_MD_L1_TLB0_CNTL, tmp);
868 WREG32(MC_VM_MD_L1_TLB2_CNTL, tmp); 867 WREG32(FUS_MC_VM_MD_L1_TLB1_CNTL, tmp);
868 WREG32(FUS_MC_VM_MD_L1_TLB2_CNTL, tmp);
869 } else {
870 WREG32(MC_VM_MD_L1_TLB0_CNTL, tmp);
871 WREG32(MC_VM_MD_L1_TLB1_CNTL, tmp);
872 WREG32(MC_VM_MD_L1_TLB2_CNTL, tmp);
873 }
869 WREG32(MC_VM_MB_L1_TLB0_CNTL, tmp); 874 WREG32(MC_VM_MB_L1_TLB0_CNTL, tmp);
870 WREG32(MC_VM_MB_L1_TLB1_CNTL, tmp); 875 WREG32(MC_VM_MB_L1_TLB1_CNTL, tmp);
871 WREG32(MC_VM_MB_L1_TLB2_CNTL, tmp); 876 WREG32(MC_VM_MB_L1_TLB2_CNTL, tmp);
@@ -1775,7 +1780,10 @@ static void evergreen_gpu_init(struct radeon_device *rdev)
1775 1780
1776 1781
1777 mc_shared_chmap = RREG32(MC_SHARED_CHMAP); 1782 mc_shared_chmap = RREG32(MC_SHARED_CHMAP);
1778 mc_arb_ramcfg = RREG32(MC_ARB_RAMCFG); 1783 if (rdev->flags & RADEON_IS_IGP)
1784 mc_arb_ramcfg = RREG32(FUS_MC_ARB_RAMCFG);
1785 else
1786 mc_arb_ramcfg = RREG32(MC_ARB_RAMCFG);
1779 1787
1780 switch (rdev->config.evergreen.max_tile_pipes) { 1788 switch (rdev->config.evergreen.max_tile_pipes) {
1781 case 1: 1789 case 1:
@@ -2581,7 +2589,7 @@ static inline u32 evergreen_get_ih_wptr(struct radeon_device *rdev)
2581 u32 wptr, tmp; 2589 u32 wptr, tmp;
2582 2590
2583 if (rdev->wb.enabled) 2591 if (rdev->wb.enabled)
2584 wptr = rdev->wb.wb[R600_WB_IH_WPTR_OFFSET/4]; 2592 wptr = le32_to_cpu(rdev->wb.wb[R600_WB_IH_WPTR_OFFSET/4]);
2585 else 2593 else
2586 wptr = RREG32(IH_RB_WPTR); 2594 wptr = RREG32(IH_RB_WPTR);
2587 2595
@@ -2924,11 +2932,6 @@ static int evergreen_startup(struct radeon_device *rdev)
2924 rdev->asic->copy = NULL; 2932 rdev->asic->copy = NULL;
2925 dev_warn(rdev->dev, "failed blitter (%d) falling back to memcpy\n", r); 2933 dev_warn(rdev->dev, "failed blitter (%d) falling back to memcpy\n", r);
2926 } 2934 }
2927 /* XXX: ontario has problems blitting to gart at the moment */
2928 if (rdev->family == CHIP_PALM) {
2929 rdev->asic->copy = NULL;
2930 radeon_ttm_set_active_vram_size(rdev, rdev->mc.visible_vram_size);
2931 }
2932 2935
2933 /* allocate wb buffer */ 2936 /* allocate wb buffer */
2934 r = radeon_wb_init(rdev); 2937 r = radeon_wb_init(rdev);
diff --git a/drivers/gpu/drm/radeon/evergreend.h b/drivers/gpu/drm/radeon/evergreend.h
index 9aaa3f0c9372..fc40e0cc3451 100644
--- a/drivers/gpu/drm/radeon/evergreend.h
+++ b/drivers/gpu/drm/radeon/evergreend.h
@@ -200,6 +200,7 @@
200#define BURSTLENGTH_SHIFT 9 200#define BURSTLENGTH_SHIFT 9
201#define BURSTLENGTH_MASK 0x00000200 201#define BURSTLENGTH_MASK 0x00000200
202#define CHANSIZE_OVERRIDE (1 << 11) 202#define CHANSIZE_OVERRIDE (1 << 11)
203#define FUS_MC_ARB_RAMCFG 0x2768
203#define MC_VM_AGP_TOP 0x2028 204#define MC_VM_AGP_TOP 0x2028
204#define MC_VM_AGP_BOT 0x202C 205#define MC_VM_AGP_BOT 0x202C
205#define MC_VM_AGP_BASE 0x2030 206#define MC_VM_AGP_BASE 0x2030
@@ -221,6 +222,11 @@
221#define MC_VM_MD_L1_TLB0_CNTL 0x2654 222#define MC_VM_MD_L1_TLB0_CNTL 0x2654
222#define MC_VM_MD_L1_TLB1_CNTL 0x2658 223#define MC_VM_MD_L1_TLB1_CNTL 0x2658
223#define MC_VM_MD_L1_TLB2_CNTL 0x265C 224#define MC_VM_MD_L1_TLB2_CNTL 0x265C
225
226#define FUS_MC_VM_MD_L1_TLB0_CNTL 0x265C
227#define FUS_MC_VM_MD_L1_TLB1_CNTL 0x2660
228#define FUS_MC_VM_MD_L1_TLB2_CNTL 0x2664
229
224#define MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR 0x203C 230#define MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR 0x203C
225#define MC_VM_SYSTEM_APERTURE_HIGH_ADDR 0x2038 231#define MC_VM_SYSTEM_APERTURE_HIGH_ADDR 0x2038
226#define MC_VM_SYSTEM_APERTURE_LOW_ADDR 0x2034 232#define MC_VM_SYSTEM_APERTURE_LOW_ADDR 0x2034
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index 7aade20f63a8..3d8a7634bbe9 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -674,7 +674,7 @@ static void cayman_gpu_init(struct radeon_device *rdev)
674 674
675 cc_rb_backend_disable = RREG32(CC_RB_BACKEND_DISABLE); 675 cc_rb_backend_disable = RREG32(CC_RB_BACKEND_DISABLE);
676 cc_gc_shader_pipe_config = RREG32(CC_GC_SHADER_PIPE_CONFIG); 676 cc_gc_shader_pipe_config = RREG32(CC_GC_SHADER_PIPE_CONFIG);
677 cgts_tcc_disable = RREG32(CGTS_TCC_DISABLE); 677 cgts_tcc_disable = 0xff000000;
678 gc_user_rb_backend_disable = RREG32(GC_USER_RB_BACKEND_DISABLE); 678 gc_user_rb_backend_disable = RREG32(GC_USER_RB_BACKEND_DISABLE);
679 gc_user_shader_pipe_config = RREG32(GC_USER_SHADER_PIPE_CONFIG); 679 gc_user_shader_pipe_config = RREG32(GC_USER_SHADER_PIPE_CONFIG);
680 cgts_user_tcc_disable = RREG32(CGTS_USER_TCC_DISABLE); 680 cgts_user_tcc_disable = RREG32(CGTS_USER_TCC_DISABLE);
@@ -871,7 +871,7 @@ static void cayman_gpu_init(struct radeon_device *rdev)
871 871
872 smx_dc_ctl0 = RREG32(SMX_DC_CTL0); 872 smx_dc_ctl0 = RREG32(SMX_DC_CTL0);
873 smx_dc_ctl0 &= ~NUMBER_OF_SETS(0x1ff); 873 smx_dc_ctl0 &= ~NUMBER_OF_SETS(0x1ff);
874 smx_dc_ctl0 |= NUMBER_OF_SETS(rdev->config.evergreen.sx_num_of_sets); 874 smx_dc_ctl0 |= NUMBER_OF_SETS(rdev->config.cayman.sx_num_of_sets);
875 WREG32(SMX_DC_CTL0, smx_dc_ctl0); 875 WREG32(SMX_DC_CTL0, smx_dc_ctl0);
876 876
877 WREG32(SPI_CONFIG_CNTL_1, VTX_DONE_DELAY(4) | CRC_SIMD_ID_WADDR_DISABLE); 877 WREG32(SPI_CONFIG_CNTL_1, VTX_DONE_DELAY(4) | CRC_SIMD_ID_WADDR_DISABLE);
@@ -887,20 +887,20 @@ static void cayman_gpu_init(struct radeon_device *rdev)
887 887
888 WREG32(TA_CNTL_AUX, DISABLE_CUBE_ANISO); 888 WREG32(TA_CNTL_AUX, DISABLE_CUBE_ANISO);
889 889
890 WREG32(SX_EXPORT_BUFFER_SIZES, (COLOR_BUFFER_SIZE((rdev->config.evergreen.sx_max_export_size / 4) - 1) | 890 WREG32(SX_EXPORT_BUFFER_SIZES, (COLOR_BUFFER_SIZE((rdev->config.cayman.sx_max_export_size / 4) - 1) |
891 POSITION_BUFFER_SIZE((rdev->config.evergreen.sx_max_export_pos_size / 4) - 1) | 891 POSITION_BUFFER_SIZE((rdev->config.cayman.sx_max_export_pos_size / 4) - 1) |
892 SMX_BUFFER_SIZE((rdev->config.evergreen.sx_max_export_smx_size / 4) - 1))); 892 SMX_BUFFER_SIZE((rdev->config.cayman.sx_max_export_smx_size / 4) - 1)));
893 893
894 WREG32(PA_SC_FIFO_SIZE, (SC_PRIM_FIFO_SIZE(rdev->config.evergreen.sc_prim_fifo_size) | 894 WREG32(PA_SC_FIFO_SIZE, (SC_PRIM_FIFO_SIZE(rdev->config.cayman.sc_prim_fifo_size) |
895 SC_HIZ_TILE_FIFO_SIZE(rdev->config.evergreen.sc_hiz_tile_fifo_size) | 895 SC_HIZ_TILE_FIFO_SIZE(rdev->config.cayman.sc_hiz_tile_fifo_size) |
896 SC_EARLYZ_TILE_FIFO_SIZE(rdev->config.evergreen.sc_earlyz_tile_fifo_size))); 896 SC_EARLYZ_TILE_FIFO_SIZE(rdev->config.cayman.sc_earlyz_tile_fifo_size)));
897 897
898 898
899 WREG32(VGT_NUM_INSTANCES, 1); 899 WREG32(VGT_NUM_INSTANCES, 1);
900 900
901 WREG32(CP_PERFMON_CNTL, 0); 901 WREG32(CP_PERFMON_CNTL, 0);
902 902
903 WREG32(SQ_MS_FIFO_SIZES, (CACHE_FIFO_SIZE(16 * rdev->config.evergreen.sq_num_cf_insts) | 903 WREG32(SQ_MS_FIFO_SIZES, (CACHE_FIFO_SIZE(16 * rdev->config.cayman.sq_num_cf_insts) |
904 FETCH_FIFO_HIWATER(0x4) | 904 FETCH_FIFO_HIWATER(0x4) |
905 DONE_FIFO_HIWATER(0xe0) | 905 DONE_FIFO_HIWATER(0xe0) |
906 ALU_UPDATE_FIFO_HIWATER(0x8))); 906 ALU_UPDATE_FIFO_HIWATER(0x8)));
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 15d58292677a..6f27593901c7 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -3231,7 +3231,7 @@ static inline u32 r600_get_ih_wptr(struct radeon_device *rdev)
3231 u32 wptr, tmp; 3231 u32 wptr, tmp;
3232 3232
3233 if (rdev->wb.enabled) 3233 if (rdev->wb.enabled)
3234 wptr = rdev->wb.wb[R600_WB_IH_WPTR_OFFSET/4]; 3234 wptr = le32_to_cpu(rdev->wb.wb[R600_WB_IH_WPTR_OFFSET/4]);
3235 else 3235 else
3236 wptr = RREG32(IH_RB_WPTR); 3236 wptr = RREG32(IH_RB_WPTR);
3237 3237
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
index f5d12fb103fa..90dfb2b8cf03 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -431,7 +431,7 @@ static bool radeon_atom_apply_quirks(struct drm_device *dev,
431 } 431 }
432 } 432 }
433 433
434 /* Acer laptop (Acer TravelMate 5730G) has an HDMI port 434 /* Acer laptop (Acer TravelMate 5730/5730G) has an HDMI port
435 * on the laptop and a DVI port on the docking station and 435 * on the laptop and a DVI port on the docking station and
436 * both share the same encoder, hpd pin, and ddc line. 436 * both share the same encoder, hpd pin, and ddc line.
437 * So while the bios table is technically correct, 437 * So while the bios table is technically correct,
@@ -440,7 +440,7 @@ static bool radeon_atom_apply_quirks(struct drm_device *dev,
440 * with different crtcs which isn't possible on the hardware 440 * with different crtcs which isn't possible on the hardware
441 * side and leaves no crtcs for LVDS or VGA. 441 * side and leaves no crtcs for LVDS or VGA.
442 */ 442 */
443 if ((dev->pdev->device == 0x95c4) && 443 if (((dev->pdev->device == 0x95c4) || (dev->pdev->device == 0x9591)) &&
444 (dev->pdev->subsystem_vendor == 0x1025) && 444 (dev->pdev->subsystem_vendor == 0x1025) &&
445 (dev->pdev->subsystem_device == 0x013c)) { 445 (dev->pdev->subsystem_device == 0x013c)) {
446 if ((*connector_type == DRM_MODE_CONNECTOR_DVII) && 446 if ((*connector_type == DRM_MODE_CONNECTOR_DVII) &&
@@ -1574,9 +1574,17 @@ struct radeon_encoder_atom_dig *radeon_atombios_get_lvds_info(struct
1574 ATOM_FAKE_EDID_PATCH_RECORD *fake_edid_record; 1574 ATOM_FAKE_EDID_PATCH_RECORD *fake_edid_record;
1575 ATOM_PANEL_RESOLUTION_PATCH_RECORD *panel_res_record; 1575 ATOM_PANEL_RESOLUTION_PATCH_RECORD *panel_res_record;
1576 bool bad_record = false; 1576 bool bad_record = false;
1577 u8 *record = (u8 *)(mode_info->atom_context->bios + 1577 u8 *record;
1578 data_offset + 1578
1579 le16_to_cpu(lvds_info->info.usModePatchTableOffset)); 1579 if ((frev == 1) && (crev < 2))
1580 /* absolute */
1581 record = (u8 *)(mode_info->atom_context->bios +
1582 le16_to_cpu(lvds_info->info.usModePatchTableOffset));
1583 else
1584 /* relative */
1585 record = (u8 *)(mode_info->atom_context->bios +
1586 data_offset +
1587 le16_to_cpu(lvds_info->info.usModePatchTableOffset));
1580 while (*record != ATOM_RECORD_END_TYPE) { 1588 while (*record != ATOM_RECORD_END_TYPE) {
1581 switch (*record) { 1589 switch (*record) {
1582 case LCD_MODE_PATCH_RECORD_MODE_TYPE: 1590 case LCD_MODE_PATCH_RECORD_MODE_TYPE:
@@ -1599,9 +1607,10 @@ struct radeon_encoder_atom_dig *radeon_atombios_get_lvds_info(struct
1599 memcpy((u8 *)edid, (u8 *)&fake_edid_record->ucFakeEDIDString[0], 1607 memcpy((u8 *)edid, (u8 *)&fake_edid_record->ucFakeEDIDString[0],
1600 fake_edid_record->ucFakeEDIDLength); 1608 fake_edid_record->ucFakeEDIDLength);
1601 1609
1602 if (drm_edid_is_valid(edid)) 1610 if (drm_edid_is_valid(edid)) {
1603 rdev->mode_info.bios_hardcoded_edid = edid; 1611 rdev->mode_info.bios_hardcoded_edid = edid;
1604 else 1612 rdev->mode_info.bios_hardcoded_edid_size = edid_size;
1613 } else
1605 kfree(edid); 1614 kfree(edid);
1606 } 1615 }
1607 } 1616 }
diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
index ed5dfe58f29c..9d95792bea3e 100644
--- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c
+++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
@@ -15,6 +15,9 @@
15#define ATPX_VERSION 0 15#define ATPX_VERSION 0
16#define ATPX_GPU_PWR 2 16#define ATPX_GPU_PWR 2
17#define ATPX_MUX_SELECT 3 17#define ATPX_MUX_SELECT 3
18#define ATPX_I2C_MUX_SELECT 4
19#define ATPX_SWITCH_START 5
20#define ATPX_SWITCH_END 6
18 21
19#define ATPX_INTEGRATED 0 22#define ATPX_INTEGRATED 0
20#define ATPX_DISCRETE 1 23#define ATPX_DISCRETE 1
@@ -149,13 +152,35 @@ static int radeon_atpx_switch_mux(acpi_handle handle, int mux_id)
149 return radeon_atpx_execute(handle, ATPX_MUX_SELECT, mux_id); 152 return radeon_atpx_execute(handle, ATPX_MUX_SELECT, mux_id);
150} 153}
151 154
155static int radeon_atpx_switch_i2c_mux(acpi_handle handle, int mux_id)
156{
157 return radeon_atpx_execute(handle, ATPX_I2C_MUX_SELECT, mux_id);
158}
159
160static int radeon_atpx_switch_start(acpi_handle handle, int gpu_id)
161{
162 return radeon_atpx_execute(handle, ATPX_SWITCH_START, gpu_id);
163}
164
165static int radeon_atpx_switch_end(acpi_handle handle, int gpu_id)
166{
167 return radeon_atpx_execute(handle, ATPX_SWITCH_END, gpu_id);
168}
152 169
153static int radeon_atpx_switchto(enum vga_switcheroo_client_id id) 170static int radeon_atpx_switchto(enum vga_switcheroo_client_id id)
154{ 171{
172 int gpu_id;
173
155 if (id == VGA_SWITCHEROO_IGD) 174 if (id == VGA_SWITCHEROO_IGD)
156 radeon_atpx_switch_mux(radeon_atpx_priv.atpx_handle, 0); 175 gpu_id = ATPX_INTEGRATED;
157 else 176 else
158 radeon_atpx_switch_mux(radeon_atpx_priv.atpx_handle, 1); 177 gpu_id = ATPX_DISCRETE;
178
179 radeon_atpx_switch_start(radeon_atpx_priv.atpx_handle, gpu_id);
180 radeon_atpx_switch_mux(radeon_atpx_priv.atpx_handle, gpu_id);
181 radeon_atpx_switch_i2c_mux(radeon_atpx_priv.atpx_handle, gpu_id);
182 radeon_atpx_switch_end(radeon_atpx_priv.atpx_handle, gpu_id);
183
159 return 0; 184 return 0;
160} 185}
161 186
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index 2ef6d5135064..5f45fa12bb8b 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -1199,7 +1199,7 @@ radeon_add_atom_connector(struct drm_device *dev,
1199 if (router->ddc_valid || router->cd_valid) { 1199 if (router->ddc_valid || router->cd_valid) {
1200 radeon_connector->router_bus = radeon_i2c_lookup(rdev, &router->i2c_info); 1200 radeon_connector->router_bus = radeon_i2c_lookup(rdev, &router->i2c_info);
1201 if (!radeon_connector->router_bus) 1201 if (!radeon_connector->router_bus)
1202 goto failed; 1202 DRM_ERROR("Failed to assign router i2c bus! Check dmesg for i2c errors.\n");
1203 } 1203 }
1204 switch (connector_type) { 1204 switch (connector_type) {
1205 case DRM_MODE_CONNECTOR_VGA: 1205 case DRM_MODE_CONNECTOR_VGA:
@@ -1208,7 +1208,7 @@ radeon_add_atom_connector(struct drm_device *dev,
1208 if (i2c_bus->valid) { 1208 if (i2c_bus->valid) {
1209 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1209 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1210 if (!radeon_connector->ddc_bus) 1210 if (!radeon_connector->ddc_bus)
1211 goto failed; 1211 DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1212 } 1212 }
1213 radeon_connector->dac_load_detect = true; 1213 radeon_connector->dac_load_detect = true;
1214 drm_connector_attach_property(&radeon_connector->base, 1214 drm_connector_attach_property(&radeon_connector->base,
@@ -1226,7 +1226,7 @@ radeon_add_atom_connector(struct drm_device *dev,
1226 if (i2c_bus->valid) { 1226 if (i2c_bus->valid) {
1227 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1227 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1228 if (!radeon_connector->ddc_bus) 1228 if (!radeon_connector->ddc_bus)
1229 goto failed; 1229 DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1230 } 1230 }
1231 radeon_connector->dac_load_detect = true; 1231 radeon_connector->dac_load_detect = true;
1232 drm_connector_attach_property(&radeon_connector->base, 1232 drm_connector_attach_property(&radeon_connector->base,
@@ -1249,7 +1249,7 @@ radeon_add_atom_connector(struct drm_device *dev,
1249 if (i2c_bus->valid) { 1249 if (i2c_bus->valid) {
1250 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1250 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1251 if (!radeon_connector->ddc_bus) 1251 if (!radeon_connector->ddc_bus)
1252 goto failed; 1252 DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1253 } 1253 }
1254 subpixel_order = SubPixelHorizontalRGB; 1254 subpixel_order = SubPixelHorizontalRGB;
1255 drm_connector_attach_property(&radeon_connector->base, 1255 drm_connector_attach_property(&radeon_connector->base,
@@ -1290,7 +1290,7 @@ radeon_add_atom_connector(struct drm_device *dev,
1290 if (i2c_bus->valid) { 1290 if (i2c_bus->valid) {
1291 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1291 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1292 if (!radeon_connector->ddc_bus) 1292 if (!radeon_connector->ddc_bus)
1293 goto failed; 1293 DRM_ERROR("HDMI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1294 } 1294 }
1295 drm_connector_attach_property(&radeon_connector->base, 1295 drm_connector_attach_property(&radeon_connector->base,
1296 rdev->mode_info.coherent_mode_property, 1296 rdev->mode_info.coherent_mode_property,
@@ -1329,10 +1329,10 @@ radeon_add_atom_connector(struct drm_device *dev,
1329 else 1329 else
1330 radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "DP-auxch"); 1330 radeon_dig_connector->dp_i2c_bus = radeon_i2c_create_dp(dev, i2c_bus, "DP-auxch");
1331 if (!radeon_dig_connector->dp_i2c_bus) 1331 if (!radeon_dig_connector->dp_i2c_bus)
1332 goto failed; 1332 DRM_ERROR("DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n");
1333 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1333 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1334 if (!radeon_connector->ddc_bus) 1334 if (!radeon_connector->ddc_bus)
1335 goto failed; 1335 DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1336 } 1336 }
1337 subpixel_order = SubPixelHorizontalRGB; 1337 subpixel_order = SubPixelHorizontalRGB;
1338 drm_connector_attach_property(&radeon_connector->base, 1338 drm_connector_attach_property(&radeon_connector->base,
@@ -1381,7 +1381,7 @@ radeon_add_atom_connector(struct drm_device *dev,
1381 if (i2c_bus->valid) { 1381 if (i2c_bus->valid) {
1382 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1382 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1383 if (!radeon_connector->ddc_bus) 1383 if (!radeon_connector->ddc_bus)
1384 goto failed; 1384 DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1385 } 1385 }
1386 drm_connector_attach_property(&radeon_connector->base, 1386 drm_connector_attach_property(&radeon_connector->base,
1387 dev->mode_config.scaling_mode_property, 1387 dev->mode_config.scaling_mode_property,
@@ -1457,7 +1457,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
1457 if (i2c_bus->valid) { 1457 if (i2c_bus->valid) {
1458 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1458 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1459 if (!radeon_connector->ddc_bus) 1459 if (!radeon_connector->ddc_bus)
1460 goto failed; 1460 DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1461 } 1461 }
1462 radeon_connector->dac_load_detect = true; 1462 radeon_connector->dac_load_detect = true;
1463 drm_connector_attach_property(&radeon_connector->base, 1463 drm_connector_attach_property(&radeon_connector->base,
@@ -1475,7 +1475,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
1475 if (i2c_bus->valid) { 1475 if (i2c_bus->valid) {
1476 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1476 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1477 if (!radeon_connector->ddc_bus) 1477 if (!radeon_connector->ddc_bus)
1478 goto failed; 1478 DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1479 } 1479 }
1480 radeon_connector->dac_load_detect = true; 1480 radeon_connector->dac_load_detect = true;
1481 drm_connector_attach_property(&radeon_connector->base, 1481 drm_connector_attach_property(&radeon_connector->base,
@@ -1493,7 +1493,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
1493 if (i2c_bus->valid) { 1493 if (i2c_bus->valid) {
1494 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1494 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1495 if (!radeon_connector->ddc_bus) 1495 if (!radeon_connector->ddc_bus)
1496 goto failed; 1496 DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1497 } 1497 }
1498 if (connector_type == DRM_MODE_CONNECTOR_DVII) { 1498 if (connector_type == DRM_MODE_CONNECTOR_DVII) {
1499 radeon_connector->dac_load_detect = true; 1499 radeon_connector->dac_load_detect = true;
@@ -1538,7 +1538,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
1538 if (i2c_bus->valid) { 1538 if (i2c_bus->valid) {
1539 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus); 1539 radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
1540 if (!radeon_connector->ddc_bus) 1540 if (!radeon_connector->ddc_bus)
1541 goto failed; 1541 DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1542 } 1542 }
1543 drm_connector_attach_property(&radeon_connector->base, 1543 drm_connector_attach_property(&radeon_connector->base,
1544 dev->mode_config.scaling_mode_property, 1544 dev->mode_config.scaling_mode_property,
@@ -1567,9 +1567,4 @@ radeon_add_legacy_connector(struct drm_device *dev,
1567 radeon_legacy_backlight_init(radeon_encoder, connector); 1567 radeon_legacy_backlight_init(radeon_encoder, connector);
1568 } 1568 }
1569 } 1569 }
1570 return;
1571
1572failed:
1573 drm_connector_cleanup(connector);
1574 kfree(connector);
1575} 1570}
diff --git a/drivers/gpu/drm/radeon/radeon_cursor.c b/drivers/gpu/drm/radeon/radeon_cursor.c
index bdf2fa1189ae..3189a7efb2e9 100644
--- a/drivers/gpu/drm/radeon/radeon_cursor.c
+++ b/drivers/gpu/drm/radeon/radeon_cursor.c
@@ -167,9 +167,6 @@ int radeon_crtc_cursor_set(struct drm_crtc *crtc,
167 return -EINVAL; 167 return -EINVAL;
168 } 168 }
169 169
170 radeon_crtc->cursor_width = width;
171 radeon_crtc->cursor_height = height;
172
173 obj = drm_gem_object_lookup(crtc->dev, file_priv, handle); 170 obj = drm_gem_object_lookup(crtc->dev, file_priv, handle);
174 if (!obj) { 171 if (!obj) {
175 DRM_ERROR("Cannot find cursor object %x for crtc %d\n", handle, radeon_crtc->crtc_id); 172 DRM_ERROR("Cannot find cursor object %x for crtc %d\n", handle, radeon_crtc->crtc_id);
@@ -180,6 +177,9 @@ int radeon_crtc_cursor_set(struct drm_crtc *crtc,
180 if (ret) 177 if (ret)
181 goto fail; 178 goto fail;
182 179
180 radeon_crtc->cursor_width = width;
181 radeon_crtc->cursor_height = height;
182
183 radeon_lock_cursor(crtc, true); 183 radeon_lock_cursor(crtc, true);
184 /* XXX only 27 bit offset for legacy cursor */ 184 /* XXX only 27 bit offset for legacy cursor */
185 radeon_set_cursor(crtc, obj, gpu_addr); 185 radeon_set_cursor(crtc, obj, gpu_addr);
diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c
index 8a955bbdb608..a533f52fd163 100644
--- a/drivers/gpu/drm/radeon/radeon_gart.c
+++ b/drivers/gpu/drm/radeon/radeon_gart.c
@@ -181,9 +181,9 @@ int radeon_gart_bind(struct radeon_device *rdev, unsigned offset,
181 p = t / (PAGE_SIZE / RADEON_GPU_PAGE_SIZE); 181 p = t / (PAGE_SIZE / RADEON_GPU_PAGE_SIZE);
182 182
183 for (i = 0; i < pages; i++, p++) { 183 for (i = 0; i < pages; i++, p++) {
184 /* On TTM path, we only use the DMA API if TTM_PAGE_FLAG_DMA32 184 /* we reverted the patch using dma_addr in TTM for now but this
185 * is requested. */ 185 * code stops building on alpha so just comment it out for now */
186 if (dma_addr[i] != DMA_ERROR_CODE) { 186 if (0) { /*dma_addr[i] != DMA_ERROR_CODE) */
187 rdev->gart.ttm_alloced[p] = true; 187 rdev->gart.ttm_alloced[p] = true;
188 rdev->gart.pages_addr[p] = dma_addr[i]; 188 rdev->gart.pages_addr[p] = dma_addr[i];
189 } else { 189 } else {
diff --git a/drivers/gpu/drm/radeon/radeon_i2c.c b/drivers/gpu/drm/radeon/radeon_i2c.c
index ccbabf734a61..983cbac75af0 100644
--- a/drivers/gpu/drm/radeon/radeon_i2c.c
+++ b/drivers/gpu/drm/radeon/radeon_i2c.c
@@ -1096,6 +1096,9 @@ void radeon_router_select_ddc_port(struct radeon_connector *radeon_connector)
1096 if (!radeon_connector->router.ddc_valid) 1096 if (!radeon_connector->router.ddc_valid)
1097 return; 1097 return;
1098 1098
1099 if (!radeon_connector->router_bus)
1100 return;
1101
1099 radeon_i2c_get_byte(radeon_connector->router_bus, 1102 radeon_i2c_get_byte(radeon_connector->router_bus,
1100 radeon_connector->router.i2c_addr, 1103 radeon_connector->router.i2c_addr,
1101 0x3, &val); 1104 0x3, &val);
@@ -1121,6 +1124,9 @@ void radeon_router_select_cd_port(struct radeon_connector *radeon_connector)
1121 if (!radeon_connector->router.cd_valid) 1124 if (!radeon_connector->router.cd_valid)
1122 return; 1125 return;
1123 1126
1127 if (!radeon_connector->router_bus)
1128 return;
1129
1124 radeon_i2c_get_byte(radeon_connector->router_bus, 1130 radeon_i2c_get_byte(radeon_connector->router_bus,
1125 radeon_connector->router.i2c_addr, 1131 radeon_connector->router.i2c_addr,
1126 0x3, &val); 1132 0x3, &val);
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index bf7d4c061451..bd58af658581 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -221,6 +221,22 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
221 return -EINVAL; 221 return -EINVAL;
222 } 222 }
223 break; 223 break;
224 case RADEON_INFO_NUM_TILE_PIPES:
225 if (rdev->family >= CHIP_CAYMAN)
226 value = rdev->config.cayman.max_tile_pipes;
227 else if (rdev->family >= CHIP_CEDAR)
228 value = rdev->config.evergreen.max_tile_pipes;
229 else if (rdev->family >= CHIP_RV770)
230 value = rdev->config.rv770.max_tile_pipes;
231 else if (rdev->family >= CHIP_R600)
232 value = rdev->config.r600.max_tile_pipes;
233 else {
234 return -EINVAL;
235 }
236 break;
237 case RADEON_INFO_FUSION_GART_WORKING:
238 value = 1;
239 break;
224 default: 240 default:
225 DRM_DEBUG_KMS("Invalid request %d\n", info->request); 241 DRM_DEBUG_KMS("Invalid request %d\n", info->request);
226 return -EINVAL; 242 return -EINVAL;
diff --git a/drivers/gpu/drm/radeon/reg_srcs/cayman b/drivers/gpu/drm/radeon/reg_srcs/cayman
index 6334f8ac1209..0aa8e85a9457 100644
--- a/drivers/gpu/drm/radeon/reg_srcs/cayman
+++ b/drivers/gpu/drm/radeon/reg_srcs/cayman
@@ -33,6 +33,7 @@ cayman 0x9400
330x00008E48 SQ_EX_ALLOC_TABLE_SLOTS 330x00008E48 SQ_EX_ALLOC_TABLE_SLOTS
340x00009100 SPI_CONFIG_CNTL 340x00009100 SPI_CONFIG_CNTL
350x0000913C SPI_CONFIG_CNTL_1 350x0000913C SPI_CONFIG_CNTL_1
360x00009508 TA_CNTL_AUX
360x00009830 DB_DEBUG 370x00009830 DB_DEBUG
370x00009834 DB_DEBUG2 380x00009834 DB_DEBUG2
380x00009838 DB_DEBUG3 390x00009838 DB_DEBUG3
diff --git a/drivers/gpu/drm/radeon/reg_srcs/evergreen b/drivers/gpu/drm/radeon/reg_srcs/evergreen
index 7e1637176e08..0e28cae7ea43 100644
--- a/drivers/gpu/drm/radeon/reg_srcs/evergreen
+++ b/drivers/gpu/drm/radeon/reg_srcs/evergreen
@@ -46,6 +46,7 @@ evergreen 0x9400
460x00008E48 SQ_EX_ALLOC_TABLE_SLOTS 460x00008E48 SQ_EX_ALLOC_TABLE_SLOTS
470x00009100 SPI_CONFIG_CNTL 470x00009100 SPI_CONFIG_CNTL
480x0000913C SPI_CONFIG_CNTL_1 480x0000913C SPI_CONFIG_CNTL_1
490x00009508 TA_CNTL_AUX
490x00009700 VC_CNTL 500x00009700 VC_CNTL
500x00009714 VC_ENHANCE 510x00009714 VC_ENHANCE
510x00009830 DB_DEBUG 520x00009830 DB_DEBUG
diff --git a/drivers/gpu/drm/radeon/reg_srcs/r600 b/drivers/gpu/drm/radeon/reg_srcs/r600
index af0da4ae3f55..92f1900dc7ca 100644
--- a/drivers/gpu/drm/radeon/reg_srcs/r600
+++ b/drivers/gpu/drm/radeon/reg_srcs/r600
@@ -708,6 +708,7 @@ r600 0x9400
7080x00028D0C DB_RENDER_CONTROL 7080x00028D0C DB_RENDER_CONTROL
7090x00028D10 DB_RENDER_OVERRIDE 7090x00028D10 DB_RENDER_OVERRIDE
7100x0002880C DB_SHADER_CONTROL 7100x0002880C DB_SHADER_CONTROL
7110x00028D28 DB_SRESULTS_COMPARE_STATE0
7110x00028D2C DB_SRESULTS_COMPARE_STATE1 7120x00028D2C DB_SRESULTS_COMPARE_STATE1
7120x00028430 DB_STENCILREFMASK 7130x00028430 DB_STENCILREFMASK
7130x00028434 DB_STENCILREFMASK_BF 7140x00028434 DB_STENCILREFMASK_BF
diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
index e01cacba685f..498b284e5ef9 100644
--- a/drivers/gpu/vga/vga_switcheroo.c
+++ b/drivers/gpu/vga/vga_switcheroo.c
@@ -219,9 +219,6 @@ static int vga_switchto_stage1(struct vga_switcheroo_client *new_client)
219 int i; 219 int i;
220 struct vga_switcheroo_client *active = NULL; 220 struct vga_switcheroo_client *active = NULL;
221 221
222 if (new_client->active == true)
223 return 0;
224
225 for (i = 0; i < VGA_SWITCHEROO_MAX_CLIENTS; i++) { 222 for (i = 0; i < VGA_SWITCHEROO_MAX_CLIENTS; i++) {
226 if (vgasr_priv.clients[i].active == true) { 223 if (vgasr_priv.clients[i].active == true) {
227 active = &vgasr_priv.clients[i]; 224 active = &vgasr_priv.clients[i];
@@ -372,6 +369,9 @@ vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf,
372 goto out; 369 goto out;
373 } 370 }
374 371
372 if (client->active == true)
373 goto out;
374
375 /* okay we want a switch - test if devices are willing to switch */ 375 /* okay we want a switch - test if devices are willing to switch */
376 can_switch = true; 376 can_switch = true;
377 for (i = 0; i < VGA_SWITCHEROO_MAX_CLIENTS; i++) { 377 for (i = 0; i < VGA_SWITCHEROO_MAX_CLIENTS; i++) {
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 060ef6327876..50e40dbd8bb6 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -110,8 +110,7 @@ config SENSORS_ADM1021
110 help 110 help
111 If you say yes here you get support for Analog Devices ADM1021 111 If you say yes here you get support for Analog Devices ADM1021
112 and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A, 112 and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A,
113 Genesys Logic GL523SM, National Semiconductor LM84, TI THMC10, 113 Genesys Logic GL523SM, National Semiconductor LM84 and TI THMC10.
114 and the XEON processor built-in sensor.
115 114
116 This driver can also be built as a module. If so, the module 115 This driver can also be built as a module. If so, the module
117 will be called adm1021. 116 will be called adm1021.
@@ -618,10 +617,10 @@ config SENSORS_LM90
618 depends on I2C 617 depends on I2C
619 help 618 help
620 If you say yes here you get support for National Semiconductor LM90, 619 If you say yes here you get support for National Semiconductor LM90,
621 LM86, LM89 and LM99, Analog Devices ADM1032 and ADT7461, Maxim 620 LM86, LM89 and LM99, Analog Devices ADM1032, ADT7461, and ADT7461A,
622 MAX6646, MAX6647, MAX6648, MAX6649, MAX6657, MAX6658, MAX6659, 621 Maxim MAX6646, MAX6647, MAX6648, MAX6649, MAX6657, MAX6658, MAX6659,
623 MAX6680, MAX6681, MAX6692, MAX6695, MAX6696, and Winbond/Nuvoton 622 MAX6680, MAX6681, MAX6692, MAX6695, MAX6696, ON Semiconductor NCT1008,
624 W83L771W/G/AWG/ASG sensor chips. 623 and Winbond/Nuvoton W83L771W/G/AWG/ASG sensor chips.
625 624
626 This driver can also be built as a module. If so, the module 625 This driver can also be built as a module. If so, the module
627 will be called lm90. 626 will be called lm90.
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
index 250d099ca398..da72dc12068c 100644
--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -1094,6 +1094,7 @@ static struct attribute *lm85_attributes_minctl[] = {
1094 &sensor_dev_attr_pwm1_auto_pwm_minctl.dev_attr.attr, 1094 &sensor_dev_attr_pwm1_auto_pwm_minctl.dev_attr.attr,
1095 &sensor_dev_attr_pwm2_auto_pwm_minctl.dev_attr.attr, 1095 &sensor_dev_attr_pwm2_auto_pwm_minctl.dev_attr.attr,
1096 &sensor_dev_attr_pwm3_auto_pwm_minctl.dev_attr.attr, 1096 &sensor_dev_attr_pwm3_auto_pwm_minctl.dev_attr.attr,
1097 NULL
1097}; 1098};
1098 1099
1099static const struct attribute_group lm85_group_minctl = { 1100static const struct attribute_group lm85_group_minctl = {
@@ -1104,6 +1105,7 @@ static struct attribute *lm85_attributes_temp_off[] = {
1104 &sensor_dev_attr_temp1_auto_temp_off.dev_attr.attr, 1105 &sensor_dev_attr_temp1_auto_temp_off.dev_attr.attr,
1105 &sensor_dev_attr_temp2_auto_temp_off.dev_attr.attr, 1106 &sensor_dev_attr_temp2_auto_temp_off.dev_attr.attr,
1106 &sensor_dev_attr_temp3_auto_temp_off.dev_attr.attr, 1107 &sensor_dev_attr_temp3_auto_temp_off.dev_attr.attr,
1108 NULL
1107}; 1109};
1108 1110
1109static const struct attribute_group lm85_group_temp_off = { 1111static const struct attribute_group lm85_group_temp_off = {
@@ -1329,11 +1331,11 @@ static int lm85_probe(struct i2c_client *client,
1329 if (data->type != emc6d103s) { 1331 if (data->type != emc6d103s) {
1330 err = sysfs_create_group(&client->dev.kobj, &lm85_group_minctl); 1332 err = sysfs_create_group(&client->dev.kobj, &lm85_group_minctl);
1331 if (err) 1333 if (err)
1332 goto err_kfree; 1334 goto err_remove_files;
1333 err = sysfs_create_group(&client->dev.kobj, 1335 err = sysfs_create_group(&client->dev.kobj,
1334 &lm85_group_temp_off); 1336 &lm85_group_temp_off);
1335 if (err) 1337 if (err)
1336 goto err_kfree; 1338 goto err_remove_files;
1337 } 1339 }
1338 1340
1339 /* The ADT7463/68 have an optional VRM 10 mode where pin 21 is used 1341 /* The ADT7463/68 have an optional VRM 10 mode where pin 21 is used
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index c43b4e9f96a9..2f94f9504804 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -49,10 +49,10 @@
49 * chips, but support three temperature sensors instead of two. MAX6695 49 * chips, but support three temperature sensors instead of two. MAX6695
50 * and MAX6696 only differ in the pinout so they can be treated identically. 50 * and MAX6696 only differ in the pinout so they can be treated identically.
51 * 51 *
52 * This driver also supports the ADT7461 chip from Analog Devices. 52 * This driver also supports ADT7461 and ADT7461A from Analog Devices as well as
53 * It's supported in both compatibility and extended mode. It is mostly 53 * NCT1008 from ON Semiconductor. The chips are supported in both compatibility
54 * compatible with LM90 except for a data format difference for the 54 * and extended mode. They are mostly compatible with LM90 except for a data
55 * temperature value registers. 55 * format difference for the temperature value registers.
56 * 56 *
57 * Since the LM90 was the first chipset supported by this driver, most 57 * Since the LM90 was the first chipset supported by this driver, most
58 * comments will refer to this chipset, but are actually general and 58 * comments will refer to this chipset, but are actually general and
@@ -88,9 +88,10 @@
88 * Addresses to scan 88 * Addresses to scan
89 * Address is fully defined internally and cannot be changed except for 89 * Address is fully defined internally and cannot be changed except for
90 * MAX6659, MAX6680 and MAX6681. 90 * MAX6659, MAX6680 and MAX6681.
91 * LM86, LM89, LM90, LM99, ADM1032, ADM1032-1, ADT7461, MAX6649, MAX6657, 91 * LM86, LM89, LM90, LM99, ADM1032, ADM1032-1, ADT7461, ADT7461A, MAX6649,
92 * MAX6658 and W83L771 have address 0x4c. 92 * MAX6657, MAX6658, NCT1008 and W83L771 have address 0x4c.
93 * ADM1032-2, ADT7461-2, LM89-1, LM99-1 and MAX6646 have address 0x4d. 93 * ADM1032-2, ADT7461-2, ADT7461A-2, LM89-1, LM99-1, MAX6646, and NCT1008D
94 * have address 0x4d.
94 * MAX6647 has address 0x4e. 95 * MAX6647 has address 0x4e.
95 * MAX6659 can have address 0x4c, 0x4d or 0x4e. 96 * MAX6659 can have address 0x4c, 0x4d or 0x4e.
96 * MAX6680 and MAX6681 can have address 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 97 * MAX6680 and MAX6681 can have address 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b,
@@ -174,6 +175,7 @@ enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680,
174static const struct i2c_device_id lm90_id[] = { 175static const struct i2c_device_id lm90_id[] = {
175 { "adm1032", adm1032 }, 176 { "adm1032", adm1032 },
176 { "adt7461", adt7461 }, 177 { "adt7461", adt7461 },
178 { "adt7461a", adt7461 },
177 { "lm90", lm90 }, 179 { "lm90", lm90 },
178 { "lm86", lm86 }, 180 { "lm86", lm86 },
179 { "lm89", lm86 }, 181 { "lm89", lm86 },
@@ -188,6 +190,7 @@ static const struct i2c_device_id lm90_id[] = {
188 { "max6681", max6680 }, 190 { "max6681", max6680 },
189 { "max6695", max6696 }, 191 { "max6695", max6696 },
190 { "max6696", max6696 }, 192 { "max6696", max6696 },
193 { "nct1008", adt7461 },
191 { "w83l771", w83l771 }, 194 { "w83l771", w83l771 },
192 { } 195 { }
193}; 196};
@@ -1153,6 +1156,11 @@ static int lm90_detect(struct i2c_client *new_client,
1153 && (reg_config1 & 0x1B) == 0x00 1156 && (reg_config1 & 0x1B) == 0x00
1154 && reg_convrate <= 0x0A) { 1157 && reg_convrate <= 0x0A) {
1155 name = "adt7461"; 1158 name = "adt7461";
1159 } else
1160 if (chip_id == 0x57 /* ADT7461A, NCT1008 */
1161 && (reg_config1 & 0x1B) == 0x00
1162 && reg_convrate <= 0x0A) {
1163 name = "adt7461a";
1156 } 1164 }
1157 } else 1165 } else
1158 if (man_id == 0x4D) { /* Maxim */ 1166 if (man_id == 0x4D) { /* Maxim */
diff --git a/drivers/hwmon/pmbus_core.c b/drivers/hwmon/pmbus_core.c
index edfb92e41735..196ffafafd88 100644
--- a/drivers/hwmon/pmbus_core.c
+++ b/drivers/hwmon/pmbus_core.c
@@ -139,7 +139,6 @@ struct pmbus_data {
139 * A single status register covers multiple attributes, 139 * A single status register covers multiple attributes,
140 * so we keep them all together. 140 * so we keep them all together.
141 */ 141 */
142 u8 status_bits;
143 u8 status[PB_NUM_STATUS_REG]; 142 u8 status[PB_NUM_STATUS_REG];
144 143
145 u8 currpage; 144 u8 currpage;
diff --git a/drivers/hwmon/twl4030-madc-hwmon.c b/drivers/hwmon/twl4030-madc-hwmon.c
index de5819199e2e..57240740b161 100644
--- a/drivers/hwmon/twl4030-madc-hwmon.c
+++ b/drivers/hwmon/twl4030-madc-hwmon.c
@@ -98,7 +98,6 @@ static const struct attribute_group twl4030_madc_group = {
98static int __devinit twl4030_madc_hwmon_probe(struct platform_device *pdev) 98static int __devinit twl4030_madc_hwmon_probe(struct platform_device *pdev)
99{ 99{
100 int ret; 100 int ret;
101 int status;
102 struct device *hwmon; 101 struct device *hwmon;
103 102
104 ret = sysfs_create_group(&pdev->dev.kobj, &twl4030_madc_group); 103 ret = sysfs_create_group(&pdev->dev.kobj, &twl4030_madc_group);
@@ -107,7 +106,7 @@ static int __devinit twl4030_madc_hwmon_probe(struct platform_device *pdev)
107 hwmon = hwmon_device_register(&pdev->dev); 106 hwmon = hwmon_device_register(&pdev->dev);
108 if (IS_ERR(hwmon)) { 107 if (IS_ERR(hwmon)) {
109 dev_err(&pdev->dev, "hwmon_device_register failed.\n"); 108 dev_err(&pdev->dev, "hwmon_device_register failed.\n");
110 status = PTR_ERR(hwmon); 109 ret = PTR_ERR(hwmon);
111 goto err_reg; 110 goto err_reg;
112 } 111 }
113 112
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 72c0415f6f94..455e909bc768 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -134,10 +134,15 @@
134 SMBHSTSTS_BUS_ERR | SMBHSTSTS_DEV_ERR | \ 134 SMBHSTSTS_BUS_ERR | SMBHSTSTS_DEV_ERR | \
135 SMBHSTSTS_INTR) 135 SMBHSTSTS_INTR)
136 136
137/* Older devices have their ID defined in <linux/pci_ids.h> */
138#define PCI_DEVICE_ID_INTEL_COUGARPOINT_SMBUS 0x1c22
139#define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS 0x1d22
137/* Patsburg also has three 'Integrated Device Function' SMBus controllers */ 140/* Patsburg also has three 'Integrated Device Function' SMBus controllers */
138#define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF0 0x1d70 141#define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF0 0x1d70
139#define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF1 0x1d71 142#define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF1 0x1d71
140#define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF2 0x1d72 143#define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF2 0x1d72
144#define PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS 0x2330
145#define PCI_DEVICE_ID_INTEL_5_3400_SERIES_SMBUS 0x3b30
141 146
142struct i801_priv { 147struct i801_priv {
143 struct i2c_adapter adapter; 148 struct i2c_adapter adapter;
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 75b984c519ac..107397a606b4 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -560,15 +560,18 @@ static struct i2c_adapter mpc_ops = {
560 .timeout = HZ, 560 .timeout = HZ,
561}; 561};
562 562
563static const struct of_device_id mpc_i2c_of_match[];
563static int __devinit fsl_i2c_probe(struct platform_device *op) 564static int __devinit fsl_i2c_probe(struct platform_device *op)
564{ 565{
566 const struct of_device_id *match;
565 struct mpc_i2c *i2c; 567 struct mpc_i2c *i2c;
566 const u32 *prop; 568 const u32 *prop;
567 u32 clock = MPC_I2C_CLOCK_LEGACY; 569 u32 clock = MPC_I2C_CLOCK_LEGACY;
568 int result = 0; 570 int result = 0;
569 int plen; 571 int plen;
570 572
571 if (!op->dev.of_match) 573 match = of_match_device(mpc_i2c_of_match, &op->dev);
574 if (!match)
572 return -EINVAL; 575 return -EINVAL;
573 576
574 i2c = kzalloc(sizeof(*i2c), GFP_KERNEL); 577 i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
@@ -605,8 +608,8 @@ static int __devinit fsl_i2c_probe(struct platform_device *op)
605 clock = *prop; 608 clock = *prop;
606 } 609 }
607 610
608 if (op->dev.of_match->data) { 611 if (match->data) {
609 struct mpc_i2c_data *data = op->dev.of_match->data; 612 struct mpc_i2c_data *data = match->data;
610 data->setup(op->dev.of_node, i2c, clock, data->prescaler); 613 data->setup(op->dev.of_node, i2c, clock, data->prescaler);
611 } else { 614 } else {
612 /* Backwards compatibility */ 615 /* Backwards compatibility */
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c
index 0eb1515541e7..2dbba163b102 100644
--- a/drivers/i2c/busses/i2c-parport.c
+++ b/drivers/i2c/busses/i2c-parport.c
@@ -1,7 +1,7 @@
1/* ------------------------------------------------------------------------ * 1/* ------------------------------------------------------------------------ *
2 * i2c-parport.c I2C bus over parallel port * 2 * i2c-parport.c I2C bus over parallel port *
3 * ------------------------------------------------------------------------ * 3 * ------------------------------------------------------------------------ *
4 Copyright (C) 2003-2010 Jean Delvare <khali@linux-fr.org> 4 Copyright (C) 2003-2011 Jean Delvare <khali@linux-fr.org>
5 5
6 Based on older i2c-philips-par.c driver 6 Based on older i2c-philips-par.c driver
7 Copyright (C) 1995-2000 Simon G. Vogl 7 Copyright (C) 1995-2000 Simon G. Vogl
@@ -33,6 +33,8 @@
33#include <linux/i2c-algo-bit.h> 33#include <linux/i2c-algo-bit.h>
34#include <linux/i2c-smbus.h> 34#include <linux/i2c-smbus.h>
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/list.h>
37#include <linux/mutex.h>
36#include "i2c-parport.h" 38#include "i2c-parport.h"
37 39
38/* ----- Device list ------------------------------------------------------ */ 40/* ----- Device list ------------------------------------------------------ */
@@ -43,10 +45,11 @@ struct i2c_par {
43 struct i2c_algo_bit_data algo_data; 45 struct i2c_algo_bit_data algo_data;
44 struct i2c_smbus_alert_setup alert_data; 46 struct i2c_smbus_alert_setup alert_data;
45 struct i2c_client *ara; 47 struct i2c_client *ara;
46 struct i2c_par *next; 48 struct list_head node;
47}; 49};
48 50
49static struct i2c_par *adapter_list; 51static LIST_HEAD(adapter_list);
52static DEFINE_MUTEX(adapter_list_lock);
50 53
51/* ----- Low-level parallel port access ----------------------------------- */ 54/* ----- Low-level parallel port access ----------------------------------- */
52 55
@@ -228,8 +231,9 @@ static void i2c_parport_attach (struct parport *port)
228 } 231 }
229 232
230 /* Add the new adapter to the list */ 233 /* Add the new adapter to the list */
231 adapter->next = adapter_list; 234 mutex_lock(&adapter_list_lock);
232 adapter_list = adapter; 235 list_add_tail(&adapter->node, &adapter_list);
236 mutex_unlock(&adapter_list_lock);
233 return; 237 return;
234 238
235ERROR1: 239ERROR1:
@@ -241,11 +245,11 @@ ERROR0:
241 245
242static void i2c_parport_detach (struct parport *port) 246static void i2c_parport_detach (struct parport *port)
243{ 247{
244 struct i2c_par *adapter, *prev; 248 struct i2c_par *adapter, *_n;
245 249
246 /* Walk the list */ 250 /* Walk the list */
247 for (prev = NULL, adapter = adapter_list; adapter; 251 mutex_lock(&adapter_list_lock);
248 prev = adapter, adapter = adapter->next) { 252 list_for_each_entry_safe(adapter, _n, &adapter_list, node) {
249 if (adapter->pdev->port == port) { 253 if (adapter->pdev->port == port) {
250 if (adapter->ara) { 254 if (adapter->ara) {
251 parport_disable_irq(port); 255 parport_disable_irq(port);
@@ -259,14 +263,11 @@ static void i2c_parport_detach (struct parport *port)
259 263
260 parport_release(adapter->pdev); 264 parport_release(adapter->pdev);
261 parport_unregister_device(adapter->pdev); 265 parport_unregister_device(adapter->pdev);
262 if (prev) 266 list_del(&adapter->node);
263 prev->next = adapter->next;
264 else
265 adapter_list = adapter->next;
266 kfree(adapter); 267 kfree(adapter);
267 return;
268 } 268 }
269 } 269 }
270 mutex_unlock(&adapter_list_lock);
270} 271}
271 272
272static struct parport_driver i2c_parport_driver = { 273static struct parport_driver i2c_parport_driver = {
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index a97e3fec8148..04be9f82e14b 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -65,7 +65,7 @@ static inline void i2c_pnx_arm_timer(struct i2c_pnx_algo_data *alg_data)
65 jiffies, expires); 65 jiffies, expires);
66 66
67 timer->expires = jiffies + expires; 67 timer->expires = jiffies + expires;
68 timer->data = (unsigned long)&alg_data; 68 timer->data = (unsigned long)alg_data;
69 69
70 add_timer(timer); 70 add_timer(timer);
71} 71}
diff --git a/drivers/ide/ide-cd_ioctl.c b/drivers/ide/ide-cd_ioctl.c
index 2a6bc50e8a41..02caa7dd51c8 100644
--- a/drivers/ide/ide-cd_ioctl.c
+++ b/drivers/ide/ide-cd_ioctl.c
@@ -79,6 +79,12 @@ int ide_cdrom_drive_status(struct cdrom_device_info *cdi, int slot_nr)
79 return CDS_DRIVE_NOT_READY; 79 return CDS_DRIVE_NOT_READY;
80} 80}
81 81
82/*
83 * ide-cd always generates media changed event if media is missing, which
84 * makes it impossible to use for proper event reporting, so disk->events
85 * is cleared to 0 and the following function is used only to trigger
86 * revalidation and never propagated to userland.
87 */
82unsigned int ide_cdrom_check_events_real(struct cdrom_device_info *cdi, 88unsigned int ide_cdrom_check_events_real(struct cdrom_device_info *cdi,
83 unsigned int clearing, int slot_nr) 89 unsigned int clearing, int slot_nr)
84{ 90{
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
index c4ffd4888939..70ea8763567d 100644
--- a/drivers/ide/ide-gd.c
+++ b/drivers/ide/ide-gd.c
@@ -298,6 +298,12 @@ static unsigned int ide_gd_check_events(struct gendisk *disk,
298 return 0; 298 return 0;
299 } 299 }
300 300
301 /*
302 * The following is used to force revalidation on the first open on
303 * removeable devices, and never gets reported to userland as
304 * genhd->events is 0. This is intended as removeable ide disk
305 * can't really detect MEDIA_CHANGE events.
306 */
301 ret = drive->dev_flags & IDE_DFLAG_MEDIA_CHANGED; 307 ret = drive->dev_flags & IDE_DFLAG_MEDIA_CHANGED;
302 drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED; 308 drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED;
303 309
@@ -413,7 +419,6 @@ static int ide_gd_probe(ide_drive_t *drive)
413 if (drive->dev_flags & IDE_DFLAG_REMOVABLE) 419 if (drive->dev_flags & IDE_DFLAG_REMOVABLE)
414 g->flags = GENHD_FL_REMOVABLE; 420 g->flags = GENHD_FL_REMOVABLE;
415 g->fops = &ide_gd_ops; 421 g->fops = &ide_gd_ops;
416 g->events = DISK_EVENT_MEDIA_CHANGE;
417 add_disk(g); 422 add_disk(g);
418 return 0; 423 return 0;
419 424
diff --git a/drivers/infiniband/hw/qib/qib_iba6120.c b/drivers/infiniband/hw/qib/qib_iba6120.c
index 7de4b7ebffc5..d8ca0a0b970d 100644
--- a/drivers/infiniband/hw/qib/qib_iba6120.c
+++ b/drivers/infiniband/hw/qib/qib_iba6120.c
@@ -1799,7 +1799,7 @@ static int qib_6120_setup_reset(struct qib_devdata *dd)
1799 /* 1799 /*
1800 * Keep chip from being accessed until we are ready. Use 1800 * Keep chip from being accessed until we are ready. Use
1801 * writeq() directly, to allow the write even though QIB_PRESENT 1801 * writeq() directly, to allow the write even though QIB_PRESENT
1802 * isn't' set. 1802 * isn't set.
1803 */ 1803 */
1804 dd->flags &= ~(QIB_INITTED | QIB_PRESENT); 1804 dd->flags &= ~(QIB_INITTED | QIB_PRESENT);
1805 dd->int_counter = 0; /* so we check interrupts work again */ 1805 dd->int_counter = 0; /* so we check interrupts work again */
diff --git a/drivers/infiniband/hw/qib/qib_iba7220.c b/drivers/infiniband/hw/qib/qib_iba7220.c
index 74fe0360bec7..c765a2eb04cf 100644
--- a/drivers/infiniband/hw/qib/qib_iba7220.c
+++ b/drivers/infiniband/hw/qib/qib_iba7220.c
@@ -2111,7 +2111,7 @@ static int qib_setup_7220_reset(struct qib_devdata *dd)
2111 /* 2111 /*
2112 * Keep chip from being accessed until we are ready. Use 2112 * Keep chip from being accessed until we are ready. Use
2113 * writeq() directly, to allow the write even though QIB_PRESENT 2113 * writeq() directly, to allow the write even though QIB_PRESENT
2114 * isn't' set. 2114 * isn't set.
2115 */ 2115 */
2116 dd->flags &= ~(QIB_INITTED | QIB_PRESENT); 2116 dd->flags &= ~(QIB_INITTED | QIB_PRESENT);
2117 dd->int_counter = 0; /* so we check interrupts work again */ 2117 dd->int_counter = 0; /* so we check interrupts work again */
diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c
index 55de3cf3441c..6bab3eaea70f 100644
--- a/drivers/infiniband/hw/qib/qib_iba7322.c
+++ b/drivers/infiniband/hw/qib/qib_iba7322.c
@@ -3299,7 +3299,7 @@ static int qib_do_7322_reset(struct qib_devdata *dd)
3299 /* 3299 /*
3300 * Keep chip from being accessed until we are ready. Use 3300 * Keep chip from being accessed until we are ready. Use
3301 * writeq() directly, to allow the write even though QIB_PRESENT 3301 * writeq() directly, to allow the write even though QIB_PRESENT
3302 * isn't' set. 3302 * isn't set.
3303 */ 3303 */
3304 dd->flags &= ~(QIB_INITTED | QIB_PRESENT | QIB_BADINTR); 3304 dd->flags &= ~(QIB_INITTED | QIB_PRESENT | QIB_BADINTR);
3305 dd->flags |= QIB_DOING_RESET; 3305 dd->flags |= QIB_DOING_RESET;
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index c24946f51256..1de1c19dad30 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -281,17 +281,24 @@ struct ser_req {
281 u8 command; 281 u8 command;
282 u8 ref_off; 282 u8 ref_off;
283 u16 scratch; 283 u16 scratch;
284 __be16 sample;
285 struct spi_message msg; 284 struct spi_message msg;
286 struct spi_transfer xfer[6]; 285 struct spi_transfer xfer[6];
286 /*
287 * DMA (thus cache coherency maintenance) requires the
288 * transfer buffers to live in their own cache lines.
289 */
290 __be16 sample ____cacheline_aligned;
287}; 291};
288 292
289struct ads7845_ser_req { 293struct ads7845_ser_req {
290 u8 command[3]; 294 u8 command[3];
291 u8 pwrdown[3];
292 u8 sample[3];
293 struct spi_message msg; 295 struct spi_message msg;
294 struct spi_transfer xfer[2]; 296 struct spi_transfer xfer[2];
297 /*
298 * DMA (thus cache coherency maintenance) requires the
299 * transfer buffers to live in their own cache lines.
300 */
301 u8 sample[3] ____cacheline_aligned;
295}; 302};
296 303
297static int ads7846_read12_ser(struct device *dev, unsigned command) 304static int ads7846_read12_ser(struct device *dev, unsigned command)
diff --git a/drivers/input/touchscreen/wm831x-ts.c b/drivers/input/touchscreen/wm831x-ts.c
index 6ae054f8e0aa..9175d49d2546 100644
--- a/drivers/input/touchscreen/wm831x-ts.c
+++ b/drivers/input/touchscreen/wm831x-ts.c
@@ -68,8 +68,23 @@ struct wm831x_ts {
68 unsigned int pd_irq; 68 unsigned int pd_irq;
69 bool pressure; 69 bool pressure;
70 bool pen_down; 70 bool pen_down;
71 struct work_struct pd_data_work;
71}; 72};
72 73
74static void wm831x_pd_data_work(struct work_struct *work)
75{
76 struct wm831x_ts *wm831x_ts =
77 container_of(work, struct wm831x_ts, pd_data_work);
78
79 if (wm831x_ts->pen_down) {
80 enable_irq(wm831x_ts->data_irq);
81 dev_dbg(wm831x_ts->wm831x->dev, "IRQ PD->DATA done\n");
82 } else {
83 enable_irq(wm831x_ts->pd_irq);
84 dev_dbg(wm831x_ts->wm831x->dev, "IRQ DATA->PD done\n");
85 }
86}
87
73static irqreturn_t wm831x_ts_data_irq(int irq, void *irq_data) 88static irqreturn_t wm831x_ts_data_irq(int irq, void *irq_data)
74{ 89{
75 struct wm831x_ts *wm831x_ts = irq_data; 90 struct wm831x_ts *wm831x_ts = irq_data;
@@ -110,6 +125,9 @@ static irqreturn_t wm831x_ts_data_irq(int irq, void *irq_data)
110 } 125 }
111 126
112 if (!wm831x_ts->pen_down) { 127 if (!wm831x_ts->pen_down) {
128 /* Switch from data to pen down */
129 dev_dbg(wm831x->dev, "IRQ DATA->PD\n");
130
113 disable_irq_nosync(wm831x_ts->data_irq); 131 disable_irq_nosync(wm831x_ts->data_irq);
114 132
115 /* Don't need data any more */ 133 /* Don't need data any more */
@@ -128,6 +146,10 @@ static irqreturn_t wm831x_ts_data_irq(int irq, void *irq_data)
128 ABS_PRESSURE, 0); 146 ABS_PRESSURE, 0);
129 147
130 input_report_key(wm831x_ts->input_dev, BTN_TOUCH, 0); 148 input_report_key(wm831x_ts->input_dev, BTN_TOUCH, 0);
149
150 schedule_work(&wm831x_ts->pd_data_work);
151 } else {
152 input_report_key(wm831x_ts->input_dev, BTN_TOUCH, 1);
131 } 153 }
132 154
133 input_sync(wm831x_ts->input_dev); 155 input_sync(wm831x_ts->input_dev);
@@ -141,6 +163,11 @@ static irqreturn_t wm831x_ts_pen_down_irq(int irq, void *irq_data)
141 struct wm831x *wm831x = wm831x_ts->wm831x; 163 struct wm831x *wm831x = wm831x_ts->wm831x;
142 int ena = 0; 164 int ena = 0;
143 165
166 if (wm831x_ts->pen_down)
167 return IRQ_HANDLED;
168
169 disable_irq_nosync(wm831x_ts->pd_irq);
170
144 /* Start collecting data */ 171 /* Start collecting data */
145 if (wm831x_ts->pressure) 172 if (wm831x_ts->pressure)
146 ena |= WM831X_TCH_Z_ENA; 173 ena |= WM831X_TCH_Z_ENA;
@@ -149,14 +176,14 @@ static irqreturn_t wm831x_ts_pen_down_irq(int irq, void *irq_data)
149 WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | WM831X_TCH_Z_ENA, 176 WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | WM831X_TCH_Z_ENA,
150 WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | ena); 177 WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | ena);
151 178
152 input_report_key(wm831x_ts->input_dev, BTN_TOUCH, 1);
153 input_sync(wm831x_ts->input_dev);
154
155 wm831x_set_bits(wm831x, WM831X_INTERRUPT_STATUS_1, 179 wm831x_set_bits(wm831x, WM831X_INTERRUPT_STATUS_1,
156 WM831X_TCHPD_EINT, WM831X_TCHPD_EINT); 180 WM831X_TCHPD_EINT, WM831X_TCHPD_EINT);
157 181
158 wm831x_ts->pen_down = true; 182 wm831x_ts->pen_down = true;
159 enable_irq(wm831x_ts->data_irq); 183
184 /* Switch from pen down to data */
185 dev_dbg(wm831x->dev, "IRQ PD->DATA\n");
186 schedule_work(&wm831x_ts->pd_data_work);
160 187
161 return IRQ_HANDLED; 188 return IRQ_HANDLED;
162} 189}
@@ -182,13 +209,28 @@ static void wm831x_ts_input_close(struct input_dev *idev)
182 struct wm831x_ts *wm831x_ts = input_get_drvdata(idev); 209 struct wm831x_ts *wm831x_ts = input_get_drvdata(idev);
183 struct wm831x *wm831x = wm831x_ts->wm831x; 210 struct wm831x *wm831x = wm831x_ts->wm831x;
184 211
212 /* Shut the controller down, disabling all other functionality too */
185 wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1, 213 wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1,
186 WM831X_TCH_ENA | WM831X_TCH_CVT_ENA | 214 WM831X_TCH_ENA | WM831X_TCH_X_ENA |
187 WM831X_TCH_X_ENA | WM831X_TCH_Y_ENA | 215 WM831X_TCH_Y_ENA | WM831X_TCH_Z_ENA, 0);
188 WM831X_TCH_Z_ENA, 0);
189 216
190 if (wm831x_ts->pen_down) 217 /* Make sure any pending IRQs are done, the above will prevent
218 * new ones firing.
219 */
220 synchronize_irq(wm831x_ts->data_irq);
221 synchronize_irq(wm831x_ts->pd_irq);
222
223 /* Make sure the IRQ completion work is quiesced */
224 flush_work_sync(&wm831x_ts->pd_data_work);
225
226 /* If we ended up with the pen down then make sure we revert back
227 * to pen detection state for the next time we start up.
228 */
229 if (wm831x_ts->pen_down) {
191 disable_irq(wm831x_ts->data_irq); 230 disable_irq(wm831x_ts->data_irq);
231 enable_irq(wm831x_ts->pd_irq);
232 wm831x_ts->pen_down = false;
233 }
192} 234}
193 235
194static __devinit int wm831x_ts_probe(struct platform_device *pdev) 236static __devinit int wm831x_ts_probe(struct platform_device *pdev)
@@ -198,7 +240,7 @@ static __devinit int wm831x_ts_probe(struct platform_device *pdev)
198 struct wm831x_pdata *core_pdata = dev_get_platdata(pdev->dev.parent); 240 struct wm831x_pdata *core_pdata = dev_get_platdata(pdev->dev.parent);
199 struct wm831x_touch_pdata *pdata = NULL; 241 struct wm831x_touch_pdata *pdata = NULL;
200 struct input_dev *input_dev; 242 struct input_dev *input_dev;
201 int error; 243 int error, irqf;
202 244
203 if (core_pdata) 245 if (core_pdata)
204 pdata = core_pdata->touch; 246 pdata = core_pdata->touch;
@@ -212,6 +254,7 @@ static __devinit int wm831x_ts_probe(struct platform_device *pdev)
212 254
213 wm831x_ts->wm831x = wm831x; 255 wm831x_ts->wm831x = wm831x;
214 wm831x_ts->input_dev = input_dev; 256 wm831x_ts->input_dev = input_dev;
257 INIT_WORK(&wm831x_ts->pd_data_work, wm831x_pd_data_work);
215 258
216 /* 259 /*
217 * If we have a direct IRQ use it, otherwise use the interrupt 260 * If we have a direct IRQ use it, otherwise use the interrupt
@@ -270,9 +313,14 @@ static __devinit int wm831x_ts_probe(struct platform_device *pdev)
270 wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1, 313 wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_1,
271 WM831X_TCH_RATE_MASK, 6); 314 WM831X_TCH_RATE_MASK, 6);
272 315
316 if (pdata && pdata->data_irqf)
317 irqf = pdata->data_irqf;
318 else
319 irqf = IRQF_TRIGGER_HIGH;
320
273 error = request_threaded_irq(wm831x_ts->data_irq, 321 error = request_threaded_irq(wm831x_ts->data_irq,
274 NULL, wm831x_ts_data_irq, 322 NULL, wm831x_ts_data_irq,
275 IRQF_ONESHOT, 323 irqf | IRQF_ONESHOT,
276 "Touchscreen data", wm831x_ts); 324 "Touchscreen data", wm831x_ts);
277 if (error) { 325 if (error) {
278 dev_err(&pdev->dev, "Failed to request data IRQ %d: %d\n", 326 dev_err(&pdev->dev, "Failed to request data IRQ %d: %d\n",
@@ -281,9 +329,14 @@ static __devinit int wm831x_ts_probe(struct platform_device *pdev)
281 } 329 }
282 disable_irq(wm831x_ts->data_irq); 330 disable_irq(wm831x_ts->data_irq);
283 331
332 if (pdata && pdata->pd_irqf)
333 irqf = pdata->pd_irqf;
334 else
335 irqf = IRQF_TRIGGER_HIGH;
336
284 error = request_threaded_irq(wm831x_ts->pd_irq, 337 error = request_threaded_irq(wm831x_ts->pd_irq,
285 NULL, wm831x_ts_pen_down_irq, 338 NULL, wm831x_ts_pen_down_irq,
286 IRQF_ONESHOT, 339 irqf | IRQF_ONESHOT,
287 "Touchscreen pen down", wm831x_ts); 340 "Touchscreen pen down", wm831x_ts);
288 if (error) { 341 if (error) {
289 dev_err(&pdev->dev, "Failed to request pen down IRQ %d: %d\n", 342 dev_err(&pdev->dev, "Failed to request pen down IRQ %d: %d\n",
diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c
index e7089a1f6cb6..b37e6186d0fa 100644
--- a/drivers/leds/leds-lm3530.c
+++ b/drivers/leds/leds-lm3530.c
@@ -349,6 +349,7 @@ static const struct i2c_device_id lm3530_id[] = {
349 {LM3530_NAME, 0}, 349 {LM3530_NAME, 0},
350 {} 350 {}
351}; 351};
352MODULE_DEVICE_TABLE(i2c, lm3530_id);
352 353
353static struct i2c_driver lm3530_i2c_driver = { 354static struct i2c_driver lm3530_i2c_driver = {
354 .probe = lm3530_probe, 355 .probe = lm3530_probe,
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 6e853c61d87e..7d6f7f18a920 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -3170,6 +3170,7 @@ level_store(mddev_t *mddev, const char *buf, size_t len)
3170 mddev->layout = mddev->new_layout; 3170 mddev->layout = mddev->new_layout;
3171 mddev->chunk_sectors = mddev->new_chunk_sectors; 3171 mddev->chunk_sectors = mddev->new_chunk_sectors;
3172 mddev->delta_disks = 0; 3172 mddev->delta_disks = 0;
3173 mddev->degraded = 0;
3173 if (mddev->pers->sync_request == NULL) { 3174 if (mddev->pers->sync_request == NULL) {
3174 /* this is now an array without redundancy, so 3175 /* this is now an array without redundancy, so
3175 * it must always be in_sync 3176 * it must always be in_sync
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index f301e6ae220c..49bf5f891435 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5151,7 +5151,6 @@ static int run(mddev_t *mddev)
5151 5151
5152 mddev->queue->backing_dev_info.congested_data = mddev; 5152 mddev->queue->backing_dev_info.congested_data = mddev;
5153 mddev->queue->backing_dev_info.congested_fn = raid5_congested; 5153 mddev->queue->backing_dev_info.congested_fn = raid5_congested;
5154 mddev->queue->queue_lock = &conf->device_lock;
5155 5154
5156 chunk_size = mddev->chunk_sectors << 9; 5155 chunk_size = mddev->chunk_sectors << 9;
5157 blk_queue_io_min(mddev->queue, chunk_size); 5156 blk_queue_io_min(mddev->queue, chunk_size);
@@ -5679,6 +5678,7 @@ static void raid5_quiesce(mddev_t *mddev, int state)
5679static void *raid45_takeover_raid0(mddev_t *mddev, int level) 5678static void *raid45_takeover_raid0(mddev_t *mddev, int level)
5680{ 5679{
5681 struct raid0_private_data *raid0_priv = mddev->private; 5680 struct raid0_private_data *raid0_priv = mddev->private;
5681 sector_t sectors;
5682 5682
5683 /* for raid0 takeover only one zone is supported */ 5683 /* for raid0 takeover only one zone is supported */
5684 if (raid0_priv->nr_strip_zones > 1) { 5684 if (raid0_priv->nr_strip_zones > 1) {
@@ -5687,6 +5687,9 @@ static void *raid45_takeover_raid0(mddev_t *mddev, int level)
5687 return ERR_PTR(-EINVAL); 5687 return ERR_PTR(-EINVAL);
5688 } 5688 }
5689 5689
5690 sectors = raid0_priv->strip_zone[0].zone_end;
5691 sector_div(sectors, raid0_priv->strip_zone[0].nb_dev);
5692 mddev->dev_sectors = sectors;
5690 mddev->new_level = level; 5693 mddev->new_level = level;
5691 mddev->new_layout = ALGORITHM_PARITY_N; 5694 mddev->new_layout = ALGORITHM_PARITY_N;
5692 mddev->new_chunk_sectors = mddev->chunk_sectors; 5695 mddev->new_chunk_sectors = mddev->chunk_sectors;
diff --git a/drivers/media/common/tuners/tda18271-common.c b/drivers/media/common/tuners/tda18271-common.c
index 5466d47db899..aae40e52af5b 100644
--- a/drivers/media/common/tuners/tda18271-common.c
+++ b/drivers/media/common/tuners/tda18271-common.c
@@ -533,16 +533,7 @@ int tda18271_calc_main_pll(struct dvb_frontend *fe, u32 freq)
533 if (tda_fail(ret)) 533 if (tda_fail(ret))
534 goto fail; 534 goto fail;
535 535
536 regs[R_MPD] = (0x77 & pd); 536 regs[R_MPD] = (0x7f & pd);
537
538 switch (priv->mode) {
539 case TDA18271_ANALOG:
540 regs[R_MPD] &= ~0x08;
541 break;
542 case TDA18271_DIGITAL:
543 regs[R_MPD] |= 0x08;
544 break;
545 }
546 537
547 div = ((d * (freq / 1000)) << 7) / 125; 538 div = ((d * (freq / 1000)) << 7) / 125;
548 539
diff --git a/drivers/media/common/tuners/tda18271-fe.c b/drivers/media/common/tuners/tda18271-fe.c
index 9ad4454a148d..d884f5eee73c 100644
--- a/drivers/media/common/tuners/tda18271-fe.c
+++ b/drivers/media/common/tuners/tda18271-fe.c
@@ -579,8 +579,8 @@ static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq)
579#define RF3 2 579#define RF3 2
580 u32 rf_default[3]; 580 u32 rf_default[3];
581 u32 rf_freq[3]; 581 u32 rf_freq[3];
582 u8 prog_cal[3]; 582 s32 prog_cal[3];
583 u8 prog_tab[3]; 583 s32 prog_tab[3];
584 584
585 i = tda18271_lookup_rf_band(fe, &freq, NULL); 585 i = tda18271_lookup_rf_band(fe, &freq, NULL);
586 586
@@ -602,32 +602,33 @@ static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq)
602 return bcal; 602 return bcal;
603 603
604 tda18271_calc_rf_cal(fe, &rf_freq[rf]); 604 tda18271_calc_rf_cal(fe, &rf_freq[rf]);
605 prog_tab[rf] = regs[R_EB14]; 605 prog_tab[rf] = (s32)regs[R_EB14];
606 606
607 if (1 == bcal) 607 if (1 == bcal)
608 prog_cal[rf] = tda18271_calibrate_rf(fe, rf_freq[rf]); 608 prog_cal[rf] =
609 (s32)tda18271_calibrate_rf(fe, rf_freq[rf]);
609 else 610 else
610 prog_cal[rf] = prog_tab[rf]; 611 prog_cal[rf] = prog_tab[rf];
611 612
612 switch (rf) { 613 switch (rf) {
613 case RF1: 614 case RF1:
614 map[i].rf_a1 = 0; 615 map[i].rf_a1 = 0;
615 map[i].rf_b1 = (s32)(prog_cal[RF1] - prog_tab[RF1]); 616 map[i].rf_b1 = (prog_cal[RF1] - prog_tab[RF1]);
616 map[i].rf1 = rf_freq[RF1] / 1000; 617 map[i].rf1 = rf_freq[RF1] / 1000;
617 break; 618 break;
618 case RF2: 619 case RF2:
619 dividend = (s32)(prog_cal[RF2] - prog_tab[RF2]) - 620 dividend = (prog_cal[RF2] - prog_tab[RF2] -
620 (s32)(prog_cal[RF1] + prog_tab[RF1]); 621 prog_cal[RF1] + prog_tab[RF1]);
621 divisor = (s32)(rf_freq[RF2] - rf_freq[RF1]) / 1000; 622 divisor = (s32)(rf_freq[RF2] - rf_freq[RF1]) / 1000;
622 map[i].rf_a1 = (dividend / divisor); 623 map[i].rf_a1 = (dividend / divisor);
623 map[i].rf2 = rf_freq[RF2] / 1000; 624 map[i].rf2 = rf_freq[RF2] / 1000;
624 break; 625 break;
625 case RF3: 626 case RF3:
626 dividend = (s32)(prog_cal[RF3] - prog_tab[RF3]) - 627 dividend = (prog_cal[RF3] - prog_tab[RF3] -
627 (s32)(prog_cal[RF2] + prog_tab[RF2]); 628 prog_cal[RF2] + prog_tab[RF2]);
628 divisor = (s32)(rf_freq[RF3] - rf_freq[RF2]) / 1000; 629 divisor = (s32)(rf_freq[RF3] - rf_freq[RF2]) / 1000;
629 map[i].rf_a2 = (dividend / divisor); 630 map[i].rf_a2 = (dividend / divisor);
630 map[i].rf_b2 = (s32)(prog_cal[RF2] - prog_tab[RF2]); 631 map[i].rf_b2 = (prog_cal[RF2] - prog_tab[RF2]);
631 map[i].rf3 = rf_freq[RF3] / 1000; 632 map[i].rf3 = rf_freq[RF3] / 1000;
632 break; 633 break;
633 default: 634 default:
diff --git a/drivers/media/common/tuners/tda18271-maps.c b/drivers/media/common/tuners/tda18271-maps.c
index e7f84c705da8..3d5b6ab7e332 100644
--- a/drivers/media/common/tuners/tda18271-maps.c
+++ b/drivers/media/common/tuners/tda18271-maps.c
@@ -229,8 +229,7 @@ static struct tda18271_map tda18271c2_km[] = {
229static struct tda18271_map tda18271_rf_band[] = { 229static struct tda18271_map tda18271_rf_band[] = {
230 { .rfmax = 47900, .val = 0x00 }, 230 { .rfmax = 47900, .val = 0x00 },
231 { .rfmax = 61100, .val = 0x01 }, 231 { .rfmax = 61100, .val = 0x01 },
232/* { .rfmax = 152600, .val = 0x02 }, */ 232 { .rfmax = 152600, .val = 0x02 },
233 { .rfmax = 121200, .val = 0x02 },
234 { .rfmax = 164700, .val = 0x03 }, 233 { .rfmax = 164700, .val = 0x03 },
235 { .rfmax = 203500, .val = 0x04 }, 234 { .rfmax = 203500, .val = 0x04 },
236 { .rfmax = 457800, .val = 0x05 }, 235 { .rfmax = 457800, .val = 0x05 },
@@ -448,7 +447,7 @@ static struct tda18271_map tda18271c2_rf_cal[] = {
448 { .rfmax = 150000, .val = 0xb0 }, 447 { .rfmax = 150000, .val = 0xb0 },
449 { .rfmax = 151000, .val = 0xb1 }, 448 { .rfmax = 151000, .val = 0xb1 },
450 { .rfmax = 152000, .val = 0xb7 }, 449 { .rfmax = 152000, .val = 0xb7 },
451 { .rfmax = 153000, .val = 0xbd }, 450 { .rfmax = 152600, .val = 0xbd },
452 { .rfmax = 154000, .val = 0x20 }, 451 { .rfmax = 154000, .val = 0x20 },
453 { .rfmax = 155000, .val = 0x22 }, 452 { .rfmax = 155000, .val = 0x22 },
454 { .rfmax = 156000, .val = 0x24 }, 453 { .rfmax = 156000, .val = 0x24 },
@@ -459,7 +458,7 @@ static struct tda18271_map tda18271c2_rf_cal[] = {
459 { .rfmax = 161000, .val = 0x2d }, 458 { .rfmax = 161000, .val = 0x2d },
460 { .rfmax = 163000, .val = 0x2e }, 459 { .rfmax = 163000, .val = 0x2e },
461 { .rfmax = 164000, .val = 0x2f }, 460 { .rfmax = 164000, .val = 0x2f },
462 { .rfmax = 165000, .val = 0x30 }, 461 { .rfmax = 164700, .val = 0x30 },
463 { .rfmax = 166000, .val = 0x11 }, 462 { .rfmax = 166000, .val = 0x11 },
464 { .rfmax = 167000, .val = 0x12 }, 463 { .rfmax = 167000, .val = 0x12 },
465 { .rfmax = 168000, .val = 0x13 }, 464 { .rfmax = 168000, .val = 0x13 },
@@ -510,7 +509,8 @@ static struct tda18271_map tda18271c2_rf_cal[] = {
510 { .rfmax = 236000, .val = 0x1b }, 509 { .rfmax = 236000, .val = 0x1b },
511 { .rfmax = 237000, .val = 0x1c }, 510 { .rfmax = 237000, .val = 0x1c },
512 { .rfmax = 240000, .val = 0x1d }, 511 { .rfmax = 240000, .val = 0x1d },
513 { .rfmax = 242000, .val = 0x1f }, 512 { .rfmax = 242000, .val = 0x1e },
513 { .rfmax = 244000, .val = 0x1f },
514 { .rfmax = 247000, .val = 0x20 }, 514 { .rfmax = 247000, .val = 0x20 },
515 { .rfmax = 249000, .val = 0x21 }, 515 { .rfmax = 249000, .val = 0x21 },
516 { .rfmax = 252000, .val = 0x22 }, 516 { .rfmax = 252000, .val = 0x22 },
@@ -624,7 +624,7 @@ static struct tda18271_map tda18271c2_rf_cal[] = {
624 { .rfmax = 453000, .val = 0x93 }, 624 { .rfmax = 453000, .val = 0x93 },
625 { .rfmax = 454000, .val = 0x94 }, 625 { .rfmax = 454000, .val = 0x94 },
626 { .rfmax = 456000, .val = 0x96 }, 626 { .rfmax = 456000, .val = 0x96 },
627 { .rfmax = 457000, .val = 0x98 }, 627 { .rfmax = 457800, .val = 0x98 },
628 { .rfmax = 461000, .val = 0x11 }, 628 { .rfmax = 461000, .val = 0x11 },
629 { .rfmax = 468000, .val = 0x12 }, 629 { .rfmax = 468000, .val = 0x12 },
630 { .rfmax = 472000, .val = 0x13 }, 630 { .rfmax = 472000, .val = 0x13 },
diff --git a/drivers/media/dvb/b2c2/flexcop-pci.c b/drivers/media/dvb/b2c2/flexcop-pci.c
index 955254090a0e..03f96d6ca894 100644
--- a/drivers/media/dvb/b2c2/flexcop-pci.c
+++ b/drivers/media/dvb/b2c2/flexcop-pci.c
@@ -38,7 +38,7 @@ MODULE_PARM_DESC(debug,
38 DEBSTATUS); 38 DEBSTATUS);
39 39
40#define DRIVER_VERSION "0.1" 40#define DRIVER_VERSION "0.1"
41#define DRIVER_NAME "Technisat/B2C2 FlexCop II/IIb/III Digital TV PCI Driver" 41#define DRIVER_NAME "flexcop-pci"
42#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@desy.de>" 42#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@desy.de>"
43 43
44struct flexcop_pci { 44struct flexcop_pci {
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index fe4f894183ff..c545039287ad 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -356,13 +356,15 @@ config DVB_USB_LME2510
356 select DVB_TDA826X if !DVB_FE_CUSTOMISE 356 select DVB_TDA826X if !DVB_FE_CUSTOMISE
357 select DVB_STV0288 if !DVB_FE_CUSTOMISE 357 select DVB_STV0288 if !DVB_FE_CUSTOMISE
358 select DVB_IX2505V if !DVB_FE_CUSTOMISE 358 select DVB_IX2505V if !DVB_FE_CUSTOMISE
359 select DVB_STV0299 if !DVB_FE_CUSTOMISE
360 select DVB_PLL if !DVB_FE_CUSTOMISE
359 help 361 help
360 Say Y here to support the LME DM04/QQBOX DVB-S USB2.0 . 362 Say Y here to support the LME DM04/QQBOX DVB-S USB2.0 .
361 363
362config DVB_USB_TECHNISAT_USB2 364config DVB_USB_TECHNISAT_USB2
363 tristate "Technisat DVB-S/S2 USB2.0 support" 365 tristate "Technisat DVB-S/S2 USB2.0 support"
364 depends on DVB_USB 366 depends on DVB_USB
365 select DVB_STB0899 if !DVB_FE_CUSTOMISE 367 select DVB_STV090x if !DVB_FE_CUSTOMISE
366 select DVB_STB6100 if !DVB_FE_CUSTOMISE 368 select DVB_STV6110x if !DVB_FE_CUSTOMISE
367 help 369 help
368 Say Y here to support the Technisat USB2 DVB-S/S2 device 370 Say Y here to support the Technisat USB2 DVB-S/S2 device
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c
index 97af266d7f1d..65214af5cd74 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c
@@ -2162,7 +2162,7 @@ struct dibx000_agc_config dib7090_agc_config[2] = {
2162 .agc1_pt3 = 98, 2162 .agc1_pt3 = 98,
2163 .agc1_slope1 = 0, 2163 .agc1_slope1 = 0,
2164 .agc1_slope2 = 167, 2164 .agc1_slope2 = 167,
2165 .agc1_pt1 = 98, 2165 .agc2_pt1 = 98,
2166 .agc2_pt2 = 255, 2166 .agc2_pt2 = 255,
2167 .agc2_slope1 = 104, 2167 .agc2_slope1 = 104,
2168 .agc2_slope2 = 0, 2168 .agc2_slope2 = 0,
@@ -2440,11 +2440,11 @@ static int tfe7090pvr_frontend0_attach(struct dvb_usb_adapter *adap)
2440 dib0700_set_i2c_speed(adap->dev, 340); 2440 dib0700_set_i2c_speed(adap->dev, 340);
2441 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x90, &tfe7090pvr_dib7000p_config[0]); 2441 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x90, &tfe7090pvr_dib7000p_config[0]);
2442 2442
2443 dib7090_slave_reset(adap->fe);
2444
2445 if (adap->fe == NULL) 2443 if (adap->fe == NULL)
2446 return -ENODEV; 2444 return -ENODEV;
2447 2445
2446 dib7090_slave_reset(adap->fe);
2447
2448 return 0; 2448 return 0;
2449} 2449}
2450 2450
diff --git a/drivers/media/dvb/ngene/ngene-core.c b/drivers/media/dvb/ngene/ngene-core.c
index ccc2d1af49d4..6927c726ce35 100644
--- a/drivers/media/dvb/ngene/ngene-core.c
+++ b/drivers/media/dvb/ngene/ngene-core.c
@@ -1520,6 +1520,7 @@ static int init_channel(struct ngene_channel *chan)
1520 if (dev->ci.en && (io & NGENE_IO_TSOUT)) { 1520 if (dev->ci.en && (io & NGENE_IO_TSOUT)) {
1521 dvb_ca_en50221_init(adapter, dev->ci.en, 0, 1); 1521 dvb_ca_en50221_init(adapter, dev->ci.en, 0, 1);
1522 set_transfer(chan, 1); 1522 set_transfer(chan, 1);
1523 chan->dev->channel[2].DataFormatFlags = DF_SWAP32;
1523 set_transfer(&chan->dev->channel[2], 1); 1524 set_transfer(&chan->dev->channel[2], 1);
1524 dvb_register_device(adapter, &chan->ci_dev, 1525 dvb_register_device(adapter, &chan->ci_dev,
1525 &ngene_dvbdev_ci, (void *) chan, 1526 &ngene_dvbdev_ci, (void *) chan,
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 23640ed44d85..056138f63c7d 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -378,7 +378,6 @@ EXPORT_SYMBOL_GPL(media_entity_create_link);
378 378
379static int __media_entity_setup_link_notify(struct media_link *link, u32 flags) 379static int __media_entity_setup_link_notify(struct media_link *link, u32 flags)
380{ 380{
381 const u32 mask = MEDIA_LNK_FL_ENABLED;
382 int ret; 381 int ret;
383 382
384 /* Notify both entities. */ 383 /* Notify both entities. */
@@ -395,7 +394,7 @@ static int __media_entity_setup_link_notify(struct media_link *link, u32 flags)
395 return ret; 394 return ret;
396 } 395 }
397 396
398 link->flags = (link->flags & ~mask) | (flags & mask); 397 link->flags = flags;
399 link->reverse->flags = link->flags; 398 link->reverse->flags = link->flags;
400 399
401 return 0; 400 return 0;
@@ -417,6 +416,7 @@ static int __media_entity_setup_link_notify(struct media_link *link, u32 flags)
417 */ 416 */
418int __media_entity_setup_link(struct media_link *link, u32 flags) 417int __media_entity_setup_link(struct media_link *link, u32 flags)
419{ 418{
419 const u32 mask = MEDIA_LNK_FL_ENABLED;
420 struct media_device *mdev; 420 struct media_device *mdev;
421 struct media_entity *source, *sink; 421 struct media_entity *source, *sink;
422 int ret = -EBUSY; 422 int ret = -EBUSY;
@@ -424,6 +424,10 @@ int __media_entity_setup_link(struct media_link *link, u32 flags)
424 if (link == NULL) 424 if (link == NULL)
425 return -EINVAL; 425 return -EINVAL;
426 426
427 /* The non-modifiable link flags must not be modified. */
428 if ((link->flags & ~mask) != (flags & ~mask))
429 return -EINVAL;
430
427 if (link->flags & MEDIA_LNK_FL_IMMUTABLE) 431 if (link->flags & MEDIA_LNK_FL_IMMUTABLE)
428 return link->flags == flags ? 0 : -EINVAL; 432 return link->flags == flags ? 0 : -EINVAL;
429 433
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c
index dc3f04c52d5e..87bad7678d92 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -170,7 +170,7 @@ static int fmr2_setfreq(struct fmr2 *dev)
170 return 0; 170 return 0;
171} 171}
172 172
173/* !!! not tested, in my card this does't work !!! */ 173/* !!! not tested, in my card this doesn't work !!! */
174static int fmr2_setvolume(struct fmr2 *dev) 174static int fmr2_setvolume(struct fmr2 *dev)
175{ 175{
176 int vol[16] = { 0x021, 0x084, 0x090, 0x104, 176 int vol[16] = { 0x021, 0x084, 0x090, 0x104,
diff --git a/drivers/media/radio/saa7706h.c b/drivers/media/radio/saa7706h.c
index 585680ffbfb6..b1193dfc5087 100644
--- a/drivers/media/radio/saa7706h.c
+++ b/drivers/media/radio/saa7706h.c
@@ -376,7 +376,7 @@ static int __devinit saa7706h_probe(struct i2c_client *client,
376 v4l_info(client, "chip found @ 0x%02x (%s)\n", 376 v4l_info(client, "chip found @ 0x%02x (%s)\n",
377 client->addr << 1, client->adapter->name); 377 client->addr << 1, client->adapter->name);
378 378
379 state = kmalloc(sizeof(struct saa7706h_state), GFP_KERNEL); 379 state = kzalloc(sizeof(struct saa7706h_state), GFP_KERNEL);
380 if (state == NULL) 380 if (state == NULL)
381 return -ENOMEM; 381 return -ENOMEM;
382 sd = &state->sd; 382 sd = &state->sd;
diff --git a/drivers/media/radio/tef6862.c b/drivers/media/radio/tef6862.c
index 7c0d77751f6e..0991e1973678 100644
--- a/drivers/media/radio/tef6862.c
+++ b/drivers/media/radio/tef6862.c
@@ -176,7 +176,7 @@ static int __devinit tef6862_probe(struct i2c_client *client,
176 v4l_info(client, "chip found @ 0x%02x (%s)\n", 176 v4l_info(client, "chip found @ 0x%02x (%s)\n",
177 client->addr << 1, client->adapter->name); 177 client->addr << 1, client->adapter->name);
178 178
179 state = kmalloc(sizeof(struct tef6862_state), GFP_KERNEL); 179 state = kzalloc(sizeof(struct tef6862_state), GFP_KERNEL);
180 if (state == NULL) 180 if (state == NULL)
181 return -ENOMEM; 181 return -ENOMEM;
182 state->freq = TEF6862_LO_FREQ; 182 state->freq = TEF6862_LO_FREQ;
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index ebd68edf5b24..8fc0f081b470 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -46,7 +46,7 @@
46#define MOD_AUTHOR "Jarod Wilson <jarod@wilsonet.com>" 46#define MOD_AUTHOR "Jarod Wilson <jarod@wilsonet.com>"
47#define MOD_DESC "Driver for SoundGraph iMON MultiMedia IR/Display" 47#define MOD_DESC "Driver for SoundGraph iMON MultiMedia IR/Display"
48#define MOD_NAME "imon" 48#define MOD_NAME "imon"
49#define MOD_VERSION "0.9.2" 49#define MOD_VERSION "0.9.3"
50 50
51#define DISPLAY_MINOR_BASE 144 51#define DISPLAY_MINOR_BASE 144
52#define DEVICE_NAME "lcd%d" 52#define DEVICE_NAME "lcd%d"
@@ -460,8 +460,9 @@ static int display_close(struct inode *inode, struct file *file)
460} 460}
461 461
462/** 462/**
463 * Sends a packet to the device -- this function must be called 463 * Sends a packet to the device -- this function must be called with
464 * with ictx->lock held. 464 * ictx->lock held, or its unlock/lock sequence while waiting for tx
465 * to complete can/will lead to a deadlock.
465 */ 466 */
466static int send_packet(struct imon_context *ictx) 467static int send_packet(struct imon_context *ictx)
467{ 468{
@@ -991,12 +992,21 @@ static void imon_touch_display_timeout(unsigned long data)
991 * the iMON remotes, and those used by the Windows MCE remotes (which is 992 * the iMON remotes, and those used by the Windows MCE remotes (which is
992 * really just RC-6), but only one or the other at a time, as the signals 993 * really just RC-6), but only one or the other at a time, as the signals
993 * are decoded onboard the receiver. 994 * are decoded onboard the receiver.
995 *
996 * This function gets called two different ways, one way is from
997 * rc_register_device, for initial protocol selection/setup, and the other is
998 * via a userspace-initiated protocol change request, either by direct sysfs
999 * prodding or by something like ir-keytable. In the rc_register_device case,
1000 * the imon context lock is already held, but when initiated from userspace,
1001 * it is not, so we must acquire it prior to calling send_packet, which
1002 * requires that the lock is held.
994 */ 1003 */
995static int imon_ir_change_protocol(struct rc_dev *rc, u64 rc_type) 1004static int imon_ir_change_protocol(struct rc_dev *rc, u64 rc_type)
996{ 1005{
997 int retval; 1006 int retval;
998 struct imon_context *ictx = rc->priv; 1007 struct imon_context *ictx = rc->priv;
999 struct device *dev = ictx->dev; 1008 struct device *dev = ictx->dev;
1009 bool unlock = false;
1000 unsigned char ir_proto_packet[] = { 1010 unsigned char ir_proto_packet[] = {
1001 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 }; 1011 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 };
1002 1012
@@ -1029,6 +1039,11 @@ static int imon_ir_change_protocol(struct rc_dev *rc, u64 rc_type)
1029 1039
1030 memcpy(ictx->usb_tx_buf, &ir_proto_packet, sizeof(ir_proto_packet)); 1040 memcpy(ictx->usb_tx_buf, &ir_proto_packet, sizeof(ir_proto_packet));
1031 1041
1042 if (!mutex_is_locked(&ictx->lock)) {
1043 unlock = true;
1044 mutex_lock(&ictx->lock);
1045 }
1046
1032 retval = send_packet(ictx); 1047 retval = send_packet(ictx);
1033 if (retval) 1048 if (retval)
1034 goto out; 1049 goto out;
@@ -1037,6 +1052,9 @@ static int imon_ir_change_protocol(struct rc_dev *rc, u64 rc_type)
1037 ictx->pad_mouse = false; 1052 ictx->pad_mouse = false;
1038 1053
1039out: 1054out:
1055 if (unlock)
1056 mutex_unlock(&ictx->lock);
1057
1040 return retval; 1058 return retval;
1041} 1059}
1042 1060
@@ -2134,6 +2152,7 @@ static struct imon_context *imon_init_intf0(struct usb_interface *intf)
2134 goto rdev_setup_failed; 2152 goto rdev_setup_failed;
2135 } 2153 }
2136 2154
2155 mutex_unlock(&ictx->lock);
2137 return ictx; 2156 return ictx;
2138 2157
2139rdev_setup_failed: 2158rdev_setup_failed:
@@ -2205,6 +2224,7 @@ static struct imon_context *imon_init_intf1(struct usb_interface *intf,
2205 goto urb_submit_failed; 2224 goto urb_submit_failed;
2206 } 2225 }
2207 2226
2227 mutex_unlock(&ictx->lock);
2208 return ictx; 2228 return ictx;
2209 2229
2210urb_submit_failed: 2230urb_submit_failed:
@@ -2299,6 +2319,8 @@ static int __devinit imon_probe(struct usb_interface *interface,
2299 usb_set_intfdata(interface, ictx); 2319 usb_set_intfdata(interface, ictx);
2300 2320
2301 if (ifnum == 0) { 2321 if (ifnum == 0) {
2322 mutex_lock(&ictx->lock);
2323
2302 if (product == 0xffdc && ictx->rf_device) { 2324 if (product == 0xffdc && ictx->rf_device) {
2303 sysfs_err = sysfs_create_group(&interface->dev.kobj, 2325 sysfs_err = sysfs_create_group(&interface->dev.kobj,
2304 &imon_rf_attr_group); 2326 &imon_rf_attr_group);
@@ -2309,13 +2331,14 @@ static int __devinit imon_probe(struct usb_interface *interface,
2309 2331
2310 if (ictx->display_supported) 2332 if (ictx->display_supported)
2311 imon_init_display(ictx, interface); 2333 imon_init_display(ictx, interface);
2334
2335 mutex_unlock(&ictx->lock);
2312 } 2336 }
2313 2337
2314 dev_info(dev, "iMON device (%04x:%04x, intf%d) on " 2338 dev_info(dev, "iMON device (%04x:%04x, intf%d) on "
2315 "usb<%d:%d> initialized\n", vendor, product, ifnum, 2339 "usb<%d:%d> initialized\n", vendor, product, ifnum,
2316 usbdev->bus->busnum, usbdev->devnum); 2340 usbdev->bus->busnum, usbdev->devnum);
2317 2341
2318 mutex_unlock(&ictx->lock);
2319 mutex_unlock(&driver_lock); 2342 mutex_unlock(&driver_lock);
2320 2343
2321 return 0; 2344 return 0;
diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c
index accaf6c9789a..43908a70bd8b 100644
--- a/drivers/media/rc/ite-cir.c
+++ b/drivers/media/rc/ite-cir.c
@@ -36,6 +36,7 @@
36#include <linux/io.h> 36#include <linux/io.h>
37#include <linux/interrupt.h> 37#include <linux/interrupt.h>
38#include <linux/sched.h> 38#include <linux/sched.h>
39#include <linux/delay.h>
39#include <linux/slab.h> 40#include <linux/slab.h>
40#include <linux/input.h> 41#include <linux/input.h>
41#include <linux/bitops.h> 42#include <linux/bitops.h>
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index 044fb7a382d6..0c273ec465c9 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -220,6 +220,8 @@ static struct usb_device_id mceusb_dev_table[] = {
220 { USB_DEVICE(VENDOR_PHILIPS, 0x206c) }, 220 { USB_DEVICE(VENDOR_PHILIPS, 0x206c) },
221 /* Philips/Spinel plus IR transceiver for ASUS */ 221 /* Philips/Spinel plus IR transceiver for ASUS */
222 { USB_DEVICE(VENDOR_PHILIPS, 0x2088) }, 222 { USB_DEVICE(VENDOR_PHILIPS, 0x2088) },
223 /* Philips IR transceiver (Dell branded) */
224 { USB_DEVICE(VENDOR_PHILIPS, 0x2093) },
223 /* Realtek MCE IR Receiver and card reader */ 225 /* Realtek MCE IR Receiver and card reader */
224 { USB_DEVICE(VENDOR_REALTEK, 0x0161), 226 { USB_DEVICE(VENDOR_REALTEK, 0x0161),
225 .driver_info = MULTIFUNCTION }, 227 .driver_info = MULTIFUNCTION },
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index f53f9c68d38d..a2706648e365 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -707,7 +707,8 @@ static void ir_close(struct input_dev *idev)
707{ 707{
708 struct rc_dev *rdev = input_get_drvdata(idev); 708 struct rc_dev *rdev = input_get_drvdata(idev);
709 709
710 rdev->close(rdev); 710 if (rdev)
711 rdev->close(rdev);
711} 712}
712 713
713/* class for /sys/class/rc */ 714/* class for /sys/class/rc */
@@ -733,6 +734,7 @@ static struct {
733 { RC_TYPE_SONY, "sony" }, 734 { RC_TYPE_SONY, "sony" },
734 { RC_TYPE_RC5_SZ, "rc-5-sz" }, 735 { RC_TYPE_RC5_SZ, "rc-5-sz" },
735 { RC_TYPE_LIRC, "lirc" }, 736 { RC_TYPE_LIRC, "lirc" },
737 { RC_TYPE_OTHER, "other" },
736}; 738};
737 739
738#define PROTO_NONE "none" 740#define PROTO_NONE "none"
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 4498b944dec8..00f51dd121f3 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -875,7 +875,7 @@ config MX3_VIDEO
875config VIDEO_MX3 875config VIDEO_MX3
876 tristate "i.MX3x Camera Sensor Interface driver" 876 tristate "i.MX3x Camera Sensor Interface driver"
877 depends on VIDEO_DEV && MX3_IPU && SOC_CAMERA 877 depends on VIDEO_DEV && MX3_IPU && SOC_CAMERA
878 select VIDEOBUF_DMA_CONTIG 878 select VIDEOBUF2_DMA_CONTIG
879 select MX3_VIDEO 879 select MX3_VIDEO
880 ---help--- 880 ---help---
881 This is a v4l2 driver for the i.MX3x Camera Sensor Interface 881 This is a v4l2 driver for the i.MX3x Camera Sensor Interface
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c
index c6e2ca3b1149..6fbc356113c1 100644
--- a/drivers/media/video/cx18/cx18-streams.c
+++ b/drivers/media/video/cx18/cx18-streams.c
@@ -350,9 +350,17 @@ void cx18_streams_cleanup(struct cx18 *cx, int unregister)
350 350
351 /* No struct video_device, but can have buffers allocated */ 351 /* No struct video_device, but can have buffers allocated */
352 if (type == CX18_ENC_STREAM_TYPE_IDX) { 352 if (type == CX18_ENC_STREAM_TYPE_IDX) {
353 /* If the module params didn't inhibit IDX ... */
353 if (cx->stream_buffers[type] != 0) { 354 if (cx->stream_buffers[type] != 0) {
354 cx->stream_buffers[type] = 0; 355 cx->stream_buffers[type] = 0;
355 cx18_stream_free(&cx->streams[type]); 356 /*
357 * Before calling cx18_stream_free(),
358 * check if the IDX stream was actually set up.
359 * Needed, since the cx18_probe() error path
360 * exits through here as well as normal clean up
361 */
362 if (cx->streams[type].buffers != 0)
363 cx18_stream_free(&cx->streams[type]);
356 } 364 }
357 continue; 365 continue;
358 } 366 }
diff --git a/drivers/media/video/cx23885/Kconfig b/drivers/media/video/cx23885/Kconfig
index 3b6e7f28568e..caab1bfb79e2 100644
--- a/drivers/media/video/cx23885/Kconfig
+++ b/drivers/media/video/cx23885/Kconfig
@@ -22,6 +22,7 @@ config VIDEO_CX23885
22 select DVB_CX24116 if !DVB_FE_CUSTOMISE 22 select DVB_CX24116 if !DVB_FE_CUSTOMISE
23 select DVB_STV0900 if !DVB_FE_CUSTOMISE 23 select DVB_STV0900 if !DVB_FE_CUSTOMISE
24 select DVB_DS3000 if !DVB_FE_CUSTOMISE 24 select DVB_DS3000 if !DVB_FE_CUSTOMISE
25 select DVB_STV0367 if !DVB_FE_CUSTOMISE
25 select MEDIA_TUNER_MT2131 if !MEDIA_TUNER_CUSTOMISE 26 select MEDIA_TUNER_MT2131 if !MEDIA_TUNER_CUSTOMISE
26 select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMISE 27 select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMISE
27 select MEDIA_TUNER_TDA8290 if !MEDIA_TUNER_CUSTOMISE 28 select MEDIA_TUNER_TDA8290 if !MEDIA_TUNER_CUSTOMISE
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index c820e2f53527..3f442003623d 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -524,7 +524,7 @@ void cx88_ir_irq(struct cx88_core *core)
524 for (todo = 32; todo > 0; todo -= bits) { 524 for (todo = 32; todo > 0; todo -= bits) {
525 ev.pulse = samples & 0x80000000 ? false : true; 525 ev.pulse = samples & 0x80000000 ? false : true;
526 bits = min(todo, 32U - fls(ev.pulse ? samples : ~samples)); 526 bits = min(todo, 32U - fls(ev.pulse ? samples : ~samples));
527 ev.duration = (bits * NSEC_PER_SEC) / (1000 * ir_samplerate); 527 ev.duration = (bits * (NSEC_PER_SEC / 1000)) / ir_samplerate;
528 ir_raw_event_store_with_filter(ir->dev, &ev); 528 ir_raw_event_store_with_filter(ir->dev, &ev);
529 samples <<= bits; 529 samples <<= bits;
530 } 530 }
diff --git a/drivers/media/video/imx074.c b/drivers/media/video/imx074.c
index 1a1169115716..0382ea752e6f 100644
--- a/drivers/media/video/imx074.c
+++ b/drivers/media/video/imx074.c
@@ -298,7 +298,7 @@ static unsigned long imx074_query_bus_param(struct soc_camera_device *icd)
298static int imx074_set_bus_param(struct soc_camera_device *icd, 298static int imx074_set_bus_param(struct soc_camera_device *icd,
299 unsigned long flags) 299 unsigned long flags)
300{ 300{
301 return -1; 301 return -EINVAL;
302} 302}
303 303
304static struct soc_camera_ops imx074_ops = { 304static struct soc_camera_ops imx074_ops = {
diff --git a/drivers/media/video/m52790.c b/drivers/media/video/m52790.c
index 5e1c9a81984c..303ffa7df4ac 100644
--- a/drivers/media/video/m52790.c
+++ b/drivers/media/video/m52790.c
@@ -174,7 +174,7 @@ static int m52790_probe(struct i2c_client *client,
174 v4l_info(client, "chip found @ 0x%x (%s)\n", 174 v4l_info(client, "chip found @ 0x%x (%s)\n",
175 client->addr << 1, client->adapter->name); 175 client->addr << 1, client->adapter->name);
176 176
177 state = kmalloc(sizeof(struct m52790_state), GFP_KERNEL); 177 state = kzalloc(sizeof(struct m52790_state), GFP_KERNEL);
178 if (state == NULL) 178 if (state == NULL)
179 return -ENOMEM; 179 return -ENOMEM;
180 180
diff --git a/drivers/media/video/omap3isp/isp.c b/drivers/media/video/omap3isp/isp.c
index 503bd7922bd6..472a69359e60 100644
--- a/drivers/media/video/omap3isp/isp.c
+++ b/drivers/media/video/omap3isp/isp.c
@@ -215,20 +215,21 @@ static u32 isp_set_xclk(struct isp_device *isp, u32 xclk, u8 xclksel)
215 } 215 }
216 216
217 switch (xclksel) { 217 switch (xclksel) {
218 case 0: 218 case ISP_XCLK_A:
219 isp_reg_clr_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_TCTRL_CTRL, 219 isp_reg_clr_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_TCTRL_CTRL,
220 ISPTCTRL_CTRL_DIVA_MASK, 220 ISPTCTRL_CTRL_DIVA_MASK,
221 divisor << ISPTCTRL_CTRL_DIVA_SHIFT); 221 divisor << ISPTCTRL_CTRL_DIVA_SHIFT);
222 dev_dbg(isp->dev, "isp_set_xclk(): cam_xclka set to %d Hz\n", 222 dev_dbg(isp->dev, "isp_set_xclk(): cam_xclka set to %d Hz\n",
223 currentxclk); 223 currentxclk);
224 break; 224 break;
225 case 1: 225 case ISP_XCLK_B:
226 isp_reg_clr_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_TCTRL_CTRL, 226 isp_reg_clr_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_TCTRL_CTRL,
227 ISPTCTRL_CTRL_DIVB_MASK, 227 ISPTCTRL_CTRL_DIVB_MASK,
228 divisor << ISPTCTRL_CTRL_DIVB_SHIFT); 228 divisor << ISPTCTRL_CTRL_DIVB_SHIFT);
229 dev_dbg(isp->dev, "isp_set_xclk(): cam_xclkb set to %d Hz\n", 229 dev_dbg(isp->dev, "isp_set_xclk(): cam_xclkb set to %d Hz\n",
230 currentxclk); 230 currentxclk);
231 break; 231 break;
232 case ISP_XCLK_NONE:
232 default: 233 default:
233 omap3isp_put(isp); 234 omap3isp_put(isp);
234 dev_dbg(isp->dev, "ISP_ERR: isp_set_xclk(): Invalid requested " 235 dev_dbg(isp->dev, "ISP_ERR: isp_set_xclk(): Invalid requested "
@@ -237,13 +238,13 @@ static u32 isp_set_xclk(struct isp_device *isp, u32 xclk, u8 xclksel)
237 } 238 }
238 239
239 /* Do we go from stable whatever to clock? */ 240 /* Do we go from stable whatever to clock? */
240 if (divisor >= 2 && isp->xclk_divisor[xclksel] < 2) 241 if (divisor >= 2 && isp->xclk_divisor[xclksel - 1] < 2)
241 omap3isp_get(isp); 242 omap3isp_get(isp);
242 /* Stopping the clock. */ 243 /* Stopping the clock. */
243 else if (divisor < 2 && isp->xclk_divisor[xclksel] >= 2) 244 else if (divisor < 2 && isp->xclk_divisor[xclksel - 1] >= 2)
244 omap3isp_put(isp); 245 omap3isp_put(isp);
245 246
246 isp->xclk_divisor[xclksel] = divisor; 247 isp->xclk_divisor[xclksel - 1] = divisor;
247 248
248 omap3isp_put(isp); 249 omap3isp_put(isp);
249 250
@@ -285,7 +286,8 @@ static void isp_power_settings(struct isp_device *isp, int idle)
285 */ 286 */
286void omap3isp_configure_bridge(struct isp_device *isp, 287void omap3isp_configure_bridge(struct isp_device *isp,
287 enum ccdc_input_entity input, 288 enum ccdc_input_entity input,
288 const struct isp_parallel_platform_data *pdata) 289 const struct isp_parallel_platform_data *pdata,
290 unsigned int shift)
289{ 291{
290 u32 ispctrl_val; 292 u32 ispctrl_val;
291 293
@@ -298,9 +300,9 @@ void omap3isp_configure_bridge(struct isp_device *isp,
298 switch (input) { 300 switch (input) {
299 case CCDC_INPUT_PARALLEL: 301 case CCDC_INPUT_PARALLEL:
300 ispctrl_val |= ISPCTRL_PAR_SER_CLK_SEL_PARALLEL; 302 ispctrl_val |= ISPCTRL_PAR_SER_CLK_SEL_PARALLEL;
301 ispctrl_val |= pdata->data_lane_shift << ISPCTRL_SHIFT_SHIFT;
302 ispctrl_val |= pdata->clk_pol << ISPCTRL_PAR_CLK_POL_SHIFT; 303 ispctrl_val |= pdata->clk_pol << ISPCTRL_PAR_CLK_POL_SHIFT;
303 ispctrl_val |= pdata->bridge << ISPCTRL_PAR_BRIDGE_SHIFT; 304 ispctrl_val |= pdata->bridge << ISPCTRL_PAR_BRIDGE_SHIFT;
305 shift += pdata->data_lane_shift * 2;
304 break; 306 break;
305 307
306 case CCDC_INPUT_CSI2A: 308 case CCDC_INPUT_CSI2A:
@@ -319,6 +321,8 @@ void omap3isp_configure_bridge(struct isp_device *isp,
319 return; 321 return;
320 } 322 }
321 323
324 ispctrl_val |= ((shift/2) << ISPCTRL_SHIFT_SHIFT) & ISPCTRL_SHIFT_MASK;
325
322 ispctrl_val &= ~ISPCTRL_SYNC_DETECT_MASK; 326 ispctrl_val &= ~ISPCTRL_SYNC_DETECT_MASK;
323 ispctrl_val |= ISPCTRL_SYNC_DETECT_VSRISE; 327 ispctrl_val |= ISPCTRL_SYNC_DETECT_VSRISE;
324 328
@@ -658,6 +662,8 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, int use)
658 662
659 /* Apply power change to connected non-nodes. */ 663 /* Apply power change to connected non-nodes. */
660 ret = isp_pipeline_pm_power(entity, change); 664 ret = isp_pipeline_pm_power(entity, change);
665 if (ret < 0)
666 entity->use_count -= change;
661 667
662 mutex_unlock(&entity->parent->graph_mutex); 668 mutex_unlock(&entity->parent->graph_mutex);
663 669
@@ -872,6 +878,9 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe)
872 } 878 }
873 } 879 }
874 880
881 if (failure < 0)
882 isp->needs_reset = true;
883
875 return failure; 884 return failure;
876} 885}
877 886
@@ -884,7 +893,8 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe)
884 * single-shot or continuous mode. 893 * single-shot or continuous mode.
885 * 894 *
886 * Return 0 if successful, or the return value of the failed video::s_stream 895 * Return 0 if successful, or the return value of the failed video::s_stream
887 * operation otherwise. 896 * operation otherwise. The pipeline state is not updated when the operation
897 * fails, except when stopping the pipeline.
888 */ 898 */
889int omap3isp_pipeline_set_stream(struct isp_pipeline *pipe, 899int omap3isp_pipeline_set_stream(struct isp_pipeline *pipe,
890 enum isp_pipeline_stream_state state) 900 enum isp_pipeline_stream_state state)
@@ -895,7 +905,9 @@ int omap3isp_pipeline_set_stream(struct isp_pipeline *pipe,
895 ret = isp_pipeline_disable(pipe); 905 ret = isp_pipeline_disable(pipe);
896 else 906 else
897 ret = isp_pipeline_enable(pipe, state); 907 ret = isp_pipeline_enable(pipe, state);
898 pipe->stream_state = state; 908
909 if (ret == 0 || state == ISP_PIPELINE_STREAM_STOPPED)
910 pipe->stream_state = state;
899 911
900 return ret; 912 return ret;
901} 913}
@@ -1481,6 +1493,10 @@ void omap3isp_put(struct isp_device *isp)
1481 if (--isp->ref_count == 0) { 1493 if (--isp->ref_count == 0) {
1482 isp_disable_interrupts(isp); 1494 isp_disable_interrupts(isp);
1483 isp_save_ctx(isp); 1495 isp_save_ctx(isp);
1496 if (isp->needs_reset) {
1497 isp_reset(isp);
1498 isp->needs_reset = false;
1499 }
1484 isp_disable_clocks(isp); 1500 isp_disable_clocks(isp);
1485 } 1501 }
1486 mutex_unlock(&isp->isp_mutex); 1502 mutex_unlock(&isp->isp_mutex);
diff --git a/drivers/media/video/omap3isp/isp.h b/drivers/media/video/omap3isp/isp.h
index cf5214e95a92..2620c405f5e4 100644
--- a/drivers/media/video/omap3isp/isp.h
+++ b/drivers/media/video/omap3isp/isp.h
@@ -132,7 +132,6 @@ struct isp_reg {
132 132
133/** 133/**
134 * struct isp_parallel_platform_data - Parallel interface platform data 134 * struct isp_parallel_platform_data - Parallel interface platform data
135 * @width: Parallel bus width in bits (8, 10, 11 or 12)
136 * @data_lane_shift: Data lane shifter 135 * @data_lane_shift: Data lane shifter
137 * 0 - CAMEXT[13:0] -> CAM[13:0] 136 * 0 - CAMEXT[13:0] -> CAM[13:0]
138 * 1 - CAMEXT[13:2] -> CAM[11:0] 137 * 1 - CAMEXT[13:2] -> CAM[11:0]
@@ -146,7 +145,6 @@ struct isp_reg {
146 * ISPCTRL_PAR_BRIDGE_BENDIAN - Big endian 145 * ISPCTRL_PAR_BRIDGE_BENDIAN - Big endian
147 */ 146 */
148struct isp_parallel_platform_data { 147struct isp_parallel_platform_data {
149 unsigned int width;
150 unsigned int data_lane_shift:2; 148 unsigned int data_lane_shift:2;
151 unsigned int clk_pol:1; 149 unsigned int clk_pol:1;
152 unsigned int bridge:4; 150 unsigned int bridge:4;
@@ -262,6 +260,7 @@ struct isp_device {
262 /* ISP Obj */ 260 /* ISP Obj */
263 spinlock_t stat_lock; /* common lock for statistic drivers */ 261 spinlock_t stat_lock; /* common lock for statistic drivers */
264 struct mutex isp_mutex; /* For handling ref_count field */ 262 struct mutex isp_mutex; /* For handling ref_count field */
263 bool needs_reset;
265 int has_context; 264 int has_context;
266 int ref_count; 265 int ref_count;
267 unsigned int autoidle; 266 unsigned int autoidle;
@@ -311,11 +310,12 @@ int omap3isp_pipeline_set_stream(struct isp_pipeline *pipe,
311 enum isp_pipeline_stream_state state); 310 enum isp_pipeline_stream_state state);
312void omap3isp_configure_bridge(struct isp_device *isp, 311void omap3isp_configure_bridge(struct isp_device *isp,
313 enum ccdc_input_entity input, 312 enum ccdc_input_entity input,
314 const struct isp_parallel_platform_data *pdata); 313 const struct isp_parallel_platform_data *pdata,
314 unsigned int shift);
315 315
316#define ISP_XCLK_NONE -1 316#define ISP_XCLK_NONE 0
317#define ISP_XCLK_A 0 317#define ISP_XCLK_A 1
318#define ISP_XCLK_B 1 318#define ISP_XCLK_B 2
319 319
320struct isp_device *omap3isp_get(struct isp_device *isp); 320struct isp_device *omap3isp_get(struct isp_device *isp);
321void omap3isp_put(struct isp_device *isp); 321void omap3isp_put(struct isp_device *isp);
diff --git a/drivers/media/video/omap3isp/ispccdc.c b/drivers/media/video/omap3isp/ispccdc.c
index 5ff9d14ce710..39d501bda636 100644
--- a/drivers/media/video/omap3isp/ispccdc.c
+++ b/drivers/media/video/omap3isp/ispccdc.c
@@ -43,6 +43,12 @@ __ccdc_get_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_fh *fh,
43 43
44static const unsigned int ccdc_fmts[] = { 44static const unsigned int ccdc_fmts[] = {
45 V4L2_MBUS_FMT_Y8_1X8, 45 V4L2_MBUS_FMT_Y8_1X8,
46 V4L2_MBUS_FMT_Y10_1X10,
47 V4L2_MBUS_FMT_Y12_1X12,
48 V4L2_MBUS_FMT_SGRBG8_1X8,
49 V4L2_MBUS_FMT_SRGGB8_1X8,
50 V4L2_MBUS_FMT_SBGGR8_1X8,
51 V4L2_MBUS_FMT_SGBRG8_1X8,
46 V4L2_MBUS_FMT_SGRBG10_1X10, 52 V4L2_MBUS_FMT_SGRBG10_1X10,
47 V4L2_MBUS_FMT_SRGGB10_1X10, 53 V4L2_MBUS_FMT_SRGGB10_1X10,
48 V4L2_MBUS_FMT_SBGGR10_1X10, 54 V4L2_MBUS_FMT_SBGGR10_1X10,
@@ -1110,21 +1116,38 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc)
1110 struct isp_parallel_platform_data *pdata = NULL; 1116 struct isp_parallel_platform_data *pdata = NULL;
1111 struct v4l2_subdev *sensor; 1117 struct v4l2_subdev *sensor;
1112 struct v4l2_mbus_framefmt *format; 1118 struct v4l2_mbus_framefmt *format;
1119 const struct isp_format_info *fmt_info;
1120 struct v4l2_subdev_format fmt_src;
1121 unsigned int depth_out;
1122 unsigned int depth_in = 0;
1113 struct media_pad *pad; 1123 struct media_pad *pad;
1114 unsigned long flags; 1124 unsigned long flags;
1125 unsigned int shift;
1115 u32 syn_mode; 1126 u32 syn_mode;
1116 u32 ccdc_pattern; 1127 u32 ccdc_pattern;
1117 1128
1118 if (ccdc->input == CCDC_INPUT_PARALLEL) { 1129 pad = media_entity_remote_source(&ccdc->pads[CCDC_PAD_SINK]);
1119 pad = media_entity_remote_source(&ccdc->pads[CCDC_PAD_SINK]); 1130 sensor = media_entity_to_v4l2_subdev(pad->entity);
1120 sensor = media_entity_to_v4l2_subdev(pad->entity); 1131 if (ccdc->input == CCDC_INPUT_PARALLEL)
1121 pdata = &((struct isp_v4l2_subdevs_group *)sensor->host_priv) 1132 pdata = &((struct isp_v4l2_subdevs_group *)sensor->host_priv)
1122 ->bus.parallel; 1133 ->bus.parallel;
1134
1135 /* Compute shift value for lane shifter to configure the bridge. */
1136 fmt_src.pad = pad->index;
1137 fmt_src.which = V4L2_SUBDEV_FORMAT_ACTIVE;
1138 if (!v4l2_subdev_call(sensor, pad, get_fmt, NULL, &fmt_src)) {
1139 fmt_info = omap3isp_video_format_info(fmt_src.format.code);
1140 depth_in = fmt_info->bpp;
1123 } 1141 }
1124 1142
1125 omap3isp_configure_bridge(isp, ccdc->input, pdata); 1143 fmt_info = omap3isp_video_format_info
1144 (isp->isp_ccdc.formats[CCDC_PAD_SINK].code);
1145 depth_out = fmt_info->bpp;
1146
1147 shift = depth_in - depth_out;
1148 omap3isp_configure_bridge(isp, ccdc->input, pdata, shift);
1126 1149
1127 ccdc->syncif.datsz = pdata ? pdata->width : 10; 1150 ccdc->syncif.datsz = depth_out;
1128 ccdc_config_sync_if(ccdc, &ccdc->syncif); 1151 ccdc_config_sync_if(ccdc, &ccdc->syncif);
1129 1152
1130 /* CCDC_PAD_SINK */ 1153 /* CCDC_PAD_SINK */
@@ -1338,7 +1361,7 @@ static int ccdc_sbl_wait_idle(struct isp_ccdc_device *ccdc,
1338 * @ccdc: Pointer to ISP CCDC device. 1361 * @ccdc: Pointer to ISP CCDC device.
1339 * @event: Pointing which event trigger handler 1362 * @event: Pointing which event trigger handler
1340 * 1363 *
1341 * Return 1 when the event and stopping request combination is satisfyied, 1364 * Return 1 when the event and stopping request combination is satisfied,
1342 * zero otherwise. 1365 * zero otherwise.
1343 */ 1366 */
1344static int __ccdc_handle_stopping(struct isp_ccdc_device *ccdc, u32 event) 1367static int __ccdc_handle_stopping(struct isp_ccdc_device *ccdc, u32 event)
@@ -1618,7 +1641,7 @@ static int ccdc_video_queue(struct isp_video *video, struct isp_buffer *buffer)
1618 1641
1619 ccdc_set_outaddr(ccdc, buffer->isp_addr); 1642 ccdc_set_outaddr(ccdc, buffer->isp_addr);
1620 1643
1621 /* We now have a buffer queued on the output, restart the pipeline in 1644 /* We now have a buffer queued on the output, restart the pipeline
1622 * on the next CCDC interrupt if running in continuous mode (or when 1645 * on the next CCDC interrupt if running in continuous mode (or when
1623 * starting the stream). 1646 * starting the stream).
1624 */ 1647 */
diff --git a/drivers/media/video/omap3isp/isppreview.c b/drivers/media/video/omap3isp/isppreview.c
index 2b16988a501d..aba537af87e4 100644
--- a/drivers/media/video/omap3isp/isppreview.c
+++ b/drivers/media/video/omap3isp/isppreview.c
@@ -755,7 +755,7 @@ static struct preview_update update_attrs[] = {
755 * @configs - pointer to update config structure. 755 * @configs - pointer to update config structure.
756 * @config - return pointer to appropriate structure field. 756 * @config - return pointer to appropriate structure field.
757 * @bit - for which feature to return pointers. 757 * @bit - for which feature to return pointers.
758 * Return size of coresponding prev_params member 758 * Return size of corresponding prev_params member
759 */ 759 */
760static u32 760static u32
761__preview_get_ptrs(struct prev_params *params, void **param, 761__preview_get_ptrs(struct prev_params *params, void **param,
diff --git a/drivers/media/video/omap3isp/ispqueue.c b/drivers/media/video/omap3isp/ispqueue.c
index 8fddc5806b0d..9c317148205f 100644
--- a/drivers/media/video/omap3isp/ispqueue.c
+++ b/drivers/media/video/omap3isp/ispqueue.c
@@ -339,7 +339,7 @@ static int isp_video_buffer_prepare_user(struct isp_video_buffer *buf)
339 up_read(&current->mm->mmap_sem); 339 up_read(&current->mm->mmap_sem);
340 340
341 if (ret != buf->npages) { 341 if (ret != buf->npages) {
342 buf->npages = ret; 342 buf->npages = ret < 0 ? 0 : ret;
343 isp_video_buffer_cleanup(buf); 343 isp_video_buffer_cleanup(buf);
344 return -EFAULT; 344 return -EFAULT;
345 } 345 }
@@ -408,8 +408,8 @@ done:
408 * isp_video_buffer_prepare_vm_flags - Get VMA flags for a userspace address 408 * isp_video_buffer_prepare_vm_flags - Get VMA flags for a userspace address
409 * 409 *
410 * This function locates the VMAs for the buffer's userspace address and checks 410 * This function locates the VMAs for the buffer's userspace address and checks
411 * that their flags match. The onlflag that we need to care for at the moment is 411 * that their flags match. The only flag that we need to care for at the moment
412 * VM_PFNMAP. 412 * is VM_PFNMAP.
413 * 413 *
414 * The buffer vm_flags field is set to the first VMA flags. 414 * The buffer vm_flags field is set to the first VMA flags.
415 * 415 *
diff --git a/drivers/media/video/omap3isp/ispresizer.c b/drivers/media/video/omap3isp/ispresizer.c
index 653f88ba56db..0bb0f8cd36f5 100644
--- a/drivers/media/video/omap3isp/ispresizer.c
+++ b/drivers/media/video/omap3isp/ispresizer.c
@@ -714,19 +714,50 @@ static void resizer_print_status(struct isp_res_device *res)
714 * iw and ih are the input width and height after cropping. Those equations need 714 * iw and ih are the input width and height after cropping. Those equations need
715 * to be satisfied exactly for the resizer to work correctly. 715 * to be satisfied exactly for the resizer to work correctly.
716 * 716 *
717 * Reverting the equations, we can compute the resizing ratios with 717 * The equations can't be easily reverted, as the >> 8 operation is not linear.
718 * In addition, not all input sizes can be achieved for a given output size. To
719 * get the highest input size lower than or equal to the requested input size,
720 * we need to compute the highest resizing ratio that satisfies the following
721 * inequality (taking the 4-tap mode width equation as an example)
722 *
723 * iw >= (32 * sph + (ow - 1) * hrsz + 16) >> 8 - 7
724 *
725 * (where iw is the requested input width) which can be rewritten as
726 *
727 * iw - 7 >= (32 * sph + (ow - 1) * hrsz + 16) >> 8
728 * (iw - 7) << 8 >= 32 * sph + (ow - 1) * hrsz + 16 - b
729 * ((iw - 7) << 8) + b >= 32 * sph + (ow - 1) * hrsz + 16
730 *
731 * where b is the value of the 8 least significant bits of the right hand side
732 * expression of the last inequality. The highest resizing ratio value will be
733 * achieved when b is equal to its maximum value of 255. That resizing ratio
734 * value will still satisfy the original inequality, as b will disappear when
735 * the expression will be shifted right by 8.
736 *
737 * The reverted the equations thus become
718 * 738 *
719 * - 8-phase, 4-tap mode 739 * - 8-phase, 4-tap mode
720 * hrsz = ((iw - 7) * 256 - 16 - 32 * sph) / (ow - 1) 740 * hrsz = ((iw - 7) * 256 + 255 - 16 - 32 * sph) / (ow - 1)
721 * vrsz = ((ih - 4) * 256 - 16 - 32 * spv) / (oh - 1) 741 * vrsz = ((ih - 4) * 256 + 255 - 16 - 32 * spv) / (oh - 1)
722 * - 4-phase, 7-tap mode 742 * - 4-phase, 7-tap mode
723 * hrsz = ((iw - 7) * 256 - 32 - 64 * sph) / (ow - 1) 743 * hrsz = ((iw - 7) * 256 + 255 - 32 - 64 * sph) / (ow - 1)
724 * vrsz = ((ih - 7) * 256 - 32 - 64 * spv) / (oh - 1) 744 * vrsz = ((ih - 7) * 256 + 255 - 32 - 64 * spv) / (oh - 1)
725 * 745 *
726 * The ratios are integer values, and must be rounded down to ensure that the 746 * The ratios are integer values, and are rounded down to ensure that the
727 * cropped input size is not bigger than the uncropped input size. As the ratio 747 * cropped input size is not bigger than the uncropped input size.
728 * in 7-tap mode is always smaller than the ratio in 4-tap mode, we can use the 748 *
729 * 7-tap mode equations to compute a ratio approximation. 749 * As the number of phases/taps, used to select the correct equations to compute
750 * the ratio, depends on the ratio, we start with the 4-tap mode equations to
751 * compute an approximation of the ratio, and switch to the 7-tap mode equations
752 * if the approximation is higher than the ratio threshold.
753 *
754 * As the 7-tap mode equations will return a ratio smaller than or equal to the
755 * 4-tap mode equations, the resulting ratio could become lower than or equal to
756 * the ratio threshold. This 'equations loop' isn't an issue as long as the
757 * correct equations are used to compute the final input size. Starting with the
758 * 4-tap mode equations ensure that, in case of values resulting in a 'ratio
759 * loop', the smallest of the ratio values will be used, never exceeding the
760 * requested input size.
730 * 761 *
731 * We first clamp the output size according to the hardware capabilitie to avoid 762 * We first clamp the output size according to the hardware capabilitie to avoid
732 * auto-cropping the input more than required to satisfy the TRM equations. The 763 * auto-cropping the input more than required to satisfy the TRM equations. The
@@ -775,6 +806,8 @@ static void resizer_calc_ratios(struct isp_res_device *res,
775 unsigned int max_width; 806 unsigned int max_width;
776 unsigned int max_height; 807 unsigned int max_height;
777 unsigned int width_alignment; 808 unsigned int width_alignment;
809 unsigned int width;
810 unsigned int height;
778 811
779 /* 812 /*
780 * Clamp the output height based on the hardware capabilities and 813 * Clamp the output height based on the hardware capabilities and
@@ -786,19 +819,22 @@ static void resizer_calc_ratios(struct isp_res_device *res,
786 max_height = min_t(unsigned int, max_height, MAX_OUT_HEIGHT); 819 max_height = min_t(unsigned int, max_height, MAX_OUT_HEIGHT);
787 output->height = clamp(output->height, min_height, max_height); 820 output->height = clamp(output->height, min_height, max_height);
788 821
789 ratio->vert = ((input->height - 7) * 256 - 32 - 64 * spv) 822 ratio->vert = ((input->height - 4) * 256 + 255 - 16 - 32 * spv)
790 / (output->height - 1); 823 / (output->height - 1);
824 if (ratio->vert > MID_RESIZE_VALUE)
825 ratio->vert = ((input->height - 7) * 256 + 255 - 32 - 64 * spv)
826 / (output->height - 1);
791 ratio->vert = clamp_t(unsigned int, ratio->vert, 827 ratio->vert = clamp_t(unsigned int, ratio->vert,
792 MIN_RESIZE_VALUE, MAX_RESIZE_VALUE); 828 MIN_RESIZE_VALUE, MAX_RESIZE_VALUE);
793 829
794 if (ratio->vert <= MID_RESIZE_VALUE) { 830 if (ratio->vert <= MID_RESIZE_VALUE) {
795 upscaled_height = (output->height - 1) * ratio->vert 831 upscaled_height = (output->height - 1) * ratio->vert
796 + 32 * spv + 16; 832 + 32 * spv + 16;
797 input->height = (upscaled_height >> 8) + 4; 833 height = (upscaled_height >> 8) + 4;
798 } else { 834 } else {
799 upscaled_height = (output->height - 1) * ratio->vert 835 upscaled_height = (output->height - 1) * ratio->vert
800 + 64 * spv + 32; 836 + 64 * spv + 32;
801 input->height = (upscaled_height >> 8) + 7; 837 height = (upscaled_height >> 8) + 7;
802 } 838 }
803 839
804 /* 840 /*
@@ -854,20 +890,29 @@ static void resizer_calc_ratios(struct isp_res_device *res,
854 max_width & ~(width_alignment - 1)); 890 max_width & ~(width_alignment - 1));
855 output->width = ALIGN(output->width, width_alignment); 891 output->width = ALIGN(output->width, width_alignment);
856 892
857 ratio->horz = ((input->width - 7) * 256 - 32 - 64 * sph) 893 ratio->horz = ((input->width - 7) * 256 + 255 - 16 - 32 * sph)
858 / (output->width - 1); 894 / (output->width - 1);
895 if (ratio->horz > MID_RESIZE_VALUE)
896 ratio->horz = ((input->width - 7) * 256 + 255 - 32 - 64 * sph)
897 / (output->width - 1);
859 ratio->horz = clamp_t(unsigned int, ratio->horz, 898 ratio->horz = clamp_t(unsigned int, ratio->horz,
860 MIN_RESIZE_VALUE, MAX_RESIZE_VALUE); 899 MIN_RESIZE_VALUE, MAX_RESIZE_VALUE);
861 900
862 if (ratio->horz <= MID_RESIZE_VALUE) { 901 if (ratio->horz <= MID_RESIZE_VALUE) {
863 upscaled_width = (output->width - 1) * ratio->horz 902 upscaled_width = (output->width - 1) * ratio->horz
864 + 32 * sph + 16; 903 + 32 * sph + 16;
865 input->width = (upscaled_width >> 8) + 7; 904 width = (upscaled_width >> 8) + 7;
866 } else { 905 } else {
867 upscaled_width = (output->width - 1) * ratio->horz 906 upscaled_width = (output->width - 1) * ratio->horz
868 + 64 * sph + 32; 907 + 64 * sph + 32;
869 input->width = (upscaled_width >> 8) + 7; 908 width = (upscaled_width >> 8) + 7;
870 } 909 }
910
911 /* Center the new crop rectangle. */
912 input->left += (input->width - width) / 2;
913 input->top += (input->height - height) / 2;
914 input->width = width;
915 input->height = height;
871} 916}
872 917
873/* 918/*
diff --git a/drivers/media/video/omap3isp/ispstat.h b/drivers/media/video/omap3isp/ispstat.h
index 820950c9ef46..d86da94fa50d 100644
--- a/drivers/media/video/omap3isp/ispstat.h
+++ b/drivers/media/video/omap3isp/ispstat.h
@@ -131,9 +131,9 @@ struct ispstat {
131struct ispstat_generic_config { 131struct ispstat_generic_config {
132 /* 132 /*
133 * Fields must be in the same order as in: 133 * Fields must be in the same order as in:
134 * - isph3a_aewb_config 134 * - omap3isp_h3a_aewb_config
135 * - isph3a_af_config 135 * - omap3isp_h3a_af_config
136 * - isphist_config 136 * - omap3isp_hist_config
137 */ 137 */
138 u32 buf_size; 138 u32 buf_size;
139 u16 config_counter; 139 u16 config_counter;
diff --git a/drivers/media/video/omap3isp/ispvideo.c b/drivers/media/video/omap3isp/ispvideo.c
index 208a7ec739d7..9cd8f1aa567b 100644
--- a/drivers/media/video/omap3isp/ispvideo.c
+++ b/drivers/media/video/omap3isp/ispvideo.c
@@ -47,29 +47,59 @@
47 47
48static struct isp_format_info formats[] = { 48static struct isp_format_info formats[] = {
49 { V4L2_MBUS_FMT_Y8_1X8, V4L2_MBUS_FMT_Y8_1X8, 49 { V4L2_MBUS_FMT_Y8_1X8, V4L2_MBUS_FMT_Y8_1X8,
50 V4L2_MBUS_FMT_Y8_1X8, V4L2_PIX_FMT_GREY, 8, }, 50 V4L2_MBUS_FMT_Y8_1X8, V4L2_MBUS_FMT_Y8_1X8,
51 V4L2_PIX_FMT_GREY, 8, },
52 { V4L2_MBUS_FMT_Y10_1X10, V4L2_MBUS_FMT_Y10_1X10,
53 V4L2_MBUS_FMT_Y10_1X10, V4L2_MBUS_FMT_Y8_1X8,
54 V4L2_PIX_FMT_Y10, 10, },
55 { V4L2_MBUS_FMT_Y12_1X12, V4L2_MBUS_FMT_Y10_1X10,
56 V4L2_MBUS_FMT_Y12_1X12, V4L2_MBUS_FMT_Y8_1X8,
57 V4L2_PIX_FMT_Y12, 12, },
58 { V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_MBUS_FMT_SBGGR8_1X8,
59 V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_MBUS_FMT_SBGGR8_1X8,
60 V4L2_PIX_FMT_SBGGR8, 8, },
61 { V4L2_MBUS_FMT_SGBRG8_1X8, V4L2_MBUS_FMT_SGBRG8_1X8,
62 V4L2_MBUS_FMT_SGBRG8_1X8, V4L2_MBUS_FMT_SGBRG8_1X8,
63 V4L2_PIX_FMT_SGBRG8, 8, },
64 { V4L2_MBUS_FMT_SGRBG8_1X8, V4L2_MBUS_FMT_SGRBG8_1X8,
65 V4L2_MBUS_FMT_SGRBG8_1X8, V4L2_MBUS_FMT_SGRBG8_1X8,
66 V4L2_PIX_FMT_SGRBG8, 8, },
67 { V4L2_MBUS_FMT_SRGGB8_1X8, V4L2_MBUS_FMT_SRGGB8_1X8,
68 V4L2_MBUS_FMT_SRGGB8_1X8, V4L2_MBUS_FMT_SRGGB8_1X8,
69 V4L2_PIX_FMT_SRGGB8, 8, },
51 { V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, 70 { V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8, V4L2_MBUS_FMT_SGRBG10_DPCM8_1X8,
52 V4L2_MBUS_FMT_SGRBG10_1X10, V4L2_PIX_FMT_SGRBG10DPCM8, 8, }, 71 V4L2_MBUS_FMT_SGRBG10_1X10, 0,
72 V4L2_PIX_FMT_SGRBG10DPCM8, 8, },
53 { V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_MBUS_FMT_SBGGR10_1X10, 73 { V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_MBUS_FMT_SBGGR10_1X10,
54 V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_PIX_FMT_SBGGR10, 10, }, 74 V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_MBUS_FMT_SBGGR8_1X8,
75 V4L2_PIX_FMT_SBGGR10, 10, },
55 { V4L2_MBUS_FMT_SGBRG10_1X10, V4L2_MBUS_FMT_SGBRG10_1X10, 76 { V4L2_MBUS_FMT_SGBRG10_1X10, V4L2_MBUS_FMT_SGBRG10_1X10,
56 V4L2_MBUS_FMT_SGBRG10_1X10, V4L2_PIX_FMT_SGBRG10, 10, }, 77 V4L2_MBUS_FMT_SGBRG10_1X10, V4L2_MBUS_FMT_SGBRG8_1X8,
78 V4L2_PIX_FMT_SGBRG10, 10, },
57 { V4L2_MBUS_FMT_SGRBG10_1X10, V4L2_MBUS_FMT_SGRBG10_1X10, 79 { V4L2_MBUS_FMT_SGRBG10_1X10, V4L2_MBUS_FMT_SGRBG10_1X10,
58 V4L2_MBUS_FMT_SGRBG10_1X10, V4L2_PIX_FMT_SGRBG10, 10, }, 80 V4L2_MBUS_FMT_SGRBG10_1X10, V4L2_MBUS_FMT_SGRBG8_1X8,
81 V4L2_PIX_FMT_SGRBG10, 10, },
59 { V4L2_MBUS_FMT_SRGGB10_1X10, V4L2_MBUS_FMT_SRGGB10_1X10, 82 { V4L2_MBUS_FMT_SRGGB10_1X10, V4L2_MBUS_FMT_SRGGB10_1X10,
60 V4L2_MBUS_FMT_SRGGB10_1X10, V4L2_PIX_FMT_SRGGB10, 10, }, 83 V4L2_MBUS_FMT_SRGGB10_1X10, V4L2_MBUS_FMT_SRGGB8_1X8,
84 V4L2_PIX_FMT_SRGGB10, 10, },
61 { V4L2_MBUS_FMT_SBGGR12_1X12, V4L2_MBUS_FMT_SBGGR10_1X10, 85 { V4L2_MBUS_FMT_SBGGR12_1X12, V4L2_MBUS_FMT_SBGGR10_1X10,
62 V4L2_MBUS_FMT_SBGGR12_1X12, V4L2_PIX_FMT_SBGGR12, 12, }, 86 V4L2_MBUS_FMT_SBGGR12_1X12, V4L2_MBUS_FMT_SBGGR8_1X8,
87 V4L2_PIX_FMT_SBGGR12, 12, },
63 { V4L2_MBUS_FMT_SGBRG12_1X12, V4L2_MBUS_FMT_SGBRG10_1X10, 88 { V4L2_MBUS_FMT_SGBRG12_1X12, V4L2_MBUS_FMT_SGBRG10_1X10,
64 V4L2_MBUS_FMT_SGBRG12_1X12, V4L2_PIX_FMT_SGBRG12, 12, }, 89 V4L2_MBUS_FMT_SGBRG12_1X12, V4L2_MBUS_FMT_SGBRG8_1X8,
90 V4L2_PIX_FMT_SGBRG12, 12, },
65 { V4L2_MBUS_FMT_SGRBG12_1X12, V4L2_MBUS_FMT_SGRBG10_1X10, 91 { V4L2_MBUS_FMT_SGRBG12_1X12, V4L2_MBUS_FMT_SGRBG10_1X10,
66 V4L2_MBUS_FMT_SGRBG12_1X12, V4L2_PIX_FMT_SGRBG12, 12, }, 92 V4L2_MBUS_FMT_SGRBG12_1X12, V4L2_MBUS_FMT_SGRBG8_1X8,
93 V4L2_PIX_FMT_SGRBG12, 12, },
67 { V4L2_MBUS_FMT_SRGGB12_1X12, V4L2_MBUS_FMT_SRGGB10_1X10, 94 { V4L2_MBUS_FMT_SRGGB12_1X12, V4L2_MBUS_FMT_SRGGB10_1X10,
68 V4L2_MBUS_FMT_SRGGB12_1X12, V4L2_PIX_FMT_SRGGB12, 12, }, 95 V4L2_MBUS_FMT_SRGGB12_1X12, V4L2_MBUS_FMT_SRGGB8_1X8,
96 V4L2_PIX_FMT_SRGGB12, 12, },
69 { V4L2_MBUS_FMT_UYVY8_1X16, V4L2_MBUS_FMT_UYVY8_1X16, 97 { V4L2_MBUS_FMT_UYVY8_1X16, V4L2_MBUS_FMT_UYVY8_1X16,
70 V4L2_MBUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_UYVY, 16, }, 98 V4L2_MBUS_FMT_UYVY8_1X16, 0,
99 V4L2_PIX_FMT_UYVY, 16, },
71 { V4L2_MBUS_FMT_YUYV8_1X16, V4L2_MBUS_FMT_YUYV8_1X16, 100 { V4L2_MBUS_FMT_YUYV8_1X16, V4L2_MBUS_FMT_YUYV8_1X16,
72 V4L2_MBUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_YUYV, 16, }, 101 V4L2_MBUS_FMT_YUYV8_1X16, 0,
102 V4L2_PIX_FMT_YUYV, 16, },
73}; 103};
74 104
75const struct isp_format_info * 105const struct isp_format_info *
@@ -86,6 +116,37 @@ omap3isp_video_format_info(enum v4l2_mbus_pixelcode code)
86} 116}
87 117
88/* 118/*
119 * Decide whether desired output pixel code can be obtained with
120 * the lane shifter by shifting the input pixel code.
121 * @in: input pixelcode to shifter
122 * @out: output pixelcode from shifter
123 * @additional_shift: # of bits the sensor's LSB is offset from CAMEXT[0]
124 *
125 * return true if the combination is possible
126 * return false otherwise
127 */
128static bool isp_video_is_shiftable(enum v4l2_mbus_pixelcode in,
129 enum v4l2_mbus_pixelcode out,
130 unsigned int additional_shift)
131{
132 const struct isp_format_info *in_info, *out_info;
133
134 if (in == out)
135 return true;
136
137 in_info = omap3isp_video_format_info(in);
138 out_info = omap3isp_video_format_info(out);
139
140 if ((in_info->flavor == 0) || (out_info->flavor == 0))
141 return false;
142
143 if (in_info->flavor != out_info->flavor)
144 return false;
145
146 return in_info->bpp - out_info->bpp + additional_shift <= 6;
147}
148
149/*
89 * isp_video_mbus_to_pix - Convert v4l2_mbus_framefmt to v4l2_pix_format 150 * isp_video_mbus_to_pix - Convert v4l2_mbus_framefmt to v4l2_pix_format
90 * @video: ISP video instance 151 * @video: ISP video instance
91 * @mbus: v4l2_mbus_framefmt format (input) 152 * @mbus: v4l2_mbus_framefmt format (input)
@@ -235,6 +296,7 @@ static int isp_video_validate_pipeline(struct isp_pipeline *pipe)
235 return -EPIPE; 296 return -EPIPE;
236 297
237 while (1) { 298 while (1) {
299 unsigned int shifter_link;
238 /* Retrieve the sink format */ 300 /* Retrieve the sink format */
239 pad = &subdev->entity.pads[0]; 301 pad = &subdev->entity.pads[0];
240 if (!(pad->flags & MEDIA_PAD_FL_SINK)) 302 if (!(pad->flags & MEDIA_PAD_FL_SINK))
@@ -263,6 +325,10 @@ static int isp_video_validate_pipeline(struct isp_pipeline *pipe)
263 return -ENOSPC; 325 return -ENOSPC;
264 } 326 }
265 327
328 /* If sink pad is on CCDC, the link has the lane shifter
329 * in the middle of it. */
330 shifter_link = subdev == &isp->isp_ccdc.subdev;
331
266 /* Retrieve the source format */ 332 /* Retrieve the source format */
267 pad = media_entity_remote_source(pad); 333 pad = media_entity_remote_source(pad);
268 if (pad == NULL || 334 if (pad == NULL ||
@@ -278,10 +344,24 @@ static int isp_video_validate_pipeline(struct isp_pipeline *pipe)
278 return -EPIPE; 344 return -EPIPE;
279 345
280 /* Check if the two ends match */ 346 /* Check if the two ends match */
281 if (fmt_source.format.code != fmt_sink.format.code || 347 if (fmt_source.format.width != fmt_sink.format.width ||
282 fmt_source.format.width != fmt_sink.format.width ||
283 fmt_source.format.height != fmt_sink.format.height) 348 fmt_source.format.height != fmt_sink.format.height)
284 return -EPIPE; 349 return -EPIPE;
350
351 if (shifter_link) {
352 unsigned int parallel_shift = 0;
353 if (isp->isp_ccdc.input == CCDC_INPUT_PARALLEL) {
354 struct isp_parallel_platform_data *pdata =
355 &((struct isp_v4l2_subdevs_group *)
356 subdev->host_priv)->bus.parallel;
357 parallel_shift = pdata->data_lane_shift * 2;
358 }
359 if (!isp_video_is_shiftable(fmt_source.format.code,
360 fmt_sink.format.code,
361 parallel_shift))
362 return -EPIPE;
363 } else if (fmt_source.format.code != fmt_sink.format.code)
364 return -EPIPE;
285 } 365 }
286 366
287 return 0; 367 return 0;
diff --git a/drivers/media/video/omap3isp/ispvideo.h b/drivers/media/video/omap3isp/ispvideo.h
index 524a1acd0906..911bea64e78a 100644
--- a/drivers/media/video/omap3isp/ispvideo.h
+++ b/drivers/media/video/omap3isp/ispvideo.h
@@ -49,6 +49,8 @@ struct v4l2_pix_format;
49 * bits. Identical to @code if the format is 10 bits wide or less. 49 * bits. Identical to @code if the format is 10 bits wide or less.
50 * @uncompressed: V4L2 media bus format code for the corresponding uncompressed 50 * @uncompressed: V4L2 media bus format code for the corresponding uncompressed
51 * format. Identical to @code if the format is not DPCM compressed. 51 * format. Identical to @code if the format is not DPCM compressed.
52 * @flavor: V4L2 media bus format code for the same pixel layout but
53 * shifted to be 8 bits per pixel. =0 if format is not shiftable.
52 * @pixelformat: V4L2 pixel format FCC identifier 54 * @pixelformat: V4L2 pixel format FCC identifier
53 * @bpp: Bits per pixel 55 * @bpp: Bits per pixel
54 */ 56 */
@@ -56,6 +58,7 @@ struct isp_format_info {
56 enum v4l2_mbus_pixelcode code; 58 enum v4l2_mbus_pixelcode code;
57 enum v4l2_mbus_pixelcode truncated; 59 enum v4l2_mbus_pixelcode truncated;
58 enum v4l2_mbus_pixelcode uncompressed; 60 enum v4l2_mbus_pixelcode uncompressed;
61 enum v4l2_mbus_pixelcode flavor;
59 u32 pixelformat; 62 u32 pixelformat;
60 unsigned int bpp; 63 unsigned int bpp;
61}; 64};
diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c
index 95f8b4e11e46..d142b40ea64e 100644
--- a/drivers/media/video/s5p-fimc/fimc-capture.c
+++ b/drivers/media/video/s5p-fimc/fimc-capture.c
@@ -527,7 +527,7 @@ static int fimc_cap_s_fmt_mplane(struct file *file, void *priv,
527 if (ret) 527 if (ret)
528 return ret; 528 return ret;
529 529
530 if (vb2_is_streaming(&fimc->vid_cap.vbq) || fimc_capture_active(fimc)) 530 if (vb2_is_busy(&fimc->vid_cap.vbq) || fimc_capture_active(fimc))
531 return -EBUSY; 531 return -EBUSY;
532 532
533 frame = &ctx->d_frame; 533 frame = &ctx->d_frame;
@@ -539,8 +539,10 @@ static int fimc_cap_s_fmt_mplane(struct file *file, void *priv,
539 return -EINVAL; 539 return -EINVAL;
540 } 540 }
541 541
542 for (i = 0; i < frame->fmt->colplanes; i++) 542 for (i = 0; i < frame->fmt->colplanes; i++) {
543 frame->payload[i] = pix->plane_fmt[i].bytesperline * pix->height; 543 frame->payload[i] =
544 (pix->width * pix->height * frame->fmt->depth[i]) >> 3;
545 }
544 546
545 /* Output DMA frame pixel size and offsets. */ 547 /* Output DMA frame pixel size and offsets. */
546 frame->f_width = pix->plane_fmt[0].bytesperline * 8 548 frame->f_width = pix->plane_fmt[0].bytesperline * 8
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c b/drivers/media/video/s5p-fimc/fimc-core.c
index 6c919b38a3d8..dc91a8511af6 100644
--- a/drivers/media/video/s5p-fimc/fimc-core.c
+++ b/drivers/media/video/s5p-fimc/fimc-core.c
@@ -361,10 +361,20 @@ static void fimc_capture_irq_handler(struct fimc_dev *fimc)
361{ 361{
362 struct fimc_vid_cap *cap = &fimc->vid_cap; 362 struct fimc_vid_cap *cap = &fimc->vid_cap;
363 struct fimc_vid_buffer *v_buf; 363 struct fimc_vid_buffer *v_buf;
364 struct timeval *tv;
365 struct timespec ts;
364 366
365 if (!list_empty(&cap->active_buf_q) && 367 if (!list_empty(&cap->active_buf_q) &&
366 test_bit(ST_CAPT_RUN, &fimc->state)) { 368 test_bit(ST_CAPT_RUN, &fimc->state)) {
369 ktime_get_real_ts(&ts);
370
367 v_buf = active_queue_pop(cap); 371 v_buf = active_queue_pop(cap);
372
373 tv = &v_buf->vb.v4l2_buf.timestamp;
374 tv->tv_sec = ts.tv_sec;
375 tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC;
376 v_buf->vb.v4l2_buf.sequence = cap->frame_count++;
377
368 vb2_buffer_done(&v_buf->vb, VB2_BUF_STATE_DONE); 378 vb2_buffer_done(&v_buf->vb, VB2_BUF_STATE_DONE);
369 } 379 }
370 380
@@ -758,7 +768,7 @@ static void fimc_unlock(struct vb2_queue *vq)
758 mutex_unlock(&ctx->fimc_dev->lock); 768 mutex_unlock(&ctx->fimc_dev->lock);
759} 769}
760 770
761struct vb2_ops fimc_qops = { 771static struct vb2_ops fimc_qops = {
762 .queue_setup = fimc_queue_setup, 772 .queue_setup = fimc_queue_setup,
763 .buf_prepare = fimc_buf_prepare, 773 .buf_prepare = fimc_buf_prepare,
764 .buf_queue = fimc_buf_queue, 774 .buf_queue = fimc_buf_queue,
@@ -927,23 +937,23 @@ int fimc_vidioc_try_fmt_mplane(struct file *file, void *priv,
927 pix->num_planes = fmt->memplanes; 937 pix->num_planes = fmt->memplanes;
928 pix->colorspace = V4L2_COLORSPACE_JPEG; 938 pix->colorspace = V4L2_COLORSPACE_JPEG;
929 939
930 for (i = 0; i < pix->num_planes; ++i) {
931 int bpl = pix->plane_fmt[i].bytesperline;
932 940
933 dbg("[%d] bpl: %d, depth: %d, w: %d, h: %d", 941 for (i = 0; i < pix->num_planes; ++i) {
934 i, bpl, fmt->depth[i], pix->width, pix->height); 942 u32 bpl = pix->plane_fmt[i].bytesperline;
943 u32 *sizeimage = &pix->plane_fmt[i].sizeimage;
935 944
936 if (!bpl || (bpl * 8 / fmt->depth[i]) > pix->width) 945 if (fmt->colplanes > 1 && (bpl == 0 || bpl < pix->width))
937 bpl = (pix->width * fmt->depth[0]) >> 3; 946 bpl = pix->width; /* Planar */
938 947
939 if (!pix->plane_fmt[i].sizeimage) 948 if (fmt->colplanes == 1 && /* Packed */
940 pix->plane_fmt[i].sizeimage = pix->height * bpl; 949 (bpl == 0 || ((bpl * 8) / fmt->depth[i]) < pix->width))
950 bpl = (pix->width * fmt->depth[0]) / 8;
941 951
942 pix->plane_fmt[i].bytesperline = bpl; 952 if (i == 0) /* Same bytesperline for each plane. */
953 mod_x = bpl;
943 954
944 dbg("[%d]: bpl: %d, sizeimage: %d", 955 pix->plane_fmt[i].bytesperline = mod_x;
945 i, pix->plane_fmt[i].bytesperline, 956 *sizeimage = (pix->width * pix->height * fmt->depth[i]) / 8;
946 pix->plane_fmt[i].sizeimage);
947 } 957 }
948 958
949 return 0; 959 return 0;
@@ -965,7 +975,7 @@ static int fimc_m2m_s_fmt_mplane(struct file *file, void *priv,
965 975
966 vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type); 976 vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
967 977
968 if (vb2_is_streaming(vq)) { 978 if (vb2_is_busy(vq)) {
969 v4l2_err(&fimc->m2m.v4l2_dev, "queue (%d) busy\n", f->type); 979 v4l2_err(&fimc->m2m.v4l2_dev, "queue (%d) busy\n", f->type);
970 return -EBUSY; 980 return -EBUSY;
971 } 981 }
@@ -985,8 +995,10 @@ static int fimc_m2m_s_fmt_mplane(struct file *file, void *priv,
985 if (!frame->fmt) 995 if (!frame->fmt)
986 return -EINVAL; 996 return -EINVAL;
987 997
988 for (i = 0; i < frame->fmt->colplanes; i++) 998 for (i = 0; i < frame->fmt->colplanes; i++) {
989 frame->payload[i] = pix->plane_fmt[i].bytesperline * pix->height; 999 frame->payload[i] =
1000 (pix->width * pix->height * frame->fmt->depth[i]) / 8;
1001 }
990 1002
991 frame->f_width = pix->plane_fmt[0].bytesperline * 8 / 1003 frame->f_width = pix->plane_fmt[0].bytesperline * 8 /
992 frame->fmt->depth[0]; 1004 frame->fmt->depth[0];
@@ -1750,7 +1762,7 @@ static int __devexit fimc_remove(struct platform_device *pdev)
1750} 1762}
1751 1763
1752/* Image pixel limits, similar across several FIMC HW revisions. */ 1764/* Image pixel limits, similar across several FIMC HW revisions. */
1753static struct fimc_pix_limit s5p_pix_limit[3] = { 1765static struct fimc_pix_limit s5p_pix_limit[4] = {
1754 [0] = { 1766 [0] = {
1755 .scaler_en_w = 3264, 1767 .scaler_en_w = 3264,
1756 .scaler_dis_w = 8192, 1768 .scaler_dis_w = 8192,
@@ -1775,6 +1787,14 @@ static struct fimc_pix_limit s5p_pix_limit[3] = {
1775 .out_rot_en_w = 1280, 1787 .out_rot_en_w = 1280,
1776 .out_rot_dis_w = 1920, 1788 .out_rot_dis_w = 1920,
1777 }, 1789 },
1790 [3] = {
1791 .scaler_en_w = 1920,
1792 .scaler_dis_w = 8192,
1793 .in_rot_en_h = 1366,
1794 .in_rot_dis_w = 8192,
1795 .out_rot_en_w = 1366,
1796 .out_rot_dis_w = 1920,
1797 },
1778}; 1798};
1779 1799
1780static struct samsung_fimc_variant fimc0_variant_s5p = { 1800static struct samsung_fimc_variant fimc0_variant_s5p = {
@@ -1827,7 +1847,7 @@ static struct samsung_fimc_variant fimc2_variant_s5pv210 = {
1827 .pix_limit = &s5p_pix_limit[2], 1847 .pix_limit = &s5p_pix_limit[2],
1828}; 1848};
1829 1849
1830static struct samsung_fimc_variant fimc0_variant_s5pv310 = { 1850static struct samsung_fimc_variant fimc0_variant_exynos4 = {
1831 .pix_hoff = 1, 1851 .pix_hoff = 1,
1832 .has_inp_rot = 1, 1852 .has_inp_rot = 1,
1833 .has_out_rot = 1, 1853 .has_out_rot = 1,
@@ -1840,7 +1860,7 @@ static struct samsung_fimc_variant fimc0_variant_s5pv310 = {
1840 .pix_limit = &s5p_pix_limit[1], 1860 .pix_limit = &s5p_pix_limit[1],
1841}; 1861};
1842 1862
1843static struct samsung_fimc_variant fimc2_variant_s5pv310 = { 1863static struct samsung_fimc_variant fimc2_variant_exynos4 = {
1844 .pix_hoff = 1, 1864 .pix_hoff = 1,
1845 .has_cistatus2 = 1, 1865 .has_cistatus2 = 1,
1846 .has_mainscaler_ext = 1, 1866 .has_mainscaler_ext = 1,
@@ -1848,7 +1868,7 @@ static struct samsung_fimc_variant fimc2_variant_s5pv310 = {
1848 .min_out_pixsize = 16, 1868 .min_out_pixsize = 16,
1849 .hor_offs_align = 1, 1869 .hor_offs_align = 1,
1850 .out_buf_count = 32, 1870 .out_buf_count = 32,
1851 .pix_limit = &s5p_pix_limit[2], 1871 .pix_limit = &s5p_pix_limit[3],
1852}; 1872};
1853 1873
1854/* S5PC100 */ 1874/* S5PC100 */
@@ -1874,12 +1894,12 @@ static struct samsung_fimc_driverdata fimc_drvdata_s5pv210 = {
1874}; 1894};
1875 1895
1876/* S5PV310, S5PC210 */ 1896/* S5PV310, S5PC210 */
1877static struct samsung_fimc_driverdata fimc_drvdata_s5pv310 = { 1897static struct samsung_fimc_driverdata fimc_drvdata_exynos4 = {
1878 .variant = { 1898 .variant = {
1879 [0] = &fimc0_variant_s5pv310, 1899 [0] = &fimc0_variant_exynos4,
1880 [1] = &fimc0_variant_s5pv310, 1900 [1] = &fimc0_variant_exynos4,
1881 [2] = &fimc0_variant_s5pv310, 1901 [2] = &fimc0_variant_exynos4,
1882 [3] = &fimc2_variant_s5pv310, 1902 [3] = &fimc2_variant_exynos4,
1883 }, 1903 },
1884 .num_entities = 4, 1904 .num_entities = 4,
1885 .lclk_frequency = 166000000UL, 1905 .lclk_frequency = 166000000UL,
@@ -1893,8 +1913,8 @@ static struct platform_device_id fimc_driver_ids[] = {
1893 .name = "s5pv210-fimc", 1913 .name = "s5pv210-fimc",
1894 .driver_data = (unsigned long)&fimc_drvdata_s5pv210, 1914 .driver_data = (unsigned long)&fimc_drvdata_s5pv210,
1895 }, { 1915 }, {
1896 .name = "s5pv310-fimc", 1916 .name = "exynos4-fimc",
1897 .driver_data = (unsigned long)&fimc_drvdata_s5pv310, 1917 .driver_data = (unsigned long)&fimc_drvdata_exynos4,
1898 }, 1918 },
1899 {}, 1919 {},
1900}; 1920};
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c
index 3fe54bf41142..134e86bf6d97 100644
--- a/drivers/media/video/sh_mobile_ceu_camera.c
+++ b/drivers/media/video/sh_mobile_ceu_camera.c
@@ -922,7 +922,7 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, unsigned int
922 /* Try 2560x1920, 1280x960, 640x480, 320x240 */ 922 /* Try 2560x1920, 1280x960, 640x480, 320x240 */
923 mf.width = 2560 >> shift; 923 mf.width = 2560 >> shift;
924 mf.height = 1920 >> shift; 924 mf.height = 1920 >> shift;
925 ret = v4l2_device_call_until_err(sd->v4l2_dev, 0, video, 925 ret = v4l2_device_call_until_err(sd->v4l2_dev, (long)icd, video,
926 s_mbus_fmt, &mf); 926 s_mbus_fmt, &mf);
927 if (ret < 0) 927 if (ret < 0)
928 return ret; 928 return ret;
@@ -1224,7 +1224,7 @@ static int client_s_fmt(struct soc_camera_device *icd,
1224 struct v4l2_cropcap cap; 1224 struct v4l2_cropcap cap;
1225 int ret; 1225 int ret;
1226 1226
1227 ret = v4l2_device_call_until_err(sd->v4l2_dev, 0, video, 1227 ret = v4l2_device_call_until_err(sd->v4l2_dev, (long)icd, video,
1228 s_mbus_fmt, mf); 1228 s_mbus_fmt, mf);
1229 if (ret < 0) 1229 if (ret < 0)
1230 return ret; 1230 return ret;
@@ -1254,7 +1254,7 @@ static int client_s_fmt(struct soc_camera_device *icd,
1254 tmp_h = min(2 * tmp_h, max_height); 1254 tmp_h = min(2 * tmp_h, max_height);
1255 mf->width = tmp_w; 1255 mf->width = tmp_w;
1256 mf->height = tmp_h; 1256 mf->height = tmp_h;
1257 ret = v4l2_device_call_until_err(sd->v4l2_dev, 0, video, 1257 ret = v4l2_device_call_until_err(sd->v4l2_dev, (long)icd, video,
1258 s_mbus_fmt, mf); 1258 s_mbus_fmt, mf);
1259 dev_geo(dev, "Camera scaled to %ux%u\n", 1259 dev_geo(dev, "Camera scaled to %ux%u\n",
1260 mf->width, mf->height); 1260 mf->width, mf->height);
@@ -1658,7 +1658,7 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd,
1658 mf.code = xlate->code; 1658 mf.code = xlate->code;
1659 mf.colorspace = pix->colorspace; 1659 mf.colorspace = pix->colorspace;
1660 1660
1661 ret = v4l2_device_call_until_err(sd->v4l2_dev, 0, video, try_mbus_fmt, &mf); 1661 ret = v4l2_device_call_until_err(sd->v4l2_dev, (long)icd, video, try_mbus_fmt, &mf);
1662 if (ret < 0) 1662 if (ret < 0)
1663 return ret; 1663 return ret;
1664 1664
@@ -1682,7 +1682,7 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd,
1682 */ 1682 */
1683 mf.width = 2560; 1683 mf.width = 2560;
1684 mf.height = 1920; 1684 mf.height = 1920;
1685 ret = v4l2_device_call_until_err(sd->v4l2_dev, 0, video, 1685 ret = v4l2_device_call_until_err(sd->v4l2_dev, (long)icd, video,
1686 try_mbus_fmt, &mf); 1686 try_mbus_fmt, &mf);
1687 if (ret < 0) { 1687 if (ret < 0) {
1688 /* Shouldn't actually happen... */ 1688 /* Shouldn't actually happen... */
diff --git a/drivers/media/video/sh_mobile_csi2.c b/drivers/media/video/sh_mobile_csi2.c
index dd1b81b1442b..98b87481fa94 100644
--- a/drivers/media/video/sh_mobile_csi2.c
+++ b/drivers/media/video/sh_mobile_csi2.c
@@ -38,6 +38,8 @@ struct sh_csi2 {
38 void __iomem *base; 38 void __iomem *base;
39 struct platform_device *pdev; 39 struct platform_device *pdev;
40 struct sh_csi2_client_config *client; 40 struct sh_csi2_client_config *client;
41 unsigned long (*query_bus_param)(struct soc_camera_device *);
42 int (*set_bus_param)(struct soc_camera_device *, unsigned long);
41}; 43};
42 44
43static int sh_csi2_try_fmt(struct v4l2_subdev *sd, 45static int sh_csi2_try_fmt(struct v4l2_subdev *sd,
@@ -208,6 +210,7 @@ static int sh_csi2_notify(struct notifier_block *nb,
208 case BUS_NOTIFY_BOUND_DRIVER: 210 case BUS_NOTIFY_BOUND_DRIVER:
209 snprintf(priv->subdev.name, V4L2_SUBDEV_NAME_SIZE, "%s%s", 211 snprintf(priv->subdev.name, V4L2_SUBDEV_NAME_SIZE, "%s%s",
210 dev_name(v4l2_dev->dev), ".mipi-csi"); 212 dev_name(v4l2_dev->dev), ".mipi-csi");
213 priv->subdev.grp_id = (long)icd;
211 ret = v4l2_device_register_subdev(v4l2_dev, &priv->subdev); 214 ret = v4l2_device_register_subdev(v4l2_dev, &priv->subdev);
212 dev_dbg(dev, "%s(%p): ret(register_subdev) = %d\n", __func__, priv, ret); 215 dev_dbg(dev, "%s(%p): ret(register_subdev) = %d\n", __func__, priv, ret);
213 if (ret < 0) 216 if (ret < 0)
@@ -215,6 +218,8 @@ static int sh_csi2_notify(struct notifier_block *nb,
215 218
216 priv->client = pdata->clients + i; 219 priv->client = pdata->clients + i;
217 220
221 priv->set_bus_param = icd->ops->set_bus_param;
222 priv->query_bus_param = icd->ops->query_bus_param;
218 icd->ops->set_bus_param = sh_csi2_set_bus_param; 223 icd->ops->set_bus_param = sh_csi2_set_bus_param;
219 icd->ops->query_bus_param = sh_csi2_query_bus_param; 224 icd->ops->query_bus_param = sh_csi2_query_bus_param;
220 225
@@ -226,8 +231,10 @@ static int sh_csi2_notify(struct notifier_block *nb,
226 priv->client = NULL; 231 priv->client = NULL;
227 232
228 /* Driver is about to be unbound */ 233 /* Driver is about to be unbound */
229 icd->ops->set_bus_param = NULL; 234 icd->ops->set_bus_param = priv->set_bus_param;
230 icd->ops->query_bus_param = NULL; 235 icd->ops->query_bus_param = priv->query_bus_param;
236 priv->set_bus_param = NULL;
237 priv->query_bus_param = NULL;
231 238
232 v4l2_device_unregister_subdev(&priv->subdev); 239 v4l2_device_unregister_subdev(&priv->subdev);
233 240
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index 46284489e4eb..ddb4c091dedc 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -136,11 +136,50 @@ unsigned long soc_camera_apply_sensor_flags(struct soc_camera_link *icl,
136} 136}
137EXPORT_SYMBOL(soc_camera_apply_sensor_flags); 137EXPORT_SYMBOL(soc_camera_apply_sensor_flags);
138 138
139#define pixfmtstr(x) (x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, \
140 ((x) >> 24) & 0xff
141
142static int soc_camera_try_fmt(struct soc_camera_device *icd,
143 struct v4l2_format *f)
144{
145 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
146 struct v4l2_pix_format *pix = &f->fmt.pix;
147 int ret;
148
149 dev_dbg(&icd->dev, "TRY_FMT(%c%c%c%c, %ux%u)\n",
150 pixfmtstr(pix->pixelformat), pix->width, pix->height);
151
152 pix->bytesperline = 0;
153 pix->sizeimage = 0;
154
155 ret = ici->ops->try_fmt(icd, f);
156 if (ret < 0)
157 return ret;
158
159 if (!pix->sizeimage) {
160 if (!pix->bytesperline) {
161 const struct soc_camera_format_xlate *xlate;
162
163 xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
164 if (!xlate)
165 return -EINVAL;
166
167 ret = soc_mbus_bytes_per_line(pix->width,
168 xlate->host_fmt);
169 if (ret > 0)
170 pix->bytesperline = ret;
171 }
172 if (pix->bytesperline)
173 pix->sizeimage = pix->bytesperline * pix->height;
174 }
175
176 return 0;
177}
178
139static int soc_camera_try_fmt_vid_cap(struct file *file, void *priv, 179static int soc_camera_try_fmt_vid_cap(struct file *file, void *priv,
140 struct v4l2_format *f) 180 struct v4l2_format *f)
141{ 181{
142 struct soc_camera_device *icd = file->private_data; 182 struct soc_camera_device *icd = file->private_data;
143 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
144 183
145 WARN_ON(priv != file->private_data); 184 WARN_ON(priv != file->private_data);
146 185
@@ -149,7 +188,7 @@ static int soc_camera_try_fmt_vid_cap(struct file *file, void *priv,
149 return -EINVAL; 188 return -EINVAL;
150 189
151 /* limit format to hardware capabilities */ 190 /* limit format to hardware capabilities */
152 return ici->ops->try_fmt(icd, f); 191 return soc_camera_try_fmt(icd, f);
153} 192}
154 193
155static int soc_camera_enum_input(struct file *file, void *priv, 194static int soc_camera_enum_input(struct file *file, void *priv,
@@ -362,9 +401,6 @@ static void soc_camera_free_user_formats(struct soc_camera_device *icd)
362 icd->user_formats = NULL; 401 icd->user_formats = NULL;
363} 402}
364 403
365#define pixfmtstr(x) (x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, \
366 ((x) >> 24) & 0xff
367
368/* Called with .vb_lock held, or from the first open(2), see comment there */ 404/* Called with .vb_lock held, or from the first open(2), see comment there */
369static int soc_camera_set_fmt(struct soc_camera_device *icd, 405static int soc_camera_set_fmt(struct soc_camera_device *icd,
370 struct v4l2_format *f) 406 struct v4l2_format *f)
@@ -377,7 +413,7 @@ static int soc_camera_set_fmt(struct soc_camera_device *icd,
377 pixfmtstr(pix->pixelformat), pix->width, pix->height); 413 pixfmtstr(pix->pixelformat), pix->width, pix->height);
378 414
379 /* We always call try_fmt() before set_fmt() or set_crop() */ 415 /* We always call try_fmt() before set_fmt() or set_crop() */
380 ret = ici->ops->try_fmt(icd, f); 416 ret = soc_camera_try_fmt(icd, f);
381 if (ret < 0) 417 if (ret < 0)
382 return ret; 418 return ret;
383 419
@@ -996,10 +1032,11 @@ static void soc_camera_free_i2c(struct soc_camera_device *icd)
996{ 1032{
997 struct i2c_client *client = 1033 struct i2c_client *client =
998 to_i2c_client(to_soc_camera_control(icd)); 1034 to_i2c_client(to_soc_camera_control(icd));
1035 struct i2c_adapter *adap = client->adapter;
999 dev_set_drvdata(&icd->dev, NULL); 1036 dev_set_drvdata(&icd->dev, NULL);
1000 v4l2_device_unregister_subdev(i2c_get_clientdata(client)); 1037 v4l2_device_unregister_subdev(i2c_get_clientdata(client));
1001 i2c_unregister_device(client); 1038 i2c_unregister_device(client);
1002 i2c_put_adapter(client->adapter); 1039 i2c_put_adapter(adap);
1003} 1040}
1004#else 1041#else
1005#define soc_camera_init_i2c(icd, icl) (-ENODEV) 1042#define soc_camera_init_i2c(icd, icl) (-ENODEV)
@@ -1071,6 +1108,9 @@ static int soc_camera_probe(struct device *dev)
1071 } 1108 }
1072 } 1109 }
1073 1110
1111 sd = soc_camera_to_subdev(icd);
1112 sd->grp_id = (long)icd;
1113
1074 /* At this point client .probe() should have run already */ 1114 /* At this point client .probe() should have run already */
1075 ret = soc_camera_init_user_formats(icd); 1115 ret = soc_camera_init_user_formats(icd);
1076 if (ret < 0) 1116 if (ret < 0)
@@ -1092,7 +1132,6 @@ static int soc_camera_probe(struct device *dev)
1092 goto evidstart; 1132 goto evidstart;
1093 1133
1094 /* Try to improve our guess of a reasonable window format */ 1134 /* Try to improve our guess of a reasonable window format */
1095 sd = soc_camera_to_subdev(icd);
1096 if (!v4l2_subdev_call(sd, video, g_mbus_fmt, &mf)) { 1135 if (!v4l2_subdev_call(sd, video, g_mbus_fmt, &mf)) {
1097 icd->user_width = mf.width; 1136 icd->user_width = mf.width;
1098 icd->user_height = mf.height; 1137 icd->user_height = mf.height;
diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c
index 5d4cf3b3d435..22fa8202d5ca 100644
--- a/drivers/media/video/tda9840.c
+++ b/drivers/media/video/tda9840.c
@@ -171,7 +171,7 @@ static int tda9840_probe(struct i2c_client *client,
171 v4l_info(client, "chip found @ 0x%x (%s)\n", 171 v4l_info(client, "chip found @ 0x%x (%s)\n",
172 client->addr << 1, client->adapter->name); 172 client->addr << 1, client->adapter->name);
173 173
174 sd = kmalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); 174 sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
175 if (sd == NULL) 175 if (sd == NULL)
176 return -ENOMEM; 176 return -ENOMEM;
177 v4l2_i2c_subdev_init(sd, client, &tda9840_ops); 177 v4l2_i2c_subdev_init(sd, client, &tda9840_ops);
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c
index 19621ed523ec..827425c5b866 100644
--- a/drivers/media/video/tea6415c.c
+++ b/drivers/media/video/tea6415c.c
@@ -152,7 +152,7 @@ static int tea6415c_probe(struct i2c_client *client,
152 152
153 v4l_info(client, "chip found @ 0x%x (%s)\n", 153 v4l_info(client, "chip found @ 0x%x (%s)\n",
154 client->addr << 1, client->adapter->name); 154 client->addr << 1, client->adapter->name);
155 sd = kmalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); 155 sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
156 if (sd == NULL) 156 if (sd == NULL)
157 return -ENOMEM; 157 return -ENOMEM;
158 v4l2_i2c_subdev_init(sd, client, &tea6415c_ops); 158 v4l2_i2c_subdev_init(sd, client, &tea6415c_ops);
diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c
index 5ea840401f21..f350b6c24500 100644
--- a/drivers/media/video/tea6420.c
+++ b/drivers/media/video/tea6420.c
@@ -125,7 +125,7 @@ static int tea6420_probe(struct i2c_client *client,
125 v4l_info(client, "chip found @ 0x%x (%s)\n", 125 v4l_info(client, "chip found @ 0x%x (%s)\n",
126 client->addr << 1, client->adapter->name); 126 client->addr << 1, client->adapter->name);
127 127
128 sd = kmalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); 128 sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
129 if (sd == NULL) 129 if (sd == NULL)
130 return -ENOMEM; 130 return -ENOMEM;
131 v4l2_i2c_subdev_init(sd, client, &tea6420_ops); 131 v4l2_i2c_subdev_init(sd, client, &tea6420_ops);
diff --git a/drivers/media/video/upd64031a.c b/drivers/media/video/upd64031a.c
index f8138c75be8b..1aab96a88203 100644
--- a/drivers/media/video/upd64031a.c
+++ b/drivers/media/video/upd64031a.c
@@ -230,7 +230,7 @@ static int upd64031a_probe(struct i2c_client *client,
230 v4l_info(client, "chip found @ 0x%x (%s)\n", 230 v4l_info(client, "chip found @ 0x%x (%s)\n",
231 client->addr << 1, client->adapter->name); 231 client->addr << 1, client->adapter->name);
232 232
233 state = kmalloc(sizeof(struct upd64031a_state), GFP_KERNEL); 233 state = kzalloc(sizeof(struct upd64031a_state), GFP_KERNEL);
234 if (state == NULL) 234 if (state == NULL)
235 return -ENOMEM; 235 return -ENOMEM;
236 sd = &state->sd; 236 sd = &state->sd;
diff --git a/drivers/media/video/upd64083.c b/drivers/media/video/upd64083.c
index 28e0e6b6ca84..9bbe61700fd5 100644
--- a/drivers/media/video/upd64083.c
+++ b/drivers/media/video/upd64083.c
@@ -202,7 +202,7 @@ static int upd64083_probe(struct i2c_client *client,
202 v4l_info(client, "chip found @ 0x%x (%s)\n", 202 v4l_info(client, "chip found @ 0x%x (%s)\n",
203 client->addr << 1, client->adapter->name); 203 client->addr << 1, client->adapter->name);
204 204
205 state = kmalloc(sizeof(struct upd64083_state), GFP_KERNEL); 205 state = kzalloc(sizeof(struct upd64083_state), GFP_KERNEL);
206 if (state == NULL) 206 if (state == NULL)
207 return -ENOMEM; 207 return -ENOMEM;
208 sd = &state->sd; 208 sd = &state->sd;
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index 498e6742579e..6dc7196296b3 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -389,7 +389,8 @@ static int v4l2_open(struct inode *inode, struct file *filp)
389 video_get(vdev); 389 video_get(vdev);
390 mutex_unlock(&videodev_lock); 390 mutex_unlock(&videodev_lock);
391#if defined(CONFIG_MEDIA_CONTROLLER) 391#if defined(CONFIG_MEDIA_CONTROLLER)
392 if (vdev->v4l2_dev && vdev->v4l2_dev->mdev) { 392 if (vdev->v4l2_dev && vdev->v4l2_dev->mdev &&
393 vdev->vfl_type != VFL_TYPE_SUBDEV) {
393 entity = media_entity_get(&vdev->entity); 394 entity = media_entity_get(&vdev->entity);
394 if (!entity) { 395 if (!entity) {
395 ret = -EBUSY; 396 ret = -EBUSY;
@@ -415,7 +416,8 @@ err:
415 /* decrease the refcount in case of an error */ 416 /* decrease the refcount in case of an error */
416 if (ret) { 417 if (ret) {
417#if defined(CONFIG_MEDIA_CONTROLLER) 418#if defined(CONFIG_MEDIA_CONTROLLER)
418 if (vdev->v4l2_dev && vdev->v4l2_dev->mdev) 419 if (vdev->v4l2_dev && vdev->v4l2_dev->mdev &&
420 vdev->vfl_type != VFL_TYPE_SUBDEV)
419 media_entity_put(entity); 421 media_entity_put(entity);
420#endif 422#endif
421 video_put(vdev); 423 video_put(vdev);
@@ -437,7 +439,8 @@ static int v4l2_release(struct inode *inode, struct file *filp)
437 mutex_unlock(vdev->lock); 439 mutex_unlock(vdev->lock);
438 } 440 }
439#if defined(CONFIG_MEDIA_CONTROLLER) 441#if defined(CONFIG_MEDIA_CONTROLLER)
440 if (vdev->v4l2_dev && vdev->v4l2_dev->mdev) 442 if (vdev->v4l2_dev && vdev->v4l2_dev->mdev &&
443 vdev->vfl_type != VFL_TYPE_SUBDEV)
441 media_entity_put(&vdev->entity); 444 media_entity_put(&vdev->entity);
442#endif 445#endif
443 /* decrease the refcount unconditionally since the release() 446 /* decrease the refcount unconditionally since the release()
@@ -686,7 +689,8 @@ int __video_register_device(struct video_device *vdev, int type, int nr,
686 689
687#if defined(CONFIG_MEDIA_CONTROLLER) 690#if defined(CONFIG_MEDIA_CONTROLLER)
688 /* Part 5: Register the entity. */ 691 /* Part 5: Register the entity. */
689 if (vdev->v4l2_dev && vdev->v4l2_dev->mdev) { 692 if (vdev->v4l2_dev && vdev->v4l2_dev->mdev &&
693 vdev->vfl_type != VFL_TYPE_SUBDEV) {
690 vdev->entity.type = MEDIA_ENT_T_DEVNODE_V4L; 694 vdev->entity.type = MEDIA_ENT_T_DEVNODE_V4L;
691 vdev->entity.name = vdev->name; 695 vdev->entity.name = vdev->name;
692 vdev->entity.v4l.major = VIDEO_MAJOR; 696 vdev->entity.v4l.major = VIDEO_MAJOR;
@@ -733,7 +737,8 @@ void video_unregister_device(struct video_device *vdev)
733 return; 737 return;
734 738
735#if defined(CONFIG_MEDIA_CONTROLLER) 739#if defined(CONFIG_MEDIA_CONTROLLER)
736 if (vdev->v4l2_dev && vdev->v4l2_dev->mdev) 740 if (vdev->v4l2_dev && vdev->v4l2_dev->mdev &&
741 vdev->vfl_type != VFL_TYPE_SUBDEV)
737 media_device_unregister_entity(&vdev->entity); 742 media_device_unregister_entity(&vdev->entity);
738#endif 743#endif
739 744
diff --git a/drivers/media/video/v4l2-device.c b/drivers/media/video/v4l2-device.c
index 5aeaf876ba9b..4aae501f02d0 100644
--- a/drivers/media/video/v4l2-device.c
+++ b/drivers/media/video/v4l2-device.c
@@ -155,8 +155,10 @@ int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
155 sd->v4l2_dev = v4l2_dev; 155 sd->v4l2_dev = v4l2_dev;
156 if (sd->internal_ops && sd->internal_ops->registered) { 156 if (sd->internal_ops && sd->internal_ops->registered) {
157 err = sd->internal_ops->registered(sd); 157 err = sd->internal_ops->registered(sd);
158 if (err) 158 if (err) {
159 module_put(sd->owner);
159 return err; 160 return err;
161 }
160 } 162 }
161 163
162 /* This just returns 0 if either of the two args is NULL */ 164 /* This just returns 0 if either of the two args is NULL */
@@ -164,6 +166,7 @@ int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
164 if (err) { 166 if (err) {
165 if (sd->internal_ops && sd->internal_ops->unregistered) 167 if (sd->internal_ops && sd->internal_ops->unregistered)
166 sd->internal_ops->unregistered(sd); 168 sd->internal_ops->unregistered(sd);
169 module_put(sd->owner);
167 return err; 170 return err;
168 } 171 }
169 172
diff --git a/drivers/media/video/v4l2-subdev.c b/drivers/media/video/v4l2-subdev.c
index 0b8064490676..812729ebf09e 100644
--- a/drivers/media/video/v4l2-subdev.c
+++ b/drivers/media/video/v4l2-subdev.c
@@ -155,25 +155,25 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
155 155
156 switch (cmd) { 156 switch (cmd) {
157 case VIDIOC_QUERYCTRL: 157 case VIDIOC_QUERYCTRL:
158 return v4l2_subdev_queryctrl(sd, arg); 158 return v4l2_queryctrl(sd->ctrl_handler, arg);
159 159
160 case VIDIOC_QUERYMENU: 160 case VIDIOC_QUERYMENU:
161 return v4l2_subdev_querymenu(sd, arg); 161 return v4l2_querymenu(sd->ctrl_handler, arg);
162 162
163 case VIDIOC_G_CTRL: 163 case VIDIOC_G_CTRL:
164 return v4l2_subdev_g_ctrl(sd, arg); 164 return v4l2_g_ctrl(sd->ctrl_handler, arg);
165 165
166 case VIDIOC_S_CTRL: 166 case VIDIOC_S_CTRL:
167 return v4l2_subdev_s_ctrl(sd, arg); 167 return v4l2_s_ctrl(sd->ctrl_handler, arg);
168 168
169 case VIDIOC_G_EXT_CTRLS: 169 case VIDIOC_G_EXT_CTRLS:
170 return v4l2_subdev_g_ext_ctrls(sd, arg); 170 return v4l2_g_ext_ctrls(sd->ctrl_handler, arg);
171 171
172 case VIDIOC_S_EXT_CTRLS: 172 case VIDIOC_S_EXT_CTRLS:
173 return v4l2_subdev_s_ext_ctrls(sd, arg); 173 return v4l2_s_ext_ctrls(sd->ctrl_handler, arg);
174 174
175 case VIDIOC_TRY_EXT_CTRLS: 175 case VIDIOC_TRY_EXT_CTRLS:
176 return v4l2_subdev_try_ext_ctrls(sd, arg); 176 return v4l2_try_ext_ctrls(sd->ctrl_handler, arg);
177 177
178 case VIDIOC_DQEVENT: 178 case VIDIOC_DQEVENT:
179 if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS)) 179 if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS))
diff --git a/drivers/media/video/videobuf-dma-contig.c b/drivers/media/video/videobuf-dma-contig.c
index c4742fc15529..c9691115f2d2 100644
--- a/drivers/media/video/videobuf-dma-contig.c
+++ b/drivers/media/video/videobuf-dma-contig.c
@@ -300,7 +300,7 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q,
300 300
301 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 301 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
302 retval = remap_pfn_range(vma, vma->vm_start, 302 retval = remap_pfn_range(vma, vma->vm_start,
303 PFN_DOWN(virt_to_phys(mem->vaddr)), 303 mem->dma_handle >> PAGE_SHIFT,
304 size, vma->vm_page_prot); 304 size, vma->vm_page_prot);
305 if (retval) { 305 if (retval) {
306 dev_err(q->dev, "mmap: remap failed with error %d. ", retval); 306 dev_err(q->dev, "mmap: remap failed with error %d. ", retval);
diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c
index 6698c77e0f64..6ba1461d51ef 100644
--- a/drivers/media/video/videobuf2-core.c
+++ b/drivers/media/video/videobuf2-core.c
@@ -37,6 +37,9 @@ module_param(debug, int, 0644);
37#define call_qop(q, op, args...) \ 37#define call_qop(q, op, args...) \
38 (((q)->ops->op) ? ((q)->ops->op(args)) : 0) 38 (((q)->ops->op) ? ((q)->ops->op(args)) : 0)
39 39
40#define V4L2_BUFFER_STATE_FLAGS (V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_QUEUED | \
41 V4L2_BUF_FLAG_DONE | V4L2_BUF_FLAG_ERROR)
42
40/** 43/**
41 * __vb2_buf_mem_alloc() - allocate video memory for the given buffer 44 * __vb2_buf_mem_alloc() - allocate video memory for the given buffer
42 */ 45 */
@@ -51,7 +54,7 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb,
51 for (plane = 0; plane < vb->num_planes; ++plane) { 54 for (plane = 0; plane < vb->num_planes; ++plane) {
52 mem_priv = call_memop(q, plane, alloc, q->alloc_ctx[plane], 55 mem_priv = call_memop(q, plane, alloc, q->alloc_ctx[plane],
53 plane_sizes[plane]); 56 plane_sizes[plane]);
54 if (!mem_priv) 57 if (IS_ERR_OR_NULL(mem_priv))
55 goto free; 58 goto free;
56 59
57 /* Associate allocator private data with this plane */ 60 /* Associate allocator private data with this plane */
@@ -284,7 +287,7 @@ static int __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
284 struct vb2_queue *q = vb->vb2_queue; 287 struct vb2_queue *q = vb->vb2_queue;
285 int ret = 0; 288 int ret = 0;
286 289
287 /* Copy back data such as timestamp, input, etc. */ 290 /* Copy back data such as timestamp, flags, input, etc. */
288 memcpy(b, &vb->v4l2_buf, offsetof(struct v4l2_buffer, m)); 291 memcpy(b, &vb->v4l2_buf, offsetof(struct v4l2_buffer, m));
289 b->input = vb->v4l2_buf.input; 292 b->input = vb->v4l2_buf.input;
290 b->reserved = vb->v4l2_buf.reserved; 293 b->reserved = vb->v4l2_buf.reserved;
@@ -313,7 +316,10 @@ static int __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
313 b->m.userptr = vb->v4l2_planes[0].m.userptr; 316 b->m.userptr = vb->v4l2_planes[0].m.userptr;
314 } 317 }
315 318
316 b->flags = 0; 319 /*
320 * Clear any buffer state related flags.
321 */
322 b->flags &= ~V4L2_BUFFER_STATE_FLAGS;
317 323
318 switch (vb->state) { 324 switch (vb->state) {
319 case VB2_BUF_STATE_QUEUED: 325 case VB2_BUF_STATE_QUEUED:
@@ -519,6 +525,7 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
519 num_buffers = min_t(unsigned int, req->count, VIDEO_MAX_FRAME); 525 num_buffers = min_t(unsigned int, req->count, VIDEO_MAX_FRAME);
520 memset(plane_sizes, 0, sizeof(plane_sizes)); 526 memset(plane_sizes, 0, sizeof(plane_sizes));
521 memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx)); 527 memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx));
528 q->memory = req->memory;
522 529
523 /* 530 /*
524 * Ask the driver how many buffers and planes per buffer it requires. 531 * Ask the driver how many buffers and planes per buffer it requires.
@@ -560,8 +567,6 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
560 ret = num_buffers; 567 ret = num_buffers;
561 } 568 }
562 569
563 q->memory = req->memory;
564
565 /* 570 /*
566 * Return the number of successfully allocated buffers 571 * Return the number of successfully allocated buffers
567 * to the userspace. 572 * to the userspace.
@@ -715,6 +720,8 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b,
715 720
716 vb->v4l2_buf.field = b->field; 721 vb->v4l2_buf.field = b->field;
717 vb->v4l2_buf.timestamp = b->timestamp; 722 vb->v4l2_buf.timestamp = b->timestamp;
723 vb->v4l2_buf.input = b->input;
724 vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_STATE_FLAGS;
718 725
719 return 0; 726 return 0;
720} 727}
diff --git a/drivers/media/video/videobuf2-dma-contig.c b/drivers/media/video/videobuf2-dma-contig.c
index 58205d596138..a790a5f8c06f 100644
--- a/drivers/media/video/videobuf2-dma-contig.c
+++ b/drivers/media/video/videobuf2-dma-contig.c
@@ -46,7 +46,7 @@ static void *vb2_dma_contig_alloc(void *alloc_ctx, unsigned long size)
46 GFP_KERNEL); 46 GFP_KERNEL);
47 if (!buf->vaddr) { 47 if (!buf->vaddr) {
48 dev_err(conf->dev, "dma_alloc_coherent of size %ld failed\n", 48 dev_err(conf->dev, "dma_alloc_coherent of size %ld failed\n",
49 buf->size); 49 size);
50 kfree(buf); 50 kfree(buf);
51 return ERR_PTR(-ENOMEM); 51 return ERR_PTR(-ENOMEM);
52 } 52 }
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
index 643ad52e3ca2..4796bbf0ae4e 100644
--- a/drivers/message/i2o/i2o_block.c
+++ b/drivers/message/i2o/i2o_block.c
@@ -1000,7 +1000,6 @@ static struct i2o_block_device *i2o_block_device_alloc(void)
1000 gd->major = I2O_MAJOR; 1000 gd->major = I2O_MAJOR;
1001 gd->queue = queue; 1001 gd->queue = queue;
1002 gd->fops = &i2o_block_fops; 1002 gd->fops = &i2o_block_fops;
1003 gd->events = DISK_EVENT_MEDIA_CHANGE;
1004 gd->private_data = dev; 1003 gd->private_data = dev;
1005 1004
1006 dev->gd = gd; 1005 dev->gd = gd;
diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c
index d4a851c6b5bf..0b4d5b23bec9 100644
--- a/drivers/mfd/asic3.c
+++ b/drivers/mfd/asic3.c
@@ -144,7 +144,7 @@ static void asic3_irq_demux(unsigned int irq, struct irq_desc *desc)
144 int iter, i; 144 int iter, i;
145 unsigned long flags; 145 unsigned long flags;
146 146
147 data->chip->irq_ack(irq_data); 147 data->chip->irq_ack(data);
148 148
149 for (iter = 0 ; iter < MAX_ASIC_ISR_LOOPS; iter++) { 149 for (iter = 0 ; iter < MAX_ASIC_ISR_LOOPS; iter++) {
150 u32 status; 150 u32 status;
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index 53450f433f10..3ab9ffa00aad 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -25,7 +25,6 @@
25#include <linux/dma-mapping.h> 25#include <linux/dma-mapping.h>
26#include <linux/spinlock.h> 26#include <linux/spinlock.h>
27#include <linux/gpio.h> 27#include <linux/gpio.h>
28#include <linux/regulator/consumer.h>
29#include <plat/usb.h> 28#include <plat/usb.h>
30 29
31#define USBHS_DRIVER_NAME "usbhs-omap" 30#define USBHS_DRIVER_NAME "usbhs-omap"
@@ -700,8 +699,7 @@ static int usbhs_enable(struct device *dev)
700 dev_dbg(dev, "starting TI HSUSB Controller\n"); 699 dev_dbg(dev, "starting TI HSUSB Controller\n");
701 if (!pdata) { 700 if (!pdata) {
702 dev_dbg(dev, "missing platform_data\n"); 701 dev_dbg(dev, "missing platform_data\n");
703 ret = -ENODEV; 702 return -ENODEV;
704 goto end_enable;
705 } 703 }
706 704
707 spin_lock_irqsave(&omap->lock, flags); 705 spin_lock_irqsave(&omap->lock, flags);
@@ -719,14 +717,14 @@ static int usbhs_enable(struct device *dev)
719 gpio_request(pdata->ehci_data->reset_gpio_port[0], 717 gpio_request(pdata->ehci_data->reset_gpio_port[0],
720 "USB1 PHY reset"); 718 "USB1 PHY reset");
721 gpio_direction_output 719 gpio_direction_output
722 (pdata->ehci_data->reset_gpio_port[0], 1); 720 (pdata->ehci_data->reset_gpio_port[0], 0);
723 } 721 }
724 722
725 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) { 723 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) {
726 gpio_request(pdata->ehci_data->reset_gpio_port[1], 724 gpio_request(pdata->ehci_data->reset_gpio_port[1],
727 "USB2 PHY reset"); 725 "USB2 PHY reset");
728 gpio_direction_output 726 gpio_direction_output
729 (pdata->ehci_data->reset_gpio_port[1], 1); 727 (pdata->ehci_data->reset_gpio_port[1], 0);
730 } 728 }
731 729
732 /* Hold the PHY in RESET for enough time till DIR is high */ 730 /* Hold the PHY in RESET for enough time till DIR is high */
@@ -906,16 +904,17 @@ static int usbhs_enable(struct device *dev)
906 904
907 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0])) 905 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
908 gpio_set_value 906 gpio_set_value
909 (pdata->ehci_data->reset_gpio_port[0], 0); 907 (pdata->ehci_data->reset_gpio_port[0], 1);
910 908
911 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) 909 if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
912 gpio_set_value 910 gpio_set_value
913 (pdata->ehci_data->reset_gpio_port[1], 0); 911 (pdata->ehci_data->reset_gpio_port[1], 1);
914 } 912 }
915 913
916end_count: 914end_count:
917 omap->count++; 915 omap->count++;
918 goto end_enable; 916 spin_unlock_irqrestore(&omap->lock, flags);
917 return 0;
919 918
920err_tll: 919err_tll:
921 if (pdata->ehci_data->phy_reset) { 920 if (pdata->ehci_data->phy_reset) {
@@ -931,8 +930,6 @@ err_tll:
931 clk_disable(omap->usbhost_fs_fck); 930 clk_disable(omap->usbhost_fs_fck);
932 clk_disable(omap->usbhost_hs_fck); 931 clk_disable(omap->usbhost_hs_fck);
933 clk_disable(omap->usbhost_ick); 932 clk_disable(omap->usbhost_ick);
934
935end_enable:
936 spin_unlock_irqrestore(&omap->lock, flags); 933 spin_unlock_irqrestore(&omap->lock, flags);
937 return ret; 934 return ret;
938} 935}
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 16422de0823a..2c0d4d16491a 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -447,12 +447,13 @@ static int __init load_twl4030_script(struct twl4030_script *tscript,
447 if (err) 447 if (err)
448 goto out; 448 goto out;
449 } 449 }
450 if (tscript->flags & TWL4030_SLEEP_SCRIPT) 450 if (tscript->flags & TWL4030_SLEEP_SCRIPT) {
451 if (order) 451 if (order)
452 pr_warning("TWL4030: Bad order of scripts (sleep "\ 452 pr_warning("TWL4030: Bad order of scripts (sleep "\
453 "script before wakeup) Leads to boot"\ 453 "script before wakeup) Leads to boot"\
454 "failure on some boards\n"); 454 "failure on some boards\n");
455 err = twl4030_config_sleep_sequence(address); 455 err = twl4030_config_sleep_sequence(address);
456 }
456out: 457out:
457 return err; 458 return err;
458} 459}
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index 63667a8f140c..d6d62fd07ee9 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -284,6 +284,7 @@ int mmc_add_card(struct mmc_card *card)
284 type = "SD-combo"; 284 type = "SD-combo";
285 if (mmc_card_blockaddr(card)) 285 if (mmc_card_blockaddr(card))
286 type = "SDHC-combo"; 286 type = "SDHC-combo";
287 break;
287 default: 288 default:
288 type = "?"; 289 type = "?";
289 break; 290 break;
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index 2e032f0e8cf4..a6c329040140 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -832,7 +832,7 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id)
832 return IRQ_HANDLED; 832 return IRQ_HANDLED;
833 } 833 }
834 834
835 if (end_command) 835 if (end_command && host->cmd)
836 mmc_omap_cmd_done(host, host->cmd); 836 mmc_omap_cmd_done(host, host->cmd);
837 if (host->data != NULL) { 837 if (host->data != NULL) {
838 if (transfer_error) 838 if (transfer_error)
diff --git a/drivers/mmc/host/sdhci-of-core.c b/drivers/mmc/host/sdhci-of-core.c
index f9b611fc773e..60e4186a4345 100644
--- a/drivers/mmc/host/sdhci-of-core.c
+++ b/drivers/mmc/host/sdhci-of-core.c
@@ -124,8 +124,10 @@ static bool __devinit sdhci_of_wp_inverted(struct device_node *np)
124#endif 124#endif
125} 125}
126 126
127static const struct of_device_id sdhci_of_match[];
127static int __devinit sdhci_of_probe(struct platform_device *ofdev) 128static int __devinit sdhci_of_probe(struct platform_device *ofdev)
128{ 129{
130 const struct of_device_id *match;
129 struct device_node *np = ofdev->dev.of_node; 131 struct device_node *np = ofdev->dev.of_node;
130 struct sdhci_of_data *sdhci_of_data; 132 struct sdhci_of_data *sdhci_of_data;
131 struct sdhci_host *host; 133 struct sdhci_host *host;
@@ -134,9 +136,10 @@ static int __devinit sdhci_of_probe(struct platform_device *ofdev)
134 int size; 136 int size;
135 int ret; 137 int ret;
136 138
137 if (!ofdev->dev.of_match) 139 match = of_match_device(sdhci_of_match, &ofdev->dev);
140 if (!match)
138 return -EINVAL; 141 return -EINVAL;
139 sdhci_of_data = ofdev->dev.of_match->data; 142 sdhci_of_data = match->data;
140 143
141 if (!of_device_is_available(np)) 144 if (!of_device_is_available(np))
142 return -ENODEV; 145 return -ENODEV;
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index a136be706347..f8b5f37007b2 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -957,6 +957,7 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot(
957 host->ioaddr = pci_ioremap_bar(pdev, bar); 957 host->ioaddr = pci_ioremap_bar(pdev, bar);
958 if (!host->ioaddr) { 958 if (!host->ioaddr) {
959 dev_err(&pdev->dev, "failed to remap registers\n"); 959 dev_err(&pdev->dev, "failed to remap registers\n");
960 ret = -ENOMEM;
960 goto release; 961 goto release;
961 } 962 }
962 963
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 9e15f41f87be..5d20661bc357 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1334,6 +1334,13 @@ static void sdhci_tasklet_finish(unsigned long param)
1334 1334
1335 host = (struct sdhci_host*)param; 1335 host = (struct sdhci_host*)param;
1336 1336
1337 /*
1338 * If this tasklet gets rescheduled while running, it will
1339 * be run again afterwards but without any active request.
1340 */
1341 if (!host->mrq)
1342 return;
1343
1337 spin_lock_irqsave(&host->lock, flags); 1344 spin_lock_irqsave(&host->lock, flags);
1338 1345
1339 del_timer(&host->timer); 1346 del_timer(&host->timer);
@@ -1345,7 +1352,7 @@ static void sdhci_tasklet_finish(unsigned long param)
1345 * upon error conditions. 1352 * upon error conditions.
1346 */ 1353 */
1347 if (!(host->flags & SDHCI_DEVICE_DEAD) && 1354 if (!(host->flags & SDHCI_DEVICE_DEAD) &&
1348 (mrq->cmd->error || 1355 ((mrq->cmd && mrq->cmd->error) ||
1349 (mrq->data && (mrq->data->error || 1356 (mrq->data && (mrq->data->error ||
1350 (mrq->data->stop && mrq->data->stop->error))) || 1357 (mrq->data->stop && mrq->data->stop->error))) ||
1351 (host->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST))) { 1358 (host->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST))) {
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 62d37de6de76..710339a85c84 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -728,15 +728,15 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
728 tmio_mmc_set_clock(host, ios->clock); 728 tmio_mmc_set_clock(host, ios->clock);
729 729
730 /* Power sequence - OFF -> UP -> ON */ 730 /* Power sequence - OFF -> UP -> ON */
731 if (ios->power_mode == MMC_POWER_OFF || !ios->clock) { 731 if (ios->power_mode == MMC_POWER_UP) {
732 /* power up SD bus */
733 if (host->set_pwr)
734 host->set_pwr(host->pdev, 1);
735 } else if (ios->power_mode == MMC_POWER_OFF || !ios->clock) {
732 /* power down SD bus */ 736 /* power down SD bus */
733 if (ios->power_mode == MMC_POWER_OFF && host->set_pwr) 737 if (ios->power_mode == MMC_POWER_OFF && host->set_pwr)
734 host->set_pwr(host->pdev, 0); 738 host->set_pwr(host->pdev, 0);
735 tmio_mmc_clk_stop(host); 739 tmio_mmc_clk_stop(host);
736 } else if (ios->power_mode == MMC_POWER_UP) {
737 /* power up SD bus */
738 if (host->set_pwr)
739 host->set_pwr(host->pdev, 1);
740 } else { 740 } else {
741 /* start bus clock */ 741 /* start bus clock */
742 tmio_mmc_clk_start(host); 742 tmio_mmc_clk_start(host);
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index bd483f0c57e1..c1d33464aee8 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -214,11 +214,13 @@ static void __devinit of_free_probes(const char **probes)
214} 214}
215#endif 215#endif
216 216
217static struct of_device_id of_flash_match[];
217static int __devinit of_flash_probe(struct platform_device *dev) 218static int __devinit of_flash_probe(struct platform_device *dev)
218{ 219{
219#ifdef CONFIG_MTD_PARTITIONS 220#ifdef CONFIG_MTD_PARTITIONS
220 const char **part_probe_types; 221 const char **part_probe_types;
221#endif 222#endif
223 const struct of_device_id *match;
222 struct device_node *dp = dev->dev.of_node; 224 struct device_node *dp = dev->dev.of_node;
223 struct resource res; 225 struct resource res;
224 struct of_flash *info; 226 struct of_flash *info;
@@ -232,9 +234,10 @@ static int __devinit of_flash_probe(struct platform_device *dev)
232 struct mtd_info **mtd_list = NULL; 234 struct mtd_info **mtd_list = NULL;
233 resource_size_t res_size; 235 resource_size_t res_size;
234 236
235 if (!dev->dev.of_match) 237 match = of_match_device(of_flash_match, &dev->dev);
238 if (!match)
236 return -EINVAL; 239 return -EINVAL;
237 probe_type = dev->dev.of_match->data; 240 probe_type = match->data;
238 241
239 reg_tuple_size = (of_n_addr_cells(dp) + of_n_size_cells(dp)) * sizeof(u32); 242 reg_tuple_size = (of_n_addr_cells(dp) + of_n_size_cells(dp)) * sizeof(u32);
240 243
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c
index 96c0b34ba8db..657b9f4b6f9b 100644
--- a/drivers/mtd/nand/diskonchip.c
+++ b/drivers/mtd/nand/diskonchip.c
@@ -400,7 +400,7 @@ static uint16_t __init doc200x_ident_chip(struct mtd_info *mtd, int nr)
400 doc200x_hwcontrol(mtd, 0, NAND_CTRL_ALE | NAND_CTRL_CHANGE); 400 doc200x_hwcontrol(mtd, 0, NAND_CTRL_ALE | NAND_CTRL_CHANGE);
401 doc200x_hwcontrol(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); 401 doc200x_hwcontrol(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE);
402 402
403 /* We can't' use dev_ready here, but at least we wait for the 403 /* We can't use dev_ready here, but at least we wait for the
404 * command to complete 404 * command to complete
405 */ 405 */
406 udelay(50); 406 udelay(50);
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index dc280bc8eba2..6c884ef1b069 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2536,7 +2536,7 @@ config S6GMAC
2536source "drivers/net/stmmac/Kconfig" 2536source "drivers/net/stmmac/Kconfig"
2537 2537
2538config PCH_GBE 2538config PCH_GBE
2539 tristate "PCH Gigabit Ethernet" 2539 tristate "Intel EG20T PCH / OKI SEMICONDUCTOR ML7223 IOH GbE"
2540 depends on PCI 2540 depends on PCI
2541 select MII 2541 select MII
2542 ---help--- 2542 ---help---
@@ -2548,6 +2548,12 @@ config PCH_GBE
2548 to Gigabit Ethernet. 2548 to Gigabit Ethernet.
2549 This driver enables Gigabit Ethernet function. 2549 This driver enables Gigabit Ethernet function.
2550 2550
2551 This driver also can be used for OKI SEMICONDUCTOR IOH(Input/
2552 Output Hub), ML7223.
2553 ML7223 IOH is for MP(Media Phone) use.
2554 ML7223 is companion chip for Intel Atom E6xx series.
2555 ML7223 is completely compatible for Intel EG20T PCH.
2556
2551endif # NETDEV_1000 2557endif # NETDEV_1000
2552 2558
2553# 2559#
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 01b604ad155e..e5a7375685ad 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -144,7 +144,7 @@ obj-$(CONFIG_NE3210) += ne3210.o 8390.o
144obj-$(CONFIG_SB1250_MAC) += sb1250-mac.o 144obj-$(CONFIG_SB1250_MAC) += sb1250-mac.o
145obj-$(CONFIG_B44) += b44.o 145obj-$(CONFIG_B44) += b44.o
146obj-$(CONFIG_FORCEDETH) += forcedeth.o 146obj-$(CONFIG_FORCEDETH) += forcedeth.o
147obj-$(CONFIG_NE_H8300) += ne-h8300.o 8390.o 147obj-$(CONFIG_NE_H8300) += ne-h8300.o
148obj-$(CONFIG_AX88796) += ax88796.o 148obj-$(CONFIG_AX88796) += ax88796.o
149obj-$(CONFIG_BCM63XX_ENET) += bcm63xx_enet.o 149obj-$(CONFIG_BCM63XX_ENET) += bcm63xx_enet.o
150obj-$(CONFIG_FTMAC100) += ftmac100.o 150obj-$(CONFIG_FTMAC100) += ftmac100.o
@@ -219,7 +219,7 @@ obj-$(CONFIG_SC92031) += sc92031.o
219obj-$(CONFIG_LP486E) += lp486e.o 219obj-$(CONFIG_LP486E) += lp486e.o
220 220
221obj-$(CONFIG_ETH16I) += eth16i.o 221obj-$(CONFIG_ETH16I) += eth16i.o
222obj-$(CONFIG_ZORRO8390) += zorro8390.o 8390.o 222obj-$(CONFIG_ZORRO8390) += zorro8390.o
223obj-$(CONFIG_HPLANCE) += hplance.o 7990.o 223obj-$(CONFIG_HPLANCE) += hplance.o 7990.o
224obj-$(CONFIG_MVME147_NET) += mvme147.o 7990.o 224obj-$(CONFIG_MVME147_NET) += mvme147.o 7990.o
225obj-$(CONFIG_EQUALIZER) += eql.o 225obj-$(CONFIG_EQUALIZER) += eql.o
@@ -231,7 +231,7 @@ obj-$(CONFIG_SGI_IOC3_ETH) += ioc3-eth.o
231obj-$(CONFIG_DECLANCE) += declance.o 231obj-$(CONFIG_DECLANCE) += declance.o
232obj-$(CONFIG_ATARILANCE) += atarilance.o 232obj-$(CONFIG_ATARILANCE) += atarilance.o
233obj-$(CONFIG_A2065) += a2065.o 233obj-$(CONFIG_A2065) += a2065.o
234obj-$(CONFIG_HYDRA) += hydra.o 8390.o 234obj-$(CONFIG_HYDRA) += hydra.o
235obj-$(CONFIG_ARIADNE) += ariadne.o 235obj-$(CONFIG_ARIADNE) += ariadne.o
236obj-$(CONFIG_CS89x0) += cs89x0.o 236obj-$(CONFIG_CS89x0) += cs89x0.o
237obj-$(CONFIG_MACSONIC) += macsonic.o 237obj-$(CONFIG_MACSONIC) += macsonic.o
diff --git a/drivers/net/amd8111e.c b/drivers/net/amd8111e.c
index 88495c48a81d..241b185e6569 100644
--- a/drivers/net/amd8111e.c
+++ b/drivers/net/amd8111e.c
@@ -106,7 +106,7 @@ MODULE_DESCRIPTION ("AMD8111 based 10/100 Ethernet Controller. Driver Version "M
106MODULE_LICENSE("GPL"); 106MODULE_LICENSE("GPL");
107MODULE_DEVICE_TABLE(pci, amd8111e_pci_tbl); 107MODULE_DEVICE_TABLE(pci, amd8111e_pci_tbl);
108module_param_array(speed_duplex, int, NULL, 0); 108module_param_array(speed_duplex, int, NULL, 0);
109MODULE_PARM_DESC(speed_duplex, "Set device speed and duplex modes, 0: Auto Negotitate, 1: 10Mbps Half Duplex, 2: 10Mbps Full Duplex, 3: 100Mbps Half Duplex, 4: 100Mbps Full Duplex"); 109MODULE_PARM_DESC(speed_duplex, "Set device speed and duplex modes, 0: Auto Negotiate, 1: 10Mbps Half Duplex, 2: 10Mbps Full Duplex, 3: 100Mbps Half Duplex, 4: 100Mbps Full Duplex");
110module_param_array(coalesce, bool, NULL, 0); 110module_param_array(coalesce, bool, NULL, 0);
111MODULE_PARM_DESC(coalesce, "Enable or Disable interrupt coalescing, 1: Enable, 0: Disable"); 111MODULE_PARM_DESC(coalesce, "Enable or Disable interrupt coalescing, 1: Enable, 0: Disable");
112module_param_array(dynamic_ipg, bool, NULL, 0); 112module_param_array(dynamic_ipg, bool, NULL, 0);
diff --git a/drivers/net/arm/etherh.c b/drivers/net/arm/etherh.c
index 4af235d41fda..fbfb5b47c506 100644
--- a/drivers/net/arm/etherh.c
+++ b/drivers/net/arm/etherh.c
@@ -527,7 +527,7 @@ static void __init etherh_banner(void)
527 * Read the ethernet address string from the on board rom. 527 * Read the ethernet address string from the on board rom.
528 * This is an ascii string... 528 * This is an ascii string...
529 */ 529 */
530static int __init etherh_addr(char *addr, struct expansion_card *ec) 530static int __devinit etherh_addr(char *addr, struct expansion_card *ec)
531{ 531{
532 struct in_chunk_dir cd; 532 struct in_chunk_dir cd;
533 char *s; 533 char *s;
@@ -655,7 +655,7 @@ static const struct net_device_ops etherh_netdev_ops = {
655static u32 etherh_regoffsets[16]; 655static u32 etherh_regoffsets[16];
656static u32 etherm_regoffsets[16]; 656static u32 etherm_regoffsets[16];
657 657
658static int __init 658static int __devinit
659etherh_probe(struct expansion_card *ec, const struct ecard_id *id) 659etherh_probe(struct expansion_card *ec, const struct ecard_id *id)
660{ 660{
661 const struct etherh_data *data = id->data; 661 const struct etherh_data *data = id->data;
diff --git a/drivers/net/atl1c/atl1c.h b/drivers/net/atl1c/atl1c.h
index 7cb375e0e29c..925929d764ca 100644
--- a/drivers/net/atl1c/atl1c.h
+++ b/drivers/net/atl1c/atl1c.h
@@ -566,9 +566,9 @@ struct atl1c_adapter {
566#define __AT_TESTING 0x0001 566#define __AT_TESTING 0x0001
567#define __AT_RESETTING 0x0002 567#define __AT_RESETTING 0x0002
568#define __AT_DOWN 0x0003 568#define __AT_DOWN 0x0003
569 u8 work_event; 569 unsigned long work_event;
570#define ATL1C_WORK_EVENT_RESET 0x01 570#define ATL1C_WORK_EVENT_RESET 0
571#define ATL1C_WORK_EVENT_LINK_CHANGE 0x02 571#define ATL1C_WORK_EVENT_LINK_CHANGE 1
572 u32 msg_enable; 572 u32 msg_enable;
573 573
574 bool have_msi; 574 bool have_msi;
diff --git a/drivers/net/atl1c/atl1c_main.c b/drivers/net/atl1c/atl1c_main.c
index 7d9d5067a65c..a6e1c36e48e6 100644
--- a/drivers/net/atl1c/atl1c_main.c
+++ b/drivers/net/atl1c/atl1c_main.c
@@ -325,7 +325,7 @@ static void atl1c_link_chg_event(struct atl1c_adapter *adapter)
325 } 325 }
326 } 326 }
327 327
328 adapter->work_event |= ATL1C_WORK_EVENT_LINK_CHANGE; 328 set_bit(ATL1C_WORK_EVENT_LINK_CHANGE, &adapter->work_event);
329 schedule_work(&adapter->common_task); 329 schedule_work(&adapter->common_task);
330} 330}
331 331
@@ -337,20 +337,16 @@ static void atl1c_common_task(struct work_struct *work)
337 adapter = container_of(work, struct atl1c_adapter, common_task); 337 adapter = container_of(work, struct atl1c_adapter, common_task);
338 netdev = adapter->netdev; 338 netdev = adapter->netdev;
339 339
340 if (adapter->work_event & ATL1C_WORK_EVENT_RESET) { 340 if (test_and_clear_bit(ATL1C_WORK_EVENT_RESET, &adapter->work_event)) {
341 adapter->work_event &= ~ATL1C_WORK_EVENT_RESET;
342 netif_device_detach(netdev); 341 netif_device_detach(netdev);
343 atl1c_down(adapter); 342 atl1c_down(adapter);
344 atl1c_up(adapter); 343 atl1c_up(adapter);
345 netif_device_attach(netdev); 344 netif_device_attach(netdev);
346 return;
347 } 345 }
348 346
349 if (adapter->work_event & ATL1C_WORK_EVENT_LINK_CHANGE) { 347 if (test_and_clear_bit(ATL1C_WORK_EVENT_LINK_CHANGE,
350 adapter->work_event &= ~ATL1C_WORK_EVENT_LINK_CHANGE; 348 &adapter->work_event))
351 atl1c_check_link_status(adapter); 349 atl1c_check_link_status(adapter);
352 }
353 return;
354} 350}
355 351
356 352
@@ -369,7 +365,7 @@ static void atl1c_tx_timeout(struct net_device *netdev)
369 struct atl1c_adapter *adapter = netdev_priv(netdev); 365 struct atl1c_adapter *adapter = netdev_priv(netdev);
370 366
371 /* Do the reset outside of interrupt context */ 367 /* Do the reset outside of interrupt context */
372 adapter->work_event |= ATL1C_WORK_EVENT_RESET; 368 set_bit(ATL1C_WORK_EVENT_RESET, &adapter->work_event);
373 schedule_work(&adapter->common_task); 369 schedule_work(&adapter->common_task);
374} 370}
375 371
diff --git a/drivers/net/benet/be.h b/drivers/net/benet/be.h
index 66823eded7a3..2353eca32593 100644
--- a/drivers/net/benet/be.h
+++ b/drivers/net/benet/be.h
@@ -213,7 +213,7 @@ struct be_rx_stats {
213 213
214struct be_rx_compl_info { 214struct be_rx_compl_info {
215 u32 rss_hash; 215 u32 rss_hash;
216 u16 vid; 216 u16 vlan_tag;
217 u16 pkt_size; 217 u16 pkt_size;
218 u16 rxq_idx; 218 u16 rxq_idx;
219 u16 mac_id; 219 u16 mac_id;
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c
index 1e2d825bb94a..9dc9394fd4ca 100644
--- a/drivers/net/benet/be_cmds.c
+++ b/drivers/net/benet/be_cmds.c
@@ -132,7 +132,7 @@ static void be_async_grp5_pvid_state_process(struct be_adapter *adapter,
132 struct be_async_event_grp5_pvid_state *evt) 132 struct be_async_event_grp5_pvid_state *evt)
133{ 133{
134 if (evt->enabled) 134 if (evt->enabled)
135 adapter->pvid = evt->tag; 135 adapter->pvid = le16_to_cpu(evt->tag);
136 else 136 else
137 adapter->pvid = 0; 137 adapter->pvid = 0;
138} 138}
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
index 7cb5a114c733..9187fb4e08f1 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -1018,7 +1018,8 @@ static void be_rx_compl_process(struct be_adapter *adapter,
1018 kfree_skb(skb); 1018 kfree_skb(skb);
1019 return; 1019 return;
1020 } 1020 }
1021 vlan_hwaccel_receive_skb(skb, adapter->vlan_grp, rxcp->vid); 1021 vlan_hwaccel_receive_skb(skb, adapter->vlan_grp,
1022 rxcp->vlan_tag);
1022 } else { 1023 } else {
1023 netif_receive_skb(skb); 1024 netif_receive_skb(skb);
1024 } 1025 }
@@ -1076,7 +1077,8 @@ static void be_rx_compl_process_gro(struct be_adapter *adapter,
1076 if (likely(!rxcp->vlanf)) 1077 if (likely(!rxcp->vlanf))
1077 napi_gro_frags(&eq_obj->napi); 1078 napi_gro_frags(&eq_obj->napi);
1078 else 1079 else
1079 vlan_gro_frags(&eq_obj->napi, adapter->vlan_grp, rxcp->vid); 1080 vlan_gro_frags(&eq_obj->napi, adapter->vlan_grp,
1081 rxcp->vlan_tag);
1080} 1082}
1081 1083
1082static void be_parse_rx_compl_v1(struct be_adapter *adapter, 1084static void be_parse_rx_compl_v1(struct be_adapter *adapter,
@@ -1102,7 +1104,8 @@ static void be_parse_rx_compl_v1(struct be_adapter *adapter,
1102 rxcp->pkt_type = 1104 rxcp->pkt_type =
1103 AMAP_GET_BITS(struct amap_eth_rx_compl_v1, cast_enc, compl); 1105 AMAP_GET_BITS(struct amap_eth_rx_compl_v1, cast_enc, compl);
1104 rxcp->vtm = AMAP_GET_BITS(struct amap_eth_rx_compl_v1, vtm, compl); 1106 rxcp->vtm = AMAP_GET_BITS(struct amap_eth_rx_compl_v1, vtm, compl);
1105 rxcp->vid = AMAP_GET_BITS(struct amap_eth_rx_compl_v1, vlan_tag, compl); 1107 rxcp->vlan_tag = AMAP_GET_BITS(struct amap_eth_rx_compl_v1, vlan_tag,
1108 compl);
1106} 1109}
1107 1110
1108static void be_parse_rx_compl_v0(struct be_adapter *adapter, 1111static void be_parse_rx_compl_v0(struct be_adapter *adapter,
@@ -1128,7 +1131,8 @@ static void be_parse_rx_compl_v0(struct be_adapter *adapter,
1128 rxcp->pkt_type = 1131 rxcp->pkt_type =
1129 AMAP_GET_BITS(struct amap_eth_rx_compl_v0, cast_enc, compl); 1132 AMAP_GET_BITS(struct amap_eth_rx_compl_v0, cast_enc, compl);
1130 rxcp->vtm = AMAP_GET_BITS(struct amap_eth_rx_compl_v0, vtm, compl); 1133 rxcp->vtm = AMAP_GET_BITS(struct amap_eth_rx_compl_v0, vtm, compl);
1131 rxcp->vid = AMAP_GET_BITS(struct amap_eth_rx_compl_v0, vlan_tag, compl); 1134 rxcp->vlan_tag = AMAP_GET_BITS(struct amap_eth_rx_compl_v0, vlan_tag,
1135 compl);
1132} 1136}
1133 1137
1134static struct be_rx_compl_info *be_rx_compl_get(struct be_rx_obj *rxo) 1138static struct be_rx_compl_info *be_rx_compl_get(struct be_rx_obj *rxo)
@@ -1155,9 +1159,11 @@ static struct be_rx_compl_info *be_rx_compl_get(struct be_rx_obj *rxo)
1155 rxcp->vlanf = 0; 1159 rxcp->vlanf = 0;
1156 1160
1157 if (!lancer_chip(adapter)) 1161 if (!lancer_chip(adapter))
1158 rxcp->vid = swab16(rxcp->vid); 1162 rxcp->vlan_tag = swab16(rxcp->vlan_tag);
1159 1163
1160 if ((adapter->pvid == rxcp->vid) && !adapter->vlan_tag[rxcp->vid]) 1164 if (((adapter->pvid & VLAN_VID_MASK) ==
1165 (rxcp->vlan_tag & VLAN_VID_MASK)) &&
1166 !adapter->vlan_tag[rxcp->vlan_tag])
1161 rxcp->vlanf = 0; 1167 rxcp->vlanf = 0;
1162 1168
1163 /* As the compl has been parsed, reset it; we wont touch it again */ 1169 /* As the compl has been parsed, reset it; we wont touch it again */
@@ -1873,6 +1879,7 @@ static void be_worker(struct work_struct *work)
1873 be_detect_dump_ue(adapter); 1879 be_detect_dump_ue(adapter);
1874 1880
1875reschedule: 1881reschedule:
1882 adapter->work_counter++;
1876 schedule_delayed_work(&adapter->work, msecs_to_jiffies(1000)); 1883 schedule_delayed_work(&adapter->work, msecs_to_jiffies(1000));
1877} 1884}
1878 1885
diff --git a/drivers/net/bna/bfa_ioc.c b/drivers/net/bna/bfa_ioc.c
index e3de0b8625cd..7581518ecfa2 100644
--- a/drivers/net/bna/bfa_ioc.c
+++ b/drivers/net/bna/bfa_ioc.c
@@ -38,6 +38,8 @@
38#define bfa_ioc_map_port(__ioc) ((__ioc)->ioc_hwif->ioc_map_port(__ioc)) 38#define bfa_ioc_map_port(__ioc) ((__ioc)->ioc_hwif->ioc_map_port(__ioc))
39#define bfa_ioc_notify_fail(__ioc) \ 39#define bfa_ioc_notify_fail(__ioc) \
40 ((__ioc)->ioc_hwif->ioc_notify_fail(__ioc)) 40 ((__ioc)->ioc_hwif->ioc_notify_fail(__ioc))
41#define bfa_ioc_sync_start(__ioc) \
42 ((__ioc)->ioc_hwif->ioc_sync_start(__ioc))
41#define bfa_ioc_sync_join(__ioc) \ 43#define bfa_ioc_sync_join(__ioc) \
42 ((__ioc)->ioc_hwif->ioc_sync_join(__ioc)) 44 ((__ioc)->ioc_hwif->ioc_sync_join(__ioc))
43#define bfa_ioc_sync_leave(__ioc) \ 45#define bfa_ioc_sync_leave(__ioc) \
@@ -602,7 +604,7 @@ bfa_iocpf_sm_fwcheck(struct bfa_iocpf *iocpf, enum iocpf_event event)
602 switch (event) { 604 switch (event) {
603 case IOCPF_E_SEMLOCKED: 605 case IOCPF_E_SEMLOCKED:
604 if (bfa_ioc_firmware_lock(ioc)) { 606 if (bfa_ioc_firmware_lock(ioc)) {
605 if (bfa_ioc_sync_complete(ioc)) { 607 if (bfa_ioc_sync_start(ioc)) {
606 iocpf->retry_count = 0; 608 iocpf->retry_count = 0;
607 bfa_ioc_sync_join(ioc); 609 bfa_ioc_sync_join(ioc);
608 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit); 610 bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit);
@@ -1314,7 +1316,7 @@ bfa_nw_ioc_fwver_cmp(struct bfa_ioc *ioc, struct bfi_ioc_image_hdr *fwhdr)
1314 * execution context (driver/bios) must match. 1316 * execution context (driver/bios) must match.
1315 */ 1317 */
1316static bool 1318static bool
1317bfa_ioc_fwver_valid(struct bfa_ioc *ioc) 1319bfa_ioc_fwver_valid(struct bfa_ioc *ioc, u32 boot_env)
1318{ 1320{
1319 struct bfi_ioc_image_hdr fwhdr, *drv_fwhdr; 1321 struct bfi_ioc_image_hdr fwhdr, *drv_fwhdr;
1320 1322
@@ -1325,7 +1327,7 @@ bfa_ioc_fwver_valid(struct bfa_ioc *ioc)
1325 if (fwhdr.signature != drv_fwhdr->signature) 1327 if (fwhdr.signature != drv_fwhdr->signature)
1326 return false; 1328 return false;
1327 1329
1328 if (fwhdr.exec != drv_fwhdr->exec) 1330 if (swab32(fwhdr.param) != boot_env)
1329 return false; 1331 return false;
1330 1332
1331 return bfa_nw_ioc_fwver_cmp(ioc, &fwhdr); 1333 return bfa_nw_ioc_fwver_cmp(ioc, &fwhdr);
@@ -1352,9 +1354,12 @@ bfa_ioc_hwinit(struct bfa_ioc *ioc, bool force)
1352{ 1354{
1353 enum bfi_ioc_state ioc_fwstate; 1355 enum bfi_ioc_state ioc_fwstate;
1354 bool fwvalid; 1356 bool fwvalid;
1357 u32 boot_env;
1355 1358
1356 ioc_fwstate = readl(ioc->ioc_regs.ioc_fwstate); 1359 ioc_fwstate = readl(ioc->ioc_regs.ioc_fwstate);
1357 1360
1361 boot_env = BFI_BOOT_LOADER_OS;
1362
1358 if (force) 1363 if (force)
1359 ioc_fwstate = BFI_IOC_UNINIT; 1364 ioc_fwstate = BFI_IOC_UNINIT;
1360 1365
@@ -1362,10 +1367,10 @@ bfa_ioc_hwinit(struct bfa_ioc *ioc, bool force)
1362 * check if firmware is valid 1367 * check if firmware is valid
1363 */ 1368 */
1364 fwvalid = (ioc_fwstate == BFI_IOC_UNINIT) ? 1369 fwvalid = (ioc_fwstate == BFI_IOC_UNINIT) ?
1365 false : bfa_ioc_fwver_valid(ioc); 1370 false : bfa_ioc_fwver_valid(ioc, boot_env);
1366 1371
1367 if (!fwvalid) { 1372 if (!fwvalid) {
1368 bfa_ioc_boot(ioc, BFI_BOOT_TYPE_NORMAL, ioc->pcidev.device_id); 1373 bfa_ioc_boot(ioc, BFI_BOOT_TYPE_NORMAL, boot_env);
1369 return; 1374 return;
1370 } 1375 }
1371 1376
@@ -1396,7 +1401,7 @@ bfa_ioc_hwinit(struct bfa_ioc *ioc, bool force)
1396 /** 1401 /**
1397 * Initialize the h/w for any other states. 1402 * Initialize the h/w for any other states.
1398 */ 1403 */
1399 bfa_ioc_boot(ioc, BFI_BOOT_TYPE_NORMAL, ioc->pcidev.device_id); 1404 bfa_ioc_boot(ioc, BFI_BOOT_TYPE_NORMAL, boot_env);
1400} 1405}
1401 1406
1402void 1407void
@@ -1506,7 +1511,7 @@ bfa_ioc_hb_stop(struct bfa_ioc *ioc)
1506 */ 1511 */
1507static void 1512static void
1508bfa_ioc_download_fw(struct bfa_ioc *ioc, u32 boot_type, 1513bfa_ioc_download_fw(struct bfa_ioc *ioc, u32 boot_type,
1509 u32 boot_param) 1514 u32 boot_env)
1510{ 1515{
1511 u32 *fwimg; 1516 u32 *fwimg;
1512 u32 pgnum, pgoff; 1517 u32 pgnum, pgoff;
@@ -1558,10 +1563,10 @@ bfa_ioc_download_fw(struct bfa_ioc *ioc, u32 boot_type,
1558 /* 1563 /*
1559 * Set boot type and boot param at the end. 1564 * Set boot type and boot param at the end.
1560 */ 1565 */
1561 writel((swab32(swab32(boot_type))), ((ioc->ioc_regs.smem_page_start) 1566 writel(boot_type, ((ioc->ioc_regs.smem_page_start)
1562 + (BFI_BOOT_TYPE_OFF))); 1567 + (BFI_BOOT_TYPE_OFF)));
1563 writel((swab32(swab32(boot_param))), ((ioc->ioc_regs.smem_page_start) 1568 writel(boot_env, ((ioc->ioc_regs.smem_page_start)
1564 + (BFI_BOOT_PARAM_OFF))); 1569 + (BFI_BOOT_LOADER_OFF)));
1565} 1570}
1566 1571
1567static void 1572static void
@@ -1721,7 +1726,7 @@ bfa_ioc_pll_init(struct bfa_ioc *ioc)
1721 * as the entry vector. 1726 * as the entry vector.
1722 */ 1727 */
1723static void 1728static void
1724bfa_ioc_boot(struct bfa_ioc *ioc, u32 boot_type, u32 boot_param) 1729bfa_ioc_boot(struct bfa_ioc *ioc, u32 boot_type, u32 boot_env)
1725{ 1730{
1726 void __iomem *rb; 1731 void __iomem *rb;
1727 1732
@@ -1734,7 +1739,7 @@ bfa_ioc_boot(struct bfa_ioc *ioc, u32 boot_type, u32 boot_param)
1734 * Initialize IOC state of all functions on a chip reset. 1739 * Initialize IOC state of all functions on a chip reset.
1735 */ 1740 */
1736 rb = ioc->pcidev.pci_bar_kva; 1741 rb = ioc->pcidev.pci_bar_kva;
1737 if (boot_param == BFI_BOOT_TYPE_MEMTEST) { 1742 if (boot_type == BFI_BOOT_TYPE_MEMTEST) {
1738 writel(BFI_IOC_MEMTEST, (rb + BFA_IOC0_STATE_REG)); 1743 writel(BFI_IOC_MEMTEST, (rb + BFA_IOC0_STATE_REG));
1739 writel(BFI_IOC_MEMTEST, (rb + BFA_IOC1_STATE_REG)); 1744 writel(BFI_IOC_MEMTEST, (rb + BFA_IOC1_STATE_REG));
1740 } else { 1745 } else {
@@ -1743,7 +1748,7 @@ bfa_ioc_boot(struct bfa_ioc *ioc, u32 boot_type, u32 boot_param)
1743 } 1748 }
1744 1749
1745 bfa_ioc_msgflush(ioc); 1750 bfa_ioc_msgflush(ioc);
1746 bfa_ioc_download_fw(ioc, boot_type, boot_param); 1751 bfa_ioc_download_fw(ioc, boot_type, boot_env);
1747 1752
1748 /** 1753 /**
1749 * Enable interrupts just before starting LPU 1754 * Enable interrupts just before starting LPU
diff --git a/drivers/net/bna/bfa_ioc.h b/drivers/net/bna/bfa_ioc.h
index e4974bc24ef6..bd48abee781f 100644
--- a/drivers/net/bna/bfa_ioc.h
+++ b/drivers/net/bna/bfa_ioc.h
@@ -194,6 +194,7 @@ struct bfa_ioc_hwif {
194 bool msix); 194 bool msix);
195 void (*ioc_notify_fail) (struct bfa_ioc *ioc); 195 void (*ioc_notify_fail) (struct bfa_ioc *ioc);
196 void (*ioc_ownership_reset) (struct bfa_ioc *ioc); 196 void (*ioc_ownership_reset) (struct bfa_ioc *ioc);
197 bool (*ioc_sync_start) (struct bfa_ioc *ioc);
197 void (*ioc_sync_join) (struct bfa_ioc *ioc); 198 void (*ioc_sync_join) (struct bfa_ioc *ioc);
198 void (*ioc_sync_leave) (struct bfa_ioc *ioc); 199 void (*ioc_sync_leave) (struct bfa_ioc *ioc);
199 void (*ioc_sync_ack) (struct bfa_ioc *ioc); 200 void (*ioc_sync_ack) (struct bfa_ioc *ioc);
diff --git a/drivers/net/bna/bfa_ioc_ct.c b/drivers/net/bna/bfa_ioc_ct.c
index 469997c4ffd1..87aecdf22cf9 100644
--- a/drivers/net/bna/bfa_ioc_ct.c
+++ b/drivers/net/bna/bfa_ioc_ct.c
@@ -41,6 +41,7 @@ static void bfa_ioc_ct_map_port(struct bfa_ioc *ioc);
41static void bfa_ioc_ct_isr_mode_set(struct bfa_ioc *ioc, bool msix); 41static void bfa_ioc_ct_isr_mode_set(struct bfa_ioc *ioc, bool msix);
42static void bfa_ioc_ct_notify_fail(struct bfa_ioc *ioc); 42static void bfa_ioc_ct_notify_fail(struct bfa_ioc *ioc);
43static void bfa_ioc_ct_ownership_reset(struct bfa_ioc *ioc); 43static void bfa_ioc_ct_ownership_reset(struct bfa_ioc *ioc);
44static bool bfa_ioc_ct_sync_start(struct bfa_ioc *ioc);
44static void bfa_ioc_ct_sync_join(struct bfa_ioc *ioc); 45static void bfa_ioc_ct_sync_join(struct bfa_ioc *ioc);
45static void bfa_ioc_ct_sync_leave(struct bfa_ioc *ioc); 46static void bfa_ioc_ct_sync_leave(struct bfa_ioc *ioc);
46static void bfa_ioc_ct_sync_ack(struct bfa_ioc *ioc); 47static void bfa_ioc_ct_sync_ack(struct bfa_ioc *ioc);
@@ -63,6 +64,7 @@ bfa_nw_ioc_set_ct_hwif(struct bfa_ioc *ioc)
63 nw_hwif_ct.ioc_isr_mode_set = bfa_ioc_ct_isr_mode_set; 64 nw_hwif_ct.ioc_isr_mode_set = bfa_ioc_ct_isr_mode_set;
64 nw_hwif_ct.ioc_notify_fail = bfa_ioc_ct_notify_fail; 65 nw_hwif_ct.ioc_notify_fail = bfa_ioc_ct_notify_fail;
65 nw_hwif_ct.ioc_ownership_reset = bfa_ioc_ct_ownership_reset; 66 nw_hwif_ct.ioc_ownership_reset = bfa_ioc_ct_ownership_reset;
67 nw_hwif_ct.ioc_sync_start = bfa_ioc_ct_sync_start;
66 nw_hwif_ct.ioc_sync_join = bfa_ioc_ct_sync_join; 68 nw_hwif_ct.ioc_sync_join = bfa_ioc_ct_sync_join;
67 nw_hwif_ct.ioc_sync_leave = bfa_ioc_ct_sync_leave; 69 nw_hwif_ct.ioc_sync_leave = bfa_ioc_ct_sync_leave;
68 nw_hwif_ct.ioc_sync_ack = bfa_ioc_ct_sync_ack; 70 nw_hwif_ct.ioc_sync_ack = bfa_ioc_ct_sync_ack;
@@ -345,6 +347,32 @@ bfa_ioc_ct_ownership_reset(struct bfa_ioc *ioc)
345/** 347/**
346 * Synchronized IOC failure processing routines 348 * Synchronized IOC failure processing routines
347 */ 349 */
350static bool
351bfa_ioc_ct_sync_start(struct bfa_ioc *ioc)
352{
353 u32 r32 = readl(ioc->ioc_regs.ioc_fail_sync);
354 u32 sync_reqd = bfa_ioc_ct_get_sync_reqd(r32);
355
356 /*
357 * Driver load time. If the sync required bit for this PCI fn
358 * is set, it is due to an unclean exit by the driver for this
359 * PCI fn in the previous incarnation. Whoever comes here first
360 * should clean it up, no matter which PCI fn.
361 */
362
363 if (sync_reqd & bfa_ioc_ct_sync_pos(ioc)) {
364 writel(0, ioc->ioc_regs.ioc_fail_sync);
365 writel(1, ioc->ioc_regs.ioc_usage_reg);
366 writel(BFI_IOC_UNINIT, ioc->ioc_regs.ioc_fwstate);
367 writel(BFI_IOC_UNINIT, ioc->ioc_regs.alt_ioc_fwstate);
368 return true;
369 }
370
371 return bfa_ioc_ct_sync_complete(ioc);
372}
373/**
374 * Synchronized IOC failure processing routines
375 */
348static void 376static void
349bfa_ioc_ct_sync_join(struct bfa_ioc *ioc) 377bfa_ioc_ct_sync_join(struct bfa_ioc *ioc)
350{ 378{
diff --git a/drivers/net/bna/bfi.h b/drivers/net/bna/bfi.h
index a97396811050..6050379526f7 100644
--- a/drivers/net/bna/bfi.h
+++ b/drivers/net/bna/bfi.h
@@ -184,12 +184,14 @@ enum bfi_mclass {
184#define BFI_IOC_MSGLEN_MAX 32 /* 32 bytes */ 184#define BFI_IOC_MSGLEN_MAX 32 /* 32 bytes */
185 185
186#define BFI_BOOT_TYPE_OFF 8 186#define BFI_BOOT_TYPE_OFF 8
187#define BFI_BOOT_PARAM_OFF 12 187#define BFI_BOOT_LOADER_OFF 12
188 188
189#define BFI_BOOT_TYPE_NORMAL 0 /* param is device id */ 189#define BFI_BOOT_TYPE_NORMAL 0
190#define BFI_BOOT_TYPE_FLASH 1 190#define BFI_BOOT_TYPE_FLASH 1
191#define BFI_BOOT_TYPE_MEMTEST 2 191#define BFI_BOOT_TYPE_MEMTEST 2
192 192
193#define BFI_BOOT_LOADER_OS 0
194
193#define BFI_BOOT_MEMTEST_RES_ADDR 0x900 195#define BFI_BOOT_MEMTEST_RES_ADDR 0x900
194#define BFI_BOOT_MEMTEST_RES_SIG 0xA0A1A2A3 196#define BFI_BOOT_MEMTEST_RES_SIG 0xA0A1A2A3
195 197
diff --git a/drivers/net/bna/bnad.c b/drivers/net/bna/bnad.c
index 9f356d5d0f33..8e6ceab9f4d8 100644
--- a/drivers/net/bna/bnad.c
+++ b/drivers/net/bna/bnad.c
@@ -1837,7 +1837,6 @@ bnad_setup_rx(struct bnad *bnad, uint rx_id)
1837 /* Initialize the Rx event handlers */ 1837 /* Initialize the Rx event handlers */
1838 rx_cbfn.rcb_setup_cbfn = bnad_cb_rcb_setup; 1838 rx_cbfn.rcb_setup_cbfn = bnad_cb_rcb_setup;
1839 rx_cbfn.rcb_destroy_cbfn = bnad_cb_rcb_destroy; 1839 rx_cbfn.rcb_destroy_cbfn = bnad_cb_rcb_destroy;
1840 rx_cbfn.rcb_destroy_cbfn = NULL;
1841 rx_cbfn.ccb_setup_cbfn = bnad_cb_ccb_setup; 1840 rx_cbfn.ccb_setup_cbfn = bnad_cb_ccb_setup;
1842 rx_cbfn.ccb_destroy_cbfn = bnad_cb_ccb_destroy; 1841 rx_cbfn.ccb_destroy_cbfn = bnad_cb_ccb_destroy;
1843 rx_cbfn.rx_cleanup_cbfn = bnad_cb_rx_cleanup; 1842 rx_cbfn.rx_cleanup_cbfn = bnad_cb_rx_cleanup;
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 8e6d618b5305..d8383a9af9ad 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -8413,6 +8413,8 @@ bnx2_remove_one(struct pci_dev *pdev)
8413 8413
8414 unregister_netdev(dev); 8414 unregister_netdev(dev);
8415 8415
8416 del_timer_sync(&bp->timer);
8417
8416 if (bp->mips_firmware) 8418 if (bp->mips_firmware)
8417 release_firmware(bp->mips_firmware); 8419 release_firmware(bp->mips_firmware);
8418 if (bp->rv2p_firmware) 8420 if (bp->rv2p_firmware)
diff --git a/drivers/net/bnx2x/bnx2x_cmn.c b/drivers/net/bnx2x/bnx2x_cmn.c
index e83ac6dd6fc0..16581df5ee4e 100644
--- a/drivers/net/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/bnx2x/bnx2x_cmn.c
@@ -2019,15 +2019,23 @@ static inline void bnx2x_set_pbd_gso(struct sk_buff *skb,
2019static inline u8 bnx2x_set_pbd_csum_e2(struct bnx2x *bp, struct sk_buff *skb, 2019static inline u8 bnx2x_set_pbd_csum_e2(struct bnx2x *bp, struct sk_buff *skb,
2020 u32 *parsing_data, u32 xmit_type) 2020 u32 *parsing_data, u32 xmit_type)
2021{ 2021{
2022 *parsing_data |= ((tcp_hdrlen(skb)/4) << 2022 *parsing_data |=
2023 ETH_TX_PARSE_BD_E2_TCP_HDR_LENGTH_DW_SHIFT) & 2023 ((((u8 *)skb_transport_header(skb) - skb->data) >> 1) <<
2024 ETH_TX_PARSE_BD_E2_TCP_HDR_LENGTH_DW; 2024 ETH_TX_PARSE_BD_E2_TCP_HDR_START_OFFSET_W_SHIFT) &
2025 ETH_TX_PARSE_BD_E2_TCP_HDR_START_OFFSET_W;
2025 2026
2026 *parsing_data |= ((((u8 *)tcp_hdr(skb) - skb->data) / 2) << 2027 if (xmit_type & XMIT_CSUM_TCP) {
2027 ETH_TX_PARSE_BD_E2_TCP_HDR_START_OFFSET_W_SHIFT) & 2028 *parsing_data |= ((tcp_hdrlen(skb) / 4) <<
2028 ETH_TX_PARSE_BD_E2_TCP_HDR_START_OFFSET_W; 2029 ETH_TX_PARSE_BD_E2_TCP_HDR_LENGTH_DW_SHIFT) &
2030 ETH_TX_PARSE_BD_E2_TCP_HDR_LENGTH_DW;
2029 2031
2030 return skb_transport_header(skb) + tcp_hdrlen(skb) - skb->data; 2032 return skb_transport_header(skb) + tcp_hdrlen(skb) - skb->data;
2033 } else
2034 /* We support checksum offload for TCP and UDP only.
2035 * No need to pass the UDP header length - it's a constant.
2036 */
2037 return skb_transport_header(skb) +
2038 sizeof(struct udphdr) - skb->data;
2031} 2039}
2032 2040
2033/** 2041/**
@@ -2043,7 +2051,7 @@ static inline u8 bnx2x_set_pbd_csum(struct bnx2x *bp, struct sk_buff *skb,
2043 struct eth_tx_parse_bd_e1x *pbd, 2051 struct eth_tx_parse_bd_e1x *pbd,
2044 u32 xmit_type) 2052 u32 xmit_type)
2045{ 2053{
2046 u8 hlen = (skb_network_header(skb) - skb->data) / 2; 2054 u8 hlen = (skb_network_header(skb) - skb->data) >> 1;
2047 2055
2048 /* for now NS flag is not used in Linux */ 2056 /* for now NS flag is not used in Linux */
2049 pbd->global_data = 2057 pbd->global_data =
@@ -2051,9 +2059,15 @@ static inline u8 bnx2x_set_pbd_csum(struct bnx2x *bp, struct sk_buff *skb,
2051 ETH_TX_PARSE_BD_E1X_LLC_SNAP_EN_SHIFT)); 2059 ETH_TX_PARSE_BD_E1X_LLC_SNAP_EN_SHIFT));
2052 2060
2053 pbd->ip_hlen_w = (skb_transport_header(skb) - 2061 pbd->ip_hlen_w = (skb_transport_header(skb) -
2054 skb_network_header(skb)) / 2; 2062 skb_network_header(skb)) >> 1;
2055 2063
2056 hlen += pbd->ip_hlen_w + tcp_hdrlen(skb) / 2; 2064 hlen += pbd->ip_hlen_w;
2065
2066 /* We support checksum offload for TCP and UDP only */
2067 if (xmit_type & XMIT_CSUM_TCP)
2068 hlen += tcp_hdrlen(skb) / 2;
2069 else
2070 hlen += sizeof(struct udphdr) / 2;
2057 2071
2058 pbd->total_hlen_w = cpu_to_le16(hlen); 2072 pbd->total_hlen_w = cpu_to_le16(hlen);
2059 hlen = hlen*2; 2073 hlen = hlen*2;
diff --git a/drivers/net/bnx2x/bnx2x_ethtool.c b/drivers/net/bnx2x/bnx2x_ethtool.c
index f5050155c6b5..89cb977898cb 100644
--- a/drivers/net/bnx2x/bnx2x_ethtool.c
+++ b/drivers/net/bnx2x/bnx2x_ethtool.c
@@ -2114,19 +2114,18 @@ static int bnx2x_phys_id(struct net_device *dev, u32 data)
2114 for (i = 0; i < (data * 2); i++) { 2114 for (i = 0; i < (data * 2); i++) {
2115 if ((i % 2) == 0) 2115 if ((i % 2) == 0)
2116 bnx2x_set_led(&bp->link_params, &bp->link_vars, 2116 bnx2x_set_led(&bp->link_params, &bp->link_vars,
2117 LED_MODE_OPER, SPEED_1000); 2117 LED_MODE_ON, SPEED_1000);
2118 else 2118 else
2119 bnx2x_set_led(&bp->link_params, &bp->link_vars, 2119 bnx2x_set_led(&bp->link_params, &bp->link_vars,
2120 LED_MODE_OFF, 0); 2120 LED_MODE_FRONT_PANEL_OFF, 0);
2121 2121
2122 msleep_interruptible(500); 2122 msleep_interruptible(500);
2123 if (signal_pending(current)) 2123 if (signal_pending(current))
2124 break; 2124 break;
2125 } 2125 }
2126 2126
2127 if (bp->link_vars.link_up) 2127 bnx2x_set_led(&bp->link_params, &bp->link_vars,
2128 bnx2x_set_led(&bp->link_params, &bp->link_vars, LED_MODE_OPER, 2128 LED_MODE_OPER, bp->link_vars.line_speed);
2129 bp->link_vars.line_speed);
2130 2129
2131 return 0; 2130 return 0;
2132} 2131}
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index 494bf960442d..31912f17653f 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -1482,8 +1482,11 @@ static struct aggregator *ad_agg_selection_test(struct aggregator *best,
1482 1482
1483static int agg_device_up(const struct aggregator *agg) 1483static int agg_device_up(const struct aggregator *agg)
1484{ 1484{
1485 return (netif_running(agg->slave->dev) && 1485 struct port *port = agg->lag_ports;
1486 netif_carrier_ok(agg->slave->dev)); 1486 if (!port)
1487 return 0;
1488 return (netif_running(port->slave->dev) &&
1489 netif_carrier_ok(port->slave->dev));
1487} 1490}
1488 1491
1489/** 1492/**
diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h
index b28baff70864..01b8a6af275b 100644
--- a/drivers/net/bonding/bond_3ad.h
+++ b/drivers/net/bonding/bond_3ad.h
@@ -39,7 +39,7 @@
39 39
40typedef struct mac_addr { 40typedef struct mac_addr {
41 u8 mac_addr_value[ETH_ALEN]; 41 u8 mac_addr_value[ETH_ALEN];
42} mac_addr_t; 42} __packed mac_addr_t;
43 43
44enum { 44enum {
45 BOND_AD_STABLE = 0, 45 BOND_AD_STABLE = 0,
@@ -134,12 +134,12 @@ typedef struct lacpdu {
134 u8 tlv_type_terminator; // = terminator 134 u8 tlv_type_terminator; // = terminator
135 u8 terminator_length; // = 0 135 u8 terminator_length; // = 0
136 u8 reserved_50[50]; // = 0 136 u8 reserved_50[50]; // = 0
137} lacpdu_t; 137} __packed lacpdu_t;
138 138
139typedef struct lacpdu_header { 139typedef struct lacpdu_header {
140 struct ethhdr hdr; 140 struct ethhdr hdr;
141 struct lacpdu lacpdu; 141 struct lacpdu lacpdu;
142} lacpdu_header_t; 142} __packed lacpdu_header_t;
143 143
144// Marker Protocol Data Unit(PDU) structure(43.5.3.2 in the 802.3ad standard) 144// Marker Protocol Data Unit(PDU) structure(43.5.3.2 in the 802.3ad standard)
145typedef struct bond_marker { 145typedef struct bond_marker {
@@ -155,12 +155,12 @@ typedef struct bond_marker {
155 u8 tlv_type_terminator; // = 0x00 155 u8 tlv_type_terminator; // = 0x00
156 u8 terminator_length; // = 0x00 156 u8 terminator_length; // = 0x00
157 u8 reserved_90[90]; // = 0 157 u8 reserved_90[90]; // = 0
158} bond_marker_t; 158} __packed bond_marker_t;
159 159
160typedef struct bond_marker_header { 160typedef struct bond_marker_header {
161 struct ethhdr hdr; 161 struct ethhdr hdr;
162 struct bond_marker marker; 162 struct bond_marker marker;
163} bond_marker_header_t; 163} __packed bond_marker_header_t;
164 164
165#pragma pack() 165#pragma pack()
166 166
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 9bc5de3e04a8..ba715826e2a8 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -176,7 +176,7 @@ static int tlb_initialize(struct bonding *bond)
176 bond_info->tx_hashtbl = new_hashtbl; 176 bond_info->tx_hashtbl = new_hashtbl;
177 177
178 for (i = 0; i < TLB_HASH_TABLE_SIZE; i++) { 178 for (i = 0; i < TLB_HASH_TABLE_SIZE; i++) {
179 tlb_init_table_entry(&bond_info->tx_hashtbl[i], 1); 179 tlb_init_table_entry(&bond_info->tx_hashtbl[i], 0);
180 } 180 }
181 181
182 _unlock_tx_hashtbl(bond); 182 _unlock_tx_hashtbl(bond);
@@ -701,7 +701,7 @@ static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond)
701 */ 701 */
702 rlb_choose_channel(skb, bond); 702 rlb_choose_channel(skb, bond);
703 703
704 /* The ARP relpy packets must be delayed so that 704 /* The ARP reply packets must be delayed so that
705 * they can cancel out the influence of the ARP request. 705 * they can cancel out the influence of the ARP request.
706 */ 706 */
707 bond->alb_info.rlb_update_delay_counter = RLB_UPDATE_DELAY; 707 bond->alb_info.rlb_update_delay_counter = RLB_UPDATE_DELAY;
@@ -1042,7 +1042,7 @@ static void alb_change_hw_addr_on_detach(struct bonding *bond, struct slave *sla
1042 * 1042 *
1043 * If the permanent hw address of @slave is @bond's hw address, we need to 1043 * If the permanent hw address of @slave is @bond's hw address, we need to
1044 * find a different hw address to give @slave, that isn't in use by any other 1044 * find a different hw address to give @slave, that isn't in use by any other
1045 * slave in the bond. This address must be, of course, one of the premanent 1045 * slave in the bond. This address must be, of course, one of the permanent
1046 * addresses of the other slaves. 1046 * addresses of the other slaves.
1047 * 1047 *
1048 * We go over the slave list, and for each slave there we compare its 1048 * We go over the slave list, and for each slave there we compare its
diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h
index 86861f08b24d..8ca7158b2dda 100644
--- a/drivers/net/bonding/bond_alb.h
+++ b/drivers/net/bonding/bond_alb.h
@@ -75,7 +75,7 @@ struct tlb_client_info {
75 * gave this entry index. 75 * gave this entry index.
76 */ 76 */
77 u32 tx_bytes; /* Each Client accumulates the BytesTx that 77 u32 tx_bytes; /* Each Client accumulates the BytesTx that
78 * were tranmitted to it, and after each 78 * were transmitted to it, and after each
79 * CallBack the LoadHistory is divided 79 * CallBack the LoadHistory is divided
80 * by the balance interval 80 * by the balance interval
81 */ 81 */
@@ -122,7 +122,6 @@ struct tlb_slave_info {
122}; 122};
123 123
124struct alb_bond_info { 124struct alb_bond_info {
125 struct timer_list alb_timer;
126 struct tlb_client_info *tx_hashtbl; /* Dynamically allocated */ 125 struct tlb_client_info *tx_hashtbl; /* Dynamically allocated */
127 spinlock_t tx_hashtbl_lock; 126 spinlock_t tx_hashtbl_lock;
128 u32 unbalanced_load; 127 u32 unbalanced_load;
@@ -140,7 +139,6 @@ struct alb_bond_info {
140 struct slave *next_rx_slave;/* next slave to be assigned 139 struct slave *next_rx_slave;/* next slave to be assigned
141 * to a new rx client for 140 * to a new rx client for
142 */ 141 */
143 u32 rlb_interval_counter;
144 u8 primary_is_promisc; /* boolean */ 142 u8 primary_is_promisc; /* boolean */
145 u32 rlb_promisc_timeout_counter;/* counts primary 143 u32 rlb_promisc_timeout_counter;/* counts primary
146 * promiscuity time 144 * promiscuity time
diff --git a/drivers/net/can/mscan/mpc5xxx_can.c b/drivers/net/can/mscan/mpc5xxx_can.c
index c0a1bc5b1435..5fedc3375562 100644
--- a/drivers/net/can/mscan/mpc5xxx_can.c
+++ b/drivers/net/can/mscan/mpc5xxx_can.c
@@ -247,8 +247,10 @@ static u32 __devinit mpc512x_can_get_clock(struct platform_device *ofdev,
247} 247}
248#endif /* CONFIG_PPC_MPC512x */ 248#endif /* CONFIG_PPC_MPC512x */
249 249
250static struct of_device_id mpc5xxx_can_table[];
250static int __devinit mpc5xxx_can_probe(struct platform_device *ofdev) 251static int __devinit mpc5xxx_can_probe(struct platform_device *ofdev)
251{ 252{
253 const struct of_device_id *match;
252 struct mpc5xxx_can_data *data; 254 struct mpc5xxx_can_data *data;
253 struct device_node *np = ofdev->dev.of_node; 255 struct device_node *np = ofdev->dev.of_node;
254 struct net_device *dev; 256 struct net_device *dev;
@@ -258,9 +260,10 @@ static int __devinit mpc5xxx_can_probe(struct platform_device *ofdev)
258 int irq, mscan_clksrc = 0; 260 int irq, mscan_clksrc = 0;
259 int err = -ENOMEM; 261 int err = -ENOMEM;
260 262
261 if (!ofdev->dev.of_match) 263 match = of_match_device(mpc5xxx_can_table, &ofdev->dev);
264 if (!match)
262 return -EINVAL; 265 return -EINVAL;
263 data = (struct mpc5xxx_can_data *)of_dev->dev.of_match->data; 266 data = match->data;
264 267
265 base = of_iomap(np, 0); 268 base = of_iomap(np, 0);
266 if (!base) { 269 if (!base) {
diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
index a358ea9445a2..f501bba1fc6f 100644
--- a/drivers/net/can/sja1000/sja1000.c
+++ b/drivers/net/can/sja1000/sja1000.c
@@ -346,10 +346,10 @@ static void sja1000_rx(struct net_device *dev)
346 | (priv->read_reg(priv, REG_ID2) >> 5); 346 | (priv->read_reg(priv, REG_ID2) >> 5);
347 } 347 }
348 348
349 cf->can_dlc = get_can_dlc(fi & 0x0F);
349 if (fi & FI_RTR) { 350 if (fi & FI_RTR) {
350 id |= CAN_RTR_FLAG; 351 id |= CAN_RTR_FLAG;
351 } else { 352 } else {
352 cf->can_dlc = get_can_dlc(fi & 0x0F);
353 for (i = 0; i < cf->can_dlc; i++) 353 for (i = 0; i < cf->can_dlc; i++)
354 cf->data[i] = priv->read_reg(priv, dreg++); 354 cf->data[i] = priv->read_reg(priv, dreg++);
355 } 355 }
diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
index b423965a78d1..1b49df6b2470 100644
--- a/drivers/net/can/slcan.c
+++ b/drivers/net/can/slcan.c
@@ -583,7 +583,9 @@ static int slcan_open(struct tty_struct *tty)
583 /* Done. We have linked the TTY line to a channel. */ 583 /* Done. We have linked the TTY line to a channel. */
584 rtnl_unlock(); 584 rtnl_unlock();
585 tty->receive_room = 65536; /* We don't flow control */ 585 tty->receive_room = 65536; /* We don't flow control */
586 return sl->dev->base_addr; 586
587 /* TTY layer expects 0 on success */
588 return 0;
587 589
588err_free_chan: 590err_free_chan:
589 sl->tty = NULL; 591 sl->tty = NULL;
diff --git a/drivers/net/ehea/ehea_ethtool.c b/drivers/net/ehea/ehea_ethtool.c
index 3e2e734fecb7..f3bbdcef338c 100644
--- a/drivers/net/ehea/ehea_ethtool.c
+++ b/drivers/net/ehea/ehea_ethtool.c
@@ -55,15 +55,20 @@ static int ehea_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
55 cmd->duplex = -1; 55 cmd->duplex = -1;
56 } 56 }
57 57
58 cmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_1000baseT_Full 58 if (cmd->speed == SPEED_10000) {
59 | SUPPORTED_100baseT_Full | SUPPORTED_100baseT_Half 59 cmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
60 | SUPPORTED_10baseT_Full | SUPPORTED_10baseT_Half 60 cmd->advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_FIBRE);
61 | SUPPORTED_Autoneg | SUPPORTED_FIBRE); 61 cmd->port = PORT_FIBRE;
62 62 } else {
63 cmd->advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_Autoneg 63 cmd->supported = (SUPPORTED_1000baseT_Full | SUPPORTED_100baseT_Full
64 | ADVERTISED_FIBRE); 64 | SUPPORTED_100baseT_Half | SUPPORTED_10baseT_Full
65 | SUPPORTED_10baseT_Half | SUPPORTED_Autoneg
66 | SUPPORTED_TP);
67 cmd->advertising = (ADVERTISED_1000baseT_Full | ADVERTISED_Autoneg
68 | ADVERTISED_TP);
69 cmd->port = PORT_TP;
70 }
65 71
66 cmd->port = PORT_FIBRE;
67 cmd->autoneg = port->autoneg == 1 ? AUTONEG_ENABLE : AUTONEG_DISABLE; 72 cmd->autoneg = port->autoneg == 1 ? AUTONEG_ENABLE : AUTONEG_DISABLE;
68 73
69 return 0; 74 return 0;
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index f75d3144b8a5..cf79cf759e13 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -2688,9 +2688,6 @@ static int ehea_open(struct net_device *dev)
2688 netif_start_queue(dev); 2688 netif_start_queue(dev);
2689 } 2689 }
2690 2690
2691 init_waitqueue_head(&port->swqe_avail_wq);
2692 init_waitqueue_head(&port->restart_wq);
2693
2694 mutex_unlock(&port->port_lock); 2691 mutex_unlock(&port->port_lock);
2695 2692
2696 return ret; 2693 return ret;
@@ -3040,11 +3037,14 @@ static void ehea_rereg_mrs(void)
3040 3037
3041 if (dev->flags & IFF_UP) { 3038 if (dev->flags & IFF_UP) {
3042 mutex_lock(&port->port_lock); 3039 mutex_lock(&port->port_lock);
3043 port_napi_enable(port);
3044 ret = ehea_restart_qps(dev); 3040 ret = ehea_restart_qps(dev);
3045 check_sqs(port); 3041 if (!ret) {
3046 if (!ret) 3042 check_sqs(port);
3043 port_napi_enable(port);
3047 netif_wake_queue(dev); 3044 netif_wake_queue(dev);
3045 } else {
3046 netdev_err(dev, "Unable to restart QPS\n");
3047 }
3048 mutex_unlock(&port->port_lock); 3048 mutex_unlock(&port->port_lock);
3049 } 3049 }
3050 } 3050 }
@@ -3273,6 +3273,9 @@ struct ehea_port *ehea_setup_single_port(struct ehea_adapter *adapter,
3273 3273
3274 INIT_WORK(&port->reset_task, ehea_reset_port); 3274 INIT_WORK(&port->reset_task, ehea_reset_port);
3275 3275
3276 init_waitqueue_head(&port->swqe_avail_wq);
3277 init_waitqueue_head(&port->restart_wq);
3278
3276 ret = register_netdev(dev); 3279 ret = register_netdev(dev);
3277 if (ret) { 3280 if (ret) {
3278 pr_err("register_netdev failed. ret=%d\n", ret); 3281 pr_err("register_netdev failed. ret=%d\n", ret);
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index 24cb953900dd..5131e61c358c 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -998,8 +998,10 @@ static const struct net_device_ops fs_enet_netdev_ops = {
998#endif 998#endif
999}; 999};
1000 1000
1001static struct of_device_id fs_enet_match[];
1001static int __devinit fs_enet_probe(struct platform_device *ofdev) 1002static int __devinit fs_enet_probe(struct platform_device *ofdev)
1002{ 1003{
1004 const struct of_device_id *match;
1003 struct net_device *ndev; 1005 struct net_device *ndev;
1004 struct fs_enet_private *fep; 1006 struct fs_enet_private *fep;
1005 struct fs_platform_info *fpi; 1007 struct fs_platform_info *fpi;
@@ -1007,14 +1009,15 @@ static int __devinit fs_enet_probe(struct platform_device *ofdev)
1007 const u8 *mac_addr; 1009 const u8 *mac_addr;
1008 int privsize, len, ret = -ENODEV; 1010 int privsize, len, ret = -ENODEV;
1009 1011
1010 if (!ofdev->dev.of_match) 1012 match = of_match_device(fs_enet_match, &ofdev->dev);
1013 if (!match)
1011 return -EINVAL; 1014 return -EINVAL;
1012 1015
1013 fpi = kzalloc(sizeof(*fpi), GFP_KERNEL); 1016 fpi = kzalloc(sizeof(*fpi), GFP_KERNEL);
1014 if (!fpi) 1017 if (!fpi)
1015 return -ENOMEM; 1018 return -ENOMEM;
1016 1019
1017 if (!IS_FEC(ofdev->dev.of_match)) { 1020 if (!IS_FEC(match)) {
1018 data = of_get_property(ofdev->dev.of_node, "fsl,cpm-command", &len); 1021 data = of_get_property(ofdev->dev.of_node, "fsl,cpm-command", &len);
1019 if (!data || len != 4) 1022 if (!data || len != 4)
1020 goto out_free_fpi; 1023 goto out_free_fpi;
@@ -1049,7 +1052,7 @@ static int __devinit fs_enet_probe(struct platform_device *ofdev)
1049 fep->dev = &ofdev->dev; 1052 fep->dev = &ofdev->dev;
1050 fep->ndev = ndev; 1053 fep->ndev = ndev;
1051 fep->fpi = fpi; 1054 fep->fpi = fpi;
1052 fep->ops = ofdev->dev.of_match->data; 1055 fep->ops = match->data;
1053 1056
1054 ret = fep->ops->setup_data(ndev); 1057 ret = fep->ops->setup_data(ndev);
1055 if (ret) 1058 if (ret)
diff --git a/drivers/net/fs_enet/mac-fec.c b/drivers/net/fs_enet/mac-fec.c
index 61035fc5599b..b9fbc83d64a7 100644
--- a/drivers/net/fs_enet/mac-fec.c
+++ b/drivers/net/fs_enet/mac-fec.c
@@ -226,8 +226,8 @@ static void set_multicast_finish(struct net_device *dev)
226 } 226 }
227 227
228 FC(fecp, r_cntrl, FEC_RCNTRL_PROM); 228 FC(fecp, r_cntrl, FEC_RCNTRL_PROM);
229 FW(fecp, hash_table_high, fep->fec.hthi); 229 FW(fecp, grp_hash_table_high, fep->fec.hthi);
230 FW(fecp, hash_table_low, fep->fec.htlo); 230 FW(fecp, grp_hash_table_low, fep->fec.htlo);
231} 231}
232 232
233static void set_multicast_list(struct net_device *dev) 233static void set_multicast_list(struct net_device *dev)
@@ -273,8 +273,8 @@ static void restart(struct net_device *dev)
273 /* 273 /*
274 * Reset all multicast. 274 * Reset all multicast.
275 */ 275 */
276 FW(fecp, hash_table_high, fep->fec.hthi); 276 FW(fecp, grp_hash_table_high, fep->fec.hthi);
277 FW(fecp, hash_table_low, fep->fec.htlo); 277 FW(fecp, grp_hash_table_low, fep->fec.htlo);
278 278
279 /* 279 /*
280 * Set maximum receive buffer size. 280 * Set maximum receive buffer size.
diff --git a/drivers/net/fs_enet/mii-fec.c b/drivers/net/fs_enet/mii-fec.c
index 7e840d373ab3..6a2e150e75bb 100644
--- a/drivers/net/fs_enet/mii-fec.c
+++ b/drivers/net/fs_enet/mii-fec.c
@@ -101,17 +101,20 @@ static int fs_enet_fec_mii_reset(struct mii_bus *bus)
101 return 0; 101 return 0;
102} 102}
103 103
104static struct of_device_id fs_enet_mdio_fec_match[];
104static int __devinit fs_enet_mdio_probe(struct platform_device *ofdev) 105static int __devinit fs_enet_mdio_probe(struct platform_device *ofdev)
105{ 106{
107 const struct of_device_id *match;
106 struct resource res; 108 struct resource res;
107 struct mii_bus *new_bus; 109 struct mii_bus *new_bus;
108 struct fec_info *fec; 110 struct fec_info *fec;
109 int (*get_bus_freq)(struct device_node *); 111 int (*get_bus_freq)(struct device_node *);
110 int ret = -ENOMEM, clock, speed; 112 int ret = -ENOMEM, clock, speed;
111 113
112 if (!ofdev->dev.of_match) 114 match = of_match_device(fs_enet_mdio_fec_match, &ofdev->dev);
115 if (!match)
113 return -EINVAL; 116 return -EINVAL;
114 get_bus_freq = ofdev->dev.of_match->data; 117 get_bus_freq = match->data;
115 118
116 new_bus = mdiobus_alloc(); 119 new_bus = mdiobus_alloc();
117 if (!new_bus) 120 if (!new_bus)
diff --git a/drivers/net/ftmac100.c b/drivers/net/ftmac100.c
index a31661948c42..9bd7746cbfcf 100644
--- a/drivers/net/ftmac100.c
+++ b/drivers/net/ftmac100.c
@@ -139,11 +139,11 @@ static int ftmac100_reset(struct ftmac100 *priv)
139 * that hardware reset completed (what the f*ck). 139 * that hardware reset completed (what the f*ck).
140 * We still need to wait for a while. 140 * We still need to wait for a while.
141 */ 141 */
142 usleep_range(500, 1000); 142 udelay(500);
143 return 0; 143 return 0;
144 } 144 }
145 145
146 usleep_range(1000, 10000); 146 udelay(1000);
147 } 147 }
148 148
149 netdev_err(netdev, "software reset failed\n"); 149 netdev_err(netdev, "software reset failed\n");
@@ -772,7 +772,7 @@ static int ftmac100_mdio_read(struct net_device *netdev, int phy_id, int reg)
772 if ((phycr & FTMAC100_PHYCR_MIIRD) == 0) 772 if ((phycr & FTMAC100_PHYCR_MIIRD) == 0)
773 return phycr & FTMAC100_PHYCR_MIIRDATA; 773 return phycr & FTMAC100_PHYCR_MIIRDATA;
774 774
775 usleep_range(100, 1000); 775 udelay(100);
776 } 776 }
777 777
778 netdev_err(netdev, "mdio read timed out\n"); 778 netdev_err(netdev, "mdio read timed out\n");
@@ -801,7 +801,7 @@ static void ftmac100_mdio_write(struct net_device *netdev, int phy_id, int reg,
801 if ((phycr & FTMAC100_PHYCR_MIIWR) == 0) 801 if ((phycr & FTMAC100_PHYCR_MIIWR) == 0)
802 return; 802 return;
803 803
804 usleep_range(100, 1000); 804 udelay(100);
805 } 805 }
806 806
807 netdev_err(netdev, "mdio write timed out\n"); 807 netdev_err(netdev, "mdio write timed out\n");
diff --git a/drivers/net/hydra.c b/drivers/net/hydra.c
index c5ef62ceb840..1cd481c04202 100644
--- a/drivers/net/hydra.c
+++ b/drivers/net/hydra.c
@@ -98,15 +98,15 @@ static const struct net_device_ops hydra_netdev_ops = {
98 .ndo_open = hydra_open, 98 .ndo_open = hydra_open,
99 .ndo_stop = hydra_close, 99 .ndo_stop = hydra_close,
100 100
101 .ndo_start_xmit = ei_start_xmit, 101 .ndo_start_xmit = __ei_start_xmit,
102 .ndo_tx_timeout = ei_tx_timeout, 102 .ndo_tx_timeout = __ei_tx_timeout,
103 .ndo_get_stats = ei_get_stats, 103 .ndo_get_stats = __ei_get_stats,
104 .ndo_set_multicast_list = ei_set_multicast_list, 104 .ndo_set_multicast_list = __ei_set_multicast_list,
105 .ndo_validate_addr = eth_validate_addr, 105 .ndo_validate_addr = eth_validate_addr,
106 .ndo_set_mac_address = eth_mac_addr, 106 .ndo_set_mac_address = eth_mac_addr,
107 .ndo_change_mtu = eth_change_mtu, 107 .ndo_change_mtu = eth_change_mtu,
108#ifdef CONFIG_NET_POLL_CONTROLLER 108#ifdef CONFIG_NET_POLL_CONTROLLER
109 .ndo_poll_controller = ei_poll, 109 .ndo_poll_controller = __ei_poll,
110#endif 110#endif
111}; 111};
112 112
@@ -125,7 +125,7 @@ static int __devinit hydra_init(struct zorro_dev *z)
125 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e, 125 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e,
126 }; 126 };
127 127
128 dev = alloc_ei_netdev(); 128 dev = ____alloc_ei_netdev(0);
129 if (!dev) 129 if (!dev)
130 return -ENOMEM; 130 return -ENOMEM;
131 131
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index ea0dc451da9c..d70fb76edb77 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -173,7 +173,8 @@ static void loopback_setup(struct net_device *dev)
173 | NETIF_F_RXCSUM 173 | NETIF_F_RXCSUM
174 | NETIF_F_HIGHDMA 174 | NETIF_F_HIGHDMA
175 | NETIF_F_LLTX 175 | NETIF_F_LLTX
176 | NETIF_F_NETNS_LOCAL; 176 | NETIF_F_NETNS_LOCAL
177 | NETIF_F_VLAN_CHALLENGED;
177 dev->ethtool_ops = &loopback_ethtool_ops; 178 dev->ethtool_ops = &loopback_ethtool_ops;
178 dev->header_ops = &eth_header_ops; 179 dev->header_ops = &eth_header_ops;
179 dev->netdev_ops = &loopback_ops; 180 dev->netdev_ops = &loopback_ops;
diff --git a/drivers/net/mii.c b/drivers/net/mii.c
index 0a6c6a2e7550..d4fc00b1ff93 100644
--- a/drivers/net/mii.c
+++ b/drivers/net/mii.c
@@ -49,6 +49,10 @@ static u32 mii_get_an(struct mii_if_info *mii, u16 addr)
49 result |= ADVERTISED_100baseT_Half; 49 result |= ADVERTISED_100baseT_Half;
50 if (advert & ADVERTISE_100FULL) 50 if (advert & ADVERTISE_100FULL)
51 result |= ADVERTISED_100baseT_Full; 51 result |= ADVERTISED_100baseT_Full;
52 if (advert & ADVERTISE_PAUSE_CAP)
53 result |= ADVERTISED_Pause;
54 if (advert & ADVERTISE_PAUSE_ASYM)
55 result |= ADVERTISED_Asym_Pause;
52 56
53 return result; 57 return result;
54} 58}
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
index aa2813e06d00..1074231f0a0d 100644
--- a/drivers/net/natsemi.c
+++ b/drivers/net/natsemi.c
@@ -860,6 +860,9 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
860 prev_eedata = eedata; 860 prev_eedata = eedata;
861 } 861 }
862 862
863 /* Store MAC Address in perm_addr */
864 memcpy(dev->perm_addr, dev->dev_addr, ETH_ALEN);
865
863 dev->base_addr = (unsigned long __force) ioaddr; 866 dev->base_addr = (unsigned long __force) ioaddr;
864 dev->irq = irq; 867 dev->irq = irq;
865 868
diff --git a/drivers/net/ne-h8300.c b/drivers/net/ne-h8300.c
index 30be8c634ebd..7298a34bc795 100644
--- a/drivers/net/ne-h8300.c
+++ b/drivers/net/ne-h8300.c
@@ -167,7 +167,7 @@ static void cleanup_card(struct net_device *dev)
167#ifndef MODULE 167#ifndef MODULE
168struct net_device * __init ne_probe(int unit) 168struct net_device * __init ne_probe(int unit)
169{ 169{
170 struct net_device *dev = alloc_ei_netdev(); 170 struct net_device *dev = ____alloc_ei_netdev(0);
171 int err; 171 int err;
172 172
173 if (!dev) 173 if (!dev)
@@ -197,15 +197,15 @@ static const struct net_device_ops ne_netdev_ops = {
197 .ndo_open = ne_open, 197 .ndo_open = ne_open,
198 .ndo_stop = ne_close, 198 .ndo_stop = ne_close,
199 199
200 .ndo_start_xmit = ei_start_xmit, 200 .ndo_start_xmit = __ei_start_xmit,
201 .ndo_tx_timeout = ei_tx_timeout, 201 .ndo_tx_timeout = __ei_tx_timeout,
202 .ndo_get_stats = ei_get_stats, 202 .ndo_get_stats = __ei_get_stats,
203 .ndo_set_multicast_list = ei_set_multicast_list, 203 .ndo_set_multicast_list = __ei_set_multicast_list,
204 .ndo_validate_addr = eth_validate_addr, 204 .ndo_validate_addr = eth_validate_addr,
205 .ndo_set_mac_address = eth_mac_addr, 205 .ndo_set_mac_address = eth_mac_addr,
206 .ndo_change_mtu = eth_change_mtu, 206 .ndo_change_mtu = eth_change_mtu,
207#ifdef CONFIG_NET_POLL_CONTROLLER 207#ifdef CONFIG_NET_POLL_CONTROLLER
208 .ndo_poll_controller = ei_poll, 208 .ndo_poll_controller = __ei_poll,
209#endif 209#endif
210}; 210};
211 211
@@ -637,7 +637,7 @@ int init_module(void)
637 int err; 637 int err;
638 638
639 for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) { 639 for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
640 struct net_device *dev = alloc_ei_netdev(); 640 struct net_device *dev = ____alloc_ei_netdev(0);
641 if (!dev) 641 if (!dev)
642 break; 642 break;
643 if (io[this_dev]) { 643 if (io[this_dev]) {
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index dfb67eb2a94b..eb41e44921e6 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -671,6 +671,7 @@ static int netconsole_netdev_event(struct notifier_block *this,
671 goto done; 671 goto done;
672 672
673 spin_lock_irqsave(&target_list_lock, flags); 673 spin_lock_irqsave(&target_list_lock, flags);
674restart:
674 list_for_each_entry(nt, &target_list, list) { 675 list_for_each_entry(nt, &target_list, list) {
675 netconsole_target_get(nt); 676 netconsole_target_get(nt);
676 if (nt->np.dev == dev) { 677 if (nt->np.dev == dev) {
@@ -683,9 +684,16 @@ static int netconsole_netdev_event(struct notifier_block *this,
683 * rtnl_lock already held 684 * rtnl_lock already held
684 */ 685 */
685 if (nt->np.dev) { 686 if (nt->np.dev) {
687 spin_unlock_irqrestore(
688 &target_list_lock,
689 flags);
686 __netpoll_cleanup(&nt->np); 690 __netpoll_cleanup(&nt->np);
691 spin_lock_irqsave(&target_list_lock,
692 flags);
687 dev_put(nt->np.dev); 693 dev_put(nt->np.dev);
688 nt->np.dev = NULL; 694 nt->np.dev = NULL;
695 netconsole_target_put(nt);
696 goto restart;
689 } 697 }
690 /* Fall through */ 698 /* Fall through */
691 case NETDEV_GOING_DOWN: 699 case NETDEV_GOING_DOWN:
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index d7299f1a4940..679dc8519c5b 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -174,7 +174,7 @@
174 174
175#define MAX_NUM_CARDS 4 175#define MAX_NUM_CARDS 4
176 176
177#define MAX_BUFFERS_PER_CMD 32 177#define NETXEN_MAX_FRAGS_PER_TX 14
178#define MAX_TSO_HEADER_DESC 2 178#define MAX_TSO_HEADER_DESC 2
179#define MGMT_CMD_DESC_RESV 4 179#define MGMT_CMD_DESC_RESV 4
180#define TX_STOP_THRESH ((MAX_SKB_FRAGS >> 2) + MAX_TSO_HEADER_DESC \ 180#define TX_STOP_THRESH ((MAX_SKB_FRAGS >> 2) + MAX_TSO_HEADER_DESC \
@@ -558,7 +558,7 @@ struct netxen_recv_crb {
558 */ 558 */
559struct netxen_cmd_buffer { 559struct netxen_cmd_buffer {
560 struct sk_buff *skb; 560 struct sk_buff *skb;
561 struct netxen_skb_frag frag_array[MAX_BUFFERS_PER_CMD + 1]; 561 struct netxen_skb_frag frag_array[MAX_SKB_FRAGS + 1];
562 u32 frag_count; 562 u32 frag_count;
563}; 563};
564 564
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 83348dc4b184..e8a4b6655999 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -1844,6 +1844,8 @@ netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1844 struct cmd_desc_type0 *hwdesc, *first_desc; 1844 struct cmd_desc_type0 *hwdesc, *first_desc;
1845 struct pci_dev *pdev; 1845 struct pci_dev *pdev;
1846 int i, k; 1846 int i, k;
1847 int delta = 0;
1848 struct skb_frag_struct *frag;
1847 1849
1848 u32 producer; 1850 u32 producer;
1849 int frag_count, no_of_desc; 1851 int frag_count, no_of_desc;
@@ -1851,6 +1853,21 @@ netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1851 1853
1852 frag_count = skb_shinfo(skb)->nr_frags + 1; 1854 frag_count = skb_shinfo(skb)->nr_frags + 1;
1853 1855
1856 /* 14 frags supported for normal packet and
1857 * 32 frags supported for TSO packet
1858 */
1859 if (!skb_is_gso(skb) && frag_count > NETXEN_MAX_FRAGS_PER_TX) {
1860
1861 for (i = 0; i < (frag_count - NETXEN_MAX_FRAGS_PER_TX); i++) {
1862 frag = &skb_shinfo(skb)->frags[i];
1863 delta += frag->size;
1864 }
1865
1866 if (!__pskb_pull_tail(skb, delta))
1867 goto drop_packet;
1868
1869 frag_count = 1 + skb_shinfo(skb)->nr_frags;
1870 }
1854 /* 4 fragments per cmd des */ 1871 /* 4 fragments per cmd des */
1855 no_of_desc = (frag_count + 3) >> 2; 1872 no_of_desc = (frag_count + 3) >> 2;
1856 1873
diff --git a/drivers/net/pch_gbe/pch_gbe_main.c b/drivers/net/pch_gbe/pch_gbe_main.c
index 2ef2f9cdefa6..56d049a472da 100644
--- a/drivers/net/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/pch_gbe/pch_gbe_main.c
@@ -34,6 +34,10 @@ const char pch_driver_version[] = DRV_VERSION;
34#define PCH_GBE_COPYBREAK_DEFAULT 256 34#define PCH_GBE_COPYBREAK_DEFAULT 256
35#define PCH_GBE_PCI_BAR 1 35#define PCH_GBE_PCI_BAR 1
36 36
37/* Macros for ML7223 */
38#define PCI_VENDOR_ID_ROHM 0x10db
39#define PCI_DEVICE_ID_ROHM_ML7223_GBE 0x8013
40
37#define PCH_GBE_TX_WEIGHT 64 41#define PCH_GBE_TX_WEIGHT 64
38#define PCH_GBE_RX_WEIGHT 64 42#define PCH_GBE_RX_WEIGHT 64
39#define PCH_GBE_RX_BUFFER_WRITE 16 43#define PCH_GBE_RX_BUFFER_WRITE 16
@@ -43,8 +47,7 @@ const char pch_driver_version[] = DRV_VERSION;
43 47
44#define PCH_GBE_MAC_RGMII_CTRL_SETTING ( \ 48#define PCH_GBE_MAC_RGMII_CTRL_SETTING ( \
45 PCH_GBE_CHIP_TYPE_INTERNAL | \ 49 PCH_GBE_CHIP_TYPE_INTERNAL | \
46 PCH_GBE_RGMII_MODE_RGMII | \ 50 PCH_GBE_RGMII_MODE_RGMII \
47 PCH_GBE_CRS_SEL \
48 ) 51 )
49 52
50/* Ethertype field values */ 53/* Ethertype field values */
@@ -1494,12 +1497,11 @@ pch_gbe_clean_rx(struct pch_gbe_adapter *adapter,
1494 /* Write meta date of skb */ 1497 /* Write meta date of skb */
1495 skb_put(skb, length); 1498 skb_put(skb, length);
1496 skb->protocol = eth_type_trans(skb, netdev); 1499 skb->protocol = eth_type_trans(skb, netdev);
1497 if ((tcp_ip_status & PCH_GBE_RXD_ACC_STAT_TCPIPOK) == 1500 if (tcp_ip_status & PCH_GBE_RXD_ACC_STAT_TCPIPOK)
1498 PCH_GBE_RXD_ACC_STAT_TCPIPOK) {
1499 skb->ip_summed = CHECKSUM_UNNECESSARY;
1500 } else {
1501 skb->ip_summed = CHECKSUM_NONE; 1501 skb->ip_summed = CHECKSUM_NONE;
1502 } 1502 else
1503 skb->ip_summed = CHECKSUM_UNNECESSARY;
1504
1503 napi_gro_receive(&adapter->napi, skb); 1505 napi_gro_receive(&adapter->napi, skb);
1504 (*work_done)++; 1506 (*work_done)++;
1505 pr_debug("Receive skb->ip_summed: %d length: %d\n", 1507 pr_debug("Receive skb->ip_summed: %d length: %d\n",
@@ -2420,6 +2422,13 @@ static DEFINE_PCI_DEVICE_TABLE(pch_gbe_pcidev_id) = {
2420 .class = (PCI_CLASS_NETWORK_ETHERNET << 8), 2422 .class = (PCI_CLASS_NETWORK_ETHERNET << 8),
2421 .class_mask = (0xFFFF00) 2423 .class_mask = (0xFFFF00)
2422 }, 2424 },
2425 {.vendor = PCI_VENDOR_ID_ROHM,
2426 .device = PCI_DEVICE_ID_ROHM_ML7223_GBE,
2427 .subvendor = PCI_ANY_ID,
2428 .subdevice = PCI_ANY_ID,
2429 .class = (PCI_CLASS_NETWORK_ETHERNET << 8),
2430 .class_mask = (0xFFFF00)
2431 },
2423 /* required last entry */ 2432 /* required last entry */
2424 {0} 2433 {0}
2425}; 2434};
diff --git a/drivers/net/qlcnic/qlcnic.h b/drivers/net/qlcnic/qlcnic.h
index dc44564ef6f9..b0dead00b2d1 100644
--- a/drivers/net/qlcnic/qlcnic.h
+++ b/drivers/net/qlcnic/qlcnic.h
@@ -99,6 +99,7 @@
99#define TX_UDPV6_PKT 0x0c 99#define TX_UDPV6_PKT 0x0c
100 100
101/* Tx defines */ 101/* Tx defines */
102#define QLCNIC_MAX_FRAGS_PER_TX 14
102#define MAX_TSO_HEADER_DESC 2 103#define MAX_TSO_HEADER_DESC 2
103#define MGMT_CMD_DESC_RESV 4 104#define MGMT_CMD_DESC_RESV 4
104#define TX_STOP_THRESH ((MAX_SKB_FRAGS >> 2) + MAX_TSO_HEADER_DESC \ 105#define TX_STOP_THRESH ((MAX_SKB_FRAGS >> 2) + MAX_TSO_HEADER_DESC \
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c
index cd88c7e1bfa9..cb1a1ef36c0a 100644
--- a/drivers/net/qlcnic/qlcnic_main.c
+++ b/drivers/net/qlcnic/qlcnic_main.c
@@ -2099,6 +2099,7 @@ qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2099 struct cmd_desc_type0 *hwdesc, *first_desc; 2099 struct cmd_desc_type0 *hwdesc, *first_desc;
2100 struct pci_dev *pdev; 2100 struct pci_dev *pdev;
2101 struct ethhdr *phdr; 2101 struct ethhdr *phdr;
2102 int delta = 0;
2102 int i, k; 2103 int i, k;
2103 2104
2104 u32 producer; 2105 u32 producer;
@@ -2118,6 +2119,19 @@ qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2118 } 2119 }
2119 2120
2120 frag_count = skb_shinfo(skb)->nr_frags + 1; 2121 frag_count = skb_shinfo(skb)->nr_frags + 1;
2122 /* 14 frags supported for normal packet and
2123 * 32 frags supported for TSO packet
2124 */
2125 if (!skb_is_gso(skb) && frag_count > QLCNIC_MAX_FRAGS_PER_TX) {
2126
2127 for (i = 0; i < (frag_count - QLCNIC_MAX_FRAGS_PER_TX); i++)
2128 delta += skb_shinfo(skb)->frags[i].size;
2129
2130 if (!__pskb_pull_tail(skb, delta))
2131 goto drop_packet;
2132
2133 frag_count = 1 + skb_shinfo(skb)->nr_frags;
2134 }
2121 2135
2122 /* 4 fragments per cmd des */ 2136 /* 4 fragments per cmd des */
2123 no_of_desc = (frag_count + 3) >> 2; 2137 no_of_desc = (frag_count + 3) >> 2;
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 493b0de3848b..397c36810a15 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -170,6 +170,16 @@ static const struct {
170}; 170};
171#undef _R 171#undef _R
172 172
173static const struct rtl_firmware_info {
174 int mac_version;
175 const char *fw_name;
176} rtl_firmware_infos[] = {
177 { .mac_version = RTL_GIGA_MAC_VER_25, .fw_name = FIRMWARE_8168D_1 },
178 { .mac_version = RTL_GIGA_MAC_VER_26, .fw_name = FIRMWARE_8168D_2 },
179 { .mac_version = RTL_GIGA_MAC_VER_29, .fw_name = FIRMWARE_8105E_1 },
180 { .mac_version = RTL_GIGA_MAC_VER_30, .fw_name = FIRMWARE_8105E_1 }
181};
182
173enum cfg_version { 183enum cfg_version {
174 RTL_CFG_0 = 0x00, 184 RTL_CFG_0 = 0x00,
175 RTL_CFG_1, 185 RTL_CFG_1,
@@ -565,6 +575,7 @@ struct rtl8169_private {
565 u32 saved_wolopts; 575 u32 saved_wolopts;
566 576
567 const struct firmware *fw; 577 const struct firmware *fw;
578#define RTL_FIRMWARE_UNKNOWN ERR_PTR(-EAGAIN);
568}; 579};
569 580
570MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@vger.kernel.org>"); 581MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@vger.kernel.org>");
@@ -1789,25 +1800,26 @@ rtl_phy_write_fw(struct rtl8169_private *tp, const struct firmware *fw)
1789 1800
1790static void rtl_release_firmware(struct rtl8169_private *tp) 1801static void rtl_release_firmware(struct rtl8169_private *tp)
1791{ 1802{
1792 release_firmware(tp->fw); 1803 if (!IS_ERR_OR_NULL(tp->fw))
1793 tp->fw = NULL; 1804 release_firmware(tp->fw);
1805 tp->fw = RTL_FIRMWARE_UNKNOWN;
1794} 1806}
1795 1807
1796static int rtl_apply_firmware(struct rtl8169_private *tp, const char *fw_name) 1808static void rtl_apply_firmware(struct rtl8169_private *tp)
1797{ 1809{
1798 const struct firmware **fw = &tp->fw; 1810 const struct firmware *fw = tp->fw;
1799 int rc = !*fw;
1800
1801 if (rc) {
1802 rc = request_firmware(fw, fw_name, &tp->pci_dev->dev);
1803 if (rc < 0)
1804 goto out;
1805 }
1806 1811
1807 /* TODO: release firmware once rtl_phy_write_fw signals failures. */ 1812 /* TODO: release firmware once rtl_phy_write_fw signals failures. */
1808 rtl_phy_write_fw(tp, *fw); 1813 if (!IS_ERR_OR_NULL(fw))
1809out: 1814 rtl_phy_write_fw(tp, fw);
1810 return rc; 1815}
1816
1817static void rtl_apply_firmware_cond(struct rtl8169_private *tp, u8 reg, u16 val)
1818{
1819 if (rtl_readphy(tp, reg) != val)
1820 netif_warn(tp, hw, tp->dev, "chipset not ready for firmware\n");
1821 else
1822 rtl_apply_firmware(tp);
1811} 1823}
1812 1824
1813static void rtl8169s_hw_phy_config(struct rtl8169_private *tp) 1825static void rtl8169s_hw_phy_config(struct rtl8169_private *tp)
@@ -2246,10 +2258,8 @@ static void rtl8168d_1_hw_phy_config(struct rtl8169_private *tp)
2246 2258
2247 rtl_writephy(tp, 0x1f, 0x0005); 2259 rtl_writephy(tp, 0x1f, 0x0005);
2248 rtl_writephy(tp, 0x05, 0x001b); 2260 rtl_writephy(tp, 0x05, 0x001b);
2249 if ((rtl_readphy(tp, 0x06) != 0xbf00) || 2261
2250 (rtl_apply_firmware(tp, FIRMWARE_8168D_1) < 0)) { 2262 rtl_apply_firmware_cond(tp, MII_EXPANSION, 0xbf00);
2251 netif_warn(tp, probe, tp->dev, "unable to apply firmware patch\n");
2252 }
2253 2263
2254 rtl_writephy(tp, 0x1f, 0x0000); 2264 rtl_writephy(tp, 0x1f, 0x0000);
2255} 2265}
@@ -2351,10 +2361,8 @@ static void rtl8168d_2_hw_phy_config(struct rtl8169_private *tp)
2351 2361
2352 rtl_writephy(tp, 0x1f, 0x0005); 2362 rtl_writephy(tp, 0x1f, 0x0005);
2353 rtl_writephy(tp, 0x05, 0x001b); 2363 rtl_writephy(tp, 0x05, 0x001b);
2354 if ((rtl_readphy(tp, 0x06) != 0xb300) || 2364
2355 (rtl_apply_firmware(tp, FIRMWARE_8168D_2) < 0)) { 2365 rtl_apply_firmware_cond(tp, MII_EXPANSION, 0xb300);
2356 netif_warn(tp, probe, tp->dev, "unable to apply firmware patch\n");
2357 }
2358 2366
2359 rtl_writephy(tp, 0x1f, 0x0000); 2367 rtl_writephy(tp, 0x1f, 0x0000);
2360} 2368}
@@ -2474,8 +2482,7 @@ static void rtl8105e_hw_phy_config(struct rtl8169_private *tp)
2474 rtl_writephy(tp, 0x18, 0x0310); 2482 rtl_writephy(tp, 0x18, 0x0310);
2475 msleep(100); 2483 msleep(100);
2476 2484
2477 if (rtl_apply_firmware(tp, FIRMWARE_8105E_1) < 0) 2485 rtl_apply_firmware(tp);
2478 netif_warn(tp, probe, tp->dev, "unable to apply firmware patch\n");
2479 2486
2480 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 2487 rtl_writephy_batch(tp, phy_reg_init, ARRAY_SIZE(phy_reg_init));
2481} 2488}
@@ -3237,6 +3244,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3237 tp->timer.data = (unsigned long) dev; 3244 tp->timer.data = (unsigned long) dev;
3238 tp->timer.function = rtl8169_phy_timer; 3245 tp->timer.function = rtl8169_phy_timer;
3239 3246
3247 tp->fw = RTL_FIRMWARE_UNKNOWN;
3248
3240 rc = register_netdev(dev); 3249 rc = register_netdev(dev);
3241 if (rc < 0) 3250 if (rc < 0)
3242 goto err_out_msi_4; 3251 goto err_out_msi_4;
@@ -3288,10 +3297,10 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev)
3288 3297
3289 cancel_delayed_work_sync(&tp->task); 3298 cancel_delayed_work_sync(&tp->task);
3290 3299
3291 rtl_release_firmware(tp);
3292
3293 unregister_netdev(dev); 3300 unregister_netdev(dev);
3294 3301
3302 rtl_release_firmware(tp);
3303
3295 if (pci_dev_run_wake(pdev)) 3304 if (pci_dev_run_wake(pdev))
3296 pm_runtime_get_noresume(&pdev->dev); 3305 pm_runtime_get_noresume(&pdev->dev);
3297 3306
@@ -3303,6 +3312,37 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev)
3303 pci_set_drvdata(pdev, NULL); 3312 pci_set_drvdata(pdev, NULL);
3304} 3313}
3305 3314
3315static void rtl_request_firmware(struct rtl8169_private *tp)
3316{
3317 int i;
3318
3319 /* Return early if the firmware is already loaded / cached. */
3320 if (!IS_ERR(tp->fw))
3321 goto out;
3322
3323 for (i = 0; i < ARRAY_SIZE(rtl_firmware_infos); i++) {
3324 const struct rtl_firmware_info *info = rtl_firmware_infos + i;
3325
3326 if (info->mac_version == tp->mac_version) {
3327 const char *name = info->fw_name;
3328 int rc;
3329
3330 rc = request_firmware(&tp->fw, name, &tp->pci_dev->dev);
3331 if (rc < 0) {
3332 netif_warn(tp, ifup, tp->dev, "unable to load "
3333 "firmware patch %s (%d)\n", name, rc);
3334 goto out_disable_request_firmware;
3335 }
3336 goto out;
3337 }
3338 }
3339
3340out_disable_request_firmware:
3341 tp->fw = NULL;
3342out:
3343 return;
3344}
3345
3306static int rtl8169_open(struct net_device *dev) 3346static int rtl8169_open(struct net_device *dev)
3307{ 3347{
3308 struct rtl8169_private *tp = netdev_priv(dev); 3348 struct rtl8169_private *tp = netdev_priv(dev);
@@ -3334,11 +3374,13 @@ static int rtl8169_open(struct net_device *dev)
3334 3374
3335 smp_mb(); 3375 smp_mb();
3336 3376
3377 rtl_request_firmware(tp);
3378
3337 retval = request_irq(dev->irq, rtl8169_interrupt, 3379 retval = request_irq(dev->irq, rtl8169_interrupt,
3338 (tp->features & RTL_FEATURE_MSI) ? 0 : IRQF_SHARED, 3380 (tp->features & RTL_FEATURE_MSI) ? 0 : IRQF_SHARED,
3339 dev->name, dev); 3381 dev->name, dev);
3340 if (retval < 0) 3382 if (retval < 0)
3341 goto err_release_ring_2; 3383 goto err_release_fw_2;
3342 3384
3343 napi_enable(&tp->napi); 3385 napi_enable(&tp->napi);
3344 3386
@@ -3359,7 +3401,8 @@ static int rtl8169_open(struct net_device *dev)
3359out: 3401out:
3360 return retval; 3402 return retval;
3361 3403
3362err_release_ring_2: 3404err_release_fw_2:
3405 rtl_release_firmware(tp);
3363 rtl8169_rx_clear(tp); 3406 rtl8169_rx_clear(tp);
3364err_free_rx_1: 3407err_free_rx_1:
3365 dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray, 3408 dma_free_coherent(&pdev->dev, R8169_RX_RING_BYTES, tp->RxDescArray,
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index d890679e4c4d..a3c2aab53de8 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -328,7 +328,8 @@ static int efx_poll(struct napi_struct *napi, int budget)
328 * processing to finish, then directly poll (and ack ) the eventq. 328 * processing to finish, then directly poll (and ack ) the eventq.
329 * Finally reenable NAPI and interrupts. 329 * Finally reenable NAPI and interrupts.
330 * 330 *
331 * Since we are touching interrupts the caller should hold the suspend lock 331 * This is for use only during a loopback self-test. It must not
332 * deliver any packets up the stack as this can result in deadlock.
332 */ 333 */
333void efx_process_channel_now(struct efx_channel *channel) 334void efx_process_channel_now(struct efx_channel *channel)
334{ 335{
@@ -336,6 +337,7 @@ void efx_process_channel_now(struct efx_channel *channel)
336 337
337 BUG_ON(channel->channel >= efx->n_channels); 338 BUG_ON(channel->channel >= efx->n_channels);
338 BUG_ON(!channel->enabled); 339 BUG_ON(!channel->enabled);
340 BUG_ON(!efx->loopback_selftest);
339 341
340 /* Disable interrupts and wait for ISRs to complete */ 342 /* Disable interrupts and wait for ISRs to complete */
341 efx_nic_disable_interrupts(efx); 343 efx_nic_disable_interrupts(efx);
@@ -1436,7 +1438,7 @@ static void efx_start_all(struct efx_nic *efx)
1436 * restart the transmit interface early so the watchdog timer stops */ 1438 * restart the transmit interface early so the watchdog timer stops */
1437 efx_start_port(efx); 1439 efx_start_port(efx);
1438 1440
1439 if (efx_dev_registered(efx)) 1441 if (efx_dev_registered(efx) && !efx->port_inhibited)
1440 netif_tx_wake_all_queues(efx->net_dev); 1442 netif_tx_wake_all_queues(efx->net_dev);
1441 1443
1442 efx_for_each_channel(channel, efx) 1444 efx_for_each_channel(channel, efx)
diff --git a/drivers/net/sfc/io.h b/drivers/net/sfc/io.h
index d9d8c2ef1074..cc978803d484 100644
--- a/drivers/net/sfc/io.h
+++ b/drivers/net/sfc/io.h
@@ -152,6 +152,7 @@ static inline void efx_reado(struct efx_nic *efx, efx_oword_t *value,
152 152
153 spin_lock_irqsave(&efx->biu_lock, flags); 153 spin_lock_irqsave(&efx->biu_lock, flags);
154 value->u32[0] = _efx_readd(efx, reg + 0); 154 value->u32[0] = _efx_readd(efx, reg + 0);
155 rmb();
155 value->u32[1] = _efx_readd(efx, reg + 4); 156 value->u32[1] = _efx_readd(efx, reg + 4);
156 value->u32[2] = _efx_readd(efx, reg + 8); 157 value->u32[2] = _efx_readd(efx, reg + 8);
157 value->u32[3] = _efx_readd(efx, reg + 12); 158 value->u32[3] = _efx_readd(efx, reg + 12);
@@ -174,6 +175,7 @@ static inline void efx_sram_readq(struct efx_nic *efx, void __iomem *membase,
174 value->u64[0] = (__force __le64)__raw_readq(membase + addr); 175 value->u64[0] = (__force __le64)__raw_readq(membase + addr);
175#else 176#else
176 value->u32[0] = (__force __le32)__raw_readl(membase + addr); 177 value->u32[0] = (__force __le32)__raw_readl(membase + addr);
178 rmb();
177 value->u32[1] = (__force __le32)__raw_readl(membase + addr + 4); 179 value->u32[1] = (__force __le32)__raw_readl(membase + addr + 4);
178#endif 180#endif
179 spin_unlock_irqrestore(&efx->biu_lock, flags); 181 spin_unlock_irqrestore(&efx->biu_lock, flags);
diff --git a/drivers/net/sfc/mcdi.c b/drivers/net/sfc/mcdi.c
index d98479030ef2..3dd45ed61f0a 100644
--- a/drivers/net/sfc/mcdi.c
+++ b/drivers/net/sfc/mcdi.c
@@ -50,6 +50,20 @@ static inline struct efx_mcdi_iface *efx_mcdi(struct efx_nic *efx)
50 return &nic_data->mcdi; 50 return &nic_data->mcdi;
51} 51}
52 52
53static inline void
54efx_mcdi_readd(struct efx_nic *efx, efx_dword_t *value, unsigned reg)
55{
56 struct siena_nic_data *nic_data = efx->nic_data;
57 value->u32[0] = (__force __le32)__raw_readl(nic_data->mcdi_smem + reg);
58}
59
60static inline void
61efx_mcdi_writed(struct efx_nic *efx, const efx_dword_t *value, unsigned reg)
62{
63 struct siena_nic_data *nic_data = efx->nic_data;
64 __raw_writel((__force u32)value->u32[0], nic_data->mcdi_smem + reg);
65}
66
53void efx_mcdi_init(struct efx_nic *efx) 67void efx_mcdi_init(struct efx_nic *efx)
54{ 68{
55 struct efx_mcdi_iface *mcdi; 69 struct efx_mcdi_iface *mcdi;
@@ -70,8 +84,8 @@ static void efx_mcdi_copyin(struct efx_nic *efx, unsigned cmd,
70 const u8 *inbuf, size_t inlen) 84 const u8 *inbuf, size_t inlen)
71{ 85{
72 struct efx_mcdi_iface *mcdi = efx_mcdi(efx); 86 struct efx_mcdi_iface *mcdi = efx_mcdi(efx);
73 unsigned pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU(efx); 87 unsigned pdu = MCDI_PDU(efx);
74 unsigned doorbell = FR_CZ_MC_TREG_SMEM + MCDI_DOORBELL(efx); 88 unsigned doorbell = MCDI_DOORBELL(efx);
75 unsigned int i; 89 unsigned int i;
76 efx_dword_t hdr; 90 efx_dword_t hdr;
77 u32 xflags, seqno; 91 u32 xflags, seqno;
@@ -92,30 +106,28 @@ static void efx_mcdi_copyin(struct efx_nic *efx, unsigned cmd,
92 MCDI_HEADER_SEQ, seqno, 106 MCDI_HEADER_SEQ, seqno,
93 MCDI_HEADER_XFLAGS, xflags); 107 MCDI_HEADER_XFLAGS, xflags);
94 108
95 efx_writed(efx, &hdr, pdu); 109 efx_mcdi_writed(efx, &hdr, pdu);
96 110
97 for (i = 0; i < inlen; i += 4) { 111 for (i = 0; i < inlen; i += 4)
98 _efx_writed(efx, *((__le32 *)(inbuf + i)), pdu + 4 + i); 112 efx_mcdi_writed(efx, (const efx_dword_t *)(inbuf + i),
99 /* use wmb() within loop to inhibit write combining */ 113 pdu + 4 + i);
100 wmb();
101 }
102 114
103 /* ring the doorbell with a distinctive value */ 115 /* ring the doorbell with a distinctive value */
104 _efx_writed(efx, (__force __le32) 0x45789abc, doorbell); 116 EFX_POPULATE_DWORD_1(hdr, EFX_DWORD_0, 0x45789abc);
105 wmb(); 117 efx_mcdi_writed(efx, &hdr, doorbell);
106} 118}
107 119
108static void efx_mcdi_copyout(struct efx_nic *efx, u8 *outbuf, size_t outlen) 120static void efx_mcdi_copyout(struct efx_nic *efx, u8 *outbuf, size_t outlen)
109{ 121{
110 struct efx_mcdi_iface *mcdi = efx_mcdi(efx); 122 struct efx_mcdi_iface *mcdi = efx_mcdi(efx);
111 unsigned int pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU(efx); 123 unsigned int pdu = MCDI_PDU(efx);
112 int i; 124 int i;
113 125
114 BUG_ON(atomic_read(&mcdi->state) == MCDI_STATE_QUIESCENT); 126 BUG_ON(atomic_read(&mcdi->state) == MCDI_STATE_QUIESCENT);
115 BUG_ON(outlen & 3 || outlen >= 0x100); 127 BUG_ON(outlen & 3 || outlen >= 0x100);
116 128
117 for (i = 0; i < outlen; i += 4) 129 for (i = 0; i < outlen; i += 4)
118 *((__le32 *)(outbuf + i)) = _efx_readd(efx, pdu + 4 + i); 130 efx_mcdi_readd(efx, (efx_dword_t *)(outbuf + i), pdu + 4 + i);
119} 131}
120 132
121static int efx_mcdi_poll(struct efx_nic *efx) 133static int efx_mcdi_poll(struct efx_nic *efx)
@@ -123,7 +135,7 @@ static int efx_mcdi_poll(struct efx_nic *efx)
123 struct efx_mcdi_iface *mcdi = efx_mcdi(efx); 135 struct efx_mcdi_iface *mcdi = efx_mcdi(efx);
124 unsigned int time, finish; 136 unsigned int time, finish;
125 unsigned int respseq, respcmd, error; 137 unsigned int respseq, respcmd, error;
126 unsigned int pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU(efx); 138 unsigned int pdu = MCDI_PDU(efx);
127 unsigned int rc, spins; 139 unsigned int rc, spins;
128 efx_dword_t reg; 140 efx_dword_t reg;
129 141
@@ -149,8 +161,7 @@ static int efx_mcdi_poll(struct efx_nic *efx)
149 161
150 time = get_seconds(); 162 time = get_seconds();
151 163
152 rmb(); 164 efx_mcdi_readd(efx, &reg, pdu);
153 efx_readd(efx, &reg, pdu);
154 165
155 /* All 1's indicates that shared memory is in reset (and is 166 /* All 1's indicates that shared memory is in reset (and is
156 * not a valid header). Wait for it to come out reset before 167 * not a valid header). Wait for it to come out reset before
@@ -177,7 +188,7 @@ static int efx_mcdi_poll(struct efx_nic *efx)
177 respseq, mcdi->seqno); 188 respseq, mcdi->seqno);
178 rc = EIO; 189 rc = EIO;
179 } else if (error) { 190 } else if (error) {
180 efx_readd(efx, &reg, pdu + 4); 191 efx_mcdi_readd(efx, &reg, pdu + 4);
181 switch (EFX_DWORD_FIELD(reg, EFX_DWORD_0)) { 192 switch (EFX_DWORD_FIELD(reg, EFX_DWORD_0)) {
182#define TRANSLATE_ERROR(name) \ 193#define TRANSLATE_ERROR(name) \
183 case MC_CMD_ERR_ ## name: \ 194 case MC_CMD_ERR_ ## name: \
@@ -211,21 +222,21 @@ out:
211/* Test and clear MC-rebooted flag for this port/function */ 222/* Test and clear MC-rebooted flag for this port/function */
212int efx_mcdi_poll_reboot(struct efx_nic *efx) 223int efx_mcdi_poll_reboot(struct efx_nic *efx)
213{ 224{
214 unsigned int addr = FR_CZ_MC_TREG_SMEM + MCDI_REBOOT_FLAG(efx); 225 unsigned int addr = MCDI_REBOOT_FLAG(efx);
215 efx_dword_t reg; 226 efx_dword_t reg;
216 uint32_t value; 227 uint32_t value;
217 228
218 if (efx_nic_rev(efx) < EFX_REV_SIENA_A0) 229 if (efx_nic_rev(efx) < EFX_REV_SIENA_A0)
219 return false; 230 return false;
220 231
221 efx_readd(efx, &reg, addr); 232 efx_mcdi_readd(efx, &reg, addr);
222 value = EFX_DWORD_FIELD(reg, EFX_DWORD_0); 233 value = EFX_DWORD_FIELD(reg, EFX_DWORD_0);
223 234
224 if (value == 0) 235 if (value == 0)
225 return 0; 236 return 0;
226 237
227 EFX_ZERO_DWORD(reg); 238 EFX_ZERO_DWORD(reg);
228 efx_writed(efx, &reg, addr); 239 efx_mcdi_writed(efx, &reg, addr);
229 240
230 if (value == MC_STATUS_DWORD_ASSERT) 241 if (value == MC_STATUS_DWORD_ASSERT)
231 return -EINTR; 242 return -EINTR;
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h
index 9ffa9a6b55a0..191a311da2dc 100644
--- a/drivers/net/sfc/net_driver.h
+++ b/drivers/net/sfc/net_driver.h
@@ -330,7 +330,6 @@ enum efx_rx_alloc_method {
330 * @eventq_mask: Event queue pointer mask 330 * @eventq_mask: Event queue pointer mask
331 * @eventq_read_ptr: Event queue read pointer 331 * @eventq_read_ptr: Event queue read pointer
332 * @last_eventq_read_ptr: Last event queue read pointer value. 332 * @last_eventq_read_ptr: Last event queue read pointer value.
333 * @magic_count: Event queue test event count
334 * @irq_count: Number of IRQs since last adaptive moderation decision 333 * @irq_count: Number of IRQs since last adaptive moderation decision
335 * @irq_mod_score: IRQ moderation score 334 * @irq_mod_score: IRQ moderation score
336 * @rx_alloc_level: Watermark based heuristic counter for pushing descriptors 335 * @rx_alloc_level: Watermark based heuristic counter for pushing descriptors
@@ -360,7 +359,6 @@ struct efx_channel {
360 unsigned int eventq_mask; 359 unsigned int eventq_mask;
361 unsigned int eventq_read_ptr; 360 unsigned int eventq_read_ptr;
362 unsigned int last_eventq_read_ptr; 361 unsigned int last_eventq_read_ptr;
363 unsigned int magic_count;
364 362
365 unsigned int irq_count; 363 unsigned int irq_count;
366 unsigned int irq_mod_score; 364 unsigned int irq_mod_score;
diff --git a/drivers/net/sfc/nic.c b/drivers/net/sfc/nic.c
index e8396614daf3..9b29a8d7c449 100644
--- a/drivers/net/sfc/nic.c
+++ b/drivers/net/sfc/nic.c
@@ -84,7 +84,8 @@ static inline void efx_write_buf_tbl(struct efx_nic *efx, efx_qword_t *value,
84static inline efx_qword_t *efx_event(struct efx_channel *channel, 84static inline efx_qword_t *efx_event(struct efx_channel *channel,
85 unsigned int index) 85 unsigned int index)
86{ 86{
87 return ((efx_qword_t *) (channel->eventq.addr)) + index; 87 return ((efx_qword_t *) (channel->eventq.addr)) +
88 (index & channel->eventq_mask);
88} 89}
89 90
90/* See if an event is present 91/* See if an event is present
@@ -673,7 +674,8 @@ void efx_nic_eventq_read_ack(struct efx_channel *channel)
673 efx_dword_t reg; 674 efx_dword_t reg;
674 struct efx_nic *efx = channel->efx; 675 struct efx_nic *efx = channel->efx;
675 676
676 EFX_POPULATE_DWORD_1(reg, FRF_AZ_EVQ_RPTR, channel->eventq_read_ptr); 677 EFX_POPULATE_DWORD_1(reg, FRF_AZ_EVQ_RPTR,
678 channel->eventq_read_ptr & channel->eventq_mask);
677 efx_writed_table(efx, &reg, efx->type->evq_rptr_tbl_base, 679 efx_writed_table(efx, &reg, efx->type->evq_rptr_tbl_base,
678 channel->channel); 680 channel->channel);
679} 681}
@@ -908,7 +910,7 @@ efx_handle_generated_event(struct efx_channel *channel, efx_qword_t *event)
908 910
909 code = EFX_QWORD_FIELD(*event, FSF_AZ_DRV_GEN_EV_MAGIC); 911 code = EFX_QWORD_FIELD(*event, FSF_AZ_DRV_GEN_EV_MAGIC);
910 if (code == EFX_CHANNEL_MAGIC_TEST(channel)) 912 if (code == EFX_CHANNEL_MAGIC_TEST(channel))
911 ++channel->magic_count; 913 ; /* ignore */
912 else if (code == EFX_CHANNEL_MAGIC_FILL(channel)) 914 else if (code == EFX_CHANNEL_MAGIC_FILL(channel))
913 /* The queue must be empty, so we won't receive any rx 915 /* The queue must be empty, so we won't receive any rx
914 * events, so efx_process_channel() won't refill the 916 * events, so efx_process_channel() won't refill the
@@ -1015,8 +1017,7 @@ int efx_nic_process_eventq(struct efx_channel *channel, int budget)
1015 /* Clear this event by marking it all ones */ 1017 /* Clear this event by marking it all ones */
1016 EFX_SET_QWORD(*p_event); 1018 EFX_SET_QWORD(*p_event);
1017 1019
1018 /* Increment read pointer */ 1020 ++read_ptr;
1019 read_ptr = (read_ptr + 1) & channel->eventq_mask;
1020 1021
1021 ev_code = EFX_QWORD_FIELD(event, FSF_AZ_EV_CODE); 1022 ev_code = EFX_QWORD_FIELD(event, FSF_AZ_EV_CODE);
1022 1023
@@ -1060,6 +1061,13 @@ out:
1060 return spent; 1061 return spent;
1061} 1062}
1062 1063
1064/* Check whether an event is present in the eventq at the current
1065 * read pointer. Only useful for self-test.
1066 */
1067bool efx_nic_event_present(struct efx_channel *channel)
1068{
1069 return efx_event_present(efx_event(channel, channel->eventq_read_ptr));
1070}
1063 1071
1064/* Allocate buffer table entries for event queue */ 1072/* Allocate buffer table entries for event queue */
1065int efx_nic_probe_eventq(struct efx_channel *channel) 1073int efx_nic_probe_eventq(struct efx_channel *channel)
@@ -1165,7 +1173,7 @@ static void efx_poll_flush_events(struct efx_nic *efx)
1165 struct efx_tx_queue *tx_queue; 1173 struct efx_tx_queue *tx_queue;
1166 struct efx_rx_queue *rx_queue; 1174 struct efx_rx_queue *rx_queue;
1167 unsigned int read_ptr = channel->eventq_read_ptr; 1175 unsigned int read_ptr = channel->eventq_read_ptr;
1168 unsigned int end_ptr = (read_ptr - 1) & channel->eventq_mask; 1176 unsigned int end_ptr = read_ptr + channel->eventq_mask - 1;
1169 1177
1170 do { 1178 do {
1171 efx_qword_t *event = efx_event(channel, read_ptr); 1179 efx_qword_t *event = efx_event(channel, read_ptr);
@@ -1205,7 +1213,7 @@ static void efx_poll_flush_events(struct efx_nic *efx)
1205 * it's ok to throw away every non-flush event */ 1213 * it's ok to throw away every non-flush event */
1206 EFX_SET_QWORD(*event); 1214 EFX_SET_QWORD(*event);
1207 1215
1208 read_ptr = (read_ptr + 1) & channel->eventq_mask; 1216 ++read_ptr;
1209 } while (read_ptr != end_ptr); 1217 } while (read_ptr != end_ptr);
1210 1218
1211 channel->eventq_read_ptr = read_ptr; 1219 channel->eventq_read_ptr = read_ptr;
@@ -1929,6 +1937,13 @@ void efx_nic_get_regs(struct efx_nic *efx, void *buf)
1929 1937
1930 size = min_t(size_t, table->step, 16); 1938 size = min_t(size_t, table->step, 16);
1931 1939
1940 if (table->offset >= efx->type->mem_map_size) {
1941 /* No longer mapped; return dummy data */
1942 memcpy(buf, "\xde\xc0\xad\xde", 4);
1943 buf += table->rows * size;
1944 continue;
1945 }
1946
1932 for (i = 0; i < table->rows; i++) { 1947 for (i = 0; i < table->rows; i++) {
1933 switch (table->step) { 1948 switch (table->step) {
1934 case 4: /* 32-bit register or SRAM */ 1949 case 4: /* 32-bit register or SRAM */
diff --git a/drivers/net/sfc/nic.h b/drivers/net/sfc/nic.h
index d9de1b647d41..d91701abd331 100644
--- a/drivers/net/sfc/nic.h
+++ b/drivers/net/sfc/nic.h
@@ -143,10 +143,12 @@ static inline struct falcon_board *falcon_board(struct efx_nic *efx)
143/** 143/**
144 * struct siena_nic_data - Siena NIC state 144 * struct siena_nic_data - Siena NIC state
145 * @mcdi: Management-Controller-to-Driver Interface 145 * @mcdi: Management-Controller-to-Driver Interface
146 * @mcdi_smem: MCDI shared memory mapping. The mapping is always uncacheable.
146 * @wol_filter_id: Wake-on-LAN packet filter id 147 * @wol_filter_id: Wake-on-LAN packet filter id
147 */ 148 */
148struct siena_nic_data { 149struct siena_nic_data {
149 struct efx_mcdi_iface mcdi; 150 struct efx_mcdi_iface mcdi;
151 void __iomem *mcdi_smem;
150 int wol_filter_id; 152 int wol_filter_id;
151}; 153};
152 154
@@ -184,6 +186,7 @@ extern void efx_nic_fini_eventq(struct efx_channel *channel);
184extern void efx_nic_remove_eventq(struct efx_channel *channel); 186extern void efx_nic_remove_eventq(struct efx_channel *channel);
185extern int efx_nic_process_eventq(struct efx_channel *channel, int rx_quota); 187extern int efx_nic_process_eventq(struct efx_channel *channel, int rx_quota);
186extern void efx_nic_eventq_read_ack(struct efx_channel *channel); 188extern void efx_nic_eventq_read_ack(struct efx_channel *channel);
189extern bool efx_nic_event_present(struct efx_channel *channel);
187 190
188/* MAC/PHY */ 191/* MAC/PHY */
189extern void falcon_drain_tx_fifo(struct efx_nic *efx); 192extern void falcon_drain_tx_fifo(struct efx_nic *efx);
diff --git a/drivers/net/sfc/selftest.c b/drivers/net/sfc/selftest.c
index a0f49b348d62..50ad3bcaf68a 100644
--- a/drivers/net/sfc/selftest.c
+++ b/drivers/net/sfc/selftest.c
@@ -131,8 +131,6 @@ static int efx_test_chip(struct efx_nic *efx, struct efx_self_tests *tests)
131static int efx_test_interrupts(struct efx_nic *efx, 131static int efx_test_interrupts(struct efx_nic *efx,
132 struct efx_self_tests *tests) 132 struct efx_self_tests *tests)
133{ 133{
134 struct efx_channel *channel;
135
136 netif_dbg(efx, drv, efx->net_dev, "testing interrupts\n"); 134 netif_dbg(efx, drv, efx->net_dev, "testing interrupts\n");
137 tests->interrupt = -1; 135 tests->interrupt = -1;
138 136
@@ -140,15 +138,6 @@ static int efx_test_interrupts(struct efx_nic *efx,
140 efx->last_irq_cpu = -1; 138 efx->last_irq_cpu = -1;
141 smp_wmb(); 139 smp_wmb();
142 140
143 /* ACK each interrupting event queue. Receiving an interrupt due to
144 * traffic before a test event is raised is considered a pass */
145 efx_for_each_channel(channel, efx) {
146 if (channel->work_pending)
147 efx_process_channel_now(channel);
148 if (efx->last_irq_cpu >= 0)
149 goto success;
150 }
151
152 efx_nic_generate_interrupt(efx); 141 efx_nic_generate_interrupt(efx);
153 142
154 /* Wait for arrival of test interrupt. */ 143 /* Wait for arrival of test interrupt. */
@@ -173,13 +162,13 @@ static int efx_test_eventq_irq(struct efx_channel *channel,
173 struct efx_self_tests *tests) 162 struct efx_self_tests *tests)
174{ 163{
175 struct efx_nic *efx = channel->efx; 164 struct efx_nic *efx = channel->efx;
176 unsigned int magic_count, count; 165 unsigned int read_ptr, count;
177 166
178 tests->eventq_dma[channel->channel] = -1; 167 tests->eventq_dma[channel->channel] = -1;
179 tests->eventq_int[channel->channel] = -1; 168 tests->eventq_int[channel->channel] = -1;
180 tests->eventq_poll[channel->channel] = -1; 169 tests->eventq_poll[channel->channel] = -1;
181 170
182 magic_count = channel->magic_count; 171 read_ptr = channel->eventq_read_ptr;
183 channel->efx->last_irq_cpu = -1; 172 channel->efx->last_irq_cpu = -1;
184 smp_wmb(); 173 smp_wmb();
185 174
@@ -190,10 +179,7 @@ static int efx_test_eventq_irq(struct efx_channel *channel,
190 do { 179 do {
191 schedule_timeout_uninterruptible(HZ / 100); 180 schedule_timeout_uninterruptible(HZ / 100);
192 181
193 if (channel->work_pending) 182 if (ACCESS_ONCE(channel->eventq_read_ptr) != read_ptr)
194 efx_process_channel_now(channel);
195
196 if (channel->magic_count != magic_count)
197 goto eventq_ok; 183 goto eventq_ok;
198 } while (++count < 2); 184 } while (++count < 2);
199 185
@@ -211,8 +197,7 @@ static int efx_test_eventq_irq(struct efx_channel *channel,
211 } 197 }
212 198
213 /* Check to see if event was received even if interrupt wasn't */ 199 /* Check to see if event was received even if interrupt wasn't */
214 efx_process_channel_now(channel); 200 if (efx_nic_event_present(channel)) {
215 if (channel->magic_count != magic_count) {
216 netif_err(efx, drv, efx->net_dev, 201 netif_err(efx, drv, efx->net_dev,
217 "channel %d event was generated, but " 202 "channel %d event was generated, but "
218 "failed to trigger an interrupt\n", channel->channel); 203 "failed to trigger an interrupt\n", channel->channel);
@@ -770,6 +755,8 @@ int efx_selftest(struct efx_nic *efx, struct efx_self_tests *tests,
770 __efx_reconfigure_port(efx); 755 __efx_reconfigure_port(efx);
771 mutex_unlock(&efx->mac_lock); 756 mutex_unlock(&efx->mac_lock);
772 757
758 netif_tx_wake_all_queues(efx->net_dev);
759
773 return rc_test; 760 return rc_test;
774} 761}
775 762
diff --git a/drivers/net/sfc/siena.c b/drivers/net/sfc/siena.c
index e4dd8986b1fe..837869b71db9 100644
--- a/drivers/net/sfc/siena.c
+++ b/drivers/net/sfc/siena.c
@@ -220,12 +220,26 @@ static int siena_probe_nic(struct efx_nic *efx)
220 efx_reado(efx, &reg, FR_AZ_CS_DEBUG); 220 efx_reado(efx, &reg, FR_AZ_CS_DEBUG);
221 efx->net_dev->dev_id = EFX_OWORD_FIELD(reg, FRF_CZ_CS_PORT_NUM) - 1; 221 efx->net_dev->dev_id = EFX_OWORD_FIELD(reg, FRF_CZ_CS_PORT_NUM) - 1;
222 222
223 /* Initialise MCDI */
224 nic_data->mcdi_smem = ioremap_nocache(efx->membase_phys +
225 FR_CZ_MC_TREG_SMEM,
226 FR_CZ_MC_TREG_SMEM_STEP *
227 FR_CZ_MC_TREG_SMEM_ROWS);
228 if (!nic_data->mcdi_smem) {
229 netif_err(efx, probe, efx->net_dev,
230 "could not map MCDI at %llx+%x\n",
231 (unsigned long long)efx->membase_phys +
232 FR_CZ_MC_TREG_SMEM,
233 FR_CZ_MC_TREG_SMEM_STEP * FR_CZ_MC_TREG_SMEM_ROWS);
234 rc = -ENOMEM;
235 goto fail1;
236 }
223 efx_mcdi_init(efx); 237 efx_mcdi_init(efx);
224 238
225 /* Recover from a failed assertion before probing */ 239 /* Recover from a failed assertion before probing */
226 rc = efx_mcdi_handle_assertion(efx); 240 rc = efx_mcdi_handle_assertion(efx);
227 if (rc) 241 if (rc)
228 goto fail1; 242 goto fail2;
229 243
230 /* Let the BMC know that the driver is now in charge of link and 244 /* Let the BMC know that the driver is now in charge of link and
231 * filter settings. We must do this before we reset the NIC */ 245 * filter settings. We must do this before we reset the NIC */
@@ -280,6 +294,7 @@ fail4:
280fail3: 294fail3:
281 efx_mcdi_drv_attach(efx, false, NULL); 295 efx_mcdi_drv_attach(efx, false, NULL);
282fail2: 296fail2:
297 iounmap(nic_data->mcdi_smem);
283fail1: 298fail1:
284 kfree(efx->nic_data); 299 kfree(efx->nic_data);
285 return rc; 300 return rc;
@@ -359,6 +374,8 @@ static int siena_init_nic(struct efx_nic *efx)
359 374
360static void siena_remove_nic(struct efx_nic *efx) 375static void siena_remove_nic(struct efx_nic *efx)
361{ 376{
377 struct siena_nic_data *nic_data = efx->nic_data;
378
362 efx_nic_free_buffer(efx, &efx->irq_status); 379 efx_nic_free_buffer(efx, &efx->irq_status);
363 380
364 siena_reset_hw(efx, RESET_TYPE_ALL); 381 siena_reset_hw(efx, RESET_TYPE_ALL);
@@ -368,7 +385,8 @@ static void siena_remove_nic(struct efx_nic *efx)
368 efx_mcdi_drv_attach(efx, false, NULL); 385 efx_mcdi_drv_attach(efx, false, NULL);
369 386
370 /* Tear down the private nic state */ 387 /* Tear down the private nic state */
371 kfree(efx->nic_data); 388 iounmap(nic_data->mcdi_smem);
389 kfree(nic_data);
372 efx->nic_data = NULL; 390 efx->nic_data = NULL;
373} 391}
374 392
@@ -606,8 +624,7 @@ struct efx_nic_type siena_a0_nic_type = {
606 .default_mac_ops = &efx_mcdi_mac_operations, 624 .default_mac_ops = &efx_mcdi_mac_operations,
607 625
608 .revision = EFX_REV_SIENA_A0, 626 .revision = EFX_REV_SIENA_A0,
609 .mem_map_size = (FR_CZ_MC_TREG_SMEM + 627 .mem_map_size = FR_CZ_MC_TREG_SMEM, /* MC_TREG_SMEM mapped separately */
610 FR_CZ_MC_TREG_SMEM_STEP * FR_CZ_MC_TREG_SMEM_ROWS),
611 .txd_ptr_tbl_base = FR_BZ_TX_DESC_PTR_TBL, 628 .txd_ptr_tbl_base = FR_BZ_TX_DESC_PTR_TBL,
612 .rxd_ptr_tbl_base = FR_BZ_RX_DESC_PTR_TBL, 629 .rxd_ptr_tbl_base = FR_BZ_RX_DESC_PTR_TBL,
613 .buf_tbl_base = FR_BZ_BUF_FULL_TBL, 630 .buf_tbl_base = FR_BZ_BUF_FULL_TBL,
diff --git a/drivers/net/sfc/tx.c b/drivers/net/sfc/tx.c
index 139801908217..d2c85dfdf3bf 100644
--- a/drivers/net/sfc/tx.c
+++ b/drivers/net/sfc/tx.c
@@ -435,7 +435,8 @@ void efx_xmit_done(struct efx_tx_queue *tx_queue, unsigned int index)
435 * queue state. */ 435 * queue state. */
436 smp_mb(); 436 smp_mb();
437 if (unlikely(netif_tx_queue_stopped(tx_queue->core_txq)) && 437 if (unlikely(netif_tx_queue_stopped(tx_queue->core_txq)) &&
438 likely(efx->port_enabled)) { 438 likely(efx->port_enabled) &&
439 likely(!efx->port_inhibited)) {
439 fill_level = tx_queue->insert_count - tx_queue->read_count; 440 fill_level = tx_queue->insert_count - tx_queue->read_count;
440 if (fill_level < EFX_TXQ_THRESHOLD(efx)) { 441 if (fill_level < EFX_TXQ_THRESHOLD(efx)) {
441 EFX_BUG_ON_PARANOID(!efx_dev_registered(efx)); 442 EFX_BUG_ON_PARANOID(!efx_dev_registered(efx));
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c
index cb317cd069ff..484f795a779d 100644
--- a/drivers/net/sis900.c
+++ b/drivers/net/sis900.c
@@ -240,7 +240,8 @@ static const struct ethtool_ops sis900_ethtool_ops;
240 * @net_dev: the net device to get address for 240 * @net_dev: the net device to get address for
241 * 241 *
242 * Older SiS900 and friends, use EEPROM to store MAC address. 242 * Older SiS900 and friends, use EEPROM to store MAC address.
243 * MAC address is read from read_eeprom() into @net_dev->dev_addr. 243 * MAC address is read from read_eeprom() into @net_dev->dev_addr and
244 * @net_dev->perm_addr.
244 */ 245 */
245 246
246static int __devinit sis900_get_mac_addr(struct pci_dev * pci_dev, struct net_device *net_dev) 247static int __devinit sis900_get_mac_addr(struct pci_dev * pci_dev, struct net_device *net_dev)
@@ -261,6 +262,9 @@ static int __devinit sis900_get_mac_addr(struct pci_dev * pci_dev, struct net_de
261 for (i = 0; i < 3; i++) 262 for (i = 0; i < 3; i++)
262 ((u16 *)(net_dev->dev_addr))[i] = read_eeprom(ioaddr, i+EEPROMMACAddr); 263 ((u16 *)(net_dev->dev_addr))[i] = read_eeprom(ioaddr, i+EEPROMMACAddr);
263 264
265 /* Store MAC Address in perm_addr */
266 memcpy(net_dev->perm_addr, net_dev->dev_addr, ETH_ALEN);
267
264 return 1; 268 return 1;
265} 269}
266 270
@@ -271,7 +275,8 @@ static int __devinit sis900_get_mac_addr(struct pci_dev * pci_dev, struct net_de
271 * 275 *
272 * SiS630E model, use APC CMOS RAM to store MAC address. 276 * SiS630E model, use APC CMOS RAM to store MAC address.
273 * APC CMOS RAM is accessed through ISA bridge. 277 * APC CMOS RAM is accessed through ISA bridge.
274 * MAC address is read into @net_dev->dev_addr. 278 * MAC address is read into @net_dev->dev_addr and
279 * @net_dev->perm_addr.
275 */ 280 */
276 281
277static int __devinit sis630e_get_mac_addr(struct pci_dev * pci_dev, 282static int __devinit sis630e_get_mac_addr(struct pci_dev * pci_dev,
@@ -296,6 +301,10 @@ static int __devinit sis630e_get_mac_addr(struct pci_dev * pci_dev,
296 outb(0x09 + i, 0x70); 301 outb(0x09 + i, 0x70);
297 ((u8 *)(net_dev->dev_addr))[i] = inb(0x71); 302 ((u8 *)(net_dev->dev_addr))[i] = inb(0x71);
298 } 303 }
304
305 /* Store MAC Address in perm_addr */
306 memcpy(net_dev->perm_addr, net_dev->dev_addr, ETH_ALEN);
307
299 pci_write_config_byte(isa_bridge, 0x48, reg & ~0x40); 308 pci_write_config_byte(isa_bridge, 0x48, reg & ~0x40);
300 pci_dev_put(isa_bridge); 309 pci_dev_put(isa_bridge);
301 310
@@ -310,7 +319,7 @@ static int __devinit sis630e_get_mac_addr(struct pci_dev * pci_dev,
310 * 319 *
311 * SiS635 model, set MAC Reload Bit to load Mac address from APC 320 * SiS635 model, set MAC Reload Bit to load Mac address from APC
312 * to rfdr. rfdr is accessed through rfcr. MAC address is read into 321 * to rfdr. rfdr is accessed through rfcr. MAC address is read into
313 * @net_dev->dev_addr. 322 * @net_dev->dev_addr and @net_dev->perm_addr.
314 */ 323 */
315 324
316static int __devinit sis635_get_mac_addr(struct pci_dev * pci_dev, 325static int __devinit sis635_get_mac_addr(struct pci_dev * pci_dev,
@@ -334,6 +343,9 @@ static int __devinit sis635_get_mac_addr(struct pci_dev * pci_dev,
334 *( ((u16 *)net_dev->dev_addr) + i) = inw(ioaddr + rfdr); 343 *( ((u16 *)net_dev->dev_addr) + i) = inw(ioaddr + rfdr);
335 } 344 }
336 345
346 /* Store MAC Address in perm_addr */
347 memcpy(net_dev->perm_addr, net_dev->dev_addr, ETH_ALEN);
348
337 /* enable packet filtering */ 349 /* enable packet filtering */
338 outl(rfcrSave | RFEN, rfcr + ioaddr); 350 outl(rfcrSave | RFEN, rfcr + ioaddr);
339 351
@@ -353,7 +365,7 @@ static int __devinit sis635_get_mac_addr(struct pci_dev * pci_dev,
353 * EEDONE signal to refuse EEPROM access by LAN. 365 * EEDONE signal to refuse EEPROM access by LAN.
354 * The EEPROM map of SiS962 or SiS963 is different to SiS900. 366 * The EEPROM map of SiS962 or SiS963 is different to SiS900.
355 * The signature field in SiS962 or SiS963 spec is meaningless. 367 * The signature field in SiS962 or SiS963 spec is meaningless.
356 * MAC address is read into @net_dev->dev_addr. 368 * MAC address is read into @net_dev->dev_addr and @net_dev->perm_addr.
357 */ 369 */
358 370
359static int __devinit sis96x_get_mac_addr(struct pci_dev * pci_dev, 371static int __devinit sis96x_get_mac_addr(struct pci_dev * pci_dev,
@@ -372,6 +384,9 @@ static int __devinit sis96x_get_mac_addr(struct pci_dev * pci_dev,
372 for (i = 0; i < 3; i++) 384 for (i = 0; i < 3; i++)
373 ((u16 *)(net_dev->dev_addr))[i] = read_eeprom(ioaddr, i+EEPROMMACAddr); 385 ((u16 *)(net_dev->dev_addr))[i] = read_eeprom(ioaddr, i+EEPROMMACAddr);
374 386
387 /* Store MAC Address in perm_addr */
388 memcpy(net_dev->perm_addr, net_dev->dev_addr, ETH_ALEN);
389
375 outl(EEDONE, ee_addr); 390 outl(EEDONE, ee_addr);
376 return 1; 391 return 1;
377 } else { 392 } else {
diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index 86cbb9ea2f26..8ec1a9a0bb9a 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -853,7 +853,9 @@ static int slip_open(struct tty_struct *tty)
853 /* Done. We have linked the TTY line to a channel. */ 853 /* Done. We have linked the TTY line to a channel. */
854 rtnl_unlock(); 854 rtnl_unlock();
855 tty->receive_room = 65536; /* We don't flow control */ 855 tty->receive_room = 65536; /* We don't flow control */
856 return sl->dev->base_addr; 856
857 /* TTY layer expects 0 on success */
858 return 0;
857 859
858err_free_bufs: 860err_free_bufs:
859 sl_free_bufs(sl); 861 sl_free_bufs(sl);
diff --git a/drivers/net/stmmac/dwmac_lib.c b/drivers/net/stmmac/dwmac_lib.c
index d65fab1ba790..e25093510b0c 100644
--- a/drivers/net/stmmac/dwmac_lib.c
+++ b/drivers/net/stmmac/dwmac_lib.c
@@ -26,9 +26,9 @@
26 26
27#undef DWMAC_DMA_DEBUG 27#undef DWMAC_DMA_DEBUG
28#ifdef DWMAC_DMA_DEBUG 28#ifdef DWMAC_DMA_DEBUG
29#define DBG(fmt, args...) printk(fmt, ## args) 29#define DWMAC_LIB_DBG(fmt, args...) printk(fmt, ## args)
30#else 30#else
31#define DBG(fmt, args...) do { } while (0) 31#define DWMAC_LIB_DBG(fmt, args...) do { } while (0)
32#endif 32#endif
33 33
34/* CSR1 enables the transmit DMA to check for new descriptor */ 34/* CSR1 enables the transmit DMA to check for new descriptor */
@@ -152,7 +152,7 @@ int dwmac_dma_interrupt(void __iomem *ioaddr,
152 /* read the status register (CSR5) */ 152 /* read the status register (CSR5) */
153 u32 intr_status = readl(ioaddr + DMA_STATUS); 153 u32 intr_status = readl(ioaddr + DMA_STATUS);
154 154
155 DBG(INFO, "%s: [CSR5: 0x%08x]\n", __func__, intr_status); 155 DWMAC_LIB_DBG(KERN_INFO "%s: [CSR5: 0x%08x]\n", __func__, intr_status);
156#ifdef DWMAC_DMA_DEBUG 156#ifdef DWMAC_DMA_DEBUG
157 /* It displays the DMA process states (CSR5 register) */ 157 /* It displays the DMA process states (CSR5 register) */
158 show_tx_process_state(intr_status); 158 show_tx_process_state(intr_status);
@@ -160,43 +160,43 @@ int dwmac_dma_interrupt(void __iomem *ioaddr,
160#endif 160#endif
161 /* ABNORMAL interrupts */ 161 /* ABNORMAL interrupts */
162 if (unlikely(intr_status & DMA_STATUS_AIS)) { 162 if (unlikely(intr_status & DMA_STATUS_AIS)) {
163 DBG(INFO, "CSR5[15] DMA ABNORMAL IRQ: "); 163 DWMAC_LIB_DBG(KERN_INFO "CSR5[15] DMA ABNORMAL IRQ: ");
164 if (unlikely(intr_status & DMA_STATUS_UNF)) { 164 if (unlikely(intr_status & DMA_STATUS_UNF)) {
165 DBG(INFO, "transmit underflow\n"); 165 DWMAC_LIB_DBG(KERN_INFO "transmit underflow\n");
166 ret = tx_hard_error_bump_tc; 166 ret = tx_hard_error_bump_tc;
167 x->tx_undeflow_irq++; 167 x->tx_undeflow_irq++;
168 } 168 }
169 if (unlikely(intr_status & DMA_STATUS_TJT)) { 169 if (unlikely(intr_status & DMA_STATUS_TJT)) {
170 DBG(INFO, "transmit jabber\n"); 170 DWMAC_LIB_DBG(KERN_INFO "transmit jabber\n");
171 x->tx_jabber_irq++; 171 x->tx_jabber_irq++;
172 } 172 }
173 if (unlikely(intr_status & DMA_STATUS_OVF)) { 173 if (unlikely(intr_status & DMA_STATUS_OVF)) {
174 DBG(INFO, "recv overflow\n"); 174 DWMAC_LIB_DBG(KERN_INFO "recv overflow\n");
175 x->rx_overflow_irq++; 175 x->rx_overflow_irq++;
176 } 176 }
177 if (unlikely(intr_status & DMA_STATUS_RU)) { 177 if (unlikely(intr_status & DMA_STATUS_RU)) {
178 DBG(INFO, "receive buffer unavailable\n"); 178 DWMAC_LIB_DBG(KERN_INFO "receive buffer unavailable\n");
179 x->rx_buf_unav_irq++; 179 x->rx_buf_unav_irq++;
180 } 180 }
181 if (unlikely(intr_status & DMA_STATUS_RPS)) { 181 if (unlikely(intr_status & DMA_STATUS_RPS)) {
182 DBG(INFO, "receive process stopped\n"); 182 DWMAC_LIB_DBG(KERN_INFO "receive process stopped\n");
183 x->rx_process_stopped_irq++; 183 x->rx_process_stopped_irq++;
184 } 184 }
185 if (unlikely(intr_status & DMA_STATUS_RWT)) { 185 if (unlikely(intr_status & DMA_STATUS_RWT)) {
186 DBG(INFO, "receive watchdog\n"); 186 DWMAC_LIB_DBG(KERN_INFO "receive watchdog\n");
187 x->rx_watchdog_irq++; 187 x->rx_watchdog_irq++;
188 } 188 }
189 if (unlikely(intr_status & DMA_STATUS_ETI)) { 189 if (unlikely(intr_status & DMA_STATUS_ETI)) {
190 DBG(INFO, "transmit early interrupt\n"); 190 DWMAC_LIB_DBG(KERN_INFO "transmit early interrupt\n");
191 x->tx_early_irq++; 191 x->tx_early_irq++;
192 } 192 }
193 if (unlikely(intr_status & DMA_STATUS_TPS)) { 193 if (unlikely(intr_status & DMA_STATUS_TPS)) {
194 DBG(INFO, "transmit process stopped\n"); 194 DWMAC_LIB_DBG(KERN_INFO "transmit process stopped\n");
195 x->tx_process_stopped_irq++; 195 x->tx_process_stopped_irq++;
196 ret = tx_hard_error; 196 ret = tx_hard_error;
197 } 197 }
198 if (unlikely(intr_status & DMA_STATUS_FBI)) { 198 if (unlikely(intr_status & DMA_STATUS_FBI)) {
199 DBG(INFO, "fatal bus error\n"); 199 DWMAC_LIB_DBG(KERN_INFO "fatal bus error\n");
200 x->fatal_bus_error_irq++; 200 x->fatal_bus_error_irq++;
201 ret = tx_hard_error; 201 ret = tx_hard_error;
202 } 202 }
@@ -215,7 +215,7 @@ int dwmac_dma_interrupt(void __iomem *ioaddr,
215 /* Clear the interrupt by writing a logic 1 to the CSR5[15-0] */ 215 /* Clear the interrupt by writing a logic 1 to the CSR5[15-0] */
216 writel((intr_status & 0x1ffff), ioaddr + DMA_STATUS); 216 writel((intr_status & 0x1ffff), ioaddr + DMA_STATUS);
217 217
218 DBG(INFO, "\n\n"); 218 DWMAC_LIB_DBG(KERN_INFO "\n\n");
219 return ret; 219 return ret;
220} 220}
221 221
diff --git a/drivers/net/stmmac/stmmac_main.c b/drivers/net/stmmac/stmmac_main.c
index 0e5f03135b50..cc973fc38405 100644
--- a/drivers/net/stmmac/stmmac_main.c
+++ b/drivers/net/stmmac/stmmac_main.c
@@ -750,7 +750,6 @@ static void stmmac_dma_interrupt(struct stmmac_priv *priv)
750 priv->hw->dma->dma_mode(priv->ioaddr, tc, SF_DMA_MODE); 750 priv->hw->dma->dma_mode(priv->ioaddr, tc, SF_DMA_MODE);
751 priv->xstats.threshold = tc; 751 priv->xstats.threshold = tc;
752 } 752 }
753 stmmac_tx_err(priv);
754 } else if (unlikely(status == tx_hard_error)) 753 } else if (unlikely(status == tx_hard_error))
755 stmmac_tx_err(priv); 754 stmmac_tx_err(priv);
756} 755}
@@ -781,21 +780,6 @@ static int stmmac_open(struct net_device *dev)
781 780
782 stmmac_verify_args(); 781 stmmac_verify_args();
783 782
784 ret = stmmac_init_phy(dev);
785 if (unlikely(ret)) {
786 pr_err("%s: Cannot attach to PHY (error: %d)\n", __func__, ret);
787 return ret;
788 }
789
790 /* Request the IRQ lines */
791 ret = request_irq(dev->irq, stmmac_interrupt,
792 IRQF_SHARED, dev->name, dev);
793 if (unlikely(ret < 0)) {
794 pr_err("%s: ERROR: allocating the IRQ %d (error: %d)\n",
795 __func__, dev->irq, ret);
796 return ret;
797 }
798
799#ifdef CONFIG_STMMAC_TIMER 783#ifdef CONFIG_STMMAC_TIMER
800 priv->tm = kzalloc(sizeof(struct stmmac_timer *), GFP_KERNEL); 784 priv->tm = kzalloc(sizeof(struct stmmac_timer *), GFP_KERNEL);
801 if (unlikely(priv->tm == NULL)) { 785 if (unlikely(priv->tm == NULL)) {
@@ -814,6 +798,11 @@ static int stmmac_open(struct net_device *dev)
814 } else 798 } else
815 priv->tm->enable = 1; 799 priv->tm->enable = 1;
816#endif 800#endif
801 ret = stmmac_init_phy(dev);
802 if (unlikely(ret)) {
803 pr_err("%s: Cannot attach to PHY (error: %d)\n", __func__, ret);
804 goto open_error;
805 }
817 806
818 /* Create and initialize the TX/RX descriptors chains. */ 807 /* Create and initialize the TX/RX descriptors chains. */
819 priv->dma_tx_size = STMMAC_ALIGN(dma_txsize); 808 priv->dma_tx_size = STMMAC_ALIGN(dma_txsize);
@@ -822,12 +811,11 @@ static int stmmac_open(struct net_device *dev)
822 init_dma_desc_rings(dev); 811 init_dma_desc_rings(dev);
823 812
824 /* DMA initialization and SW reset */ 813 /* DMA initialization and SW reset */
825 if (unlikely(priv->hw->dma->init(priv->ioaddr, priv->plat->pbl, 814 ret = priv->hw->dma->init(priv->ioaddr, priv->plat->pbl,
826 priv->dma_tx_phy, 815 priv->dma_tx_phy, priv->dma_rx_phy);
827 priv->dma_rx_phy) < 0)) { 816 if (ret < 0) {
828
829 pr_err("%s: DMA initialization failed\n", __func__); 817 pr_err("%s: DMA initialization failed\n", __func__);
830 return -1; 818 goto open_error;
831 } 819 }
832 820
833 /* Copy the MAC addr into the HW */ 821 /* Copy the MAC addr into the HW */
@@ -848,6 +836,15 @@ static int stmmac_open(struct net_device *dev)
848 writel(0xffffffff, priv->ioaddr + MMC_HIGH_INTR_MASK); 836 writel(0xffffffff, priv->ioaddr + MMC_HIGH_INTR_MASK);
849 writel(0xffffffff, priv->ioaddr + MMC_LOW_INTR_MASK); 837 writel(0xffffffff, priv->ioaddr + MMC_LOW_INTR_MASK);
850 838
839 /* Request the IRQ lines */
840 ret = request_irq(dev->irq, stmmac_interrupt,
841 IRQF_SHARED, dev->name, dev);
842 if (unlikely(ret < 0)) {
843 pr_err("%s: ERROR: allocating the IRQ %d (error: %d)\n",
844 __func__, dev->irq, ret);
845 goto open_error;
846 }
847
851 /* Enable the MAC Rx/Tx */ 848 /* Enable the MAC Rx/Tx */
852 stmmac_enable_mac(priv->ioaddr); 849 stmmac_enable_mac(priv->ioaddr);
853 850
@@ -878,7 +875,17 @@ static int stmmac_open(struct net_device *dev)
878 napi_enable(&priv->napi); 875 napi_enable(&priv->napi);
879 skb_queue_head_init(&priv->rx_recycle); 876 skb_queue_head_init(&priv->rx_recycle);
880 netif_start_queue(dev); 877 netif_start_queue(dev);
878
881 return 0; 879 return 0;
880
881open_error:
882#ifdef CONFIG_STMMAC_TIMER
883 kfree(priv->tm);
884#endif
885 if (priv->phydev)
886 phy_disconnect(priv->phydev);
887
888 return ret;
882} 889}
883 890
884/** 891/**
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c
index eb4f59fb01e9..bff2f7999ff0 100644
--- a/drivers/net/sunhme.c
+++ b/drivers/net/sunhme.c
@@ -3237,15 +3237,18 @@ static void happy_meal_pci_exit(void)
3237#endif 3237#endif
3238 3238
3239#ifdef CONFIG_SBUS 3239#ifdef CONFIG_SBUS
3240static const struct of_device_id hme_sbus_match[];
3240static int __devinit hme_sbus_probe(struct platform_device *op) 3241static int __devinit hme_sbus_probe(struct platform_device *op)
3241{ 3242{
3243 const struct of_device_id *match;
3242 struct device_node *dp = op->dev.of_node; 3244 struct device_node *dp = op->dev.of_node;
3243 const char *model = of_get_property(dp, "model", NULL); 3245 const char *model = of_get_property(dp, "model", NULL);
3244 int is_qfe; 3246 int is_qfe;
3245 3247
3246 if (!op->dev.of_match) 3248 match = of_match_device(hme_sbus_match, &op->dev);
3249 if (!match)
3247 return -EINVAL; 3250 return -EINVAL;
3248 is_qfe = (op->dev.of_match->data != NULL); 3251 is_qfe = (match->data != NULL);
3249 3252
3250 if (!is_qfe && model && !strcmp(model, "SUNW,sbus-qfe")) 3253 if (!is_qfe && model && !strcmp(model, "SUNW,sbus-qfe"))
3251 is_qfe = 1; 3254 is_qfe = 1;
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index b8c5f35577e4..7a5daefb6f33 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -12327,8 +12327,10 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
12327 if (val & VCPU_CFGSHDW_ASPM_DBNC) 12327 if (val & VCPU_CFGSHDW_ASPM_DBNC)
12328 tp->tg3_flags |= TG3_FLAG_ASPM_WORKAROUND; 12328 tp->tg3_flags |= TG3_FLAG_ASPM_WORKAROUND;
12329 if ((val & VCPU_CFGSHDW_WOL_ENABLE) && 12329 if ((val & VCPU_CFGSHDW_WOL_ENABLE) &&
12330 (val & VCPU_CFGSHDW_WOL_MAGPKT)) 12330 (val & VCPU_CFGSHDW_WOL_MAGPKT)) {
12331 tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; 12331 tp->tg3_flags |= TG3_FLAG_WOL_ENABLE;
12332 device_set_wakeup_enable(&tp->pdev->dev, true);
12333 }
12332 goto done; 12334 goto done;
12333 } 12335 }
12334 12336
@@ -12461,8 +12463,10 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
12461 tp->tg3_flags &= ~TG3_FLAG_WOL_CAP; 12463 tp->tg3_flags &= ~TG3_FLAG_WOL_CAP;
12462 12464
12463 if ((tp->tg3_flags & TG3_FLAG_WOL_CAP) && 12465 if ((tp->tg3_flags & TG3_FLAG_WOL_CAP) &&
12464 (nic_cfg & NIC_SRAM_DATA_CFG_WOL_ENABLE)) 12466 (nic_cfg & NIC_SRAM_DATA_CFG_WOL_ENABLE)) {
12465 tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; 12467 tp->tg3_flags |= TG3_FLAG_WOL_ENABLE;
12468 device_set_wakeup_enable(&tp->pdev->dev, true);
12469 }
12466 12470
12467 if (cfg2 & (1 << 17)) 12471 if (cfg2 & (1 << 17))
12468 tp->phy_flags |= TG3_PHYFLG_CAPACITIVE_COUPLING; 12472 tp->phy_flags |= TG3_PHYFLG_CAPACITIVE_COUPLING;
diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c
index 8a3b191b195b..ff32befd8443 100644
--- a/drivers/net/tokenring/3c359.c
+++ b/drivers/net/tokenring/3c359.c
@@ -1251,7 +1251,7 @@ static netdev_tx_t xl_xmit(struct sk_buff *skb, struct net_device *dev)
1251/* 1251/*
1252 * The NIC has told us that a packet has been downloaded onto the card, we must 1252 * The NIC has told us that a packet has been downloaded onto the card, we must
1253 * find out which packet it has done, clear the skb and information for the packet 1253 * find out which packet it has done, clear the skb and information for the packet
1254 * then advance around the ring for all tranmitted packets 1254 * then advance around the ring for all transmitted packets
1255 */ 1255 */
1256 1256
1257static void xl_dn_comp(struct net_device *dev) 1257static void xl_dn_comp(struct net_device *dev)
@@ -1568,7 +1568,7 @@ static void xl_arb_cmd(struct net_device *dev)
1568 if (lan_status_diff & LSC_SOFT_ERR) 1568 if (lan_status_diff & LSC_SOFT_ERR)
1569 printk(KERN_WARNING "%s: Adapter transmitted Soft Error Report Mac Frame\n",dev->name); 1569 printk(KERN_WARNING "%s: Adapter transmitted Soft Error Report Mac Frame\n",dev->name);
1570 if (lan_status_diff & LSC_TRAN_BCN) 1570 if (lan_status_diff & LSC_TRAN_BCN)
1571 printk(KERN_INFO "%s: We are tranmitting the beacon, aaah\n",dev->name); 1571 printk(KERN_INFO "%s: We are transmitting the beacon, aaah\n",dev->name);
1572 if (lan_status_diff & LSC_SS) 1572 if (lan_status_diff & LSC_SS)
1573 printk(KERN_INFO "%s: Single Station on the ring\n", dev->name); 1573 printk(KERN_INFO "%s: Single Station on the ring\n", dev->name);
1574 if (lan_status_diff & LSC_RING_REC) 1574 if (lan_status_diff & LSC_RING_REC)
diff --git a/drivers/net/tokenring/lanstreamer.c b/drivers/net/tokenring/lanstreamer.c
index 5bd140704533..9354ca9da576 100644
--- a/drivers/net/tokenring/lanstreamer.c
+++ b/drivers/net/tokenring/lanstreamer.c
@@ -1675,7 +1675,7 @@ drop_frame:
1675 if (lan_status_diff & LSC_SOFT_ERR) 1675 if (lan_status_diff & LSC_SOFT_ERR)
1676 printk(KERN_WARNING "%s: Adapter transmitted Soft Error Report Mac Frame\n", dev->name); 1676 printk(KERN_WARNING "%s: Adapter transmitted Soft Error Report Mac Frame\n", dev->name);
1677 if (lan_status_diff & LSC_TRAN_BCN) 1677 if (lan_status_diff & LSC_TRAN_BCN)
1678 printk(KERN_INFO "%s: We are tranmitting the beacon, aaah\n", dev->name); 1678 printk(KERN_INFO "%s: We are transmitting the beacon, aaah\n", dev->name);
1679 if (lan_status_diff & LSC_SS) 1679 if (lan_status_diff & LSC_SS)
1680 printk(KERN_INFO "%s: Single Station on the ring\n", dev->name); 1680 printk(KERN_INFO "%s: Single Station on the ring\n", dev->name);
1681 if (lan_status_diff & LSC_RING_REC) 1681 if (lan_status_diff & LSC_RING_REC)
diff --git a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c
index 3d2fbe60b46e..2684003b8ab6 100644
--- a/drivers/net/tokenring/olympic.c
+++ b/drivers/net/tokenring/olympic.c
@@ -1500,7 +1500,7 @@ drop_frame:
1500 if (lan_status_diff & LSC_SOFT_ERR) 1500 if (lan_status_diff & LSC_SOFT_ERR)
1501 printk(KERN_WARNING "%s: Adapter transmitted Soft Error Report Mac Frame\n",dev->name); 1501 printk(KERN_WARNING "%s: Adapter transmitted Soft Error Report Mac Frame\n",dev->name);
1502 if (lan_status_diff & LSC_TRAN_BCN) 1502 if (lan_status_diff & LSC_TRAN_BCN)
1503 printk(KERN_INFO "%s: We are tranmitting the beacon, aaah\n",dev->name); 1503 printk(KERN_INFO "%s: We are transmitting the beacon, aaah\n",dev->name);
1504 if (lan_status_diff & LSC_SS) 1504 if (lan_status_diff & LSC_SS)
1505 printk(KERN_INFO "%s: Single Station on the ring\n", dev->name); 1505 printk(KERN_INFO "%s: Single Station on the ring\n", dev->name);
1506 if (lan_status_diff & LSC_RING_REC) 1506 if (lan_status_diff & LSC_RING_REC)
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 341f7056a800..c924ea2bce07 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -460,7 +460,7 @@ static const struct driver_info cdc_info = {
460 .manage_power = cdc_manage_power, 460 .manage_power = cdc_manage_power,
461}; 461};
462 462
463static const struct driver_info mbm_info = { 463static const struct driver_info wwan_info = {
464 .description = "Mobile Broadband Network Device", 464 .description = "Mobile Broadband Network Device",
465 .flags = FLAG_WWAN, 465 .flags = FLAG_WWAN,
466 .bind = usbnet_cdc_bind, 466 .bind = usbnet_cdc_bind,
@@ -471,6 +471,7 @@ static const struct driver_info mbm_info = {
471 471
472/*-------------------------------------------------------------------------*/ 472/*-------------------------------------------------------------------------*/
473 473
474#define HUAWEI_VENDOR_ID 0x12D1
474 475
475static const struct usb_device_id products [] = { 476static const struct usb_device_id products [] = {
476/* 477/*
@@ -566,7 +567,7 @@ static const struct usb_device_id products [] = {
566{ 567{
567 USB_DEVICE_AND_INTERFACE_INFO(0x1004, 0x61aa, USB_CLASS_COMM, 568 USB_DEVICE_AND_INTERFACE_INFO(0x1004, 0x61aa, USB_CLASS_COMM,
568 USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), 569 USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
569 .driver_info = 0, 570 .driver_info = (unsigned long)&wwan_info,
570}, 571},
571 572
572/* 573/*
@@ -587,8 +588,17 @@ static const struct usb_device_id products [] = {
587}, { 588}, {
588 USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM, 589 USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM,
589 USB_CDC_PROTO_NONE), 590 USB_CDC_PROTO_NONE),
590 .driver_info = (unsigned long)&mbm_info, 591 .driver_info = (unsigned long)&wwan_info,
591 592
593}, {
594 /* Various Huawei modems with a network port like the UMG1831 */
595 .match_flags = USB_DEVICE_ID_MATCH_VENDOR
596 | USB_DEVICE_ID_MATCH_INT_INFO,
597 .idVendor = HUAWEI_VENDOR_ID,
598 .bInterfaceClass = USB_CLASS_COMM,
599 .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
600 .bInterfaceProtocol = 255,
601 .driver_info = (unsigned long)&wwan_info,
592}, 602},
593 { }, // END 603 { }, // END
594}; 604};
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 967371f04454..1033ef6476a4 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -54,13 +54,13 @@
54#include <linux/usb/usbnet.h> 54#include <linux/usb/usbnet.h>
55#include <linux/usb/cdc.h> 55#include <linux/usb/cdc.h>
56 56
57#define DRIVER_VERSION "7-Feb-2011" 57#define DRIVER_VERSION "23-Apr-2011"
58 58
59/* CDC NCM subclass 3.2.1 */ 59/* CDC NCM subclass 3.2.1 */
60#define USB_CDC_NCM_NDP16_LENGTH_MIN 0x10 60#define USB_CDC_NCM_NDP16_LENGTH_MIN 0x10
61 61
62/* Maximum NTB length */ 62/* Maximum NTB length */
63#define CDC_NCM_NTB_MAX_SIZE_TX 16384 /* bytes */ 63#define CDC_NCM_NTB_MAX_SIZE_TX (16384 + 4) /* bytes, must be short terminated */
64#define CDC_NCM_NTB_MAX_SIZE_RX 16384 /* bytes */ 64#define CDC_NCM_NTB_MAX_SIZE_RX 16384 /* bytes */
65 65
66/* Minimum value for MaxDatagramSize, ch. 6.2.9 */ 66/* Minimum value for MaxDatagramSize, ch. 6.2.9 */
diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c
index 7d42f9a2c068..81126ff85e05 100644
--- a/drivers/net/usb/ipheth.c
+++ b/drivers/net/usb/ipheth.c
@@ -65,6 +65,7 @@
65#define IPHETH_USBINTF_PROTO 1 65#define IPHETH_USBINTF_PROTO 1
66 66
67#define IPHETH_BUF_SIZE 1516 67#define IPHETH_BUF_SIZE 1516
68#define IPHETH_IP_ALIGN 2 /* padding at front of URB */
68#define IPHETH_TX_TIMEOUT (5 * HZ) 69#define IPHETH_TX_TIMEOUT (5 * HZ)
69 70
70#define IPHETH_INTFNUM 2 71#define IPHETH_INTFNUM 2
@@ -202,18 +203,21 @@ static void ipheth_rcvbulk_callback(struct urb *urb)
202 return; 203 return;
203 } 204 }
204 205
205 len = urb->actual_length; 206 if (urb->actual_length <= IPHETH_IP_ALIGN) {
206 buf = urb->transfer_buffer; 207 dev->net->stats.rx_length_errors++;
208 return;
209 }
210 len = urb->actual_length - IPHETH_IP_ALIGN;
211 buf = urb->transfer_buffer + IPHETH_IP_ALIGN;
207 212
208 skb = dev_alloc_skb(NET_IP_ALIGN + len); 213 skb = dev_alloc_skb(len);
209 if (!skb) { 214 if (!skb) {
210 err("%s: dev_alloc_skb: -ENOMEM", __func__); 215 err("%s: dev_alloc_skb: -ENOMEM", __func__);
211 dev->net->stats.rx_dropped++; 216 dev->net->stats.rx_dropped++;
212 return; 217 return;
213 } 218 }
214 219
215 skb_reserve(skb, NET_IP_ALIGN); 220 memcpy(skb_put(skb, len), buf, len);
216 memcpy(skb_put(skb, len), buf + NET_IP_ALIGN, len - NET_IP_ALIGN);
217 skb->dev = dev->net; 221 skb->dev = dev->net;
218 skb->protocol = eth_type_trans(skb, dev->net); 222 skb->protocol = eth_type_trans(skb, dev->net);
219 223
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 47a6c870b51f..48d4efdb4959 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -730,7 +730,7 @@ static int smsc95xx_phy_initialize(struct usbnet *dev)
730 msleep(10); 730 msleep(10);
731 bmcr = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR); 731 bmcr = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR);
732 timeout++; 732 timeout++;
733 } while ((bmcr & MII_BMCR) && (timeout < 100)); 733 } while ((bmcr & BMCR_RESET) && (timeout < 100));
734 734
735 if (timeout >= 100) { 735 if (timeout >= 100) {
736 netdev_warn(dev->net, "timeout on PHY Reset"); 736 netdev_warn(dev->net, "timeout on PHY Reset");
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 069c1cf0fdf7..9ab439d144ed 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -645,6 +645,7 @@ int usbnet_stop (struct net_device *net)
645 struct driver_info *info = dev->driver_info; 645 struct driver_info *info = dev->driver_info;
646 int retval; 646 int retval;
647 647
648 clear_bit(EVENT_DEV_OPEN, &dev->flags);
648 netif_stop_queue (net); 649 netif_stop_queue (net);
649 650
650 netif_info(dev, ifdown, dev->net, 651 netif_info(dev, ifdown, dev->net,
@@ -736,6 +737,7 @@ int usbnet_open (struct net_device *net)
736 } 737 }
737 } 738 }
738 739
740 set_bit(EVENT_DEV_OPEN, &dev->flags);
739 netif_start_queue (net); 741 netif_start_queue (net);
740 netif_info(dev, ifup, dev->net, 742 netif_info(dev, ifup, dev->net,
741 "open: enable queueing (rx %d, tx %d) mtu %d %s framing\n", 743 "open: enable queueing (rx %d, tx %d) mtu %d %s framing\n",
@@ -1259,6 +1261,9 @@ void usbnet_disconnect (struct usb_interface *intf)
1259 if (dev->driver_info->unbind) 1261 if (dev->driver_info->unbind)
1260 dev->driver_info->unbind (dev, intf); 1262 dev->driver_info->unbind (dev, intf);
1261 1263
1264 usb_kill_urb(dev->interrupt);
1265 usb_free_urb(dev->interrupt);
1266
1262 free_netdev(net); 1267 free_netdev(net);
1263 usb_put_dev (xdev); 1268 usb_put_dev (xdev);
1264} 1269}
@@ -1498,6 +1503,10 @@ int usbnet_resume (struct usb_interface *intf)
1498 int retval; 1503 int retval;
1499 1504
1500 if (!--dev->suspend_count) { 1505 if (!--dev->suspend_count) {
1506 /* resume interrupt URBs */
1507 if (dev->interrupt && test_bit(EVENT_DEV_OPEN, &dev->flags))
1508 usb_submit_urb(dev->interrupt, GFP_NOIO);
1509
1501 spin_lock_irq(&dev->txq.lock); 1510 spin_lock_irq(&dev->txq.lock);
1502 while ((res = usb_get_from_anchor(&dev->deferred))) { 1511 while ((res = usb_get_from_anchor(&dev->deferred))) {
1503 1512
@@ -1516,9 +1525,12 @@ int usbnet_resume (struct usb_interface *intf)
1516 smp_mb(); 1525 smp_mb();
1517 clear_bit(EVENT_DEV_ASLEEP, &dev->flags); 1526 clear_bit(EVENT_DEV_ASLEEP, &dev->flags);
1518 spin_unlock_irq(&dev->txq.lock); 1527 spin_unlock_irq(&dev->txq.lock);
1519 if (!(dev->txq.qlen >= TX_QLEN(dev))) 1528
1520 netif_start_queue(dev->net); 1529 if (test_bit(EVENT_DEV_OPEN, &dev->flags)) {
1521 tasklet_schedule (&dev->bh); 1530 if (!(dev->txq.qlen >= TX_QLEN(dev)))
1531 netif_start_queue(dev->net);
1532 tasklet_schedule (&dev->bh);
1533 }
1522 } 1534 }
1523 return 0; 1535 return 0;
1524} 1536}
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 2de9b90c5f8f..3b99f64104fd 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -403,6 +403,17 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
403 if (tb[IFLA_ADDRESS] == NULL) 403 if (tb[IFLA_ADDRESS] == NULL)
404 random_ether_addr(dev->dev_addr); 404 random_ether_addr(dev->dev_addr);
405 405
406 if (tb[IFLA_IFNAME])
407 nla_strlcpy(dev->name, tb[IFLA_IFNAME], IFNAMSIZ);
408 else
409 snprintf(dev->name, IFNAMSIZ, DRV_NAME "%%d");
410
411 if (strchr(dev->name, '%')) {
412 err = dev_alloc_name(dev, dev->name);
413 if (err < 0)
414 goto err_alloc_name;
415 }
416
406 err = register_netdevice(dev); 417 err = register_netdevice(dev);
407 if (err < 0) 418 if (err < 0)
408 goto err_register_dev; 419 goto err_register_dev;
@@ -422,6 +433,7 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
422 433
423err_register_dev: 434err_register_dev:
424 /* nothing to do */ 435 /* nothing to do */
436err_alloc_name:
425err_configure_peer: 437err_configure_peer:
426 unregister_netdevice(peer); 438 unregister_netdevice(peer);
427 return err; 439 return err;
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index 0d47c3a05307..c16ed961153a 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -178,6 +178,7 @@ static void
178vmxnet3_process_events(struct vmxnet3_adapter *adapter) 178vmxnet3_process_events(struct vmxnet3_adapter *adapter)
179{ 179{
180 int i; 180 int i;
181 unsigned long flags;
181 u32 events = le32_to_cpu(adapter->shared->ecr); 182 u32 events = le32_to_cpu(adapter->shared->ecr);
182 if (!events) 183 if (!events)
183 return; 184 return;
@@ -190,10 +191,10 @@ vmxnet3_process_events(struct vmxnet3_adapter *adapter)
190 191
191 /* Check if there is an error on xmit/recv queues */ 192 /* Check if there is an error on xmit/recv queues */
192 if (events & (VMXNET3_ECR_TQERR | VMXNET3_ECR_RQERR)) { 193 if (events & (VMXNET3_ECR_TQERR | VMXNET3_ECR_RQERR)) {
193 spin_lock(&adapter->cmd_lock); 194 spin_lock_irqsave(&adapter->cmd_lock, flags);
194 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, 195 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
195 VMXNET3_CMD_GET_QUEUE_STATUS); 196 VMXNET3_CMD_GET_QUEUE_STATUS);
196 spin_unlock(&adapter->cmd_lock); 197 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
197 198
198 for (i = 0; i < adapter->num_tx_queues; i++) 199 for (i = 0; i < adapter->num_tx_queues; i++)
199 if (adapter->tqd_start[i].status.stopped) 200 if (adapter->tqd_start[i].status.stopped)
@@ -2733,13 +2734,14 @@ static void
2733vmxnet3_alloc_intr_resources(struct vmxnet3_adapter *adapter) 2734vmxnet3_alloc_intr_resources(struct vmxnet3_adapter *adapter)
2734{ 2735{
2735 u32 cfg; 2736 u32 cfg;
2737 unsigned long flags;
2736 2738
2737 /* intr settings */ 2739 /* intr settings */
2738 spin_lock(&adapter->cmd_lock); 2740 spin_lock_irqsave(&adapter->cmd_lock, flags);
2739 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, 2741 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
2740 VMXNET3_CMD_GET_CONF_INTR); 2742 VMXNET3_CMD_GET_CONF_INTR);
2741 cfg = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); 2743 cfg = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD);
2742 spin_unlock(&adapter->cmd_lock); 2744 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
2743 adapter->intr.type = cfg & 0x3; 2745 adapter->intr.type = cfg & 0x3;
2744 adapter->intr.mask_mode = (cfg >> 2) & 0x3; 2746 adapter->intr.mask_mode = (cfg >> 2) & 0x3;
2745 2747
diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c
index 51f2ef142a5b..976467253d20 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethtool.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c
@@ -311,6 +311,9 @@ vmxnet3_set_flags(struct net_device *netdev, u32 data)
311 /* toggle the LRO feature*/ 311 /* toggle the LRO feature*/
312 netdev->features ^= NETIF_F_LRO; 312 netdev->features ^= NETIF_F_LRO;
313 313
314 /* Update private LRO flag */
315 adapter->lro = lro_requested;
316
314 /* update harware LRO capability accordingly */ 317 /* update harware LRO capability accordingly */
315 if (lro_requested) 318 if (lro_requested)
316 adapter->shared->devRead.misc.uptFeatures |= 319 adapter->shared->devRead.misc.uptFeatures |=
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index f1b8af64569c..2d10239ce829 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -1040,7 +1040,7 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface,
1040 } 1040 }
1041 1041
1042 ret = ath9k_htc_hw_init(hif_dev->htc_handle, 1042 ret = ath9k_htc_hw_init(hif_dev->htc_handle,
1043 &hif_dev->udev->dev, hif_dev->device_id, 1043 &interface->dev, hif_dev->device_id,
1044 hif_dev->udev->product, id->driver_info); 1044 hif_dev->udev->product, id->driver_info);
1045 if (ret) { 1045 if (ret) {
1046 ret = -EINVAL; 1046 ret = -EINVAL;
@@ -1158,7 +1158,7 @@ fail_resume:
1158#endif 1158#endif
1159 1159
1160static struct usb_driver ath9k_hif_usb_driver = { 1160static struct usb_driver ath9k_hif_usb_driver = {
1161 .name = "ath9k_hif_usb", 1161 .name = KBUILD_MODNAME,
1162 .probe = ath9k_hif_usb_probe, 1162 .probe = ath9k_hif_usb_probe,
1163 .disconnect = ath9k_hif_usb_disconnect, 1163 .disconnect = ath9k_hif_usb_disconnect,
1164#ifdef CONFIG_PM 1164#ifdef CONFIG_PM
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 1ec9bcd6b281..c95bc5cc1a1f 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -1254,15 +1254,6 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
1254 ah->txchainmask = common->tx_chainmask; 1254 ah->txchainmask = common->tx_chainmask;
1255 ah->rxchainmask = common->rx_chainmask; 1255 ah->rxchainmask = common->rx_chainmask;
1256 1256
1257 if ((common->bus_ops->ath_bus_type != ATH_USB) && !ah->chip_fullsleep) {
1258 ath9k_hw_abortpcurecv(ah);
1259 if (!ath9k_hw_stopdmarecv(ah)) {
1260 ath_dbg(common, ATH_DBG_XMIT,
1261 "Failed to stop receive dma\n");
1262 bChannelChange = false;
1263 }
1264 }
1265
1266 if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) 1257 if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE))
1267 return -EIO; 1258 return -EIO;
1268 1259
diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c
index 562257ac52cf..edc1cbbfecaf 100644
--- a/drivers/net/wireless/ath/ath9k/mac.c
+++ b/drivers/net/wireless/ath/ath9k/mac.c
@@ -751,28 +751,47 @@ void ath9k_hw_abortpcurecv(struct ath_hw *ah)
751} 751}
752EXPORT_SYMBOL(ath9k_hw_abortpcurecv); 752EXPORT_SYMBOL(ath9k_hw_abortpcurecv);
753 753
754bool ath9k_hw_stopdmarecv(struct ath_hw *ah) 754bool ath9k_hw_stopdmarecv(struct ath_hw *ah, bool *reset)
755{ 755{
756#define AH_RX_STOP_DMA_TIMEOUT 10000 /* usec */ 756#define AH_RX_STOP_DMA_TIMEOUT 10000 /* usec */
757#define AH_RX_TIME_QUANTUM 100 /* usec */ 757#define AH_RX_TIME_QUANTUM 100 /* usec */
758 struct ath_common *common = ath9k_hw_common(ah); 758 struct ath_common *common = ath9k_hw_common(ah);
759 u32 mac_status, last_mac_status = 0;
759 int i; 760 int i;
760 761
762 /* Enable access to the DMA observation bus */
763 REG_WRITE(ah, AR_MACMISC,
764 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
765 (AR_MACMISC_MISC_OBS_BUS_1 <<
766 AR_MACMISC_MISC_OBS_BUS_MSB_S)));
767
761 REG_WRITE(ah, AR_CR, AR_CR_RXD); 768 REG_WRITE(ah, AR_CR, AR_CR_RXD);
762 769
763 /* Wait for rx enable bit to go low */ 770 /* Wait for rx enable bit to go low */
764 for (i = AH_RX_STOP_DMA_TIMEOUT / AH_TIME_QUANTUM; i != 0; i--) { 771 for (i = AH_RX_STOP_DMA_TIMEOUT / AH_TIME_QUANTUM; i != 0; i--) {
765 if ((REG_READ(ah, AR_CR) & AR_CR_RXE) == 0) 772 if ((REG_READ(ah, AR_CR) & AR_CR_RXE) == 0)
766 break; 773 break;
774
775 if (!AR_SREV_9300_20_OR_LATER(ah)) {
776 mac_status = REG_READ(ah, AR_DMADBG_7) & 0x7f0;
777 if (mac_status == 0x1c0 && mac_status == last_mac_status) {
778 *reset = true;
779 break;
780 }
781
782 last_mac_status = mac_status;
783 }
784
767 udelay(AH_TIME_QUANTUM); 785 udelay(AH_TIME_QUANTUM);
768 } 786 }
769 787
770 if (i == 0) { 788 if (i == 0) {
771 ath_err(common, 789 ath_err(common,
772 "DMA failed to stop in %d ms AR_CR=0x%08x AR_DIAG_SW=0x%08x\n", 790 "DMA failed to stop in %d ms AR_CR=0x%08x AR_DIAG_SW=0x%08x DMADBG_7=0x%08x\n",
773 AH_RX_STOP_DMA_TIMEOUT / 1000, 791 AH_RX_STOP_DMA_TIMEOUT / 1000,
774 REG_READ(ah, AR_CR), 792 REG_READ(ah, AR_CR),
775 REG_READ(ah, AR_DIAG_SW)); 793 REG_READ(ah, AR_DIAG_SW),
794 REG_READ(ah, AR_DMADBG_7));
776 return false; 795 return false;
777 } else { 796 } else {
778 return true; 797 return true;
diff --git a/drivers/net/wireless/ath/ath9k/mac.h b/drivers/net/wireless/ath/ath9k/mac.h
index b2b2ff852c32..c2a59386fb9c 100644
--- a/drivers/net/wireless/ath/ath9k/mac.h
+++ b/drivers/net/wireless/ath/ath9k/mac.h
@@ -695,7 +695,7 @@ bool ath9k_hw_setrxabort(struct ath_hw *ah, bool set);
695void ath9k_hw_putrxbuf(struct ath_hw *ah, u32 rxdp); 695void ath9k_hw_putrxbuf(struct ath_hw *ah, u32 rxdp);
696void ath9k_hw_startpcureceive(struct ath_hw *ah, bool is_scanning); 696void ath9k_hw_startpcureceive(struct ath_hw *ah, bool is_scanning);
697void ath9k_hw_abortpcurecv(struct ath_hw *ah); 697void ath9k_hw_abortpcurecv(struct ath_hw *ah);
698bool ath9k_hw_stopdmarecv(struct ath_hw *ah); 698bool ath9k_hw_stopdmarecv(struct ath_hw *ah, bool *reset);
699int ath9k_hw_beaconq_setup(struct ath_hw *ah); 699int ath9k_hw_beaconq_setup(struct ath_hw *ah);
700 700
701/* Interrupt Handling */ 701/* Interrupt Handling */
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index dddb85de622d..1482fa650833 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1376,7 +1376,6 @@ static void ath9k_calculate_summary_state(struct ieee80211_hw *hw,
1376 1376
1377 ath9k_calculate_iter_data(hw, vif, &iter_data); 1377 ath9k_calculate_iter_data(hw, vif, &iter_data);
1378 1378
1379 ath9k_ps_wakeup(sc);
1380 /* Set BSSID mask. */ 1379 /* Set BSSID mask. */
1381 memcpy(common->bssidmask, iter_data.mask, ETH_ALEN); 1380 memcpy(common->bssidmask, iter_data.mask, ETH_ALEN);
1382 ath_hw_setbssidmask(common); 1381 ath_hw_setbssidmask(common);
@@ -1411,7 +1410,6 @@ static void ath9k_calculate_summary_state(struct ieee80211_hw *hw,
1411 } 1410 }
1412 1411
1413 ath9k_hw_set_interrupts(ah, ah->imask); 1412 ath9k_hw_set_interrupts(ah, ah->imask);
1414 ath9k_ps_restore(sc);
1415 1413
1416 /* Set up ANI */ 1414 /* Set up ANI */
1417 if ((iter_data.naps + iter_data.nadhocs) > 0) { 1415 if ((iter_data.naps + iter_data.nadhocs) > 0) {
@@ -1457,6 +1455,7 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
1457 struct ath_vif *avp = (void *)vif->drv_priv; 1455 struct ath_vif *avp = (void *)vif->drv_priv;
1458 int ret = 0; 1456 int ret = 0;
1459 1457
1458 ath9k_ps_wakeup(sc);
1460 mutex_lock(&sc->mutex); 1459 mutex_lock(&sc->mutex);
1461 1460
1462 switch (vif->type) { 1461 switch (vif->type) {
@@ -1503,6 +1502,7 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
1503 ath9k_do_vif_add_setup(hw, vif); 1502 ath9k_do_vif_add_setup(hw, vif);
1504out: 1503out:
1505 mutex_unlock(&sc->mutex); 1504 mutex_unlock(&sc->mutex);
1505 ath9k_ps_restore(sc);
1506 return ret; 1506 return ret;
1507} 1507}
1508 1508
@@ -1517,6 +1517,7 @@ static int ath9k_change_interface(struct ieee80211_hw *hw,
1517 1517
1518 ath_dbg(common, ATH_DBG_CONFIG, "Change Interface\n"); 1518 ath_dbg(common, ATH_DBG_CONFIG, "Change Interface\n");
1519 mutex_lock(&sc->mutex); 1519 mutex_lock(&sc->mutex);
1520 ath9k_ps_wakeup(sc);
1520 1521
1521 /* See if new interface type is valid. */ 1522 /* See if new interface type is valid. */
1522 if ((new_type == NL80211_IFTYPE_ADHOC) && 1523 if ((new_type == NL80211_IFTYPE_ADHOC) &&
@@ -1546,6 +1547,7 @@ static int ath9k_change_interface(struct ieee80211_hw *hw,
1546 1547
1547 ath9k_do_vif_add_setup(hw, vif); 1548 ath9k_do_vif_add_setup(hw, vif);
1548out: 1549out:
1550 ath9k_ps_restore(sc);
1549 mutex_unlock(&sc->mutex); 1551 mutex_unlock(&sc->mutex);
1550 return ret; 1552 return ret;
1551} 1553}
@@ -1558,6 +1560,7 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,
1558 1560
1559 ath_dbg(common, ATH_DBG_CONFIG, "Detach Interface\n"); 1561 ath_dbg(common, ATH_DBG_CONFIG, "Detach Interface\n");
1560 1562
1563 ath9k_ps_wakeup(sc);
1561 mutex_lock(&sc->mutex); 1564 mutex_lock(&sc->mutex);
1562 1565
1563 sc->nvifs--; 1566 sc->nvifs--;
@@ -1569,6 +1572,7 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,
1569 ath9k_calculate_summary_state(hw, NULL); 1572 ath9k_calculate_summary_state(hw, NULL);
1570 1573
1571 mutex_unlock(&sc->mutex); 1574 mutex_unlock(&sc->mutex);
1575 ath9k_ps_restore(sc);
1572} 1576}
1573 1577
1574static void ath9k_enable_ps(struct ath_softc *sc) 1578static void ath9k_enable_ps(struct ath_softc *sc)
@@ -1809,6 +1813,7 @@ static int ath9k_conf_tx(struct ieee80211_hw *hw, u16 queue,
1809 1813
1810 txq = sc->tx.txq_map[queue]; 1814 txq = sc->tx.txq_map[queue];
1811 1815
1816 ath9k_ps_wakeup(sc);
1812 mutex_lock(&sc->mutex); 1817 mutex_lock(&sc->mutex);
1813 1818
1814 memset(&qi, 0, sizeof(struct ath9k_tx_queue_info)); 1819 memset(&qi, 0, sizeof(struct ath9k_tx_queue_info));
@@ -1832,6 +1837,7 @@ static int ath9k_conf_tx(struct ieee80211_hw *hw, u16 queue,
1832 ath_beaconq_config(sc); 1837 ath_beaconq_config(sc);
1833 1838
1834 mutex_unlock(&sc->mutex); 1839 mutex_unlock(&sc->mutex);
1840 ath9k_ps_restore(sc);
1835 1841
1836 return ret; 1842 return ret;
1837} 1843}
@@ -1894,6 +1900,7 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
1894 int slottime; 1900 int slottime;
1895 int error; 1901 int error;
1896 1902
1903 ath9k_ps_wakeup(sc);
1897 mutex_lock(&sc->mutex); 1904 mutex_lock(&sc->mutex);
1898 1905
1899 if (changed & BSS_CHANGED_BSSID) { 1906 if (changed & BSS_CHANGED_BSSID) {
@@ -1994,6 +2001,7 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
1994 } 2001 }
1995 2002
1996 mutex_unlock(&sc->mutex); 2003 mutex_unlock(&sc->mutex);
2004 ath9k_ps_restore(sc);
1997} 2005}
1998 2006
1999static u64 ath9k_get_tsf(struct ieee80211_hw *hw) 2007static u64 ath9k_get_tsf(struct ieee80211_hw *hw)
@@ -2133,6 +2141,8 @@ static void ath9k_set_coverage_class(struct ieee80211_hw *hw, u8 coverage_class)
2133static void ath9k_flush(struct ieee80211_hw *hw, bool drop) 2141static void ath9k_flush(struct ieee80211_hw *hw, bool drop)
2134{ 2142{
2135 struct ath_softc *sc = hw->priv; 2143 struct ath_softc *sc = hw->priv;
2144 struct ath_hw *ah = sc->sc_ah;
2145 struct ath_common *common = ath9k_hw_common(ah);
2136 int timeout = 200; /* ms */ 2146 int timeout = 200; /* ms */
2137 int i, j; 2147 int i, j;
2138 2148
@@ -2141,6 +2151,12 @@ static void ath9k_flush(struct ieee80211_hw *hw, bool drop)
2141 2151
2142 cancel_delayed_work_sync(&sc->tx_complete_work); 2152 cancel_delayed_work_sync(&sc->tx_complete_work);
2143 2153
2154 if (sc->sc_flags & SC_OP_INVALID) {
2155 ath_dbg(common, ATH_DBG_ANY, "Device not present\n");
2156 mutex_unlock(&sc->mutex);
2157 return;
2158 }
2159
2144 if (drop) 2160 if (drop)
2145 timeout = 1; 2161 timeout = 1;
2146 2162
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index a9c3f4672aa0..b29c80def35e 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -486,12 +486,12 @@ start_recv:
486bool ath_stoprecv(struct ath_softc *sc) 486bool ath_stoprecv(struct ath_softc *sc)
487{ 487{
488 struct ath_hw *ah = sc->sc_ah; 488 struct ath_hw *ah = sc->sc_ah;
489 bool stopped; 489 bool stopped, reset = false;
490 490
491 spin_lock_bh(&sc->rx.rxbuflock); 491 spin_lock_bh(&sc->rx.rxbuflock);
492 ath9k_hw_abortpcurecv(ah); 492 ath9k_hw_abortpcurecv(ah);
493 ath9k_hw_setrxfilter(ah, 0); 493 ath9k_hw_setrxfilter(ah, 0);
494 stopped = ath9k_hw_stopdmarecv(ah); 494 stopped = ath9k_hw_stopdmarecv(ah, &reset);
495 495
496 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) 496 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
497 ath_edma_stop_recv(sc); 497 ath_edma_stop_recv(sc);
@@ -506,7 +506,7 @@ bool ath_stoprecv(struct ath_softc *sc)
506 "confusing the DMA engine when we start RX up\n"); 506 "confusing the DMA engine when we start RX up\n");
507 ATH_DBG_WARN_ON_ONCE(!stopped); 507 ATH_DBG_WARN_ON_ONCE(!stopped);
508 } 508 }
509 return stopped; 509 return stopped && !reset;
510} 510}
511 511
512void ath_flushrecv(struct ath_softc *sc) 512void ath_flushrecv(struct ath_softc *sc)
diff --git a/drivers/net/wireless/ath/regd_common.h b/drivers/net/wireless/ath/regd_common.h
index 248c670fdfbe..5c2cfe694152 100644
--- a/drivers/net/wireless/ath/regd_common.h
+++ b/drivers/net/wireless/ath/regd_common.h
@@ -195,6 +195,7 @@ static struct reg_dmn_pair_mapping regDomainPairs[] = {
195 {APL9_WORLD, CTL_ETSI, CTL_ETSI}, 195 {APL9_WORLD, CTL_ETSI, CTL_ETSI},
196 196
197 {APL3_FCCA, CTL_FCC, CTL_FCC}, 197 {APL3_FCCA, CTL_FCC, CTL_FCC},
198 {APL7_FCCA, CTL_FCC, CTL_FCC},
198 {APL1_ETSIC, CTL_FCC, CTL_ETSI}, 199 {APL1_ETSIC, CTL_FCC, CTL_ETSI},
199 {APL2_ETSIC, CTL_FCC, CTL_ETSI}, 200 {APL2_ETSIC, CTL_FCC, CTL_ETSI},
200 {APL2_APLD, CTL_FCC, NO_CTL}, 201 {APL2_APLD, CTL_FCC, NO_CTL},
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index d59b0168c14a..5af40d9170a0 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -72,6 +72,7 @@ MODULE_FIRMWARE("b43/ucode11.fw");
72MODULE_FIRMWARE("b43/ucode13.fw"); 72MODULE_FIRMWARE("b43/ucode13.fw");
73MODULE_FIRMWARE("b43/ucode14.fw"); 73MODULE_FIRMWARE("b43/ucode14.fw");
74MODULE_FIRMWARE("b43/ucode15.fw"); 74MODULE_FIRMWARE("b43/ucode15.fw");
75MODULE_FIRMWARE("b43/ucode16_mimo.fw");
75MODULE_FIRMWARE("b43/ucode5.fw"); 76MODULE_FIRMWARE("b43/ucode5.fw");
76MODULE_FIRMWARE("b43/ucode9.fw"); 77MODULE_FIRMWARE("b43/ucode9.fw");
77 78
diff --git a/drivers/net/wireless/iwlegacy/Kconfig b/drivers/net/wireless/iwlegacy/Kconfig
index 2a45dd44cc12..aef65cd47661 100644
--- a/drivers/net/wireless/iwlegacy/Kconfig
+++ b/drivers/net/wireless/iwlegacy/Kconfig
@@ -1,6 +1,5 @@
1config IWLWIFI_LEGACY 1config IWLWIFI_LEGACY
2 tristate "Intel Wireless Wifi legacy devices" 2 tristate
3 depends on PCI && MAC80211
4 select FW_LOADER 3 select FW_LOADER
5 select NEW_LEDS 4 select NEW_LEDS
6 select LEDS_CLASS 5 select LEDS_CLASS
@@ -65,7 +64,8 @@ endmenu
65 64
66config IWL4965 65config IWL4965
67 tristate "Intel Wireless WiFi 4965AGN (iwl4965)" 66 tristate "Intel Wireless WiFi 4965AGN (iwl4965)"
68 depends on IWLWIFI_LEGACY 67 depends on PCI && MAC80211
68 select IWLWIFI_LEGACY
69 ---help--- 69 ---help---
70 This option enables support for 70 This option enables support for
71 71
@@ -92,7 +92,8 @@ config IWL4965
92 92
93config IWL3945 93config IWL3945
94 tristate "Intel PRO/Wireless 3945ABG/BG Network Connection (iwl3945)" 94 tristate "Intel PRO/Wireless 3945ABG/BG Network Connection (iwl3945)"
95 depends on IWLWIFI_LEGACY 95 depends on PCI && MAC80211
96 select IWLWIFI_LEGACY
96 ---help--- 97 ---help---
97 Select to build the driver supporting the: 98 Select to build the driver supporting the:
98 99
diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h
index 779d3cb86e2c..5c3a68d3af12 100644
--- a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h
+++ b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h
@@ -74,8 +74,6 @@
74/* RSSI to dBm */ 74/* RSSI to dBm */
75#define IWL39_RSSI_OFFSET 95 75#define IWL39_RSSI_OFFSET 95
76 76
77#define IWL_DEFAULT_TX_POWER 0x0F
78
79/* 77/*
80 * EEPROM related constants, enums, and structures. 78 * EEPROM related constants, enums, and structures.
81 */ 79 */
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h
index 08b189c8472d..fc6fa2886d9c 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h
+++ b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h
@@ -804,9 +804,6 @@ struct iwl4965_scd_bc_tbl {
804 804
805#define IWL4965_DEFAULT_TX_RETRY 15 805#define IWL4965_DEFAULT_TX_RETRY 15
806 806
807/* Limit range of txpower output target to be between these values */
808#define IWL4965_TX_POWER_TARGET_POWER_MIN (0) /* 0 dBm: 1 milliwatt */
809
810/* EEPROM */ 807/* EEPROM */
811#define IWL4965_FIRST_AMPDU_QUEUE 10 808#define IWL4965_FIRST_AMPDU_QUEUE 10
812 809
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c
index 5c40502f869a..79ac081832fb 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c
@@ -316,12 +316,18 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
316 316
317 hdr_len = ieee80211_hdrlen(fc); 317 hdr_len = ieee80211_hdrlen(fc);
318 318
319 /* Find index into station table for destination station */ 319 /* For management frames use broadcast id to do not break aggregation */
320 sta_id = iwl_legacy_sta_id_or_broadcast(priv, ctx, info->control.sta); 320 if (!ieee80211_is_data(fc))
321 if (sta_id == IWL_INVALID_STATION) { 321 sta_id = ctx->bcast_sta_id;
322 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", 322 else {
323 hdr->addr1); 323 /* Find index into station table for destination station */
324 goto drop_unlock; 324 sta_id = iwl_legacy_sta_id_or_broadcast(priv, ctx, info->control.sta);
325
326 if (sta_id == IWL_INVALID_STATION) {
327 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
328 hdr->addr1);
329 goto drop_unlock;
330 }
325 } 331 }
326 332
327 IWL_DEBUG_TX(priv, "station Id %d\n", sta_id); 333 IWL_DEBUG_TX(priv, "station Id %d\n", sta_id);
@@ -1127,12 +1133,16 @@ int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index)
1127 q->read_ptr = iwl_legacy_queue_inc_wrap(q->read_ptr, q->n_bd)) { 1133 q->read_ptr = iwl_legacy_queue_inc_wrap(q->read_ptr, q->n_bd)) {
1128 1134
1129 tx_info = &txq->txb[txq->q.read_ptr]; 1135 tx_info = &txq->txb[txq->q.read_ptr];
1130 iwl4965_tx_status(priv, tx_info, 1136
1131 txq_id >= IWL4965_FIRST_AMPDU_QUEUE); 1137 if (WARN_ON_ONCE(tx_info->skb == NULL))
1138 continue;
1132 1139
1133 hdr = (struct ieee80211_hdr *)tx_info->skb->data; 1140 hdr = (struct ieee80211_hdr *)tx_info->skb->data;
1134 if (hdr && ieee80211_is_data_qos(hdr->frame_control)) 1141 if (ieee80211_is_data_qos(hdr->frame_control))
1135 nfreed++; 1142 nfreed++;
1143
1144 iwl4965_tx_status(priv, tx_info,
1145 txq_id >= IWL4965_FIRST_AMPDU_QUEUE);
1136 tx_info->skb = NULL; 1146 tx_info->skb = NULL;
1137 1147
1138 priv->cfg->ops->lib->txq_free_tfd(priv, txq); 1148 priv->cfg->ops->lib->txq_free_tfd(priv, txq);
diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c
index 7007d61bb6b5..42db0fc8b921 100644
--- a/drivers/net/wireless/iwlegacy/iwl-core.c
+++ b/drivers/net/wireless/iwlegacy/iwl-core.c
@@ -160,6 +160,7 @@ int iwl_legacy_init_geos(struct iwl_priv *priv)
160 struct ieee80211_channel *geo_ch; 160 struct ieee80211_channel *geo_ch;
161 struct ieee80211_rate *rates; 161 struct ieee80211_rate *rates;
162 int i = 0; 162 int i = 0;
163 s8 max_tx_power = 0;
163 164
164 if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates || 165 if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates ||
165 priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) { 166 priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) {
@@ -235,8 +236,8 @@ int iwl_legacy_init_geos(struct iwl_priv *priv)
235 236
236 geo_ch->flags |= ch->ht40_extension_channel; 237 geo_ch->flags |= ch->ht40_extension_channel;
237 238
238 if (ch->max_power_avg > priv->tx_power_device_lmt) 239 if (ch->max_power_avg > max_tx_power)
239 priv->tx_power_device_lmt = ch->max_power_avg; 240 max_tx_power = ch->max_power_avg;
240 } else { 241 } else {
241 geo_ch->flags |= IEEE80211_CHAN_DISABLED; 242 geo_ch->flags |= IEEE80211_CHAN_DISABLED;
242 } 243 }
@@ -249,6 +250,10 @@ int iwl_legacy_init_geos(struct iwl_priv *priv)
249 geo_ch->flags); 250 geo_ch->flags);
250 } 251 }
251 252
253 priv->tx_power_device_lmt = max_tx_power;
254 priv->tx_power_user_lmt = max_tx_power;
255 priv->tx_power_next = max_tx_power;
256
252 if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && 257 if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) &&
253 priv->cfg->sku & IWL_SKU_A) { 258 priv->cfg->sku & IWL_SKU_A) {
254 IWL_INFO(priv, "Incorrectly detected BG card as ABG. " 259 IWL_INFO(priv, "Incorrectly detected BG card as ABG. "
@@ -1124,11 +1129,11 @@ int iwl_legacy_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force)
1124 if (!priv->cfg->ops->lib->send_tx_power) 1129 if (!priv->cfg->ops->lib->send_tx_power)
1125 return -EOPNOTSUPP; 1130 return -EOPNOTSUPP;
1126 1131
1127 if (tx_power < IWL4965_TX_POWER_TARGET_POWER_MIN) { 1132 /* 0 dBm mean 1 milliwatt */
1133 if (tx_power < 0) {
1128 IWL_WARN(priv, 1134 IWL_WARN(priv,
1129 "Requested user TXPOWER %d below lower limit %d.\n", 1135 "Requested user TXPOWER %d below 1 mW.\n",
1130 tx_power, 1136 tx_power);
1131 IWL4965_TX_POWER_TARGET_POWER_MIN);
1132 return -EINVAL; 1137 return -EINVAL;
1133 } 1138 }
1134 1139
@@ -2150,6 +2155,13 @@ int iwl_legacy_mac_config(struct ieee80211_hw *hw, u32 changed)
2150 goto set_ch_out; 2155 goto set_ch_out;
2151 } 2156 }
2152 2157
2158 if (priv->iw_mode == NL80211_IFTYPE_ADHOC &&
2159 !iwl_legacy_is_channel_ibss(ch_info)) {
2160 IWL_DEBUG_MAC80211(priv, "leave - not IBSS channel\n");
2161 ret = -EINVAL;
2162 goto set_ch_out;
2163 }
2164
2153 spin_lock_irqsave(&priv->lock, flags); 2165 spin_lock_irqsave(&priv->lock, flags);
2154 2166
2155 for_each_context(priv, ctx) { 2167 for_each_context(priv, ctx) {
diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h
index 9ee849d669f3..f43ac1eb9014 100644
--- a/drivers/net/wireless/iwlegacy/iwl-dev.h
+++ b/drivers/net/wireless/iwlegacy/iwl-dev.h
@@ -1411,6 +1411,12 @@ iwl_legacy_is_channel_passive(const struct iwl_channel_info *ch)
1411 return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0; 1411 return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
1412} 1412}
1413 1413
1414static inline int
1415iwl_legacy_is_channel_ibss(const struct iwl_channel_info *ch)
1416{
1417 return (ch->flags & EEPROM_CHANNEL_IBSS) ? 1 : 0;
1418}
1419
1414static inline void 1420static inline void
1415__iwl_legacy_free_pages(struct iwl_priv *priv, struct page *page) 1421__iwl_legacy_free_pages(struct iwl_priv *priv, struct page *page)
1416{ 1422{
diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c
index 04c5648027df..cb346d1a9ffa 100644
--- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.c
@@ -471,13 +471,6 @@ int iwl_legacy_init_channel_map(struct iwl_priv *priv)
471 flags & EEPROM_CHANNEL_RADAR)) 471 flags & EEPROM_CHANNEL_RADAR))
472 ? "" : "not "); 472 ? "" : "not ");
473 473
474 /* Set the tx_power_user_lmt to the highest power
475 * supported by any channel */
476 if (eeprom_ch_info[ch].max_power_avg >
477 priv->tx_power_user_lmt)
478 priv->tx_power_user_lmt =
479 eeprom_ch_info[ch].max_power_avg;
480
481 ch_info++; 474 ch_info++;
482 } 475 }
483 } 476 }
diff --git a/drivers/net/wireless/iwlegacy/iwl-led.c b/drivers/net/wireless/iwlegacy/iwl-led.c
index 15eb8b707157..bda0d61b2c0d 100644
--- a/drivers/net/wireless/iwlegacy/iwl-led.c
+++ b/drivers/net/wireless/iwlegacy/iwl-led.c
@@ -48,8 +48,21 @@ module_param(led_mode, int, S_IRUGO);
48MODULE_PARM_DESC(led_mode, "0=system default, " 48MODULE_PARM_DESC(led_mode, "0=system default, "
49 "1=On(RF On)/Off(RF Off), 2=blinking"); 49 "1=On(RF On)/Off(RF Off), 2=blinking");
50 50
51/* Throughput OFF time(ms) ON time (ms)
52 * >300 25 25
53 * >200 to 300 40 40
54 * >100 to 200 55 55
55 * >70 to 100 65 65
56 * >50 to 70 75 75
57 * >20 to 50 85 85
58 * >10 to 20 95 95
59 * >5 to 10 110 110
60 * >1 to 5 130 130
61 * >0 to 1 167 167
62 * <=0 SOLID ON
63 */
51static const struct ieee80211_tpt_blink iwl_blink[] = { 64static const struct ieee80211_tpt_blink iwl_blink[] = {
52 { .throughput = 0 * 1024 - 1, .blink_time = 334 }, 65 { .throughput = 0, .blink_time = 334 },
53 { .throughput = 1 * 1024 - 1, .blink_time = 260 }, 66 { .throughput = 1 * 1024 - 1, .blink_time = 260 },
54 { .throughput = 5 * 1024 - 1, .blink_time = 220 }, 67 { .throughput = 5 * 1024 - 1, .blink_time = 220 },
55 { .throughput = 10 * 1024 - 1, .blink_time = 190 }, 68 { .throughput = 10 * 1024 - 1, .blink_time = 190 },
@@ -101,6 +114,11 @@ static int iwl_legacy_led_cmd(struct iwl_priv *priv,
101 if (priv->blink_on == on && priv->blink_off == off) 114 if (priv->blink_on == on && priv->blink_off == off)
102 return 0; 115 return 0;
103 116
117 if (off == 0) {
118 /* led is SOLID_ON */
119 on = IWL_LED_SOLID;
120 }
121
104 IWL_DEBUG_LED(priv, "Led blink time compensation=%u\n", 122 IWL_DEBUG_LED(priv, "Led blink time compensation=%u\n",
105 priv->cfg->base_params->led_compensation); 123 priv->cfg->base_params->led_compensation);
106 led_cmd.on = iwl_legacy_blink_compensation(priv, on, 124 led_cmd.on = iwl_legacy_blink_compensation(priv, on,
diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c
index 28eb3d885ba1..cc7ebcee60e5 100644
--- a/drivers/net/wireless/iwlegacy/iwl3945-base.c
+++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c
@@ -3825,10 +3825,6 @@ static int iwl3945_init_drv(struct iwl_priv *priv)
3825 priv->force_reset[IWL_FW_RESET].reset_duration = 3825 priv->force_reset[IWL_FW_RESET].reset_duration =
3826 IWL_DELAY_NEXT_FORCE_FW_RELOAD; 3826 IWL_DELAY_NEXT_FORCE_FW_RELOAD;
3827 3827
3828
3829 priv->tx_power_user_lmt = IWL_DEFAULT_TX_POWER;
3830 priv->tx_power_next = IWL_DEFAULT_TX_POWER;
3831
3832 if (eeprom->version < EEPROM_3945_EEPROM_VERSION) { 3828 if (eeprom->version < EEPROM_3945_EEPROM_VERSION) {
3833 IWL_WARN(priv, "Unsupported EEPROM version: 0x%04X\n", 3829 IWL_WARN(priv, "Unsupported EEPROM version: 0x%04X\n",
3834 eeprom->version); 3830 eeprom->version);
diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c
index 91b3d8b9d7a5..a62fe24ee594 100644
--- a/drivers/net/wireless/iwlegacy/iwl4965-base.c
+++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c
@@ -2984,15 +2984,15 @@ static void iwl4965_bg_txpower_work(struct work_struct *work)
2984 struct iwl_priv *priv = container_of(work, struct iwl_priv, 2984 struct iwl_priv *priv = container_of(work, struct iwl_priv,
2985 txpower_work); 2985 txpower_work);
2986 2986
2987 mutex_lock(&priv->mutex);
2988
2987 /* If a scan happened to start before we got here 2989 /* If a scan happened to start before we got here
2988 * then just return; the statistics notification will 2990 * then just return; the statistics notification will
2989 * kick off another scheduled work to compensate for 2991 * kick off another scheduled work to compensate for
2990 * any temperature delta we missed here. */ 2992 * any temperature delta we missed here. */
2991 if (test_bit(STATUS_EXIT_PENDING, &priv->status) || 2993 if (test_bit(STATUS_EXIT_PENDING, &priv->status) ||
2992 test_bit(STATUS_SCANNING, &priv->status)) 2994 test_bit(STATUS_SCANNING, &priv->status))
2993 return; 2995 goto out;
2994
2995 mutex_lock(&priv->mutex);
2996 2996
2997 /* Regardless of if we are associated, we must reconfigure the 2997 /* Regardless of if we are associated, we must reconfigure the
2998 * TX power since frames can be sent on non-radar channels while 2998 * TX power since frames can be sent on non-radar channels while
@@ -3002,7 +3002,7 @@ static void iwl4965_bg_txpower_work(struct work_struct *work)
3002 /* Update last_temperature to keep is_calib_needed from running 3002 /* Update last_temperature to keep is_calib_needed from running
3003 * when it isn't needed... */ 3003 * when it isn't needed... */
3004 priv->last_temperature = priv->temperature; 3004 priv->last_temperature = priv->temperature;
3005 3005out:
3006 mutex_unlock(&priv->mutex); 3006 mutex_unlock(&priv->mutex);
3007} 3007}
3008 3008
@@ -3140,12 +3140,6 @@ static int iwl4965_init_drv(struct iwl_priv *priv)
3140 3140
3141 iwl_legacy_init_scan_params(priv); 3141 iwl_legacy_init_scan_params(priv);
3142 3142
3143 /* Set the tx_power_user_lmt to the lowest power level
3144 * this value will get overwritten by channel max power avg
3145 * from eeprom */
3146 priv->tx_power_user_lmt = IWL4965_TX_POWER_TARGET_POWER_MIN;
3147 priv->tx_power_next = IWL4965_TX_POWER_TARGET_POWER_MIN;
3148
3149 ret = iwl_legacy_init_channel_map(priv); 3143 ret = iwl_legacy_init_channel_map(priv);
3150 if (ret) { 3144 if (ret) {
3151 IWL_ERR(priv, "initializing regulatory failed: %d\n", ret); 3145 IWL_ERR(priv, "initializing regulatory failed: %d\n", ret);
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 3ea31b659d1a..22e045b5bcee 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -530,6 +530,9 @@ static struct iwl_ht_params iwl5000_ht_params = {
530struct iwl_cfg iwl5300_agn_cfg = { 530struct iwl_cfg iwl5300_agn_cfg = {
531 .name = "Intel(R) Ultimate N WiFi Link 5300 AGN", 531 .name = "Intel(R) Ultimate N WiFi Link 5300 AGN",
532 IWL_DEVICE_5000, 532 IWL_DEVICE_5000,
533 /* at least EEPROM 0x11A has wrong info */
534 .valid_tx_ant = ANT_ABC, /* .cfg overwrite */
535 .valid_rx_ant = ANT_ABC, /* .cfg overwrite */
533 .ht_params = &iwl5000_ht_params, 536 .ht_params = &iwl5000_ht_params,
534}; 537};
535 538
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
index dfdbea6e8f99..fbbde0712fa5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
@@ -335,7 +335,6 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed)
335 struct ieee80211_channel *channel = conf->channel; 335 struct ieee80211_channel *channel = conf->channel;
336 const struct iwl_channel_info *ch_info; 336 const struct iwl_channel_info *ch_info;
337 int ret = 0; 337 int ret = 0;
338 bool ht_changed[NUM_IWL_RXON_CTX] = {};
339 338
340 IWL_DEBUG_MAC80211(priv, "changed %#x", changed); 339 IWL_DEBUG_MAC80211(priv, "changed %#x", changed);
341 340
@@ -383,10 +382,8 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed)
383 382
384 for_each_context(priv, ctx) { 383 for_each_context(priv, ctx) {
385 /* Configure HT40 channels */ 384 /* Configure HT40 channels */
386 if (ctx->ht.enabled != conf_is_ht(conf)) { 385 if (ctx->ht.enabled != conf_is_ht(conf))
387 ctx->ht.enabled = conf_is_ht(conf); 386 ctx->ht.enabled = conf_is_ht(conf);
388 ht_changed[ctx->ctxid] = true;
389 }
390 387
391 if (ctx->ht.enabled) { 388 if (ctx->ht.enabled) {
392 if (conf_is_ht40_minus(conf)) { 389 if (conf_is_ht40_minus(conf)) {
@@ -455,8 +452,6 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed)
455 if (!memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) 452 if (!memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging)))
456 continue; 453 continue;
457 iwlagn_commit_rxon(priv, ctx); 454 iwlagn_commit_rxon(priv, ctx);
458 if (ht_changed[ctx->ctxid])
459 iwlagn_update_qos(priv, ctx);
460 } 455 }
461 out: 456 out:
462 mutex_unlock(&priv->mutex); 457 mutex_unlock(&priv->mutex);
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
index a709d05c5868..0712b67283a4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
@@ -568,12 +568,17 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
568 568
569 hdr_len = ieee80211_hdrlen(fc); 569 hdr_len = ieee80211_hdrlen(fc);
570 570
571 /* Find index into station table for destination station */ 571 /* For management frames use broadcast id to do not break aggregation */
572 sta_id = iwl_sta_id_or_broadcast(priv, ctx, info->control.sta); 572 if (!ieee80211_is_data(fc))
573 if (sta_id == IWL_INVALID_STATION) { 573 sta_id = ctx->bcast_sta_id;
574 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", 574 else {
575 hdr->addr1); 575 /* Find index into station table for destination station */
576 goto drop_unlock; 576 sta_id = iwl_sta_id_or_broadcast(priv, ctx, info->control.sta);
577 if (sta_id == IWL_INVALID_STATION) {
578 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
579 hdr->addr1);
580 goto drop_unlock;
581 }
577 } 582 }
578 583
579 IWL_DEBUG_TX(priv, "station Id %d\n", sta_id); 584 IWL_DEBUG_TX(priv, "station Id %d\n", sta_id);
@@ -1224,12 +1229,16 @@ int iwlagn_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index)
1224 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) { 1229 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) {
1225 1230
1226 tx_info = &txq->txb[txq->q.read_ptr]; 1231 tx_info = &txq->txb[txq->q.read_ptr];
1227 iwlagn_tx_status(priv, tx_info, 1232
1228 txq_id >= IWLAGN_FIRST_AMPDU_QUEUE); 1233 if (WARN_ON_ONCE(tx_info->skb == NULL))
1234 continue;
1229 1235
1230 hdr = (struct ieee80211_hdr *)tx_info->skb->data; 1236 hdr = (struct ieee80211_hdr *)tx_info->skb->data;
1231 if (hdr && ieee80211_is_data_qos(hdr->frame_control)) 1237 if (ieee80211_is_data_qos(hdr->frame_control))
1232 nfreed++; 1238 nfreed++;
1239
1240 iwlagn_tx_status(priv, tx_info,
1241 txq_id >= IWLAGN_FIRST_AMPDU_QUEUE);
1233 tx_info->skb = NULL; 1242 tx_info->skb = NULL;
1234 1243
1235 if (priv->cfg->ops->lib->txq_inval_byte_cnt_tbl) 1244 if (priv->cfg->ops->lib->txq_inval_byte_cnt_tbl)
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index 7e8a658b7670..f3ac62431a30 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -1339,8 +1339,8 @@ int lbs_execute_next_command(struct lbs_private *priv)
1339 cpu_to_le16(PS_MODE_ACTION_EXIT_PS)) { 1339 cpu_to_le16(PS_MODE_ACTION_EXIT_PS)) {
1340 lbs_deb_host( 1340 lbs_deb_host(
1341 "EXEC_NEXT_CMD: ignore ENTER_PS cmd\n"); 1341 "EXEC_NEXT_CMD: ignore ENTER_PS cmd\n");
1342 list_del(&cmdnode->list);
1343 spin_lock_irqsave(&priv->driver_lock, flags); 1342 spin_lock_irqsave(&priv->driver_lock, flags);
1343 list_del(&cmdnode->list);
1344 lbs_complete_command(priv, cmdnode, 0); 1344 lbs_complete_command(priv, cmdnode, 0);
1345 spin_unlock_irqrestore(&priv->driver_lock, flags); 1345 spin_unlock_irqrestore(&priv->driver_lock, flags);
1346 1346
@@ -1352,8 +1352,8 @@ int lbs_execute_next_command(struct lbs_private *priv)
1352 (priv->psstate == PS_STATE_PRE_SLEEP)) { 1352 (priv->psstate == PS_STATE_PRE_SLEEP)) {
1353 lbs_deb_host( 1353 lbs_deb_host(
1354 "EXEC_NEXT_CMD: ignore EXIT_PS cmd in sleep\n"); 1354 "EXEC_NEXT_CMD: ignore EXIT_PS cmd in sleep\n");
1355 list_del(&cmdnode->list);
1356 spin_lock_irqsave(&priv->driver_lock, flags); 1355 spin_lock_irqsave(&priv->driver_lock, flags);
1356 list_del(&cmdnode->list);
1357 lbs_complete_command(priv, cmdnode, 0); 1357 lbs_complete_command(priv, cmdnode, 0);
1358 spin_unlock_irqrestore(&priv->driver_lock, flags); 1358 spin_unlock_irqrestore(&priv->driver_lock, flags);
1359 priv->needtowakeup = 1; 1359 priv->needtowakeup = 1;
@@ -1366,7 +1366,9 @@ int lbs_execute_next_command(struct lbs_private *priv)
1366 "EXEC_NEXT_CMD: sending EXIT_PS\n"); 1366 "EXEC_NEXT_CMD: sending EXIT_PS\n");
1367 } 1367 }
1368 } 1368 }
1369 spin_lock_irqsave(&priv->driver_lock, flags);
1369 list_del(&cmdnode->list); 1370 list_del(&cmdnode->list);
1371 spin_unlock_irqrestore(&priv->driver_lock, flags);
1370 lbs_deb_host("EXEC_NEXT_CMD: sending command 0x%04x\n", 1372 lbs_deb_host("EXEC_NEXT_CMD: sending command 0x%04x\n",
1371 le16_to_cpu(cmd->command)); 1373 le16_to_cpu(cmd->command));
1372 lbs_submit_command(priv, cmdnode); 1374 lbs_submit_command(priv, cmdnode);
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index 36952274950e..c1ceb4b23971 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -137,6 +137,7 @@ struct mwl8k_tx_queue {
137struct mwl8k_priv { 137struct mwl8k_priv {
138 struct ieee80211_hw *hw; 138 struct ieee80211_hw *hw;
139 struct pci_dev *pdev; 139 struct pci_dev *pdev;
140 int irq;
140 141
141 struct mwl8k_device_info *device_info; 142 struct mwl8k_device_info *device_info;
142 143
@@ -3761,9 +3762,11 @@ static int mwl8k_start(struct ieee80211_hw *hw)
3761 rc = request_irq(priv->pdev->irq, mwl8k_interrupt, 3762 rc = request_irq(priv->pdev->irq, mwl8k_interrupt,
3762 IRQF_SHARED, MWL8K_NAME, hw); 3763 IRQF_SHARED, MWL8K_NAME, hw);
3763 if (rc) { 3764 if (rc) {
3765 priv->irq = -1;
3764 wiphy_err(hw->wiphy, "failed to register IRQ handler\n"); 3766 wiphy_err(hw->wiphy, "failed to register IRQ handler\n");
3765 return -EIO; 3767 return -EIO;
3766 } 3768 }
3769 priv->irq = priv->pdev->irq;
3767 3770
3768 /* Enable TX reclaim and RX tasklets. */ 3771 /* Enable TX reclaim and RX tasklets. */
3769 tasklet_enable(&priv->poll_tx_task); 3772 tasklet_enable(&priv->poll_tx_task);
@@ -3800,6 +3803,7 @@ static int mwl8k_start(struct ieee80211_hw *hw)
3800 if (rc) { 3803 if (rc) {
3801 iowrite32(0, priv->regs + MWL8K_HIU_A2H_INTERRUPT_MASK); 3804 iowrite32(0, priv->regs + MWL8K_HIU_A2H_INTERRUPT_MASK);
3802 free_irq(priv->pdev->irq, hw); 3805 free_irq(priv->pdev->irq, hw);
3806 priv->irq = -1;
3803 tasklet_disable(&priv->poll_tx_task); 3807 tasklet_disable(&priv->poll_tx_task);
3804 tasklet_disable(&priv->poll_rx_task); 3808 tasklet_disable(&priv->poll_rx_task);
3805 } 3809 }
@@ -3818,7 +3822,10 @@ static void mwl8k_stop(struct ieee80211_hw *hw)
3818 3822
3819 /* Disable interrupts */ 3823 /* Disable interrupts */
3820 iowrite32(0, priv->regs + MWL8K_HIU_A2H_INTERRUPT_MASK); 3824 iowrite32(0, priv->regs + MWL8K_HIU_A2H_INTERRUPT_MASK);
3821 free_irq(priv->pdev->irq, hw); 3825 if (priv->irq != -1) {
3826 free_irq(priv->pdev->irq, hw);
3827 priv->irq = -1;
3828 }
3822 3829
3823 /* Stop finalize join worker */ 3830 /* Stop finalize join worker */
3824 cancel_work_sync(&priv->finalize_join_worker); 3831 cancel_work_sync(&priv->finalize_join_worker);
diff --git a/drivers/net/wireless/p54/txrx.c b/drivers/net/wireless/p54/txrx.c
index 7834c26c2954..042842e704de 100644
--- a/drivers/net/wireless/p54/txrx.c
+++ b/drivers/net/wireless/p54/txrx.c
@@ -703,7 +703,7 @@ void p54_tx_80211(struct ieee80211_hw *dev, struct sk_buff *skb)
703 struct p54_tx_info *p54info; 703 struct p54_tx_info *p54info;
704 struct p54_hdr *hdr; 704 struct p54_hdr *hdr;
705 struct p54_tx_data *txhdr; 705 struct p54_tx_data *txhdr;
706 unsigned int padding, len, extra_len; 706 unsigned int padding, len, extra_len = 0;
707 int i, j, ridx; 707 int i, j, ridx;
708 u16 hdr_flags = 0, aid = 0; 708 u16 hdr_flags = 0, aid = 0;
709 u8 rate, queue = 0, crypt_offset = 0; 709 u8 rate, queue = 0, crypt_offset = 0;
diff --git a/drivers/net/zorro8390.c b/drivers/net/zorro8390.c
index b78a38d9172a..8c7c522a056a 100644
--- a/drivers/net/zorro8390.c
+++ b/drivers/net/zorro8390.c
@@ -126,7 +126,7 @@ static int __devinit zorro8390_init_one(struct zorro_dev *z,
126 126
127 board = z->resource.start; 127 board = z->resource.start;
128 ioaddr = board+cards[i].offset; 128 ioaddr = board+cards[i].offset;
129 dev = alloc_ei_netdev(); 129 dev = ____alloc_ei_netdev(0);
130 if (!dev) 130 if (!dev)
131 return -ENOMEM; 131 return -ENOMEM;
132 if (!request_mem_region(ioaddr, NE_IO_EXTENT*2, DRV_NAME)) { 132 if (!request_mem_region(ioaddr, NE_IO_EXTENT*2, DRV_NAME)) {
@@ -146,15 +146,15 @@ static int __devinit zorro8390_init_one(struct zorro_dev *z,
146static const struct net_device_ops zorro8390_netdev_ops = { 146static const struct net_device_ops zorro8390_netdev_ops = {
147 .ndo_open = zorro8390_open, 147 .ndo_open = zorro8390_open,
148 .ndo_stop = zorro8390_close, 148 .ndo_stop = zorro8390_close,
149 .ndo_start_xmit = ei_start_xmit, 149 .ndo_start_xmit = __ei_start_xmit,
150 .ndo_tx_timeout = ei_tx_timeout, 150 .ndo_tx_timeout = __ei_tx_timeout,
151 .ndo_get_stats = ei_get_stats, 151 .ndo_get_stats = __ei_get_stats,
152 .ndo_set_multicast_list = ei_set_multicast_list, 152 .ndo_set_multicast_list = __ei_set_multicast_list,
153 .ndo_validate_addr = eth_validate_addr, 153 .ndo_validate_addr = eth_validate_addr,
154 .ndo_set_mac_address = eth_mac_addr, 154 .ndo_set_mac_address = eth_mac_addr,
155 .ndo_change_mtu = eth_change_mtu, 155 .ndo_change_mtu = eth_change_mtu,
156#ifdef CONFIG_NET_POLL_CONTROLLER 156#ifdef CONFIG_NET_POLL_CONTROLLER
157 .ndo_poll_controller = ei_poll, 157 .ndo_poll_controller = __ei_poll,
158#endif 158#endif
159}; 159};
160 160
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index a3755ffc03d4..bc8ce48f0778 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -2550,7 +2550,6 @@ static int __devinit sio_ite_8872_probe(struct pci_dev *pdev, int autoirq,
2550 const struct parport_pc_via_data *via) 2550 const struct parport_pc_via_data *via)
2551{ 2551{
2552 short inta_addr[6] = { 0x2A0, 0x2C0, 0x220, 0x240, 0x1E0 }; 2552 short inta_addr[6] = { 0x2A0, 0x2C0, 0x220, 0x240, 0x1E0 };
2553 struct resource *base_res;
2554 u32 ite8872set; 2553 u32 ite8872set;
2555 u32 ite8872_lpt, ite8872_lpthi; 2554 u32 ite8872_lpt, ite8872_lpthi;
2556 u8 ite8872_irq, type; 2555 u8 ite8872_irq, type;
@@ -2561,8 +2560,7 @@ static int __devinit sio_ite_8872_probe(struct pci_dev *pdev, int autoirq,
2561 2560
2562 /* make sure which one chip */ 2561 /* make sure which one chip */
2563 for (i = 0; i < 5; i++) { 2562 for (i = 0; i < 5; i++) {
2564 base_res = request_region(inta_addr[i], 32, "it887x"); 2563 if (request_region(inta_addr[i], 32, "it887x")) {
2565 if (base_res) {
2566 int test; 2564 int test;
2567 pci_write_config_dword(pdev, 0x60, 2565 pci_write_config_dword(pdev, 0x60,
2568 0xe5000000 | inta_addr[i]); 2566 0xe5000000 | inta_addr[i]);
@@ -2571,7 +2569,7 @@ static int __devinit sio_ite_8872_probe(struct pci_dev *pdev, int autoirq,
2571 test = inb(inta_addr[i]); 2569 test = inb(inta_addr[i]);
2572 if (test != 0xff) 2570 if (test != 0xff)
2573 break; 2571 break;
2574 release_region(inta_addr[i], 0x8); 2572 release_region(inta_addr[i], 32);
2575 } 2573 }
2576 } 2574 }
2577 if (i >= 5) { 2575 if (i >= 5) {
@@ -2635,7 +2633,7 @@ static int __devinit sio_ite_8872_probe(struct pci_dev *pdev, int autoirq,
2635 /* 2633 /*
2636 * Release the resource so that parport_pc_probe_port can get it. 2634 * Release the resource so that parport_pc_probe_port can get it.
2637 */ 2635 */
2638 release_resource(base_res); 2636 release_region(inta_addr[i], 32);
2639 if (parport_pc_probe_port(ite8872_lpt, ite8872_lpthi, 2637 if (parport_pc_probe_port(ite8872_lpt, ite8872_lpthi,
2640 irq, PARPORT_DMA_NONE, &pdev->dev, 0)) { 2638 irq, PARPORT_DMA_NONE, &pdev->dev, 0)) {
2641 printk(KERN_INFO 2639 printk(KERN_INFO
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
index c8ff646c0b05..0fa466a91bf4 100644
--- a/drivers/pci/Kconfig
+++ b/drivers/pci/Kconfig
@@ -88,4 +88,6 @@ config PCI_IOAPIC
88 depends on HOTPLUG 88 depends on HOTPLUG
89 default y 89 default y
90 90
91select NLS if (DMI || ACPI) 91config PCI_LABEL
92 def_bool y if (DMI || ACPI)
93 select NLS
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
index 98d61c8e984b..c85f744270a5 100644
--- a/drivers/pci/Makefile
+++ b/drivers/pci/Makefile
@@ -56,10 +56,10 @@ obj-$(CONFIG_TILE) += setup-bus.o setup-irq.o
56# ACPI Related PCI FW Functions 56# ACPI Related PCI FW Functions
57# ACPI _DSM provided firmware instance and string name 57# ACPI _DSM provided firmware instance and string name
58# 58#
59obj-$(CONFIG_ACPI) += pci-acpi.o pci-label.o 59obj-$(CONFIG_ACPI) += pci-acpi.o
60 60
61# SMBIOS provided firmware instance and labels 61# SMBIOS provided firmware instance and labels
62obj-$(CONFIG_DMI) += pci-label.o 62obj-$(CONFIG_PCI_LABEL) += pci-label.o
63 63
64# Cardbus & CompactPCI use setup-bus 64# Cardbus & CompactPCI use setup-bus
65obj-$(CONFIG_HOTPLUG) += setup-bus.o 65obj-$(CONFIG_HOTPLUG) += setup-bus.o
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 505c1c7075f0..d552d2c77844 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -1299,7 +1299,7 @@ static void iommu_detach_domain(struct dmar_domain *domain,
1299static struct iova_domain reserved_iova_list; 1299static struct iova_domain reserved_iova_list;
1300static struct lock_class_key reserved_rbtree_key; 1300static struct lock_class_key reserved_rbtree_key;
1301 1301
1302static void dmar_init_reserved_ranges(void) 1302static int dmar_init_reserved_ranges(void)
1303{ 1303{
1304 struct pci_dev *pdev = NULL; 1304 struct pci_dev *pdev = NULL;
1305 struct iova *iova; 1305 struct iova *iova;
@@ -1313,8 +1313,10 @@ static void dmar_init_reserved_ranges(void)
1313 /* IOAPIC ranges shouldn't be accessed by DMA */ 1313 /* IOAPIC ranges shouldn't be accessed by DMA */
1314 iova = reserve_iova(&reserved_iova_list, IOVA_PFN(IOAPIC_RANGE_START), 1314 iova = reserve_iova(&reserved_iova_list, IOVA_PFN(IOAPIC_RANGE_START),
1315 IOVA_PFN(IOAPIC_RANGE_END)); 1315 IOVA_PFN(IOAPIC_RANGE_END));
1316 if (!iova) 1316 if (!iova) {
1317 printk(KERN_ERR "Reserve IOAPIC range failed\n"); 1317 printk(KERN_ERR "Reserve IOAPIC range failed\n");
1318 return -ENODEV;
1319 }
1318 1320
1319 /* Reserve all PCI MMIO to avoid peer-to-peer access */ 1321 /* Reserve all PCI MMIO to avoid peer-to-peer access */
1320 for_each_pci_dev(pdev) { 1322 for_each_pci_dev(pdev) {
@@ -1327,11 +1329,13 @@ static void dmar_init_reserved_ranges(void)
1327 iova = reserve_iova(&reserved_iova_list, 1329 iova = reserve_iova(&reserved_iova_list,
1328 IOVA_PFN(r->start), 1330 IOVA_PFN(r->start),
1329 IOVA_PFN(r->end)); 1331 IOVA_PFN(r->end));
1330 if (!iova) 1332 if (!iova) {
1331 printk(KERN_ERR "Reserve iova failed\n"); 1333 printk(KERN_ERR "Reserve iova failed\n");
1334 return -ENODEV;
1335 }
1332 } 1336 }
1333 } 1337 }
1334 1338 return 0;
1335} 1339}
1336 1340
1337static void domain_reserve_special_ranges(struct dmar_domain *domain) 1341static void domain_reserve_special_ranges(struct dmar_domain *domain)
@@ -1835,7 +1839,7 @@ static struct dmar_domain *get_domain_for_dev(struct pci_dev *pdev, int gaw)
1835 1839
1836 ret = iommu_attach_domain(domain, iommu); 1840 ret = iommu_attach_domain(domain, iommu);
1837 if (ret) { 1841 if (ret) {
1838 domain_exit(domain); 1842 free_domain_mem(domain);
1839 goto error; 1843 goto error;
1840 } 1844 }
1841 1845
@@ -2213,7 +2217,7 @@ static int __init iommu_prepare_static_identity_mapping(int hw)
2213 return 0; 2217 return 0;
2214} 2218}
2215 2219
2216int __init init_dmars(void) 2220static int __init init_dmars(int force_on)
2217{ 2221{
2218 struct dmar_drhd_unit *drhd; 2222 struct dmar_drhd_unit *drhd;
2219 struct dmar_rmrr_unit *rmrr; 2223 struct dmar_rmrr_unit *rmrr;
@@ -2393,8 +2397,15 @@ int __init init_dmars(void)
2393 * enable translation 2397 * enable translation
2394 */ 2398 */
2395 for_each_drhd_unit(drhd) { 2399 for_each_drhd_unit(drhd) {
2396 if (drhd->ignored) 2400 if (drhd->ignored) {
2401 /*
2402 * we always have to disable PMRs or DMA may fail on
2403 * this device
2404 */
2405 if (force_on)
2406 iommu_disable_protect_mem_regions(drhd->iommu);
2397 continue; 2407 continue;
2408 }
2398 iommu = drhd->iommu; 2409 iommu = drhd->iommu;
2399 2410
2400 iommu_flush_write_buffer(iommu); 2411 iommu_flush_write_buffer(iommu);
@@ -3240,9 +3251,15 @@ static int device_notifier(struct notifier_block *nb,
3240 if (!domain) 3251 if (!domain)
3241 return 0; 3252 return 0;
3242 3253
3243 if (action == BUS_NOTIFY_UNBOUND_DRIVER && !iommu_pass_through) 3254 if (action == BUS_NOTIFY_UNBOUND_DRIVER && !iommu_pass_through) {
3244 domain_remove_one_dev_info(domain, pdev); 3255 domain_remove_one_dev_info(domain, pdev);
3245 3256
3257 if (!(domain->flags & DOMAIN_FLAG_VIRTUAL_MACHINE) &&
3258 !(domain->flags & DOMAIN_FLAG_STATIC_IDENTITY) &&
3259 list_empty(&domain->devices))
3260 domain_exit(domain);
3261 }
3262
3246 return 0; 3263 return 0;
3247} 3264}
3248 3265
@@ -3277,12 +3294,21 @@ int __init intel_iommu_init(void)
3277 if (no_iommu || dmar_disabled) 3294 if (no_iommu || dmar_disabled)
3278 return -ENODEV; 3295 return -ENODEV;
3279 3296
3280 iommu_init_mempool(); 3297 if (iommu_init_mempool()) {
3281 dmar_init_reserved_ranges(); 3298 if (force_on)
3299 panic("tboot: Failed to initialize iommu memory\n");
3300 return -ENODEV;
3301 }
3302
3303 if (dmar_init_reserved_ranges()) {
3304 if (force_on)
3305 panic("tboot: Failed to reserve iommu ranges\n");
3306 return -ENODEV;
3307 }
3282 3308
3283 init_no_remapping_devices(); 3309 init_no_remapping_devices();
3284 3310
3285 ret = init_dmars(); 3311 ret = init_dmars(force_on);
3286 if (ret) { 3312 if (ret) {
3287 if (force_on) 3313 if (force_on)
3288 panic("tboot: Failed to initialize DMARs\n"); 3314 panic("tboot: Failed to initialize DMARs\n");
@@ -3391,6 +3417,11 @@ static void domain_remove_one_dev_info(struct dmar_domain *domain,
3391 domain->iommu_count--; 3417 domain->iommu_count--;
3392 domain_update_iommu_cap(domain); 3418 domain_update_iommu_cap(domain);
3393 spin_unlock_irqrestore(&domain->iommu_lock, tmp_flags); 3419 spin_unlock_irqrestore(&domain->iommu_lock, tmp_flags);
3420
3421 spin_lock_irqsave(&iommu->lock, tmp_flags);
3422 clear_bit(domain->id, iommu->domain_ids);
3423 iommu->domains[domain->id] = NULL;
3424 spin_unlock_irqrestore(&iommu->lock, tmp_flags);
3394 } 3425 }
3395 3426
3396 spin_unlock_irqrestore(&device_domain_lock, flags); 3427 spin_unlock_irqrestore(&device_domain_lock, flags);
@@ -3607,9 +3638,9 @@ static int intel_iommu_attach_device(struct iommu_domain *domain,
3607 3638
3608 pte = dmar_domain->pgd; 3639 pte = dmar_domain->pgd;
3609 if (dma_pte_present(pte)) { 3640 if (dma_pte_present(pte)) {
3610 free_pgtable_page(dmar_domain->pgd);
3611 dmar_domain->pgd = (struct dma_pte *) 3641 dmar_domain->pgd = (struct dma_pte *)
3612 phys_to_virt(dma_pte_addr(pte)); 3642 phys_to_virt(dma_pte_addr(pte));
3643 free_pgtable_page(pte);
3613 } 3644 }
3614 dmar_domain->agaw--; 3645 dmar_domain->agaw--;
3615 } 3646 }
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index ebf51ad1b714..a806cb321d2e 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -579,7 +579,7 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
579 } 579 }
580 size0 = calculate_iosize(size, min_size, size1, 580 size0 = calculate_iosize(size, min_size, size1,
581 resource_size(b_res), 4096); 581 resource_size(b_res), 4096);
582 size1 = !add_size? size0: 582 size1 = (!add_head || (add_head && !add_size)) ? size0 :
583 calculate_iosize(size, min_size+add_size, size1, 583 calculate_iosize(size, min_size+add_size, size1,
584 resource_size(b_res), 4096); 584 resource_size(b_res), 4096);
585 if (!size0 && !size1) { 585 if (!size0 && !size1) {
@@ -677,7 +677,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
677 align += aligns[order]; 677 align += aligns[order];
678 } 678 }
679 size0 = calculate_memsize(size, min_size, 0, resource_size(b_res), min_align); 679 size0 = calculate_memsize(size, min_size, 0, resource_size(b_res), min_align);
680 size1 = !add_size ? size : 680 size1 = (!add_head || (add_head && !add_size)) ? size0 :
681 calculate_memsize(size, min_size+add_size, 0, 681 calculate_memsize(size, min_size+add_size, 0,
682 resource_size(b_res), min_align); 682 resource_size(b_res), min_align);
683 if (!size0 && !size1) { 683 if (!size0 && !size1) {
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index fe77e8223841..e8c19def1b0f 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -173,7 +173,7 @@ static int pcmcia_access_config(struct pcmcia_device *p_dev,
173 c = p_dev->function_config; 173 c = p_dev->function_config;
174 174
175 if (!(c->state & CONFIG_LOCKED)) { 175 if (!(c->state & CONFIG_LOCKED)) {
176 dev_dbg(&p_dev->dev, "Configuration isn't't locked\n"); 176 dev_dbg(&p_dev->dev, "Configuration isn't locked\n");
177 mutex_unlock(&s->ops_mutex); 177 mutex_unlock(&s->ops_mutex);
178 return -EACCES; 178 return -EACCES;
179 } 179 }
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 5f2dd386152b..2c1abf63957f 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -585,8 +585,9 @@ static bool eeepc_wlan_rfkill_blocked(struct eeepc_laptop *eeepc)
585 return true; 585 return true;
586} 586}
587 587
588static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc) 588static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc, acpi_handle handle)
589{ 589{
590 struct pci_dev *port;
590 struct pci_dev *dev; 591 struct pci_dev *dev;
591 struct pci_bus *bus; 592 struct pci_bus *bus;
592 bool blocked = eeepc_wlan_rfkill_blocked(eeepc); 593 bool blocked = eeepc_wlan_rfkill_blocked(eeepc);
@@ -599,9 +600,16 @@ static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc)
599 mutex_lock(&eeepc->hotplug_lock); 600 mutex_lock(&eeepc->hotplug_lock);
600 601
601 if (eeepc->hotplug_slot) { 602 if (eeepc->hotplug_slot) {
602 bus = pci_find_bus(0, 1); 603 port = acpi_get_pci_dev(handle);
604 if (!port) {
605 pr_warning("Unable to find port\n");
606 goto out_unlock;
607 }
608
609 bus = port->subordinate;
610
603 if (!bus) { 611 if (!bus) {
604 pr_warning("Unable to find PCI bus 1?\n"); 612 pr_warning("Unable to find PCI bus?\n");
605 goto out_unlock; 613 goto out_unlock;
606 } 614 }
607 615
@@ -609,6 +617,7 @@ static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc)
609 pr_err("Unable to read PCI config space?\n"); 617 pr_err("Unable to read PCI config space?\n");
610 goto out_unlock; 618 goto out_unlock;
611 } 619 }
620
612 absent = (l == 0xffffffff); 621 absent = (l == 0xffffffff);
613 622
614 if (blocked != absent) { 623 if (blocked != absent) {
@@ -647,6 +656,17 @@ out_unlock:
647 mutex_unlock(&eeepc->hotplug_lock); 656 mutex_unlock(&eeepc->hotplug_lock);
648} 657}
649 658
659static void eeepc_rfkill_hotplug_update(struct eeepc_laptop *eeepc, char *node)
660{
661 acpi_status status = AE_OK;
662 acpi_handle handle;
663
664 status = acpi_get_handle(NULL, node, &handle);
665
666 if (ACPI_SUCCESS(status))
667 eeepc_rfkill_hotplug(eeepc, handle);
668}
669
650static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data) 670static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
651{ 671{
652 struct eeepc_laptop *eeepc = data; 672 struct eeepc_laptop *eeepc = data;
@@ -654,7 +674,7 @@ static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
654 if (event != ACPI_NOTIFY_BUS_CHECK) 674 if (event != ACPI_NOTIFY_BUS_CHECK)
655 return; 675 return;
656 676
657 eeepc_rfkill_hotplug(eeepc); 677 eeepc_rfkill_hotplug(eeepc, handle);
658} 678}
659 679
660static int eeepc_register_rfkill_notifier(struct eeepc_laptop *eeepc, 680static int eeepc_register_rfkill_notifier(struct eeepc_laptop *eeepc,
@@ -672,6 +692,11 @@ static int eeepc_register_rfkill_notifier(struct eeepc_laptop *eeepc,
672 eeepc); 692 eeepc);
673 if (ACPI_FAILURE(status)) 693 if (ACPI_FAILURE(status))
674 pr_warning("Failed to register notify on %s\n", node); 694 pr_warning("Failed to register notify on %s\n", node);
695 /*
696 * Refresh pci hotplug in case the rfkill state was
697 * changed during setup.
698 */
699 eeepc_rfkill_hotplug(eeepc, handle);
675 } else 700 } else
676 return -ENODEV; 701 return -ENODEV;
677 702
@@ -693,6 +718,12 @@ static void eeepc_unregister_rfkill_notifier(struct eeepc_laptop *eeepc,
693 if (ACPI_FAILURE(status)) 718 if (ACPI_FAILURE(status))
694 pr_err("Error removing rfkill notify handler %s\n", 719 pr_err("Error removing rfkill notify handler %s\n",
695 node); 720 node);
721 /*
722 * Refresh pci hotplug in case the rfkill
723 * state was changed after
724 * eeepc_unregister_rfkill_notifier()
725 */
726 eeepc_rfkill_hotplug(eeepc, handle);
696 } 727 }
697} 728}
698 729
@@ -816,11 +847,7 @@ static void eeepc_rfkill_exit(struct eeepc_laptop *eeepc)
816 rfkill_destroy(eeepc->wlan_rfkill); 847 rfkill_destroy(eeepc->wlan_rfkill);
817 eeepc->wlan_rfkill = NULL; 848 eeepc->wlan_rfkill = NULL;
818 } 849 }
819 /* 850
820 * Refresh pci hotplug in case the rfkill state was changed after
821 * eeepc_unregister_rfkill_notifier()
822 */
823 eeepc_rfkill_hotplug(eeepc);
824 if (eeepc->hotplug_slot) 851 if (eeepc->hotplug_slot)
825 pci_hp_deregister(eeepc->hotplug_slot); 852 pci_hp_deregister(eeepc->hotplug_slot);
826 853
@@ -889,11 +916,6 @@ static int eeepc_rfkill_init(struct eeepc_laptop *eeepc)
889 eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P5"); 916 eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P5");
890 eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P6"); 917 eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P6");
891 eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P7"); 918 eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P7");
892 /*
893 * Refresh pci hotplug in case the rfkill state was changed during
894 * setup.
895 */
896 eeepc_rfkill_hotplug(eeepc);
897 919
898exit: 920exit:
899 if (result && result != -ENODEV) 921 if (result && result != -ENODEV)
@@ -928,8 +950,11 @@ static int eeepc_hotk_restore(struct device *device)
928 struct eeepc_laptop *eeepc = dev_get_drvdata(device); 950 struct eeepc_laptop *eeepc = dev_get_drvdata(device);
929 951
930 /* Refresh both wlan rfkill state and pci hotplug */ 952 /* Refresh both wlan rfkill state and pci hotplug */
931 if (eeepc->wlan_rfkill) 953 if (eeepc->wlan_rfkill) {
932 eeepc_rfkill_hotplug(eeepc); 954 eeepc_rfkill_hotplug_update(eeepc, "\\_SB.PCI0.P0P5");
955 eeepc_rfkill_hotplug_update(eeepc, "\\_SB.PCI0.P0P6");
956 eeepc_rfkill_hotplug_update(eeepc, "\\_SB.PCI0.P0P7");
957 }
933 958
934 if (eeepc->bluetooth_rfkill) 959 if (eeepc->bluetooth_rfkill)
935 rfkill_set_sw_state(eeepc->bluetooth_rfkill, 960 rfkill_set_sw_state(eeepc->bluetooth_rfkill,
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 8f709aec4da0..6fe8cd6e23b5 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -934,6 +934,14 @@ static ssize_t sony_nc_sysfs_store(struct device *dev,
934/* 934/*
935 * Backlight device 935 * Backlight device
936 */ 936 */
937struct sony_backlight_props {
938 struct backlight_device *dev;
939 int handle;
940 u8 offset;
941 u8 maxlvl;
942};
943struct sony_backlight_props sony_bl_props;
944
937static int sony_backlight_update_status(struct backlight_device *bd) 945static int sony_backlight_update_status(struct backlight_device *bd)
938{ 946{
939 return acpi_callsetfunc(sony_nc_acpi_handle, "SBRT", 947 return acpi_callsetfunc(sony_nc_acpi_handle, "SBRT",
@@ -954,21 +962,26 @@ static int sony_nc_get_brightness_ng(struct backlight_device *bd)
954{ 962{
955 int result; 963 int result;
956 int *handle = (int *)bl_get_data(bd); 964 int *handle = (int *)bl_get_data(bd);
965 struct sony_backlight_props *sdev =
966 (struct sony_backlight_props *)bl_get_data(bd);
957 967
958 sony_call_snc_handle(*handle, 0x0200, &result); 968 sony_call_snc_handle(sdev->handle, 0x0200, &result);
959 969
960 return result & 0xff; 970 return (result & 0xff) - sdev->offset;
961} 971}
962 972
963static int sony_nc_update_status_ng(struct backlight_device *bd) 973static int sony_nc_update_status_ng(struct backlight_device *bd)
964{ 974{
965 int value, result; 975 int value, result;
966 int *handle = (int *)bl_get_data(bd); 976 int *handle = (int *)bl_get_data(bd);
977 struct sony_backlight_props *sdev =
978 (struct sony_backlight_props *)bl_get_data(bd);
967 979
968 value = bd->props.brightness; 980 value = bd->props.brightness + sdev->offset;
969 sony_call_snc_handle(*handle, 0x0100 | (value << 16), &result); 981 if (sony_call_snc_handle(sdev->handle, 0x0100 | (value << 16), &result))
982 return -EIO;
970 983
971 return sony_nc_get_brightness_ng(bd); 984 return value;
972} 985}
973 986
974static const struct backlight_ops sony_backlight_ops = { 987static const struct backlight_ops sony_backlight_ops = {
@@ -981,8 +994,6 @@ static const struct backlight_ops sony_backlight_ng_ops = {
981 .update_status = sony_nc_update_status_ng, 994 .update_status = sony_nc_update_status_ng,
982 .get_brightness = sony_nc_get_brightness_ng, 995 .get_brightness = sony_nc_get_brightness_ng,
983}; 996};
984static int backlight_ng_handle;
985static struct backlight_device *sony_backlight_device;
986 997
987/* 998/*
988 * New SNC-only Vaios event mapping to driver known keys 999 * New SNC-only Vaios event mapping to driver known keys
@@ -1549,6 +1560,75 @@ static void sony_nc_kbd_backlight_resume(void)
1549 &ignore); 1560 &ignore);
1550} 1561}
1551 1562
1563static void sony_nc_backlight_ng_read_limits(int handle,
1564 struct sony_backlight_props *props)
1565{
1566 int offset;
1567 acpi_status status;
1568 u8 brlvl, i;
1569 u8 min = 0xff, max = 0x00;
1570 struct acpi_object_list params;
1571 union acpi_object in_obj;
1572 union acpi_object *lvl_enum;
1573 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
1574
1575 props->handle = handle;
1576 props->offset = 0;
1577 props->maxlvl = 0xff;
1578
1579 offset = sony_find_snc_handle(handle);
1580 if (offset < 0)
1581 return;
1582
1583 /* try to read the boundaries from ACPI tables, if we fail the above
1584 * defaults should be reasonable
1585 */
1586 params.count = 1;
1587 params.pointer = &in_obj;
1588 in_obj.type = ACPI_TYPE_INTEGER;
1589 in_obj.integer.value = offset;
1590 status = acpi_evaluate_object(sony_nc_acpi_handle, "SN06", &params,
1591 &buffer);
1592 if (ACPI_FAILURE(status))
1593 return;
1594
1595 lvl_enum = (union acpi_object *) buffer.pointer;
1596 if (!lvl_enum) {
1597 pr_err("No SN06 return object.");
1598 return;
1599 }
1600 if (lvl_enum->type != ACPI_TYPE_BUFFER) {
1601 pr_err("Invalid SN06 return object 0x%.2x\n",
1602 lvl_enum->type);
1603 goto out_invalid;
1604 }
1605
1606 /* the buffer lists brightness levels available, brightness levels are
1607 * from 0 to 8 in the array, other values are used by ALS control.
1608 */
1609 for (i = 0; i < 9 && i < lvl_enum->buffer.length; i++) {
1610
1611 brlvl = *(lvl_enum->buffer.pointer + i);
1612 dprintk("Brightness level: %d\n", brlvl);
1613
1614 if (!brlvl)
1615 break;
1616
1617 if (brlvl > max)
1618 max = brlvl;
1619 if (brlvl < min)
1620 min = brlvl;
1621 }
1622 props->offset = min;
1623 props->maxlvl = max;
1624 dprintk("Brightness levels: min=%d max=%d\n", props->offset,
1625 props->maxlvl);
1626
1627out_invalid:
1628 kfree(buffer.pointer);
1629 return;
1630}
1631
1552static void sony_nc_backlight_setup(void) 1632static void sony_nc_backlight_setup(void)
1553{ 1633{
1554 acpi_handle unused; 1634 acpi_handle unused;
@@ -1557,14 +1637,14 @@ static void sony_nc_backlight_setup(void)
1557 struct backlight_properties props; 1637 struct backlight_properties props;
1558 1638
1559 if (sony_find_snc_handle(0x12f) != -1) { 1639 if (sony_find_snc_handle(0x12f) != -1) {
1560 backlight_ng_handle = 0x12f;
1561 ops = &sony_backlight_ng_ops; 1640 ops = &sony_backlight_ng_ops;
1562 max_brightness = 0xff; 1641 sony_nc_backlight_ng_read_limits(0x12f, &sony_bl_props);
1642 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset;
1563 1643
1564 } else if (sony_find_snc_handle(0x137) != -1) { 1644 } else if (sony_find_snc_handle(0x137) != -1) {
1565 backlight_ng_handle = 0x137;
1566 ops = &sony_backlight_ng_ops; 1645 ops = &sony_backlight_ng_ops;
1567 max_brightness = 0xff; 1646 sony_nc_backlight_ng_read_limits(0x137, &sony_bl_props);
1647 max_brightness = sony_bl_props.maxlvl - sony_bl_props.offset;
1568 1648
1569 } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT", 1649 } else if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, "GBRT",
1570 &unused))) { 1650 &unused))) {
@@ -1577,22 +1657,22 @@ static void sony_nc_backlight_setup(void)
1577 memset(&props, 0, sizeof(struct backlight_properties)); 1657 memset(&props, 0, sizeof(struct backlight_properties));
1578 props.type = BACKLIGHT_PLATFORM; 1658 props.type = BACKLIGHT_PLATFORM;
1579 props.max_brightness = max_brightness; 1659 props.max_brightness = max_brightness;
1580 sony_backlight_device = backlight_device_register("sony", NULL, 1660 sony_bl_props.dev = backlight_device_register("sony", NULL,
1581 &backlight_ng_handle, 1661 &sony_bl_props,
1582 ops, &props); 1662 ops, &props);
1583 1663
1584 if (IS_ERR(sony_backlight_device)) { 1664 if (IS_ERR(sony_bl_props.dev)) {
1585 pr_warning(DRV_PFX "unable to register backlight device\n"); 1665 pr_warn(DRV_PFX "unable to register backlight device\n");
1586 sony_backlight_device = NULL; 1666 sony_bl_props.dev = NULL;
1587 } else 1667 } else
1588 sony_backlight_device->props.brightness = 1668 sony_bl_props.dev->props.brightness =
1589 ops->get_brightness(sony_backlight_device); 1669 ops->get_brightness(sony_bl_props.dev);
1590} 1670}
1591 1671
1592static void sony_nc_backlight_cleanup(void) 1672static void sony_nc_backlight_cleanup(void)
1593{ 1673{
1594 if (sony_backlight_device) 1674 if (sony_bl_props.dev)
1595 backlight_device_unregister(sony_backlight_device); 1675 backlight_device_unregister(sony_bl_props.dev);
1596} 1676}
1597 1677
1598static int sony_nc_add(struct acpi_device *device) 1678static int sony_nc_add(struct acpi_device *device)
@@ -2590,7 +2670,7 @@ static long sonypi_misc_ioctl(struct file *fp, unsigned int cmd,
2590 mutex_lock(&spic_dev.lock); 2670 mutex_lock(&spic_dev.lock);
2591 switch (cmd) { 2671 switch (cmd) {
2592 case SONYPI_IOCGBRT: 2672 case SONYPI_IOCGBRT:
2593 if (sony_backlight_device == NULL) { 2673 if (sony_bl_props.dev == NULL) {
2594 ret = -EIO; 2674 ret = -EIO;
2595 break; 2675 break;
2596 } 2676 }
@@ -2603,7 +2683,7 @@ static long sonypi_misc_ioctl(struct file *fp, unsigned int cmd,
2603 ret = -EFAULT; 2683 ret = -EFAULT;
2604 break; 2684 break;
2605 case SONYPI_IOCSBRT: 2685 case SONYPI_IOCSBRT:
2606 if (sony_backlight_device == NULL) { 2686 if (sony_bl_props.dev == NULL) {
2607 ret = -EIO; 2687 ret = -EIO;
2608 break; 2688 break;
2609 } 2689 }
@@ -2617,8 +2697,8 @@ static long sonypi_misc_ioctl(struct file *fp, unsigned int cmd,
2617 break; 2697 break;
2618 } 2698 }
2619 /* sync the backlight device status */ 2699 /* sync the backlight device status */
2620 sony_backlight_device->props.brightness = 2700 sony_bl_props.dev->props.brightness =
2621 sony_backlight_get_brightness(sony_backlight_device); 2701 sony_backlight_get_brightness(sony_bl_props.dev);
2622 break; 2702 break;
2623 case SONYPI_IOCGBAT1CAP: 2703 case SONYPI_IOCGBAT1CAP:
2624 if (ec_read16(SONYPI_BAT1_FULL, &val16)) { 2704 if (ec_read16(SONYPI_BAT1_FULL, &val16)) {
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index efb3b6b9bcdb..562fcf0dd2b5 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -128,7 +128,8 @@ enum {
128}; 128};
129 129
130/* ACPI HIDs */ 130/* ACPI HIDs */
131#define TPACPI_ACPI_HKEY_HID "IBM0068" 131#define TPACPI_ACPI_IBM_HKEY_HID "IBM0068"
132#define TPACPI_ACPI_LENOVO_HKEY_HID "LEN0068"
132#define TPACPI_ACPI_EC_HID "PNP0C09" 133#define TPACPI_ACPI_EC_HID "PNP0C09"
133 134
134/* Input IDs */ 135/* Input IDs */
@@ -3879,7 +3880,8 @@ errexit:
3879} 3880}
3880 3881
3881static const struct acpi_device_id ibm_htk_device_ids[] = { 3882static const struct acpi_device_id ibm_htk_device_ids[] = {
3882 {TPACPI_ACPI_HKEY_HID, 0}, 3883 {TPACPI_ACPI_IBM_HKEY_HID, 0},
3884 {TPACPI_ACPI_LENOVO_HKEY_HID, 0},
3883 {"", 0}, 3885 {"", 0},
3884}; 3886};
3885 3887
diff --git a/drivers/rapidio/switches/idt_gen2.c b/drivers/rapidio/switches/idt_gen2.c
index ac2701b22e71..043ee3136e40 100644
--- a/drivers/rapidio/switches/idt_gen2.c
+++ b/drivers/rapidio/switches/idt_gen2.c
@@ -95,6 +95,9 @@ idtg2_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount,
95 else 95 else
96 table++; 96 table++;
97 97
98 if (route_port == RIO_INVALID_ROUTE)
99 route_port = IDT_DEFAULT_ROUTE;
100
98 rio_mport_write_config_32(mport, destid, hopcount, 101 rio_mport_write_config_32(mport, destid, hopcount,
99 LOCAL_RTE_CONF_DESTID_SEL, table); 102 LOCAL_RTE_CONF_DESTID_SEL, table);
100 103
@@ -411,6 +414,12 @@ static int idtg2_switch_init(struct rio_dev *rdev, int do_enum)
411 rdev->rswitch->em_handle = idtg2_em_handler; 414 rdev->rswitch->em_handle = idtg2_em_handler;
412 rdev->rswitch->sw_sysfs = idtg2_sysfs; 415 rdev->rswitch->sw_sysfs = idtg2_sysfs;
413 416
417 if (do_enum) {
418 /* Ensure that default routing is disabled on startup */
419 rio_write_config_32(rdev,
420 RIO_STD_RTE_DEFAULT_PORT, IDT_NO_ROUTE);
421 }
422
414 return 0; 423 return 0;
415} 424}
416 425
diff --git a/drivers/rapidio/switches/idtcps.c b/drivers/rapidio/switches/idtcps.c
index 3a971077e7bf..d06ee2d44b44 100644
--- a/drivers/rapidio/switches/idtcps.c
+++ b/drivers/rapidio/switches/idtcps.c
@@ -26,6 +26,9 @@ idtcps_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount,
26{ 26{
27 u32 result; 27 u32 result;
28 28
29 if (route_port == RIO_INVALID_ROUTE)
30 route_port = CPS_DEFAULT_ROUTE;
31
29 if (table == RIO_GLOBAL_TABLE) { 32 if (table == RIO_GLOBAL_TABLE) {
30 rio_mport_write_config_32(mport, destid, hopcount, 33 rio_mport_write_config_32(mport, destid, hopcount,
31 RIO_STD_RTE_CONF_DESTID_SEL_CSR, route_destid); 34 RIO_STD_RTE_CONF_DESTID_SEL_CSR, route_destid);
@@ -130,6 +133,9 @@ static int idtcps_switch_init(struct rio_dev *rdev, int do_enum)
130 /* set TVAL = ~50us */ 133 /* set TVAL = ~50us */
131 rio_write_config_32(rdev, 134 rio_write_config_32(rdev,
132 rdev->phys_efptr + RIO_PORT_LINKTO_CTL_CSR, 0x8e << 8); 135 rdev->phys_efptr + RIO_PORT_LINKTO_CTL_CSR, 0x8e << 8);
136 /* Ensure that default routing is disabled on startup */
137 rio_write_config_32(rdev,
138 RIO_STD_RTE_DEFAULT_PORT, CPS_NO_ROUTE);
133 } 139 }
134 140
135 return 0; 141 return 0;
diff --git a/drivers/rapidio/switches/tsi57x.c b/drivers/rapidio/switches/tsi57x.c
index 1a62934bfebc..db8b8028988d 100644
--- a/drivers/rapidio/switches/tsi57x.c
+++ b/drivers/rapidio/switches/tsi57x.c
@@ -303,6 +303,12 @@ static int tsi57x_switch_init(struct rio_dev *rdev, int do_enum)
303 rdev->rswitch->em_init = tsi57x_em_init; 303 rdev->rswitch->em_init = tsi57x_em_init;
304 rdev->rswitch->em_handle = tsi57x_em_handler; 304 rdev->rswitch->em_handle = tsi57x_em_handler;
305 305
306 if (do_enum) {
307 /* Ensure that default routing is disabled on startup */
308 rio_write_config_32(rdev, RIO_STD_RTE_DEFAULT_PORT,
309 RIO_INVALID_ROUTE);
310 }
311
306 return 0; 312 return 0;
307} 313}
308 314
diff --git a/drivers/rtc/rtc-coh901331.c b/drivers/rtc/rtc-coh901331.c
index 316f484999b5..80f9c88214c5 100644
--- a/drivers/rtc/rtc-coh901331.c
+++ b/drivers/rtc/rtc-coh901331.c
@@ -220,6 +220,7 @@ static int __init coh901331_probe(struct platform_device *pdev)
220 } 220 }
221 clk_disable(rtap->clk); 221 clk_disable(rtap->clk);
222 222
223 platform_set_drvdata(pdev, rtap);
223 rtap->rtc = rtc_device_register("coh901331", &pdev->dev, &coh901331_ops, 224 rtap->rtc = rtc_device_register("coh901331", &pdev->dev, &coh901331_ops,
224 THIS_MODULE); 225 THIS_MODULE);
225 if (IS_ERR(rtap->rtc)) { 226 if (IS_ERR(rtap->rtc)) {
@@ -227,11 +228,10 @@ static int __init coh901331_probe(struct platform_device *pdev)
227 goto out_no_rtc; 228 goto out_no_rtc;
228 } 229 }
229 230
230 platform_set_drvdata(pdev, rtap);
231
232 return 0; 231 return 0;
233 232
234 out_no_rtc: 233 out_no_rtc:
234 platform_set_drvdata(pdev, NULL);
235 out_no_clk_enable: 235 out_no_clk_enable:
236 clk_put(rtap->clk); 236 clk_put(rtap->clk);
237 out_no_clk: 237 out_no_clk:
diff --git a/drivers/rtc/rtc-davinci.c b/drivers/rtc/rtc-davinci.c
index 8d46838dff8a..755e1fe914af 100644
--- a/drivers/rtc/rtc-davinci.c
+++ b/drivers/rtc/rtc-davinci.c
@@ -524,6 +524,8 @@ static int __init davinci_rtc_probe(struct platform_device *pdev)
524 goto fail2; 524 goto fail2;
525 } 525 }
526 526
527 platform_set_drvdata(pdev, davinci_rtc);
528
527 davinci_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, 529 davinci_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev,
528 &davinci_rtc_ops, THIS_MODULE); 530 &davinci_rtc_ops, THIS_MODULE);
529 if (IS_ERR(davinci_rtc->rtc)) { 531 if (IS_ERR(davinci_rtc->rtc)) {
@@ -553,8 +555,6 @@ static int __init davinci_rtc_probe(struct platform_device *pdev)
553 555
554 rtcss_write(davinci_rtc, PRTCSS_RTC_CCTRL_CAEN, PRTCSS_RTC_CCTRL); 556 rtcss_write(davinci_rtc, PRTCSS_RTC_CCTRL_CAEN, PRTCSS_RTC_CCTRL);
555 557
556 platform_set_drvdata(pdev, davinci_rtc);
557
558 device_init_wakeup(&pdev->dev, 0); 558 device_init_wakeup(&pdev->dev, 0);
559 559
560 return 0; 560 return 0;
@@ -562,6 +562,7 @@ static int __init davinci_rtc_probe(struct platform_device *pdev)
562fail4: 562fail4:
563 rtc_device_unregister(davinci_rtc->rtc); 563 rtc_device_unregister(davinci_rtc->rtc);
564fail3: 564fail3:
565 platform_set_drvdata(pdev, NULL);
565 iounmap(davinci_rtc->base); 566 iounmap(davinci_rtc->base);
566fail2: 567fail2:
567 release_mem_region(davinci_rtc->pbase, davinci_rtc->base_size); 568 release_mem_region(davinci_rtc->pbase, davinci_rtc->base_size);
diff --git a/drivers/rtc/rtc-ds1286.c b/drivers/rtc/rtc-ds1286.c
index 60ce69600828..47e681df31e2 100644
--- a/drivers/rtc/rtc-ds1286.c
+++ b/drivers/rtc/rtc-ds1286.c
@@ -355,6 +355,7 @@ static int __devinit ds1286_probe(struct platform_device *pdev)
355 goto out; 355 goto out;
356 } 356 }
357 spin_lock_init(&priv->lock); 357 spin_lock_init(&priv->lock);
358 platform_set_drvdata(pdev, priv);
358 rtc = rtc_device_register("ds1286", &pdev->dev, 359 rtc = rtc_device_register("ds1286", &pdev->dev,
359 &ds1286_ops, THIS_MODULE); 360 &ds1286_ops, THIS_MODULE);
360 if (IS_ERR(rtc)) { 361 if (IS_ERR(rtc)) {
@@ -362,7 +363,6 @@ static int __devinit ds1286_probe(struct platform_device *pdev)
362 goto out; 363 goto out;
363 } 364 }
364 priv->rtc = rtc; 365 priv->rtc = rtc;
365 platform_set_drvdata(pdev, priv);
366 return 0; 366 return 0;
367 367
368out: 368out:
diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c
index 11ae64dcbf3c..335551d333b2 100644
--- a/drivers/rtc/rtc-ep93xx.c
+++ b/drivers/rtc/rtc-ep93xx.c
@@ -151,6 +151,7 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev)
151 return -ENXIO; 151 return -ENXIO;
152 152
153 pdev->dev.platform_data = ep93xx_rtc; 153 pdev->dev.platform_data = ep93xx_rtc;
154 platform_set_drvdata(pdev, rtc);
154 155
155 rtc = rtc_device_register(pdev->name, 156 rtc = rtc_device_register(pdev->name,
156 &pdev->dev, &ep93xx_rtc_ops, THIS_MODULE); 157 &pdev->dev, &ep93xx_rtc_ops, THIS_MODULE);
@@ -159,8 +160,6 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev)
159 goto exit; 160 goto exit;
160 } 161 }
161 162
162 platform_set_drvdata(pdev, rtc);
163
164 err = sysfs_create_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files); 163 err = sysfs_create_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files);
165 if (err) 164 if (err)
166 goto fail; 165 goto fail;
@@ -168,9 +167,9 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev)
168 return 0; 167 return 0;
169 168
170fail: 169fail:
171 platform_set_drvdata(pdev, NULL);
172 rtc_device_unregister(rtc); 170 rtc_device_unregister(rtc);
173exit: 171exit:
172 platform_set_drvdata(pdev, NULL);
174 pdev->dev.platform_data = NULL; 173 pdev->dev.platform_data = NULL;
175 return err; 174 return err;
176} 175}
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 69fe664a2228..eda128fc1d38 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -783,6 +783,9 @@ static int m41t80_probe(struct i2c_client *client,
783 goto exit; 783 goto exit;
784 } 784 }
785 785
786 clientdata->features = id->driver_data;
787 i2c_set_clientdata(client, clientdata);
788
786 rtc = rtc_device_register(client->name, &client->dev, 789 rtc = rtc_device_register(client->name, &client->dev,
787 &m41t80_rtc_ops, THIS_MODULE); 790 &m41t80_rtc_ops, THIS_MODULE);
788 if (IS_ERR(rtc)) { 791 if (IS_ERR(rtc)) {
@@ -792,8 +795,6 @@ static int m41t80_probe(struct i2c_client *client,
792 } 795 }
793 796
794 clientdata->rtc = rtc; 797 clientdata->rtc = rtc;
795 clientdata->features = id->driver_data;
796 i2c_set_clientdata(client, clientdata);
797 798
798 /* Make sure HT (Halt Update) bit is cleared */ 799 /* Make sure HT (Halt Update) bit is cleared */
799 rc = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR); 800 rc = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR);
diff --git a/drivers/rtc/rtc-max8925.c b/drivers/rtc/rtc-max8925.c
index 174036dda786..3bc046f427e0 100644
--- a/drivers/rtc/rtc-max8925.c
+++ b/drivers/rtc/rtc-max8925.c
@@ -257,6 +257,10 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev)
257 goto out_irq; 257 goto out_irq;
258 } 258 }
259 259
260 dev_set_drvdata(&pdev->dev, info);
261 /* XXX - isn't this redundant? */
262 platform_set_drvdata(pdev, info);
263
260 info->rtc_dev = rtc_device_register("max8925-rtc", &pdev->dev, 264 info->rtc_dev = rtc_device_register("max8925-rtc", &pdev->dev,
261 &max8925_rtc_ops, THIS_MODULE); 265 &max8925_rtc_ops, THIS_MODULE);
262 ret = PTR_ERR(info->rtc_dev); 266 ret = PTR_ERR(info->rtc_dev);
@@ -265,11 +269,9 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev)
265 goto out_rtc; 269 goto out_rtc;
266 } 270 }
267 271
268 dev_set_drvdata(&pdev->dev, info);
269 platform_set_drvdata(pdev, info);
270
271 return 0; 272 return 0;
272out_rtc: 273out_rtc:
274 platform_set_drvdata(pdev, NULL);
273 free_irq(chip->irq_base + MAX8925_IRQ_RTC_ALARM0, info); 275 free_irq(chip->irq_base + MAX8925_IRQ_RTC_ALARM0, info);
274out_irq: 276out_irq:
275 kfree(info); 277 kfree(info);
diff --git a/drivers/rtc/rtc-max8998.c b/drivers/rtc/rtc-max8998.c
index 3f7bc6b9fefa..2e48aa604273 100644
--- a/drivers/rtc/rtc-max8998.c
+++ b/drivers/rtc/rtc-max8998.c
@@ -265,6 +265,8 @@ static int __devinit max8998_rtc_probe(struct platform_device *pdev)
265 info->rtc = max8998->rtc; 265 info->rtc = max8998->rtc;
266 info->irq = max8998->irq_base + MAX8998_IRQ_ALARM0; 266 info->irq = max8998->irq_base + MAX8998_IRQ_ALARM0;
267 267
268 platform_set_drvdata(pdev, info);
269
268 info->rtc_dev = rtc_device_register("max8998-rtc", &pdev->dev, 270 info->rtc_dev = rtc_device_register("max8998-rtc", &pdev->dev,
269 &max8998_rtc_ops, THIS_MODULE); 271 &max8998_rtc_ops, THIS_MODULE);
270 272
@@ -274,8 +276,6 @@ static int __devinit max8998_rtc_probe(struct platform_device *pdev)
274 goto out_rtc; 276 goto out_rtc;
275 } 277 }
276 278
277 platform_set_drvdata(pdev, info);
278
279 ret = request_threaded_irq(info->irq, NULL, max8998_rtc_alarm_irq, 0, 279 ret = request_threaded_irq(info->irq, NULL, max8998_rtc_alarm_irq, 0,
280 "rtc-alarm0", info); 280 "rtc-alarm0", info);
281 281
@@ -293,6 +293,7 @@ static int __devinit max8998_rtc_probe(struct platform_device *pdev)
293 return 0; 293 return 0;
294 294
295out_rtc: 295out_rtc:
296 platform_set_drvdata(pdev, NULL);
296 kfree(info); 297 kfree(info);
297 return ret; 298 return ret;
298} 299}
diff --git a/drivers/rtc/rtc-mc13xxx.c b/drivers/rtc/rtc-mc13xxx.c
index c5ac03793e79..a1a278bc340d 100644
--- a/drivers/rtc/rtc-mc13xxx.c
+++ b/drivers/rtc/rtc-mc13xxx.c
@@ -349,11 +349,15 @@ static int __devinit mc13xxx_rtc_probe(struct platform_device *pdev)
349 if (ret) 349 if (ret)
350 goto err_alarm_irq_request; 350 goto err_alarm_irq_request;
351 351
352 mc13xxx_unlock(mc13xxx);
353
352 priv->rtc = rtc_device_register(pdev->name, 354 priv->rtc = rtc_device_register(pdev->name,
353 &pdev->dev, &mc13xxx_rtc_ops, THIS_MODULE); 355 &pdev->dev, &mc13xxx_rtc_ops, THIS_MODULE);
354 if (IS_ERR(priv->rtc)) { 356 if (IS_ERR(priv->rtc)) {
355 ret = PTR_ERR(priv->rtc); 357 ret = PTR_ERR(priv->rtc);
356 358
359 mc13xxx_lock(mc13xxx);
360
357 mc13xxx_irq_free(mc13xxx, MC13XXX_IRQ_TODA, priv); 361 mc13xxx_irq_free(mc13xxx, MC13XXX_IRQ_TODA, priv);
358err_alarm_irq_request: 362err_alarm_irq_request:
359 363
@@ -365,12 +369,12 @@ err_reset_irq_status:
365 mc13xxx_irq_free(mc13xxx, MC13XXX_IRQ_RTCRST, priv); 369 mc13xxx_irq_free(mc13xxx, MC13XXX_IRQ_RTCRST, priv);
366err_reset_irq_request: 370err_reset_irq_request:
367 371
372 mc13xxx_unlock(mc13xxx);
373
368 platform_set_drvdata(pdev, NULL); 374 platform_set_drvdata(pdev, NULL);
369 kfree(priv); 375 kfree(priv);
370 } 376 }
371 377
372 mc13xxx_unlock(mc13xxx);
373
374 return ret; 378 return ret;
375} 379}
376 380
diff --git a/drivers/rtc/rtc-msm6242.c b/drivers/rtc/rtc-msm6242.c
index 67820626e18f..fcb113c11122 100644
--- a/drivers/rtc/rtc-msm6242.c
+++ b/drivers/rtc/rtc-msm6242.c
@@ -214,6 +214,7 @@ static int __init msm6242_rtc_probe(struct platform_device *dev)
214 error = -ENOMEM; 214 error = -ENOMEM;
215 goto out_free_priv; 215 goto out_free_priv;
216 } 216 }
217 platform_set_drvdata(dev, priv);
217 218
218 rtc = rtc_device_register("rtc-msm6242", &dev->dev, &msm6242_rtc_ops, 219 rtc = rtc_device_register("rtc-msm6242", &dev->dev, &msm6242_rtc_ops,
219 THIS_MODULE); 220 THIS_MODULE);
@@ -223,10 +224,10 @@ static int __init msm6242_rtc_probe(struct platform_device *dev)
223 } 224 }
224 225
225 priv->rtc = rtc; 226 priv->rtc = rtc;
226 platform_set_drvdata(dev, priv);
227 return 0; 227 return 0;
228 228
229out_unmap: 229out_unmap:
230 platform_set_drvdata(dev, NULL);
230 iounmap(priv->regs); 231 iounmap(priv->regs);
231out_free_priv: 232out_free_priv:
232 kfree(priv); 233 kfree(priv);
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
index 826ab64a8fa9..d814417bee8c 100644
--- a/drivers/rtc/rtc-mxc.c
+++ b/drivers/rtc/rtc-mxc.c
@@ -418,14 +418,6 @@ static int __init mxc_rtc_probe(struct platform_device *pdev)
418 goto exit_put_clk; 418 goto exit_put_clk;
419 } 419 }
420 420
421 rtc = rtc_device_register(pdev->name, &pdev->dev, &mxc_rtc_ops,
422 THIS_MODULE);
423 if (IS_ERR(rtc)) {
424 ret = PTR_ERR(rtc);
425 goto exit_put_clk;
426 }
427
428 pdata->rtc = rtc;
429 platform_set_drvdata(pdev, pdata); 421 platform_set_drvdata(pdev, pdata);
430 422
431 /* Configure and enable the RTC */ 423 /* Configure and enable the RTC */
@@ -438,8 +430,19 @@ static int __init mxc_rtc_probe(struct platform_device *pdev)
438 pdata->irq = -1; 430 pdata->irq = -1;
439 } 431 }
440 432
433 rtc = rtc_device_register(pdev->name, &pdev->dev, &mxc_rtc_ops,
434 THIS_MODULE);
435 if (IS_ERR(rtc)) {
436 ret = PTR_ERR(rtc);
437 goto exit_clr_drvdata;
438 }
439
440 pdata->rtc = rtc;
441
441 return 0; 442 return 0;
442 443
444exit_clr_drvdata:
445 platform_set_drvdata(pdev, NULL);
443exit_put_clk: 446exit_put_clk:
444 clk_disable(pdata->clk); 447 clk_disable(pdata->clk);
445 clk_put(pdata->clk); 448 clk_put(pdata->clk);
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index de0dd7b1f146..bcae8dd41496 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -394,7 +394,7 @@ static int __init omap_rtc_probe(struct platform_device *pdev)
394 return 0; 394 return 0;
395 395
396fail2: 396fail2:
397 free_irq(omap_rtc_timer, NULL); 397 free_irq(omap_rtc_timer, rtc);
398fail1: 398fail1:
399 rtc_device_unregister(rtc); 399 rtc_device_unregister(rtc);
400fail0: 400fail0:
diff --git a/drivers/rtc/rtc-pcap.c b/drivers/rtc/rtc-pcap.c
index a633abc42896..cd4f198cc2ef 100644
--- a/drivers/rtc/rtc-pcap.c
+++ b/drivers/rtc/rtc-pcap.c
@@ -151,6 +151,8 @@ static int __devinit pcap_rtc_probe(struct platform_device *pdev)
151 151
152 pcap_rtc->pcap = dev_get_drvdata(pdev->dev.parent); 152 pcap_rtc->pcap = dev_get_drvdata(pdev->dev.parent);
153 153
154 platform_set_drvdata(pdev, pcap_rtc);
155
154 pcap_rtc->rtc = rtc_device_register("pcap", &pdev->dev, 156 pcap_rtc->rtc = rtc_device_register("pcap", &pdev->dev,
155 &pcap_rtc_ops, THIS_MODULE); 157 &pcap_rtc_ops, THIS_MODULE);
156 if (IS_ERR(pcap_rtc->rtc)) { 158 if (IS_ERR(pcap_rtc->rtc)) {
@@ -158,7 +160,6 @@ static int __devinit pcap_rtc_probe(struct platform_device *pdev)
158 goto fail_rtc; 160 goto fail_rtc;
159 } 161 }
160 162
161 platform_set_drvdata(pdev, pcap_rtc);
162 163
163 timer_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ); 164 timer_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ);
164 alarm_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA); 165 alarm_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA);
@@ -177,6 +178,7 @@ fail_alarm:
177fail_timer: 178fail_timer:
178 rtc_device_unregister(pcap_rtc->rtc); 179 rtc_device_unregister(pcap_rtc->rtc);
179fail_rtc: 180fail_rtc:
181 platform_set_drvdata(pdev, NULL);
180 kfree(pcap_rtc); 182 kfree(pcap_rtc);
181 return err; 183 return err;
182} 184}
diff --git a/drivers/rtc/rtc-rp5c01.c b/drivers/rtc/rtc-rp5c01.c
index 694da39b6dd2..359da6d020b9 100644
--- a/drivers/rtc/rtc-rp5c01.c
+++ b/drivers/rtc/rtc-rp5c01.c
@@ -249,15 +249,15 @@ static int __init rp5c01_rtc_probe(struct platform_device *dev)
249 249
250 spin_lock_init(&priv->lock); 250 spin_lock_init(&priv->lock);
251 251
252 platform_set_drvdata(dev, priv);
253
252 rtc = rtc_device_register("rtc-rp5c01", &dev->dev, &rp5c01_rtc_ops, 254 rtc = rtc_device_register("rtc-rp5c01", &dev->dev, &rp5c01_rtc_ops,
253 THIS_MODULE); 255 THIS_MODULE);
254 if (IS_ERR(rtc)) { 256 if (IS_ERR(rtc)) {
255 error = PTR_ERR(rtc); 257 error = PTR_ERR(rtc);
256 goto out_unmap; 258 goto out_unmap;
257 } 259 }
258
259 priv->rtc = rtc; 260 priv->rtc = rtc;
260 platform_set_drvdata(dev, priv);
261 261
262 error = sysfs_create_bin_file(&dev->dev.kobj, &priv->nvram_attr); 262 error = sysfs_create_bin_file(&dev->dev.kobj, &priv->nvram_attr);
263 if (error) 263 if (error)
@@ -268,6 +268,7 @@ static int __init rp5c01_rtc_probe(struct platform_device *dev)
268out_unregister: 268out_unregister:
269 rtc_device_unregister(rtc); 269 rtc_device_unregister(rtc);
270out_unmap: 270out_unmap:
271 platform_set_drvdata(dev, NULL);
271 iounmap(priv->regs); 272 iounmap(priv->regs);
272out_free_priv: 273out_free_priv:
273 kfree(priv); 274 kfree(priv);
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index b3466c491cd3..16512ecae31a 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -46,6 +46,7 @@ static struct clk *rtc_clk;
46static void __iomem *s3c_rtc_base; 46static void __iomem *s3c_rtc_base;
47static int s3c_rtc_alarmno = NO_IRQ; 47static int s3c_rtc_alarmno = NO_IRQ;
48static int s3c_rtc_tickno = NO_IRQ; 48static int s3c_rtc_tickno = NO_IRQ;
49static bool wake_en;
49static enum s3c_cpu_type s3c_rtc_cpu_type; 50static enum s3c_cpu_type s3c_rtc_cpu_type;
50 51
51static DEFINE_SPINLOCK(s3c_rtc_pie_lock); 52static DEFINE_SPINLOCK(s3c_rtc_pie_lock);
@@ -562,8 +563,12 @@ static int s3c_rtc_suspend(struct platform_device *pdev, pm_message_t state)
562 } 563 }
563 s3c_rtc_enable(pdev, 0); 564 s3c_rtc_enable(pdev, 0);
564 565
565 if (device_may_wakeup(&pdev->dev)) 566 if (device_may_wakeup(&pdev->dev) && !wake_en) {
566 enable_irq_wake(s3c_rtc_alarmno); 567 if (enable_irq_wake(s3c_rtc_alarmno) == 0)
568 wake_en = true;
569 else
570 dev_err(&pdev->dev, "enable_irq_wake failed\n");
571 }
567 572
568 return 0; 573 return 0;
569} 574}
@@ -579,8 +584,10 @@ static int s3c_rtc_resume(struct platform_device *pdev)
579 writew(tmp | ticnt_en_save, s3c_rtc_base + S3C2410_RTCCON); 584 writew(tmp | ticnt_en_save, s3c_rtc_base + S3C2410_RTCCON);
580 } 585 }
581 586
582 if (device_may_wakeup(&pdev->dev)) 587 if (device_may_wakeup(&pdev->dev) && wake_en) {
583 disable_irq_wake(s3c_rtc_alarmno); 588 disable_irq_wake(s3c_rtc_alarmno);
589 wake_en = false;
590 }
584 591
585 return 0; 592 return 0;
586} 593}
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 4d2df2f76ea0..86b6f1cc1b10 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -1742,11 +1742,20 @@ int dasd_sleep_on_interruptible(struct dasd_ccw_req *cqr)
1742static inline int _dasd_term_running_cqr(struct dasd_device *device) 1742static inline int _dasd_term_running_cqr(struct dasd_device *device)
1743{ 1743{
1744 struct dasd_ccw_req *cqr; 1744 struct dasd_ccw_req *cqr;
1745 int rc;
1745 1746
1746 if (list_empty(&device->ccw_queue)) 1747 if (list_empty(&device->ccw_queue))
1747 return 0; 1748 return 0;
1748 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); 1749 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist);
1749 return device->discipline->term_IO(cqr); 1750 rc = device->discipline->term_IO(cqr);
1751 if (!rc)
1752 /*
1753 * CQR terminated because a more important request is pending.
1754 * Undo decreasing of retry counter because this is
1755 * not an error case.
1756 */
1757 cqr->retries++;
1758 return rc;
1750} 1759}
1751 1760
1752int dasd_sleep_on_immediatly(struct dasd_ccw_req *cqr) 1761int dasd_sleep_on_immediatly(struct dasd_ccw_req *cqr)
@@ -2314,15 +2323,14 @@ static void dasd_flush_request_queue(struct dasd_block *block)
2314 2323
2315static int dasd_open(struct block_device *bdev, fmode_t mode) 2324static int dasd_open(struct block_device *bdev, fmode_t mode)
2316{ 2325{
2317 struct dasd_block *block = bdev->bd_disk->private_data;
2318 struct dasd_device *base; 2326 struct dasd_device *base;
2319 int rc; 2327 int rc;
2320 2328
2321 if (!block) 2329 base = dasd_device_from_gendisk(bdev->bd_disk);
2330 if (!base)
2322 return -ENODEV; 2331 return -ENODEV;
2323 2332
2324 base = block->base; 2333 atomic_inc(&base->block->open_count);
2325 atomic_inc(&block->open_count);
2326 if (test_bit(DASD_FLAG_OFFLINE, &base->flags)) { 2334 if (test_bit(DASD_FLAG_OFFLINE, &base->flags)) {
2327 rc = -ENODEV; 2335 rc = -ENODEV;
2328 goto unlock; 2336 goto unlock;
@@ -2355,21 +2363,28 @@ static int dasd_open(struct block_device *bdev, fmode_t mode)
2355 goto out; 2363 goto out;
2356 } 2364 }
2357 2365
2366 dasd_put_device(base);
2358 return 0; 2367 return 0;
2359 2368
2360out: 2369out:
2361 module_put(base->discipline->owner); 2370 module_put(base->discipline->owner);
2362unlock: 2371unlock:
2363 atomic_dec(&block->open_count); 2372 atomic_dec(&base->block->open_count);
2373 dasd_put_device(base);
2364 return rc; 2374 return rc;
2365} 2375}
2366 2376
2367static int dasd_release(struct gendisk *disk, fmode_t mode) 2377static int dasd_release(struct gendisk *disk, fmode_t mode)
2368{ 2378{
2369 struct dasd_block *block = disk->private_data; 2379 struct dasd_device *base;
2370 2380
2371 atomic_dec(&block->open_count); 2381 base = dasd_device_from_gendisk(disk);
2372 module_put(block->base->discipline->owner); 2382 if (!base)
2383 return -ENODEV;
2384
2385 atomic_dec(&base->block->open_count);
2386 module_put(base->discipline->owner);
2387 dasd_put_device(base);
2373 return 0; 2388 return 0;
2374} 2389}
2375 2390
@@ -2378,20 +2393,20 @@ static int dasd_release(struct gendisk *disk, fmode_t mode)
2378 */ 2393 */
2379static int dasd_getgeo(struct block_device *bdev, struct hd_geometry *geo) 2394static int dasd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
2380{ 2395{
2381 struct dasd_block *block;
2382 struct dasd_device *base; 2396 struct dasd_device *base;
2383 2397
2384 block = bdev->bd_disk->private_data; 2398 base = dasd_device_from_gendisk(bdev->bd_disk);
2385 if (!block) 2399 if (!base)
2386 return -ENODEV; 2400 return -ENODEV;
2387 base = block->base;
2388 2401
2389 if (!base->discipline || 2402 if (!base->discipline ||
2390 !base->discipline->fill_geometry) 2403 !base->discipline->fill_geometry) {
2404 dasd_put_device(base);
2391 return -EINVAL; 2405 return -EINVAL;
2392 2406 }
2393 base->discipline->fill_geometry(block, geo); 2407 base->discipline->fill_geometry(base->block, geo);
2394 geo->start = get_start_sect(bdev) >> block->s2b_shift; 2408 geo->start = get_start_sect(bdev) >> base->block->s2b_shift;
2409 dasd_put_device(base);
2395 return 0; 2410 return 0;
2396} 2411}
2397 2412
@@ -2528,7 +2543,6 @@ void dasd_generic_remove(struct ccw_device *cdev)
2528 dasd_set_target_state(device, DASD_STATE_NEW); 2543 dasd_set_target_state(device, DASD_STATE_NEW);
2529 /* dasd_delete_device destroys the device reference. */ 2544 /* dasd_delete_device destroys the device reference. */
2530 block = device->block; 2545 block = device->block;
2531 device->block = NULL;
2532 dasd_delete_device(device); 2546 dasd_delete_device(device);
2533 /* 2547 /*
2534 * life cycle of block is bound to device, so delete it after 2548 * life cycle of block is bound to device, so delete it after
@@ -2650,7 +2664,6 @@ int dasd_generic_set_offline(struct ccw_device *cdev)
2650 dasd_set_target_state(device, DASD_STATE_NEW); 2664 dasd_set_target_state(device, DASD_STATE_NEW);
2651 /* dasd_delete_device destroys the device reference. */ 2665 /* dasd_delete_device destroys the device reference. */
2652 block = device->block; 2666 block = device->block;
2653 device->block = NULL;
2654 dasd_delete_device(device); 2667 dasd_delete_device(device);
2655 /* 2668 /*
2656 * life cycle of block is bound to device, so delete it after 2669 * life cycle of block is bound to device, so delete it after
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index 42e1bf35f689..d71511c7850a 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -674,6 +674,36 @@ dasd_device_from_cdev(struct ccw_device *cdev)
674 return device; 674 return device;
675} 675}
676 676
677void dasd_add_link_to_gendisk(struct gendisk *gdp, struct dasd_device *device)
678{
679 struct dasd_devmap *devmap;
680
681 devmap = dasd_find_busid(dev_name(&device->cdev->dev));
682 if (IS_ERR(devmap))
683 return;
684 spin_lock(&dasd_devmap_lock);
685 gdp->private_data = devmap;
686 spin_unlock(&dasd_devmap_lock);
687}
688
689struct dasd_device *dasd_device_from_gendisk(struct gendisk *gdp)
690{
691 struct dasd_device *device;
692 struct dasd_devmap *devmap;
693
694 if (!gdp->private_data)
695 return NULL;
696 device = NULL;
697 spin_lock(&dasd_devmap_lock);
698 devmap = gdp->private_data;
699 if (devmap && devmap->device) {
700 device = devmap->device;
701 dasd_get_device(device);
702 }
703 spin_unlock(&dasd_devmap_lock);
704 return device;
705}
706
677/* 707/*
678 * SECTION: files in sysfs 708 * SECTION: files in sysfs
679 */ 709 */
diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c
index 29143eda9dd9..85dddb1e4126 100644
--- a/drivers/s390/block/dasd_diag.c
+++ b/drivers/s390/block/dasd_diag.c
@@ -239,7 +239,6 @@ static void dasd_ext_handler(unsigned int ext_int_code,
239 addr_t ip; 239 addr_t ip;
240 int rc; 240 int rc;
241 241
242 kstat_cpu(smp_processor_id()).irqs[EXTINT_DSD]++;
243 switch (ext_int_code >> 24) { 242 switch (ext_int_code >> 24) {
244 case DASD_DIAG_CODE_31BIT: 243 case DASD_DIAG_CODE_31BIT:
245 ip = (addr_t) param32; 244 ip = (addr_t) param32;
@@ -250,6 +249,7 @@ static void dasd_ext_handler(unsigned int ext_int_code,
250 default: 249 default:
251 return; 250 return;
252 } 251 }
252 kstat_cpu(smp_processor_id()).irqs[EXTINT_DSD]++;
253 if (!ip) { /* no intparm: unsolicited interrupt */ 253 if (!ip) { /* no intparm: unsolicited interrupt */
254 DBF_EVENT(DBF_NOTICE, "%s", "caught unsolicited " 254 DBF_EVENT(DBF_NOTICE, "%s", "caught unsolicited "
255 "interrupt"); 255 "interrupt");
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index db8005d9f2fd..3ebdf5f92f8f 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -2037,7 +2037,7 @@ static void dasd_eckd_check_for_device_change(struct dasd_device *device,
2037 return; 2037 return;
2038 2038
2039 /* summary unit check */ 2039 /* summary unit check */
2040 if ((sense[7] == 0x0D) && 2040 if ((sense[27] & DASD_SENSE_BIT_0) && (sense[7] == 0x0D) &&
2041 (scsw_dstat(&irb->scsw) & DEV_STAT_UNIT_CHECK)) { 2041 (scsw_dstat(&irb->scsw) & DEV_STAT_UNIT_CHECK)) {
2042 dasd_alias_handle_summary_unit_check(device, irb); 2042 dasd_alias_handle_summary_unit_check(device, irb);
2043 return; 2043 return;
@@ -2053,7 +2053,8 @@ static void dasd_eckd_check_for_device_change(struct dasd_device *device,
2053 /* loss of device reservation is handled via base devices only 2053 /* loss of device reservation is handled via base devices only
2054 * as alias devices may be used with several bases 2054 * as alias devices may be used with several bases
2055 */ 2055 */
2056 if (device->block && (sense[7] == 0x3F) && 2056 if (device->block && (sense[27] & DASD_SENSE_BIT_0) &&
2057 (sense[7] == 0x3F) &&
2057 (scsw_dstat(&irb->scsw) & DEV_STAT_UNIT_CHECK) && 2058 (scsw_dstat(&irb->scsw) & DEV_STAT_UNIT_CHECK) &&
2058 test_bit(DASD_FLAG_IS_RESERVED, &device->flags)) { 2059 test_bit(DASD_FLAG_IS_RESERVED, &device->flags)) {
2059 if (device->features & DASD_FEATURE_FAILONSLCK) 2060 if (device->features & DASD_FEATURE_FAILONSLCK)
diff --git a/drivers/s390/block/dasd_genhd.c b/drivers/s390/block/dasd_genhd.c
index 5505bc07e1e7..19a1ff03d65e 100644
--- a/drivers/s390/block/dasd_genhd.c
+++ b/drivers/s390/block/dasd_genhd.c
@@ -73,7 +73,7 @@ int dasd_gendisk_alloc(struct dasd_block *block)
73 if (base->features & DASD_FEATURE_READONLY || 73 if (base->features & DASD_FEATURE_READONLY ||
74 test_bit(DASD_FLAG_DEVICE_RO, &base->flags)) 74 test_bit(DASD_FLAG_DEVICE_RO, &base->flags))
75 set_disk_ro(gdp, 1); 75 set_disk_ro(gdp, 1);
76 gdp->private_data = block; 76 dasd_add_link_to_gendisk(gdp, base);
77 gdp->queue = block->request_queue; 77 gdp->queue = block->request_queue;
78 block->gdp = gdp; 78 block->gdp = gdp;
79 set_capacity(block->gdp, 0); 79 set_capacity(block->gdp, 0);
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index df9f6999411d..d1e4f2c1264c 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -686,6 +686,9 @@ struct dasd_device *dasd_device_from_cdev(struct ccw_device *);
686struct dasd_device *dasd_device_from_cdev_locked(struct ccw_device *); 686struct dasd_device *dasd_device_from_cdev_locked(struct ccw_device *);
687struct dasd_device *dasd_device_from_devindex(int); 687struct dasd_device *dasd_device_from_devindex(int);
688 688
689void dasd_add_link_to_gendisk(struct gendisk *, struct dasd_device *);
690struct dasd_device *dasd_device_from_gendisk(struct gendisk *);
691
689int dasd_parse(void); 692int dasd_parse(void);
690int dasd_busid_known(const char *); 693int dasd_busid_known(const char *);
691 694
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index 26075e95b1ba..72261e4c516d 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -42,16 +42,22 @@ dasd_ioctl_api_version(void __user *argp)
42static int 42static int
43dasd_ioctl_enable(struct block_device *bdev) 43dasd_ioctl_enable(struct block_device *bdev)
44{ 44{
45 struct dasd_block *block = bdev->bd_disk->private_data; 45 struct dasd_device *base;
46 46
47 if (!capable(CAP_SYS_ADMIN)) 47 if (!capable(CAP_SYS_ADMIN))
48 return -EACCES; 48 return -EACCES;
49 49
50 dasd_enable_device(block->base); 50 base = dasd_device_from_gendisk(bdev->bd_disk);
51 if (!base)
52 return -ENODEV;
53
54 dasd_enable_device(base);
51 /* Formatting the dasd device can change the capacity. */ 55 /* Formatting the dasd device can change the capacity. */
52 mutex_lock(&bdev->bd_mutex); 56 mutex_lock(&bdev->bd_mutex);
53 i_size_write(bdev->bd_inode, (loff_t)get_capacity(block->gdp) << 9); 57 i_size_write(bdev->bd_inode,
58 (loff_t)get_capacity(base->block->gdp) << 9);
54 mutex_unlock(&bdev->bd_mutex); 59 mutex_unlock(&bdev->bd_mutex);
60 dasd_put_device(base);
55 return 0; 61 return 0;
56} 62}
57 63
@@ -62,11 +68,14 @@ dasd_ioctl_enable(struct block_device *bdev)
62static int 68static int
63dasd_ioctl_disable(struct block_device *bdev) 69dasd_ioctl_disable(struct block_device *bdev)
64{ 70{
65 struct dasd_block *block = bdev->bd_disk->private_data; 71 struct dasd_device *base;
66 72
67 if (!capable(CAP_SYS_ADMIN)) 73 if (!capable(CAP_SYS_ADMIN))
68 return -EACCES; 74 return -EACCES;
69 75
76 base = dasd_device_from_gendisk(bdev->bd_disk);
77 if (!base)
78 return -ENODEV;
70 /* 79 /*
71 * Man this is sick. We don't do a real disable but only downgrade 80 * Man this is sick. We don't do a real disable but only downgrade
72 * the device to DASD_STATE_BASIC. The reason is that dasdfmt uses 81 * the device to DASD_STATE_BASIC. The reason is that dasdfmt uses
@@ -75,7 +84,7 @@ dasd_ioctl_disable(struct block_device *bdev)
75 * using the BIODASDFMT ioctl. Therefore the correct state for the 84 * using the BIODASDFMT ioctl. Therefore the correct state for the
76 * device is DASD_STATE_BASIC that allows to do basic i/o. 85 * device is DASD_STATE_BASIC that allows to do basic i/o.
77 */ 86 */
78 dasd_set_target_state(block->base, DASD_STATE_BASIC); 87 dasd_set_target_state(base, DASD_STATE_BASIC);
79 /* 88 /*
80 * Set i_size to zero, since read, write, etc. check against this 89 * Set i_size to zero, since read, write, etc. check against this
81 * value. 90 * value.
@@ -83,6 +92,7 @@ dasd_ioctl_disable(struct block_device *bdev)
83 mutex_lock(&bdev->bd_mutex); 92 mutex_lock(&bdev->bd_mutex);
84 i_size_write(bdev->bd_inode, 0); 93 i_size_write(bdev->bd_inode, 0);
85 mutex_unlock(&bdev->bd_mutex); 94 mutex_unlock(&bdev->bd_mutex);
95 dasd_put_device(base);
86 return 0; 96 return 0;
87} 97}
88 98
@@ -191,26 +201,36 @@ static int dasd_format(struct dasd_block *block, struct format_data_t *fdata)
191static int 201static int
192dasd_ioctl_format(struct block_device *bdev, void __user *argp) 202dasd_ioctl_format(struct block_device *bdev, void __user *argp)
193{ 203{
194 struct dasd_block *block = bdev->bd_disk->private_data; 204 struct dasd_device *base;
195 struct format_data_t fdata; 205 struct format_data_t fdata;
206 int rc;
196 207
197 if (!capable(CAP_SYS_ADMIN)) 208 if (!capable(CAP_SYS_ADMIN))
198 return -EACCES; 209 return -EACCES;
199 if (!argp) 210 if (!argp)
200 return -EINVAL; 211 return -EINVAL;
201 212 base = dasd_device_from_gendisk(bdev->bd_disk);
202 if (block->base->features & DASD_FEATURE_READONLY || 213 if (!base)
203 test_bit(DASD_FLAG_DEVICE_RO, &block->base->flags)) 214 return -ENODEV;
215 if (base->features & DASD_FEATURE_READONLY ||
216 test_bit(DASD_FLAG_DEVICE_RO, &base->flags)) {
217 dasd_put_device(base);
204 return -EROFS; 218 return -EROFS;
205 if (copy_from_user(&fdata, argp, sizeof(struct format_data_t))) 219 }
220 if (copy_from_user(&fdata, argp, sizeof(struct format_data_t))) {
221 dasd_put_device(base);
206 return -EFAULT; 222 return -EFAULT;
223 }
207 if (bdev != bdev->bd_contains) { 224 if (bdev != bdev->bd_contains) {
208 pr_warning("%s: The specified DASD is a partition and cannot " 225 pr_warning("%s: The specified DASD is a partition and cannot "
209 "be formatted\n", 226 "be formatted\n",
210 dev_name(&block->base->cdev->dev)); 227 dev_name(&base->cdev->dev));
228 dasd_put_device(base);
211 return -EINVAL; 229 return -EINVAL;
212 } 230 }
213 return dasd_format(block, &fdata); 231 rc = dasd_format(base->block, &fdata);
232 dasd_put_device(base);
233 return rc;
214} 234}
215 235
216#ifdef CONFIG_DASD_PROFILE 236#ifdef CONFIG_DASD_PROFILE
@@ -340,8 +360,8 @@ static int dasd_ioctl_information(struct dasd_block *block,
340static int 360static int
341dasd_ioctl_set_ro(struct block_device *bdev, void __user *argp) 361dasd_ioctl_set_ro(struct block_device *bdev, void __user *argp)
342{ 362{
343 struct dasd_block *block = bdev->bd_disk->private_data; 363 struct dasd_device *base;
344 int intval; 364 int intval, rc;
345 365
346 if (!capable(CAP_SYS_ADMIN)) 366 if (!capable(CAP_SYS_ADMIN))
347 return -EACCES; 367 return -EACCES;
@@ -350,10 +370,17 @@ dasd_ioctl_set_ro(struct block_device *bdev, void __user *argp)
350 return -EINVAL; 370 return -EINVAL;
351 if (get_user(intval, (int __user *)argp)) 371 if (get_user(intval, (int __user *)argp))
352 return -EFAULT; 372 return -EFAULT;
353 if (!intval && test_bit(DASD_FLAG_DEVICE_RO, &block->base->flags)) 373 base = dasd_device_from_gendisk(bdev->bd_disk);
374 if (!base)
375 return -ENODEV;
376 if (!intval && test_bit(DASD_FLAG_DEVICE_RO, &base->flags)) {
377 dasd_put_device(base);
354 return -EROFS; 378 return -EROFS;
379 }
355 set_disk_ro(bdev->bd_disk, intval); 380 set_disk_ro(bdev->bd_disk, intval);
356 return dasd_set_feature(block->base->cdev, DASD_FEATURE_READONLY, intval); 381 rc = dasd_set_feature(base->cdev, DASD_FEATURE_READONLY, intval);
382 dasd_put_device(base);
383 return rc;
357} 384}
358 385
359static int dasd_ioctl_readall_cmb(struct dasd_block *block, unsigned int cmd, 386static int dasd_ioctl_readall_cmb(struct dasd_block *block, unsigned int cmd,
@@ -372,59 +399,78 @@ static int dasd_ioctl_readall_cmb(struct dasd_block *block, unsigned int cmd,
372int dasd_ioctl(struct block_device *bdev, fmode_t mode, 399int dasd_ioctl(struct block_device *bdev, fmode_t mode,
373 unsigned int cmd, unsigned long arg) 400 unsigned int cmd, unsigned long arg)
374{ 401{
375 struct dasd_block *block = bdev->bd_disk->private_data; 402 struct dasd_block *block;
403 struct dasd_device *base;
376 void __user *argp; 404 void __user *argp;
405 int rc;
377 406
378 if (is_compat_task()) 407 if (is_compat_task())
379 argp = compat_ptr(arg); 408 argp = compat_ptr(arg);
380 else 409 else
381 argp = (void __user *)arg; 410 argp = (void __user *)arg;
382 411
383 if (!block)
384 return -ENODEV;
385
386 if ((_IOC_DIR(cmd) != _IOC_NONE) && !arg) { 412 if ((_IOC_DIR(cmd) != _IOC_NONE) && !arg) {
387 PRINT_DEBUG("empty data ptr"); 413 PRINT_DEBUG("empty data ptr");
388 return -EINVAL; 414 return -EINVAL;
389 } 415 }
390 416
417 base = dasd_device_from_gendisk(bdev->bd_disk);
418 if (!base)
419 return -ENODEV;
420 block = base->block;
421 rc = 0;
391 switch (cmd) { 422 switch (cmd) {
392 case BIODASDDISABLE: 423 case BIODASDDISABLE:
393 return dasd_ioctl_disable(bdev); 424 rc = dasd_ioctl_disable(bdev);
425 break;
394 case BIODASDENABLE: 426 case BIODASDENABLE:
395 return dasd_ioctl_enable(bdev); 427 rc = dasd_ioctl_enable(bdev);
428 break;
396 case BIODASDQUIESCE: 429 case BIODASDQUIESCE:
397 return dasd_ioctl_quiesce(block); 430 rc = dasd_ioctl_quiesce(block);
431 break;
398 case BIODASDRESUME: 432 case BIODASDRESUME:
399 return dasd_ioctl_resume(block); 433 rc = dasd_ioctl_resume(block);
434 break;
400 case BIODASDFMT: 435 case BIODASDFMT:
401 return dasd_ioctl_format(bdev, argp); 436 rc = dasd_ioctl_format(bdev, argp);
437 break;
402 case BIODASDINFO: 438 case BIODASDINFO:
403 return dasd_ioctl_information(block, cmd, argp); 439 rc = dasd_ioctl_information(block, cmd, argp);
440 break;
404 case BIODASDINFO2: 441 case BIODASDINFO2:
405 return dasd_ioctl_information(block, cmd, argp); 442 rc = dasd_ioctl_information(block, cmd, argp);
443 break;
406 case BIODASDPRRD: 444 case BIODASDPRRD:
407 return dasd_ioctl_read_profile(block, argp); 445 rc = dasd_ioctl_read_profile(block, argp);
446 break;
408 case BIODASDPRRST: 447 case BIODASDPRRST:
409 return dasd_ioctl_reset_profile(block); 448 rc = dasd_ioctl_reset_profile(block);
449 break;
410 case BLKROSET: 450 case BLKROSET:
411 return dasd_ioctl_set_ro(bdev, argp); 451 rc = dasd_ioctl_set_ro(bdev, argp);
452 break;
412 case DASDAPIVER: 453 case DASDAPIVER:
413 return dasd_ioctl_api_version(argp); 454 rc = dasd_ioctl_api_version(argp);
455 break;
414 case BIODASDCMFENABLE: 456 case BIODASDCMFENABLE:
415 return enable_cmf(block->base->cdev); 457 rc = enable_cmf(base->cdev);
458 break;
416 case BIODASDCMFDISABLE: 459 case BIODASDCMFDISABLE:
417 return disable_cmf(block->base->cdev); 460 rc = disable_cmf(base->cdev);
461 break;
418 case BIODASDREADALLCMB: 462 case BIODASDREADALLCMB:
419 return dasd_ioctl_readall_cmb(block, cmd, argp); 463 rc = dasd_ioctl_readall_cmb(block, cmd, argp);
464 break;
420 default: 465 default:
421 /* if the discipline has an ioctl method try it. */ 466 /* if the discipline has an ioctl method try it. */
422 if (block->base->discipline->ioctl) { 467 if (base->discipline->ioctl) {
423 int rval = block->base->discipline->ioctl(block, cmd, argp); 468 rc = base->discipline->ioctl(block, cmd, argp);
424 if (rval != -ENOIOCTLCMD) 469 if (rc == -ENOIOCTLCMD)
425 return rval; 470 rc = -EINVAL;
426 } 471 } else
427 472 rc = -EINVAL;
428 return -EINVAL;
429 } 473 }
474 dasd_put_device(base);
475 return rc;
430} 476}
diff --git a/drivers/s390/char/sclp_cmd.c b/drivers/s390/char/sclp_cmd.c
index 4b60ede07f0e..be55fb2b1b1c 100644
--- a/drivers/s390/char/sclp_cmd.c
+++ b/drivers/s390/char/sclp_cmd.c
@@ -518,6 +518,8 @@ static void __init insert_increment(u16 rn, int standby, int assigned)
518 return; 518 return;
519 new_incr->rn = rn; 519 new_incr->rn = rn;
520 new_incr->standby = standby; 520 new_incr->standby = standby;
521 if (!standby)
522 new_incr->usecount = 1;
521 last_rn = 0; 523 last_rn = 0;
522 prev = &sclp_mem_list; 524 prev = &sclp_mem_list;
523 list_for_each_entry(incr, &sclp_mem_list, list) { 525 list_for_each_entry(incr, &sclp_mem_list, list) {
diff --git a/drivers/s390/char/tape_block.c b/drivers/s390/char/tape_block.c
index 83cea9a55e2f..1b3924c2fffd 100644
--- a/drivers/s390/char/tape_block.c
+++ b/drivers/s390/char/tape_block.c
@@ -236,7 +236,6 @@ tapeblock_setup_device(struct tape_device * device)
236 disk->major = tapeblock_major; 236 disk->major = tapeblock_major;
237 disk->first_minor = device->first_minor; 237 disk->first_minor = device->first_minor;
238 disk->fops = &tapeblock_fops; 238 disk->fops = &tapeblock_fops;
239 disk->events = DISK_EVENT_MEDIA_CHANGE;
240 disk->private_data = tape_get_device(device); 239 disk->private_data = tape_get_device(device);
241 disk->queue = blkdat->request_queue; 240 disk->queue = blkdat->request_queue;
242 set_capacity(disk, 0); 241 set_capacity(disk, 0);
diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c
index c532ba929ccd..e8f267eb8887 100644
--- a/drivers/s390/cio/qdio_main.c
+++ b/drivers/s390/cio/qdio_main.c
@@ -407,8 +407,11 @@ static inline void account_sbals(struct qdio_q *q, int count)
407 q->q_stats.nr_sbals[pos]++; 407 q->q_stats.nr_sbals[pos]++;
408} 408}
409 409
410static void announce_buffer_error(struct qdio_q *q, int count) 410static void process_buffer_error(struct qdio_q *q, int count)
411{ 411{
412 unsigned char state = (q->is_input_q) ? SLSB_P_INPUT_NOT_INIT :
413 SLSB_P_OUTPUT_NOT_INIT;
414
412 q->qdio_error |= QDIO_ERROR_SLSB_STATE; 415 q->qdio_error |= QDIO_ERROR_SLSB_STATE;
413 416
414 /* special handling for no target buffer empty */ 417 /* special handling for no target buffer empty */
@@ -426,6 +429,12 @@ static void announce_buffer_error(struct qdio_q *q, int count)
426 DBF_ERROR("F14:%2x F15:%2x", 429 DBF_ERROR("F14:%2x F15:%2x",
427 q->sbal[q->first_to_check]->element[14].flags & 0xff, 430 q->sbal[q->first_to_check]->element[14].flags & 0xff,
428 q->sbal[q->first_to_check]->element[15].flags & 0xff); 431 q->sbal[q->first_to_check]->element[15].flags & 0xff);
432
433 /*
434 * Interrupts may be avoided as long as the error is present
435 * so change the buffer state immediately to avoid starvation.
436 */
437 set_buf_states(q, q->first_to_check, state, count);
429} 438}
430 439
431static inline void inbound_primed(struct qdio_q *q, int count) 440static inline void inbound_primed(struct qdio_q *q, int count)
@@ -506,8 +515,7 @@ static int get_inbound_buffer_frontier(struct qdio_q *q)
506 account_sbals(q, count); 515 account_sbals(q, count);
507 break; 516 break;
508 case SLSB_P_INPUT_ERROR: 517 case SLSB_P_INPUT_ERROR:
509 announce_buffer_error(q, count); 518 process_buffer_error(q, count);
510 /* process the buffer, the upper layer will take care of it */
511 q->first_to_check = add_buf(q->first_to_check, count); 519 q->first_to_check = add_buf(q->first_to_check, count);
512 atomic_sub(count, &q->nr_buf_used); 520 atomic_sub(count, &q->nr_buf_used);
513 if (q->irq_ptr->perf_stat_enabled) 521 if (q->irq_ptr->perf_stat_enabled)
@@ -677,8 +685,7 @@ static int get_outbound_buffer_frontier(struct qdio_q *q)
677 account_sbals(q, count); 685 account_sbals(q, count);
678 break; 686 break;
679 case SLSB_P_OUTPUT_ERROR: 687 case SLSB_P_OUTPUT_ERROR:
680 announce_buffer_error(q, count); 688 process_buffer_error(q, count);
681 /* process the buffer, the upper layer will take care of it */
682 q->first_to_check = add_buf(q->first_to_check, count); 689 q->first_to_check = add_buf(q->first_to_check, count);
683 atomic_sub(count, &q->nr_buf_used); 690 atomic_sub(count, &q->nr_buf_used);
684 if (q->irq_ptr->perf_stat_enabled) 691 if (q->irq_ptr->perf_stat_enabled)
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c
index 414427d64a8f..607998f0b7d8 100644
--- a/drivers/s390/kvm/kvm_virtio.c
+++ b/drivers/s390/kvm/kvm_virtio.c
@@ -381,10 +381,10 @@ static void kvm_extint_handler(unsigned int ext_int_code,
381 u16 subcode; 381 u16 subcode;
382 u32 param; 382 u32 param;
383 383
384 kstat_cpu(smp_processor_id()).irqs[EXTINT_VRT]++;
385 subcode = ext_int_code >> 16; 384 subcode = ext_int_code >> 16;
386 if ((subcode & 0xff00) != VIRTIO_SUBCODE_64) 385 if ((subcode & 0xff00) != VIRTIO_SUBCODE_64)
387 return; 386 return;
387 kstat_cpu(smp_processor_id()).irqs[EXTINT_VRT]++;
388 388
389 /* The LSB might be overloaded, we have to mask it */ 389 /* The LSB might be overloaded, we have to mask it */
390 vq = (struct virtqueue *)(param64 & ~1UL); 390 vq = (struct virtqueue *)(param64 & ~1UL);
diff --git a/drivers/scsi/device_handler/scsi_dh.c b/drivers/scsi/device_handler/scsi_dh.c
index 564e6ecd17c2..0119b8147797 100644
--- a/drivers/scsi/device_handler/scsi_dh.c
+++ b/drivers/scsi/device_handler/scsi_dh.c
@@ -394,12 +394,14 @@ int scsi_dh_activate(struct request_queue *q, activate_complete fn, void *data)
394 unsigned long flags; 394 unsigned long flags;
395 struct scsi_device *sdev; 395 struct scsi_device *sdev;
396 struct scsi_device_handler *scsi_dh = NULL; 396 struct scsi_device_handler *scsi_dh = NULL;
397 struct device *dev = NULL;
397 398
398 spin_lock_irqsave(q->queue_lock, flags); 399 spin_lock_irqsave(q->queue_lock, flags);
399 sdev = q->queuedata; 400 sdev = q->queuedata;
400 if (sdev && sdev->scsi_dh_data) 401 if (sdev && sdev->scsi_dh_data)
401 scsi_dh = sdev->scsi_dh_data->scsi_dh; 402 scsi_dh = sdev->scsi_dh_data->scsi_dh;
402 if (!scsi_dh || !get_device(&sdev->sdev_gendev) || 403 dev = get_device(&sdev->sdev_gendev);
404 if (!scsi_dh || !dev ||
403 sdev->sdev_state == SDEV_CANCEL || 405 sdev->sdev_state == SDEV_CANCEL ||
404 sdev->sdev_state == SDEV_DEL) 406 sdev->sdev_state == SDEV_DEL)
405 err = SCSI_DH_NOSYS; 407 err = SCSI_DH_NOSYS;
@@ -410,12 +412,13 @@ int scsi_dh_activate(struct request_queue *q, activate_complete fn, void *data)
410 if (err) { 412 if (err) {
411 if (fn) 413 if (fn)
412 fn(data, err); 414 fn(data, err);
413 return err; 415 goto out;
414 } 416 }
415 417
416 if (scsi_dh->activate) 418 if (scsi_dh->activate)
417 err = scsi_dh->activate(sdev, fn, data); 419 err = scsi_dh->activate(sdev, fn, data);
418 put_device(&sdev->sdev_gendev); 420out:
421 put_device(dev);
419 return err; 422 return err;
420} 423}
421EXPORT_SYMBOL_GPL(scsi_dh_activate); 424EXPORT_SYMBOL_GPL(scsi_dh_activate);
diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.c b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
index 1c6d2b405eef..d72f1f2b1392 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_ctl.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
@@ -688,6 +688,13 @@ _ctl_do_mpt_command(struct MPT2SAS_ADAPTER *ioc,
688 goto out; 688 goto out;
689 } 689 }
690 690
691 /* Check for overflow and wraparound */
692 if (karg.data_sge_offset * 4 > ioc->request_sz ||
693 karg.data_sge_offset > (UINT_MAX / 4)) {
694 ret = -EINVAL;
695 goto out;
696 }
697
691 /* copy in request message frame from user */ 698 /* copy in request message frame from user */
692 if (copy_from_user(mpi_request, mf, karg.data_sge_offset*4)) { 699 if (copy_from_user(mpi_request, mf, karg.data_sge_offset*4)) {
693 printk(KERN_ERR "failure at %s:%d/%s()!\n", __FILE__, __LINE__, 700 printk(KERN_ERR "failure at %s:%d/%s()!\n", __FILE__, __LINE__,
@@ -1963,7 +1970,7 @@ _ctl_diag_read_buffer(void __user *arg, enum block_state state)
1963 Mpi2DiagBufferPostReply_t *mpi_reply; 1970 Mpi2DiagBufferPostReply_t *mpi_reply;
1964 int rc, i; 1971 int rc, i;
1965 u8 buffer_type; 1972 u8 buffer_type;
1966 unsigned long timeleft; 1973 unsigned long timeleft, request_size, copy_size;
1967 u16 smid; 1974 u16 smid;
1968 u16 ioc_status; 1975 u16 ioc_status;
1969 u8 issue_reset = 0; 1976 u8 issue_reset = 0;
@@ -1999,6 +2006,8 @@ _ctl_diag_read_buffer(void __user *arg, enum block_state state)
1999 return -ENOMEM; 2006 return -ENOMEM;
2000 } 2007 }
2001 2008
2009 request_size = ioc->diag_buffer_sz[buffer_type];
2010
2002 if ((karg.starting_offset % 4) || (karg.bytes_to_read % 4)) { 2011 if ((karg.starting_offset % 4) || (karg.bytes_to_read % 4)) {
2003 printk(MPT2SAS_ERR_FMT "%s: either the starting_offset " 2012 printk(MPT2SAS_ERR_FMT "%s: either the starting_offset "
2004 "or bytes_to_read are not 4 byte aligned\n", ioc->name, 2013 "or bytes_to_read are not 4 byte aligned\n", ioc->name,
@@ -2006,13 +2015,23 @@ _ctl_diag_read_buffer(void __user *arg, enum block_state state)
2006 return -EINVAL; 2015 return -EINVAL;
2007 } 2016 }
2008 2017
2018 if (karg.starting_offset > request_size)
2019 return -EINVAL;
2020
2009 diag_data = (void *)(request_data + karg.starting_offset); 2021 diag_data = (void *)(request_data + karg.starting_offset);
2010 dctlprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: diag_buffer(%p), " 2022 dctlprintk(ioc, printk(MPT2SAS_INFO_FMT "%s: diag_buffer(%p), "
2011 "offset(%d), sz(%d)\n", ioc->name, __func__, 2023 "offset(%d), sz(%d)\n", ioc->name, __func__,
2012 diag_data, karg.starting_offset, karg.bytes_to_read)); 2024 diag_data, karg.starting_offset, karg.bytes_to_read));
2013 2025
2026 /* Truncate data on requests that are too large */
2027 if ((diag_data + karg.bytes_to_read < diag_data) ||
2028 (diag_data + karg.bytes_to_read > request_data + request_size))
2029 copy_size = request_size - karg.starting_offset;
2030 else
2031 copy_size = karg.bytes_to_read;
2032
2014 if (copy_to_user((void __user *)uarg->diagnostic_data, 2033 if (copy_to_user((void __user *)uarg->diagnostic_data,
2015 diag_data, karg.bytes_to_read)) { 2034 diag_data, copy_size)) {
2016 printk(MPT2SAS_ERR_FMT "%s: Unable to write " 2035 printk(MPT2SAS_ERR_FMT "%s: Unable to write "
2017 "mpt_diag_read_buffer_t data @ %p\n", ioc->name, 2036 "mpt_diag_read_buffer_t data @ %p\n", ioc->name,
2018 __func__, diag_data); 2037 __func__, diag_data);
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index 96d5ad0c1e42..7f636b118287 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -3814,6 +3814,9 @@ static long pmcraid_ioctl_passthrough(
3814 rc = -EFAULT; 3814 rc = -EFAULT;
3815 goto out_free_buffer; 3815 goto out_free_buffer;
3816 } 3816 }
3817 } else if (request_size < 0) {
3818 rc = -EINVAL;
3819 goto out_free_buffer;
3817 } 3820 }
3818 3821
3819 /* check if we have any additional command parameters */ 3822 /* check if we have any additional command parameters */
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
index e2d45c91b8e8..9689d41c7888 100644
--- a/drivers/scsi/qlogicpti.c
+++ b/drivers/scsi/qlogicpti.c
@@ -1292,8 +1292,10 @@ static struct scsi_host_template qpti_template = {
1292 .use_clustering = ENABLE_CLUSTERING, 1292 .use_clustering = ENABLE_CLUSTERING,
1293}; 1293};
1294 1294
1295static const struct of_device_id qpti_match[];
1295static int __devinit qpti_sbus_probe(struct platform_device *op) 1296static int __devinit qpti_sbus_probe(struct platform_device *op)
1296{ 1297{
1298 const struct of_device_id *match;
1297 struct scsi_host_template *tpnt; 1299 struct scsi_host_template *tpnt;
1298 struct device_node *dp = op->dev.of_node; 1300 struct device_node *dp = op->dev.of_node;
1299 struct Scsi_Host *host; 1301 struct Scsi_Host *host;
@@ -1301,9 +1303,10 @@ static int __devinit qpti_sbus_probe(struct platform_device *op)
1301 static int nqptis; 1303 static int nqptis;
1302 const char *fcode; 1304 const char *fcode;
1303 1305
1304 if (!op->dev.of_match) 1306 match = of_match_device(qpti_match, &op->dev);
1307 if (!match)
1305 return -EINVAL; 1308 return -EINVAL;
1306 tpnt = op->dev.of_match->data; 1309 tpnt = match->data;
1307 1310
1308 /* Sometimes Antares cards come up not completely 1311 /* Sometimes Antares cards come up not completely
1309 * setup, and we get a report of a zero IRQ. 1312 * setup, and we get a report of a zero IRQ.
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index ab55c2fa7ce2..ec1803a48723 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -74,8 +74,6 @@ struct kmem_cache *scsi_sdb_cache;
74 */ 74 */
75#define SCSI_QUEUE_DELAY 3 75#define SCSI_QUEUE_DELAY 3
76 76
77static void scsi_run_queue(struct request_queue *q);
78
79/* 77/*
80 * Function: scsi_unprep_request() 78 * Function: scsi_unprep_request()
81 * 79 *
@@ -161,7 +159,7 @@ static int __scsi_queue_insert(struct scsi_cmnd *cmd, int reason, int unbusy)
161 blk_requeue_request(q, cmd->request); 159 blk_requeue_request(q, cmd->request);
162 spin_unlock_irqrestore(q->queue_lock, flags); 160 spin_unlock_irqrestore(q->queue_lock, flags);
163 161
164 scsi_run_queue(q); 162 kblockd_schedule_work(q, &device->requeue_work);
165 163
166 return 0; 164 return 0;
167} 165}
@@ -400,10 +398,15 @@ static inline int scsi_host_is_busy(struct Scsi_Host *shost)
400static void scsi_run_queue(struct request_queue *q) 398static void scsi_run_queue(struct request_queue *q)
401{ 399{
402 struct scsi_device *sdev = q->queuedata; 400 struct scsi_device *sdev = q->queuedata;
403 struct Scsi_Host *shost = sdev->host; 401 struct Scsi_Host *shost;
404 LIST_HEAD(starved_list); 402 LIST_HEAD(starved_list);
405 unsigned long flags; 403 unsigned long flags;
406 404
405 /* if the device is dead, sdev will be NULL, so no queue to run */
406 if (!sdev)
407 return;
408
409 shost = sdev->host;
407 if (scsi_target(sdev)->single_lun) 410 if (scsi_target(sdev)->single_lun)
408 scsi_single_lun_run(sdev); 411 scsi_single_lun_run(sdev);
409 412
@@ -411,8 +414,6 @@ static void scsi_run_queue(struct request_queue *q)
411 list_splice_init(&shost->starved_list, &starved_list); 414 list_splice_init(&shost->starved_list, &starved_list);
412 415
413 while (!list_empty(&starved_list)) { 416 while (!list_empty(&starved_list)) {
414 int flagset;
415
416 /* 417 /*
417 * As long as shost is accepting commands and we have 418 * As long as shost is accepting commands and we have
418 * starved queues, call blk_run_queue. scsi_request_fn 419 * starved queues, call blk_run_queue. scsi_request_fn
@@ -436,18 +437,9 @@ static void scsi_run_queue(struct request_queue *q)
436 } 437 }
437 438
438 spin_unlock(shost->host_lock); 439 spin_unlock(shost->host_lock);
439
440 spin_lock(sdev->request_queue->queue_lock); 440 spin_lock(sdev->request_queue->queue_lock);
441 flagset = test_bit(QUEUE_FLAG_REENTER, &q->queue_flags) &&
442 !test_bit(QUEUE_FLAG_REENTER,
443 &sdev->request_queue->queue_flags);
444 if (flagset)
445 queue_flag_set(QUEUE_FLAG_REENTER, sdev->request_queue);
446 __blk_run_queue(sdev->request_queue); 441 __blk_run_queue(sdev->request_queue);
447 if (flagset)
448 queue_flag_clear(QUEUE_FLAG_REENTER, sdev->request_queue);
449 spin_unlock(sdev->request_queue->queue_lock); 442 spin_unlock(sdev->request_queue->queue_lock);
450
451 spin_lock(shost->host_lock); 443 spin_lock(shost->host_lock);
452 } 444 }
453 /* put any unprocessed entries back */ 445 /* put any unprocessed entries back */
@@ -457,6 +449,16 @@ static void scsi_run_queue(struct request_queue *q)
457 blk_run_queue(q); 449 blk_run_queue(q);
458} 450}
459 451
452void scsi_requeue_run_queue(struct work_struct *work)
453{
454 struct scsi_device *sdev;
455 struct request_queue *q;
456
457 sdev = container_of(work, struct scsi_device, requeue_work);
458 q = sdev->request_queue;
459 scsi_run_queue(q);
460}
461
460/* 462/*
461 * Function: scsi_requeue_command() 463 * Function: scsi_requeue_command()
462 * 464 *
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 087821fac8fe..58584dc0724a 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -242,6 +242,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,
242 int display_failure_msg = 1, ret; 242 int display_failure_msg = 1, ret;
243 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 243 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
244 extern void scsi_evt_thread(struct work_struct *work); 244 extern void scsi_evt_thread(struct work_struct *work);
245 extern void scsi_requeue_run_queue(struct work_struct *work);
245 246
246 sdev = kzalloc(sizeof(*sdev) + shost->transportt->device_size, 247 sdev = kzalloc(sizeof(*sdev) + shost->transportt->device_size,
247 GFP_ATOMIC); 248 GFP_ATOMIC);
@@ -264,6 +265,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,
264 INIT_LIST_HEAD(&sdev->event_list); 265 INIT_LIST_HEAD(&sdev->event_list);
265 spin_lock_init(&sdev->list_lock); 266 spin_lock_init(&sdev->list_lock);
266 INIT_WORK(&sdev->event_work, scsi_evt_thread); 267 INIT_WORK(&sdev->event_work, scsi_evt_thread);
268 INIT_WORK(&sdev->requeue_work, scsi_requeue_run_queue);
267 269
268 sdev->sdev_gendev.parent = get_device(&starget->dev); 270 sdev->sdev_gendev.parent = get_device(&starget->dev);
269 sdev->sdev_target = starget; 271 sdev->sdev_target = starget;
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index e44ff64233fd..e63912510fb9 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -322,14 +322,8 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
322 kfree(evt); 322 kfree(evt);
323 } 323 }
324 324
325 if (sdev->request_queue) { 325 /* NULL queue means the device can't be used */
326 sdev->request_queue->queuedata = NULL; 326 sdev->request_queue = NULL;
327 /* user context needed to free queue */
328 scsi_free_queue(sdev->request_queue);
329 /* temporary expedient, try to catch use of queue lock
330 * after free of sdev */
331 sdev->request_queue = NULL;
332 }
333 327
334 scsi_target_reap(scsi_target(sdev)); 328 scsi_target_reap(scsi_target(sdev));
335 329
@@ -937,6 +931,12 @@ void __scsi_remove_device(struct scsi_device *sdev)
937 if (sdev->host->hostt->slave_destroy) 931 if (sdev->host->hostt->slave_destroy)
938 sdev->host->hostt->slave_destroy(sdev); 932 sdev->host->hostt->slave_destroy(sdev);
939 transport_destroy_device(dev); 933 transport_destroy_device(dev);
934
935 /* cause the request function to reject all I/O requests */
936 sdev->request_queue->queuedata = NULL;
937
938 /* Freeing the queue signals to block that we're done */
939 scsi_free_queue(sdev->request_queue);
940 put_device(dev); 940 put_device(dev);
941} 941}
942 942
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 28c33506e4ad..815069d13f9b 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -3816,28 +3816,17 @@ fail_host_msg:
3816static void 3816static void
3817fc_bsg_goose_queue(struct fc_rport *rport) 3817fc_bsg_goose_queue(struct fc_rport *rport)
3818{ 3818{
3819 int flagset;
3820 unsigned long flags;
3821
3822 if (!rport->rqst_q) 3819 if (!rport->rqst_q)
3823 return; 3820 return;
3824 3821
3822 /*
3823 * This get/put dance makes no sense
3824 */
3825 get_device(&rport->dev); 3825 get_device(&rport->dev);
3826 3826 blk_run_queue_async(rport->rqst_q);
3827 spin_lock_irqsave(rport->rqst_q->queue_lock, flags);
3828 flagset = test_bit(QUEUE_FLAG_REENTER, &rport->rqst_q->queue_flags) &&
3829 !test_bit(QUEUE_FLAG_REENTER, &rport->rqst_q->queue_flags);
3830 if (flagset)
3831 queue_flag_set(QUEUE_FLAG_REENTER, rport->rqst_q);
3832 __blk_run_queue(rport->rqst_q);
3833 if (flagset)
3834 queue_flag_clear(QUEUE_FLAG_REENTER, rport->rqst_q);
3835 spin_unlock_irqrestore(rport->rqst_q->queue_lock, flags);
3836
3837 put_device(&rport->dev); 3827 put_device(&rport->dev);
3838} 3828}
3839 3829
3840
3841/** 3830/**
3842 * fc_bsg_rport_dispatch - process rport bsg requests and dispatch to LLDD 3831 * fc_bsg_rport_dispatch - process rport bsg requests and dispatch to LLDD
3843 * @q: rport request queue 3832 * @q: rport request queue
diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c
index eeb7dd43f9a8..830822f86e41 100644
--- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c
+++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c
@@ -2288,7 +2288,3 @@ err_dev:
2288 free_netdev(dev); 2288 free_netdev(dev);
2289 return NULL; 2289 return NULL;
2290} 2290}
2291
2292EXPORT_SYMBOL(init_ft1000_card);
2293EXPORT_SYMBOL(stop_ft1000_card);
2294EXPORT_SYMBOL(flarion_ft1000_cnt);
diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c
index 935608e72007..bdfb1aec58df 100644
--- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c
+++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c
@@ -214,6 +214,3 @@ void ft1000CleanupProc(struct net_device *dev)
214 remove_proc_entry(FT1000_PROC, init_net.proc_net); 214 remove_proc_entry(FT1000_PROC, init_net.proc_net);
215 unregister_netdevice_notifier(&ft1000_netdev_notifier); 215 unregister_netdevice_notifier(&ft1000_netdev_notifier);
216} 216}
217
218EXPORT_SYMBOL(ft1000InitProc);
219EXPORT_SYMBOL(ft1000CleanupProc);
diff --git a/drivers/staging/gma500/Kconfig b/drivers/staging/gma500/Kconfig
index 5501eb9b3355..ce8bedaeaac2 100644
--- a/drivers/staging/gma500/Kconfig
+++ b/drivers/staging/gma500/Kconfig
@@ -1,6 +1,6 @@
1config DRM_PSB 1config DRM_PSB
2 tristate "Intel GMA500 KMS Framebuffer" 2 tristate "Intel GMA500 KMS Framebuffer"
3 depends on DRM && PCI 3 depends on DRM && PCI && X86
4 select FB_CFB_COPYAREA 4 select FB_CFB_COPYAREA
5 select FB_CFB_FILLRECT 5 select FB_CFB_FILLRECT
6 select FB_CFB_IMAGEBLIT 6 select FB_CFB_IMAGEBLIT
diff --git a/drivers/staging/intel_sst/intelmid_v1_control.c b/drivers/staging/intel_sst/intelmid_v1_control.c
index 9cc15c1c18d4..1ea814218059 100644
--- a/drivers/staging/intel_sst/intelmid_v1_control.c
+++ b/drivers/staging/intel_sst/intelmid_v1_control.c
@@ -28,6 +28,7 @@
28#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 28#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
29 29
30#include <linux/pci.h> 30#include <linux/pci.h>
31#include <linux/delay.h>
31#include <linux/file.h> 32#include <linux/file.h>
32#include <asm/mrst.h> 33#include <asm/mrst.h>
33#include <sound/pcm.h> 34#include <sound/pcm.h>
diff --git a/drivers/staging/intel_sst/intelmid_v2_control.c b/drivers/staging/intel_sst/intelmid_v2_control.c
index 26d815a67eb8..3c6b3abff3c3 100644
--- a/drivers/staging/intel_sst/intelmid_v2_control.c
+++ b/drivers/staging/intel_sst/intelmid_v2_control.c
@@ -29,6 +29,7 @@
29#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 29#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
30 30
31#include <linux/pci.h> 31#include <linux/pci.h>
32#include <linux/delay.h>
32#include <linux/file.h> 33#include <linux/file.h>
33#include "intel_sst.h" 34#include "intel_sst.h"
34#include "intelmid_snd_control.h" 35#include "intelmid_snd_control.h"
diff --git a/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c b/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c
index b5d21f6497f9..22c04eabed41 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c
@@ -12,6 +12,7 @@
12 */ 12 */
13#include <linux/cs5535.h> 13#include <linux/cs5535.h>
14#include <linux/gpio.h> 14#include <linux/gpio.h>
15#include <linux/delay.h>
15#include <asm/olpc.h> 16#include <asm/olpc.h>
16 17
17#include "olpc_dcon.h" 18#include "olpc_dcon.h"
diff --git a/drivers/staging/rt2860/common/cmm_data_pci.c b/drivers/staging/rt2860/common/cmm_data_pci.c
index bef0bbd8cef7..f01a51c381f1 100644
--- a/drivers/staging/rt2860/common/cmm_data_pci.c
+++ b/drivers/staging/rt2860/common/cmm_data_pci.c
@@ -444,7 +444,7 @@ int RTMPCheckRxError(struct rt_rtmp_adapter *pAd,
444 return (NDIS_STATUS_FAILURE); 444 return (NDIS_STATUS_FAILURE);
445 } 445 }
446 } 446 }
447 /* Drop not U2M frames, can't's drop here because we will drop beacon in this case */ 447 /* Drop not U2M frames, can't drop here because we will drop beacon in this case */
448 /* I am kind of doubting the U2M bit operation */ 448 /* I am kind of doubting the U2M bit operation */
449 /* if (pRxD->U2M == 0) */ 449 /* if (pRxD->U2M == 0) */
450 /* return(NDIS_STATUS_FAILURE); */ 450 /* return(NDIS_STATUS_FAILURE); */
diff --git a/drivers/staging/rt2860/common/cmm_data_usb.c b/drivers/staging/rt2860/common/cmm_data_usb.c
index 5637857ae9eb..83a62faa7e57 100644
--- a/drivers/staging/rt2860/common/cmm_data_usb.c
+++ b/drivers/staging/rt2860/common/cmm_data_usb.c
@@ -860,7 +860,7 @@ int RTMPCheckRxError(struct rt_rtmp_adapter *pAd,
860 DBGPRINT_RAW(RT_DEBUG_ERROR, ("received packet too long\n")); 860 DBGPRINT_RAW(RT_DEBUG_ERROR, ("received packet too long\n"));
861 return NDIS_STATUS_FAILURE; 861 return NDIS_STATUS_FAILURE;
862 } 862 }
863 /* Drop not U2M frames, can't's drop here because we will drop beacon in this case */ 863 /* Drop not U2M frames, can't drop here because we will drop beacon in this case */
864 /* I am kind of doubting the U2M bit operation */ 864 /* I am kind of doubting the U2M bit operation */
865 /* if (pRxD->U2M == 0) */ 865 /* if (pRxD->U2M == 0) */
866 /* return(NDIS_STATUS_FAILURE); */ 866 /* return(NDIS_STATUS_FAILURE); */
diff --git a/drivers/staging/rts_pstor/debug.h b/drivers/staging/rts_pstor/debug.h
index e1408b0e7ae4..ab305be96fb5 100644
--- a/drivers/staging/rts_pstor/debug.h
+++ b/drivers/staging/rts_pstor/debug.h
@@ -28,7 +28,7 @@
28 28
29#define RTSX_STOR "rts_pstor: " 29#define RTSX_STOR "rts_pstor: "
30 30
31#if CONFIG_RTS_PSTOR_DEBUG 31#ifdef CONFIG_RTS_PSTOR_DEBUG
32#define RTSX_DEBUGP(x...) printk(KERN_DEBUG RTSX_STOR x) 32#define RTSX_DEBUGP(x...) printk(KERN_DEBUG RTSX_STOR x)
33#define RTSX_DEBUGPN(x...) printk(KERN_DEBUG x) 33#define RTSX_DEBUGPN(x...) printk(KERN_DEBUG x)
34#define RTSX_DEBUGPX(x...) printk(x) 34#define RTSX_DEBUGPX(x...) printk(x)
diff --git a/drivers/staging/rts_pstor/ms.c b/drivers/staging/rts_pstor/ms.c
index 810e170894f5..d89795c6a3ac 100644
--- a/drivers/staging/rts_pstor/ms.c
+++ b/drivers/staging/rts_pstor/ms.c
@@ -23,6 +23,7 @@
23#include <linux/blkdev.h> 23#include <linux/blkdev.h>
24#include <linux/kthread.h> 24#include <linux/kthread.h>
25#include <linux/sched.h> 25#include <linux/sched.h>
26#include <linux/vmalloc.h>
26 27
27#include "rtsx.h" 28#include "rtsx.h"
28#include "rtsx_transport.h" 29#include "rtsx_transport.h"
diff --git a/drivers/staging/rts_pstor/rtsx_chip.c b/drivers/staging/rts_pstor/rtsx_chip.c
index d2f1c715a684..4e60780ea804 100644
--- a/drivers/staging/rts_pstor/rtsx_chip.c
+++ b/drivers/staging/rts_pstor/rtsx_chip.c
@@ -24,6 +24,7 @@
24#include <linux/kthread.h> 24#include <linux/kthread.h>
25#include <linux/sched.h> 25#include <linux/sched.h>
26#include <linux/workqueue.h> 26#include <linux/workqueue.h>
27#include <linux/vmalloc.h>
27 28
28#include "rtsx.h" 29#include "rtsx.h"
29#include "rtsx_transport.h" 30#include "rtsx_transport.h"
@@ -1311,11 +1312,11 @@ void rtsx_polling_func(struct rtsx_chip *chip)
1311 1312
1312#ifdef SUPPORT_OCP 1313#ifdef SUPPORT_OCP
1313 if (CHECK_LUN_MODE(chip, SD_MS_2LUN)) { 1314 if (CHECK_LUN_MODE(chip, SD_MS_2LUN)) {
1314 #if CONFIG_RTS_PSTOR_DEBUG 1315#ifdef CONFIG_RTS_PSTOR_DEBUG
1315 if (chip->ocp_stat & (SD_OC_NOW | SD_OC_EVER | MS_OC_NOW | MS_OC_EVER)) { 1316 if (chip->ocp_stat & (SD_OC_NOW | SD_OC_EVER | MS_OC_NOW | MS_OC_EVER)) {
1316 RTSX_DEBUGP("Over current, OCPSTAT is 0x%x\n", chip->ocp_stat); 1317 RTSX_DEBUGP("Over current, OCPSTAT is 0x%x\n", chip->ocp_stat);
1317 } 1318 }
1318 #endif 1319#endif
1319 1320
1320 if (chip->ocp_stat & (SD_OC_NOW | SD_OC_EVER)) { 1321 if (chip->ocp_stat & (SD_OC_NOW | SD_OC_EVER)) {
1321 if (chip->card_exist & SD_CARD) { 1322 if (chip->card_exist & SD_CARD) {
diff --git a/drivers/staging/rts_pstor/rtsx_scsi.c b/drivers/staging/rts_pstor/rtsx_scsi.c
index 20c2464a20f9..7de1fae443fc 100644
--- a/drivers/staging/rts_pstor/rtsx_scsi.c
+++ b/drivers/staging/rts_pstor/rtsx_scsi.c
@@ -23,6 +23,7 @@
23#include <linux/blkdev.h> 23#include <linux/blkdev.h>
24#include <linux/kthread.h> 24#include <linux/kthread.h>
25#include <linux/sched.h> 25#include <linux/sched.h>
26#include <linux/vmalloc.h>
26 27
27#include "rtsx.h" 28#include "rtsx.h"
28#include "rtsx_transport.h" 29#include "rtsx_transport.h"
diff --git a/drivers/staging/rts_pstor/sd.c b/drivers/staging/rts_pstor/sd.c
index 8d066bd428c4..b1277a6c7a8b 100644
--- a/drivers/staging/rts_pstor/sd.c
+++ b/drivers/staging/rts_pstor/sd.c
@@ -909,7 +909,7 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir)
909 RTSX_WRITE_REG(chip, SD_VPCLK0_CTL, PHASE_NOT_RESET, PHASE_NOT_RESET); 909 RTSX_WRITE_REG(chip, SD_VPCLK0_CTL, PHASE_NOT_RESET, PHASE_NOT_RESET);
910 RTSX_WRITE_REG(chip, CLK_CTL, CHANGE_CLK, 0); 910 RTSX_WRITE_REG(chip, CLK_CTL, CHANGE_CLK, 0);
911 } else { 911 } else {
912#if CONFIG_RTS_PSTOR_DEBUG 912#ifdef CONFIG_RTS_PSTOR_DEBUG
913 rtsx_read_register(chip, SD_VP_CTL, &val); 913 rtsx_read_register(chip, SD_VP_CTL, &val);
914 RTSX_DEBUGP("SD_VP_CTL: 0x%x\n", val); 914 RTSX_DEBUGP("SD_VP_CTL: 0x%x\n", val);
915 rtsx_read_register(chip, SD_DCMPS_CTL, &val); 915 rtsx_read_register(chip, SD_DCMPS_CTL, &val);
@@ -958,7 +958,7 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir)
958 return STATUS_SUCCESS; 958 return STATUS_SUCCESS;
959 959
960Fail: 960Fail:
961#if CONFIG_RTS_PSTOR_DEBUG 961#ifdef CONFIG_RTS_PSTOR_DEBUG
962 rtsx_read_register(chip, SD_VP_CTL, &val); 962 rtsx_read_register(chip, SD_VP_CTL, &val);
963 RTSX_DEBUGP("SD_VP_CTL: 0x%x\n", val); 963 RTSX_DEBUGP("SD_VP_CTL: 0x%x\n", val);
964 rtsx_read_register(chip, SD_DCMPS_CTL, &val); 964 rtsx_read_register(chip, SD_DCMPS_CTL, &val);
diff --git a/drivers/staging/rts_pstor/trace.h b/drivers/staging/rts_pstor/trace.h
index 2c668bae6ff4..bc83b49a4eb4 100644
--- a/drivers/staging/rts_pstor/trace.h
+++ b/drivers/staging/rts_pstor/trace.h
@@ -82,7 +82,7 @@ do { \
82#define TRACE_GOTO(chip, label) goto label 82#define TRACE_GOTO(chip, label) goto label
83#endif 83#endif
84 84
85#if CONFIG_RTS_PSTOR_DEBUG 85#ifdef CONFIG_RTS_PSTOR_DEBUG
86static inline void rtsx_dump(u8 *buf, int buf_len) 86static inline void rtsx_dump(u8 *buf, int buf_len)
87{ 87{
88 int i; 88 int i;
diff --git a/drivers/staging/rts_pstor/xd.c b/drivers/staging/rts_pstor/xd.c
index 7bcd468b8f2c..9f3add1e8f59 100644
--- a/drivers/staging/rts_pstor/xd.c
+++ b/drivers/staging/rts_pstor/xd.c
@@ -23,6 +23,7 @@
23#include <linux/blkdev.h> 23#include <linux/blkdev.h>
24#include <linux/kthread.h> 24#include <linux/kthread.h>
25#include <linux/sched.h> 25#include <linux/sched.h>
26#include <linux/vmalloc.h>
26 27
27#include "rtsx.h" 28#include "rtsx.h"
28#include "rtsx_transport.h" 29#include "rtsx_transport.h"
diff --git a/drivers/staging/solo6x10/Kconfig b/drivers/staging/solo6x10/Kconfig
index 2cf77c940860..03dcac4ea4d0 100644
--- a/drivers/staging/solo6x10/Kconfig
+++ b/drivers/staging/solo6x10/Kconfig
@@ -2,6 +2,7 @@ config SOLO6X10
2 tristate "Softlogic 6x10 MPEG codec cards" 2 tristate "Softlogic 6x10 MPEG codec cards"
3 depends on PCI && VIDEO_DEV && SND && I2C 3 depends on PCI && VIDEO_DEV && SND && I2C
4 select VIDEOBUF_DMA_SG 4 select VIDEOBUF_DMA_SG
5 select SND_PCM
5 ---help--- 6 ---help---
6 This driver supports the Softlogic based MPEG-4 and h.264 codec 7 This driver supports the Softlogic based MPEG-4 and h.264 codec
7 codec cards. 8 codec cards.
diff --git a/drivers/staging/spectra/ffsport.c b/drivers/staging/spectra/ffsport.c
index 20dae73d3b78..506547b603e1 100644
--- a/drivers/staging/spectra/ffsport.c
+++ b/drivers/staging/spectra/ffsport.c
@@ -653,7 +653,7 @@ static int SBD_setup_device(struct spectra_nand_dev *dev, int which)
653 } 653 }
654 dev->queue->queuedata = dev; 654 dev->queue->queuedata = dev;
655 655
656 /* As Linux block layer does't support >4KB hardware sector, */ 656 /* As Linux block layer doesn't support >4KB hardware sector, */
657 /* Here we force report 512 byte hardware sector size to Kernel */ 657 /* Here we force report 512 byte hardware sector size to Kernel */
658 blk_queue_logical_block_size(dev->queue, 512); 658 blk_queue_logical_block_size(dev->queue, 512);
659 659
diff --git a/drivers/staging/tidspbridge/dynload/cload.c b/drivers/staging/tidspbridge/dynload/cload.c
index 5cecd237e3f6..fe1ef0addb09 100644
--- a/drivers/staging/tidspbridge/dynload/cload.c
+++ b/drivers/staging/tidspbridge/dynload/cload.c
@@ -718,7 +718,7 @@ static void dload_symbols(struct dload_state *dlthis)
718 * as a temporary for .dllview record construction. 718 * as a temporary for .dllview record construction.
719 * Allocate storage for the whole table. Add 1 to the section count 719 * Allocate storage for the whole table. Add 1 to the section count
720 * in case a trampoline section is auto-generated as well as the 720 * in case a trampoline section is auto-generated as well as the
721 * size of the trampoline section name so DLLView does't get lost. 721 * size of the trampoline section name so DLLView doesn't get lost.
722 */ 722 */
723 723
724 siz = sym_count * sizeof(struct local_symbol); 724 siz = sym_count * sizeof(struct local_symbol);
diff --git a/drivers/staging/tty/specialix.c b/drivers/staging/tty/specialix.c
index cb24c6d999db..5c3598ec7456 100644
--- a/drivers/staging/tty/specialix.c
+++ b/drivers/staging/tty/specialix.c
@@ -978,7 +978,7 @@ static void sx_change_speed(struct specialix_board *bp,
978 spin_lock_irqsave(&bp->lock, flags); 978 spin_lock_irqsave(&bp->lock, flags);
979 sx_out(bp, CD186x_CAR, port_No(port)); 979 sx_out(bp, CD186x_CAR, port_No(port));
980 980
981 /* The Specialix board does't implement the RTS lines. 981 /* The Specialix board doesn't implement the RTS lines.
982 They are used to set the IRQ level. Don't touch them. */ 982 They are used to set the IRQ level. Don't touch them. */
983 if (sx_crtscts(tty)) 983 if (sx_crtscts(tty))
984 port->MSVR = MSVR_DTR | (sx_in(bp, CD186x_MSVR) & MSVR_RTS); 984 port->MSVR = MSVR_DTR | (sx_in(bp, CD186x_MSVR) & MSVR_RTS);
diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
index 0f02a4b12ae4..4f4f13321f40 100644
--- a/drivers/staging/usbip/vhci_hcd.c
+++ b/drivers/staging/usbip/vhci_hcd.c
@@ -876,8 +876,10 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
876 } 876 }
877 877
878 /* kill threads related to this sdev, if v.c. exists */ 878 /* kill threads related to this sdev, if v.c. exists */
879 kthread_stop(vdev->ud.tcp_rx); 879 if (vdev->ud.tcp_rx)
880 kthread_stop(vdev->ud.tcp_tx); 880 kthread_stop(vdev->ud.tcp_rx);
881 if (vdev->ud.tcp_tx)
882 kthread_stop(vdev->ud.tcp_tx);
881 883
882 usbip_uinfo("stop threads\n"); 884 usbip_uinfo("stop threads\n");
883 885
@@ -949,9 +951,6 @@ static void vhci_device_init(struct vhci_device *vdev)
949{ 951{
950 memset(vdev, 0, sizeof(*vdev)); 952 memset(vdev, 0, sizeof(*vdev));
951 953
952 vdev->ud.tcp_rx = kthread_create(vhci_rx_loop, &vdev->ud, "vhci_rx");
953 vdev->ud.tcp_tx = kthread_create(vhci_tx_loop, &vdev->ud, "vhci_tx");
954
955 vdev->ud.side = USBIP_VHCI; 954 vdev->ud.side = USBIP_VHCI;
956 vdev->ud.status = VDEV_ST_NULL; 955 vdev->ud.status = VDEV_ST_NULL;
957 /* vdev->ud.lock = SPIN_LOCK_UNLOCKED; */ 956 /* vdev->ud.lock = SPIN_LOCK_UNLOCKED; */
@@ -1139,7 +1138,7 @@ static int vhci_hcd_probe(struct platform_device *pdev)
1139 usbip_uerr("create hcd failed\n"); 1138 usbip_uerr("create hcd failed\n");
1140 return -ENOMEM; 1139 return -ENOMEM;
1141 } 1140 }
1142 1141 hcd->has_tt = 1;
1143 1142
1144 /* this is private data for vhci_hcd */ 1143 /* this is private data for vhci_hcd */
1145 the_controller = hcd_to_vhci(hcd); 1144 the_controller = hcd_to_vhci(hcd);
diff --git a/drivers/staging/usbip/vhci_sysfs.c b/drivers/staging/usbip/vhci_sysfs.c
index 3f2459f30415..e2dadbd5ef1e 100644
--- a/drivers/staging/usbip/vhci_sysfs.c
+++ b/drivers/staging/usbip/vhci_sysfs.c
@@ -21,6 +21,7 @@
21#include "vhci.h" 21#include "vhci.h"
22 22
23#include <linux/in.h> 23#include <linux/in.h>
24#include <linux/kthread.h>
24 25
25/* TODO: refine locking ?*/ 26/* TODO: refine locking ?*/
26 27
@@ -220,13 +221,13 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
220 vdev->ud.tcp_socket = socket; 221 vdev->ud.tcp_socket = socket;
221 vdev->ud.status = VDEV_ST_NOTASSIGNED; 222 vdev->ud.status = VDEV_ST_NOTASSIGNED;
222 223
223 wake_up_process(vdev->ud.tcp_rx);
224 wake_up_process(vdev->ud.tcp_tx);
225
226 spin_unlock(&vdev->ud.lock); 224 spin_unlock(&vdev->ud.lock);
227 spin_unlock(&the_controller->lock); 225 spin_unlock(&the_controller->lock);
228 /* end the lock */ 226 /* end the lock */
229 227
228 vdev->ud.tcp_rx = kthread_run(vhci_rx_loop, &vdev->ud, "vhci_rx");
229 vdev->ud.tcp_tx = kthread_run(vhci_tx_loop, &vdev->ud, "vhci_tx");
230
230 rh_port_connect(rhport, speed); 231 rh_port_connect(rhport, speed);
231 232
232 return count; 233 return count;
diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c
index 6a71f52c59b1..76378397b763 100644
--- a/drivers/staging/wlan-ng/cfg80211.c
+++ b/drivers/staging/wlan-ng/cfg80211.c
@@ -273,7 +273,7 @@ exit:
273} 273}
274 274
275int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev, 275int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev,
276 u8 key_index) 276 u8 key_index, bool unicast, bool multicast)
277{ 277{
278 wlandevice_t *wlandev = dev->ml_priv; 278 wlandevice_t *wlandev = dev->ml_priv;
279 279
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 47f8cdb207f1..74273e638c0d 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -1658,8 +1658,12 @@ static void gsm_queue(struct gsm_mux *gsm)
1658 1658
1659 if ((gsm->control & ~PF) == UI) 1659 if ((gsm->control & ~PF) == UI)
1660 gsm->fcs = gsm_fcs_add_block(gsm->fcs, gsm->buf, gsm->len); 1660 gsm->fcs = gsm_fcs_add_block(gsm->fcs, gsm->buf, gsm->len);
1661 /* generate final CRC with received FCS */ 1661 if (gsm->encoding == 0){
1662 gsm->fcs = gsm_fcs_add(gsm->fcs, gsm->received_fcs); 1662 /* WARNING: gsm->received_fcs is used for gsm->encoding = 0 only.
1663 In this case it contain the last piece of data
1664 required to generate final CRC */
1665 gsm->fcs = gsm_fcs_add(gsm->fcs, gsm->received_fcs);
1666 }
1663 if (gsm->fcs != GOOD_FCS) { 1667 if (gsm->fcs != GOOD_FCS) {
1664 gsm->bad_fcs++; 1668 gsm->bad_fcs++;
1665 if (debug & 4) 1669 if (debug & 4)
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index cb36b0d4ef3c..62df72d9f0aa 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -382,12 +382,13 @@ static void imx_start_tx(struct uart_port *port)
382static irqreturn_t imx_rtsint(int irq, void *dev_id) 382static irqreturn_t imx_rtsint(int irq, void *dev_id)
383{ 383{
384 struct imx_port *sport = dev_id; 384 struct imx_port *sport = dev_id;
385 unsigned int val = readl(sport->port.membase + USR1) & USR1_RTSS; 385 unsigned int val;
386 unsigned long flags; 386 unsigned long flags;
387 387
388 spin_lock_irqsave(&sport->port.lock, flags); 388 spin_lock_irqsave(&sport->port.lock, flags);
389 389
390 writel(USR1_RTSD, sport->port.membase + USR1); 390 writel(USR1_RTSD, sport->port.membase + USR1);
391 val = readl(sport->port.membase + USR1) & USR1_RTSS;
391 uart_handle_cts_change(&sport->port, !!val); 392 uart_handle_cts_change(&sport->port, !!val);
392 wake_up_interruptible(&sport->port.state->port.delta_msr_wait); 393 wake_up_interruptible(&sport->port.state->port.delta_msr_wait);
393 394
diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
index 0e8eec516df4..c911b2419abb 100644
--- a/drivers/tty/serial/of_serial.c
+++ b/drivers/tty/serial/of_serial.c
@@ -80,14 +80,17 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
80/* 80/*
81 * Try to register a serial port 81 * Try to register a serial port
82 */ 82 */
83static struct of_device_id of_platform_serial_table[];
83static int __devinit of_platform_serial_probe(struct platform_device *ofdev) 84static int __devinit of_platform_serial_probe(struct platform_device *ofdev)
84{ 85{
86 const struct of_device_id *match;
85 struct of_serial_info *info; 87 struct of_serial_info *info;
86 struct uart_port port; 88 struct uart_port port;
87 int port_type; 89 int port_type;
88 int ret; 90 int ret;
89 91
90 if (!ofdev->dev.of_match) 92 match = of_match_device(of_platform_serial_table, &ofdev->dev);
93 if (!match)
91 return -EINVAL; 94 return -EINVAL;
92 95
93 if (of_find_property(ofdev->dev.of_node, "used-by-rtas", NULL)) 96 if (of_find_property(ofdev->dev.of_node, "used-by-rtas", NULL))
@@ -97,7 +100,7 @@ static int __devinit of_platform_serial_probe(struct platform_device *ofdev)
97 if (info == NULL) 100 if (info == NULL)
98 return -ENOMEM; 101 return -ENOMEM;
99 102
100 port_type = (unsigned long)ofdev->dev.of_match->data; 103 port_type = (unsigned long)match->data;
101 ret = of_platform_serial_setup(ofdev, port_type, &port); 104 ret = of_platform_serial_setup(ofdev, port_type, &port);
102 if (ret) 105 if (ret)
103 goto out; 106 goto out;
diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c
index 36613b37c504..3a68e09309f7 100644
--- a/drivers/usb/gadget/fsl_qe_udc.c
+++ b/drivers/usb/gadget/fsl_qe_udc.c
@@ -2539,15 +2539,18 @@ static void qe_udc_release(struct device *dev)
2539} 2539}
2540 2540
2541/* Driver probe functions */ 2541/* Driver probe functions */
2542static const struct of_device_id qe_udc_match[];
2542static int __devinit qe_udc_probe(struct platform_device *ofdev) 2543static int __devinit qe_udc_probe(struct platform_device *ofdev)
2543{ 2544{
2545 const struct of_device_id *match;
2544 struct device_node *np = ofdev->dev.of_node; 2546 struct device_node *np = ofdev->dev.of_node;
2545 struct qe_ep *ep; 2547 struct qe_ep *ep;
2546 unsigned int ret = 0; 2548 unsigned int ret = 0;
2547 unsigned int i; 2549 unsigned int i;
2548 const void *prop; 2550 const void *prop;
2549 2551
2550 if (!ofdev->dev.of_match) 2552 match = of_match_device(qe_udc_match, &ofdev->dev);
2553 if (!match)
2551 return -EINVAL; 2554 return -EINVAL;
2552 2555
2553 prop = of_get_property(np, "mode", NULL); 2556 prop = of_get_property(np, "mode", NULL);
@@ -2561,7 +2564,7 @@ static int __devinit qe_udc_probe(struct platform_device *ofdev)
2561 return -ENOMEM; 2564 return -ENOMEM;
2562 } 2565 }
2563 2566
2564 udc_controller->soc_type = (unsigned long)ofdev->dev.of_match->data; 2567 udc_controller->soc_type = (unsigned long)match->data;
2565 udc_controller->usb_regs = of_iomap(np, 0); 2568 udc_controller->usb_regs = of_iomap(np, 0);
2566 if (!udc_controller->usb_regs) { 2569 if (!udc_controller->usb_regs) {
2567 ret = -ENOMEM; 2570 ret = -ENOMEM;
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 7e41a95c5ceb..627f3a678759 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -40,6 +40,7 @@
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/usb/ulpi.h> 41#include <linux/usb/ulpi.h>
42#include <plat/usb.h> 42#include <plat/usb.h>
43#include <linux/regulator/consumer.h>
43 44
44/* EHCI Register Set */ 45/* EHCI Register Set */
45#define EHCI_INSNREG04 (0xA0) 46#define EHCI_INSNREG04 (0xA0)
@@ -118,6 +119,8 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
118 struct ehci_hcd *omap_ehci; 119 struct ehci_hcd *omap_ehci;
119 int ret = -ENODEV; 120 int ret = -ENODEV;
120 int irq; 121 int irq;
122 int i;
123 char supply[7];
121 124
122 if (usb_disabled()) 125 if (usb_disabled())
123 return -ENODEV; 126 return -ENODEV;
@@ -158,6 +161,23 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
158 hcd->rsrc_len = resource_size(res); 161 hcd->rsrc_len = resource_size(res);
159 hcd->regs = regs; 162 hcd->regs = regs;
160 163
164 /* get ehci regulator and enable */
165 for (i = 0 ; i < OMAP3_HS_USB_PORTS ; i++) {
166 if (pdata->port_mode[i] != OMAP_EHCI_PORT_MODE_PHY) {
167 pdata->regulator[i] = NULL;
168 continue;
169 }
170 snprintf(supply, sizeof(supply), "hsusb%d", i);
171 pdata->regulator[i] = regulator_get(dev, supply);
172 if (IS_ERR(pdata->regulator[i])) {
173 pdata->regulator[i] = NULL;
174 dev_dbg(dev,
175 "failed to get ehci port%d regulator\n", i);
176 } else {
177 regulator_enable(pdata->regulator[i]);
178 }
179 }
180
161 ret = omap_usbhs_enable(dev); 181 ret = omap_usbhs_enable(dev);
162 if (ret) { 182 if (ret) {
163 dev_err(dev, "failed to start usbhs with err %d\n", ret); 183 dev_err(dev, "failed to start usbhs with err %d\n", ret);
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index 795345ad45e6..7b2e69aa2e98 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -1633,6 +1633,7 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
1633 ints[i].qh = NULL; 1633 ints[i].qh = NULL;
1634 ints[i].qtd = NULL; 1634 ints[i].qtd = NULL;
1635 1635
1636 urb->status = status;
1636 isp1760_urb_done(hcd, urb); 1637 isp1760_urb_done(hcd, urb);
1637 if (qtd) 1638 if (qtd)
1638 pe(hcd, qh, qtd); 1639 pe(hcd, qh, qtd);
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index a78f2ebd11b7..73f75d26436c 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -777,7 +777,7 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
777 if (t1 != t2) 777 if (t1 != t2)
778 xhci_writel(xhci, t2, port_array[port_index]); 778 xhci_writel(xhci, t2, port_array[port_index]);
779 779
780 if (DEV_HIGHSPEED(t1)) { 780 if (hcd->speed != HCD_USB3) {
781 /* enable remote wake up for USB 2.0 */ 781 /* enable remote wake up for USB 2.0 */
782 u32 __iomem *addr; 782 u32 __iomem *addr;
783 u32 tmp; 783 u32 tmp;
@@ -866,6 +866,21 @@ int xhci_bus_resume(struct usb_hcd *hcd)
866 temp |= PORT_LINK_STROBE | XDEV_U0; 866 temp |= PORT_LINK_STROBE | XDEV_U0;
867 xhci_writel(xhci, temp, port_array[port_index]); 867 xhci_writel(xhci, temp, port_array[port_index]);
868 } 868 }
869 /* wait for the port to enter U0 and report port link
870 * state change.
871 */
872 spin_unlock_irqrestore(&xhci->lock, flags);
873 msleep(20);
874 spin_lock_irqsave(&xhci->lock, flags);
875
876 /* Clear PLC */
877 temp = xhci_readl(xhci, port_array[port_index]);
878 if (temp & PORT_PLC) {
879 temp = xhci_port_state_to_neutral(temp);
880 temp |= PORT_PLC;
881 xhci_writel(xhci, temp, port_array[port_index]);
882 }
883
869 slot_id = xhci_find_slot_id_by_port(hcd, 884 slot_id = xhci_find_slot_id_by_port(hcd,
870 xhci, port_index + 1); 885 xhci, port_index + 1);
871 if (slot_id) 886 if (slot_id)
@@ -873,7 +888,7 @@ int xhci_bus_resume(struct usb_hcd *hcd)
873 } else 888 } else
874 xhci_writel(xhci, temp, port_array[port_index]); 889 xhci_writel(xhci, temp, port_array[port_index]);
875 890
876 if (DEV_HIGHSPEED(temp)) { 891 if (hcd->speed != HCD_USB3) {
877 /* disable remote wake up for USB 2.0 */ 892 /* disable remote wake up for USB 2.0 */
878 u32 __iomem *addr; 893 u32 __iomem *addr;
879 u32 tmp; 894 u32 tmp;
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 6dfbf9ffd7a6..f47c20197c61 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1887,11 +1887,9 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
1887 otg_set_vbus(musb->xceiv, 1); 1887 otg_set_vbus(musb->xceiv, 1);
1888 1888
1889 hcd->self.uses_pio_for_control = 1; 1889 hcd->self.uses_pio_for_control = 1;
1890
1891 if (musb->xceiv->last_event == USB_EVENT_NONE)
1892 pm_runtime_put(musb->controller);
1893
1894 } 1890 }
1891 if (musb->xceiv->last_event == USB_EVENT_NONE)
1892 pm_runtime_put(musb->controller);
1895 1893
1896 return 0; 1894 return 0;
1897 1895
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 57a27fa954b4..e9e60b6e0583 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -270,7 +270,7 @@ static int musb_otg_notifications(struct notifier_block *nb,
270 DBG(4, "VBUS Disconnect\n"); 270 DBG(4, "VBUS Disconnect\n");
271 271
272#ifdef CONFIG_USB_GADGET_MUSB_HDRC 272#ifdef CONFIG_USB_GADGET_MUSB_HDRC
273 if (is_otg_enabled(musb)) 273 if (is_otg_enabled(musb) || is_peripheral_enabled(musb))
274 if (musb->gadget_driver) 274 if (musb->gadget_driver)
275#endif 275#endif
276 { 276 {
diff --git a/drivers/video/acornfb.c b/drivers/video/acornfb.c
index 82acb8dc4aa1..6183a57eb69d 100644
--- a/drivers/video/acornfb.c
+++ b/drivers/video/acornfb.c
@@ -66,7 +66,7 @@
66 * have. Allow 1% either way on the nominal for TVs. 66 * have. Allow 1% either way on the nominal for TVs.
67 */ 67 */
68#define NR_MONTYPES 6 68#define NR_MONTYPES 6
69static struct fb_monspecs monspecs[NR_MONTYPES] __initdata = { 69static struct fb_monspecs monspecs[NR_MONTYPES] __devinitdata = {
70 { /* TV */ 70 { /* TV */
71 .hfmin = 15469, 71 .hfmin = 15469,
72 .hfmax = 15781, 72 .hfmax = 15781,
@@ -873,7 +873,7 @@ static struct fb_ops acornfb_ops = {
873/* 873/*
874 * Everything after here is initialisation!!! 874 * Everything after here is initialisation!!!
875 */ 875 */
876static struct fb_videomode modedb[] __initdata = { 876static struct fb_videomode modedb[] __devinitdata = {
877 { /* 320x256 @ 50Hz */ 877 { /* 320x256 @ 50Hz */
878 NULL, 50, 320, 256, 125000, 92, 62, 35, 19, 38, 2, 878 NULL, 50, 320, 256, 125000, 92, 62, 35, 19, 38, 2,
879 FB_SYNC_COMP_HIGH_ACT, 879 FB_SYNC_COMP_HIGH_ACT,
@@ -925,8 +925,7 @@ static struct fb_videomode modedb[] __initdata = {
925 } 925 }
926}; 926};
927 927
928static struct fb_videomode __initdata 928static struct fb_videomode acornfb_default_mode __devinitdata = {
929acornfb_default_mode = {
930 .name = NULL, 929 .name = NULL,
931 .refresh = 60, 930 .refresh = 60,
932 .xres = 640, 931 .xres = 640,
@@ -942,7 +941,7 @@ acornfb_default_mode = {
942 .vmode = FB_VMODE_NONINTERLACED 941 .vmode = FB_VMODE_NONINTERLACED
943}; 942};
944 943
945static void __init acornfb_init_fbinfo(void) 944static void __devinit acornfb_init_fbinfo(void)
946{ 945{
947 static int first = 1; 946 static int first = 1;
948 947
@@ -1018,8 +1017,7 @@ static void __init acornfb_init_fbinfo(void)
1018 * size can optionally be followed by 'M' or 'K' for 1017 * size can optionally be followed by 'M' or 'K' for
1019 * MB or KB respectively. 1018 * MB or KB respectively.
1020 */ 1019 */
1021static void __init 1020static void __devinit acornfb_parse_mon(char *opt)
1022acornfb_parse_mon(char *opt)
1023{ 1021{
1024 char *p = opt; 1022 char *p = opt;
1025 1023
@@ -1066,8 +1064,7 @@ bad:
1066 current_par.montype = -1; 1064 current_par.montype = -1;
1067} 1065}
1068 1066
1069static void __init 1067static void __devinit acornfb_parse_montype(char *opt)
1070acornfb_parse_montype(char *opt)
1071{ 1068{
1072 current_par.montype = -2; 1069 current_par.montype = -2;
1073 1070
@@ -1108,8 +1105,7 @@ acornfb_parse_montype(char *opt)
1108 } 1105 }
1109} 1106}
1110 1107
1111static void __init 1108static void __devinit acornfb_parse_dram(char *opt)
1112acornfb_parse_dram(char *opt)
1113{ 1109{
1114 unsigned int size; 1110 unsigned int size;
1115 1111
@@ -1134,15 +1130,14 @@ acornfb_parse_dram(char *opt)
1134static struct options { 1130static struct options {
1135 char *name; 1131 char *name;
1136 void (*parse)(char *opt); 1132 void (*parse)(char *opt);
1137} opt_table[] __initdata = { 1133} opt_table[] __devinitdata = {
1138 { "mon", acornfb_parse_mon }, 1134 { "mon", acornfb_parse_mon },
1139 { "montype", acornfb_parse_montype }, 1135 { "montype", acornfb_parse_montype },
1140 { "dram", acornfb_parse_dram }, 1136 { "dram", acornfb_parse_dram },
1141 { NULL, NULL } 1137 { NULL, NULL }
1142}; 1138};
1143 1139
1144int __init 1140static int __devinit acornfb_setup(char *options)
1145acornfb_setup(char *options)
1146{ 1141{
1147 struct options *optp; 1142 struct options *optp;
1148 char *opt; 1143 char *opt;
@@ -1179,8 +1174,7 @@ acornfb_setup(char *options)
1179 * Detect type of monitor connected 1174 * Detect type of monitor connected
1180 * For now, we just assume SVGA 1175 * For now, we just assume SVGA
1181 */ 1176 */
1182static int __init 1177static int __devinit acornfb_detect_monitortype(void)
1183acornfb_detect_monitortype(void)
1184{ 1178{
1185 return 4; 1179 return 4;
1186} 1180}
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index e0c2284924b6..5aac00eb1830 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -42,9 +42,34 @@
42 42
43#define FBPIXMAPSIZE (1024 * 8) 43#define FBPIXMAPSIZE (1024 * 8)
44 44
45static DEFINE_MUTEX(registration_lock);
45struct fb_info *registered_fb[FB_MAX] __read_mostly; 46struct fb_info *registered_fb[FB_MAX] __read_mostly;
46int num_registered_fb __read_mostly; 47int num_registered_fb __read_mostly;
47 48
49static struct fb_info *get_fb_info(unsigned int idx)
50{
51 struct fb_info *fb_info;
52
53 if (idx >= FB_MAX)
54 return ERR_PTR(-ENODEV);
55
56 mutex_lock(&registration_lock);
57 fb_info = registered_fb[idx];
58 if (fb_info)
59 atomic_inc(&fb_info->count);
60 mutex_unlock(&registration_lock);
61
62 return fb_info;
63}
64
65static void put_fb_info(struct fb_info *fb_info)
66{
67 if (!atomic_dec_and_test(&fb_info->count))
68 return;
69 if (fb_info->fbops->fb_destroy)
70 fb_info->fbops->fb_destroy(fb_info);
71}
72
48int lock_fb_info(struct fb_info *info) 73int lock_fb_info(struct fb_info *info)
49{ 74{
50 mutex_lock(&info->lock); 75 mutex_lock(&info->lock);
@@ -647,6 +672,7 @@ int fb_show_logo(struct fb_info *info, int rotate) { return 0; }
647 672
648static void *fb_seq_start(struct seq_file *m, loff_t *pos) 673static void *fb_seq_start(struct seq_file *m, loff_t *pos)
649{ 674{
675 mutex_lock(&registration_lock);
650 return (*pos < FB_MAX) ? pos : NULL; 676 return (*pos < FB_MAX) ? pos : NULL;
651} 677}
652 678
@@ -658,6 +684,7 @@ static void *fb_seq_next(struct seq_file *m, void *v, loff_t *pos)
658 684
659static void fb_seq_stop(struct seq_file *m, void *v) 685static void fb_seq_stop(struct seq_file *m, void *v)
660{ 686{
687 mutex_unlock(&registration_lock);
661} 688}
662 689
663static int fb_seq_show(struct seq_file *m, void *v) 690static int fb_seq_show(struct seq_file *m, void *v)
@@ -690,13 +717,30 @@ static const struct file_operations fb_proc_fops = {
690 .release = seq_release, 717 .release = seq_release,
691}; 718};
692 719
693static ssize_t 720/*
694fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) 721 * We hold a reference to the fb_info in file->private_data,
722 * but if the current registered fb has changed, we don't
723 * actually want to use it.
724 *
725 * So look up the fb_info using the inode minor number,
726 * and just verify it against the reference we have.
727 */
728static struct fb_info *file_fb_info(struct file *file)
695{ 729{
696 unsigned long p = *ppos;
697 struct inode *inode = file->f_path.dentry->d_inode; 730 struct inode *inode = file->f_path.dentry->d_inode;
698 int fbidx = iminor(inode); 731 int fbidx = iminor(inode);
699 struct fb_info *info = registered_fb[fbidx]; 732 struct fb_info *info = registered_fb[fbidx];
733
734 if (info != file->private_data)
735 info = NULL;
736 return info;
737}
738
739static ssize_t
740fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
741{
742 unsigned long p = *ppos;
743 struct fb_info *info = file_fb_info(file);
700 u8 *buffer, *dst; 744 u8 *buffer, *dst;
701 u8 __iomem *src; 745 u8 __iomem *src;
702 int c, cnt = 0, err = 0; 746 int c, cnt = 0, err = 0;
@@ -761,9 +805,7 @@ static ssize_t
761fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) 805fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
762{ 806{
763 unsigned long p = *ppos; 807 unsigned long p = *ppos;
764 struct inode *inode = file->f_path.dentry->d_inode; 808 struct fb_info *info = file_fb_info(file);
765 int fbidx = iminor(inode);
766 struct fb_info *info = registered_fb[fbidx];
767 u8 *buffer, *src; 809 u8 *buffer, *src;
768 u8 __iomem *dst; 810 u8 __iomem *dst;
769 int c, cnt = 0, err = 0; 811 int c, cnt = 0, err = 0;
@@ -1141,10 +1183,10 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
1141 1183
1142static long fb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 1184static long fb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1143{ 1185{
1144 struct inode *inode = file->f_path.dentry->d_inode; 1186 struct fb_info *info = file_fb_info(file);
1145 int fbidx = iminor(inode);
1146 struct fb_info *info = registered_fb[fbidx];
1147 1187
1188 if (!info)
1189 return -ENODEV;
1148 return do_fb_ioctl(info, cmd, arg); 1190 return do_fb_ioctl(info, cmd, arg);
1149} 1191}
1150 1192
@@ -1265,12 +1307,13 @@ static int fb_get_fscreeninfo(struct fb_info *info, unsigned int cmd,
1265static long fb_compat_ioctl(struct file *file, unsigned int cmd, 1307static long fb_compat_ioctl(struct file *file, unsigned int cmd,
1266 unsigned long arg) 1308 unsigned long arg)
1267{ 1309{
1268 struct inode *inode = file->f_path.dentry->d_inode; 1310 struct fb_info *info = file_fb_info(file);
1269 int fbidx = iminor(inode); 1311 struct fb_ops *fb;
1270 struct fb_info *info = registered_fb[fbidx];
1271 struct fb_ops *fb = info->fbops;
1272 long ret = -ENOIOCTLCMD; 1312 long ret = -ENOIOCTLCMD;
1273 1313
1314 if (!info)
1315 return -ENODEV;
1316 fb = info->fbops;
1274 switch(cmd) { 1317 switch(cmd) {
1275 case FBIOGET_VSCREENINFO: 1318 case FBIOGET_VSCREENINFO:
1276 case FBIOPUT_VSCREENINFO: 1319 case FBIOPUT_VSCREENINFO:
@@ -1303,16 +1346,18 @@ static long fb_compat_ioctl(struct file *file, unsigned int cmd,
1303static int 1346static int
1304fb_mmap(struct file *file, struct vm_area_struct * vma) 1347fb_mmap(struct file *file, struct vm_area_struct * vma)
1305{ 1348{
1306 int fbidx = iminor(file->f_path.dentry->d_inode); 1349 struct fb_info *info = file_fb_info(file);
1307 struct fb_info *info = registered_fb[fbidx]; 1350 struct fb_ops *fb;
1308 struct fb_ops *fb = info->fbops;
1309 unsigned long off; 1351 unsigned long off;
1310 unsigned long start; 1352 unsigned long start;
1311 u32 len; 1353 u32 len;
1312 1354
1355 if (!info)
1356 return -ENODEV;
1313 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) 1357 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
1314 return -EINVAL; 1358 return -EINVAL;
1315 off = vma->vm_pgoff << PAGE_SHIFT; 1359 off = vma->vm_pgoff << PAGE_SHIFT;
1360 fb = info->fbops;
1316 if (!fb) 1361 if (!fb)
1317 return -ENODEV; 1362 return -ENODEV;
1318 mutex_lock(&info->mm_lock); 1363 mutex_lock(&info->mm_lock);
@@ -1361,14 +1406,16 @@ __releases(&info->lock)
1361 struct fb_info *info; 1406 struct fb_info *info;
1362 int res = 0; 1407 int res = 0;
1363 1408
1364 if (fbidx >= FB_MAX) 1409 info = get_fb_info(fbidx);
1365 return -ENODEV; 1410 if (!info) {
1366 info = registered_fb[fbidx];
1367 if (!info)
1368 request_module("fb%d", fbidx); 1411 request_module("fb%d", fbidx);
1369 info = registered_fb[fbidx]; 1412 info = get_fb_info(fbidx);
1370 if (!info) 1413 if (!info)
1371 return -ENODEV; 1414 return -ENODEV;
1415 }
1416 if (IS_ERR(info))
1417 return PTR_ERR(info);
1418
1372 mutex_lock(&info->lock); 1419 mutex_lock(&info->lock);
1373 if (!try_module_get(info->fbops->owner)) { 1420 if (!try_module_get(info->fbops->owner)) {
1374 res = -ENODEV; 1421 res = -ENODEV;
@@ -1386,6 +1433,8 @@ __releases(&info->lock)
1386#endif 1433#endif
1387out: 1434out:
1388 mutex_unlock(&info->lock); 1435 mutex_unlock(&info->lock);
1436 if (res)
1437 put_fb_info(info);
1389 return res; 1438 return res;
1390} 1439}
1391 1440
@@ -1401,6 +1450,7 @@ __releases(&info->lock)
1401 info->fbops->fb_release(info,1); 1450 info->fbops->fb_release(info,1);
1402 module_put(info->fbops->owner); 1451 module_put(info->fbops->owner);
1403 mutex_unlock(&info->lock); 1452 mutex_unlock(&info->lock);
1453 put_fb_info(info);
1404 return 0; 1454 return 0;
1405} 1455}
1406 1456
@@ -1487,8 +1537,10 @@ static bool fb_do_apertures_overlap(struct apertures_struct *gena,
1487 return false; 1537 return false;
1488} 1538}
1489 1539
1540static int do_unregister_framebuffer(struct fb_info *fb_info);
1541
1490#define VGA_FB_PHYS 0xA0000 1542#define VGA_FB_PHYS 0xA0000
1491void remove_conflicting_framebuffers(struct apertures_struct *a, 1543static void do_remove_conflicting_framebuffers(struct apertures_struct *a,
1492 const char *name, bool primary) 1544 const char *name, bool primary)
1493{ 1545{
1494 int i; 1546 int i;
@@ -1510,43 +1562,32 @@ void remove_conflicting_framebuffers(struct apertures_struct *a,
1510 printk(KERN_INFO "fb: conflicting fb hw usage " 1562 printk(KERN_INFO "fb: conflicting fb hw usage "
1511 "%s vs %s - removing generic driver\n", 1563 "%s vs %s - removing generic driver\n",
1512 name, registered_fb[i]->fix.id); 1564 name, registered_fb[i]->fix.id);
1513 unregister_framebuffer(registered_fb[i]); 1565 do_unregister_framebuffer(registered_fb[i]);
1514 } 1566 }
1515 } 1567 }
1516} 1568}
1517EXPORT_SYMBOL(remove_conflicting_framebuffers);
1518 1569
1519/** 1570static int do_register_framebuffer(struct fb_info *fb_info)
1520 * register_framebuffer - registers a frame buffer device
1521 * @fb_info: frame buffer info structure
1522 *
1523 * Registers a frame buffer device @fb_info.
1524 *
1525 * Returns negative errno on error, or zero for success.
1526 *
1527 */
1528
1529int
1530register_framebuffer(struct fb_info *fb_info)
1531{ 1571{
1532 int i; 1572 int i;
1533 struct fb_event event; 1573 struct fb_event event;
1534 struct fb_videomode mode; 1574 struct fb_videomode mode;
1535 1575
1536 if (num_registered_fb == FB_MAX)
1537 return -ENXIO;
1538
1539 if (fb_check_foreignness(fb_info)) 1576 if (fb_check_foreignness(fb_info))
1540 return -ENOSYS; 1577 return -ENOSYS;
1541 1578
1542 remove_conflicting_framebuffers(fb_info->apertures, fb_info->fix.id, 1579 do_remove_conflicting_framebuffers(fb_info->apertures, fb_info->fix.id,
1543 fb_is_primary_device(fb_info)); 1580 fb_is_primary_device(fb_info));
1544 1581
1582 if (num_registered_fb == FB_MAX)
1583 return -ENXIO;
1584
1545 num_registered_fb++; 1585 num_registered_fb++;
1546 for (i = 0 ; i < FB_MAX; i++) 1586 for (i = 0 ; i < FB_MAX; i++)
1547 if (!registered_fb[i]) 1587 if (!registered_fb[i])
1548 break; 1588 break;
1549 fb_info->node = i; 1589 fb_info->node = i;
1590 atomic_set(&fb_info->count, 1);
1550 mutex_init(&fb_info->lock); 1591 mutex_init(&fb_info->lock);
1551 mutex_init(&fb_info->mm_lock); 1592 mutex_init(&fb_info->mm_lock);
1552 1593
@@ -1592,36 +1633,14 @@ register_framebuffer(struct fb_info *fb_info)
1592 return 0; 1633 return 0;
1593} 1634}
1594 1635
1595 1636static int do_unregister_framebuffer(struct fb_info *fb_info)
1596/**
1597 * unregister_framebuffer - releases a frame buffer device
1598 * @fb_info: frame buffer info structure
1599 *
1600 * Unregisters a frame buffer device @fb_info.
1601 *
1602 * Returns negative errno on error, or zero for success.
1603 *
1604 * This function will also notify the framebuffer console
1605 * to release the driver.
1606 *
1607 * This is meant to be called within a driver's module_exit()
1608 * function. If this is called outside module_exit(), ensure
1609 * that the driver implements fb_open() and fb_release() to
1610 * check that no processes are using the device.
1611 */
1612
1613int
1614unregister_framebuffer(struct fb_info *fb_info)
1615{ 1637{
1616 struct fb_event event; 1638 struct fb_event event;
1617 int i, ret = 0; 1639 int i, ret = 0;
1618 1640
1619 i = fb_info->node; 1641 i = fb_info->node;
1620 if (!registered_fb[i]) { 1642 if (i < 0 || i >= FB_MAX || registered_fb[i] != fb_info)
1621 ret = -EINVAL; 1643 return -EINVAL;
1622 goto done;
1623 }
1624
1625 1644
1626 if (!lock_fb_info(fb_info)) 1645 if (!lock_fb_info(fb_info))
1627 return -ENODEV; 1646 return -ENODEV;
@@ -1629,16 +1648,14 @@ unregister_framebuffer(struct fb_info *fb_info)
1629 ret = fb_notifier_call_chain(FB_EVENT_FB_UNBIND, &event); 1648 ret = fb_notifier_call_chain(FB_EVENT_FB_UNBIND, &event);
1630 unlock_fb_info(fb_info); 1649 unlock_fb_info(fb_info);
1631 1650
1632 if (ret) { 1651 if (ret)
1633 ret = -EINVAL; 1652 return -EINVAL;
1634 goto done;
1635 }
1636 1653
1637 if (fb_info->pixmap.addr && 1654 if (fb_info->pixmap.addr &&
1638 (fb_info->pixmap.flags & FB_PIXMAP_DEFAULT)) 1655 (fb_info->pixmap.flags & FB_PIXMAP_DEFAULT))
1639 kfree(fb_info->pixmap.addr); 1656 kfree(fb_info->pixmap.addr);
1640 fb_destroy_modelist(&fb_info->modelist); 1657 fb_destroy_modelist(&fb_info->modelist);
1641 registered_fb[i]=NULL; 1658 registered_fb[i] = NULL;
1642 num_registered_fb--; 1659 num_registered_fb--;
1643 fb_cleanup_device(fb_info); 1660 fb_cleanup_device(fb_info);
1644 device_destroy(fb_class, MKDEV(FB_MAJOR, i)); 1661 device_destroy(fb_class, MKDEV(FB_MAJOR, i));
@@ -1646,9 +1663,65 @@ unregister_framebuffer(struct fb_info *fb_info)
1646 fb_notifier_call_chain(FB_EVENT_FB_UNREGISTERED, &event); 1663 fb_notifier_call_chain(FB_EVENT_FB_UNREGISTERED, &event);
1647 1664
1648 /* this may free fb info */ 1665 /* this may free fb info */
1649 if (fb_info->fbops->fb_destroy) 1666 put_fb_info(fb_info);
1650 fb_info->fbops->fb_destroy(fb_info); 1667 return 0;
1651done: 1668}
1669
1670void remove_conflicting_framebuffers(struct apertures_struct *a,
1671 const char *name, bool primary)
1672{
1673 mutex_lock(&registration_lock);
1674 do_remove_conflicting_framebuffers(a, name, primary);
1675 mutex_unlock(&registration_lock);
1676}
1677EXPORT_SYMBOL(remove_conflicting_framebuffers);
1678
1679/**
1680 * register_framebuffer - registers a frame buffer device
1681 * @fb_info: frame buffer info structure
1682 *
1683 * Registers a frame buffer device @fb_info.
1684 *
1685 * Returns negative errno on error, or zero for success.
1686 *
1687 */
1688int
1689register_framebuffer(struct fb_info *fb_info)
1690{
1691 int ret;
1692
1693 mutex_lock(&registration_lock);
1694 ret = do_register_framebuffer(fb_info);
1695 mutex_unlock(&registration_lock);
1696
1697 return ret;
1698}
1699
1700/**
1701 * unregister_framebuffer - releases a frame buffer device
1702 * @fb_info: frame buffer info structure
1703 *
1704 * Unregisters a frame buffer device @fb_info.
1705 *
1706 * Returns negative errno on error, or zero for success.
1707 *
1708 * This function will also notify the framebuffer console
1709 * to release the driver.
1710 *
1711 * This is meant to be called within a driver's module_exit()
1712 * function. If this is called outside module_exit(), ensure
1713 * that the driver implements fb_open() and fb_release() to
1714 * check that no processes are using the device.
1715 */
1716int
1717unregister_framebuffer(struct fb_info *fb_info)
1718{
1719 int ret;
1720
1721 mutex_lock(&registration_lock);
1722 ret = do_unregister_framebuffer(fb_info);
1723 mutex_unlock(&registration_lock);
1724
1652 return ret; 1725 return ret;
1653} 1726}
1654 1727
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index 4fb5b2bf2348..4bcc8b82640b 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -590,15 +590,10 @@ static struct virtio_config_ops virtio_pci_config_ops = {
590 590
591static void virtio_pci_release_dev(struct device *_d) 591static void virtio_pci_release_dev(struct device *_d)
592{ 592{
593 struct virtio_device *dev = container_of(_d, struct virtio_device, dev); 593 struct virtio_device *dev = container_of(_d, struct virtio_device,
594 dev);
594 struct virtio_pci_device *vp_dev = to_vp_device(dev); 595 struct virtio_pci_device *vp_dev = to_vp_device(dev);
595 struct pci_dev *pci_dev = vp_dev->pci_dev;
596 596
597 vp_del_vqs(dev);
598 pci_set_drvdata(pci_dev, NULL);
599 pci_iounmap(pci_dev, vp_dev->ioaddr);
600 pci_release_regions(pci_dev);
601 pci_disable_device(pci_dev);
602 kfree(vp_dev); 597 kfree(vp_dev);
603} 598}
604 599
@@ -681,6 +676,12 @@ static void __devexit virtio_pci_remove(struct pci_dev *pci_dev)
681 struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); 676 struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
682 677
683 unregister_virtio_device(&vp_dev->vdev); 678 unregister_virtio_device(&vp_dev->vdev);
679
680 vp_del_vqs(&vp_dev->vdev);
681 pci_set_drvdata(pci_dev, NULL);
682 pci_iounmap(pci_dev, vp_dev->ioaddr);
683 pci_release_regions(pci_dev);
684 pci_disable_device(pci_dev);
684} 685}
685 686
686#ifdef CONFIG_PM 687#ifdef CONFIG_PM
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index cc2f73e03475..b0043fb26a4d 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -371,6 +371,7 @@ void *virtqueue_detach_unused_buf(struct virtqueue *_vq)
371 /* detach_buf clears data, so grab it now. */ 371 /* detach_buf clears data, so grab it now. */
372 buf = vq->data[i]; 372 buf = vq->data[i];
373 detach_buf(vq, i); 373 detach_buf(vq, i);
374 vq->vring.avail->idx--;
374 END_USE(vq); 375 END_USE(vq);
375 return buf; 376 return buf;
376 } 377 }
diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index 35a0d12dad73..5fd020da7c55 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -35,6 +35,7 @@
35 * document number 324645-001, 324646-001: Cougar Point (CPT) 35 * document number 324645-001, 324646-001: Cougar Point (CPT)
36 * document number TBD : Patsburg (PBG) 36 * document number TBD : Patsburg (PBG)
37 * document number TBD : DH89xxCC 37 * document number TBD : DH89xxCC
38 * document number TBD : Panther Point
38 */ 39 */
39 40
40/* 41/*
@@ -153,6 +154,38 @@ enum iTCO_chipsets {
153 TCO_PBG1, /* Patsburg */ 154 TCO_PBG1, /* Patsburg */
154 TCO_PBG2, /* Patsburg */ 155 TCO_PBG2, /* Patsburg */
155 TCO_DH89XXCC, /* DH89xxCC */ 156 TCO_DH89XXCC, /* DH89xxCC */
157 TCO_PPT0, /* Panther Point */
158 TCO_PPT1, /* Panther Point */
159 TCO_PPT2, /* Panther Point */
160 TCO_PPT3, /* Panther Point */
161 TCO_PPT4, /* Panther Point */
162 TCO_PPT5, /* Panther Point */
163 TCO_PPT6, /* Panther Point */
164 TCO_PPT7, /* Panther Point */
165 TCO_PPT8, /* Panther Point */
166 TCO_PPT9, /* Panther Point */
167 TCO_PPT10, /* Panther Point */
168 TCO_PPT11, /* Panther Point */
169 TCO_PPT12, /* Panther Point */
170 TCO_PPT13, /* Panther Point */
171 TCO_PPT14, /* Panther Point */
172 TCO_PPT15, /* Panther Point */
173 TCO_PPT16, /* Panther Point */
174 TCO_PPT17, /* Panther Point */
175 TCO_PPT18, /* Panther Point */
176 TCO_PPT19, /* Panther Point */
177 TCO_PPT20, /* Panther Point */
178 TCO_PPT21, /* Panther Point */
179 TCO_PPT22, /* Panther Point */
180 TCO_PPT23, /* Panther Point */
181 TCO_PPT24, /* Panther Point */
182 TCO_PPT25, /* Panther Point */
183 TCO_PPT26, /* Panther Point */
184 TCO_PPT27, /* Panther Point */
185 TCO_PPT28, /* Panther Point */
186 TCO_PPT29, /* Panther Point */
187 TCO_PPT30, /* Panther Point */
188 TCO_PPT31, /* Panther Point */
156}; 189};
157 190
158static struct { 191static struct {
@@ -244,6 +277,38 @@ static struct {
244 {"Patsburg", 2}, 277 {"Patsburg", 2},
245 {"Patsburg", 2}, 278 {"Patsburg", 2},
246 {"DH89xxCC", 2}, 279 {"DH89xxCC", 2},
280 {"Panther Point", 2},
281 {"Panther Point", 2},
282 {"Panther Point", 2},
283 {"Panther Point", 2},
284 {"Panther Point", 2},
285 {"Panther Point", 2},
286 {"Panther Point", 2},
287 {"Panther Point", 2},
288 {"Panther Point", 2},
289 {"Panther Point", 2},
290 {"Panther Point", 2},
291 {"Panther Point", 2},
292 {"Panther Point", 2},
293 {"Panther Point", 2},
294 {"Panther Point", 2},
295 {"Panther Point", 2},
296 {"Panther Point", 2},
297 {"Panther Point", 2},
298 {"Panther Point", 2},
299 {"Panther Point", 2},
300 {"Panther Point", 2},
301 {"Panther Point", 2},
302 {"Panther Point", 2},
303 {"Panther Point", 2},
304 {"Panther Point", 2},
305 {"Panther Point", 2},
306 {"Panther Point", 2},
307 {"Panther Point", 2},
308 {"Panther Point", 2},
309 {"Panther Point", 2},
310 {"Panther Point", 2},
311 {"Panther Point", 2},
247 {NULL, 0} 312 {NULL, 0}
248}; 313};
249 314
@@ -363,6 +428,38 @@ static DEFINE_PCI_DEVICE_TABLE(iTCO_wdt_pci_tbl) = {
363 { ITCO_PCI_DEVICE(0x1d40, TCO_PBG1)}, 428 { ITCO_PCI_DEVICE(0x1d40, TCO_PBG1)},
364 { ITCO_PCI_DEVICE(0x1d41, TCO_PBG2)}, 429 { ITCO_PCI_DEVICE(0x1d41, TCO_PBG2)},
365 { ITCO_PCI_DEVICE(0x2310, TCO_DH89XXCC)}, 430 { ITCO_PCI_DEVICE(0x2310, TCO_DH89XXCC)},
431 { ITCO_PCI_DEVICE(0x1e40, TCO_PPT0)},
432 { ITCO_PCI_DEVICE(0x1e41, TCO_PPT1)},
433 { ITCO_PCI_DEVICE(0x1e42, TCO_PPT2)},
434 { ITCO_PCI_DEVICE(0x1e43, TCO_PPT3)},
435 { ITCO_PCI_DEVICE(0x1e44, TCO_PPT4)},
436 { ITCO_PCI_DEVICE(0x1e45, TCO_PPT5)},
437 { ITCO_PCI_DEVICE(0x1e46, TCO_PPT6)},
438 { ITCO_PCI_DEVICE(0x1e47, TCO_PPT7)},
439 { ITCO_PCI_DEVICE(0x1e48, TCO_PPT8)},
440 { ITCO_PCI_DEVICE(0x1e49, TCO_PPT9)},
441 { ITCO_PCI_DEVICE(0x1e4a, TCO_PPT10)},
442 { ITCO_PCI_DEVICE(0x1e4b, TCO_PPT11)},
443 { ITCO_PCI_DEVICE(0x1e4c, TCO_PPT12)},
444 { ITCO_PCI_DEVICE(0x1e4d, TCO_PPT13)},
445 { ITCO_PCI_DEVICE(0x1e4e, TCO_PPT14)},
446 { ITCO_PCI_DEVICE(0x1e4f, TCO_PPT15)},
447 { ITCO_PCI_DEVICE(0x1e50, TCO_PPT16)},
448 { ITCO_PCI_DEVICE(0x1e51, TCO_PPT17)},
449 { ITCO_PCI_DEVICE(0x1e52, TCO_PPT18)},
450 { ITCO_PCI_DEVICE(0x1e53, TCO_PPT19)},
451 { ITCO_PCI_DEVICE(0x1e54, TCO_PPT20)},
452 { ITCO_PCI_DEVICE(0x1e55, TCO_PPT21)},
453 { ITCO_PCI_DEVICE(0x1e56, TCO_PPT22)},
454 { ITCO_PCI_DEVICE(0x1e57, TCO_PPT23)},
455 { ITCO_PCI_DEVICE(0x1e58, TCO_PPT24)},
456 { ITCO_PCI_DEVICE(0x1e59, TCO_PPT25)},
457 { ITCO_PCI_DEVICE(0x1e5a, TCO_PPT26)},
458 { ITCO_PCI_DEVICE(0x1e5b, TCO_PPT27)},
459 { ITCO_PCI_DEVICE(0x1e5c, TCO_PPT28)},
460 { ITCO_PCI_DEVICE(0x1e5d, TCO_PPT29)},
461 { ITCO_PCI_DEVICE(0x1e5e, TCO_PPT30)},
462 { ITCO_PCI_DEVICE(0x1e5f, TCO_PPT31)},
366 { 0, }, /* End of list */ 463 { 0, }, /* End of list */
367}; 464};
368MODULE_DEVICE_TABLE(pci, iTCO_wdt_pci_tbl); 465MODULE_DEVICE_TABLE(pci, iTCO_wdt_pci_tbl);
diff --git a/drivers/watchdog/mpc8xxx_wdt.c b/drivers/watchdog/mpc8xxx_wdt.c
index 528bceb220fd..eed5436ffb51 100644
--- a/drivers/watchdog/mpc8xxx_wdt.c
+++ b/drivers/watchdog/mpc8xxx_wdt.c
@@ -185,17 +185,20 @@ static struct miscdevice mpc8xxx_wdt_miscdev = {
185 .fops = &mpc8xxx_wdt_fops, 185 .fops = &mpc8xxx_wdt_fops,
186}; 186};
187 187
188static const struct of_device_id mpc8xxx_wdt_match[];
188static int __devinit mpc8xxx_wdt_probe(struct platform_device *ofdev) 189static int __devinit mpc8xxx_wdt_probe(struct platform_device *ofdev)
189{ 190{
190 int ret; 191 int ret;
192 const struct of_device_id *match;
191 struct device_node *np = ofdev->dev.of_node; 193 struct device_node *np = ofdev->dev.of_node;
192 struct mpc8xxx_wdt_type *wdt_type; 194 struct mpc8xxx_wdt_type *wdt_type;
193 u32 freq = fsl_get_sys_freq(); 195 u32 freq = fsl_get_sys_freq();
194 bool enabled; 196 bool enabled;
195 197
196 if (!ofdev->dev.of_match) 198 match = of_match_device(mpc8xxx_wdt_match, &ofdev->dev);
199 if (!match)
197 return -EINVAL; 200 return -EINVAL;
198 wdt_type = ofdev->dev.of_match->data; 201 wdt_type = match->data;
199 202
200 if (!freq || freq == -1) 203 if (!freq || freq == -1)
201 return -EINVAL; 204 return -EINVAL;
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index 1ac94125bf93..a2eee574784e 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -8,6 +8,7 @@
8#include <linux/sysrq.h> 8#include <linux/sysrq.h>
9#include <linux/stop_machine.h> 9#include <linux/stop_machine.h>
10#include <linux/freezer.h> 10#include <linux/freezer.h>
11#include <linux/syscore_ops.h>
11 12
12#include <xen/xen.h> 13#include <xen/xen.h>
13#include <xen/xenbus.h> 14#include <xen/xenbus.h>
@@ -70,8 +71,13 @@ static int xen_suspend(void *data)
70 BUG_ON(!irqs_disabled()); 71 BUG_ON(!irqs_disabled());
71 72
72 err = sysdev_suspend(PMSG_FREEZE); 73 err = sysdev_suspend(PMSG_FREEZE);
74 if (!err) {
75 err = syscore_suspend();
76 if (err)
77 sysdev_resume();
78 }
73 if (err) { 79 if (err) {
74 printk(KERN_ERR "xen_suspend: sysdev_suspend failed: %d\n", 80 printk(KERN_ERR "xen_suspend: system core suspend failed: %d\n",
75 err); 81 err);
76 return err; 82 return err;
77 } 83 }
@@ -95,6 +101,7 @@ static int xen_suspend(void *data)
95 xen_timer_resume(); 101 xen_timer_resume();
96 } 102 }
97 103
104 syscore_resume();
98 sysdev_resume(); 105 sysdev_resume();
99 106
100 return 0; 107 return 0;