aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/apei/apei-base.c3
-rw-r--r--drivers/acpi/osl.c2
-rw-r--r--drivers/acpi/processor_idle.c4
-rw-r--r--drivers/acpi/processor_perflib.c7
-rw-r--r--drivers/base/regmap/regmap-debugfs.c2
-rw-r--r--drivers/base/regmap/regmap.c2
-rw-r--r--drivers/bluetooth/ath3k.c10
-rw-r--r--drivers/bluetooth/btusb.c5
-rw-r--r--drivers/clk/mvebu/clk-cpu.c9
-rw-r--r--drivers/cpufreq/Kconfig.x862
-rw-r--r--drivers/cpufreq/acpi-cpufreq.c7
-rw-r--r--drivers/cpufreq/cpufreq-cpu0.c5
-rw-r--r--drivers/cpufreq/omap-cpufreq.c3
-rw-r--r--drivers/devfreq/devfreq.c5
-rw-r--r--drivers/devfreq/exynos4_bus.c94
-rw-r--r--drivers/dma/imx-dma.c5
-rw-r--r--drivers/dma/ioat/dma_v3.c2
-rw-r--r--drivers/dma/tegra20-apb-dma.c8
-rw-r--r--drivers/edac/edac_mc.c6
-rw-r--r--drivers/edac/edac_pci_sysfs.c2
-rw-r--r--drivers/firmware/dmi_scan.c2
-rw-r--r--drivers/firmware/efivars.c9
-rw-r--r--drivers/firmware/iscsi_ibft_find.c2
-rw-r--r--drivers/gpu/drm/exynos/Kconfig4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_connector.c33
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_dmabuf.c24
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.h4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_g2d.c2
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_hdmi.c9
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_hdmi.h4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_ipp.c2
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_rotator.c4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_vidi.c26
-rw-r--r--drivers/gpu/drm/exynos/exynos_hdmi.c121
-rw-r--r--drivers/gpu/drm/exynos/exynos_mixer.c9
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c2
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h1
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c24
-rw-r--r--drivers/gpu/drm/radeon/ni.c8
-rw-r--r--drivers/gpu/drm/radeon/r600.c8
-rw-r--r--drivers/gpu/drm/radeon/radeon_cs.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_cursor.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_display.c2
-rw-r--r--drivers/i2c/busses/i2c-designware-core.c4
-rw-r--r--drivers/i2c/busses/i2c-mxs.c6
-rw-r--r--drivers/i2c/busses/i2c-omap.c6
-rw-r--r--drivers/i2c/busses/i2c-sirf.c4
-rw-r--r--drivers/i2c/muxes/i2c-mux-pinctrl.c2
-rw-r--r--drivers/idle/intel_idle.c3
-rw-r--r--drivers/iommu/amd_iommu_init.c34
-rw-r--r--drivers/iommu/intel-iommu.c21
-rw-r--r--drivers/isdn/gigaset/capi.c2
-rw-r--r--drivers/md/dm-raid.c101
-rw-r--r--drivers/media/platform/coda.c2
-rw-r--r--drivers/mfd/Kconfig1
-rw-r--r--drivers/mfd/ab8500-core.c1
-rw-r--r--drivers/mfd/arizona-core.c7
-rw-r--r--drivers/mfd/arizona-irq.c18
-rw-r--r--drivers/mfd/da9052-i2c.c61
-rw-r--r--drivers/mfd/db8500-prcmu.c13
-rw-r--r--drivers/mfd/max77686.c18
-rw-r--r--drivers/mfd/max77693.c34
-rw-r--r--drivers/mfd/pcf50633-core.c5
-rw-r--r--drivers/mfd/rtl8411.c29
-rw-r--r--drivers/mfd/rts5209.c21
-rw-r--r--drivers/mfd/rts5229.c21
-rw-r--r--drivers/mfd/rtsx_pcr.c27
-rw-r--r--drivers/mfd/tc3589x.c17
-rw-r--r--drivers/mfd/twl4030-power.c2
-rw-r--r--drivers/mfd/vexpress-config.c8
-rw-r--r--drivers/mfd/vexpress-sysreg.c32
-rw-r--r--drivers/mfd/wm5102-tables.c2
-rw-r--r--drivers/mmc/host/mvsdio.c92
-rw-r--r--drivers/mmc/host/rtsx_pci_sdmmc.c30
-rw-r--r--drivers/net/can/c_can/c_can.c4
-rw-r--r--drivers/net/can/pch_can.c2
-rw-r--r--drivers/net/can/ti_hecc.c4
-rw-r--r--drivers/net/ethernet/3com/3c574_cs.c2
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c62
-rw-r--r--drivers/net/ethernet/calxeda/xgmac.c4
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c17
-rw-r--r--drivers/net/ethernet/intel/ixgbe/Makefile3
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c5
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_tx.c13
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c11
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c2
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c2
-rw-r--r--drivers/net/ethernet/realtek/r8169.c21
-rw-r--r--drivers/net/hyperv/hyperv_net.h2
-rw-r--r--drivers/net/hyperv/netvsc_drv.c2
-rw-r--r--drivers/net/loopback.c5
-rw-r--r--drivers/net/macvlan.c5
-rw-r--r--drivers/net/phy/icplus.c29
-rw-r--r--drivers/net/phy/marvell.c9
-rw-r--r--drivers/net/tun.c45
-rw-r--r--drivers/net/usb/cdc_mbim.c19
-rw-r--r--drivers/net/usb/cdc_ncm.c31
-rw-r--r--drivers/net/usb/dm9601.c52
-rw-r--r--drivers/net/usb/qmi_wwan.c2
-rw-r--r--drivers/net/usb/usbnet.c4
-rw-r--r--drivers/net/virtio_net.c118
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_calib.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_phy.c27
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h3
-rw-r--r--drivers/net/wireless/ath/ath9k/beacon.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.c1
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.h2
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_hst.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c22
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c54
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c7
-rw-r--r--drivers/net/wireless/iwlegacy/common.c35
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/tx.c2
-rw-r--r--drivers/net/wireless/mwifiex/cfg80211.c17
-rw-r--r--drivers/net/wireless/mwifiex/pcie.c2
-rw-r--r--drivers/net/wireless/mwifiex/sta_ioctl.c14
-rw-r--r--drivers/net/wireless/rtlwifi/Kconfig4
-rw-r--r--drivers/pinctrl/Kconfig1
-rw-r--r--drivers/pinctrl/mvebu/pinctrl-dove.c2
-rw-r--r--drivers/pinctrl/mvebu/pinctrl-kirkwood.c8
-rw-r--r--drivers/pinctrl/pinctrl-exynos5440.c10
-rw-r--r--drivers/pinctrl/pinctrl-mxs.c9
-rw-r--r--drivers/pinctrl/pinctrl-nomadik.c2
-rw-r--r--drivers/pinctrl/pinctrl-single.c79
-rw-r--r--drivers/platform/x86/ibm_rtl.c2
-rw-r--r--drivers/platform/x86/samsung-laptop.c4
-rw-r--r--drivers/regulator/dbx500-prcmu.c1
-rw-r--r--drivers/regulator/tps80031-regulator.c2
-rw-r--r--drivers/scsi/isci/init.c2
-rw-r--r--drivers/video/imxfb.c13
133 files changed, 1115 insertions, 811 deletions
diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c
index 00a783661d0b..46f80e2c92f7 100644
--- a/drivers/acpi/apei/apei-base.c
+++ b/drivers/acpi/apei/apei-base.c
@@ -590,6 +590,9 @@ static int apei_check_gar(struct acpi_generic_address *reg, u64 *paddr,
590 if (bit_width == 32 && bit_offset == 0 && (*paddr & 0x03) == 0 && 590 if (bit_width == 32 && bit_offset == 0 && (*paddr & 0x03) == 0 &&
591 *access_bit_width < 32) 591 *access_bit_width < 32)
592 *access_bit_width = 32; 592 *access_bit_width = 32;
593 else if (bit_width == 64 && bit_offset == 0 && (*paddr & 0x07) == 0 &&
594 *access_bit_width < 64)
595 *access_bit_width = 64;
593 596
594 if ((bit_width + bit_offset) > *access_bit_width) { 597 if ((bit_width + bit_offset) > *access_bit_width) {
595 pr_warning(FW_BUG APEI_PFX 598 pr_warning(FW_BUG APEI_PFX
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 3ff267861541..bd22f8667eed 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -250,7 +250,7 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
250 return acpi_rsdp; 250 return acpi_rsdp;
251#endif 251#endif
252 252
253 if (efi_enabled) { 253 if (efi_enabled(EFI_CONFIG_TABLES)) {
254 if (efi.acpi20 != EFI_INVALID_TABLE_ADDR) 254 if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
255 return efi.acpi20; 255 return efi.acpi20;
256 else if (efi.acpi != EFI_INVALID_TABLE_ADDR) 256 else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index f1a5da44591d..ed9a1cc690be 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -958,6 +958,9 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr)
958 return -EINVAL; 958 return -EINVAL;
959 } 959 }
960 960
961 if (!dev)
962 return -EINVAL;
963
961 dev->cpu = pr->id; 964 dev->cpu = pr->id;
962 965
963 if (max_cstate == 0) 966 if (max_cstate == 0)
@@ -1149,6 +1152,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
1149 } 1152 }
1150 1153
1151 /* Populate Updated C-state information */ 1154 /* Populate Updated C-state information */
1155 acpi_processor_get_power_info(pr);
1152 acpi_processor_setup_cpuidle_states(pr); 1156 acpi_processor_setup_cpuidle_states(pr);
1153 1157
1154 /* Enable all cpuidle devices */ 1158 /* Enable all cpuidle devices */
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 836bfe069042..53e7ac9403a7 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -340,6 +340,13 @@ static void amd_fixup_frequency(struct acpi_processor_px *px, int i)
340 if ((boot_cpu_data.x86 == 0x10 && boot_cpu_data.x86_model < 10) 340 if ((boot_cpu_data.x86 == 0x10 && boot_cpu_data.x86_model < 10)
341 || boot_cpu_data.x86 == 0x11) { 341 || boot_cpu_data.x86 == 0x11) {
342 rdmsr(MSR_AMD_PSTATE_DEF_BASE + index, lo, hi); 342 rdmsr(MSR_AMD_PSTATE_DEF_BASE + index, lo, hi);
343 /*
344 * MSR C001_0064+:
345 * Bit 63: PstateEn. Read-write. If set, the P-state is valid.
346 */
347 if (!(hi & BIT(31)))
348 return;
349
343 fid = lo & 0x3f; 350 fid = lo & 0x3f;
344 did = (lo >> 6) & 7; 351 did = (lo >> 6) & 7;
345 if (boot_cpu_data.x86 == 0x10) 352 if (boot_cpu_data.x86 == 0x10)
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index 46a213a596e2..d9a6c94ce423 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -121,8 +121,6 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map,
121 c->max = p - 1; 121 c->max = p - 1;
122 list_add_tail(&c->list, 122 list_add_tail(&c->list,
123 &map->debugfs_off_cache); 123 &map->debugfs_off_cache);
124 } else {
125 return base;
126 } 124 }
127 125
128 /* 126 /*
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 42d5cb0f503f..f00b059c057a 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1106,7 +1106,7 @@ EXPORT_SYMBOL_GPL(regmap_raw_write);
1106 * @val_count: Number of registers to write 1106 * @val_count: Number of registers to write
1107 * 1107 *
1108 * This function is intended to be used for writing a large block of 1108 * This function is intended to be used for writing a large block of
1109 * data to be device either in single transfer or multiple transfer. 1109 * data to the device either in single transfer or multiple transfer.
1110 * 1110 *
1111 * A value of zero will be returned on success, a negative errno will 1111 * A value of zero will be returned on success, a negative errno will
1112 * be returned in error cases. 1112 * be returned in error cases.
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index b00000e8aef6..33c9a44a9678 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -77,10 +77,15 @@ static struct usb_device_id ath3k_table[] = {
77 { USB_DEVICE(0x0CF3, 0x311D) }, 77 { USB_DEVICE(0x0CF3, 0x311D) },
78 { USB_DEVICE(0x13d3, 0x3375) }, 78 { USB_DEVICE(0x13d3, 0x3375) },
79 { USB_DEVICE(0x04CA, 0x3005) }, 79 { USB_DEVICE(0x04CA, 0x3005) },
80 { USB_DEVICE(0x04CA, 0x3006) },
81 { USB_DEVICE(0x04CA, 0x3008) },
80 { USB_DEVICE(0x13d3, 0x3362) }, 82 { USB_DEVICE(0x13d3, 0x3362) },
81 { USB_DEVICE(0x0CF3, 0xE004) }, 83 { USB_DEVICE(0x0CF3, 0xE004) },
82 { USB_DEVICE(0x0930, 0x0219) }, 84 { USB_DEVICE(0x0930, 0x0219) },
83 { USB_DEVICE(0x0489, 0xe057) }, 85 { USB_DEVICE(0x0489, 0xe057) },
86 { USB_DEVICE(0x13d3, 0x3393) },
87 { USB_DEVICE(0x0489, 0xe04e) },
88 { USB_DEVICE(0x0489, 0xe056) },
84 89
85 /* Atheros AR5BBU12 with sflash firmware */ 90 /* Atheros AR5BBU12 with sflash firmware */
86 { USB_DEVICE(0x0489, 0xE02C) }, 91 { USB_DEVICE(0x0489, 0xE02C) },
@@ -104,10 +109,15 @@ static struct usb_device_id ath3k_blist_tbl[] = {
104 { USB_DEVICE(0x0cf3, 0x311D), .driver_info = BTUSB_ATH3012 }, 109 { USB_DEVICE(0x0cf3, 0x311D), .driver_info = BTUSB_ATH3012 },
105 { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 }, 110 { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
106 { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 }, 111 { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
112 { USB_DEVICE(0x04ca, 0x3006), .driver_info = BTUSB_ATH3012 },
113 { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
107 { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 }, 114 { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
108 { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 }, 115 { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
109 { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 }, 116 { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
110 { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 }, 117 { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 },
118 { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 },
119 { USB_DEVICE(0x0489, 0xe04e), .driver_info = BTUSB_ATH3012 },
120 { USB_DEVICE(0x0489, 0xe056), .driver_info = BTUSB_ATH3012 },
111 121
112 /* Atheros AR5BBU22 with sflash firmware */ 122 /* Atheros AR5BBU22 with sflash firmware */
113 { USB_DEVICE(0x0489, 0xE03C), .driver_info = BTUSB_ATH3012 }, 123 { USB_DEVICE(0x0489, 0xE03C), .driver_info = BTUSB_ATH3012 },
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index a1d4ede5b892..7e351e345476 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -135,10 +135,15 @@ static struct usb_device_id blacklist_table[] = {
135 { USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 }, 135 { USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 },
136 { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 }, 136 { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
137 { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 }, 137 { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
138 { USB_DEVICE(0x04ca, 0x3006), .driver_info = BTUSB_ATH3012 },
139 { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
138 { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 }, 140 { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
139 { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 }, 141 { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
140 { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 }, 142 { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
141 { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 }, 143 { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 },
144 { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 },
145 { USB_DEVICE(0x0489, 0xe04e), .driver_info = BTUSB_ATH3012 },
146 { USB_DEVICE(0x0489, 0xe056), .driver_info = BTUSB_ATH3012 },
142 147
143 /* Atheros AR5BBU12 with sflash firmware */ 148 /* Atheros AR5BBU12 with sflash firmware */
144 { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE }, 149 { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE },
diff --git a/drivers/clk/mvebu/clk-cpu.c b/drivers/clk/mvebu/clk-cpu.c
index ff004578a119..9dd2551a0a41 100644
--- a/drivers/clk/mvebu/clk-cpu.c
+++ b/drivers/clk/mvebu/clk-cpu.c
@@ -124,7 +124,7 @@ void __init of_cpu_clk_setup(struct device_node *node)
124 124
125 clks = kzalloc(ncpus * sizeof(*clks), GFP_KERNEL); 125 clks = kzalloc(ncpus * sizeof(*clks), GFP_KERNEL);
126 if (WARN_ON(!clks)) 126 if (WARN_ON(!clks))
127 return; 127 goto clks_out;
128 128
129 for_each_node_by_type(dn, "cpu") { 129 for_each_node_by_type(dn, "cpu") {
130 struct clk_init_data init; 130 struct clk_init_data init;
@@ -134,11 +134,11 @@ void __init of_cpu_clk_setup(struct device_node *node)
134 int cpu, err; 134 int cpu, err;
135 135
136 if (WARN_ON(!clk_name)) 136 if (WARN_ON(!clk_name))
137 return; 137 goto bail_out;
138 138
139 err = of_property_read_u32(dn, "reg", &cpu); 139 err = of_property_read_u32(dn, "reg", &cpu);
140 if (WARN_ON(err)) 140 if (WARN_ON(err))
141 return; 141 goto bail_out;
142 142
143 sprintf(clk_name, "cpu%d", cpu); 143 sprintf(clk_name, "cpu%d", cpu);
144 parent_clk = of_clk_get(node, 0); 144 parent_clk = of_clk_get(node, 0);
@@ -167,6 +167,9 @@ void __init of_cpu_clk_setup(struct device_node *node)
167 return; 167 return;
168bail_out: 168bail_out:
169 kfree(clks); 169 kfree(clks);
170 while(ncpus--)
171 kfree(cpuclk[ncpus].clk_name);
172clks_out:
170 kfree(cpuclk); 173 kfree(cpuclk);
171} 174}
172 175
diff --git a/drivers/cpufreq/Kconfig.x86 b/drivers/cpufreq/Kconfig.x86
index 934854ae5eb4..7227cd734042 100644
--- a/drivers/cpufreq/Kconfig.x86
+++ b/drivers/cpufreq/Kconfig.x86
@@ -106,7 +106,7 @@ config X86_POWERNOW_K7_ACPI
106config X86_POWERNOW_K8 106config X86_POWERNOW_K8
107 tristate "AMD Opteron/Athlon64 PowerNow!" 107 tristate "AMD Opteron/Athlon64 PowerNow!"
108 select CPU_FREQ_TABLE 108 select CPU_FREQ_TABLE
109 depends on ACPI && ACPI_PROCESSOR 109 depends on ACPI && ACPI_PROCESSOR && X86_ACPI_CPUFREQ
110 help 110 help
111 This adds the CPUFreq driver for K8/early Opteron/Athlon64 processors. 111 This adds the CPUFreq driver for K8/early Opteron/Athlon64 processors.
112 Support for K10 and newer processors is now in acpi-cpufreq. 112 Support for K10 and newer processors is now in acpi-cpufreq.
diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 0d048f6a2b23..7b0d49d78c61 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -1030,4 +1030,11 @@ MODULE_PARM_DESC(acpi_pstate_strict,
1030late_initcall(acpi_cpufreq_init); 1030late_initcall(acpi_cpufreq_init);
1031module_exit(acpi_cpufreq_exit); 1031module_exit(acpi_cpufreq_exit);
1032 1032
1033static const struct x86_cpu_id acpi_cpufreq_ids[] = {
1034 X86_FEATURE_MATCH(X86_FEATURE_ACPI),
1035 X86_FEATURE_MATCH(X86_FEATURE_HW_PSTATE),
1036 {}
1037};
1038MODULE_DEVICE_TABLE(x86cpu, acpi_cpufreq_ids);
1039
1033MODULE_ALIAS("acpi"); 1040MODULE_ALIAS("acpi");
diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index 52bf36d599f5..debc5a7c8db6 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -71,12 +71,15 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
71 } 71 }
72 72
73 if (cpu_reg) { 73 if (cpu_reg) {
74 rcu_read_lock();
74 opp = opp_find_freq_ceil(cpu_dev, &freq_Hz); 75 opp = opp_find_freq_ceil(cpu_dev, &freq_Hz);
75 if (IS_ERR(opp)) { 76 if (IS_ERR(opp)) {
77 rcu_read_unlock();
76 pr_err("failed to find OPP for %ld\n", freq_Hz); 78 pr_err("failed to find OPP for %ld\n", freq_Hz);
77 return PTR_ERR(opp); 79 return PTR_ERR(opp);
78 } 80 }
79 volt = opp_get_voltage(opp); 81 volt = opp_get_voltage(opp);
82 rcu_read_unlock();
80 tol = volt * voltage_tolerance / 100; 83 tol = volt * voltage_tolerance / 100;
81 volt_old = regulator_get_voltage(cpu_reg); 84 volt_old = regulator_get_voltage(cpu_reg);
82 } 85 }
@@ -236,12 +239,14 @@ static int cpu0_cpufreq_driver_init(void)
236 */ 239 */
237 for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) 240 for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++)
238 ; 241 ;
242 rcu_read_lock();
239 opp = opp_find_freq_exact(cpu_dev, 243 opp = opp_find_freq_exact(cpu_dev,
240 freq_table[0].frequency * 1000, true); 244 freq_table[0].frequency * 1000, true);
241 min_uV = opp_get_voltage(opp); 245 min_uV = opp_get_voltage(opp);
242 opp = opp_find_freq_exact(cpu_dev, 246 opp = opp_find_freq_exact(cpu_dev,
243 freq_table[i-1].frequency * 1000, true); 247 freq_table[i-1].frequency * 1000, true);
244 max_uV = opp_get_voltage(opp); 248 max_uV = opp_get_voltage(opp);
249 rcu_read_unlock();
245 ret = regulator_set_voltage_time(cpu_reg, min_uV, max_uV); 250 ret = regulator_set_voltage_time(cpu_reg, min_uV, max_uV);
246 if (ret > 0) 251 if (ret > 0)
247 transition_latency += ret * 1000; 252 transition_latency += ret * 1000;
diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c
index 1f3417a8322d..97102b05843f 100644
--- a/drivers/cpufreq/omap-cpufreq.c
+++ b/drivers/cpufreq/omap-cpufreq.c
@@ -110,13 +110,16 @@ static int omap_target(struct cpufreq_policy *policy,
110 freq = ret; 110 freq = ret;
111 111
112 if (mpu_reg) { 112 if (mpu_reg) {
113 rcu_read_lock();
113 opp = opp_find_freq_ceil(mpu_dev, &freq); 114 opp = opp_find_freq_ceil(mpu_dev, &freq);
114 if (IS_ERR(opp)) { 115 if (IS_ERR(opp)) {
116 rcu_read_unlock();
115 dev_err(mpu_dev, "%s: unable to find MPU OPP for %d\n", 117 dev_err(mpu_dev, "%s: unable to find MPU OPP for %d\n",
116 __func__, freqs.new); 118 __func__, freqs.new);
117 return -EINVAL; 119 return -EINVAL;
118 } 120 }
119 volt = opp_get_voltage(opp); 121 volt = opp_get_voltage(opp);
122 rcu_read_unlock();
120 tol = volt * OPP_TOLERANCE / 100; 123 tol = volt * OPP_TOLERANCE / 100;
121 volt_old = regulator_get_voltage(mpu_reg); 124 volt_old = regulator_get_voltage(mpu_reg);
122 } 125 }
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 53766f39aadd..3b367973a802 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -994,6 +994,11 @@ module_exit(devfreq_exit);
994 * @freq: The frequency given to target function 994 * @freq: The frequency given to target function
995 * @flags: Flags handed from devfreq framework. 995 * @flags: Flags handed from devfreq framework.
996 * 996 *
997 * Locking: This function must be called under rcu_read_lock(). opp is a rcu
998 * protected pointer. The reason for the same is that the opp pointer which is
999 * returned will remain valid for use with opp_get_{voltage, freq} only while
1000 * under the locked area. The pointer returned must be used prior to unlocking
1001 * with rcu_read_unlock() to maintain the integrity of the pointer.
997 */ 1002 */
998struct opp *devfreq_recommended_opp(struct device *dev, unsigned long *freq, 1003struct opp *devfreq_recommended_opp(struct device *dev, unsigned long *freq,
999 u32 flags) 1004 u32 flags)
diff --git a/drivers/devfreq/exynos4_bus.c b/drivers/devfreq/exynos4_bus.c
index 80c745e83082..46d94e9e95b5 100644
--- a/drivers/devfreq/exynos4_bus.c
+++ b/drivers/devfreq/exynos4_bus.c
@@ -73,6 +73,16 @@ enum busclk_level_idx {
73#define EX4210_LV_NUM (LV_2 + 1) 73#define EX4210_LV_NUM (LV_2 + 1)
74#define EX4x12_LV_NUM (LV_4 + 1) 74#define EX4x12_LV_NUM (LV_4 + 1)
75 75
76/**
77 * struct busfreq_opp_info - opp information for bus
78 * @rate: Frequency in hertz
79 * @volt: Voltage in microvolts corresponding to this OPP
80 */
81struct busfreq_opp_info {
82 unsigned long rate;
83 unsigned long volt;
84};
85
76struct busfreq_data { 86struct busfreq_data {
77 enum exynos4_busf_type type; 87 enum exynos4_busf_type type;
78 struct device *dev; 88 struct device *dev;
@@ -80,7 +90,7 @@ struct busfreq_data {
80 bool disabled; 90 bool disabled;
81 struct regulator *vdd_int; 91 struct regulator *vdd_int;
82 struct regulator *vdd_mif; /* Exynos4412/4212 only */ 92 struct regulator *vdd_mif; /* Exynos4412/4212 only */
83 struct opp *curr_opp; 93 struct busfreq_opp_info curr_oppinfo;
84 struct exynos4_ppmu dmc[2]; 94 struct exynos4_ppmu dmc[2];
85 95
86 struct notifier_block pm_notifier; 96 struct notifier_block pm_notifier;
@@ -296,13 +306,14 @@ static unsigned int exynos4x12_clkdiv_sclkip[][3] = {
296}; 306};
297 307
298 308
299static int exynos4210_set_busclk(struct busfreq_data *data, struct opp *opp) 309static int exynos4210_set_busclk(struct busfreq_data *data,
310 struct busfreq_opp_info *oppi)
300{ 311{
301 unsigned int index; 312 unsigned int index;
302 unsigned int tmp; 313 unsigned int tmp;
303 314
304 for (index = LV_0; index < EX4210_LV_NUM; index++) 315 for (index = LV_0; index < EX4210_LV_NUM; index++)
305 if (opp_get_freq(opp) == exynos4210_busclk_table[index].clk) 316 if (oppi->rate == exynos4210_busclk_table[index].clk)
306 break; 317 break;
307 318
308 if (index == EX4210_LV_NUM) 319 if (index == EX4210_LV_NUM)
@@ -361,13 +372,14 @@ static int exynos4210_set_busclk(struct busfreq_data *data, struct opp *opp)
361 return 0; 372 return 0;
362} 373}
363 374
364static int exynos4x12_set_busclk(struct busfreq_data *data, struct opp *opp) 375static int exynos4x12_set_busclk(struct busfreq_data *data,
376 struct busfreq_opp_info *oppi)
365{ 377{
366 unsigned int index; 378 unsigned int index;
367 unsigned int tmp; 379 unsigned int tmp;
368 380
369 for (index = LV_0; index < EX4x12_LV_NUM; index++) 381 for (index = LV_0; index < EX4x12_LV_NUM; index++)
370 if (opp_get_freq(opp) == exynos4x12_mifclk_table[index].clk) 382 if (oppi->rate == exynos4x12_mifclk_table[index].clk)
371 break; 383 break;
372 384
373 if (index == EX4x12_LV_NUM) 385 if (index == EX4x12_LV_NUM)
@@ -576,11 +588,12 @@ static int exynos4x12_get_intspec(unsigned long mifclk)
576 return -EINVAL; 588 return -EINVAL;
577} 589}
578 590
579static int exynos4_bus_setvolt(struct busfreq_data *data, struct opp *opp, 591static int exynos4_bus_setvolt(struct busfreq_data *data,
580 struct opp *oldopp) 592 struct busfreq_opp_info *oppi,
593 struct busfreq_opp_info *oldoppi)
581{ 594{
582 int err = 0, tmp; 595 int err = 0, tmp;
583 unsigned long volt = opp_get_voltage(opp); 596 unsigned long volt = oppi->volt;
584 597
585 switch (data->type) { 598 switch (data->type) {
586 case TYPE_BUSF_EXYNOS4210: 599 case TYPE_BUSF_EXYNOS4210:
@@ -595,11 +608,11 @@ static int exynos4_bus_setvolt(struct busfreq_data *data, struct opp *opp,
595 if (err) 608 if (err)
596 break; 609 break;
597 610
598 tmp = exynos4x12_get_intspec(opp_get_freq(opp)); 611 tmp = exynos4x12_get_intspec(oppi->rate);
599 if (tmp < 0) { 612 if (tmp < 0) {
600 err = tmp; 613 err = tmp;
601 regulator_set_voltage(data->vdd_mif, 614 regulator_set_voltage(data->vdd_mif,
602 opp_get_voltage(oldopp), 615 oldoppi->volt,
603 MAX_SAFEVOLT); 616 MAX_SAFEVOLT);
604 break; 617 break;
605 } 618 }
@@ -609,7 +622,7 @@ static int exynos4_bus_setvolt(struct busfreq_data *data, struct opp *opp,
609 /* Try to recover */ 622 /* Try to recover */
610 if (err) 623 if (err)
611 regulator_set_voltage(data->vdd_mif, 624 regulator_set_voltage(data->vdd_mif,
612 opp_get_voltage(oldopp), 625 oldoppi->volt,
613 MAX_SAFEVOLT); 626 MAX_SAFEVOLT);
614 break; 627 break;
615 default: 628 default:
@@ -626,17 +639,26 @@ static int exynos4_bus_target(struct device *dev, unsigned long *_freq,
626 struct platform_device *pdev = container_of(dev, struct platform_device, 639 struct platform_device *pdev = container_of(dev, struct platform_device,
627 dev); 640 dev);
628 struct busfreq_data *data = platform_get_drvdata(pdev); 641 struct busfreq_data *data = platform_get_drvdata(pdev);
629 struct opp *opp = devfreq_recommended_opp(dev, _freq, flags); 642 struct opp *opp;
630 unsigned long freq = opp_get_freq(opp); 643 unsigned long freq;
631 unsigned long old_freq = opp_get_freq(data->curr_opp); 644 unsigned long old_freq = data->curr_oppinfo.rate;
645 struct busfreq_opp_info new_oppinfo;
632 646
633 if (IS_ERR(opp)) 647 rcu_read_lock();
648 opp = devfreq_recommended_opp(dev, _freq, flags);
649 if (IS_ERR(opp)) {
650 rcu_read_unlock();
634 return PTR_ERR(opp); 651 return PTR_ERR(opp);
652 }
653 new_oppinfo.rate = opp_get_freq(opp);
654 new_oppinfo.volt = opp_get_voltage(opp);
655 rcu_read_unlock();
656 freq = new_oppinfo.rate;
635 657
636 if (old_freq == freq) 658 if (old_freq == freq)
637 return 0; 659 return 0;
638 660
639 dev_dbg(dev, "targetting %lukHz %luuV\n", freq, opp_get_voltage(opp)); 661 dev_dbg(dev, "targetting %lukHz %luuV\n", freq, new_oppinfo.volt);
640 662
641 mutex_lock(&data->lock); 663 mutex_lock(&data->lock);
642 664
@@ -644,17 +666,18 @@ static int exynos4_bus_target(struct device *dev, unsigned long *_freq,
644 goto out; 666 goto out;
645 667
646 if (old_freq < freq) 668 if (old_freq < freq)
647 err = exynos4_bus_setvolt(data, opp, data->curr_opp); 669 err = exynos4_bus_setvolt(data, &new_oppinfo,
670 &data->curr_oppinfo);
648 if (err) 671 if (err)
649 goto out; 672 goto out;
650 673
651 if (old_freq != freq) { 674 if (old_freq != freq) {
652 switch (data->type) { 675 switch (data->type) {
653 case TYPE_BUSF_EXYNOS4210: 676 case TYPE_BUSF_EXYNOS4210:
654 err = exynos4210_set_busclk(data, opp); 677 err = exynos4210_set_busclk(data, &new_oppinfo);
655 break; 678 break;
656 case TYPE_BUSF_EXYNOS4x12: 679 case TYPE_BUSF_EXYNOS4x12:
657 err = exynos4x12_set_busclk(data, opp); 680 err = exynos4x12_set_busclk(data, &new_oppinfo);
658 break; 681 break;
659 default: 682 default:
660 err = -EINVAL; 683 err = -EINVAL;
@@ -664,11 +687,12 @@ static int exynos4_bus_target(struct device *dev, unsigned long *_freq,
664 goto out; 687 goto out;
665 688
666 if (old_freq > freq) 689 if (old_freq > freq)
667 err = exynos4_bus_setvolt(data, opp, data->curr_opp); 690 err = exynos4_bus_setvolt(data, &new_oppinfo,
691 &data->curr_oppinfo);
668 if (err) 692 if (err)
669 goto out; 693 goto out;
670 694
671 data->curr_opp = opp; 695 data->curr_oppinfo = new_oppinfo;
672out: 696out:
673 mutex_unlock(&data->lock); 697 mutex_unlock(&data->lock);
674 return err; 698 return err;
@@ -702,7 +726,7 @@ static int exynos4_bus_get_dev_status(struct device *dev,
702 726
703 exynos4_read_ppmu(data); 727 exynos4_read_ppmu(data);
704 busier_dmc = exynos4_get_busier_dmc(data); 728 busier_dmc = exynos4_get_busier_dmc(data);
705 stat->current_frequency = opp_get_freq(data->curr_opp); 729 stat->current_frequency = data->curr_oppinfo.rate;
706 730
707 if (busier_dmc) 731 if (busier_dmc)
708 addr = S5P_VA_DMC1; 732 addr = S5P_VA_DMC1;
@@ -933,6 +957,7 @@ static int exynos4_busfreq_pm_notifier_event(struct notifier_block *this,
933 struct busfreq_data *data = container_of(this, struct busfreq_data, 957 struct busfreq_data *data = container_of(this, struct busfreq_data,
934 pm_notifier); 958 pm_notifier);
935 struct opp *opp; 959 struct opp *opp;
960 struct busfreq_opp_info new_oppinfo;
936 unsigned long maxfreq = ULONG_MAX; 961 unsigned long maxfreq = ULONG_MAX;
937 int err = 0; 962 int err = 0;
938 963
@@ -943,18 +968,29 @@ static int exynos4_busfreq_pm_notifier_event(struct notifier_block *this,
943 968
944 data->disabled = true; 969 data->disabled = true;
945 970
971 rcu_read_lock();
946 opp = opp_find_freq_floor(data->dev, &maxfreq); 972 opp = opp_find_freq_floor(data->dev, &maxfreq);
973 if (IS_ERR(opp)) {
974 rcu_read_unlock();
975 dev_err(data->dev, "%s: unable to find a min freq\n",
976 __func__);
977 return PTR_ERR(opp);
978 }
979 new_oppinfo.rate = opp_get_freq(opp);
980 new_oppinfo.volt = opp_get_voltage(opp);
981 rcu_read_unlock();
947 982
948 err = exynos4_bus_setvolt(data, opp, data->curr_opp); 983 err = exynos4_bus_setvolt(data, &new_oppinfo,
984 &data->curr_oppinfo);
949 if (err) 985 if (err)
950 goto unlock; 986 goto unlock;
951 987
952 switch (data->type) { 988 switch (data->type) {
953 case TYPE_BUSF_EXYNOS4210: 989 case TYPE_BUSF_EXYNOS4210:
954 err = exynos4210_set_busclk(data, opp); 990 err = exynos4210_set_busclk(data, &new_oppinfo);
955 break; 991 break;
956 case TYPE_BUSF_EXYNOS4x12: 992 case TYPE_BUSF_EXYNOS4x12:
957 err = exynos4x12_set_busclk(data, opp); 993 err = exynos4x12_set_busclk(data, &new_oppinfo);
958 break; 994 break;
959 default: 995 default:
960 err = -EINVAL; 996 err = -EINVAL;
@@ -962,7 +998,7 @@ static int exynos4_busfreq_pm_notifier_event(struct notifier_block *this,
962 if (err) 998 if (err)
963 goto unlock; 999 goto unlock;
964 1000
965 data->curr_opp = opp; 1001 data->curr_oppinfo = new_oppinfo;
966unlock: 1002unlock:
967 mutex_unlock(&data->lock); 1003 mutex_unlock(&data->lock);
968 if (err) 1004 if (err)
@@ -1027,13 +1063,17 @@ static int exynos4_busfreq_probe(struct platform_device *pdev)
1027 } 1063 }
1028 } 1064 }
1029 1065
1066 rcu_read_lock();
1030 opp = opp_find_freq_floor(dev, &exynos4_devfreq_profile.initial_freq); 1067 opp = opp_find_freq_floor(dev, &exynos4_devfreq_profile.initial_freq);
1031 if (IS_ERR(opp)) { 1068 if (IS_ERR(opp)) {
1069 rcu_read_unlock();
1032 dev_err(dev, "Invalid initial frequency %lu kHz.\n", 1070 dev_err(dev, "Invalid initial frequency %lu kHz.\n",
1033 exynos4_devfreq_profile.initial_freq); 1071 exynos4_devfreq_profile.initial_freq);
1034 return PTR_ERR(opp); 1072 return PTR_ERR(opp);
1035 } 1073 }
1036 data->curr_opp = opp; 1074 data->curr_oppinfo.rate = opp_get_freq(opp);
1075 data->curr_oppinfo.volt = opp_get_voltage(opp);
1076 rcu_read_unlock();
1037 1077
1038 platform_set_drvdata(pdev, data); 1078 platform_set_drvdata(pdev, data);
1039 1079
diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c
index dbf0e6f8de8a..a7dcf78b1ff8 100644
--- a/drivers/dma/imx-dma.c
+++ b/drivers/dma/imx-dma.c
@@ -684,9 +684,8 @@ static int imxdma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
684 break; 684 break;
685 } 685 }
686 686
687 imxdmac->hw_chaining = 1; 687 imxdmac->hw_chaining = 0;
688 if (!imxdma_hw_chain(imxdmac)) 688
689 return -EINVAL;
690 imxdmac->ccr_from_device = (mode | IMX_DMA_TYPE_FIFO) | 689 imxdmac->ccr_from_device = (mode | IMX_DMA_TYPE_FIFO) |
691 ((IMX_DMA_MEMSIZE_32 | IMX_DMA_TYPE_LINEAR) << 2) | 690 ((IMX_DMA_MEMSIZE_32 | IMX_DMA_TYPE_LINEAR) << 2) |
692 CCR_REN; 691 CCR_REN;
diff --git a/drivers/dma/ioat/dma_v3.c b/drivers/dma/ioat/dma_v3.c
index e5fc944de1f0..3e9d66920eb3 100644
--- a/drivers/dma/ioat/dma_v3.c
+++ b/drivers/dma/ioat/dma_v3.c
@@ -951,7 +951,7 @@ static int ioat_xor_val_self_test(struct ioatdma_device *device)
951 goto free_resources; 951 goto free_resources;
952 } 952 }
953 } 953 }
954 dma_sync_single_for_device(dev, dest_dma, PAGE_SIZE, DMA_TO_DEVICE); 954 dma_sync_single_for_device(dev, dest_dma, PAGE_SIZE, DMA_FROM_DEVICE);
955 955
956 /* skip validate if the capability is not present */ 956 /* skip validate if the capability is not present */
957 if (!dma_has_cap(DMA_XOR_VAL, dma_chan->device->cap_mask)) 957 if (!dma_has_cap(DMA_XOR_VAL, dma_chan->device->cap_mask))
diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
index c39e61bc8172..3cad856fe67f 100644
--- a/drivers/dma/tegra20-apb-dma.c
+++ b/drivers/dma/tegra20-apb-dma.c
@@ -266,6 +266,7 @@ static struct tegra_dma_desc *tegra_dma_desc_get(
266 if (async_tx_test_ack(&dma_desc->txd)) { 266 if (async_tx_test_ack(&dma_desc->txd)) {
267 list_del(&dma_desc->node); 267 list_del(&dma_desc->node);
268 spin_unlock_irqrestore(&tdc->lock, flags); 268 spin_unlock_irqrestore(&tdc->lock, flags);
269 dma_desc->txd.flags = 0;
269 return dma_desc; 270 return dma_desc;
270 } 271 }
271 } 272 }
@@ -1050,7 +1051,9 @@ struct dma_async_tx_descriptor *tegra_dma_prep_dma_cyclic(
1050 TEGRA_APBDMA_AHBSEQ_WRAP_SHIFT; 1051 TEGRA_APBDMA_AHBSEQ_WRAP_SHIFT;
1051 ahb_seq |= TEGRA_APBDMA_AHBSEQ_BUS_WIDTH_32; 1052 ahb_seq |= TEGRA_APBDMA_AHBSEQ_BUS_WIDTH_32;
1052 1053
1053 csr |= TEGRA_APBDMA_CSR_FLOW | TEGRA_APBDMA_CSR_IE_EOC; 1054 csr |= TEGRA_APBDMA_CSR_FLOW;
1055 if (flags & DMA_PREP_INTERRUPT)
1056 csr |= TEGRA_APBDMA_CSR_IE_EOC;
1054 csr |= tdc->dma_sconfig.slave_id << TEGRA_APBDMA_CSR_REQ_SEL_SHIFT; 1057 csr |= tdc->dma_sconfig.slave_id << TEGRA_APBDMA_CSR_REQ_SEL_SHIFT;
1055 1058
1056 apb_seq |= TEGRA_APBDMA_APBSEQ_WRAP_WORD_1; 1059 apb_seq |= TEGRA_APBDMA_APBSEQ_WRAP_WORD_1;
@@ -1095,7 +1098,8 @@ struct dma_async_tx_descriptor *tegra_dma_prep_dma_cyclic(
1095 mem += len; 1098 mem += len;
1096 } 1099 }
1097 sg_req->last_sg = true; 1100 sg_req->last_sg = true;
1098 dma_desc->txd.flags = 0; 1101 if (flags & DMA_CTRL_ACK)
1102 dma_desc->txd.flags = DMA_CTRL_ACK;
1099 1103
1100 /* 1104 /*
1101 * Make sure that mode should not be conflicting with currently 1105 * Make sure that mode should not be conflicting with currently
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 281f566a5513..d1e9eb191f2b 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -340,7 +340,7 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
340 /* 340 /*
341 * Alocate and fill the csrow/channels structs 341 * Alocate and fill the csrow/channels structs
342 */ 342 */
343 mci->csrows = kcalloc(sizeof(*mci->csrows), tot_csrows, GFP_KERNEL); 343 mci->csrows = kcalloc(tot_csrows, sizeof(*mci->csrows), GFP_KERNEL);
344 if (!mci->csrows) 344 if (!mci->csrows)
345 goto error; 345 goto error;
346 for (row = 0; row < tot_csrows; row++) { 346 for (row = 0; row < tot_csrows; row++) {
@@ -351,7 +351,7 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
351 csr->csrow_idx = row; 351 csr->csrow_idx = row;
352 csr->mci = mci; 352 csr->mci = mci;
353 csr->nr_channels = tot_channels; 353 csr->nr_channels = tot_channels;
354 csr->channels = kcalloc(sizeof(*csr->channels), tot_channels, 354 csr->channels = kcalloc(tot_channels, sizeof(*csr->channels),
355 GFP_KERNEL); 355 GFP_KERNEL);
356 if (!csr->channels) 356 if (!csr->channels)
357 goto error; 357 goto error;
@@ -369,7 +369,7 @@ struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
369 /* 369 /*
370 * Allocate and fill the dimm structs 370 * Allocate and fill the dimm structs
371 */ 371 */
372 mci->dimms = kcalloc(sizeof(*mci->dimms), tot_dimms, GFP_KERNEL); 372 mci->dimms = kcalloc(tot_dimms, sizeof(*mci->dimms), GFP_KERNEL);
373 if (!mci->dimms) 373 if (!mci->dimms)
374 goto error; 374 goto error;
375 375
diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
index dc6e905ee1a5..0056c4dae9d5 100644
--- a/drivers/edac/edac_pci_sysfs.c
+++ b/drivers/edac/edac_pci_sysfs.c
@@ -256,7 +256,7 @@ static ssize_t edac_pci_dev_store(struct kobject *kobj,
256 struct edac_pci_dev_attribute *edac_pci_dev; 256 struct edac_pci_dev_attribute *edac_pci_dev;
257 edac_pci_dev = (struct edac_pci_dev_attribute *)attr; 257 edac_pci_dev = (struct edac_pci_dev_attribute *)attr;
258 258
259 if (edac_pci_dev->show) 259 if (edac_pci_dev->store)
260 return edac_pci_dev->store(edac_pci_dev->value, buffer, count); 260 return edac_pci_dev->store(edac_pci_dev->value, buffer, count);
261 return -EIO; 261 return -EIO;
262} 262}
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index fd3ae6290d71..982f1f5f5742 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -471,7 +471,7 @@ void __init dmi_scan_machine(void)
471 char __iomem *p, *q; 471 char __iomem *p, *q;
472 int rc; 472 int rc;
473 473
474 if (efi_enabled) { 474 if (efi_enabled(EFI_CONFIG_TABLES)) {
475 if (efi.smbios == EFI_INVALID_TABLE_ADDR) 475 if (efi.smbios == EFI_INVALID_TABLE_ADDR)
476 goto error; 476 goto error;
477 477
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 7b1c37497c9a..f5596db0cf58 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -674,7 +674,7 @@ static int efi_status_to_err(efi_status_t status)
674 err = -EACCES; 674 err = -EACCES;
675 break; 675 break;
676 case EFI_NOT_FOUND: 676 case EFI_NOT_FOUND:
677 err = -ENOENT; 677 err = -EIO;
678 break; 678 break;
679 default: 679 default:
680 err = -EINVAL; 680 err = -EINVAL;
@@ -793,6 +793,7 @@ static ssize_t efivarfs_file_write(struct file *file,
793 spin_unlock(&efivars->lock); 793 spin_unlock(&efivars->lock);
794 efivar_unregister(var); 794 efivar_unregister(var);
795 drop_nlink(inode); 795 drop_nlink(inode);
796 d_delete(file->f_dentry);
796 dput(file->f_dentry); 797 dput(file->f_dentry);
797 798
798 } else { 799 } else {
@@ -994,7 +995,7 @@ static int efivarfs_unlink(struct inode *dir, struct dentry *dentry)
994 list_del(&var->list); 995 list_del(&var->list);
995 spin_unlock(&efivars->lock); 996 spin_unlock(&efivars->lock);
996 efivar_unregister(var); 997 efivar_unregister(var);
997 drop_nlink(dir); 998 drop_nlink(dentry->d_inode);
998 dput(dentry); 999 dput(dentry);
999 return 0; 1000 return 0;
1000 } 1001 }
@@ -1782,7 +1783,7 @@ efivars_init(void)
1782 printk(KERN_INFO "EFI Variables Facility v%s %s\n", EFIVARS_VERSION, 1783 printk(KERN_INFO "EFI Variables Facility v%s %s\n", EFIVARS_VERSION,
1783 EFIVARS_DATE); 1784 EFIVARS_DATE);
1784 1785
1785 if (!efi_enabled) 1786 if (!efi_enabled(EFI_RUNTIME_SERVICES))
1786 return 0; 1787 return 0;
1787 1788
1788 /* For now we'll register the efi directory at /sys/firmware/efi */ 1789 /* For now we'll register the efi directory at /sys/firmware/efi */
@@ -1822,7 +1823,7 @@ err_put:
1822static void __exit 1823static void __exit
1823efivars_exit(void) 1824efivars_exit(void)
1824{ 1825{
1825 if (efi_enabled) { 1826 if (efi_enabled(EFI_RUNTIME_SERVICES)) {
1826 unregister_efivars(&__efivars); 1827 unregister_efivars(&__efivars);
1827 kobject_put(efi_kobj); 1828 kobject_put(efi_kobj);
1828 } 1829 }
diff --git a/drivers/firmware/iscsi_ibft_find.c b/drivers/firmware/iscsi_ibft_find.c
index 4da4eb9ae926..2224f1dc074b 100644
--- a/drivers/firmware/iscsi_ibft_find.c
+++ b/drivers/firmware/iscsi_ibft_find.c
@@ -99,7 +99,7 @@ unsigned long __init find_ibft_region(unsigned long *sizep)
99 /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will 99 /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
100 * only use ACPI for this */ 100 * only use ACPI for this */
101 101
102 if (!efi_enabled) 102 if (!efi_enabled(EFI_BOOT))
103 find_ibft_in_mem(); 103 find_ibft_in_mem();
104 104
105 if (ibft_addr) { 105 if (ibft_addr) {
diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig
index 1d1f1e5e33f0..046bcda36abe 100644
--- a/drivers/gpu/drm/exynos/Kconfig
+++ b/drivers/gpu/drm/exynos/Kconfig
@@ -24,7 +24,7 @@ config DRM_EXYNOS_DMABUF
24 24
25config DRM_EXYNOS_FIMD 25config DRM_EXYNOS_FIMD
26 bool "Exynos DRM FIMD" 26 bool "Exynos DRM FIMD"
27 depends on DRM_EXYNOS && !FB_S3C 27 depends on DRM_EXYNOS && !FB_S3C && !ARCH_MULTIPLATFORM
28 help 28 help
29 Choose this option if you want to use Exynos FIMD for DRM. 29 Choose this option if you want to use Exynos FIMD for DRM.
30 30
@@ -48,7 +48,7 @@ config DRM_EXYNOS_G2D
48 48
49config DRM_EXYNOS_IPP 49config DRM_EXYNOS_IPP
50 bool "Exynos DRM IPP" 50 bool "Exynos DRM IPP"
51 depends on DRM_EXYNOS 51 depends on DRM_EXYNOS && !ARCH_MULTIPLATFORM
52 help 52 help
53 Choose this option if you want to use IPP feature for DRM. 53 Choose this option if you want to use IPP feature for DRM.
54 54
diff --git a/drivers/gpu/drm/exynos/exynos_drm_connector.c b/drivers/gpu/drm/exynos/exynos_drm_connector.c
index ab37437bad8a..4c5b6859c9ea 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_connector.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_connector.c
@@ -18,7 +18,6 @@
18#include "exynos_drm_drv.h" 18#include "exynos_drm_drv.h"
19#include "exynos_drm_encoder.h" 19#include "exynos_drm_encoder.h"
20 20
21#define MAX_EDID 256
22#define to_exynos_connector(x) container_of(x, struct exynos_drm_connector,\ 21#define to_exynos_connector(x) container_of(x, struct exynos_drm_connector,\
23 drm_connector) 22 drm_connector)
24 23
@@ -96,7 +95,9 @@ static int exynos_drm_connector_get_modes(struct drm_connector *connector)
96 to_exynos_connector(connector); 95 to_exynos_connector(connector);
97 struct exynos_drm_manager *manager = exynos_connector->manager; 96 struct exynos_drm_manager *manager = exynos_connector->manager;
98 struct exynos_drm_display_ops *display_ops = manager->display_ops; 97 struct exynos_drm_display_ops *display_ops = manager->display_ops;
99 unsigned int count; 98 struct edid *edid = NULL;
99 unsigned int count = 0;
100 int ret;
100 101
101 DRM_DEBUG_KMS("%s\n", __FILE__); 102 DRM_DEBUG_KMS("%s\n", __FILE__);
102 103
@@ -114,27 +115,21 @@ static int exynos_drm_connector_get_modes(struct drm_connector *connector)
114 * because lcd panel has only one mode. 115 * because lcd panel has only one mode.
115 */ 116 */
116 if (display_ops->get_edid) { 117 if (display_ops->get_edid) {
117 int ret; 118 edid = display_ops->get_edid(manager->dev, connector);
118 void *edid; 119 if (IS_ERR_OR_NULL(edid)) {
119 120 ret = PTR_ERR(edid);
120 edid = kzalloc(MAX_EDID, GFP_KERNEL); 121 edid = NULL;
121 if (!edid) { 122 DRM_ERROR("Panel operation get_edid failed %d\n", ret);
122 DRM_ERROR("failed to allocate edid\n"); 123 goto out;
123 return 0;
124 } 124 }
125 125
126 ret = display_ops->get_edid(manager->dev, connector, 126 count = drm_add_edid_modes(connector, edid);
127 edid, MAX_EDID); 127 if (count < 0) {
128 if (ret < 0) { 128 DRM_ERROR("Add edid modes failed %d\n", count);
129 DRM_ERROR("failed to get edid data.\n"); 129 goto out;
130 kfree(edid);
131 edid = NULL;
132 return 0;
133 } 130 }
134 131
135 drm_mode_connector_update_edid_property(connector, edid); 132 drm_mode_connector_update_edid_property(connector, edid);
136 count = drm_add_edid_modes(connector, edid);
137 kfree(edid);
138 } else { 133 } else {
139 struct exynos_drm_panel_info *panel; 134 struct exynos_drm_panel_info *panel;
140 struct drm_display_mode *mode = drm_mode_create(connector->dev); 135 struct drm_display_mode *mode = drm_mode_create(connector->dev);
@@ -161,6 +156,8 @@ static int exynos_drm_connector_get_modes(struct drm_connector *connector)
161 count = 1; 156 count = 1;
162 } 157 }
163 158
159out:
160 kfree(edid);
164 return count; 161 return count;
165} 162}
166 163
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
index 9df97714b6c0..ba0a3aa78547 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
@@ -19,6 +19,7 @@
19struct exynos_drm_dmabuf_attachment { 19struct exynos_drm_dmabuf_attachment {
20 struct sg_table sgt; 20 struct sg_table sgt;
21 enum dma_data_direction dir; 21 enum dma_data_direction dir;
22 bool is_mapped;
22}; 23};
23 24
24static int exynos_gem_attach_dma_buf(struct dma_buf *dmabuf, 25static int exynos_gem_attach_dma_buf(struct dma_buf *dmabuf,
@@ -72,17 +73,10 @@ static struct sg_table *
72 73
73 DRM_DEBUG_PRIME("%s\n", __FILE__); 74 DRM_DEBUG_PRIME("%s\n", __FILE__);
74 75
75 if (WARN_ON(dir == DMA_NONE))
76 return ERR_PTR(-EINVAL);
77
78 /* just return current sgt if already requested. */ 76 /* just return current sgt if already requested. */
79 if (exynos_attach->dir == dir) 77 if (exynos_attach->dir == dir && exynos_attach->is_mapped)
80 return &exynos_attach->sgt; 78 return &exynos_attach->sgt;
81 79
82 /* reattaching is not allowed. */
83 if (WARN_ON(exynos_attach->dir != DMA_NONE))
84 return ERR_PTR(-EBUSY);
85
86 buf = gem_obj->buffer; 80 buf = gem_obj->buffer;
87 if (!buf) { 81 if (!buf) {
88 DRM_ERROR("buffer is null.\n"); 82 DRM_ERROR("buffer is null.\n");
@@ -107,13 +101,17 @@ static struct sg_table *
107 wr = sg_next(wr); 101 wr = sg_next(wr);
108 } 102 }
109 103
110 nents = dma_map_sg(attach->dev, sgt->sgl, sgt->orig_nents, dir); 104 if (dir != DMA_NONE) {
111 if (!nents) { 105 nents = dma_map_sg(attach->dev, sgt->sgl, sgt->orig_nents, dir);
112 DRM_ERROR("failed to map sgl with iommu.\n"); 106 if (!nents) {
113 sgt = ERR_PTR(-EIO); 107 DRM_ERROR("failed to map sgl with iommu.\n");
114 goto err_unlock; 108 sg_free_table(sgt);
109 sgt = ERR_PTR(-EIO);
110 goto err_unlock;
111 }
115 } 112 }
116 113
114 exynos_attach->is_mapped = true;
117 exynos_attach->dir = dir; 115 exynos_attach->dir = dir;
118 attach->priv = exynos_attach; 116 attach->priv = exynos_attach;
119 117
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index b9e51bc09e81..4606fac7241a 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -148,8 +148,8 @@ struct exynos_drm_overlay {
148struct exynos_drm_display_ops { 148struct exynos_drm_display_ops {
149 enum exynos_drm_output_type type; 149 enum exynos_drm_output_type type;
150 bool (*is_connected)(struct device *dev); 150 bool (*is_connected)(struct device *dev);
151 int (*get_edid)(struct device *dev, struct drm_connector *connector, 151 struct edid *(*get_edid)(struct device *dev,
152 u8 *edid, int len); 152 struct drm_connector *connector);
153 void *(*get_panel)(struct device *dev); 153 void *(*get_panel)(struct device *dev);
154 int (*check_timing)(struct device *dev, void *timing); 154 int (*check_timing)(struct device *dev, void *timing);
155 int (*power_on)(struct device *dev, int mode); 155 int (*power_on)(struct device *dev, int mode);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
index 36c3905536a6..9a4c08e7453c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
@@ -324,7 +324,7 @@ out:
324 g2d_userptr = NULL; 324 g2d_userptr = NULL;
325} 325}
326 326
327dma_addr_t *g2d_userptr_get_dma_addr(struct drm_device *drm_dev, 327static dma_addr_t *g2d_userptr_get_dma_addr(struct drm_device *drm_dev,
328 unsigned long userptr, 328 unsigned long userptr,
329 unsigned long size, 329 unsigned long size,
330 struct drm_file *filp, 330 struct drm_file *filp,
diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c
index 850e9950b7da..28644539b305 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c
@@ -108,18 +108,17 @@ static bool drm_hdmi_is_connected(struct device *dev)
108 return false; 108 return false;
109} 109}
110 110
111static int drm_hdmi_get_edid(struct device *dev, 111static struct edid *drm_hdmi_get_edid(struct device *dev,
112 struct drm_connector *connector, u8 *edid, int len) 112 struct drm_connector *connector)
113{ 113{
114 struct drm_hdmi_context *ctx = to_context(dev); 114 struct drm_hdmi_context *ctx = to_context(dev);
115 115
116 DRM_DEBUG_KMS("%s\n", __FILE__); 116 DRM_DEBUG_KMS("%s\n", __FILE__);
117 117
118 if (hdmi_ops && hdmi_ops->get_edid) 118 if (hdmi_ops && hdmi_ops->get_edid)
119 return hdmi_ops->get_edid(ctx->hdmi_ctx->ctx, connector, edid, 119 return hdmi_ops->get_edid(ctx->hdmi_ctx->ctx, connector);
120 len);
121 120
122 return 0; 121 return NULL;
123} 122}
124 123
125static int drm_hdmi_check_timing(struct device *dev, void *timing) 124static int drm_hdmi_check_timing(struct device *dev, void *timing)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.h b/drivers/gpu/drm/exynos/exynos_drm_hdmi.h
index 784a7e9a766c..d80516fc9ed7 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.h
@@ -30,8 +30,8 @@ struct exynos_drm_hdmi_context {
30struct exynos_hdmi_ops { 30struct exynos_hdmi_ops {
31 /* display */ 31 /* display */
32 bool (*is_connected)(void *ctx); 32 bool (*is_connected)(void *ctx);
33 int (*get_edid)(void *ctx, struct drm_connector *connector, 33 struct edid *(*get_edid)(void *ctx,
34 u8 *edid, int len); 34 struct drm_connector *connector);
35 int (*check_timing)(void *ctx, void *timing); 35 int (*check_timing)(void *ctx, void *timing);
36 int (*power_on)(void *ctx, int mode); 36 int (*power_on)(void *ctx, int mode);
37 37
diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
index 0bda96454a02..1a556354e92f 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
@@ -869,7 +869,7 @@ static void ipp_put_event(struct drm_exynos_ipp_cmd_node *c_node,
869 } 869 }
870} 870}
871 871
872void ipp_handle_cmd_work(struct device *dev, 872static void ipp_handle_cmd_work(struct device *dev,
873 struct exynos_drm_ippdrv *ippdrv, 873 struct exynos_drm_ippdrv *ippdrv,
874 struct drm_exynos_ipp_cmd_work *cmd_work, 874 struct drm_exynos_ipp_cmd_work *cmd_work,
875 struct drm_exynos_ipp_cmd_node *c_node) 875 struct drm_exynos_ipp_cmd_node *c_node)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
index e9e83ef688f0..f976e29def6e 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
@@ -734,7 +734,7 @@ static int rotator_remove(struct platform_device *pdev)
734 return 0; 734 return 0;
735} 735}
736 736
737struct rot_limit_table rot_limit_tbl = { 737static struct rot_limit_table rot_limit_tbl = {
738 .ycbcr420_2p = { 738 .ycbcr420_2p = {
739 .min_w = 32, 739 .min_w = 32,
740 .min_h = 32, 740 .min_h = 32,
@@ -751,7 +751,7 @@ struct rot_limit_table rot_limit_tbl = {
751 }, 751 },
752}; 752};
753 753
754struct platform_device_id rotator_driver_ids[] = { 754static struct platform_device_id rotator_driver_ids[] = {
755 { 755 {
756 .name = "exynos-rot", 756 .name = "exynos-rot",
757 .driver_data = (unsigned long)&rot_limit_tbl, 757 .driver_data = (unsigned long)&rot_limit_tbl,
diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
index d0ca3c4e06c6..13ccbd4bcfaa 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
@@ -98,10 +98,12 @@ static bool vidi_display_is_connected(struct device *dev)
98 return ctx->connected ? true : false; 98 return ctx->connected ? true : false;
99} 99}
100 100
101static int vidi_get_edid(struct device *dev, struct drm_connector *connector, 101static struct edid *vidi_get_edid(struct device *dev,
102 u8 *edid, int len) 102 struct drm_connector *connector)
103{ 103{
104 struct vidi_context *ctx = get_vidi_context(dev); 104 struct vidi_context *ctx = get_vidi_context(dev);
105 struct edid *edid;
106 int edid_len;
105 107
106 DRM_DEBUG_KMS("%s\n", __FILE__); 108 DRM_DEBUG_KMS("%s\n", __FILE__);
107 109
@@ -111,13 +113,18 @@ static int vidi_get_edid(struct device *dev, struct drm_connector *connector,
111 */ 113 */
112 if (!ctx->raw_edid) { 114 if (!ctx->raw_edid) {
113 DRM_DEBUG_KMS("raw_edid is null.\n"); 115 DRM_DEBUG_KMS("raw_edid is null.\n");
114 return -EFAULT; 116 return ERR_PTR(-EFAULT);
115 } 117 }
116 118
117 memcpy(edid, ctx->raw_edid, min((1 + ctx->raw_edid->extensions) 119 edid_len = (1 + ctx->raw_edid->extensions) * EDID_LENGTH;
118 * EDID_LENGTH, len)); 120 edid = kzalloc(edid_len, GFP_KERNEL);
121 if (!edid) {
122 DRM_DEBUG_KMS("failed to allocate edid\n");
123 return ERR_PTR(-ENOMEM);
124 }
119 125
120 return 0; 126 memcpy(edid, ctx->raw_edid, edid_len);
127 return edid;
121} 128}
122 129
123static void *vidi_get_panel(struct device *dev) 130static void *vidi_get_panel(struct device *dev)
@@ -514,7 +521,6 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
514 struct exynos_drm_manager *manager; 521 struct exynos_drm_manager *manager;
515 struct exynos_drm_display_ops *display_ops; 522 struct exynos_drm_display_ops *display_ops;
516 struct drm_exynos_vidi_connection *vidi = data; 523 struct drm_exynos_vidi_connection *vidi = data;
517 struct edid *raw_edid;
518 int edid_len; 524 int edid_len;
519 525
520 DRM_DEBUG_KMS("%s\n", __FILE__); 526 DRM_DEBUG_KMS("%s\n", __FILE__);
@@ -551,11 +557,11 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
551 } 557 }
552 558
553 if (vidi->connection) { 559 if (vidi->connection) {
554 if (!vidi->edid) { 560 struct edid *raw_edid = (struct edid *)(uint32_t)vidi->edid;
555 DRM_DEBUG_KMS("edid data is null.\n"); 561 if (!drm_edid_is_valid(raw_edid)) {
562 DRM_DEBUG_KMS("edid data is invalid.\n");
556 return -EINVAL; 563 return -EINVAL;
557 } 564 }
558 raw_edid = (struct edid *)(uint32_t)vidi->edid;
559 edid_len = (1 + raw_edid->extensions) * EDID_LENGTH; 565 edid_len = (1 + raw_edid->extensions) * EDID_LENGTH;
560 ctx->raw_edid = kzalloc(edid_len, GFP_KERNEL); 566 ctx->raw_edid = kzalloc(edid_len, GFP_KERNEL);
561 if (!ctx->raw_edid) { 567 if (!ctx->raw_edid) {
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 41ff79d8ac8e..fbab3c468603 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -34,7 +34,6 @@
34#include <linux/regulator/consumer.h> 34#include <linux/regulator/consumer.h>
35#include <linux/io.h> 35#include <linux/io.h>
36#include <linux/of_gpio.h> 36#include <linux/of_gpio.h>
37#include <plat/gpio-cfg.h>
38 37
39#include <drm/exynos_drm.h> 38#include <drm/exynos_drm.h>
40 39
@@ -98,8 +97,7 @@ struct hdmi_context {
98 97
99 void __iomem *regs; 98 void __iomem *regs;
100 void *parent_ctx; 99 void *parent_ctx;
101 int external_irq; 100 int irq;
102 int internal_irq;
103 101
104 struct i2c_client *ddc_port; 102 struct i2c_client *ddc_port;
105 struct i2c_client *hdmiphy_port; 103 struct i2c_client *hdmiphy_port;
@@ -1391,8 +1389,7 @@ static bool hdmi_is_connected(void *ctx)
1391 return hdata->hpd; 1389 return hdata->hpd;
1392} 1390}
1393 1391
1394static int hdmi_get_edid(void *ctx, struct drm_connector *connector, 1392static struct edid *hdmi_get_edid(void *ctx, struct drm_connector *connector)
1395 u8 *edid, int len)
1396{ 1393{
1397 struct edid *raw_edid; 1394 struct edid *raw_edid;
1398 struct hdmi_context *hdata = ctx; 1395 struct hdmi_context *hdata = ctx;
@@ -1400,22 +1397,18 @@ static int hdmi_get_edid(void *ctx, struct drm_connector *connector,
1400 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 1397 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
1401 1398
1402 if (!hdata->ddc_port) 1399 if (!hdata->ddc_port)
1403 return -ENODEV; 1400 return ERR_PTR(-ENODEV);
1404 1401
1405 raw_edid = drm_get_edid(connector, hdata->ddc_port->adapter); 1402 raw_edid = drm_get_edid(connector, hdata->ddc_port->adapter);
1406 if (raw_edid) { 1403 if (!raw_edid)
1407 hdata->dvi_mode = !drm_detect_hdmi_monitor(raw_edid); 1404 return ERR_PTR(-ENODEV);
1408 memcpy(edid, raw_edid, min((1 + raw_edid->extensions)
1409 * EDID_LENGTH, len));
1410 DRM_DEBUG_KMS("%s : width[%d] x height[%d]\n",
1411 (hdata->dvi_mode ? "dvi monitor" : "hdmi monitor"),
1412 raw_edid->width_cm, raw_edid->height_cm);
1413 kfree(raw_edid);
1414 } else {
1415 return -ENODEV;
1416 }
1417 1405
1418 return 0; 1406 hdata->dvi_mode = !drm_detect_hdmi_monitor(raw_edid);
1407 DRM_DEBUG_KMS("%s : width[%d] x height[%d]\n",
1408 (hdata->dvi_mode ? "dvi monitor" : "hdmi monitor"),
1409 raw_edid->width_cm, raw_edid->height_cm);
1410
1411 return raw_edid;
1419} 1412}
1420 1413
1421static int hdmi_v13_check_timing(struct fb_videomode *check_timing) 1414static int hdmi_v13_check_timing(struct fb_videomode *check_timing)
@@ -1652,16 +1645,16 @@ static void hdmi_conf_reset(struct hdmi_context *hdata)
1652 1645
1653 /* resetting HDMI core */ 1646 /* resetting HDMI core */
1654 hdmi_reg_writemask(hdata, reg, 0, HDMI_CORE_SW_RSTOUT); 1647 hdmi_reg_writemask(hdata, reg, 0, HDMI_CORE_SW_RSTOUT);
1655 mdelay(10); 1648 usleep_range(10000, 12000);
1656 hdmi_reg_writemask(hdata, reg, ~0, HDMI_CORE_SW_RSTOUT); 1649 hdmi_reg_writemask(hdata, reg, ~0, HDMI_CORE_SW_RSTOUT);
1657 mdelay(10); 1650 usleep_range(10000, 12000);
1658} 1651}
1659 1652
1660static void hdmi_conf_init(struct hdmi_context *hdata) 1653static void hdmi_conf_init(struct hdmi_context *hdata)
1661{ 1654{
1662 struct hdmi_infoframe infoframe; 1655 struct hdmi_infoframe infoframe;
1663 1656
1664 /* disable HPD interrupts */ 1657 /* disable HPD interrupts from HDMI IP block, use GPIO instead */
1665 hdmi_reg_writemask(hdata, HDMI_INTC_CON, 0, HDMI_INTC_EN_GLOBAL | 1658 hdmi_reg_writemask(hdata, HDMI_INTC_CON, 0, HDMI_INTC_EN_GLOBAL |
1666 HDMI_INTC_EN_HPD_PLUG | HDMI_INTC_EN_HPD_UNPLUG); 1659 HDMI_INTC_EN_HPD_PLUG | HDMI_INTC_EN_HPD_UNPLUG);
1667 1660
@@ -1779,7 +1772,7 @@ static void hdmi_v13_timing_apply(struct hdmi_context *hdata)
1779 u32 val = hdmi_reg_read(hdata, HDMI_V13_PHY_STATUS); 1772 u32 val = hdmi_reg_read(hdata, HDMI_V13_PHY_STATUS);
1780 if (val & HDMI_PHY_STATUS_READY) 1773 if (val & HDMI_PHY_STATUS_READY)
1781 break; 1774 break;
1782 mdelay(1); 1775 usleep_range(1000, 2000);
1783 } 1776 }
1784 /* steady state not achieved */ 1777 /* steady state not achieved */
1785 if (tries == 0) { 1778 if (tries == 0) {
@@ -1946,7 +1939,7 @@ static void hdmi_v14_timing_apply(struct hdmi_context *hdata)
1946 u32 val = hdmi_reg_read(hdata, HDMI_PHY_STATUS_0); 1939 u32 val = hdmi_reg_read(hdata, HDMI_PHY_STATUS_0);
1947 if (val & HDMI_PHY_STATUS_READY) 1940 if (val & HDMI_PHY_STATUS_READY)
1948 break; 1941 break;
1949 mdelay(1); 1942 usleep_range(1000, 2000);
1950 } 1943 }
1951 /* steady state not achieved */ 1944 /* steady state not achieved */
1952 if (tries == 0) { 1945 if (tries == 0) {
@@ -1998,9 +1991,9 @@ static void hdmiphy_conf_reset(struct hdmi_context *hdata)
1998 1991
1999 /* reset hdmiphy */ 1992 /* reset hdmiphy */
2000 hdmi_reg_writemask(hdata, reg, ~0, HDMI_PHY_SW_RSTOUT); 1993 hdmi_reg_writemask(hdata, reg, ~0, HDMI_PHY_SW_RSTOUT);
2001 mdelay(10); 1994 usleep_range(10000, 12000);
2002 hdmi_reg_writemask(hdata, reg, 0, HDMI_PHY_SW_RSTOUT); 1995 hdmi_reg_writemask(hdata, reg, 0, HDMI_PHY_SW_RSTOUT);
2003 mdelay(10); 1996 usleep_range(10000, 12000);
2004} 1997}
2005 1998
2006static void hdmiphy_poweron(struct hdmi_context *hdata) 1999static void hdmiphy_poweron(struct hdmi_context *hdata)
@@ -2048,7 +2041,7 @@ static void hdmiphy_conf_apply(struct hdmi_context *hdata)
2048 return; 2041 return;
2049 } 2042 }
2050 2043
2051 mdelay(10); 2044 usleep_range(10000, 12000);
2052 2045
2053 /* operation mode */ 2046 /* operation mode */
2054 operation[0] = 0x1f; 2047 operation[0] = 0x1f;
@@ -2170,6 +2163,13 @@ static void hdmi_commit(void *ctx)
2170 2163
2171 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 2164 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
2172 2165
2166 mutex_lock(&hdata->hdmi_mutex);
2167 if (!hdata->powered) {
2168 mutex_unlock(&hdata->hdmi_mutex);
2169 return;
2170 }
2171 mutex_unlock(&hdata->hdmi_mutex);
2172
2173 hdmi_conf_apply(hdata); 2173 hdmi_conf_apply(hdata);
2174} 2174}
2175 2175
@@ -2265,7 +2265,7 @@ static struct exynos_hdmi_ops hdmi_ops = {
2265 .dpms = hdmi_dpms, 2265 .dpms = hdmi_dpms,
2266}; 2266};
2267 2267
2268static irqreturn_t hdmi_external_irq_thread(int irq, void *arg) 2268static irqreturn_t hdmi_irq_thread(int irq, void *arg)
2269{ 2269{
2270 struct exynos_drm_hdmi_context *ctx = arg; 2270 struct exynos_drm_hdmi_context *ctx = arg;
2271 struct hdmi_context *hdata = ctx->ctx; 2271 struct hdmi_context *hdata = ctx->ctx;
@@ -2280,31 +2280,6 @@ static irqreturn_t hdmi_external_irq_thread(int irq, void *arg)
2280 return IRQ_HANDLED; 2280 return IRQ_HANDLED;
2281} 2281}
2282 2282
2283static irqreturn_t hdmi_internal_irq_thread(int irq, void *arg)
2284{
2285 struct exynos_drm_hdmi_context *ctx = arg;
2286 struct hdmi_context *hdata = ctx->ctx;
2287 u32 intc_flag;
2288
2289 intc_flag = hdmi_reg_read(hdata, HDMI_INTC_FLAG);
2290 /* clearing flags for HPD plug/unplug */
2291 if (intc_flag & HDMI_INTC_FLAG_HPD_UNPLUG) {
2292 DRM_DEBUG_KMS("unplugged\n");
2293 hdmi_reg_writemask(hdata, HDMI_INTC_FLAG, ~0,
2294 HDMI_INTC_FLAG_HPD_UNPLUG);
2295 }
2296 if (intc_flag & HDMI_INTC_FLAG_HPD_PLUG) {
2297 DRM_DEBUG_KMS("plugged\n");
2298 hdmi_reg_writemask(hdata, HDMI_INTC_FLAG, ~0,
2299 HDMI_INTC_FLAG_HPD_PLUG);
2300 }
2301
2302 if (ctx->drm_dev)
2303 drm_helper_hpd_irq_event(ctx->drm_dev);
2304
2305 return IRQ_HANDLED;
2306}
2307
2308static int hdmi_resources_init(struct hdmi_context *hdata) 2283static int hdmi_resources_init(struct hdmi_context *hdata)
2309{ 2284{
2310 struct device *dev = hdata->dev; 2285 struct device *dev = hdata->dev;
@@ -2555,39 +2530,24 @@ static int hdmi_probe(struct platform_device *pdev)
2555 2530
2556 hdata->hdmiphy_port = hdmi_hdmiphy; 2531 hdata->hdmiphy_port = hdmi_hdmiphy;
2557 2532
2558 hdata->external_irq = gpio_to_irq(hdata->hpd_gpio); 2533 hdata->irq = gpio_to_irq(hdata->hpd_gpio);
2559 if (hdata->external_irq < 0) { 2534 if (hdata->irq < 0) {
2560 DRM_ERROR("failed to get GPIO external irq\n"); 2535 DRM_ERROR("failed to get GPIO irq\n");
2561 ret = hdata->external_irq; 2536 ret = hdata->irq;
2562 goto err_hdmiphy;
2563 }
2564
2565 hdata->internal_irq = platform_get_irq(pdev, 0);
2566 if (hdata->internal_irq < 0) {
2567 DRM_ERROR("failed to get platform internal irq\n");
2568 ret = hdata->internal_irq;
2569 goto err_hdmiphy; 2537 goto err_hdmiphy;
2570 } 2538 }
2571 2539
2572 hdata->hpd = gpio_get_value(hdata->hpd_gpio); 2540 hdata->hpd = gpio_get_value(hdata->hpd_gpio);
2573 2541
2574 ret = request_threaded_irq(hdata->external_irq, NULL, 2542 ret = request_threaded_irq(hdata->irq, NULL,
2575 hdmi_external_irq_thread, IRQF_TRIGGER_RISING | 2543 hdmi_irq_thread, IRQF_TRIGGER_RISING |
2576 IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 2544 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
2577 "hdmi_external", drm_hdmi_ctx); 2545 "hdmi", drm_hdmi_ctx);
2578 if (ret) { 2546 if (ret) {
2579 DRM_ERROR("failed to register hdmi external interrupt\n"); 2547 DRM_ERROR("failed to register hdmi interrupt\n");
2580 goto err_hdmiphy; 2548 goto err_hdmiphy;
2581 } 2549 }
2582 2550
2583 ret = request_threaded_irq(hdata->internal_irq, NULL,
2584 hdmi_internal_irq_thread, IRQF_ONESHOT,
2585 "hdmi_internal", drm_hdmi_ctx);
2586 if (ret) {
2587 DRM_ERROR("failed to register hdmi internal interrupt\n");
2588 goto err_free_irq;
2589 }
2590
2591 /* Attach HDMI Driver to common hdmi. */ 2551 /* Attach HDMI Driver to common hdmi. */
2592 exynos_hdmi_drv_attach(drm_hdmi_ctx); 2552 exynos_hdmi_drv_attach(drm_hdmi_ctx);
2593 2553
@@ -2598,8 +2558,6 @@ static int hdmi_probe(struct platform_device *pdev)
2598 2558
2599 return 0; 2559 return 0;
2600 2560
2601err_free_irq:
2602 free_irq(hdata->external_irq, drm_hdmi_ctx);
2603err_hdmiphy: 2561err_hdmiphy:
2604 i2c_del_driver(&hdmiphy_driver); 2562 i2c_del_driver(&hdmiphy_driver);
2605err_ddc: 2563err_ddc:
@@ -2617,8 +2575,7 @@ static int hdmi_remove(struct platform_device *pdev)
2617 2575
2618 pm_runtime_disable(dev); 2576 pm_runtime_disable(dev);
2619 2577
2620 free_irq(hdata->internal_irq, hdata); 2578 free_irq(hdata->irq, hdata);
2621 free_irq(hdata->external_irq, hdata);
2622 2579
2623 2580
2624 /* hdmiphy i2c driver */ 2581 /* hdmiphy i2c driver */
@@ -2637,8 +2594,7 @@ static int hdmi_suspend(struct device *dev)
2637 2594
2638 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); 2595 DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
2639 2596
2640 disable_irq(hdata->internal_irq); 2597 disable_irq(hdata->irq);
2641 disable_irq(hdata->external_irq);
2642 2598
2643 hdata->hpd = false; 2599 hdata->hpd = false;
2644 if (ctx->drm_dev) 2600 if (ctx->drm_dev)
@@ -2663,8 +2619,7 @@ static int hdmi_resume(struct device *dev)
2663 2619
2664 hdata->hpd = gpio_get_value(hdata->hpd_gpio); 2620 hdata->hpd = gpio_get_value(hdata->hpd_gpio);
2665 2621
2666 enable_irq(hdata->external_irq); 2622 enable_irq(hdata->irq);
2667 enable_irq(hdata->internal_irq);
2668 2623
2669 if (!pm_runtime_suspended(dev)) { 2624 if (!pm_runtime_suspended(dev)) {
2670 DRM_DEBUG_KMS("%s : Already resumed\n", __func__); 2625 DRM_DEBUG_KMS("%s : Already resumed\n", __func__);
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index c187ea33b748..c414584bfbae 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -600,7 +600,7 @@ static void vp_win_reset(struct mixer_context *ctx)
600 /* waiting until VP_SRESET_PROCESSING is 0 */ 600 /* waiting until VP_SRESET_PROCESSING is 0 */
601 if (~vp_reg_read(res, VP_SRESET) & VP_SRESET_PROCESSING) 601 if (~vp_reg_read(res, VP_SRESET) & VP_SRESET_PROCESSING)
602 break; 602 break;
603 mdelay(10); 603 usleep_range(10000, 12000);
604 } 604 }
605 WARN(tries == 0, "failed to reset Video Processor\n"); 605 WARN(tries == 0, "failed to reset Video Processor\n");
606} 606}
@@ -776,6 +776,13 @@ static void mixer_win_commit(void *ctx, int win)
776 776
777 DRM_DEBUG_KMS("[%d] %s, win: %d\n", __LINE__, __func__, win); 777 DRM_DEBUG_KMS("[%d] %s, win: %d\n", __LINE__, __func__, win);
778 778
779 mutex_lock(&mixer_ctx->mixer_mutex);
780 if (!mixer_ctx->powered) {
781 mutex_unlock(&mixer_ctx->mixer_mutex);
782 return;
783 }
784 mutex_unlock(&mixer_ctx->mixer_mutex);
785
779 if (win > 1 && mixer_ctx->vp_enabled) 786 if (win > 1 && mixer_ctx->vp_enabled)
780 vp_video_buffer(mixer_ctx, win); 787 vp_video_buffer(mixer_ctx, win);
781 else 788 else
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 7944d301518a..9d4a2c2adf0e 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -30,6 +30,7 @@
30#include <linux/debugfs.h> 30#include <linux/debugfs.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/export.h> 32#include <linux/export.h>
33#include <generated/utsrelease.h>
33#include <drm/drmP.h> 34#include <drm/drmP.h>
34#include "intel_drv.h" 35#include "intel_drv.h"
35#include "intel_ringbuffer.h" 36#include "intel_ringbuffer.h"
@@ -690,6 +691,7 @@ static int i915_error_state(struct seq_file *m, void *unused)
690 691
691 seq_printf(m, "Time: %ld s %ld us\n", error->time.tv_sec, 692 seq_printf(m, "Time: %ld s %ld us\n", error->time.tv_sec,
692 error->time.tv_usec); 693 error->time.tv_usec);
694 seq_printf(m, "Kernel: " UTS_RELEASE);
693 seq_printf(m, "PCI ID: 0x%04x\n", dev->pci_device); 695 seq_printf(m, "PCI ID: 0x%04x\n", dev->pci_device);
694 seq_printf(m, "EIR: 0x%08x\n", error->eir); 696 seq_printf(m, "EIR: 0x%08x\n", error->eir);
695 seq_printf(m, "IER: 0x%08x\n", error->ier); 697 seq_printf(m, "IER: 0x%08x\n", error->ier);
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index b401788e1791..59afb7eb6db6 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -533,6 +533,7 @@
533#define MI_MODE 0x0209c 533#define MI_MODE 0x0209c
534# define VS_TIMER_DISPATCH (1 << 6) 534# define VS_TIMER_DISPATCH (1 << 6)
535# define MI_FLUSH_ENABLE (1 << 12) 535# define MI_FLUSH_ENABLE (1 << 12)
536# define ASYNC_FLIP_PERF_DISABLE (1 << 14)
536 537
537#define GEN6_GT_MODE 0x20d0 538#define GEN6_GT_MODE 0x20d0
538#define GEN6_GT_MODE_HI (1 << 9) 539#define GEN6_GT_MODE_HI (1 << 9)
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index ae253e04c391..42ff97d667d2 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -505,13 +505,25 @@ static int init_render_ring(struct intel_ring_buffer *ring)
505 struct drm_i915_private *dev_priv = dev->dev_private; 505 struct drm_i915_private *dev_priv = dev->dev_private;
506 int ret = init_ring_common(ring); 506 int ret = init_ring_common(ring);
507 507
508 if (INTEL_INFO(dev)->gen > 3) { 508 if (INTEL_INFO(dev)->gen > 3)
509 I915_WRITE(MI_MODE, _MASKED_BIT_ENABLE(VS_TIMER_DISPATCH)); 509 I915_WRITE(MI_MODE, _MASKED_BIT_ENABLE(VS_TIMER_DISPATCH));
510 if (IS_GEN7(dev)) 510
511 I915_WRITE(GFX_MODE_GEN7, 511 /* We need to disable the AsyncFlip performance optimisations in order
512 _MASKED_BIT_DISABLE(GFX_TLB_INVALIDATE_ALWAYS) | 512 * to use MI_WAIT_FOR_EVENT within the CS. It should already be
513 _MASKED_BIT_ENABLE(GFX_REPLAY_MODE)); 513 * programmed to '1' on all products.
514 } 514 */
515 if (INTEL_INFO(dev)->gen >= 6)
516 I915_WRITE(MI_MODE, _MASKED_BIT_ENABLE(ASYNC_FLIP_PERF_DISABLE));
517
518 /* Required for the hardware to program scanline values for waiting */
519 if (INTEL_INFO(dev)->gen == 6)
520 I915_WRITE(GFX_MODE,
521 _MASKED_BIT_ENABLE(GFX_TLB_INVALIDATE_ALWAYS));
522
523 if (IS_GEN7(dev))
524 I915_WRITE(GFX_MODE_GEN7,
525 _MASKED_BIT_DISABLE(GFX_TLB_INVALIDATE_ALWAYS) |
526 _MASKED_BIT_ENABLE(GFX_REPLAY_MODE));
515 527
516 if (INTEL_INFO(dev)->gen >= 5) { 528 if (INTEL_INFO(dev)->gen >= 5) {
517 ret = init_pipe_control(ring); 529 ret = init_pipe_control(ring);
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index 59acabb45c9b..835992d8d067 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -1216,7 +1216,7 @@ void cayman_dma_stop(struct radeon_device *rdev)
1216int cayman_dma_resume(struct radeon_device *rdev) 1216int cayman_dma_resume(struct radeon_device *rdev)
1217{ 1217{
1218 struct radeon_ring *ring; 1218 struct radeon_ring *ring;
1219 u32 rb_cntl, dma_cntl; 1219 u32 rb_cntl, dma_cntl, ib_cntl;
1220 u32 rb_bufsz; 1220 u32 rb_bufsz;
1221 u32 reg_offset, wb_offset; 1221 u32 reg_offset, wb_offset;
1222 int i, r; 1222 int i, r;
@@ -1265,7 +1265,11 @@ int cayman_dma_resume(struct radeon_device *rdev)
1265 WREG32(DMA_RB_BASE + reg_offset, ring->gpu_addr >> 8); 1265 WREG32(DMA_RB_BASE + reg_offset, ring->gpu_addr >> 8);
1266 1266
1267 /* enable DMA IBs */ 1267 /* enable DMA IBs */
1268 WREG32(DMA_IB_CNTL + reg_offset, DMA_IB_ENABLE | CMD_VMID_FORCE); 1268 ib_cntl = DMA_IB_ENABLE | CMD_VMID_FORCE;
1269#ifdef __BIG_ENDIAN
1270 ib_cntl |= DMA_IB_SWAP_ENABLE;
1271#endif
1272 WREG32(DMA_IB_CNTL + reg_offset, ib_cntl);
1269 1273
1270 dma_cntl = RREG32(DMA_CNTL + reg_offset); 1274 dma_cntl = RREG32(DMA_CNTL + reg_offset);
1271 dma_cntl &= ~CTXEMPTY_INT_ENABLE; 1275 dma_cntl &= ~CTXEMPTY_INT_ENABLE;
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 3cb9d6089373..bc2540b17c5e 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -2313,7 +2313,7 @@ void r600_dma_stop(struct radeon_device *rdev)
2313int r600_dma_resume(struct radeon_device *rdev) 2313int r600_dma_resume(struct radeon_device *rdev)
2314{ 2314{
2315 struct radeon_ring *ring = &rdev->ring[R600_RING_TYPE_DMA_INDEX]; 2315 struct radeon_ring *ring = &rdev->ring[R600_RING_TYPE_DMA_INDEX];
2316 u32 rb_cntl, dma_cntl; 2316 u32 rb_cntl, dma_cntl, ib_cntl;
2317 u32 rb_bufsz; 2317 u32 rb_bufsz;
2318 int r; 2318 int r;
2319 2319
@@ -2353,7 +2353,11 @@ int r600_dma_resume(struct radeon_device *rdev)
2353 WREG32(DMA_RB_BASE, ring->gpu_addr >> 8); 2353 WREG32(DMA_RB_BASE, ring->gpu_addr >> 8);
2354 2354
2355 /* enable DMA IBs */ 2355 /* enable DMA IBs */
2356 WREG32(DMA_IB_CNTL, DMA_IB_ENABLE); 2356 ib_cntl = DMA_IB_ENABLE;
2357#ifdef __BIG_ENDIAN
2358 ib_cntl |= DMA_IB_SWAP_ENABLE;
2359#endif
2360 WREG32(DMA_IB_CNTL, ib_cntl);
2357 2361
2358 dma_cntl = RREG32(DMA_CNTL); 2362 dma_cntl = RREG32(DMA_CNTL);
2359 dma_cntl &= ~CTXEMPTY_INT_ENABLE; 2363 dma_cntl &= ~CTXEMPTY_INT_ENABLE;
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index 469661fd1903..5407459e56d2 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -286,6 +286,8 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
286 p->chunks[p->chunk_ib_idx].kpage[1] == NULL) { 286 p->chunks[p->chunk_ib_idx].kpage[1] == NULL) {
287 kfree(p->chunks[p->chunk_ib_idx].kpage[0]); 287 kfree(p->chunks[p->chunk_ib_idx].kpage[0]);
288 kfree(p->chunks[p->chunk_ib_idx].kpage[1]); 288 kfree(p->chunks[p->chunk_ib_idx].kpage[1]);
289 p->chunks[p->chunk_ib_idx].kpage[0] = NULL;
290 p->chunks[p->chunk_ib_idx].kpage[1] = NULL;
289 return -ENOMEM; 291 return -ENOMEM;
290 } 292 }
291 } 293 }
diff --git a/drivers/gpu/drm/radeon/radeon_cursor.c b/drivers/gpu/drm/radeon/radeon_cursor.c
index ad6df625e8b8..0d67674b64b1 100644
--- a/drivers/gpu/drm/radeon/radeon_cursor.c
+++ b/drivers/gpu/drm/radeon/radeon_cursor.c
@@ -241,7 +241,8 @@ int radeon_crtc_cursor_move(struct drm_crtc *crtc,
241 y = 0; 241 y = 0;
242 } 242 }
243 243
244 if (ASIC_IS_AVIVO(rdev)) { 244 /* fixed on DCE6 and newer */
245 if (ASIC_IS_AVIVO(rdev) && !ASIC_IS_DCE6(rdev)) {
245 int i = 0; 246 int i = 0;
246 struct drm_crtc *crtc_p; 247 struct drm_crtc *crtc_p;
247 248
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index edfc54e41842..0d6562bb0c93 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -429,7 +429,8 @@ bool radeon_card_posted(struct radeon_device *rdev)
429{ 429{
430 uint32_t reg; 430 uint32_t reg;
431 431
432 if (efi_enabled && rdev->pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE) 432 if (efi_enabled(EFI_BOOT) &&
433 rdev->pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE)
433 return false; 434 return false;
434 435
435 /* first check CRTCs */ 436 /* first check CRTCs */
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 1da2386d7cf7..ff3def784619 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -1122,7 +1122,7 @@ radeon_user_framebuffer_create(struct drm_device *dev,
1122 if (ret) { 1122 if (ret) {
1123 kfree(radeon_fb); 1123 kfree(radeon_fb);
1124 drm_gem_object_unreference_unlocked(obj); 1124 drm_gem_object_unreference_unlocked(obj);
1125 return NULL; 1125 return ERR_PTR(ret);
1126 } 1126 }
1127 1127
1128 return &radeon_fb->base; 1128 return &radeon_fb->base;
diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c
index cbba7db9ad59..f5258c205de5 100644
--- a/drivers/i2c/busses/i2c-designware-core.c
+++ b/drivers/i2c/busses/i2c-designware-core.c
@@ -34,6 +34,7 @@
34#include <linux/io.h> 34#include <linux/io.h>
35#include <linux/pm_runtime.h> 35#include <linux/pm_runtime.h>
36#include <linux/delay.h> 36#include <linux/delay.h>
37#include <linux/module.h>
37#include "i2c-designware-core.h" 38#include "i2c-designware-core.h"
38 39
39/* 40/*
@@ -725,3 +726,6 @@ u32 i2c_dw_read_comp_param(struct dw_i2c_dev *dev)
725 return dw_readl(dev, DW_IC_COMP_PARAM_1); 726 return dw_readl(dev, DW_IC_COMP_PARAM_1);
726} 727}
727EXPORT_SYMBOL_GPL(i2c_dw_read_comp_param); 728EXPORT_SYMBOL_GPL(i2c_dw_read_comp_param);
729
730MODULE_DESCRIPTION("Synopsys DesignWare I2C bus adapter core");
731MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 1b1a936eccc9..d6abaf2cf2e3 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -127,7 +127,7 @@ struct mxs_i2c_dev {
127 struct device *dev; 127 struct device *dev;
128 void __iomem *regs; 128 void __iomem *regs;
129 struct completion cmd_complete; 129 struct completion cmd_complete;
130 u32 cmd_err; 130 int cmd_err;
131 struct i2c_adapter adapter; 131 struct i2c_adapter adapter;
132 const struct mxs_i2c_speed_config *speed; 132 const struct mxs_i2c_speed_config *speed;
133 133
@@ -316,7 +316,7 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,
316 if (msg->len == 0) 316 if (msg->len == 0)
317 return -EINVAL; 317 return -EINVAL;
318 318
319 init_completion(&i2c->cmd_complete); 319 INIT_COMPLETION(i2c->cmd_complete);
320 i2c->cmd_err = 0; 320 i2c->cmd_err = 0;
321 321
322 ret = mxs_i2c_dma_setup_xfer(adap, msg, flags); 322 ret = mxs_i2c_dma_setup_xfer(adap, msg, flags);
@@ -473,6 +473,8 @@ static int mxs_i2c_probe(struct platform_device *pdev)
473 i2c->dev = dev; 473 i2c->dev = dev;
474 i2c->speed = &mxs_i2c_95kHz_config; 474 i2c->speed = &mxs_i2c_95kHz_config;
475 475
476 init_completion(&i2c->cmd_complete);
477
476 if (dev->of_node) { 478 if (dev->of_node) {
477 err = mxs_i2c_get_ofdata(i2c); 479 err = mxs_i2c_get_ofdata(i2c);
478 if (err) 480 if (err)
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 20d41bfa7c19..4cc2f0528c88 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -803,7 +803,7 @@ static int errata_omap3_i462(struct omap_i2c_dev *dev)
803 if (stat & OMAP_I2C_STAT_AL) { 803 if (stat & OMAP_I2C_STAT_AL) {
804 dev_err(dev->dev, "Arbitration lost\n"); 804 dev_err(dev->dev, "Arbitration lost\n");
805 dev->cmd_err |= OMAP_I2C_STAT_AL; 805 dev->cmd_err |= OMAP_I2C_STAT_AL;
806 omap_i2c_ack_stat(dev, OMAP_I2C_STAT_NACK); 806 omap_i2c_ack_stat(dev, OMAP_I2C_STAT_AL);
807 } 807 }
808 808
809 return -EIO; 809 return -EIO;
@@ -963,7 +963,7 @@ omap_i2c_isr_thread(int this_irq, void *dev_id)
963 i2c_omap_errata_i207(dev, stat); 963 i2c_omap_errata_i207(dev, stat);
964 964
965 omap_i2c_ack_stat(dev, OMAP_I2C_STAT_RDR); 965 omap_i2c_ack_stat(dev, OMAP_I2C_STAT_RDR);
966 break; 966 continue;
967 } 967 }
968 968
969 if (stat & OMAP_I2C_STAT_RRDY) { 969 if (stat & OMAP_I2C_STAT_RRDY) {
@@ -989,7 +989,7 @@ omap_i2c_isr_thread(int this_irq, void *dev_id)
989 break; 989 break;
990 990
991 omap_i2c_ack_stat(dev, OMAP_I2C_STAT_XDR); 991 omap_i2c_ack_stat(dev, OMAP_I2C_STAT_XDR);
992 break; 992 continue;
993 } 993 }
994 994
995 if (stat & OMAP_I2C_STAT_XRDY) { 995 if (stat & OMAP_I2C_STAT_XRDY) {
diff --git a/drivers/i2c/busses/i2c-sirf.c b/drivers/i2c/busses/i2c-sirf.c
index 3f1818b87974..e03381aee34f 100644
--- a/drivers/i2c/busses/i2c-sirf.c
+++ b/drivers/i2c/busses/i2c-sirf.c
@@ -12,6 +12,7 @@
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/i2c.h> 14#include <linux/i2c.h>
15#include <linux/of_i2c.h>
15#include <linux/clk.h> 16#include <linux/clk.h>
16#include <linux/err.h> 17#include <linux/err.h>
17#include <linux/io.h> 18#include <linux/io.h>
@@ -328,6 +329,7 @@ static int i2c_sirfsoc_probe(struct platform_device *pdev)
328 adap->algo = &i2c_sirfsoc_algo; 329 adap->algo = &i2c_sirfsoc_algo;
329 adap->algo_data = siic; 330 adap->algo_data = siic;
330 331
332 adap->dev.of_node = pdev->dev.of_node;
331 adap->dev.parent = &pdev->dev; 333 adap->dev.parent = &pdev->dev;
332 adap->nr = pdev->id; 334 adap->nr = pdev->id;
333 335
@@ -371,6 +373,8 @@ static int i2c_sirfsoc_probe(struct platform_device *pdev)
371 373
372 clk_disable(clk); 374 clk_disable(clk);
373 375
376 of_i2c_register_devices(adap);
377
374 dev_info(&pdev->dev, " I2C adapter ready to operate\n"); 378 dev_info(&pdev->dev, " I2C adapter ready to operate\n");
375 379
376 return 0; 380 return 0;
diff --git a/drivers/i2c/muxes/i2c-mux-pinctrl.c b/drivers/i2c/muxes/i2c-mux-pinctrl.c
index 1e44d04d1b22..a43c0ce5e3d8 100644
--- a/drivers/i2c/muxes/i2c-mux-pinctrl.c
+++ b/drivers/i2c/muxes/i2c-mux-pinctrl.c
@@ -167,7 +167,7 @@ static int i2c_mux_pinctrl_probe(struct platform_device *pdev)
167 } 167 }
168 168
169 mux->busses = devm_kzalloc(&pdev->dev, 169 mux->busses = devm_kzalloc(&pdev->dev,
170 sizeof(mux->busses) * mux->pdata->bus_count, 170 sizeof(*mux->busses) * mux->pdata->bus_count,
171 GFP_KERNEL); 171 GFP_KERNEL);
172 if (!mux->busses) { 172 if (!mux->busses) {
173 dev_err(&pdev->dev, "Cannot allocate busses\n"); 173 dev_err(&pdev->dev, "Cannot allocate busses\n");
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 4ba384f1ab54..2df9414a72f7 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -448,8 +448,6 @@ static int intel_idle_probe(void)
448 else 448 else
449 on_each_cpu(__setup_broadcast_timer, (void *)true, 1); 449 on_each_cpu(__setup_broadcast_timer, (void *)true, 1);
450 450
451 register_cpu_notifier(&cpu_hotplug_notifier);
452
453 pr_debug(PREFIX "v" INTEL_IDLE_VERSION 451 pr_debug(PREFIX "v" INTEL_IDLE_VERSION
454 " model 0x%X\n", boot_cpu_data.x86_model); 452 " model 0x%X\n", boot_cpu_data.x86_model);
455 453
@@ -612,6 +610,7 @@ static int __init intel_idle_init(void)
612 return retval; 610 return retval;
613 } 611 }
614 } 612 }
613 register_cpu_notifier(&cpu_hotplug_notifier);
615 614
616 return 0; 615 return 0;
617} 616}
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 81837b0710a9..faf10ba1ed9a 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -975,6 +975,38 @@ static void __init free_iommu_all(void)
975} 975}
976 976
977/* 977/*
978 * Family15h Model 10h-1fh erratum 746 (IOMMU Logging May Stall Translations)
979 * Workaround:
980 * BIOS should disable L2B micellaneous clock gating by setting
981 * L2_L2B_CK_GATE_CONTROL[CKGateL2BMiscDisable](D0F2xF4_x90[2]) = 1b
982 */
983static void __init amd_iommu_erratum_746_workaround(struct amd_iommu *iommu)
984{
985 u32 value;
986
987 if ((boot_cpu_data.x86 != 0x15) ||
988 (boot_cpu_data.x86_model < 0x10) ||
989 (boot_cpu_data.x86_model > 0x1f))
990 return;
991
992 pci_write_config_dword(iommu->dev, 0xf0, 0x90);
993 pci_read_config_dword(iommu->dev, 0xf4, &value);
994
995 if (value & BIT(2))
996 return;
997
998 /* Select NB indirect register 0x90 and enable writing */
999 pci_write_config_dword(iommu->dev, 0xf0, 0x90 | (1 << 8));
1000
1001 pci_write_config_dword(iommu->dev, 0xf4, value | 0x4);
1002 pr_info("AMD-Vi: Applying erratum 746 workaround for IOMMU at %s\n",
1003 dev_name(&iommu->dev->dev));
1004
1005 /* Clear the enable writing bit */
1006 pci_write_config_dword(iommu->dev, 0xf0, 0x90);
1007}
1008
1009/*
978 * This function clues the initialization function for one IOMMU 1010 * This function clues the initialization function for one IOMMU
979 * together and also allocates the command buffer and programs the 1011 * together and also allocates the command buffer and programs the
980 * hardware. It does NOT enable the IOMMU. This is done afterwards. 1012 * hardware. It does NOT enable the IOMMU. This is done afterwards.
@@ -1172,6 +1204,8 @@ static int iommu_init_pci(struct amd_iommu *iommu)
1172 iommu->stored_l2[i] = iommu_read_l2(iommu, i); 1204 iommu->stored_l2[i] = iommu_read_l2(iommu, i);
1173 } 1205 }
1174 1206
1207 amd_iommu_erratum_746_workaround(iommu);
1208
1175 return pci_enable_device(iommu->dev); 1209 return pci_enable_device(iommu->dev);
1176} 1210}
1177 1211
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index b9d091157884..eca28014ef3e 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -4234,6 +4234,21 @@ static struct iommu_ops intel_iommu_ops = {
4234 .pgsize_bitmap = INTEL_IOMMU_PGSIZES, 4234 .pgsize_bitmap = INTEL_IOMMU_PGSIZES,
4235}; 4235};
4236 4236
4237static void quirk_iommu_g4x_gfx(struct pci_dev *dev)
4238{
4239 /* G4x/GM45 integrated gfx dmar support is totally busted. */
4240 printk(KERN_INFO "DMAR: Disabling IOMMU for graphics on this chipset\n");
4241 dmar_map_gfx = 0;
4242}
4243
4244DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2a40, quirk_iommu_g4x_gfx);
4245DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e00, quirk_iommu_g4x_gfx);
4246DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e10, quirk_iommu_g4x_gfx);
4247DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e20, quirk_iommu_g4x_gfx);
4248DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e30, quirk_iommu_g4x_gfx);
4249DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e40, quirk_iommu_g4x_gfx);
4250DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e90, quirk_iommu_g4x_gfx);
4251
4237static void quirk_iommu_rwbf(struct pci_dev *dev) 4252static void quirk_iommu_rwbf(struct pci_dev *dev)
4238{ 4253{
4239 /* 4254 /*
@@ -4242,12 +4257,6 @@ static void quirk_iommu_rwbf(struct pci_dev *dev)
4242 */ 4257 */
4243 printk(KERN_INFO "DMAR: Forcing write-buffer flush capability\n"); 4258 printk(KERN_INFO "DMAR: Forcing write-buffer flush capability\n");
4244 rwbf_quirk = 1; 4259 rwbf_quirk = 1;
4245
4246 /* https://bugzilla.redhat.com/show_bug.cgi?id=538163 */
4247 if (dev->revision == 0x07) {
4248 printk(KERN_INFO "DMAR: Disabling IOMMU for graphics on this chipset\n");
4249 dmar_map_gfx = 0;
4250 }
4251} 4260}
4252 4261
4253DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2a40, quirk_iommu_rwbf); 4262DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2a40, quirk_iommu_rwbf);
diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c
index 68452b768da2..03a0a01a4054 100644
--- a/drivers/isdn/gigaset/capi.c
+++ b/drivers/isdn/gigaset/capi.c
@@ -248,6 +248,8 @@ static inline void dump_rawmsg(enum debuglevel level, const char *tag,
248 CAPIMSG_APPID(data), CAPIMSG_MSGID(data), l, 248 CAPIMSG_APPID(data), CAPIMSG_MSGID(data), l,
249 CAPIMSG_CONTROL(data)); 249 CAPIMSG_CONTROL(data));
250 l -= 12; 250 l -= 12;
251 if (l <= 0)
252 return;
251 dbgline = kmalloc(3 * l, GFP_ATOMIC); 253 dbgline = kmalloc(3 * l, GFP_ATOMIC);
252 if (!dbgline) 254 if (!dbgline)
253 return; 255 return;
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 3d8984edeff7..9e58dbd8d8cb 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -340,24 +340,22 @@ static int validate_region_size(struct raid_set *rs, unsigned long region_size)
340} 340}
341 341
342/* 342/*
343 * validate_rebuild_devices 343 * validate_raid_redundancy
344 * @rs 344 * @rs
345 * 345 *
346 * Determine if the devices specified for rebuild can result in a valid 346 * Determine if there are enough devices in the array that haven't
347 * usable array that is capable of rebuilding the given devices. 347 * failed (or are being rebuilt) to form a usable array.
348 * 348 *
349 * Returns: 0 on success, -EINVAL on failure. 349 * Returns: 0 on success, -EINVAL on failure.
350 */ 350 */
351static int validate_rebuild_devices(struct raid_set *rs) 351static int validate_raid_redundancy(struct raid_set *rs)
352{ 352{
353 unsigned i, rebuild_cnt = 0; 353 unsigned i, rebuild_cnt = 0;
354 unsigned rebuilds_per_group, copies, d; 354 unsigned rebuilds_per_group, copies, d;
355 355
356 if (!(rs->print_flags & DMPF_REBUILD))
357 return 0;
358
359 for (i = 0; i < rs->md.raid_disks; i++) 356 for (i = 0; i < rs->md.raid_disks; i++)
360 if (!test_bit(In_sync, &rs->dev[i].rdev.flags)) 357 if (!test_bit(In_sync, &rs->dev[i].rdev.flags) ||
358 !rs->dev[i].rdev.sb_page)
361 rebuild_cnt++; 359 rebuild_cnt++;
362 360
363 switch (rs->raid_type->level) { 361 switch (rs->raid_type->level) {
@@ -393,27 +391,24 @@ static int validate_rebuild_devices(struct raid_set *rs)
393 * A A B B C 391 * A A B B C
394 * C D D E E 392 * C D D E E
395 */ 393 */
396 rebuilds_per_group = 0;
397 for (i = 0; i < rs->md.raid_disks * copies; i++) { 394 for (i = 0; i < rs->md.raid_disks * copies; i++) {
395 if (!(i % copies))
396 rebuilds_per_group = 0;
398 d = i % rs->md.raid_disks; 397 d = i % rs->md.raid_disks;
399 if (!test_bit(In_sync, &rs->dev[d].rdev.flags) && 398 if ((!rs->dev[d].rdev.sb_page ||
399 !test_bit(In_sync, &rs->dev[d].rdev.flags)) &&
400 (++rebuilds_per_group >= copies)) 400 (++rebuilds_per_group >= copies))
401 goto too_many; 401 goto too_many;
402 if (!((i + 1) % copies))
403 rebuilds_per_group = 0;
404 } 402 }
405 break; 403 break;
406 default: 404 default:
407 DMERR("The rebuild parameter is not supported for %s", 405 if (rebuild_cnt)
408 rs->raid_type->name); 406 return -EINVAL;
409 rs->ti->error = "Rebuild not supported for this RAID type";
410 return -EINVAL;
411 } 407 }
412 408
413 return 0; 409 return 0;
414 410
415too_many: 411too_many:
416 rs->ti->error = "Too many rebuild devices specified";
417 return -EINVAL; 412 return -EINVAL;
418} 413}
419 414
@@ -664,9 +659,6 @@ static int parse_raid_params(struct raid_set *rs, char **argv,
664 } 659 }
665 rs->md.dev_sectors = sectors_per_dev; 660 rs->md.dev_sectors = sectors_per_dev;
666 661
667 if (validate_rebuild_devices(rs))
668 return -EINVAL;
669
670 /* Assume there are no metadata devices until the drives are parsed */ 662 /* Assume there are no metadata devices until the drives are parsed */
671 rs->md.persistent = 0; 663 rs->md.persistent = 0;
672 rs->md.external = 1; 664 rs->md.external = 1;
@@ -995,28 +987,10 @@ static int super_validate(struct mddev *mddev, struct md_rdev *rdev)
995static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs) 987static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs)
996{ 988{
997 int ret; 989 int ret;
998 unsigned redundancy = 0;
999 struct raid_dev *dev; 990 struct raid_dev *dev;
1000 struct md_rdev *rdev, *tmp, *freshest; 991 struct md_rdev *rdev, *tmp, *freshest;
1001 struct mddev *mddev = &rs->md; 992 struct mddev *mddev = &rs->md;
1002 993
1003 switch (rs->raid_type->level) {
1004 case 1:
1005 redundancy = rs->md.raid_disks - 1;
1006 break;
1007 case 4:
1008 case 5:
1009 case 6:
1010 redundancy = rs->raid_type->parity_devs;
1011 break;
1012 case 10:
1013 redundancy = raid10_md_layout_to_copies(mddev->layout) - 1;
1014 break;
1015 default:
1016 ti->error = "Unknown RAID type";
1017 return -EINVAL;
1018 }
1019
1020 freshest = NULL; 994 freshest = NULL;
1021 rdev_for_each_safe(rdev, tmp, mddev) { 995 rdev_for_each_safe(rdev, tmp, mddev) {
1022 /* 996 /*
@@ -1045,44 +1019,43 @@ static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs)
1045 break; 1019 break;
1046 default: 1020 default:
1047 dev = container_of(rdev, struct raid_dev, rdev); 1021 dev = container_of(rdev, struct raid_dev, rdev);
1048 if (redundancy--) { 1022 if (dev->meta_dev)
1049 if (dev->meta_dev) 1023 dm_put_device(ti, dev->meta_dev);
1050 dm_put_device(ti, dev->meta_dev);
1051
1052 dev->meta_dev = NULL;
1053 rdev->meta_bdev = NULL;
1054 1024
1055 if (rdev->sb_page) 1025 dev->meta_dev = NULL;
1056 put_page(rdev->sb_page); 1026 rdev->meta_bdev = NULL;
1057 1027
1058 rdev->sb_page = NULL; 1028 if (rdev->sb_page)
1029 put_page(rdev->sb_page);
1059 1030
1060 rdev->sb_loaded = 0; 1031 rdev->sb_page = NULL;
1061 1032
1062 /* 1033 rdev->sb_loaded = 0;
1063 * We might be able to salvage the data device
1064 * even though the meta device has failed. For
1065 * now, we behave as though '- -' had been
1066 * set for this device in the table.
1067 */
1068 if (dev->data_dev)
1069 dm_put_device(ti, dev->data_dev);
1070 1034
1071 dev->data_dev = NULL; 1035 /*
1072 rdev->bdev = NULL; 1036 * We might be able to salvage the data device
1037 * even though the meta device has failed. For
1038 * now, we behave as though '- -' had been
1039 * set for this device in the table.
1040 */
1041 if (dev->data_dev)
1042 dm_put_device(ti, dev->data_dev);
1073 1043
1074 list_del(&rdev->same_set); 1044 dev->data_dev = NULL;
1045 rdev->bdev = NULL;
1075 1046
1076 continue; 1047 list_del(&rdev->same_set);
1077 }
1078 ti->error = "Failed to load superblock";
1079 return ret;
1080 } 1048 }
1081 } 1049 }
1082 1050
1083 if (!freshest) 1051 if (!freshest)
1084 return 0; 1052 return 0;
1085 1053
1054 if (validate_raid_redundancy(rs)) {
1055 rs->ti->error = "Insufficient redundancy to activate array";
1056 return -EINVAL;
1057 }
1058
1086 /* 1059 /*
1087 * Validation of the freshest device provides the source of 1060 * Validation of the freshest device provides the source of
1088 * validation for the remaining devices. 1061 * validation for the remaining devices.
@@ -1432,7 +1405,7 @@ static void raid_resume(struct dm_target *ti)
1432 1405
1433static struct target_type raid_target = { 1406static struct target_type raid_target = {
1434 .name = "raid", 1407 .name = "raid",
1435 .version = {1, 4, 0}, 1408 .version = {1, 4, 1},
1436 .module = THIS_MODULE, 1409 .module = THIS_MODULE,
1437 .ctr = raid_ctr, 1410 .ctr = raid_ctr,
1438 .dtr = raid_dtr, 1411 .dtr = raid_dtr,
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index 1cf8293c0fb0..4a980e029ca7 100644
--- a/drivers/media/platform/coda.c
+++ b/drivers/media/platform/coda.c
@@ -23,8 +23,8 @@
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/videodev2.h> 24#include <linux/videodev2.h>
25#include <linux/of.h> 25#include <linux/of.h>
26#include <linux/platform_data/imx-iram.h>
26 27
27#include <mach/iram.h>
28#include <media/v4l2-ctrls.h> 28#include <media/v4l2-ctrls.h>
29#include <media/v4l2-device.h> 29#include <media/v4l2-device.h>
30#include <media/v4l2-ioctl.h> 30#include <media/v4l2-ioctl.h>
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 47ad4e270877..ff553babf455 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -237,6 +237,7 @@ config MFD_TPS65910
237 depends on I2C=y && GPIOLIB 237 depends on I2C=y && GPIOLIB
238 select MFD_CORE 238 select MFD_CORE
239 select REGMAP_I2C 239 select REGMAP_I2C
240 select REGMAP_IRQ
240 select IRQ_DOMAIN 241 select IRQ_DOMAIN
241 help 242 help
242 if you say yes here you get support for the TPS65910 series of 243 if you say yes here you get support for the TPS65910 series of
diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
index e1650badd106..4778bb124efe 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -19,6 +19,7 @@
19#include <linux/mfd/core.h> 19#include <linux/mfd/core.h>
20#include <linux/mfd/abx500.h> 20#include <linux/mfd/abx500.h>
21#include <linux/mfd/abx500/ab8500.h> 21#include <linux/mfd/abx500/ab8500.h>
22#include <linux/mfd/abx500/ab8500-bm.h>
22#include <linux/mfd/dbx500-prcmu.h> 23#include <linux/mfd/dbx500-prcmu.h>
23#include <linux/regulator/ab8500.h> 24#include <linux/regulator/ab8500.h>
24#include <linux/of.h> 25#include <linux/of.h>
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index bc8a3edb6bbf..222c03a5ddc0 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -239,7 +239,12 @@ static int arizona_runtime_resume(struct device *dev)
239 return ret; 239 return ret;
240 } 240 }
241 241
242 regcache_sync(arizona->regmap); 242 ret = regcache_sync(arizona->regmap);
243 if (ret != 0) {
244 dev_err(arizona->dev, "Failed to restore register cache\n");
245 regulator_disable(arizona->dcvdd);
246 return ret;
247 }
243 248
244 return 0; 249 return 0;
245} 250}
diff --git a/drivers/mfd/arizona-irq.c b/drivers/mfd/arizona-irq.c
index 74713bf5371f..2bec5f0db3ee 100644
--- a/drivers/mfd/arizona-irq.c
+++ b/drivers/mfd/arizona-irq.c
@@ -176,14 +176,7 @@ int arizona_irq_init(struct arizona *arizona)
176 aod = &wm5102_aod; 176 aod = &wm5102_aod;
177 irq = &wm5102_irq; 177 irq = &wm5102_irq;
178 178
179 switch (arizona->rev) { 179 ctrlif_error = false;
180 case 0:
181 case 1:
182 ctrlif_error = false;
183 break;
184 default:
185 break;
186 }
187 break; 180 break;
188#endif 181#endif
189#ifdef CONFIG_MFD_WM5110 182#ifdef CONFIG_MFD_WM5110
@@ -191,14 +184,7 @@ int arizona_irq_init(struct arizona *arizona)
191 aod = &wm5110_aod; 184 aod = &wm5110_aod;
192 irq = &wm5110_irq; 185 irq = &wm5110_irq;
193 186
194 switch (arizona->rev) { 187 ctrlif_error = false;
195 case 0:
196 case 1:
197 ctrlif_error = false;
198 break;
199 default:
200 break;
201 }
202 break; 188 break;
203#endif 189#endif
204 default: 190 default:
diff --git a/drivers/mfd/da9052-i2c.c b/drivers/mfd/da9052-i2c.c
index ac74a4d1daea..885e56780358 100644
--- a/drivers/mfd/da9052-i2c.c
+++ b/drivers/mfd/da9052-i2c.c
@@ -27,6 +27,66 @@
27#include <linux/of_device.h> 27#include <linux/of_device.h>
28#endif 28#endif
29 29
30/* I2C safe register check */
31static inline bool i2c_safe_reg(unsigned char reg)
32{
33 switch (reg) {
34 case DA9052_STATUS_A_REG:
35 case DA9052_STATUS_B_REG:
36 case DA9052_STATUS_C_REG:
37 case DA9052_STATUS_D_REG:
38 case DA9052_ADC_RES_L_REG:
39 case DA9052_ADC_RES_H_REG:
40 case DA9052_VDD_RES_REG:
41 case DA9052_ICHG_AV_REG:
42 case DA9052_TBAT_RES_REG:
43 case DA9052_ADCIN4_RES_REG:
44 case DA9052_ADCIN5_RES_REG:
45 case DA9052_ADCIN6_RES_REG:
46 case DA9052_TJUNC_RES_REG:
47 case DA9052_TSI_X_MSB_REG:
48 case DA9052_TSI_Y_MSB_REG:
49 case DA9052_TSI_LSB_REG:
50 case DA9052_TSI_Z_MSB_REG:
51 return true;
52 default:
53 return false;
54 }
55}
56
57/*
58 * There is an issue with DA9052 and DA9053_AA/BA/BB PMIC where the PMIC
59 * gets lockup up or fails to respond following a system reset.
60 * This fix is to follow any read or write with a dummy read to a safe
61 * register.
62 */
63int da9052_i2c_fix(struct da9052 *da9052, unsigned char reg)
64{
65 int val;
66
67 switch (da9052->chip_id) {
68 case DA9052:
69 case DA9053_AA:
70 case DA9053_BA:
71 case DA9053_BB:
72 /* A dummy read to a safe register address. */
73 if (!i2c_safe_reg(reg))
74 return regmap_read(da9052->regmap,
75 DA9052_PARK_REGISTER,
76 &val);
77 break;
78 default:
79 /*
80 * For other chips parking of I2C register
81 * to a safe place is not required.
82 */
83 break;
84 }
85
86 return 0;
87}
88EXPORT_SYMBOL(da9052_i2c_fix);
89
30static int da9052_i2c_enable_multiwrite(struct da9052 *da9052) 90static int da9052_i2c_enable_multiwrite(struct da9052 *da9052)
31{ 91{
32 int reg_val, ret; 92 int reg_val, ret;
@@ -83,6 +143,7 @@ static int da9052_i2c_probe(struct i2c_client *client,
83 143
84 da9052->dev = &client->dev; 144 da9052->dev = &client->dev;
85 da9052->chip_irq = client->irq; 145 da9052->chip_irq = client->irq;
146 da9052->fix_io = da9052_i2c_fix;
86 147
87 i2c_set_clientdata(client, da9052); 148 i2c_set_clientdata(client, da9052);
88 149
diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c
index dc8826d8d69d..268f45d42394 100644
--- a/drivers/mfd/db8500-prcmu.c
+++ b/drivers/mfd/db8500-prcmu.c
@@ -2524,7 +2524,7 @@ static bool read_mailbox_0(void)
2524 2524
2525 for (n = 0; n < NUM_PRCMU_WAKEUPS; n++) { 2525 for (n = 0; n < NUM_PRCMU_WAKEUPS; n++) {
2526 if (ev & prcmu_irq_bit[n]) 2526 if (ev & prcmu_irq_bit[n])
2527 generic_handle_irq(IRQ_PRCMU_BASE + n); 2527 generic_handle_irq(irq_find_mapping(db8500_irq_domain, n));
2528 } 2528 }
2529 r = true; 2529 r = true;
2530 break; 2530 break;
@@ -2737,13 +2737,14 @@ static int db8500_irq_map(struct irq_domain *d, unsigned int virq,
2737} 2737}
2738 2738
2739static struct irq_domain_ops db8500_irq_ops = { 2739static struct irq_domain_ops db8500_irq_ops = {
2740 .map = db8500_irq_map, 2740 .map = db8500_irq_map,
2741 .xlate = irq_domain_xlate_twocell, 2741 .xlate = irq_domain_xlate_twocell,
2742}; 2742};
2743 2743
2744static int db8500_irq_init(struct device_node *np) 2744static int db8500_irq_init(struct device_node *np)
2745{ 2745{
2746 int irq_base = -1; 2746 int irq_base = 0;
2747 int i;
2747 2748
2748 /* In the device tree case, just take some IRQs */ 2749 /* In the device tree case, just take some IRQs */
2749 if (!np) 2750 if (!np)
@@ -2758,6 +2759,10 @@ static int db8500_irq_init(struct device_node *np)
2758 return -ENOSYS; 2759 return -ENOSYS;
2759 } 2760 }
2760 2761
2762 /* All wakeups will be used, so create mappings for all */
2763 for (i = 0; i < NUM_PRCMU_WAKEUPS; i++)
2764 irq_create_mapping(db8500_irq_domain, i);
2765
2761 return 0; 2766 return 0;
2762} 2767}
2763 2768
diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
index f6878f8db57d..4d73963cd8f0 100644
--- a/drivers/mfd/max77686.c
+++ b/drivers/mfd/max77686.c
@@ -93,15 +93,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
93 if (max77686 == NULL) 93 if (max77686 == NULL)
94 return -ENOMEM; 94 return -ENOMEM;
95 95
96 max77686->regmap = regmap_init_i2c(i2c, &max77686_regmap_config);
97 if (IS_ERR(max77686->regmap)) {
98 ret = PTR_ERR(max77686->regmap);
99 dev_err(max77686->dev, "Failed to allocate register map: %d\n",
100 ret);
101 kfree(max77686);
102 return ret;
103 }
104
105 i2c_set_clientdata(i2c, max77686); 96 i2c_set_clientdata(i2c, max77686);
106 max77686->dev = &i2c->dev; 97 max77686->dev = &i2c->dev;
107 max77686->i2c = i2c; 98 max77686->i2c = i2c;
@@ -111,6 +102,15 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
111 max77686->irq_gpio = pdata->irq_gpio; 102 max77686->irq_gpio = pdata->irq_gpio;
112 max77686->irq = i2c->irq; 103 max77686->irq = i2c->irq;
113 104
105 max77686->regmap = regmap_init_i2c(i2c, &max77686_regmap_config);
106 if (IS_ERR(max77686->regmap)) {
107 ret = PTR_ERR(max77686->regmap);
108 dev_err(max77686->dev, "Failed to allocate register map: %d\n",
109 ret);
110 kfree(max77686);
111 return ret;
112 }
113
114 if (regmap_read(max77686->regmap, 114 if (regmap_read(max77686->regmap,
115 MAX77686_REG_DEVICE_ID, &data) < 0) { 115 MAX77686_REG_DEVICE_ID, &data) < 0) {
116 dev_err(max77686->dev, 116 dev_err(max77686->dev,
diff --git a/drivers/mfd/max77693.c b/drivers/mfd/max77693.c
index cc5155e20494..9e60fed5ff82 100644
--- a/drivers/mfd/max77693.c
+++ b/drivers/mfd/max77693.c
@@ -114,35 +114,37 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
114 u8 reg_data; 114 u8 reg_data;
115 int ret = 0; 115 int ret = 0;
116 116
117 if (!pdata) {
118 dev_err(&i2c->dev, "No platform data found.\n");
119 return -EINVAL;
120 }
121
117 max77693 = devm_kzalloc(&i2c->dev, 122 max77693 = devm_kzalloc(&i2c->dev,
118 sizeof(struct max77693_dev), GFP_KERNEL); 123 sizeof(struct max77693_dev), GFP_KERNEL);
119 if (max77693 == NULL) 124 if (max77693 == NULL)
120 return -ENOMEM; 125 return -ENOMEM;
121 126
122 max77693->regmap = devm_regmap_init_i2c(i2c, &max77693_regmap_config);
123 if (IS_ERR(max77693->regmap)) {
124 ret = PTR_ERR(max77693->regmap);
125 dev_err(max77693->dev,"failed to allocate register map: %d\n",
126 ret);
127 goto err_regmap;
128 }
129
130 i2c_set_clientdata(i2c, max77693); 127 i2c_set_clientdata(i2c, max77693);
131 max77693->dev = &i2c->dev; 128 max77693->dev = &i2c->dev;
132 max77693->i2c = i2c; 129 max77693->i2c = i2c;
133 max77693->irq = i2c->irq; 130 max77693->irq = i2c->irq;
134 max77693->type = id->driver_data; 131 max77693->type = id->driver_data;
135 132
136 if (!pdata) 133 max77693->regmap = devm_regmap_init_i2c(i2c, &max77693_regmap_config);
137 goto err_regmap; 134 if (IS_ERR(max77693->regmap)) {
135 ret = PTR_ERR(max77693->regmap);
136 dev_err(max77693->dev, "failed to allocate register map: %d\n",
137 ret);
138 return ret;
139 }
138 140
139 max77693->wakeup = pdata->wakeup; 141 max77693->wakeup = pdata->wakeup;
140 142
141 if (max77693_read_reg(max77693->regmap, 143 ret = max77693_read_reg(max77693->regmap, MAX77693_PMIC_REG_PMIC_ID2,
142 MAX77693_PMIC_REG_PMIC_ID2, &reg_data) < 0) { 144 &reg_data);
145 if (ret < 0) {
143 dev_err(max77693->dev, "device not found on this channel\n"); 146 dev_err(max77693->dev, "device not found on this channel\n");
144 ret = -ENODEV; 147 return ret;
145 goto err_regmap;
146 } else 148 } else
147 dev_info(max77693->dev, "device ID: 0x%x\n", reg_data); 149 dev_info(max77693->dev, "device ID: 0x%x\n", reg_data);
148 150
@@ -163,7 +165,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
163 ret = PTR_ERR(max77693->regmap_muic); 165 ret = PTR_ERR(max77693->regmap_muic);
164 dev_err(max77693->dev, 166 dev_err(max77693->dev,
165 "failed to allocate register map: %d\n", ret); 167 "failed to allocate register map: %d\n", ret);
166 goto err_regmap; 168 goto err_regmap_muic;
167 } 169 }
168 170
169 ret = max77693_irq_init(max77693); 171 ret = max77693_irq_init(max77693);
@@ -184,9 +186,9 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
184err_mfd: 186err_mfd:
185 max77693_irq_exit(max77693); 187 max77693_irq_exit(max77693);
186err_irq: 188err_irq:
189err_regmap_muic:
187 i2c_unregister_device(max77693->muic); 190 i2c_unregister_device(max77693->muic);
188 i2c_unregister_device(max77693->haptic); 191 i2c_unregister_device(max77693->haptic);
189err_regmap:
190 return ret; 192 return ret;
191} 193}
192 194
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c
index 64803f13bcec..d11567307fbe 100644
--- a/drivers/mfd/pcf50633-core.c
+++ b/drivers/mfd/pcf50633-core.c
@@ -208,6 +208,8 @@ static int pcf50633_probe(struct i2c_client *client,
208 if (!pcf) 208 if (!pcf)
209 return -ENOMEM; 209 return -ENOMEM;
210 210
211 i2c_set_clientdata(client, pcf);
212 pcf->dev = &client->dev;
211 pcf->pdata = pdata; 213 pcf->pdata = pdata;
212 214
213 mutex_init(&pcf->lock); 215 mutex_init(&pcf->lock);
@@ -219,9 +221,6 @@ static int pcf50633_probe(struct i2c_client *client,
219 return ret; 221 return ret;
220 } 222 }
221 223
222 i2c_set_clientdata(client, pcf);
223 pcf->dev = &client->dev;
224
225 version = pcf50633_reg_read(pcf, 0); 224 version = pcf50633_reg_read(pcf, 0);
226 variant = pcf50633_reg_read(pcf, 1); 225 variant = pcf50633_reg_read(pcf, 1);
227 if (version < 0 || variant < 0) { 226 if (version < 0 || variant < 0) {
diff --git a/drivers/mfd/rtl8411.c b/drivers/mfd/rtl8411.c
index 89f046ca9e41..3d3b4addf81a 100644
--- a/drivers/mfd/rtl8411.c
+++ b/drivers/mfd/rtl8411.c
@@ -112,6 +112,21 @@ static int rtl8411_card_power_off(struct rtsx_pcr *pcr, int card)
112 BPP_LDO_POWB, BPP_LDO_SUSPEND); 112 BPP_LDO_POWB, BPP_LDO_SUSPEND);
113} 113}
114 114
115static int rtl8411_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
116{
117 u8 mask, val;
118
119 mask = (BPP_REG_TUNED18 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_MASK;
120 if (voltage == OUTPUT_3V3)
121 val = (BPP_ASIC_3V3 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_3V3;
122 else if (voltage == OUTPUT_1V8)
123 val = (BPP_ASIC_1V8 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_1V8;
124 else
125 return -EINVAL;
126
127 return rtsx_pci_write_register(pcr, LDO_CTL, mask, val);
128}
129
115static unsigned int rtl8411_cd_deglitch(struct rtsx_pcr *pcr) 130static unsigned int rtl8411_cd_deglitch(struct rtsx_pcr *pcr)
116{ 131{
117 unsigned int card_exist; 132 unsigned int card_exist;
@@ -163,6 +178,18 @@ static unsigned int rtl8411_cd_deglitch(struct rtsx_pcr *pcr)
163 return card_exist; 178 return card_exist;
164} 179}
165 180
181static int rtl8411_conv_clk_and_div_n(int input, int dir)
182{
183 int output;
184
185 if (dir == CLK_TO_DIV_N)
186 output = input * 4 / 5 - 2;
187 else
188 output = (input + 2) * 5 / 4;
189
190 return output;
191}
192
166static const struct pcr_ops rtl8411_pcr_ops = { 193static const struct pcr_ops rtl8411_pcr_ops = {
167 .extra_init_hw = rtl8411_extra_init_hw, 194 .extra_init_hw = rtl8411_extra_init_hw,
168 .optimize_phy = NULL, 195 .optimize_phy = NULL,
@@ -172,7 +199,9 @@ static const struct pcr_ops rtl8411_pcr_ops = {
172 .disable_auto_blink = rtl8411_disable_auto_blink, 199 .disable_auto_blink = rtl8411_disable_auto_blink,
173 .card_power_on = rtl8411_card_power_on, 200 .card_power_on = rtl8411_card_power_on,
174 .card_power_off = rtl8411_card_power_off, 201 .card_power_off = rtl8411_card_power_off,
202 .switch_output_voltage = rtl8411_switch_output_voltage,
175 .cd_deglitch = rtl8411_cd_deglitch, 203 .cd_deglitch = rtl8411_cd_deglitch,
204 .conv_clk_and_div_n = rtl8411_conv_clk_and_div_n,
176}; 205};
177 206
178/* SD Pull Control Enable: 207/* SD Pull Control Enable:
diff --git a/drivers/mfd/rts5209.c b/drivers/mfd/rts5209.c
index 283a4f148084..98fe0f39463e 100644
--- a/drivers/mfd/rts5209.c
+++ b/drivers/mfd/rts5209.c
@@ -144,6 +144,25 @@ static int rts5209_card_power_off(struct rtsx_pcr *pcr, int card)
144 return rtsx_pci_send_cmd(pcr, 100); 144 return rtsx_pci_send_cmd(pcr, 100);
145} 145}
146 146
147static int rts5209_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
148{
149 int err;
150
151 if (voltage == OUTPUT_3V3) {
152 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24);
153 if (err < 0)
154 return err;
155 } else if (voltage == OUTPUT_1V8) {
156 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C40 | 0x24);
157 if (err < 0)
158 return err;
159 } else {
160 return -EINVAL;
161 }
162
163 return 0;
164}
165
147static const struct pcr_ops rts5209_pcr_ops = { 166static const struct pcr_ops rts5209_pcr_ops = {
148 .extra_init_hw = rts5209_extra_init_hw, 167 .extra_init_hw = rts5209_extra_init_hw,
149 .optimize_phy = rts5209_optimize_phy, 168 .optimize_phy = rts5209_optimize_phy,
@@ -153,7 +172,9 @@ static const struct pcr_ops rts5209_pcr_ops = {
153 .disable_auto_blink = rts5209_disable_auto_blink, 172 .disable_auto_blink = rts5209_disable_auto_blink,
154 .card_power_on = rts5209_card_power_on, 173 .card_power_on = rts5209_card_power_on,
155 .card_power_off = rts5209_card_power_off, 174 .card_power_off = rts5209_card_power_off,
175 .switch_output_voltage = rts5209_switch_output_voltage,
156 .cd_deglitch = NULL, 176 .cd_deglitch = NULL,
177 .conv_clk_and_div_n = NULL,
157}; 178};
158 179
159/* SD Pull Control Enable: 180/* SD Pull Control Enable:
diff --git a/drivers/mfd/rts5229.c b/drivers/mfd/rts5229.c
index b9dbab266fda..29d889cbb9c5 100644
--- a/drivers/mfd/rts5229.c
+++ b/drivers/mfd/rts5229.c
@@ -114,6 +114,25 @@ static int rts5229_card_power_off(struct rtsx_pcr *pcr, int card)
114 return rtsx_pci_send_cmd(pcr, 100); 114 return rtsx_pci_send_cmd(pcr, 100);
115} 115}
116 116
117static int rts5229_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
118{
119 int err;
120
121 if (voltage == OUTPUT_3V3) {
122 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24);
123 if (err < 0)
124 return err;
125 } else if (voltage == OUTPUT_1V8) {
126 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C40 | 0x24);
127 if (err < 0)
128 return err;
129 } else {
130 return -EINVAL;
131 }
132
133 return 0;
134}
135
117static const struct pcr_ops rts5229_pcr_ops = { 136static const struct pcr_ops rts5229_pcr_ops = {
118 .extra_init_hw = rts5229_extra_init_hw, 137 .extra_init_hw = rts5229_extra_init_hw,
119 .optimize_phy = rts5229_optimize_phy, 138 .optimize_phy = rts5229_optimize_phy,
@@ -123,7 +142,9 @@ static const struct pcr_ops rts5229_pcr_ops = {
123 .disable_auto_blink = rts5229_disable_auto_blink, 142 .disable_auto_blink = rts5229_disable_auto_blink,
124 .card_power_on = rts5229_card_power_on, 143 .card_power_on = rts5229_card_power_on,
125 .card_power_off = rts5229_card_power_off, 144 .card_power_off = rts5229_card_power_off,
145 .switch_output_voltage = rts5229_switch_output_voltage,
126 .cd_deglitch = NULL, 146 .cd_deglitch = NULL,
147 .conv_clk_and_div_n = NULL,
127}; 148};
128 149
129/* SD Pull Control Enable: 150/* SD Pull Control Enable:
diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
index 7a7b0bda4618..9fc57009e228 100644
--- a/drivers/mfd/rtsx_pcr.c
+++ b/drivers/mfd/rtsx_pcr.c
@@ -630,7 +630,10 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
630 if (clk == pcr->cur_clock) 630 if (clk == pcr->cur_clock)
631 return 0; 631 return 0;
632 632
633 N = (u8)(clk - 2); 633 if (pcr->ops->conv_clk_and_div_n)
634 N = (u8)pcr->ops->conv_clk_and_div_n(clk, CLK_TO_DIV_N);
635 else
636 N = (u8)(clk - 2);
634 if ((clk <= 2) || (N > max_N)) 637 if ((clk <= 2) || (N > max_N))
635 return -EINVAL; 638 return -EINVAL;
636 639
@@ -641,7 +644,14 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
641 /* Make sure that the SSC clock div_n is equal or greater than min_N */ 644 /* Make sure that the SSC clock div_n is equal or greater than min_N */
642 div = CLK_DIV_1; 645 div = CLK_DIV_1;
643 while ((N < min_N) && (div < max_div)) { 646 while ((N < min_N) && (div < max_div)) {
644 N = (N + 2) * 2 - 2; 647 if (pcr->ops->conv_clk_and_div_n) {
648 int dbl_clk = pcr->ops->conv_clk_and_div_n(N,
649 DIV_N_TO_CLK) * 2;
650 N = (u8)pcr->ops->conv_clk_and_div_n(dbl_clk,
651 CLK_TO_DIV_N);
652 } else {
653 N = (N + 2) * 2 - 2;
654 }
645 div++; 655 div++;
646 } 656 }
647 dev_dbg(&(pcr->pci->dev), "N = %d, div = %d\n", N, div); 657 dev_dbg(&(pcr->pci->dev), "N = %d, div = %d\n", N, div);
@@ -703,6 +713,15 @@ int rtsx_pci_card_power_off(struct rtsx_pcr *pcr, int card)
703} 713}
704EXPORT_SYMBOL_GPL(rtsx_pci_card_power_off); 714EXPORT_SYMBOL_GPL(rtsx_pci_card_power_off);
705 715
716int rtsx_pci_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
717{
718 if (pcr->ops->switch_output_voltage)
719 return pcr->ops->switch_output_voltage(pcr, voltage);
720
721 return 0;
722}
723EXPORT_SYMBOL_GPL(rtsx_pci_switch_output_voltage);
724
706unsigned int rtsx_pci_card_exist(struct rtsx_pcr *pcr) 725unsigned int rtsx_pci_card_exist(struct rtsx_pcr *pcr)
707{ 726{
708 unsigned int val; 727 unsigned int val;
@@ -767,10 +786,10 @@ static void rtsx_pci_card_detect(struct work_struct *work)
767 786
768 spin_unlock_irqrestore(&pcr->lock, flags); 787 spin_unlock_irqrestore(&pcr->lock, flags);
769 788
770 if (card_detect & SD_EXIST) 789 if ((card_detect & SD_EXIST) && pcr->slots[RTSX_SD_CARD].card_event)
771 pcr->slots[RTSX_SD_CARD].card_event( 790 pcr->slots[RTSX_SD_CARD].card_event(
772 pcr->slots[RTSX_SD_CARD].p_dev); 791 pcr->slots[RTSX_SD_CARD].p_dev);
773 if (card_detect & MS_EXIST) 792 if ((card_detect & MS_EXIST) && pcr->slots[RTSX_MS_CARD].card_event)
774 pcr->slots[RTSX_MS_CARD].card_event( 793 pcr->slots[RTSX_MS_CARD].card_event(
775 pcr->slots[RTSX_MS_CARD].p_dev); 794 pcr->slots[RTSX_MS_CARD].p_dev);
776} 795}
diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c
index a06d66b929b1..ecc092c7f745 100644
--- a/drivers/mfd/tc3589x.c
+++ b/drivers/mfd/tc3589x.c
@@ -219,25 +219,18 @@ static void tc3589x_irq_unmap(struct irq_domain *d, unsigned int virq)
219} 219}
220 220
221static struct irq_domain_ops tc3589x_irq_ops = { 221static struct irq_domain_ops tc3589x_irq_ops = {
222 .map = tc3589x_irq_map, 222 .map = tc3589x_irq_map,
223 .unmap = tc3589x_irq_unmap, 223 .unmap = tc3589x_irq_unmap,
224 .xlate = irq_domain_xlate_twocell, 224 .xlate = irq_domain_xlate_twocell,
225}; 225};
226 226
227static int tc3589x_irq_init(struct tc3589x *tc3589x, struct device_node *np) 227static int tc3589x_irq_init(struct tc3589x *tc3589x, struct device_node *np)
228{ 228{
229 int base = tc3589x->irq_base; 229 int base = tc3589x->irq_base;
230 230
231 if (base) { 231 tc3589x->domain = irq_domain_add_simple(
232 tc3589x->domain = irq_domain_add_legacy( 232 np, TC3589x_NR_INTERNAL_IRQS, base,
233 NULL, TC3589x_NR_INTERNAL_IRQS, base, 233 &tc3589x_irq_ops, tc3589x);
234 0, &tc3589x_irq_ops, tc3589x);
235 }
236 else {
237 tc3589x->domain = irq_domain_add_linear(
238 np, TC3589x_NR_INTERNAL_IRQS,
239 &tc3589x_irq_ops, tc3589x);
240 }
241 234
242 if (!tc3589x->domain) { 235 if (!tc3589x->domain) {
243 dev_err(tc3589x->dev, "Failed to create irqdomain\n"); 236 dev_err(tc3589x->dev, "Failed to create irqdomain\n");
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 4dae241e5017..dd362c1078e1 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -159,7 +159,7 @@ out:
159static int twl4030_write_script(u8 address, struct twl4030_ins *script, 159static int twl4030_write_script(u8 address, struct twl4030_ins *script,
160 int len) 160 int len)
161{ 161{
162 int err; 162 int err = -EINVAL;
163 163
164 for (; len; len--, address++, script++) { 164 for (; len; len--, address++, script++) {
165 if (len == 1) { 165 if (len == 1) {
diff --git a/drivers/mfd/vexpress-config.c b/drivers/mfd/vexpress-config.c
index fae15d880758..3c1723aa6225 100644
--- a/drivers/mfd/vexpress-config.c
+++ b/drivers/mfd/vexpress-config.c
@@ -67,6 +67,7 @@ struct vexpress_config_bridge *vexpress_config_bridge_register(
67 67
68 return bridge; 68 return bridge;
69} 69}
70EXPORT_SYMBOL(vexpress_config_bridge_register);
70 71
71void vexpress_config_bridge_unregister(struct vexpress_config_bridge *bridge) 72void vexpress_config_bridge_unregister(struct vexpress_config_bridge *bridge)
72{ 73{
@@ -83,6 +84,7 @@ void vexpress_config_bridge_unregister(struct vexpress_config_bridge *bridge)
83 while (!list_empty(&__bridge.transactions)) 84 while (!list_empty(&__bridge.transactions))
84 cpu_relax(); 85 cpu_relax();
85} 86}
87EXPORT_SYMBOL(vexpress_config_bridge_unregister);
86 88
87 89
88struct vexpress_config_func { 90struct vexpress_config_func {
@@ -142,6 +144,7 @@ struct vexpress_config_func *__vexpress_config_func_get(struct device *dev,
142 144
143 return func; 145 return func;
144} 146}
147EXPORT_SYMBOL(__vexpress_config_func_get);
145 148
146void vexpress_config_func_put(struct vexpress_config_func *func) 149void vexpress_config_func_put(struct vexpress_config_func *func)
147{ 150{
@@ -149,7 +152,7 @@ void vexpress_config_func_put(struct vexpress_config_func *func)
149 of_node_put(func->bridge->node); 152 of_node_put(func->bridge->node);
150 kfree(func); 153 kfree(func);
151} 154}
152 155EXPORT_SYMBOL(vexpress_config_func_put);
153 156
154struct vexpress_config_trans { 157struct vexpress_config_trans {
155 struct vexpress_config_func *func; 158 struct vexpress_config_func *func;
@@ -229,6 +232,7 @@ void vexpress_config_complete(struct vexpress_config_bridge *bridge,
229 232
230 complete(&trans->completion); 233 complete(&trans->completion);
231} 234}
235EXPORT_SYMBOL(vexpress_config_complete);
232 236
233int vexpress_config_wait(struct vexpress_config_trans *trans) 237int vexpress_config_wait(struct vexpress_config_trans *trans)
234{ 238{
@@ -236,7 +240,7 @@ int vexpress_config_wait(struct vexpress_config_trans *trans)
236 240
237 return trans->status; 241 return trans->status;
238} 242}
239 243EXPORT_SYMBOL(vexpress_config_wait);
240 244
241int vexpress_config_read(struct vexpress_config_func *func, int offset, 245int vexpress_config_read(struct vexpress_config_func *func, int offset,
242 u32 *data) 246 u32 *data)
diff --git a/drivers/mfd/vexpress-sysreg.c b/drivers/mfd/vexpress-sysreg.c
index e5d8f63b252a..77048b18439e 100644
--- a/drivers/mfd/vexpress-sysreg.c
+++ b/drivers/mfd/vexpress-sysreg.c
@@ -313,19 +313,11 @@ static void vexpress_sysreg_config_complete(unsigned long data)
313} 313}
314 314
315 315
316void __init vexpress_sysreg_early_init(void __iomem *base) 316void __init vexpress_sysreg_setup(struct device_node *node)
317{ 317{
318 struct device_node *node = of_find_compatible_node(NULL, NULL, 318 if (WARN_ON(!vexpress_sysreg_base))
319 "arm,vexpress-sysreg");
320
321 if (node)
322 base = of_iomap(node, 0);
323
324 if (WARN_ON(!base))
325 return; 319 return;
326 320
327 vexpress_sysreg_base = base;
328
329 if (readl(vexpress_sysreg_base + SYS_MISC) & SYS_MISC_MASTERSITE) 321 if (readl(vexpress_sysreg_base + SYS_MISC) & SYS_MISC_MASTERSITE)
330 vexpress_master_site = VEXPRESS_SITE_DB2; 322 vexpress_master_site = VEXPRESS_SITE_DB2;
331 else 323 else
@@ -336,9 +328,23 @@ void __init vexpress_sysreg_early_init(void __iomem *base)
336 WARN_ON(!vexpress_sysreg_config_bridge); 328 WARN_ON(!vexpress_sysreg_config_bridge);
337} 329}
338 330
331void __init vexpress_sysreg_early_init(void __iomem *base)
332{
333 vexpress_sysreg_base = base;
334 vexpress_sysreg_setup(NULL);
335}
336
339void __init vexpress_sysreg_of_early_init(void) 337void __init vexpress_sysreg_of_early_init(void)
340{ 338{
341 vexpress_sysreg_early_init(NULL); 339 struct device_node *node = of_find_compatible_node(NULL, NULL,
340 "arm,vexpress-sysreg");
341
342 if (node) {
343 vexpress_sysreg_base = of_iomap(node, 0);
344 vexpress_sysreg_setup(node);
345 } else {
346 pr_info("vexpress-sysreg: No Device Tree node found.");
347 }
342} 348}
343 349
344 350
@@ -426,9 +432,11 @@ static int vexpress_sysreg_probe(struct platform_device *pdev)
426 return -EBUSY; 432 return -EBUSY;
427 } 433 }
428 434
429 if (!vexpress_sysreg_base) 435 if (!vexpress_sysreg_base) {
430 vexpress_sysreg_base = devm_ioremap(&pdev->dev, res->start, 436 vexpress_sysreg_base = devm_ioremap(&pdev->dev, res->start,
431 resource_size(res)); 437 resource_size(res));
438 vexpress_sysreg_setup(pdev->dev.of_node);
439 }
432 440
433 if (!vexpress_sysreg_base) { 441 if (!vexpress_sysreg_base) {
434 dev_err(&pdev->dev, "Failed to obtain base address!\n"); 442 dev_err(&pdev->dev, "Failed to obtain base address!\n");
diff --git a/drivers/mfd/wm5102-tables.c b/drivers/mfd/wm5102-tables.c
index 088872ab6338..1133a64c2dc9 100644
--- a/drivers/mfd/wm5102-tables.c
+++ b/drivers/mfd/wm5102-tables.c
@@ -1882,7 +1882,7 @@ static bool wm5102_volatile_register(struct device *dev, unsigned int reg)
1882 } 1882 }
1883} 1883}
1884 1884
1885#define WM5102_MAX_REGISTER 0x1a8fff 1885#define WM5102_MAX_REGISTER 0x1a9800
1886 1886
1887const struct regmap_config wm5102_spi_regmap = { 1887const struct regmap_config wm5102_spi_regmap = {
1888 .reg_bits = 32, 1888 .reg_bits = 32,
diff --git a/drivers/mmc/host/mvsdio.c b/drivers/mmc/host/mvsdio.c
index de4c20b3936c..f8dd36102949 100644
--- a/drivers/mmc/host/mvsdio.c
+++ b/drivers/mmc/host/mvsdio.c
@@ -50,8 +50,6 @@ struct mvsd_host {
50 struct timer_list timer; 50 struct timer_list timer;
51 struct mmc_host *mmc; 51 struct mmc_host *mmc;
52 struct device *dev; 52 struct device *dev;
53 struct resource *res;
54 int irq;
55 struct clk *clk; 53 struct clk *clk;
56 int gpio_card_detect; 54 int gpio_card_detect;
57 int gpio_write_protect; 55 int gpio_write_protect;
@@ -718,10 +716,6 @@ static int __init mvsd_probe(struct platform_device *pdev)
718 if (!r || irq < 0 || !mvsd_data) 716 if (!r || irq < 0 || !mvsd_data)
719 return -ENXIO; 717 return -ENXIO;
720 718
721 r = request_mem_region(r->start, SZ_1K, DRIVER_NAME);
722 if (!r)
723 return -EBUSY;
724
725 mmc = mmc_alloc_host(sizeof(struct mvsd_host), &pdev->dev); 719 mmc = mmc_alloc_host(sizeof(struct mvsd_host), &pdev->dev);
726 if (!mmc) { 720 if (!mmc) {
727 ret = -ENOMEM; 721 ret = -ENOMEM;
@@ -731,8 +725,8 @@ static int __init mvsd_probe(struct platform_device *pdev)
731 host = mmc_priv(mmc); 725 host = mmc_priv(mmc);
732 host->mmc = mmc; 726 host->mmc = mmc;
733 host->dev = &pdev->dev; 727 host->dev = &pdev->dev;
734 host->res = r;
735 host->base_clock = mvsd_data->clock / 2; 728 host->base_clock = mvsd_data->clock / 2;
729 host->clk = ERR_PTR(-EINVAL);
736 730
737 mmc->ops = &mvsd_ops; 731 mmc->ops = &mvsd_ops;
738 732
@@ -752,7 +746,7 @@ static int __init mvsd_probe(struct platform_device *pdev)
752 746
753 spin_lock_init(&host->lock); 747 spin_lock_init(&host->lock);
754 748
755 host->base = ioremap(r->start, SZ_4K); 749 host->base = devm_request_and_ioremap(&pdev->dev, r);
756 if (!host->base) { 750 if (!host->base) {
757 ret = -ENOMEM; 751 ret = -ENOMEM;
758 goto out; 752 goto out;
@@ -765,44 +759,45 @@ static int __init mvsd_probe(struct platform_device *pdev)
765 759
766 mvsd_power_down(host); 760 mvsd_power_down(host);
767 761
768 ret = request_irq(irq, mvsd_irq, 0, DRIVER_NAME, host); 762 ret = devm_request_irq(&pdev->dev, irq, mvsd_irq, 0, DRIVER_NAME, host);
769 if (ret) { 763 if (ret) {
770 pr_err("%s: cannot assign irq %d\n", DRIVER_NAME, irq); 764 pr_err("%s: cannot assign irq %d\n", DRIVER_NAME, irq);
771 goto out; 765 goto out;
772 } else 766 }
773 host->irq = irq;
774 767
775 /* Not all platforms can gate the clock, so it is not 768 /* Not all platforms can gate the clock, so it is not
776 an error if the clock does not exists. */ 769 an error if the clock does not exists. */
777 host->clk = clk_get(&pdev->dev, NULL); 770 host->clk = devm_clk_get(&pdev->dev, NULL);
778 if (!IS_ERR(host->clk)) { 771 if (!IS_ERR(host->clk))
779 clk_prepare_enable(host->clk); 772 clk_prepare_enable(host->clk);
780 }
781 773
782 if (mvsd_data->gpio_card_detect) { 774 if (mvsd_data->gpio_card_detect) {
783 ret = gpio_request(mvsd_data->gpio_card_detect, 775 ret = devm_gpio_request_one(&pdev->dev,
784 DRIVER_NAME " cd"); 776 mvsd_data->gpio_card_detect,
777 GPIOF_IN, DRIVER_NAME " cd");
785 if (ret == 0) { 778 if (ret == 0) {
786 gpio_direction_input(mvsd_data->gpio_card_detect);
787 irq = gpio_to_irq(mvsd_data->gpio_card_detect); 779 irq = gpio_to_irq(mvsd_data->gpio_card_detect);
788 ret = request_irq(irq, mvsd_card_detect_irq, 780 ret = devm_request_irq(&pdev->dev, irq,
789 IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING, 781 mvsd_card_detect_irq,
790 DRIVER_NAME " cd", host); 782 IRQ_TYPE_EDGE_RISING |
783 IRQ_TYPE_EDGE_FALLING,
784 DRIVER_NAME " cd", host);
791 if (ret == 0) 785 if (ret == 0)
792 host->gpio_card_detect = 786 host->gpio_card_detect =
793 mvsd_data->gpio_card_detect; 787 mvsd_data->gpio_card_detect;
794 else 788 else
795 gpio_free(mvsd_data->gpio_card_detect); 789 devm_gpio_free(&pdev->dev,
790 mvsd_data->gpio_card_detect);
796 } 791 }
797 } 792 }
798 if (!host->gpio_card_detect) 793 if (!host->gpio_card_detect)
799 mmc->caps |= MMC_CAP_NEEDS_POLL; 794 mmc->caps |= MMC_CAP_NEEDS_POLL;
800 795
801 if (mvsd_data->gpio_write_protect) { 796 if (mvsd_data->gpio_write_protect) {
802 ret = gpio_request(mvsd_data->gpio_write_protect, 797 ret = devm_gpio_request_one(&pdev->dev,
803 DRIVER_NAME " wp"); 798 mvsd_data->gpio_write_protect,
799 GPIOF_IN, DRIVER_NAME " wp");
804 if (ret == 0) { 800 if (ret == 0) {
805 gpio_direction_input(mvsd_data->gpio_write_protect);
806 host->gpio_write_protect = 801 host->gpio_write_protect =
807 mvsd_data->gpio_write_protect; 802 mvsd_data->gpio_write_protect;
808 } 803 }
@@ -824,26 +819,11 @@ static int __init mvsd_probe(struct platform_device *pdev)
824 return 0; 819 return 0;
825 820
826out: 821out:
827 if (host) { 822 if (mmc) {
828 if (host->irq) 823 if (!IS_ERR(host->clk))
829 free_irq(host->irq, host);
830 if (host->gpio_card_detect) {
831 free_irq(gpio_to_irq(host->gpio_card_detect), host);
832 gpio_free(host->gpio_card_detect);
833 }
834 if (host->gpio_write_protect)
835 gpio_free(host->gpio_write_protect);
836 if (host->base)
837 iounmap(host->base);
838 }
839 if (r)
840 release_resource(r);
841 if (mmc)
842 if (!IS_ERR_OR_NULL(host->clk)) {
843 clk_disable_unprepare(host->clk); 824 clk_disable_unprepare(host->clk);
844 clk_put(host->clk);
845 }
846 mmc_free_host(mmc); 825 mmc_free_host(mmc);
826 }
847 827
848 return ret; 828 return ret;
849} 829}
@@ -852,28 +832,16 @@ static int __exit mvsd_remove(struct platform_device *pdev)
852{ 832{
853 struct mmc_host *mmc = platform_get_drvdata(pdev); 833 struct mmc_host *mmc = platform_get_drvdata(pdev);
854 834
855 if (mmc) { 835 struct mvsd_host *host = mmc_priv(mmc);
856 struct mvsd_host *host = mmc_priv(mmc);
857 836
858 if (host->gpio_card_detect) { 837 mmc_remove_host(mmc);
859 free_irq(gpio_to_irq(host->gpio_card_detect), host); 838 del_timer_sync(&host->timer);
860 gpio_free(host->gpio_card_detect); 839 mvsd_power_down(host);
861 } 840
862 mmc_remove_host(mmc); 841 if (!IS_ERR(host->clk))
863 free_irq(host->irq, host); 842 clk_disable_unprepare(host->clk);
864 if (host->gpio_write_protect) 843 mmc_free_host(mmc);
865 gpio_free(host->gpio_write_protect);
866 del_timer_sync(&host->timer);
867 mvsd_power_down(host);
868 iounmap(host->base);
869 release_resource(host->res);
870 844
871 if (!IS_ERR(host->clk)) {
872 clk_disable_unprepare(host->clk);
873 clk_put(host->clk);
874 }
875 mmc_free_host(mmc);
876 }
877 platform_set_drvdata(pdev, NULL); 845 platform_set_drvdata(pdev, NULL);
878 return 0; 846 return 0;
879} 847}
diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
index 571915dfb218..f74b5adca642 100644
--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
@@ -1060,26 +1060,6 @@ static int sd_wait_voltage_stable_2(struct realtek_pci_sdmmc *host)
1060 return 0; 1060 return 0;
1061} 1061}
1062 1062
1063static int sd_change_bank_voltage(struct realtek_pci_sdmmc *host, u8 voltage)
1064{
1065 struct rtsx_pcr *pcr = host->pcr;
1066 int err;
1067
1068 if (voltage == SD_IO_3V3) {
1069 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24);
1070 if (err < 0)
1071 return err;
1072 } else if (voltage == SD_IO_1V8) {
1073 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C40 | 0x24);
1074 if (err < 0)
1075 return err;
1076 } else {
1077 return -EINVAL;
1078 }
1079
1080 return 0;
1081}
1082
1083static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios) 1063static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
1084{ 1064{
1085 struct realtek_pci_sdmmc *host = mmc_priv(mmc); 1065 struct realtek_pci_sdmmc *host = mmc_priv(mmc);
@@ -1098,11 +1078,11 @@ static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
1098 rtsx_pci_start_run(pcr); 1078 rtsx_pci_start_run(pcr);
1099 1079
1100 if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330) 1080 if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330)
1101 voltage = SD_IO_3V3; 1081 voltage = OUTPUT_3V3;
1102 else 1082 else
1103 voltage = SD_IO_1V8; 1083 voltage = OUTPUT_1V8;
1104 1084
1105 if (voltage == SD_IO_1V8) { 1085 if (voltage == OUTPUT_1V8) {
1106 err = rtsx_pci_write_register(pcr, 1086 err = rtsx_pci_write_register(pcr,
1107 SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_B); 1087 SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_B);
1108 if (err < 0) 1088 if (err < 0)
@@ -1113,11 +1093,11 @@ static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
1113 goto out; 1093 goto out;
1114 } 1094 }
1115 1095
1116 err = sd_change_bank_voltage(host, voltage); 1096 err = rtsx_pci_switch_output_voltage(pcr, voltage);
1117 if (err < 0) 1097 if (err < 0)
1118 goto out; 1098 goto out;
1119 1099
1120 if (voltage == SD_IO_1V8) { 1100 if (voltage == OUTPUT_1V8) {
1121 err = sd_wait_voltage_stable_2(host); 1101 err = sd_wait_voltage_stable_2(host);
1122 if (err < 0) 1102 if (err < 0)
1123 goto out; 1103 goto out;
diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index 5233b8f58d77..58607f196c9e 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -960,7 +960,7 @@ static int c_can_handle_bus_err(struct net_device *dev,
960 break; 960 break;
961 case LEC_ACK_ERROR: 961 case LEC_ACK_ERROR:
962 netdev_dbg(dev, "ack error\n"); 962 netdev_dbg(dev, "ack error\n");
963 cf->data[2] |= (CAN_ERR_PROT_LOC_ACK | 963 cf->data[3] |= (CAN_ERR_PROT_LOC_ACK |
964 CAN_ERR_PROT_LOC_ACK_DEL); 964 CAN_ERR_PROT_LOC_ACK_DEL);
965 break; 965 break;
966 case LEC_BIT1_ERROR: 966 case LEC_BIT1_ERROR:
@@ -973,7 +973,7 @@ static int c_can_handle_bus_err(struct net_device *dev,
973 break; 973 break;
974 case LEC_CRC_ERROR: 974 case LEC_CRC_ERROR:
975 netdev_dbg(dev, "CRC error\n"); 975 netdev_dbg(dev, "CRC error\n");
976 cf->data[2] |= (CAN_ERR_PROT_LOC_CRC_SEQ | 976 cf->data[3] |= (CAN_ERR_PROT_LOC_CRC_SEQ |
977 CAN_ERR_PROT_LOC_CRC_DEL); 977 CAN_ERR_PROT_LOC_CRC_DEL);
978 break; 978 break;
979 default: 979 default:
diff --git a/drivers/net/can/pch_can.c b/drivers/net/can/pch_can.c
index 7d1748575b1f..5c314a961970 100644
--- a/drivers/net/can/pch_can.c
+++ b/drivers/net/can/pch_can.c
@@ -560,7 +560,7 @@ static void pch_can_error(struct net_device *ndev, u32 status)
560 stats->rx_errors++; 560 stats->rx_errors++;
561 break; 561 break;
562 case PCH_CRC_ERR: 562 case PCH_CRC_ERR:
563 cf->data[2] |= CAN_ERR_PROT_LOC_CRC_SEQ | 563 cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ |
564 CAN_ERR_PROT_LOC_CRC_DEL; 564 CAN_ERR_PROT_LOC_CRC_DEL;
565 priv->can.can_stats.bus_error++; 565 priv->can.can_stats.bus_error++;
566 stats->rx_errors++; 566 stats->rx_errors++;
diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index f898c6363729..300581b24ff3 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -746,12 +746,12 @@ static int ti_hecc_error(struct net_device *ndev, int int_status,
746 } 746 }
747 if (err_status & HECC_CANES_CRCE) { 747 if (err_status & HECC_CANES_CRCE) {
748 hecc_set_bit(priv, HECC_CANES, HECC_CANES_CRCE); 748 hecc_set_bit(priv, HECC_CANES, HECC_CANES_CRCE);
749 cf->data[2] |= CAN_ERR_PROT_LOC_CRC_SEQ | 749 cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ |
750 CAN_ERR_PROT_LOC_CRC_DEL; 750 CAN_ERR_PROT_LOC_CRC_DEL;
751 } 751 }
752 if (err_status & HECC_CANES_ACKE) { 752 if (err_status & HECC_CANES_ACKE) {
753 hecc_set_bit(priv, HECC_CANES, HECC_CANES_ACKE); 753 hecc_set_bit(priv, HECC_CANES, HECC_CANES_ACKE);
754 cf->data[2] |= CAN_ERR_PROT_LOC_ACK | 754 cf->data[3] |= CAN_ERR_PROT_LOC_ACK |
755 CAN_ERR_PROT_LOC_ACK_DEL; 755 CAN_ERR_PROT_LOC_ACK_DEL;
756 } 756 }
757 } 757 }
diff --git a/drivers/net/ethernet/3com/3c574_cs.c b/drivers/net/ethernet/3com/3c574_cs.c
index 66df93638085..ffd8de28a76a 100644
--- a/drivers/net/ethernet/3com/3c574_cs.c
+++ b/drivers/net/ethernet/3com/3c574_cs.c
@@ -432,7 +432,7 @@ static int tc574_config(struct pcmcia_device *link)
432 netdev_info(dev, "%s at io %#3lx, irq %d, hw_addr %pM\n", 432 netdev_info(dev, "%s at io %#3lx, irq %d, hw_addr %pM\n",
433 cardname, dev->base_addr, dev->irq, dev->dev_addr); 433 cardname, dev->base_addr, dev->irq, dev->dev_addr);
434 netdev_info(dev, " %dK FIFO split %s Rx:Tx, %sMII interface.\n", 434 netdev_info(dev, " %dK FIFO split %s Rx:Tx, %sMII interface.\n",
435 8 << config & Ram_size, 435 8 << (config & Ram_size),
436 ram_split[(config & Ram_split) >> Ram_split_shift], 436 ram_split[(config & Ram_split) >> Ram_split_shift],
437 config & Autoselect ? "autoselect " : ""); 437 config & Autoselect ? "autoselect " : "");
438 438
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 78ea90c40e19..bdb086934cd9 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -1283,14 +1283,26 @@ static int tg3_phy_auxctl_write(struct tg3 *tp, int reg, u32 set)
1283 return tg3_writephy(tp, MII_TG3_AUX_CTRL, set | reg); 1283 return tg3_writephy(tp, MII_TG3_AUX_CTRL, set | reg);
1284} 1284}
1285 1285
1286#define TG3_PHY_AUXCTL_SMDSP_ENABLE(tp) \ 1286static int tg3_phy_toggle_auxctl_smdsp(struct tg3 *tp, bool enable)
1287 tg3_phy_auxctl_write((tp), MII_TG3_AUXCTL_SHDWSEL_AUXCTL, \ 1287{
1288 MII_TG3_AUXCTL_ACTL_SMDSP_ENA | \ 1288 u32 val;
1289 MII_TG3_AUXCTL_ACTL_TX_6DB) 1289 int err;
1290 1290
1291#define TG3_PHY_AUXCTL_SMDSP_DISABLE(tp) \ 1291 err = tg3_phy_auxctl_read(tp, MII_TG3_AUXCTL_SHDWSEL_AUXCTL, &val);
1292 tg3_phy_auxctl_write((tp), MII_TG3_AUXCTL_SHDWSEL_AUXCTL, \ 1292
1293 MII_TG3_AUXCTL_ACTL_TX_6DB); 1293 if (err)
1294 return err;
1295 if (enable)
1296
1297 val |= MII_TG3_AUXCTL_ACTL_SMDSP_ENA;
1298 else
1299 val &= ~MII_TG3_AUXCTL_ACTL_SMDSP_ENA;
1300
1301 err = tg3_phy_auxctl_write((tp), MII_TG3_AUXCTL_SHDWSEL_AUXCTL,
1302 val | MII_TG3_AUXCTL_ACTL_TX_6DB);
1303
1304 return err;
1305}
1294 1306
1295static int tg3_bmcr_reset(struct tg3 *tp) 1307static int tg3_bmcr_reset(struct tg3 *tp)
1296{ 1308{
@@ -2223,7 +2235,7 @@ static void tg3_phy_apply_otp(struct tg3 *tp)
2223 2235
2224 otp = tp->phy_otp; 2236 otp = tp->phy_otp;
2225 2237
2226 if (TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)) 2238 if (tg3_phy_toggle_auxctl_smdsp(tp, true))
2227 return; 2239 return;
2228 2240
2229 phy = ((otp & TG3_OTP_AGCTGT_MASK) >> TG3_OTP_AGCTGT_SHIFT); 2241 phy = ((otp & TG3_OTP_AGCTGT_MASK) >> TG3_OTP_AGCTGT_SHIFT);
@@ -2248,7 +2260,7 @@ static void tg3_phy_apply_otp(struct tg3 *tp)
2248 ((otp & TG3_OTP_RCOFF_MASK) >> TG3_OTP_RCOFF_SHIFT); 2260 ((otp & TG3_OTP_RCOFF_MASK) >> TG3_OTP_RCOFF_SHIFT);
2249 tg3_phydsp_write(tp, MII_TG3_DSP_EXP97, phy); 2261 tg3_phydsp_write(tp, MII_TG3_DSP_EXP97, phy);
2250 2262
2251 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp); 2263 tg3_phy_toggle_auxctl_smdsp(tp, false);
2252} 2264}
2253 2265
2254static void tg3_phy_eee_adjust(struct tg3 *tp, u32 current_link_up) 2266static void tg3_phy_eee_adjust(struct tg3 *tp, u32 current_link_up)
@@ -2284,9 +2296,9 @@ static void tg3_phy_eee_adjust(struct tg3 *tp, u32 current_link_up)
2284 2296
2285 if (!tp->setlpicnt) { 2297 if (!tp->setlpicnt) {
2286 if (current_link_up == 1 && 2298 if (current_link_up == 1 &&
2287 !TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)) { 2299 !tg3_phy_toggle_auxctl_smdsp(tp, true)) {
2288 tg3_phydsp_write(tp, MII_TG3_DSP_TAP26, 0x0000); 2300 tg3_phydsp_write(tp, MII_TG3_DSP_TAP26, 0x0000);
2289 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp); 2301 tg3_phy_toggle_auxctl_smdsp(tp, false);
2290 } 2302 }
2291 2303
2292 val = tr32(TG3_CPMU_EEE_MODE); 2304 val = tr32(TG3_CPMU_EEE_MODE);
@@ -2302,11 +2314,11 @@ static void tg3_phy_eee_enable(struct tg3 *tp)
2302 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 || 2314 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 ||
2303 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719 || 2315 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719 ||
2304 tg3_flag(tp, 57765_CLASS)) && 2316 tg3_flag(tp, 57765_CLASS)) &&
2305 !TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)) { 2317 !tg3_phy_toggle_auxctl_smdsp(tp, true)) {
2306 val = MII_TG3_DSP_TAP26_ALNOKO | 2318 val = MII_TG3_DSP_TAP26_ALNOKO |
2307 MII_TG3_DSP_TAP26_RMRXSTO; 2319 MII_TG3_DSP_TAP26_RMRXSTO;
2308 tg3_phydsp_write(tp, MII_TG3_DSP_TAP26, val); 2320 tg3_phydsp_write(tp, MII_TG3_DSP_TAP26, val);
2309 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp); 2321 tg3_phy_toggle_auxctl_smdsp(tp, false);
2310 } 2322 }
2311 2323
2312 val = tr32(TG3_CPMU_EEE_MODE); 2324 val = tr32(TG3_CPMU_EEE_MODE);
@@ -2450,7 +2462,7 @@ static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
2450 tg3_writephy(tp, MII_CTRL1000, 2462 tg3_writephy(tp, MII_CTRL1000,
2451 CTL1000_AS_MASTER | CTL1000_ENABLE_MASTER); 2463 CTL1000_AS_MASTER | CTL1000_ENABLE_MASTER);
2452 2464
2453 err = TG3_PHY_AUXCTL_SMDSP_ENABLE(tp); 2465 err = tg3_phy_toggle_auxctl_smdsp(tp, true);
2454 if (err) 2466 if (err)
2455 return err; 2467 return err;
2456 2468
@@ -2471,7 +2483,7 @@ static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
2471 tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8200); 2483 tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8200);
2472 tg3_writephy(tp, MII_TG3_DSP_CONTROL, 0x0000); 2484 tg3_writephy(tp, MII_TG3_DSP_CONTROL, 0x0000);
2473 2485
2474 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp); 2486 tg3_phy_toggle_auxctl_smdsp(tp, false);
2475 2487
2476 tg3_writephy(tp, MII_CTRL1000, phy9_orig); 2488 tg3_writephy(tp, MII_CTRL1000, phy9_orig);
2477 2489
@@ -2572,10 +2584,10 @@ static int tg3_phy_reset(struct tg3 *tp)
2572 2584
2573out: 2585out:
2574 if ((tp->phy_flags & TG3_PHYFLG_ADC_BUG) && 2586 if ((tp->phy_flags & TG3_PHYFLG_ADC_BUG) &&
2575 !TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)) { 2587 !tg3_phy_toggle_auxctl_smdsp(tp, true)) {
2576 tg3_phydsp_write(tp, 0x201f, 0x2aaa); 2588 tg3_phydsp_write(tp, 0x201f, 0x2aaa);
2577 tg3_phydsp_write(tp, 0x000a, 0x0323); 2589 tg3_phydsp_write(tp, 0x000a, 0x0323);
2578 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp); 2590 tg3_phy_toggle_auxctl_smdsp(tp, false);
2579 } 2591 }
2580 2592
2581 if (tp->phy_flags & TG3_PHYFLG_5704_A0_BUG) { 2593 if (tp->phy_flags & TG3_PHYFLG_5704_A0_BUG) {
@@ -2584,14 +2596,14 @@ out:
2584 } 2596 }
2585 2597
2586 if (tp->phy_flags & TG3_PHYFLG_BER_BUG) { 2598 if (tp->phy_flags & TG3_PHYFLG_BER_BUG) {
2587 if (!TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)) { 2599 if (!tg3_phy_toggle_auxctl_smdsp(tp, true)) {
2588 tg3_phydsp_write(tp, 0x000a, 0x310b); 2600 tg3_phydsp_write(tp, 0x000a, 0x310b);
2589 tg3_phydsp_write(tp, 0x201f, 0x9506); 2601 tg3_phydsp_write(tp, 0x201f, 0x9506);
2590 tg3_phydsp_write(tp, 0x401f, 0x14e2); 2602 tg3_phydsp_write(tp, 0x401f, 0x14e2);
2591 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp); 2603 tg3_phy_toggle_auxctl_smdsp(tp, false);
2592 } 2604 }
2593 } else if (tp->phy_flags & TG3_PHYFLG_JITTER_BUG) { 2605 } else if (tp->phy_flags & TG3_PHYFLG_JITTER_BUG) {
2594 if (!TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)) { 2606 if (!tg3_phy_toggle_auxctl_smdsp(tp, true)) {
2595 tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x000a); 2607 tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x000a);
2596 if (tp->phy_flags & TG3_PHYFLG_ADJUST_TRIM) { 2608 if (tp->phy_flags & TG3_PHYFLG_ADJUST_TRIM) {
2597 tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x110b); 2609 tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x110b);
@@ -2600,7 +2612,7 @@ out:
2600 } else 2612 } else
2601 tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x010b); 2613 tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x010b);
2602 2614
2603 TG3_PHY_AUXCTL_SMDSP_DISABLE(tp); 2615 tg3_phy_toggle_auxctl_smdsp(tp, false);
2604 } 2616 }
2605 } 2617 }
2606 2618
@@ -4009,7 +4021,7 @@ static int tg3_phy_autoneg_cfg(struct tg3 *tp, u32 advertise, u32 flowctrl)
4009 tw32(TG3_CPMU_EEE_MODE, 4021 tw32(TG3_CPMU_EEE_MODE,
4010 tr32(TG3_CPMU_EEE_MODE) & ~TG3_CPMU_EEEMD_LPI_ENABLE); 4022 tr32(TG3_CPMU_EEE_MODE) & ~TG3_CPMU_EEEMD_LPI_ENABLE);
4011 4023
4012 err = TG3_PHY_AUXCTL_SMDSP_ENABLE(tp); 4024 err = tg3_phy_toggle_auxctl_smdsp(tp, true);
4013 if (!err) { 4025 if (!err) {
4014 u32 err2; 4026 u32 err2;
4015 4027
@@ -4042,7 +4054,7 @@ static int tg3_phy_autoneg_cfg(struct tg3 *tp, u32 advertise, u32 flowctrl)
4042 MII_TG3_DSP_CH34TP2_HIBW01); 4054 MII_TG3_DSP_CH34TP2_HIBW01);
4043 } 4055 }
4044 4056
4045 err2 = TG3_PHY_AUXCTL_SMDSP_DISABLE(tp); 4057 err2 = tg3_phy_toggle_auxctl_smdsp(tp, false);
4046 if (!err) 4058 if (!err)
4047 err = err2; 4059 err = err2;
4048 } 4060 }
@@ -6950,6 +6962,9 @@ static void tg3_poll_controller(struct net_device *dev)
6950 int i; 6962 int i;
6951 struct tg3 *tp = netdev_priv(dev); 6963 struct tg3 *tp = netdev_priv(dev);
6952 6964
6965 if (tg3_irq_sync(tp))
6966 return;
6967
6953 for (i = 0; i < tp->irq_cnt; i++) 6968 for (i = 0; i < tp->irq_cnt; i++)
6954 tg3_interrupt(tp->napi[i].irq_vec, &tp->napi[i]); 6969 tg3_interrupt(tp->napi[i].irq_vec, &tp->napi[i]);
6955} 6970}
@@ -16367,6 +16382,7 @@ static int tg3_init_one(struct pci_dev *pdev,
16367 tp->pm_cap = pm_cap; 16382 tp->pm_cap = pm_cap;
16368 tp->rx_mode = TG3_DEF_RX_MODE; 16383 tp->rx_mode = TG3_DEF_RX_MODE;
16369 tp->tx_mode = TG3_DEF_TX_MODE; 16384 tp->tx_mode = TG3_DEF_TX_MODE;
16385 tp->irq_sync = 1;
16370 16386
16371 if (tg3_debug > 0) 16387 if (tg3_debug > 0)
16372 tp->msg_enable = tg3_debug; 16388 tp->msg_enable = tg3_debug;
diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c
index b407043ce9b0..f7f02900f650 100644
--- a/drivers/net/ethernet/calxeda/xgmac.c
+++ b/drivers/net/ethernet/calxeda/xgmac.c
@@ -548,6 +548,10 @@ static int desc_get_rx_status(struct xgmac_priv *priv, struct xgmac_dma_desc *p)
548 return -1; 548 return -1;
549 } 549 }
550 550
551 /* All frames should fit into a single buffer */
552 if (!(status & RXDESC_FIRST_SEG) || !(status & RXDESC_LAST_SEG))
553 return -1;
554
551 /* Check if packet has checksum already */ 555 /* Check if packet has checksum already */
552 if ((status & RXDESC_FRAME_TYPE) && (status & RXDESC_EXT_STATUS) && 556 if ((status & RXDESC_FRAME_TYPE) && (status & RXDESC_EXT_STATUS) &&
553 !(ext_status & RXDESC_IP_PAYLOAD_MASK)) 557 !(ext_status & RXDESC_IP_PAYLOAD_MASK))
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index f0718e1a8369..c306df7d4568 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -1994,9 +1994,20 @@ static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
1994{ 1994{
1995 const struct port_info *pi = netdev_priv(dev); 1995 const struct port_info *pi = netdev_priv(dev);
1996 struct adapter *adap = pi->adapter; 1996 struct adapter *adap = pi->adapter;
1997 1997 struct sge_rspq *q;
1998 return set_rxq_intr_params(adap, &adap->sge.ethrxq[pi->first_qset].rspq, 1998 int i;
1999 c->rx_coalesce_usecs, c->rx_max_coalesced_frames); 1999 int r = 0;
2000
2001 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++) {
2002 q = &adap->sge.ethrxq[i].rspq;
2003 r = set_rxq_intr_params(adap, q, c->rx_coalesce_usecs,
2004 c->rx_max_coalesced_frames);
2005 if (r) {
2006 dev_err(&dev->dev, "failed to set coalesce %d\n", r);
2007 break;
2008 }
2009 }
2010 return r;
2000} 2011}
2001 2012
2002static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c) 2013static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
diff --git a/drivers/net/ethernet/intel/ixgbe/Makefile b/drivers/net/ethernet/intel/ixgbe/Makefile
index f3a632bf8d96..687c83d1bdab 100644
--- a/drivers/net/ethernet/intel/ixgbe/Makefile
+++ b/drivers/net/ethernet/intel/ixgbe/Makefile
@@ -32,7 +32,7 @@
32 32
33obj-$(CONFIG_IXGBE) += ixgbe.o 33obj-$(CONFIG_IXGBE) += ixgbe.o
34 34
35ixgbe-objs := ixgbe_main.o ixgbe_common.o ixgbe_ethtool.o ixgbe_debugfs.o\ 35ixgbe-objs := ixgbe_main.o ixgbe_common.o ixgbe_ethtool.o \
36 ixgbe_82599.o ixgbe_82598.o ixgbe_phy.o ixgbe_sriov.o \ 36 ixgbe_82599.o ixgbe_82598.o ixgbe_phy.o ixgbe_sriov.o \
37 ixgbe_mbx.o ixgbe_x540.o ixgbe_lib.o ixgbe_ptp.o 37 ixgbe_mbx.o ixgbe_x540.o ixgbe_lib.o ixgbe_ptp.o
38 38
@@ -40,4 +40,5 @@ ixgbe-$(CONFIG_IXGBE_DCB) += ixgbe_dcb.o ixgbe_dcb_82598.o \
40 ixgbe_dcb_82599.o ixgbe_dcb_nl.o 40 ixgbe_dcb_82599.o ixgbe_dcb_nl.o
41 41
42ixgbe-$(CONFIG_IXGBE_HWMON) += ixgbe_sysfs.o 42ixgbe-$(CONFIG_IXGBE_HWMON) += ixgbe_sysfs.o
43ixgbe-$(CONFIG_DEBUG_FS) += ixgbe_debugfs.o
43ixgbe-$(CONFIG_FCOE:m=y) += ixgbe_fcoe.o 44ixgbe-$(CONFIG_FCOE:m=y) += ixgbe_fcoe.o
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
index 50aa546b8c7a..3504686d3af5 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
@@ -24,9 +24,6 @@
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 25
26*******************************************************************************/ 26*******************************************************************************/
27
28#ifdef CONFIG_DEBUG_FS
29
30#include <linux/debugfs.h> 27#include <linux/debugfs.h>
31#include <linux/module.h> 28#include <linux/module.h>
32 29
@@ -277,5 +274,3 @@ void ixgbe_dbg_exit(void)
277{ 274{
278 debugfs_remove_recursive(ixgbe_dbg_root); 275 debugfs_remove_recursive(ixgbe_dbg_root);
279} 276}
280
281#endif /* CONFIG_DEBUG_FS */
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
index 1a751c9d09c4..bb9256a1b0a9 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
@@ -660,11 +660,11 @@ int ixgbe_ptp_hwtstamp_ioctl(struct ixgbe_adapter *adapter,
660 break; 660 break;
661 case HWTSTAMP_FILTER_PTP_V1_L4_SYNC: 661 case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
662 tsync_rx_ctl |= IXGBE_TSYNCRXCTL_TYPE_L4_V1; 662 tsync_rx_ctl |= IXGBE_TSYNCRXCTL_TYPE_L4_V1;
663 tsync_rx_mtrl = IXGBE_RXMTRL_V1_SYNC_MSG; 663 tsync_rx_mtrl |= IXGBE_RXMTRL_V1_SYNC_MSG;
664 break; 664 break;
665 case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ: 665 case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
666 tsync_rx_ctl |= IXGBE_TSYNCRXCTL_TYPE_L4_V1; 666 tsync_rx_ctl |= IXGBE_TSYNCRXCTL_TYPE_L4_V1;
667 tsync_rx_mtrl = IXGBE_RXMTRL_V1_DELAY_REQ_MSG; 667 tsync_rx_mtrl |= IXGBE_RXMTRL_V1_DELAY_REQ_MSG;
668 break; 668 break;
669 case HWTSTAMP_FILTER_PTP_V2_EVENT: 669 case HWTSTAMP_FILTER_PTP_V2_EVENT:
670 case HWTSTAMP_FILTER_PTP_V2_L2_EVENT: 670 case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 2b799f4f1c37..6771b69f40d5 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -630,10 +630,15 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
630 ring->tx_csum++; 630 ring->tx_csum++;
631 } 631 }
632 632
633 /* Copy dst mac address to wqe */ 633 if (mlx4_is_mfunc(mdev->dev) || priv->validate_loopback) {
634 ethh = (struct ethhdr *)skb->data; 634 /* Copy dst mac address to wqe. This allows loopback in eSwitch,
635 tx_desc->ctrl.srcrb_flags16[0] = get_unaligned((__be16 *)ethh->h_dest); 635 * so that VFs and PF can communicate with each other
636 tx_desc->ctrl.imm = get_unaligned((__be32 *)(ethh->h_dest + 2)); 636 */
637 ethh = (struct ethhdr *)skb->data;
638 tx_desc->ctrl.srcrb_flags16[0] = get_unaligned((__be16 *)ethh->h_dest);
639 tx_desc->ctrl.imm = get_unaligned((__be32 *)(ethh->h_dest + 2));
640 }
641
637 /* Handle LSO (TSO) packets */ 642 /* Handle LSO (TSO) packets */
638 if (lso_header_size) { 643 if (lso_header_size) {
639 /* Mark opcode as LSO */ 644 /* Mark opcode as LSO */
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index e1bafffbc3b1..a6542d75374c 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -1790,15 +1790,8 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
1790 int i; 1790 int i;
1791 1791
1792 if (msi_x) { 1792 if (msi_x) {
1793 /* In multifunction mode each function gets 2 msi-X vectors 1793 nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs,
1794 * one for data path completions anf the other for asynch events 1794 nreq);
1795 * or command completions */
1796 if (mlx4_is_mfunc(dev)) {
1797 nreq = 2;
1798 } else {
1799 nreq = min_t(int, dev->caps.num_eqs -
1800 dev->caps.reserved_eqs, nreq);
1801 }
1802 1795
1803 entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL); 1796 entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL);
1804 if (!entries) 1797 if (!entries)
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
index bc165f4d0f65..695667d471a1 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
@@ -144,7 +144,7 @@ void netxen_release_tx_buffers(struct netxen_adapter *adapter)
144 buffrag->length, PCI_DMA_TODEVICE); 144 buffrag->length, PCI_DMA_TODEVICE);
145 buffrag->dma = 0ULL; 145 buffrag->dma = 0ULL;
146 } 146 }
147 for (j = 0; j < cmd_buf->frag_count; j++) { 147 for (j = 1; j < cmd_buf->frag_count; j++) {
148 buffrag++; 148 buffrag++;
149 if (buffrag->dma) { 149 if (buffrag->dma) {
150 pci_unmap_page(adapter->pdev, buffrag->dma, 150 pci_unmap_page(adapter->pdev, buffrag->dma,
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
index 6098fd4adfeb..69e321a65077 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
@@ -1963,10 +1963,12 @@ unwind:
1963 while (--i >= 0) { 1963 while (--i >= 0) {
1964 nf = &pbuf->frag_array[i+1]; 1964 nf = &pbuf->frag_array[i+1];
1965 pci_unmap_page(pdev, nf->dma, nf->length, PCI_DMA_TODEVICE); 1965 pci_unmap_page(pdev, nf->dma, nf->length, PCI_DMA_TODEVICE);
1966 nf->dma = 0ULL;
1966 } 1967 }
1967 1968
1968 nf = &pbuf->frag_array[0]; 1969 nf = &pbuf->frag_array[0];
1969 pci_unmap_single(pdev, nf->dma, skb_headlen(skb), PCI_DMA_TODEVICE); 1970 pci_unmap_single(pdev, nf->dma, skb_headlen(skb), PCI_DMA_TODEVICE);
1971 nf->dma = 0ULL;
1970 1972
1971out_err: 1973out_err:
1972 return -ENOMEM; 1974 return -ENOMEM;
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index ed96f309bca8..11702324a071 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -1826,8 +1826,6 @@ static void rtl8169_rx_vlan_tag(struct RxDesc *desc, struct sk_buff *skb)
1826 1826
1827 if (opts2 & RxVlanTag) 1827 if (opts2 & RxVlanTag)
1828 __vlan_hwaccel_put_tag(skb, swab16(opts2 & 0xffff)); 1828 __vlan_hwaccel_put_tag(skb, swab16(opts2 & 0xffff));
1829
1830 desc->opts2 = 0;
1831} 1829}
1832 1830
1833static int rtl8169_gset_tbi(struct net_device *dev, struct ethtool_cmd *cmd) 1831static int rtl8169_gset_tbi(struct net_device *dev, struct ethtool_cmd *cmd)
@@ -6064,8 +6062,6 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget
6064 !(status & (RxRWT | RxFOVF)) && 6062 !(status & (RxRWT | RxFOVF)) &&
6065 (dev->features & NETIF_F_RXALL)) 6063 (dev->features & NETIF_F_RXALL))
6066 goto process_pkt; 6064 goto process_pkt;
6067
6068 rtl8169_mark_to_asic(desc, rx_buf_sz);
6069 } else { 6065 } else {
6070 struct sk_buff *skb; 6066 struct sk_buff *skb;
6071 dma_addr_t addr; 6067 dma_addr_t addr;
@@ -6086,16 +6082,14 @@ process_pkt:
6086 if (unlikely(rtl8169_fragmented_frame(status))) { 6082 if (unlikely(rtl8169_fragmented_frame(status))) {
6087 dev->stats.rx_dropped++; 6083 dev->stats.rx_dropped++;
6088 dev->stats.rx_length_errors++; 6084 dev->stats.rx_length_errors++;
6089 rtl8169_mark_to_asic(desc, rx_buf_sz); 6085 goto release_descriptor;
6090 continue;
6091 } 6086 }
6092 6087
6093 skb = rtl8169_try_rx_copy(tp->Rx_databuff[entry], 6088 skb = rtl8169_try_rx_copy(tp->Rx_databuff[entry],
6094 tp, pkt_size, addr); 6089 tp, pkt_size, addr);
6095 rtl8169_mark_to_asic(desc, rx_buf_sz);
6096 if (!skb) { 6090 if (!skb) {
6097 dev->stats.rx_dropped++; 6091 dev->stats.rx_dropped++;
6098 continue; 6092 goto release_descriptor;
6099 } 6093 }
6100 6094
6101 rtl8169_rx_csum(skb, status); 6095 rtl8169_rx_csum(skb, status);
@@ -6111,13 +6105,10 @@ process_pkt:
6111 tp->rx_stats.bytes += pkt_size; 6105 tp->rx_stats.bytes += pkt_size;
6112 u64_stats_update_end(&tp->rx_stats.syncp); 6106 u64_stats_update_end(&tp->rx_stats.syncp);
6113 } 6107 }
6114 6108release_descriptor:
6115 /* Work around for AMD plateform. */ 6109 desc->opts2 = 0;
6116 if ((desc->opts2 & cpu_to_le32(0xfffe000)) && 6110 wmb();
6117 (tp->mac_version == RTL_GIGA_MAC_VER_05)) { 6111 rtl8169_mark_to_asic(desc, rx_buf_sz);
6118 desc->opts2 = 0;
6119 cur_rx++;
6120 }
6121 } 6112 }
6122 6113
6123 count = cur_rx - tp->cur_rx; 6114 count = cur_rx - tp->cur_rx;
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 5fd6f4674326..e6fe0d80d612 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -84,7 +84,7 @@ struct hv_netvsc_packet {
84}; 84};
85 85
86struct netvsc_device_info { 86struct netvsc_device_info {
87 unsigned char mac_adr[6]; 87 unsigned char mac_adr[ETH_ALEN];
88 bool link_state; /* 0 - link up, 1 - link down */ 88 bool link_state; /* 0 - link up, 1 - link down */
89 int ring_size; 89 int ring_size;
90}; 90};
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index f825a629a699..8264f0ef7692 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -349,7 +349,7 @@ static int netvsc_set_mac_addr(struct net_device *ndev, void *p)
349 struct net_device_context *ndevctx = netdev_priv(ndev); 349 struct net_device_context *ndevctx = netdev_priv(ndev);
350 struct hv_device *hdev = ndevctx->device_ctx; 350 struct hv_device *hdev = ndevctx->device_ctx;
351 struct sockaddr *addr = p; 351 struct sockaddr *addr = p;
352 char save_adr[14]; 352 char save_adr[ETH_ALEN];
353 unsigned char save_aatype; 353 unsigned char save_aatype;
354 int err; 354 int err;
355 355
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 81f8f9e31db5..fcbf680c3e62 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -77,6 +77,11 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
77 77
78 skb_orphan(skb); 78 skb_orphan(skb);
79 79
80 /* Before queueing this packet to netif_rx(),
81 * make sure dst is refcounted.
82 */
83 skb_dst_force(skb);
84
80 skb->protocol = eth_type_trans(skb, dev); 85 skb->protocol = eth_type_trans(skb, dev);
81 86
82 /* it's OK to use per_cpu_ptr() because BHs are off */ 87 /* it's OK to use per_cpu_ptr() because BHs are off */
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 68a43fe602e7..d3fb97d97cbc 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -822,7 +822,10 @@ static int macvlan_changelink(struct net_device *dev,
822 822
823static size_t macvlan_get_size(const struct net_device *dev) 823static size_t macvlan_get_size(const struct net_device *dev)
824{ 824{
825 return nla_total_size(4); 825 return (0
826 + nla_total_size(4) /* IFLA_MACVLAN_MODE */
827 + nla_total_size(2) /* IFLA_MACVLAN_FLAGS */
828 );
826} 829}
827 830
828static int macvlan_fill_info(struct sk_buff *skb, 831static int macvlan_fill_info(struct sk_buff *skb,
diff --git a/drivers/net/phy/icplus.c b/drivers/net/phy/icplus.c
index d5199cb4caec..b5ddd5077a80 100644
--- a/drivers/net/phy/icplus.c
+++ b/drivers/net/phy/icplus.c
@@ -36,8 +36,9 @@ MODULE_LICENSE("GPL");
36 36
37/* IP101A/G - IP1001 */ 37/* IP101A/G - IP1001 */
38#define IP10XX_SPEC_CTRL_STATUS 16 /* Spec. Control Register */ 38#define IP10XX_SPEC_CTRL_STATUS 16 /* Spec. Control Register */
39#define IP1001_RXPHASE_SEL (1<<0) /* Add delay on RX_CLK */
40#define IP1001_TXPHASE_SEL (1<<1) /* Add delay on TX_CLK */
39#define IP1001_SPEC_CTRL_STATUS_2 20 /* IP1001 Spec. Control Reg 2 */ 41#define IP1001_SPEC_CTRL_STATUS_2 20 /* IP1001 Spec. Control Reg 2 */
40#define IP1001_PHASE_SEL_MASK 3 /* IP1001 RX/TXPHASE_SEL */
41#define IP1001_APS_ON 11 /* IP1001 APS Mode bit */ 42#define IP1001_APS_ON 11 /* IP1001 APS Mode bit */
42#define IP101A_G_APS_ON 2 /* IP101A/G APS Mode bit */ 43#define IP101A_G_APS_ON 2 /* IP101A/G APS Mode bit */
43#define IP101A_G_IRQ_CONF_STATUS 0x11 /* Conf Info IRQ & Status Reg */ 44#define IP101A_G_IRQ_CONF_STATUS 0x11 /* Conf Info IRQ & Status Reg */
@@ -138,19 +139,24 @@ static int ip1001_config_init(struct phy_device *phydev)
138 if (c < 0) 139 if (c < 0)
139 return c; 140 return c;
140 141
141 /* INTR pin used: speed/link/duplex will cause an interrupt */ 142 if ((phydev->interface == PHY_INTERFACE_MODE_RGMII) ||
142 c = phy_write(phydev, IP101A_G_IRQ_CONF_STATUS, IP101A_G_IRQ_DEFAULT); 143 (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) ||
143 if (c < 0) 144 (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) ||
144 return c; 145 (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)) {
145 146
146 if (phydev->interface == PHY_INTERFACE_MODE_RGMII) {
147 /* Additional delay (2ns) used to adjust RX clock phase
148 * at RGMII interface */
149 c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS); 147 c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS);
150 if (c < 0) 148 if (c < 0)
151 return c; 149 return c;
152 150
153 c |= IP1001_PHASE_SEL_MASK; 151 c &= ~(IP1001_RXPHASE_SEL | IP1001_TXPHASE_SEL);
152
153 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
154 c |= (IP1001_RXPHASE_SEL | IP1001_TXPHASE_SEL);
155 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID)
156 c |= IP1001_RXPHASE_SEL;
157 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)
158 c |= IP1001_TXPHASE_SEL;
159
154 c = phy_write(phydev, IP10XX_SPEC_CTRL_STATUS, c); 160 c = phy_write(phydev, IP10XX_SPEC_CTRL_STATUS, c);
155 if (c < 0) 161 if (c < 0)
156 return c; 162 return c;
@@ -167,6 +173,11 @@ static int ip101a_g_config_init(struct phy_device *phydev)
167 if (c < 0) 173 if (c < 0)
168 return c; 174 return c;
169 175
176 /* INTR pin used: speed/link/duplex will cause an interrupt */
177 c = phy_write(phydev, IP101A_G_IRQ_CONF_STATUS, IP101A_G_IRQ_DEFAULT);
178 if (c < 0)
179 return c;
180
170 /* Enable Auto Power Saving mode */ 181 /* Enable Auto Power Saving mode */
171 c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS); 182 c = phy_read(phydev, IP10XX_SPEC_CTRL_STATUS);
172 c |= IP101A_G_APS_ON; 183 c |= IP101A_G_APS_ON;
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 5d2a3f215887..22dec9c7ef05 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -353,15 +353,6 @@ static int m88e1111_config_init(struct phy_device *phydev)
353 int err; 353 int err;
354 int temp; 354 int temp;
355 355
356 /* Enable Fiber/Copper auto selection */
357 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
358 temp &= ~MII_M1111_HWCFG_FIBER_COPPER_AUTO;
359 phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
360
361 temp = phy_read(phydev, MII_BMCR);
362 temp |= BMCR_RESET;
363 phy_write(phydev, MII_BMCR, temp);
364
365 if ((phydev->interface == PHY_INTERFACE_MODE_RGMII) || 356 if ((phydev->interface == PHY_INTERFACE_MODE_RGMII) ||
366 (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) || 357 (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) ||
367 (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) || 358 (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) ||
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index af372d0957fe..cc09b67c23bc 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -109,11 +109,11 @@ struct tap_filter {
109 unsigned char addr[FLT_EXACT_COUNT][ETH_ALEN]; 109 unsigned char addr[FLT_EXACT_COUNT][ETH_ALEN];
110}; 110};
111 111
112/* 1024 is probably a high enough limit: modern hypervisors seem to support on 112/* DEFAULT_MAX_NUM_RSS_QUEUES were choosed to let the rx/tx queues allocated for
113 * the order of 100-200 CPUs so this leaves us some breathing space if we want 113 * the netdevice to be fit in one page. So we can make sure the success of
114 * to match a queue per guest CPU. 114 * memory allocation. TODO: increase the limit. */
115 */ 115#define MAX_TAP_QUEUES DEFAULT_MAX_NUM_RSS_QUEUES
116#define MAX_TAP_QUEUES 1024 116#define MAX_TAP_FLOWS 4096
117 117
118#define TUN_FLOW_EXPIRE (3 * HZ) 118#define TUN_FLOW_EXPIRE (3 * HZ)
119 119
@@ -185,6 +185,8 @@ struct tun_struct {
185 unsigned long ageing_time; 185 unsigned long ageing_time;
186 unsigned int numdisabled; 186 unsigned int numdisabled;
187 struct list_head disabled; 187 struct list_head disabled;
188 void *security;
189 u32 flow_count;
188}; 190};
189 191
190static inline u32 tun_hashfn(u32 rxhash) 192static inline u32 tun_hashfn(u32 rxhash)
@@ -218,6 +220,7 @@ static struct tun_flow_entry *tun_flow_create(struct tun_struct *tun,
218 e->queue_index = queue_index; 220 e->queue_index = queue_index;
219 e->tun = tun; 221 e->tun = tun;
220 hlist_add_head_rcu(&e->hash_link, head); 222 hlist_add_head_rcu(&e->hash_link, head);
223 ++tun->flow_count;
221 } 224 }
222 return e; 225 return e;
223} 226}
@@ -228,6 +231,7 @@ static void tun_flow_delete(struct tun_struct *tun, struct tun_flow_entry *e)
228 e->rxhash, e->queue_index); 231 e->rxhash, e->queue_index);
229 hlist_del_rcu(&e->hash_link); 232 hlist_del_rcu(&e->hash_link);
230 kfree_rcu(e, rcu); 233 kfree_rcu(e, rcu);
234 --tun->flow_count;
231} 235}
232 236
233static void tun_flow_flush(struct tun_struct *tun) 237static void tun_flow_flush(struct tun_struct *tun)
@@ -317,7 +321,8 @@ static void tun_flow_update(struct tun_struct *tun, u32 rxhash,
317 e->updated = jiffies; 321 e->updated = jiffies;
318 } else { 322 } else {
319 spin_lock_bh(&tun->lock); 323 spin_lock_bh(&tun->lock);
320 if (!tun_flow_find(head, rxhash)) 324 if (!tun_flow_find(head, rxhash) &&
325 tun->flow_count < MAX_TAP_FLOWS)
321 tun_flow_create(tun, head, rxhash, queue_index); 326 tun_flow_create(tun, head, rxhash, queue_index);
322 327
323 if (!timer_pending(&tun->flow_gc_timer)) 328 if (!timer_pending(&tun->flow_gc_timer))
@@ -490,6 +495,10 @@ static int tun_attach(struct tun_struct *tun, struct file *file)
490 struct tun_file *tfile = file->private_data; 495 struct tun_file *tfile = file->private_data;
491 int err; 496 int err;
492 497
498 err = security_tun_dev_attach(tfile->socket.sk, tun->security);
499 if (err < 0)
500 goto out;
501
493 err = -EINVAL; 502 err = -EINVAL;
494 if (rtnl_dereference(tfile->tun)) 503 if (rtnl_dereference(tfile->tun))
495 goto out; 504 goto out;
@@ -1373,6 +1382,7 @@ static void tun_free_netdev(struct net_device *dev)
1373 1382
1374 BUG_ON(!(list_empty(&tun->disabled))); 1383 BUG_ON(!(list_empty(&tun->disabled)));
1375 tun_flow_uninit(tun); 1384 tun_flow_uninit(tun);
1385 security_tun_dev_free_security(tun->security);
1376 free_netdev(dev); 1386 free_netdev(dev);
1377} 1387}
1378 1388
@@ -1562,7 +1572,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1562 1572
1563 if (tun_not_capable(tun)) 1573 if (tun_not_capable(tun))
1564 return -EPERM; 1574 return -EPERM;
1565 err = security_tun_dev_attach(tfile->socket.sk); 1575 err = security_tun_dev_open(tun->security);
1566 if (err < 0) 1576 if (err < 0)
1567 return err; 1577 return err;
1568 1578
@@ -1577,6 +1587,8 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1577 else { 1587 else {
1578 char *name; 1588 char *name;
1579 unsigned long flags = 0; 1589 unsigned long flags = 0;
1590 int queues = ifr->ifr_flags & IFF_MULTI_QUEUE ?
1591 MAX_TAP_QUEUES : 1;
1580 1592
1581 if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) 1593 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
1582 return -EPERM; 1594 return -EPERM;
@@ -1600,8 +1612,8 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1600 name = ifr->ifr_name; 1612 name = ifr->ifr_name;
1601 1613
1602 dev = alloc_netdev_mqs(sizeof(struct tun_struct), name, 1614 dev = alloc_netdev_mqs(sizeof(struct tun_struct), name,
1603 tun_setup, 1615 tun_setup, queues, queues);
1604 MAX_TAP_QUEUES, MAX_TAP_QUEUES); 1616
1605 if (!dev) 1617 if (!dev)
1606 return -ENOMEM; 1618 return -ENOMEM;
1607 1619
@@ -1619,7 +1631,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1619 1631
1620 spin_lock_init(&tun->lock); 1632 spin_lock_init(&tun->lock);
1621 1633
1622 security_tun_dev_post_create(&tfile->sk); 1634 err = security_tun_dev_alloc_security(&tun->security);
1635 if (err < 0)
1636 goto err_free_dev;
1623 1637
1624 tun_net_init(dev); 1638 tun_net_init(dev);
1625 1639
@@ -1789,10 +1803,14 @@ static int tun_set_queue(struct file *file, struct ifreq *ifr)
1789 1803
1790 if (ifr->ifr_flags & IFF_ATTACH_QUEUE) { 1804 if (ifr->ifr_flags & IFF_ATTACH_QUEUE) {
1791 tun = tfile->detached; 1805 tun = tfile->detached;
1792 if (!tun) 1806 if (!tun) {
1793 ret = -EINVAL; 1807 ret = -EINVAL;
1794 else 1808 goto unlock;
1795 ret = tun_attach(tun, file); 1809 }
1810 ret = security_tun_dev_attach_queue(tun->security);
1811 if (ret < 0)
1812 goto unlock;
1813 ret = tun_attach(tun, file);
1796 } else if (ifr->ifr_flags & IFF_DETACH_QUEUE) { 1814 } else if (ifr->ifr_flags & IFF_DETACH_QUEUE) {
1797 tun = rtnl_dereference(tfile->tun); 1815 tun = rtnl_dereference(tfile->tun);
1798 if (!tun || !(tun->flags & TUN_TAP_MQ)) 1816 if (!tun || !(tun->flags & TUN_TAP_MQ))
@@ -1802,6 +1820,7 @@ static int tun_set_queue(struct file *file, struct ifreq *ifr)
1802 } else 1820 } else
1803 ret = -EINVAL; 1821 ret = -EINVAL;
1804 1822
1823unlock:
1805 rtnl_unlock(); 1824 rtnl_unlock();
1806 return ret; 1825 return ret;
1807} 1826}
diff --git a/drivers/net/usb/cdc_mbim.c b/drivers/net/usb/cdc_mbim.c
index 42f51c71ec1f..248d2dc765a5 100644
--- a/drivers/net/usb/cdc_mbim.c
+++ b/drivers/net/usb/cdc_mbim.c
@@ -374,6 +374,21 @@ static const struct driver_info cdc_mbim_info = {
374 .tx_fixup = cdc_mbim_tx_fixup, 374 .tx_fixup = cdc_mbim_tx_fixup,
375}; 375};
376 376
377/* MBIM and NCM devices should not need a ZLP after NTBs with
378 * dwNtbOutMaxSize length. This driver_info is for the exceptional
379 * devices requiring it anyway, allowing them to be supported without
380 * forcing the performance penalty on all the sane devices.
381 */
382static const struct driver_info cdc_mbim_info_zlp = {
383 .description = "CDC MBIM",
384 .flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET | FLAG_WWAN | FLAG_SEND_ZLP,
385 .bind = cdc_mbim_bind,
386 .unbind = cdc_mbim_unbind,
387 .manage_power = cdc_mbim_manage_power,
388 .rx_fixup = cdc_mbim_rx_fixup,
389 .tx_fixup = cdc_mbim_tx_fixup,
390};
391
377static const struct usb_device_id mbim_devs[] = { 392static const struct usb_device_id mbim_devs[] = {
378 /* This duplicate NCM entry is intentional. MBIM devices can 393 /* This duplicate NCM entry is intentional. MBIM devices can
379 * be disguised as NCM by default, and this is necessary to 394 * be disguised as NCM by default, and this is necessary to
@@ -385,6 +400,10 @@ static const struct usb_device_id mbim_devs[] = {
385 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE), 400 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE),
386 .driver_info = (unsigned long)&cdc_mbim_info, 401 .driver_info = (unsigned long)&cdc_mbim_info,
387 }, 402 },
403 /* Sierra Wireless MC7710 need ZLPs */
404 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x68a2, USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE),
405 .driver_info = (unsigned long)&cdc_mbim_info_zlp,
406 },
388 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE), 407 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE),
389 .driver_info = (unsigned long)&cdc_mbim_info, 408 .driver_info = (unsigned long)&cdc_mbim_info,
390 }, 409 },
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 71b6e92b8e9b..9197b2c72ca3 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -435,6 +435,13 @@ advance:
435 len -= temp; 435 len -= temp;
436 } 436 }
437 437
438 /* some buggy devices have an IAD but no CDC Union */
439 if (!ctx->union_desc && intf->intf_assoc && intf->intf_assoc->bInterfaceCount == 2) {
440 ctx->control = intf;
441 ctx->data = usb_ifnum_to_if(dev->udev, intf->cur_altsetting->desc.bInterfaceNumber + 1);
442 dev_dbg(&intf->dev, "CDC Union missing - got slave from IAD\n");
443 }
444
438 /* check if we got everything */ 445 /* check if we got everything */
439 if ((ctx->control == NULL) || (ctx->data == NULL) || 446 if ((ctx->control == NULL) || (ctx->data == NULL) ||
440 ((!ctx->mbim_desc) && ((ctx->ether_desc == NULL) || (ctx->control != intf)))) 447 ((!ctx->mbim_desc) && ((ctx->ether_desc == NULL) || (ctx->control != intf))))
@@ -497,7 +504,8 @@ advance:
497error2: 504error2:
498 usb_set_intfdata(ctx->control, NULL); 505 usb_set_intfdata(ctx->control, NULL);
499 usb_set_intfdata(ctx->data, NULL); 506 usb_set_intfdata(ctx->data, NULL);
500 usb_driver_release_interface(driver, ctx->data); 507 if (ctx->data != ctx->control)
508 usb_driver_release_interface(driver, ctx->data);
501error: 509error:
502 cdc_ncm_free((struct cdc_ncm_ctx *)dev->data[0]); 510 cdc_ncm_free((struct cdc_ncm_ctx *)dev->data[0]);
503 dev->data[0] = 0; 511 dev->data[0] = 0;
@@ -1155,6 +1163,20 @@ static const struct driver_info wwan_info = {
1155 .tx_fixup = cdc_ncm_tx_fixup, 1163 .tx_fixup = cdc_ncm_tx_fixup,
1156}; 1164};
1157 1165
1166/* Same as wwan_info, but with FLAG_NOARP */
1167static const struct driver_info wwan_noarp_info = {
1168 .description = "Mobile Broadband Network Device (NO ARP)",
1169 .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
1170 | FLAG_WWAN | FLAG_NOARP,
1171 .bind = cdc_ncm_bind,
1172 .unbind = cdc_ncm_unbind,
1173 .check_connect = cdc_ncm_check_connect,
1174 .manage_power = usbnet_manage_power,
1175 .status = cdc_ncm_status,
1176 .rx_fixup = cdc_ncm_rx_fixup,
1177 .tx_fixup = cdc_ncm_tx_fixup,
1178};
1179
1158static const struct usb_device_id cdc_devs[] = { 1180static const struct usb_device_id cdc_devs[] = {
1159 /* Ericsson MBM devices like F5521gw */ 1181 /* Ericsson MBM devices like F5521gw */
1160 { .match_flags = USB_DEVICE_ID_MATCH_INT_INFO 1182 { .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
@@ -1194,6 +1216,13 @@ static const struct usb_device_id cdc_devs[] = {
1194 .driver_info = (unsigned long)&wwan_info, 1216 .driver_info = (unsigned long)&wwan_info,
1195 }, 1217 },
1196 1218
1219 /* Infineon(now Intel) HSPA Modem platform */
1220 { USB_DEVICE_AND_INTERFACE_INFO(0x1519, 0x0443,
1221 USB_CLASS_COMM,
1222 USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE),
1223 .driver_info = (unsigned long)&wwan_noarp_info,
1224 },
1225
1197 /* Generic CDC-NCM devices */ 1226 /* Generic CDC-NCM devices */
1198 { USB_INTERFACE_INFO(USB_CLASS_COMM, 1227 { USB_INTERFACE_INFO(USB_CLASS_COMM,
1199 USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE), 1228 USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE),
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index 3f554c1149f3..d7e99445518e 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -45,6 +45,12 @@
45#define DM_MCAST_ADDR 0x16 /* 8 bytes */ 45#define DM_MCAST_ADDR 0x16 /* 8 bytes */
46#define DM_GPR_CTRL 0x1e 46#define DM_GPR_CTRL 0x1e
47#define DM_GPR_DATA 0x1f 47#define DM_GPR_DATA 0x1f
48#define DM_CHIP_ID 0x2c
49#define DM_MODE_CTRL 0x91 /* only on dm9620 */
50
51/* chip id values */
52#define ID_DM9601 0
53#define ID_DM9620 1
48 54
49#define DM_MAX_MCAST 64 55#define DM_MAX_MCAST 64
50#define DM_MCAST_SIZE 8 56#define DM_MCAST_SIZE 8
@@ -53,7 +59,6 @@
53#define DM_RX_OVERHEAD 7 /* 3 byte header + 4 byte crc tail */ 59#define DM_RX_OVERHEAD 7 /* 3 byte header + 4 byte crc tail */
54#define DM_TIMEOUT 1000 60#define DM_TIMEOUT 1000
55 61
56
57static int dm_read(struct usbnet *dev, u8 reg, u16 length, void *data) 62static int dm_read(struct usbnet *dev, u8 reg, u16 length, void *data)
58{ 63{
59 int err; 64 int err;
@@ -84,32 +89,23 @@ static int dm_write(struct usbnet *dev, u8 reg, u16 length, void *data)
84 89
85static int dm_write_reg(struct usbnet *dev, u8 reg, u8 value) 90static int dm_write_reg(struct usbnet *dev, u8 reg, u8 value)
86{ 91{
87 return usbnet_write_cmd(dev, DM_WRITE_REGS, 92 return usbnet_write_cmd(dev, DM_WRITE_REG,
88 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 93 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
89 value, reg, NULL, 0); 94 value, reg, NULL, 0);
90} 95}
91 96
92static void dm_write_async_helper(struct usbnet *dev, u8 reg, u8 value, 97static void dm_write_async(struct usbnet *dev, u8 reg, u16 length, void *data)
93 u16 length, void *data)
94{ 98{
95 usbnet_write_cmd_async(dev, DM_WRITE_REGS, 99 usbnet_write_cmd_async(dev, DM_WRITE_REGS,
96 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 100 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
97 value, reg, data, length); 101 0, reg, data, length);
98}
99
100static void dm_write_async(struct usbnet *dev, u8 reg, u16 length, void *data)
101{
102 netdev_dbg(dev->net, "dm_write_async() reg=0x%02x length=%d\n", reg, length);
103
104 dm_write_async_helper(dev, reg, 0, length, data);
105} 102}
106 103
107static void dm_write_reg_async(struct usbnet *dev, u8 reg, u8 value) 104static void dm_write_reg_async(struct usbnet *dev, u8 reg, u8 value)
108{ 105{
109 netdev_dbg(dev->net, "dm_write_reg_async() reg=0x%02x value=0x%02x\n", 106 usbnet_write_cmd_async(dev, DM_WRITE_REG,
110 reg, value); 107 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
111 108 value, reg, NULL, 0);
112 dm_write_async_helper(dev, reg, value, 0, NULL);
113} 109}
114 110
115static int dm_read_shared_word(struct usbnet *dev, int phy, u8 reg, __le16 *value) 111static int dm_read_shared_word(struct usbnet *dev, int phy, u8 reg, __le16 *value)
@@ -358,7 +354,7 @@ static const struct net_device_ops dm9601_netdev_ops = {
358static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf) 354static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf)
359{ 355{
360 int ret; 356 int ret;
361 u8 mac[ETH_ALEN]; 357 u8 mac[ETH_ALEN], id;
362 358
363 ret = usbnet_get_endpoints(dev, intf); 359 ret = usbnet_get_endpoints(dev, intf);
364 if (ret) 360 if (ret)
@@ -399,6 +395,24 @@ static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf)
399 __dm9601_set_mac_address(dev); 395 __dm9601_set_mac_address(dev);
400 } 396 }
401 397
398 if (dm_read_reg(dev, DM_CHIP_ID, &id) < 0) {
399 netdev_err(dev->net, "Error reading chip ID\n");
400 ret = -ENODEV;
401 goto out;
402 }
403
404 /* put dm9620 devices in dm9601 mode */
405 if (id == ID_DM9620) {
406 u8 mode;
407
408 if (dm_read_reg(dev, DM_MODE_CTRL, &mode) < 0) {
409 netdev_err(dev->net, "Error reading MODE_CTRL\n");
410 ret = -ENODEV;
411 goto out;
412 }
413 dm_write_reg(dev, DM_MODE_CTRL, mode & 0x7f);
414 }
415
402 /* power up phy */ 416 /* power up phy */
403 dm_write_reg(dev, DM_GPR_CTRL, 1); 417 dm_write_reg(dev, DM_GPR_CTRL, 1);
404 dm_write_reg(dev, DM_GPR_DATA, 0); 418 dm_write_reg(dev, DM_GPR_DATA, 0);
@@ -581,6 +595,10 @@ static const struct usb_device_id products[] = {
581 USB_DEVICE(0x0a46, 0x9000), /* DM9000E */ 595 USB_DEVICE(0x0a46, 0x9000), /* DM9000E */
582 .driver_info = (unsigned long)&dm9601_info, 596 .driver_info = (unsigned long)&dm9601_info,
583 }, 597 },
598 {
599 USB_DEVICE(0x0a46, 0x9620), /* DM9620 USB to Fast Ethernet Adapter */
600 .driver_info = (unsigned long)&dm9601_info,
601 },
584 {}, // END 602 {}, // END
585}; 603};
586 604
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 6a1ca500e612..575a5839ee34 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -433,6 +433,7 @@ static const struct usb_device_id products[] = {
433 {QMI_FIXED_INTF(0x19d2, 0x0199, 1)}, /* ZTE MF820S */ 433 {QMI_FIXED_INTF(0x19d2, 0x0199, 1)}, /* ZTE MF820S */
434 {QMI_FIXED_INTF(0x19d2, 0x0200, 1)}, 434 {QMI_FIXED_INTF(0x19d2, 0x0200, 1)},
435 {QMI_FIXED_INTF(0x19d2, 0x0257, 3)}, /* ZTE MF821 */ 435 {QMI_FIXED_INTF(0x19d2, 0x0257, 3)}, /* ZTE MF821 */
436 {QMI_FIXED_INTF(0x19d2, 0x0265, 4)}, /* ONDA MT8205 4G LTE */
436 {QMI_FIXED_INTF(0x19d2, 0x0284, 4)}, /* ZTE MF880 */ 437 {QMI_FIXED_INTF(0x19d2, 0x0284, 4)}, /* ZTE MF880 */
437 {QMI_FIXED_INTF(0x19d2, 0x0326, 4)}, /* ZTE MF821D */ 438 {QMI_FIXED_INTF(0x19d2, 0x0326, 4)}, /* ZTE MF821D */
438 {QMI_FIXED_INTF(0x19d2, 0x1008, 4)}, /* ZTE (Vodafone) K3570-Z */ 439 {QMI_FIXED_INTF(0x19d2, 0x1008, 4)}, /* ZTE (Vodafone) K3570-Z */
@@ -459,6 +460,7 @@ static const struct usb_device_id products[] = {
459 {QMI_FIXED_INTF(0x1199, 0x68a2, 19)}, /* Sierra Wireless MC7710 in QMI mode */ 460 {QMI_FIXED_INTF(0x1199, 0x68a2, 19)}, /* Sierra Wireless MC7710 in QMI mode */
460 {QMI_FIXED_INTF(0x1199, 0x901c, 8)}, /* Sierra Wireless EM7700 */ 461 {QMI_FIXED_INTF(0x1199, 0x901c, 8)}, /* Sierra Wireless EM7700 */
461 {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)}, /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */ 462 {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)}, /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */
463 {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */
462 464
463 /* 4. Gobi 1000 devices */ 465 /* 4. Gobi 1000 devices */
464 {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ 466 {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 3d4bf01641b4..f34b2ebee815 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1448,6 +1448,10 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1448 if ((dev->driver_info->flags & FLAG_WWAN) != 0) 1448 if ((dev->driver_info->flags & FLAG_WWAN) != 0)
1449 strcpy(net->name, "wwan%d"); 1449 strcpy(net->name, "wwan%d");
1450 1450
1451 /* devices that cannot do ARP */
1452 if ((dev->driver_info->flags & FLAG_NOARP) != 0)
1453 net->flags |= IFF_NOARP;
1454
1451 /* maybe the remote can't receive an Ethernet MTU */ 1455 /* maybe the remote can't receive an Ethernet MTU */
1452 if (net->mtu > (dev->hard_mtu - net->hard_header_len)) 1456 if (net->mtu > (dev->hard_mtu - net->hard_header_len))
1453 net->mtu = dev->hard_mtu - net->hard_header_len; 1457 net->mtu = dev->hard_mtu - net->hard_header_len;
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index a6fcf15adc4f..35c00c5ea02a 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -26,6 +26,7 @@
26#include <linux/scatterlist.h> 26#include <linux/scatterlist.h>
27#include <linux/if_vlan.h> 27#include <linux/if_vlan.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/cpu.h>
29 30
30static int napi_weight = 128; 31static int napi_weight = 128;
31module_param(napi_weight, int, 0444); 32module_param(napi_weight, int, 0444);
@@ -123,6 +124,12 @@ struct virtnet_info {
123 124
124 /* Does the affinity hint is set for virtqueues? */ 125 /* Does the affinity hint is set for virtqueues? */
125 bool affinity_hint_set; 126 bool affinity_hint_set;
127
128 /* Per-cpu variable to show the mapping from CPU to virtqueue */
129 int __percpu *vq_index;
130
131 /* CPU hot plug notifier */
132 struct notifier_block nb;
126}; 133};
127 134
128struct skb_vnet_hdr { 135struct skb_vnet_hdr {
@@ -1013,32 +1020,75 @@ static int virtnet_vlan_rx_kill_vid(struct net_device *dev, u16 vid)
1013 return 0; 1020 return 0;
1014} 1021}
1015 1022
1016static void virtnet_set_affinity(struct virtnet_info *vi, bool set) 1023static void virtnet_clean_affinity(struct virtnet_info *vi, long hcpu)
1017{ 1024{
1018 int i; 1025 int i;
1026 int cpu;
1027
1028 if (vi->affinity_hint_set) {
1029 for (i = 0; i < vi->max_queue_pairs; i++) {
1030 virtqueue_set_affinity(vi->rq[i].vq, -1);
1031 virtqueue_set_affinity(vi->sq[i].vq, -1);
1032 }
1033
1034 vi->affinity_hint_set = false;
1035 }
1036
1037 i = 0;
1038 for_each_online_cpu(cpu) {
1039 if (cpu == hcpu) {
1040 *per_cpu_ptr(vi->vq_index, cpu) = -1;
1041 } else {
1042 *per_cpu_ptr(vi->vq_index, cpu) =
1043 ++i % vi->curr_queue_pairs;
1044 }
1045 }
1046}
1047
1048static void virtnet_set_affinity(struct virtnet_info *vi)
1049{
1050 int i;
1051 int cpu;
1019 1052
1020 /* In multiqueue mode, when the number of cpu is equal to the number of 1053 /* In multiqueue mode, when the number of cpu is equal to the number of
1021 * queue pairs, we let the queue pairs to be private to one cpu by 1054 * queue pairs, we let the queue pairs to be private to one cpu by
1022 * setting the affinity hint to eliminate the contention. 1055 * setting the affinity hint to eliminate the contention.
1023 */ 1056 */
1024 if ((vi->curr_queue_pairs == 1 || 1057 if (vi->curr_queue_pairs == 1 ||
1025 vi->max_queue_pairs != num_online_cpus()) && set) { 1058 vi->max_queue_pairs != num_online_cpus()) {
1026 if (vi->affinity_hint_set) 1059 virtnet_clean_affinity(vi, -1);
1027 set = false; 1060 return;
1028 else
1029 return;
1030 } 1061 }
1031 1062
1032 for (i = 0; i < vi->max_queue_pairs; i++) { 1063 i = 0;
1033 int cpu = set ? i : -1; 1064 for_each_online_cpu(cpu) {
1034 virtqueue_set_affinity(vi->rq[i].vq, cpu); 1065 virtqueue_set_affinity(vi->rq[i].vq, cpu);
1035 virtqueue_set_affinity(vi->sq[i].vq, cpu); 1066 virtqueue_set_affinity(vi->sq[i].vq, cpu);
1067 *per_cpu_ptr(vi->vq_index, cpu) = i;
1068 i++;
1036 } 1069 }
1037 1070
1038 if (set) 1071 vi->affinity_hint_set = true;
1039 vi->affinity_hint_set = true; 1072}
1040 else 1073
1041 vi->affinity_hint_set = false; 1074static int virtnet_cpu_callback(struct notifier_block *nfb,
1075 unsigned long action, void *hcpu)
1076{
1077 struct virtnet_info *vi = container_of(nfb, struct virtnet_info, nb);
1078
1079 switch(action & ~CPU_TASKS_FROZEN) {
1080 case CPU_ONLINE:
1081 case CPU_DOWN_FAILED:
1082 case CPU_DEAD:
1083 virtnet_set_affinity(vi);
1084 break;
1085 case CPU_DOWN_PREPARE:
1086 virtnet_clean_affinity(vi, (long)hcpu);
1087 break;
1088 default:
1089 break;
1090 }
1091 return NOTIFY_OK;
1042} 1092}
1043 1093
1044static void virtnet_get_ringparam(struct net_device *dev, 1094static void virtnet_get_ringparam(struct net_device *dev,
@@ -1082,13 +1132,15 @@ static int virtnet_set_channels(struct net_device *dev,
1082 if (queue_pairs > vi->max_queue_pairs) 1132 if (queue_pairs > vi->max_queue_pairs)
1083 return -EINVAL; 1133 return -EINVAL;
1084 1134
1135 get_online_cpus();
1085 err = virtnet_set_queues(vi, queue_pairs); 1136 err = virtnet_set_queues(vi, queue_pairs);
1086 if (!err) { 1137 if (!err) {
1087 netif_set_real_num_tx_queues(dev, queue_pairs); 1138 netif_set_real_num_tx_queues(dev, queue_pairs);
1088 netif_set_real_num_rx_queues(dev, queue_pairs); 1139 netif_set_real_num_rx_queues(dev, queue_pairs);
1089 1140
1090 virtnet_set_affinity(vi, true); 1141 virtnet_set_affinity(vi);
1091 } 1142 }
1143 put_online_cpus();
1092 1144
1093 return err; 1145 return err;
1094} 1146}
@@ -1127,12 +1179,19 @@ static int virtnet_change_mtu(struct net_device *dev, int new_mtu)
1127 1179
1128/* To avoid contending a lock hold by a vcpu who would exit to host, select the 1180/* To avoid contending a lock hold by a vcpu who would exit to host, select the
1129 * txq based on the processor id. 1181 * txq based on the processor id.
1130 * TODO: handle cpu hotplug.
1131 */ 1182 */
1132static u16 virtnet_select_queue(struct net_device *dev, struct sk_buff *skb) 1183static u16 virtnet_select_queue(struct net_device *dev, struct sk_buff *skb)
1133{ 1184{
1134 int txq = skb_rx_queue_recorded(skb) ? skb_get_rx_queue(skb) : 1185 int txq;
1135 smp_processor_id(); 1186 struct virtnet_info *vi = netdev_priv(dev);
1187
1188 if (skb_rx_queue_recorded(skb)) {
1189 txq = skb_get_rx_queue(skb);
1190 } else {
1191 txq = *__this_cpu_ptr(vi->vq_index);
1192 if (txq == -1)
1193 txq = 0;
1194 }
1136 1195
1137 while (unlikely(txq >= dev->real_num_tx_queues)) 1196 while (unlikely(txq >= dev->real_num_tx_queues))
1138 txq -= dev->real_num_tx_queues; 1197 txq -= dev->real_num_tx_queues;
@@ -1248,7 +1307,7 @@ static void virtnet_del_vqs(struct virtnet_info *vi)
1248{ 1307{
1249 struct virtio_device *vdev = vi->vdev; 1308 struct virtio_device *vdev = vi->vdev;
1250 1309
1251 virtnet_set_affinity(vi, false); 1310 virtnet_clean_affinity(vi, -1);
1252 1311
1253 vdev->config->del_vqs(vdev); 1312 vdev->config->del_vqs(vdev);
1254 1313
@@ -1371,7 +1430,10 @@ static int init_vqs(struct virtnet_info *vi)
1371 if (ret) 1430 if (ret)
1372 goto err_free; 1431 goto err_free;
1373 1432
1374 virtnet_set_affinity(vi, true); 1433 get_online_cpus();
1434 virtnet_set_affinity(vi);
1435 put_online_cpus();
1436
1375 return 0; 1437 return 0;
1376 1438
1377err_free: 1439err_free:
@@ -1453,6 +1515,10 @@ static int virtnet_probe(struct virtio_device *vdev)
1453 if (vi->stats == NULL) 1515 if (vi->stats == NULL)
1454 goto free; 1516 goto free;
1455 1517
1518 vi->vq_index = alloc_percpu(int);
1519 if (vi->vq_index == NULL)
1520 goto free_stats;
1521
1456 mutex_init(&vi->config_lock); 1522 mutex_init(&vi->config_lock);
1457 vi->config_enable = true; 1523 vi->config_enable = true;
1458 INIT_WORK(&vi->config_work, virtnet_config_changed_work); 1524 INIT_WORK(&vi->config_work, virtnet_config_changed_work);
@@ -1476,7 +1542,7 @@ static int virtnet_probe(struct virtio_device *vdev)
1476 /* Allocate/initialize the rx/tx queues, and invoke find_vqs */ 1542 /* Allocate/initialize the rx/tx queues, and invoke find_vqs */
1477 err = init_vqs(vi); 1543 err = init_vqs(vi);
1478 if (err) 1544 if (err)
1479 goto free_stats; 1545 goto free_index;
1480 1546
1481 netif_set_real_num_tx_queues(dev, 1); 1547 netif_set_real_num_tx_queues(dev, 1);
1482 netif_set_real_num_rx_queues(dev, 1); 1548 netif_set_real_num_rx_queues(dev, 1);
@@ -1499,6 +1565,13 @@ static int virtnet_probe(struct virtio_device *vdev)
1499 } 1565 }
1500 } 1566 }
1501 1567
1568 vi->nb.notifier_call = &virtnet_cpu_callback;
1569 err = register_hotcpu_notifier(&vi->nb);
1570 if (err) {
1571 pr_debug("virtio_net: registering cpu notifier failed\n");
1572 goto free_recv_bufs;
1573 }
1574
1502 /* Assume link up if device can't report link status, 1575 /* Assume link up if device can't report link status,
1503 otherwise get link status from config. */ 1576 otherwise get link status from config. */
1504 if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) { 1577 if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) {
@@ -1520,6 +1593,8 @@ free_recv_bufs:
1520free_vqs: 1593free_vqs:
1521 cancel_delayed_work_sync(&vi->refill); 1594 cancel_delayed_work_sync(&vi->refill);
1522 virtnet_del_vqs(vi); 1595 virtnet_del_vqs(vi);
1596free_index:
1597 free_percpu(vi->vq_index);
1523free_stats: 1598free_stats:
1524 free_percpu(vi->stats); 1599 free_percpu(vi->stats);
1525free: 1600free:
@@ -1543,6 +1618,8 @@ static void virtnet_remove(struct virtio_device *vdev)
1543{ 1618{
1544 struct virtnet_info *vi = vdev->priv; 1619 struct virtnet_info *vi = vdev->priv;
1545 1620
1621 unregister_hotcpu_notifier(&vi->nb);
1622
1546 /* Prevent config work handler from accessing the device. */ 1623 /* Prevent config work handler from accessing the device. */
1547 mutex_lock(&vi->config_lock); 1624 mutex_lock(&vi->config_lock);
1548 vi->config_enable = false; 1625 vi->config_enable = false;
@@ -1554,6 +1631,7 @@ static void virtnet_remove(struct virtio_device *vdev)
1554 1631
1555 flush_work(&vi->config_work); 1632 flush_work(&vi->config_work);
1556 1633
1634 free_percpu(vi->vq_index);
1557 free_percpu(vi->stats); 1635 free_percpu(vi->stats);
1558 free_netdev(vi->dev); 1636 free_netdev(vi->dev);
1559} 1637}
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
index 8b0d8dcd7625..56317b0fb6b6 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
@@ -976,6 +976,8 @@ static bool ar9003_hw_init_cal(struct ath_hw *ah,
976 AR_PHY_CL_TAB_1, 976 AR_PHY_CL_TAB_1,
977 AR_PHY_CL_TAB_2 }; 977 AR_PHY_CL_TAB_2 };
978 978
979 ar9003_hw_set_chain_masks(ah, ah->caps.rx_chainmask, ah->caps.tx_chainmask);
980
979 if (rtt) { 981 if (rtt) {
980 if (!ar9003_hw_rtt_restore(ah, chan)) 982 if (!ar9003_hw_rtt_restore(ah, chan))
981 run_rtt_cal = true; 983 run_rtt_cal = true;
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
index ce19c09fa8e8..3afc24bde6d6 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -586,32 +586,19 @@ static void ar9003_hw_init_bb(struct ath_hw *ah,
586 ath9k_hw_synth_delay(ah, chan, synthDelay); 586 ath9k_hw_synth_delay(ah, chan, synthDelay);
587} 587}
588 588
589static void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx) 589void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx)
590{ 590{
591 switch (rx) { 591 if (ah->caps.tx_chainmask == 5 || ah->caps.rx_chainmask == 5)
592 case 0x5:
593 REG_SET_BIT(ah, AR_PHY_ANALOG_SWAP, 592 REG_SET_BIT(ah, AR_PHY_ANALOG_SWAP,
594 AR_PHY_SWAP_ALT_CHAIN); 593 AR_PHY_SWAP_ALT_CHAIN);
595 case 0x3: 594
596 case 0x1: 595 REG_WRITE(ah, AR_PHY_RX_CHAINMASK, rx);
597 case 0x2: 596 REG_WRITE(ah, AR_PHY_CAL_CHAINMASK, rx);
598 case 0x7:
599 REG_WRITE(ah, AR_PHY_RX_CHAINMASK, rx);
600 REG_WRITE(ah, AR_PHY_CAL_CHAINMASK, rx);
601 break;
602 default:
603 break;
604 }
605 597
606 if ((ah->caps.hw_caps & ATH9K_HW_CAP_APM) && (tx == 0x7)) 598 if ((ah->caps.hw_caps & ATH9K_HW_CAP_APM) && (tx == 0x7))
607 REG_WRITE(ah, AR_SELFGEN_MASK, 0x3); 599 tx = 3;
608 else
609 REG_WRITE(ah, AR_SELFGEN_MASK, tx);
610 600
611 if (tx == 0x5) { 601 REG_WRITE(ah, AR_SELFGEN_MASK, tx);
612 REG_SET_BIT(ah, AR_PHY_ANALOG_SWAP,
613 AR_PHY_SWAP_ALT_CHAIN);
614 }
615} 602}
616 603
617/* 604/*
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 86e26a19efda..42794c546a40 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -317,7 +317,6 @@ struct ath_rx {
317 u32 *rxlink; 317 u32 *rxlink;
318 u32 num_pkts; 318 u32 num_pkts;
319 unsigned int rxfilter; 319 unsigned int rxfilter;
320 spinlock_t rxbuflock;
321 struct list_head rxbuf; 320 struct list_head rxbuf;
322 struct ath_descdma rxdma; 321 struct ath_descdma rxdma;
323 struct ath_buf *rx_bufptr; 322 struct ath_buf *rx_bufptr;
@@ -328,7 +327,6 @@ struct ath_rx {
328 327
329int ath_startrecv(struct ath_softc *sc); 328int ath_startrecv(struct ath_softc *sc);
330bool ath_stoprecv(struct ath_softc *sc); 329bool ath_stoprecv(struct ath_softc *sc);
331void ath_flushrecv(struct ath_softc *sc);
332u32 ath_calcrxfilter(struct ath_softc *sc); 330u32 ath_calcrxfilter(struct ath_softc *sc);
333int ath_rx_init(struct ath_softc *sc, int nbufs); 331int ath_rx_init(struct ath_softc *sc, int nbufs);
334void ath_rx_cleanup(struct ath_softc *sc); 332void ath_rx_cleanup(struct ath_softc *sc);
@@ -646,7 +644,6 @@ void ath_ant_comb_update(struct ath_softc *sc);
646enum sc_op_flags { 644enum sc_op_flags {
647 SC_OP_INVALID, 645 SC_OP_INVALID,
648 SC_OP_BEACONS, 646 SC_OP_BEACONS,
649 SC_OP_RXFLUSH,
650 SC_OP_ANI_RUN, 647 SC_OP_ANI_RUN,
651 SC_OP_PRIM_STA_VIF, 648 SC_OP_PRIM_STA_VIF,
652 SC_OP_HW_RESET, 649 SC_OP_HW_RESET,
diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
index 531fffd801a3..2ca355e94da6 100644
--- a/drivers/net/wireless/ath/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ -147,6 +147,7 @@ static struct ath_buf *ath9k_beacon_generate(struct ieee80211_hw *hw,
147 skb->len, DMA_TO_DEVICE); 147 skb->len, DMA_TO_DEVICE);
148 dev_kfree_skb_any(skb); 148 dev_kfree_skb_any(skb);
149 bf->bf_buf_addr = 0; 149 bf->bf_buf_addr = 0;
150 bf->bf_mpdu = NULL;
150 } 151 }
151 152
152 skb = ieee80211_beacon_get(hw, vif); 153 skb = ieee80211_beacon_get(hw, vif);
@@ -359,7 +360,6 @@ void ath9k_beacon_tasklet(unsigned long data)
359 return; 360 return;
360 361
361 bf = ath9k_beacon_generate(sc->hw, vif); 362 bf = ath9k_beacon_generate(sc->hw, vif);
362 WARN_ON(!bf);
363 363
364 if (sc->beacon.bmisscnt != 0) { 364 if (sc->beacon.bmisscnt != 0) {
365 ath_dbg(common, BSTUCK, "resume beacon xmit after %u misses\n", 365 ath_dbg(common, BSTUCK, "resume beacon xmit after %u misses\n",
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 13ff9edc2401..e585fc827c50 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -861,7 +861,6 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
861 RXS_ERR("RX-LENGTH-ERR", rx_len_err); 861 RXS_ERR("RX-LENGTH-ERR", rx_len_err);
862 RXS_ERR("RX-OOM-ERR", rx_oom_err); 862 RXS_ERR("RX-OOM-ERR", rx_oom_err);
863 RXS_ERR("RX-RATE-ERR", rx_rate_err); 863 RXS_ERR("RX-RATE-ERR", rx_rate_err);
864 RXS_ERR("RX-DROP-RXFLUSH", rx_drop_rxflush);
865 RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err); 864 RXS_ERR("RX-TOO-MANY-FRAGS", rx_too_many_frags_err);
866 865
867 PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN); 866 PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN);
diff --git a/drivers/net/wireless/ath/ath9k/debug.h b/drivers/net/wireless/ath/ath9k/debug.h
index 375c3b46411e..6df2ab62dcb7 100644
--- a/drivers/net/wireless/ath/ath9k/debug.h
+++ b/drivers/net/wireless/ath/ath9k/debug.h
@@ -216,7 +216,6 @@ struct ath_tx_stats {
216 * @rx_oom_err: No. of frames dropped due to OOM issues. 216 * @rx_oom_err: No. of frames dropped due to OOM issues.
217 * @rx_rate_err: No. of frames dropped due to rate errors. 217 * @rx_rate_err: No. of frames dropped due to rate errors.
218 * @rx_too_many_frags_err: Frames dropped due to too-many-frags received. 218 * @rx_too_many_frags_err: Frames dropped due to too-many-frags received.
219 * @rx_drop_rxflush: No. of frames dropped due to RX-FLUSH.
220 * @rx_beacons: No. of beacons received. 219 * @rx_beacons: No. of beacons received.
221 * @rx_frags: No. of rx-fragements received. 220 * @rx_frags: No. of rx-fragements received.
222 */ 221 */
@@ -235,7 +234,6 @@ struct ath_rx_stats {
235 u32 rx_oom_err; 234 u32 rx_oom_err;
236 u32 rx_rate_err; 235 u32 rx_rate_err;
237 u32 rx_too_many_frags_err; 236 u32 rx_too_many_frags_err;
238 u32 rx_drop_rxflush;
239 u32 rx_beacons; 237 u32 rx_beacons;
240 u32 rx_frags; 238 u32 rx_frags;
241}; 239};
diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c
index 4a9570dfba72..aac4a406a513 100644
--- a/drivers/net/wireless/ath/ath9k/htc_hst.c
+++ b/drivers/net/wireless/ath/ath9k/htc_hst.c
@@ -344,6 +344,8 @@ void ath9k_htc_txcompletion_cb(struct htc_target *htc_handle,
344 endpoint->ep_callbacks.tx(endpoint->ep_callbacks.priv, 344 endpoint->ep_callbacks.tx(endpoint->ep_callbacks.priv,
345 skb, htc_hdr->endpoint_id, 345 skb, htc_hdr->endpoint_id,
346 txok); 346 txok);
347 } else {
348 kfree_skb(skb);
347 } 349 }
348 } 350 }
349 351
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 7f1a8e91c908..9d26fc56ca56 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -1066,6 +1066,7 @@ void ar9003_paprd_setup_gain_table(struct ath_hw *ah, int chain);
1066int ar9003_paprd_init_table(struct ath_hw *ah); 1066int ar9003_paprd_init_table(struct ath_hw *ah);
1067bool ar9003_paprd_is_done(struct ath_hw *ah); 1067bool ar9003_paprd_is_done(struct ath_hw *ah);
1068bool ar9003_is_paprd_enabled(struct ath_hw *ah); 1068bool ar9003_is_paprd_enabled(struct ath_hw *ah);
1069void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx);
1069 1070
1070/* Hardware family op attach helpers */ 1071/* Hardware family op attach helpers */
1071void ar5008_hw_attach_phy_ops(struct ath_hw *ah); 1072void ar5008_hw_attach_phy_ops(struct ath_hw *ah);
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index be30a9af1528..dd91f8fdc01c 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -182,7 +182,7 @@ static void ath_restart_work(struct ath_softc *sc)
182 ath_start_ani(sc); 182 ath_start_ani(sc);
183} 183}
184 184
185static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx, bool flush) 185static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx)
186{ 186{
187 struct ath_hw *ah = sc->sc_ah; 187 struct ath_hw *ah = sc->sc_ah;
188 bool ret = true; 188 bool ret = true;
@@ -202,14 +202,6 @@ static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx, bool flush)
202 if (!ath_drain_all_txq(sc, retry_tx)) 202 if (!ath_drain_all_txq(sc, retry_tx))
203 ret = false; 203 ret = false;
204 204
205 if (!flush) {
206 if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
207 ath_rx_tasklet(sc, 1, true);
208 ath_rx_tasklet(sc, 1, false);
209 } else {
210 ath_flushrecv(sc);
211 }
212
213 return ret; 205 return ret;
214} 206}
215 207
@@ -262,11 +254,11 @@ static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan,
262 struct ath_common *common = ath9k_hw_common(ah); 254 struct ath_common *common = ath9k_hw_common(ah);
263 struct ath9k_hw_cal_data *caldata = NULL; 255 struct ath9k_hw_cal_data *caldata = NULL;
264 bool fastcc = true; 256 bool fastcc = true;
265 bool flush = false;
266 int r; 257 int r;
267 258
268 __ath_cancel_work(sc); 259 __ath_cancel_work(sc);
269 260
261 tasklet_disable(&sc->intr_tq);
270 spin_lock_bh(&sc->sc_pcu_lock); 262 spin_lock_bh(&sc->sc_pcu_lock);
271 263
272 if (!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) { 264 if (!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) {
@@ -276,11 +268,10 @@ static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan,
276 268
277 if (!hchan) { 269 if (!hchan) {
278 fastcc = false; 270 fastcc = false;
279 flush = true;
280 hchan = ah->curchan; 271 hchan = ah->curchan;
281 } 272 }
282 273
283 if (!ath_prepare_reset(sc, retry_tx, flush)) 274 if (!ath_prepare_reset(sc, retry_tx))
284 fastcc = false; 275 fastcc = false;
285 276
286 ath_dbg(common, CONFIG, "Reset to %u MHz, HT40: %d fastcc: %d\n", 277 ath_dbg(common, CONFIG, "Reset to %u MHz, HT40: %d fastcc: %d\n",
@@ -302,6 +293,8 @@ static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan,
302 293
303out: 294out:
304 spin_unlock_bh(&sc->sc_pcu_lock); 295 spin_unlock_bh(&sc->sc_pcu_lock);
296 tasklet_enable(&sc->intr_tq);
297
305 return r; 298 return r;
306} 299}
307 300
@@ -804,7 +797,7 @@ static void ath9k_stop(struct ieee80211_hw *hw)
804 ath9k_hw_cfg_gpio_input(ah, ah->led_pin); 797 ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
805 } 798 }
806 799
807 ath_prepare_reset(sc, false, true); 800 ath_prepare_reset(sc, false);
808 801
809 if (sc->rx.frag) { 802 if (sc->rx.frag) {
810 dev_kfree_skb_any(sc->rx.frag); 803 dev_kfree_skb_any(sc->rx.frag);
@@ -1833,6 +1826,9 @@ static u32 fill_chainmask(u32 cap, u32 new)
1833 1826
1834static bool validate_antenna_mask(struct ath_hw *ah, u32 val) 1827static bool validate_antenna_mask(struct ath_hw *ah, u32 val)
1835{ 1828{
1829 if (AR_SREV_9300_20_OR_LATER(ah))
1830 return true;
1831
1836 switch (val & 0x7) { 1832 switch (val & 0x7) {
1837 case 0x1: 1833 case 0x1:
1838 case 0x3: 1834 case 0x3:
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index d4df98a938bf..90752f246970 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -254,8 +254,6 @@ rx_init_fail:
254 254
255static void ath_edma_start_recv(struct ath_softc *sc) 255static void ath_edma_start_recv(struct ath_softc *sc)
256{ 256{
257 spin_lock_bh(&sc->rx.rxbuflock);
258
259 ath9k_hw_rxena(sc->sc_ah); 257 ath9k_hw_rxena(sc->sc_ah);
260 258
261 ath_rx_addbuffer_edma(sc, ATH9K_RX_QUEUE_HP, 259 ath_rx_addbuffer_edma(sc, ATH9K_RX_QUEUE_HP,
@@ -267,8 +265,6 @@ static void ath_edma_start_recv(struct ath_softc *sc)
267 ath_opmode_init(sc); 265 ath_opmode_init(sc);
268 266
269 ath9k_hw_startpcureceive(sc->sc_ah, !!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)); 267 ath9k_hw_startpcureceive(sc->sc_ah, !!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL));
270
271 spin_unlock_bh(&sc->rx.rxbuflock);
272} 268}
273 269
274static void ath_edma_stop_recv(struct ath_softc *sc) 270static void ath_edma_stop_recv(struct ath_softc *sc)
@@ -285,8 +281,6 @@ int ath_rx_init(struct ath_softc *sc, int nbufs)
285 int error = 0; 281 int error = 0;
286 282
287 spin_lock_init(&sc->sc_pcu_lock); 283 spin_lock_init(&sc->sc_pcu_lock);
288 spin_lock_init(&sc->rx.rxbuflock);
289 clear_bit(SC_OP_RXFLUSH, &sc->sc_flags);
290 284
291 common->rx_bufsize = IEEE80211_MAX_MPDU_LEN / 2 + 285 common->rx_bufsize = IEEE80211_MAX_MPDU_LEN / 2 +
292 sc->sc_ah->caps.rx_status_len; 286 sc->sc_ah->caps.rx_status_len;
@@ -447,7 +441,6 @@ int ath_startrecv(struct ath_softc *sc)
447 return 0; 441 return 0;
448 } 442 }
449 443
450 spin_lock_bh(&sc->rx.rxbuflock);
451 if (list_empty(&sc->rx.rxbuf)) 444 if (list_empty(&sc->rx.rxbuf))
452 goto start_recv; 445 goto start_recv;
453 446
@@ -468,26 +461,31 @@ start_recv:
468 ath_opmode_init(sc); 461 ath_opmode_init(sc);
469 ath9k_hw_startpcureceive(ah, !!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)); 462 ath9k_hw_startpcureceive(ah, !!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL));
470 463
471 spin_unlock_bh(&sc->rx.rxbuflock);
472
473 return 0; 464 return 0;
474} 465}
475 466
467static void ath_flushrecv(struct ath_softc *sc)
468{
469 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
470 ath_rx_tasklet(sc, 1, true);
471 ath_rx_tasklet(sc, 1, false);
472}
473
476bool ath_stoprecv(struct ath_softc *sc) 474bool ath_stoprecv(struct ath_softc *sc)
477{ 475{
478 struct ath_hw *ah = sc->sc_ah; 476 struct ath_hw *ah = sc->sc_ah;
479 bool stopped, reset = false; 477 bool stopped, reset = false;
480 478
481 spin_lock_bh(&sc->rx.rxbuflock);
482 ath9k_hw_abortpcurecv(ah); 479 ath9k_hw_abortpcurecv(ah);
483 ath9k_hw_setrxfilter(ah, 0); 480 ath9k_hw_setrxfilter(ah, 0);
484 stopped = ath9k_hw_stopdmarecv(ah, &reset); 481 stopped = ath9k_hw_stopdmarecv(ah, &reset);
485 482
483 ath_flushrecv(sc);
484
486 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) 485 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
487 ath_edma_stop_recv(sc); 486 ath_edma_stop_recv(sc);
488 else 487 else
489 sc->rx.rxlink = NULL; 488 sc->rx.rxlink = NULL;
490 spin_unlock_bh(&sc->rx.rxbuflock);
491 489
492 if (!(ah->ah_flags & AH_UNPLUGGED) && 490 if (!(ah->ah_flags & AH_UNPLUGGED) &&
493 unlikely(!stopped)) { 491 unlikely(!stopped)) {
@@ -499,15 +497,6 @@ bool ath_stoprecv(struct ath_softc *sc)
499 return stopped && !reset; 497 return stopped && !reset;
500} 498}
501 499
502void ath_flushrecv(struct ath_softc *sc)
503{
504 set_bit(SC_OP_RXFLUSH, &sc->sc_flags);
505 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
506 ath_rx_tasklet(sc, 1, true);
507 ath_rx_tasklet(sc, 1, false);
508 clear_bit(SC_OP_RXFLUSH, &sc->sc_flags);
509}
510
511static bool ath_beacon_dtim_pending_cab(struct sk_buff *skb) 500static bool ath_beacon_dtim_pending_cab(struct sk_buff *skb)
512{ 501{
513 /* Check whether the Beacon frame has DTIM indicating buffered bc/mc */ 502 /* Check whether the Beacon frame has DTIM indicating buffered bc/mc */
@@ -744,6 +733,7 @@ static struct ath_buf *ath_get_next_rx_buf(struct ath_softc *sc,
744 return NULL; 733 return NULL;
745 } 734 }
746 735
736 list_del(&bf->list);
747 if (!bf->bf_mpdu) 737 if (!bf->bf_mpdu)
748 return bf; 738 return bf;
749 739
@@ -1059,16 +1049,12 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1059 dma_type = DMA_FROM_DEVICE; 1049 dma_type = DMA_FROM_DEVICE;
1060 1050
1061 qtype = hp ? ATH9K_RX_QUEUE_HP : ATH9K_RX_QUEUE_LP; 1051 qtype = hp ? ATH9K_RX_QUEUE_HP : ATH9K_RX_QUEUE_LP;
1062 spin_lock_bh(&sc->rx.rxbuflock);
1063 1052
1064 tsf = ath9k_hw_gettsf64(ah); 1053 tsf = ath9k_hw_gettsf64(ah);
1065 tsf_lower = tsf & 0xffffffff; 1054 tsf_lower = tsf & 0xffffffff;
1066 1055
1067 do { 1056 do {
1068 bool decrypt_error = false; 1057 bool decrypt_error = false;
1069 /* If handling rx interrupt and flush is in progress => exit */
1070 if (test_bit(SC_OP_RXFLUSH, &sc->sc_flags) && (flush == 0))
1071 break;
1072 1058
1073 memset(&rs, 0, sizeof(rs)); 1059 memset(&rs, 0, sizeof(rs));
1074 if (edma) 1060 if (edma)
@@ -1111,15 +1097,6 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
1111 1097
1112 ath_debug_stat_rx(sc, &rs); 1098 ath_debug_stat_rx(sc, &rs);
1113 1099
1114 /*
1115 * If we're asked to flush receive queue, directly
1116 * chain it back at the queue without processing it.
1117 */
1118 if (test_bit(SC_OP_RXFLUSH, &sc->sc_flags)) {
1119 RX_STAT_INC(rx_drop_rxflush);
1120 goto requeue_drop_frag;
1121 }
1122
1123 memset(rxs, 0, sizeof(struct ieee80211_rx_status)); 1100 memset(rxs, 0, sizeof(struct ieee80211_rx_status));
1124 1101
1125 rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp; 1102 rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp;
@@ -1254,19 +1231,18 @@ requeue_drop_frag:
1254 sc->rx.frag = NULL; 1231 sc->rx.frag = NULL;
1255 } 1232 }
1256requeue: 1233requeue:
1234 list_add_tail(&bf->list, &sc->rx.rxbuf);
1235 if (flush)
1236 continue;
1237
1257 if (edma) { 1238 if (edma) {
1258 list_add_tail(&bf->list, &sc->rx.rxbuf);
1259 ath_rx_edma_buf_link(sc, qtype); 1239 ath_rx_edma_buf_link(sc, qtype);
1260 } else { 1240 } else {
1261 list_move_tail(&bf->list, &sc->rx.rxbuf);
1262 ath_rx_buf_link(sc, bf); 1241 ath_rx_buf_link(sc, bf);
1263 if (!flush) 1242 ath9k_hw_rxena(ah);
1264 ath9k_hw_rxena(ah);
1265 } 1243 }
1266 } while (1); 1244 } while (1);
1267 1245
1268 spin_unlock_bh(&sc->rx.rxbuflock);
1269
1270 if (!(ah->imask & ATH9K_INT_RXEOL)) { 1246 if (!(ah->imask & ATH9K_INT_RXEOL)) {
1271 ah->imask |= (ATH9K_INT_RXEOL | ATH9K_INT_RXORN); 1247 ah->imask |= (ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
1272 ath9k_hw_set_interrupts(ah); 1248 ath9k_hw_set_interrupts(ah);
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
index 1fbd8ecbe2ea..0f71d1d4339d 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
@@ -1407,9 +1407,10 @@ void brcms_add_timer(struct brcms_timer *t, uint ms, int periodic)
1407#endif 1407#endif
1408 t->ms = ms; 1408 t->ms = ms;
1409 t->periodic = (bool) periodic; 1409 t->periodic = (bool) periodic;
1410 t->set = true; 1410 if (!t->set) {
1411 1411 t->set = true;
1412 atomic_inc(&t->wl->callbacks); 1412 atomic_inc(&t->wl->callbacks);
1413 }
1413 1414
1414 ieee80211_queue_delayed_work(hw, &t->dly_wrk, msecs_to_jiffies(ms)); 1415 ieee80211_queue_delayed_work(hw, &t->dly_wrk, msecs_to_jiffies(ms));
1415} 1416}
diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c
index 7e16d10a7f14..90b8970eadf0 100644
--- a/drivers/net/wireless/iwlegacy/common.c
+++ b/drivers/net/wireless/iwlegacy/common.c
@@ -3958,17 +3958,21 @@ il_connection_init_rx_config(struct il_priv *il)
3958 3958
3959 memset(&il->staging, 0, sizeof(il->staging)); 3959 memset(&il->staging, 0, sizeof(il->staging));
3960 3960
3961 if (!il->vif) { 3961 switch (il->iw_mode) {
3962 case NL80211_IFTYPE_UNSPECIFIED:
3962 il->staging.dev_type = RXON_DEV_TYPE_ESS; 3963 il->staging.dev_type = RXON_DEV_TYPE_ESS;
3963 } else if (il->vif->type == NL80211_IFTYPE_STATION) { 3964 break;
3965 case NL80211_IFTYPE_STATION:
3964 il->staging.dev_type = RXON_DEV_TYPE_ESS; 3966 il->staging.dev_type = RXON_DEV_TYPE_ESS;
3965 il->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; 3967 il->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK;
3966 } else if (il->vif->type == NL80211_IFTYPE_ADHOC) { 3968 break;
3969 case NL80211_IFTYPE_ADHOC:
3967 il->staging.dev_type = RXON_DEV_TYPE_IBSS; 3970 il->staging.dev_type = RXON_DEV_TYPE_IBSS;
3968 il->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK; 3971 il->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK;
3969 il->staging.filter_flags = 3972 il->staging.filter_flags =
3970 RXON_FILTER_BCON_AWARE_MSK | RXON_FILTER_ACCEPT_GRP_MSK; 3973 RXON_FILTER_BCON_AWARE_MSK | RXON_FILTER_ACCEPT_GRP_MSK;
3971 } else { 3974 break;
3975 default:
3972 IL_ERR("Unsupported interface type %d\n", il->vif->type); 3976 IL_ERR("Unsupported interface type %d\n", il->vif->type);
3973 return; 3977 return;
3974 } 3978 }
@@ -4550,8 +4554,7 @@ out:
4550EXPORT_SYMBOL(il_mac_add_interface); 4554EXPORT_SYMBOL(il_mac_add_interface);
4551 4555
4552static void 4556static void
4553il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif, 4557il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif)
4554 bool mode_change)
4555{ 4558{
4556 lockdep_assert_held(&il->mutex); 4559 lockdep_assert_held(&il->mutex);
4557 4560
@@ -4560,9 +4563,7 @@ il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif,
4560 il_force_scan_end(il); 4563 il_force_scan_end(il);
4561 } 4564 }
4562 4565
4563 if (!mode_change) 4566 il_set_mode(il);
4564 il_set_mode(il);
4565
4566} 4567}
4567 4568
4568void 4569void
@@ -4575,8 +4576,8 @@ il_mac_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
4575 4576
4576 WARN_ON(il->vif != vif); 4577 WARN_ON(il->vif != vif);
4577 il->vif = NULL; 4578 il->vif = NULL;
4578 4579 il->iw_mode = NL80211_IFTYPE_UNSPECIFIED;
4579 il_teardown_interface(il, vif, false); 4580 il_teardown_interface(il, vif);
4580 memset(il->bssid, 0, ETH_ALEN); 4581 memset(il->bssid, 0, ETH_ALEN);
4581 4582
4582 D_MAC80211("leave\n"); 4583 D_MAC80211("leave\n");
@@ -4685,18 +4686,10 @@ il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
4685 } 4686 }
4686 4687
4687 /* success */ 4688 /* success */
4688 il_teardown_interface(il, vif, true);
4689 vif->type = newtype; 4689 vif->type = newtype;
4690 vif->p2p = false; 4690 vif->p2p = false;
4691 err = il_set_mode(il); 4691 il->iw_mode = newtype;
4692 WARN_ON(err); 4692 il_teardown_interface(il, vif);
4693 /*
4694 * We've switched internally, but submitting to the
4695 * device may have failed for some reason. Mask this
4696 * error, because otherwise mac80211 will not switch
4697 * (and set the interface type back) and we'll be
4698 * out of sync with it.
4699 */
4700 err = 0; 4693 err = 0;
4701 4694
4702out: 4695out:
diff --git a/drivers/net/wireless/iwlwifi/dvm/tx.c b/drivers/net/wireless/iwlwifi/dvm/tx.c
index a790599fe2c2..31534f7c0548 100644
--- a/drivers/net/wireless/iwlwifi/dvm/tx.c
+++ b/drivers/net/wireless/iwlwifi/dvm/tx.c
@@ -1079,6 +1079,8 @@ static void iwlagn_set_tx_status(struct iwl_priv *priv,
1079{ 1079{
1080 u16 status = le16_to_cpu(tx_resp->status.status); 1080 u16 status = le16_to_cpu(tx_resp->status.status);
1081 1081
1082 info->flags &= ~IEEE80211_TX_CTL_AMPDU;
1083
1082 info->status.rates[0].count = tx_resp->failure_frame + 1; 1084 info->status.rates[0].count = tx_resp->failure_frame + 1;
1083 info->flags |= iwl_tx_status_to_mac80211(status); 1085 info->flags |= iwl_tx_status_to_mac80211(status);
1084 iwlagn_hwrate_to_tx_control(priv, le32_to_cpu(tx_resp->rate_n_flags), 1086 iwlagn_hwrate_to_tx_control(priv, le32_to_cpu(tx_resp->rate_n_flags),
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index efe525be27dd..cdb11b3964e2 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -1459,7 +1459,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
1459 struct cfg80211_ssid req_ssid; 1459 struct cfg80211_ssid req_ssid;
1460 int ret, auth_type = 0; 1460 int ret, auth_type = 0;
1461 struct cfg80211_bss *bss = NULL; 1461 struct cfg80211_bss *bss = NULL;
1462 u8 is_scanning_required = 0, config_bands = 0; 1462 u8 is_scanning_required = 0;
1463 1463
1464 memset(&req_ssid, 0, sizeof(struct cfg80211_ssid)); 1464 memset(&req_ssid, 0, sizeof(struct cfg80211_ssid));
1465 1465
@@ -1478,19 +1478,6 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
1478 /* disconnect before try to associate */ 1478 /* disconnect before try to associate */
1479 mwifiex_deauthenticate(priv, NULL); 1479 mwifiex_deauthenticate(priv, NULL);
1480 1480
1481 if (channel) {
1482 if (mode == NL80211_IFTYPE_STATION) {
1483 if (channel->band == IEEE80211_BAND_2GHZ)
1484 config_bands = BAND_B | BAND_G | BAND_GN;
1485 else
1486 config_bands = BAND_A | BAND_AN;
1487
1488 if (!((config_bands | priv->adapter->fw_bands) &
1489 ~priv->adapter->fw_bands))
1490 priv->adapter->config_bands = config_bands;
1491 }
1492 }
1493
1494 /* As this is new association, clear locally stored 1481 /* As this is new association, clear locally stored
1495 * keys and security related flags */ 1482 * keys and security related flags */
1496 priv->sec_info.wpa_enabled = false; 1483 priv->sec_info.wpa_enabled = false;
@@ -1707,7 +1694,7 @@ static int mwifiex_set_ibss_params(struct mwifiex_private *priv,
1707 1694
1708 if (cfg80211_get_chandef_type(&params->chandef) != 1695 if (cfg80211_get_chandef_type(&params->chandef) !=
1709 NL80211_CHAN_NO_HT) 1696 NL80211_CHAN_NO_HT)
1710 config_bands |= BAND_GN; 1697 config_bands |= BAND_G | BAND_GN;
1711 } else { 1698 } else {
1712 if (cfg80211_get_chandef_type(&params->chandef) == 1699 if (cfg80211_get_chandef_type(&params->chandef) ==
1713 NL80211_CHAN_NO_HT) 1700 NL80211_CHAN_NO_HT)
diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c
index 13fbc4eb1595..b879e1338a54 100644
--- a/drivers/net/wireless/mwifiex/pcie.c
+++ b/drivers/net/wireless/mwifiex/pcie.c
@@ -161,7 +161,7 @@ static int mwifiex_pcie_suspend(struct pci_dev *pdev, pm_message_t state)
161 161
162 if (pdev) { 162 if (pdev) {
163 card = (struct pcie_service_card *) pci_get_drvdata(pdev); 163 card = (struct pcie_service_card *) pci_get_drvdata(pdev);
164 if (!card || card->adapter) { 164 if (!card || !card->adapter) {
165 pr_err("Card or adapter structure is not valid\n"); 165 pr_err("Card or adapter structure is not valid\n");
166 return 0; 166 return 0;
167 } 167 }
diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c
index 60e88b58039d..f542bb8ccbc8 100644
--- a/drivers/net/wireless/mwifiex/sta_ioctl.c
+++ b/drivers/net/wireless/mwifiex/sta_ioctl.c
@@ -283,6 +283,20 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
283 if (ret) 283 if (ret)
284 goto done; 284 goto done;
285 285
286 if (bss_desc) {
287 u8 config_bands = 0;
288
289 if (mwifiex_band_to_radio_type((u8) bss_desc->bss_band)
290 == HostCmd_SCAN_RADIO_TYPE_BG)
291 config_bands = BAND_B | BAND_G | BAND_GN;
292 else
293 config_bands = BAND_A | BAND_AN;
294
295 if (!((config_bands | adapter->fw_bands) &
296 ~adapter->fw_bands))
297 adapter->config_bands = config_bands;
298 }
299
286 ret = mwifiex_check_network_compatibility(priv, bss_desc); 300 ret = mwifiex_check_network_compatibility(priv, bss_desc);
287 if (ret) 301 if (ret)
288 goto done; 302 goto done;
diff --git a/drivers/net/wireless/rtlwifi/Kconfig b/drivers/net/wireless/rtlwifi/Kconfig
index 21b1bbb93a7e..b80bc4612581 100644
--- a/drivers/net/wireless/rtlwifi/Kconfig
+++ b/drivers/net/wireless/rtlwifi/Kconfig
@@ -57,12 +57,12 @@ config RTL8192CU
57 57
58config RTLWIFI 58config RTLWIFI
59 tristate 59 tristate
60 depends on RTL8192CE || RTL8192CU || RTL8192SE || RTL8192DE 60 depends on RTL8192CE || RTL8192CU || RTL8192SE || RTL8192DE || RTL8723AE
61 default m 61 default m
62 62
63config RTLWIFI_DEBUG 63config RTLWIFI_DEBUG
64 bool "Additional debugging output" 64 bool "Additional debugging output"
65 depends on RTL8192CE || RTL8192CU || RTL8192SE || RTL8192DE 65 depends on RTL8192CE || RTL8192CU || RTL8192SE || RTL8192DE || RTL8723AE
66 default y 66 default y
67 67
68config RTL8192C_COMMON 68config RTL8192C_COMMON
diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index c31aeb01bb00..efaecefe3f8c 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -181,7 +181,6 @@ config PINCTRL_COH901
181 181
182config PINCTRL_SAMSUNG 182config PINCTRL_SAMSUNG
183 bool 183 bool
184 depends on OF && GPIOLIB
185 select PINMUX 184 select PINMUX
186 select PINCONF 185 select PINCONF
187 186
diff --git a/drivers/pinctrl/mvebu/pinctrl-dove.c b/drivers/pinctrl/mvebu/pinctrl-dove.c
index 69aba3697287..428ea96a94d3 100644
--- a/drivers/pinctrl/mvebu/pinctrl-dove.c
+++ b/drivers/pinctrl/mvebu/pinctrl-dove.c
@@ -588,7 +588,7 @@ static int dove_pinctrl_probe(struct platform_device *pdev)
588{ 588{
589 const struct of_device_id *match = 589 const struct of_device_id *match =
590 of_match_device(dove_pinctrl_of_match, &pdev->dev); 590 of_match_device(dove_pinctrl_of_match, &pdev->dev);
591 pdev->dev.platform_data = match->data; 591 pdev->dev.platform_data = (void *)match->data;
592 592
593 /* 593 /*
594 * General MPP Configuration Register is part of pdma registers. 594 * General MPP Configuration Register is part of pdma registers.
diff --git a/drivers/pinctrl/mvebu/pinctrl-kirkwood.c b/drivers/pinctrl/mvebu/pinctrl-kirkwood.c
index f12084e18057..cdd483df673e 100644
--- a/drivers/pinctrl/mvebu/pinctrl-kirkwood.c
+++ b/drivers/pinctrl/mvebu/pinctrl-kirkwood.c
@@ -66,9 +66,9 @@ static struct mvebu_mpp_mode mv88f6xxx_mpp_modes[] = {
66 MPP_VAR_FUNCTION(0x5, "sata0", "act", V(0, 1, 1, 1, 1, 0)), 66 MPP_VAR_FUNCTION(0x5, "sata0", "act", V(0, 1, 1, 1, 1, 0)),
67 MPP_VAR_FUNCTION(0xb, "lcd", "vsync", V(0, 0, 0, 0, 1, 0))), 67 MPP_VAR_FUNCTION(0xb, "lcd", "vsync", V(0, 0, 0, 0, 1, 0))),
68 MPP_MODE(6, 68 MPP_MODE(6,
69 MPP_VAR_FUNCTION(0x0, "sysrst", "out", V(1, 1, 1, 1, 1, 1)), 69 MPP_VAR_FUNCTION(0x1, "sysrst", "out", V(1, 1, 1, 1, 1, 1)),
70 MPP_VAR_FUNCTION(0x1, "spi", "mosi", V(1, 1, 1, 1, 1, 1)), 70 MPP_VAR_FUNCTION(0x2, "spi", "mosi", V(1, 1, 1, 1, 1, 1)),
71 MPP_VAR_FUNCTION(0x2, "ptp", "trig", V(1, 1, 1, 1, 0, 0))), 71 MPP_VAR_FUNCTION(0x3, "ptp", "trig", V(1, 1, 1, 1, 0, 0))),
72 MPP_MODE(7, 72 MPP_MODE(7,
73 MPP_VAR_FUNCTION(0x0, "gpo", NULL, V(1, 1, 1, 1, 1, 1)), 73 MPP_VAR_FUNCTION(0x0, "gpo", NULL, V(1, 1, 1, 1, 1, 1)),
74 MPP_VAR_FUNCTION(0x1, "pex", "rsto", V(1, 1, 1, 1, 0, 1)), 74 MPP_VAR_FUNCTION(0x1, "pex", "rsto", V(1, 1, 1, 1, 0, 1)),
@@ -458,7 +458,7 @@ static int kirkwood_pinctrl_probe(struct platform_device *pdev)
458{ 458{
459 const struct of_device_id *match = 459 const struct of_device_id *match =
460 of_match_device(kirkwood_pinctrl_of_match, &pdev->dev); 460 of_match_device(kirkwood_pinctrl_of_match, &pdev->dev);
461 pdev->dev.platform_data = match->data; 461 pdev->dev.platform_data = (void *)match->data;
462 return mvebu_pinctrl_probe(pdev); 462 return mvebu_pinctrl_probe(pdev);
463} 463}
464 464
diff --git a/drivers/pinctrl/pinctrl-exynos5440.c b/drivers/pinctrl/pinctrl-exynos5440.c
index de05b64f0da6..142729914c34 100644
--- a/drivers/pinctrl/pinctrl-exynos5440.c
+++ b/drivers/pinctrl/pinctrl-exynos5440.c
@@ -599,7 +599,7 @@ static int exynos5440_gpio_direction_output(struct gpio_chip *gc, unsigned offse
599} 599}
600 600
601/* parse the pin numbers listed in the 'samsung,exynos5440-pins' property */ 601/* parse the pin numbers listed in the 'samsung,exynos5440-pins' property */
602static int __init exynos5440_pinctrl_parse_dt_pins(struct platform_device *pdev, 602static int exynos5440_pinctrl_parse_dt_pins(struct platform_device *pdev,
603 struct device_node *cfg_np, unsigned int **pin_list, 603 struct device_node *cfg_np, unsigned int **pin_list,
604 unsigned int *npins) 604 unsigned int *npins)
605{ 605{
@@ -630,7 +630,7 @@ static int __init exynos5440_pinctrl_parse_dt_pins(struct platform_device *pdev,
630 * Parse the information about all the available pin groups and pin functions 630 * Parse the information about all the available pin groups and pin functions
631 * from device node of the pin-controller. 631 * from device node of the pin-controller.
632 */ 632 */
633static int __init exynos5440_pinctrl_parse_dt(struct platform_device *pdev, 633static int exynos5440_pinctrl_parse_dt(struct platform_device *pdev,
634 struct exynos5440_pinctrl_priv_data *priv) 634 struct exynos5440_pinctrl_priv_data *priv)
635{ 635{
636 struct device *dev = &pdev->dev; 636 struct device *dev = &pdev->dev;
@@ -723,7 +723,7 @@ static int __init exynos5440_pinctrl_parse_dt(struct platform_device *pdev,
723} 723}
724 724
725/* register the pinctrl interface with the pinctrl subsystem */ 725/* register the pinctrl interface with the pinctrl subsystem */
726static int __init exynos5440_pinctrl_register(struct platform_device *pdev, 726static int exynos5440_pinctrl_register(struct platform_device *pdev,
727 struct exynos5440_pinctrl_priv_data *priv) 727 struct exynos5440_pinctrl_priv_data *priv)
728{ 728{
729 struct device *dev = &pdev->dev; 729 struct device *dev = &pdev->dev;
@@ -798,7 +798,7 @@ static int __init exynos5440_pinctrl_register(struct platform_device *pdev,
798} 798}
799 799
800/* register the gpiolib interface with the gpiolib subsystem */ 800/* register the gpiolib interface with the gpiolib subsystem */
801static int __init exynos5440_gpiolib_register(struct platform_device *pdev, 801static int exynos5440_gpiolib_register(struct platform_device *pdev,
802 struct exynos5440_pinctrl_priv_data *priv) 802 struct exynos5440_pinctrl_priv_data *priv)
803{ 803{
804 struct gpio_chip *gc; 804 struct gpio_chip *gc;
@@ -831,7 +831,7 @@ static int __init exynos5440_gpiolib_register(struct platform_device *pdev,
831} 831}
832 832
833/* unregister the gpiolib interface with the gpiolib subsystem */ 833/* unregister the gpiolib interface with the gpiolib subsystem */
834static int __init exynos5440_gpiolib_unregister(struct platform_device *pdev, 834static int exynos5440_gpiolib_unregister(struct platform_device *pdev,
835 struct exynos5440_pinctrl_priv_data *priv) 835 struct exynos5440_pinctrl_priv_data *priv)
836{ 836{
837 int ret = gpiochip_remove(priv->gc); 837 int ret = gpiochip_remove(priv->gc);
diff --git a/drivers/pinctrl/pinctrl-mxs.c b/drivers/pinctrl/pinctrl-mxs.c
index dd227d21dcf2..23af9f1f9c35 100644
--- a/drivers/pinctrl/pinctrl-mxs.c
+++ b/drivers/pinctrl/pinctrl-mxs.c
@@ -146,7 +146,7 @@ free:
146static void mxs_dt_free_map(struct pinctrl_dev *pctldev, 146static void mxs_dt_free_map(struct pinctrl_dev *pctldev,
147 struct pinctrl_map *map, unsigned num_maps) 147 struct pinctrl_map *map, unsigned num_maps)
148{ 148{
149 int i; 149 u32 i;
150 150
151 for (i = 0; i < num_maps; i++) { 151 for (i = 0; i < num_maps; i++) {
152 if (map[i].type == PIN_MAP_TYPE_MUX_GROUP) 152 if (map[i].type == PIN_MAP_TYPE_MUX_GROUP)
@@ -203,7 +203,7 @@ static int mxs_pinctrl_enable(struct pinctrl_dev *pctldev, unsigned selector,
203 void __iomem *reg; 203 void __iomem *reg;
204 u8 bank, shift; 204 u8 bank, shift;
205 u16 pin; 205 u16 pin;
206 int i; 206 u32 i;
207 207
208 for (i = 0; i < g->npins; i++) { 208 for (i = 0; i < g->npins; i++) {
209 bank = PINID_TO_BANK(g->pins[i]); 209 bank = PINID_TO_BANK(g->pins[i]);
@@ -256,7 +256,7 @@ static int mxs_pinconf_group_set(struct pinctrl_dev *pctldev,
256 void __iomem *reg; 256 void __iomem *reg;
257 u8 ma, vol, pull, bank, shift; 257 u8 ma, vol, pull, bank, shift;
258 u16 pin; 258 u16 pin;
259 int i; 259 u32 i;
260 260
261 ma = CONFIG_TO_MA(config); 261 ma = CONFIG_TO_MA(config);
262 vol = CONFIG_TO_VOL(config); 262 vol = CONFIG_TO_VOL(config);
@@ -345,8 +345,7 @@ static int mxs_pinctrl_parse_group(struct platform_device *pdev,
345 const char *propname = "fsl,pinmux-ids"; 345 const char *propname = "fsl,pinmux-ids";
346 char *group; 346 char *group;
347 int length = strlen(np->name) + SUFFIX_LEN; 347 int length = strlen(np->name) + SUFFIX_LEN;
348 int i; 348 u32 val, i;
349 u32 val;
350 349
351 group = devm_kzalloc(&pdev->dev, length, GFP_KERNEL); 350 group = devm_kzalloc(&pdev->dev, length, GFP_KERNEL);
352 if (!group) 351 if (!group)
diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c
index 1bb16ffb4e41..5767b18ebdff 100644
--- a/drivers/pinctrl/pinctrl-nomadik.c
+++ b/drivers/pinctrl/pinctrl-nomadik.c
@@ -676,7 +676,7 @@ int nmk_gpio_set_mode(int gpio, int gpio_mode)
676} 676}
677EXPORT_SYMBOL(nmk_gpio_set_mode); 677EXPORT_SYMBOL(nmk_gpio_set_mode);
678 678
679static int nmk_prcm_gpiocr_get_mode(struct pinctrl_dev *pctldev, int gpio) 679static int __maybe_unused nmk_prcm_gpiocr_get_mode(struct pinctrl_dev *pctldev, int gpio)
680{ 680{
681 int i; 681 int i;
682 u16 reg; 682 u16 reg;
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index f6a360b86eb6..5c32e880bcb2 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -30,7 +30,6 @@
30#define PCS_MUX_BITS_NAME "pinctrl-single,bits" 30#define PCS_MUX_BITS_NAME "pinctrl-single,bits"
31#define PCS_REG_NAME_LEN ((sizeof(unsigned long) * 2) + 1) 31#define PCS_REG_NAME_LEN ((sizeof(unsigned long) * 2) + 1)
32#define PCS_OFF_DISABLED ~0U 32#define PCS_OFF_DISABLED ~0U
33#define PCS_MAX_GPIO_VALUES 2
34 33
35/** 34/**
36 * struct pcs_pingroup - pingroups for a function 35 * struct pcs_pingroup - pingroups for a function
@@ -78,16 +77,6 @@ struct pcs_function {
78}; 77};
79 78
80/** 79/**
81 * struct pcs_gpio_range - pinctrl gpio range
82 * @range: subrange of the GPIO number space
83 * @gpio_func: gpio function value in the pinmux register
84 */
85struct pcs_gpio_range {
86 struct pinctrl_gpio_range range;
87 int gpio_func;
88};
89
90/**
91 * struct pcs_data - wrapper for data needed by pinctrl framework 80 * struct pcs_data - wrapper for data needed by pinctrl framework
92 * @pa: pindesc array 81 * @pa: pindesc array
93 * @cur: index to current element 82 * @cur: index to current element
@@ -414,26 +403,9 @@ static void pcs_disable(struct pinctrl_dev *pctldev, unsigned fselector,
414} 403}
415 404
416static int pcs_request_gpio(struct pinctrl_dev *pctldev, 405static int pcs_request_gpio(struct pinctrl_dev *pctldev,
417 struct pinctrl_gpio_range *range, unsigned pin) 406 struct pinctrl_gpio_range *range, unsigned offset)
418{ 407{
419 struct pcs_device *pcs = pinctrl_dev_get_drvdata(pctldev); 408 return -ENOTSUPP;
420 struct pcs_gpio_range *gpio = NULL;
421 int end, mux_bytes;
422 unsigned data;
423
424 gpio = container_of(range, struct pcs_gpio_range, range);
425 end = range->pin_base + range->npins - 1;
426 if (pin < range->pin_base || pin > end) {
427 dev_err(pctldev->dev,
428 "pin %d isn't in the range of %d to %d\n",
429 pin, range->pin_base, end);
430 return -EINVAL;
431 }
432 mux_bytes = pcs->width / BITS_PER_BYTE;
433 data = pcs->read(pcs->base + pin * mux_bytes) & ~pcs->fmask;
434 data |= gpio->gpio_func;
435 pcs->write(data, pcs->base + pin * mux_bytes);
436 return 0;
437} 409}
438 410
439static struct pinmux_ops pcs_pinmux_ops = { 411static struct pinmux_ops pcs_pinmux_ops = {
@@ -907,49 +879,6 @@ static void pcs_free_resources(struct pcs_device *pcs)
907 879
908static struct of_device_id pcs_of_match[]; 880static struct of_device_id pcs_of_match[];
909 881
910static int pcs_add_gpio_range(struct device_node *node, struct pcs_device *pcs)
911{
912 struct pcs_gpio_range *gpio;
913 struct device_node *child;
914 struct resource r;
915 const char name[] = "pinctrl-single";
916 u32 gpiores[PCS_MAX_GPIO_VALUES];
917 int ret, i = 0, mux_bytes = 0;
918
919 for_each_child_of_node(node, child) {
920 ret = of_address_to_resource(child, 0, &r);
921 if (ret < 0)
922 continue;
923 memset(gpiores, 0, sizeof(u32) * PCS_MAX_GPIO_VALUES);
924 ret = of_property_read_u32_array(child, "pinctrl-single,gpio",
925 gpiores, PCS_MAX_GPIO_VALUES);
926 if (ret < 0)
927 continue;
928 gpio = devm_kzalloc(pcs->dev, sizeof(*gpio), GFP_KERNEL);
929 if (!gpio) {
930 dev_err(pcs->dev, "failed to allocate pcs gpio\n");
931 return -ENOMEM;
932 }
933 gpio->range.name = devm_kzalloc(pcs->dev, sizeof(name),
934 GFP_KERNEL);
935 if (!gpio->range.name) {
936 dev_err(pcs->dev, "failed to allocate range name\n");
937 return -ENOMEM;
938 }
939 memcpy((char *)gpio->range.name, name, sizeof(name));
940
941 gpio->range.id = i++;
942 gpio->range.base = gpiores[0];
943 gpio->gpio_func = gpiores[1];
944 mux_bytes = pcs->width / BITS_PER_BYTE;
945 gpio->range.pin_base = (r.start - pcs->res->start) / mux_bytes;
946 gpio->range.npins = (r.end - r.start) / mux_bytes + 1;
947
948 pinctrl_add_gpio_range(pcs->pctl, &gpio->range);
949 }
950 return 0;
951}
952
953static int pcs_probe(struct platform_device *pdev) 882static int pcs_probe(struct platform_device *pdev)
954{ 883{
955 struct device_node *np = pdev->dev.of_node; 884 struct device_node *np = pdev->dev.of_node;
@@ -1046,10 +975,6 @@ static int pcs_probe(struct platform_device *pdev)
1046 goto free; 975 goto free;
1047 } 976 }
1048 977
1049 ret = pcs_add_gpio_range(np, pcs);
1050 if (ret < 0)
1051 goto free;
1052
1053 dev_info(pcs->dev, "%i pins at pa %p size %u\n", 978 dev_info(pcs->dev, "%i pins at pa %p size %u\n",
1054 pcs->desc.npins, pcs->base, pcs->size); 979 pcs->desc.npins, pcs->base, pcs->size);
1055 980
diff --git a/drivers/platform/x86/ibm_rtl.c b/drivers/platform/x86/ibm_rtl.c
index 7481146a5b47..97c2be195efc 100644
--- a/drivers/platform/x86/ibm_rtl.c
+++ b/drivers/platform/x86/ibm_rtl.c
@@ -244,7 +244,7 @@ static int __init ibm_rtl_init(void) {
244 if (force) 244 if (force)
245 pr_warn("module loaded by force\n"); 245 pr_warn("module loaded by force\n");
246 /* first ensure that we are running on IBM HW */ 246 /* first ensure that we are running on IBM HW */
247 else if (efi_enabled || !dmi_check_system(ibm_rtl_dmi_table)) 247 else if (efi_enabled(EFI_BOOT) || !dmi_check_system(ibm_rtl_dmi_table))
248 return -ENODEV; 248 return -ENODEV;
249 249
250 /* Get the address for the Extended BIOS Data Area */ 250 /* Get the address for the Extended BIOS Data Area */
diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
index 71623a2ff3e8..d1f030053176 100644
--- a/drivers/platform/x86/samsung-laptop.c
+++ b/drivers/platform/x86/samsung-laptop.c
@@ -26,6 +26,7 @@
26#include <linux/seq_file.h> 26#include <linux/seq_file.h>
27#include <linux/debugfs.h> 27#include <linux/debugfs.h>
28#include <linux/ctype.h> 28#include <linux/ctype.h>
29#include <linux/efi.h>
29#include <acpi/video.h> 30#include <acpi/video.h>
30 31
31/* 32/*
@@ -1544,6 +1545,9 @@ static int __init samsung_init(void)
1544 struct samsung_laptop *samsung; 1545 struct samsung_laptop *samsung;
1545 int ret; 1546 int ret;
1546 1547
1548 if (efi_enabled(EFI_BOOT))
1549 return -ENODEV;
1550
1547 quirks = &samsung_unknown; 1551 quirks = &samsung_unknown;
1548 if (!force && !dmi_check_system(samsung_dmi_table)) 1552 if (!force && !dmi_check_system(samsung_dmi_table))
1549 return -ENODEV; 1553 return -ENODEV;
diff --git a/drivers/regulator/dbx500-prcmu.c b/drivers/regulator/dbx500-prcmu.c
index 261f3d2299bc..89bd2faaef8c 100644
--- a/drivers/regulator/dbx500-prcmu.c
+++ b/drivers/regulator/dbx500-prcmu.c
@@ -14,6 +14,7 @@
14#include <linux/debugfs.h> 14#include <linux/debugfs.h>
15#include <linux/seq_file.h> 15#include <linux/seq_file.h>
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/module.h>
17 18
18#include "dbx500-prcmu.h" 19#include "dbx500-prcmu.h"
19 20
diff --git a/drivers/regulator/tps80031-regulator.c b/drivers/regulator/tps80031-regulator.c
index b15d711bc8c6..9019d0e7ecb6 100644
--- a/drivers/regulator/tps80031-regulator.c
+++ b/drivers/regulator/tps80031-regulator.c
@@ -728,7 +728,7 @@ static int tps80031_regulator_probe(struct platform_device *pdev)
728 } 728 }
729 } 729 }
730 rdev = regulator_register(&ri->rinfo->desc, &config); 730 rdev = regulator_register(&ri->rinfo->desc, &config);
731 if (IS_ERR_OR_NULL(rdev)) { 731 if (IS_ERR(rdev)) {
732 dev_err(&pdev->dev, 732 dev_err(&pdev->dev,
733 "register regulator failed %s\n", 733 "register regulator failed %s\n",
734 ri->rinfo->desc.name); 734 ri->rinfo->desc.name);
diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c
index d73fdcfeb45a..2839baa82a5a 100644
--- a/drivers/scsi/isci/init.c
+++ b/drivers/scsi/isci/init.c
@@ -633,7 +633,7 @@ static int isci_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
633 return -ENOMEM; 633 return -ENOMEM;
634 pci_set_drvdata(pdev, pci_info); 634 pci_set_drvdata(pdev, pci_info);
635 635
636 if (efi_enabled) 636 if (efi_enabled(EFI_RUNTIME_SERVICES))
637 orom = isci_get_efi_var(pdev); 637 orom = isci_get_efi_var(pdev);
638 638
639 if (!orom) 639 if (!orom)
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c
index 12526787a7c7..0abf2bf20836 100644
--- a/drivers/video/imxfb.c
+++ b/drivers/video/imxfb.c
@@ -139,6 +139,7 @@ struct imxfb_info {
139 struct clk *clk_ahb; 139 struct clk *clk_ahb;
140 struct clk *clk_per; 140 struct clk *clk_per;
141 enum imxfb_type devtype; 141 enum imxfb_type devtype;
142 bool enabled;
142 143
143 /* 144 /*
144 * These are the addresses we mapped 145 * These are the addresses we mapped
@@ -536,6 +537,10 @@ static void imxfb_exit_backlight(struct imxfb_info *fbi)
536 537
537static void imxfb_enable_controller(struct imxfb_info *fbi) 538static void imxfb_enable_controller(struct imxfb_info *fbi)
538{ 539{
540
541 if (fbi->enabled)
542 return;
543
539 pr_debug("Enabling LCD controller\n"); 544 pr_debug("Enabling LCD controller\n");
540 545
541 writel(fbi->screen_dma, fbi->regs + LCDC_SSA); 546 writel(fbi->screen_dma, fbi->regs + LCDC_SSA);
@@ -556,6 +561,7 @@ static void imxfb_enable_controller(struct imxfb_info *fbi)
556 clk_prepare_enable(fbi->clk_ipg); 561 clk_prepare_enable(fbi->clk_ipg);
557 clk_prepare_enable(fbi->clk_ahb); 562 clk_prepare_enable(fbi->clk_ahb);
558 clk_prepare_enable(fbi->clk_per); 563 clk_prepare_enable(fbi->clk_per);
564 fbi->enabled = true;
559 565
560 if (fbi->backlight_power) 566 if (fbi->backlight_power)
561 fbi->backlight_power(1); 567 fbi->backlight_power(1);
@@ -565,6 +571,9 @@ static void imxfb_enable_controller(struct imxfb_info *fbi)
565 571
566static void imxfb_disable_controller(struct imxfb_info *fbi) 572static void imxfb_disable_controller(struct imxfb_info *fbi)
567{ 573{
574 if (!fbi->enabled)
575 return;
576
568 pr_debug("Disabling LCD controller\n"); 577 pr_debug("Disabling LCD controller\n");
569 578
570 if (fbi->backlight_power) 579 if (fbi->backlight_power)
@@ -575,6 +584,7 @@ static void imxfb_disable_controller(struct imxfb_info *fbi)
575 clk_disable_unprepare(fbi->clk_per); 584 clk_disable_unprepare(fbi->clk_per);
576 clk_disable_unprepare(fbi->clk_ipg); 585 clk_disable_unprepare(fbi->clk_ipg);
577 clk_disable_unprepare(fbi->clk_ahb); 586 clk_disable_unprepare(fbi->clk_ahb);
587 fbi->enabled = false;
578 588
579 writel(0, fbi->regs + LCDC_RMCR); 589 writel(0, fbi->regs + LCDC_RMCR);
580} 590}
@@ -729,6 +739,8 @@ static int __init imxfb_init_fbinfo(struct platform_device *pdev)
729 739
730 memset(fbi, 0, sizeof(struct imxfb_info)); 740 memset(fbi, 0, sizeof(struct imxfb_info));
731 741
742 fbi->devtype = pdev->id_entry->driver_data;
743
732 strlcpy(info->fix.id, IMX_NAME, sizeof(info->fix.id)); 744 strlcpy(info->fix.id, IMX_NAME, sizeof(info->fix.id));
733 745
734 info->fix.type = FB_TYPE_PACKED_PIXELS; 746 info->fix.type = FB_TYPE_PACKED_PIXELS;
@@ -789,7 +801,6 @@ static int __init imxfb_probe(struct platform_device *pdev)
789 return -ENOMEM; 801 return -ENOMEM;
790 802
791 fbi = info->par; 803 fbi = info->par;
792 fbi->devtype = pdev->id_entry->driver_data;
793 804
794 if (!fb_mode) 805 if (!fb_mode)
795 fb_mode = pdata->mode[0].mode.name; 806 fb_mode = pdata->mode[0].mode.name;