--- /dev/null
+From cbbd379aa43890f36da934f5af619d2fb8ec3d87 Mon Sep 17 00:00:00 2001
+From: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
+Date: Thu, 25 Apr 2013 22:23:36 +0200
+Subject: drm/gma500: Increase max resolution for mode setting
+
+From: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
+
+commit cbbd379aa43890f36da934f5af619d2fb8ec3d87 upstream.
+
+By having a higher max resolution we can now set up a virtual
+framebuffer that spans several monitors. 4096 should be ok since we're
+gen 3 or higher and should be enough for most dual head setups.
+
+Bugzilla:
+https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-modesetting/+bug/1169147
+Signed-off-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/drm/gma500/framebuffer.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/gpu/drm/gma500/framebuffer.c
++++ b/drivers/gpu/drm/gma500/framebuffer.c
+@@ -772,8 +772,8 @@ void psb_modeset_init(struct drm_device
+ for (i = 0; i < dev_priv->num_pipe; i++)
+ psb_intel_crtc_init(dev, i, mode_dev);
+
+- dev->mode_config.max_width = 2048;
+- dev->mode_config.max_height = 2048;
++ dev->mode_config.max_width = 4096;
++ dev->mode_config.max_height = 4096;
+
+ psb_setup_outputs(dev);
+
--- /dev/null
+From e3de42b68478a8c95dd27520e9adead2af9477a5 Mon Sep 17 00:00:00 2001
+From: Imre Deak <imre.deak@intel.com>
+Date: Fri, 3 May 2013 19:44:07 +0200
+Subject: drm/i915: force full modeset if the connector is in DPMS OFF mode
+
+From: Imre Deak <imre.deak@intel.com>
+
+commit e3de42b68478a8c95dd27520e9adead2af9477a5 upstream.
+
+Currently the driver's assumed behavior for a modeset with an attached
+FB is that the corresponding connector will be switched to DPMS ON mode
+if it happened to be in DPMS OFF (or another power save mode). This
+wasn't enforced though if only the FB changed, everything else (format,
+connector etc.) remaining the same. In this case we only set the new FB
+base and left the connector in the old power save mode.
+
+Fix this by forcing a full modeset whenever there is an attached FB and
+any affected connector is in a power save mode.
+
+V_2: Run the test for encoders in power save mode outside the the
+test for fb change: user space may have just disabled the encoders
+but left everything else in place. Make sure the connector list is
+not empty before running this test.
+
+Signed-off-by: Imre Deak <imre.deak@intel.com>
+Signed-off-by: Egbert Eich <eich@suse.de>
+Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=61642
+Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=59834
+Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=59339
+Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64178
+Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=65559
+Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org>
+[danvet: Apply Jani's s/connector_off/is_crtc_connector_off bikeshed.]
+Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/drm/i915/intel_display.c | 24 ++++++++++++++++++++++--
+ 1 file changed, 22 insertions(+), 2 deletions(-)
+
+--- a/drivers/gpu/drm/i915/intel_display.c
++++ b/drivers/gpu/drm/i915/intel_display.c
+@@ -7960,6 +7960,21 @@ static void intel_set_config_restore_sta
+ }
+ }
+
++static bool
++is_crtc_connector_off(struct drm_crtc *crtc, struct drm_connector *connectors,
++ int num_connectors)
++{
++ int i;
++
++ for (i = 0; i < num_connectors; i++)
++ if (connectors[i].encoder &&
++ connectors[i].encoder->crtc == crtc &&
++ connectors[i].dpms != DRM_MODE_DPMS_ON)
++ return true;
++
++ return false;
++}
++
+ static void
+ intel_set_config_compute_mode_changes(struct drm_mode_set *set,
+ struct intel_set_config *config)
+@@ -7967,7 +7982,11 @@ intel_set_config_compute_mode_changes(st
+
+ /* We should be able to check here if the fb has the same properties
+ * and then just flip_or_move it */
+- if (set->crtc->fb != set->fb) {
++ if (set->connectors != NULL &&
++ is_crtc_connector_off(set->crtc, *set->connectors,
++ set->num_connectors)) {
++ config->mode_changed = true;
++ } else if (set->crtc->fb != set->fb) {
+ /* If we have no fb then treat it as a full mode set */
+ if (set->crtc->fb == NULL) {
+ DRM_DEBUG_KMS("crtc has no fb, full mode set\n");
+@@ -7979,8 +7998,9 @@ intel_set_config_compute_mode_changes(st
+ } else if (set->fb->bits_per_pixel !=
+ set->crtc->fb->bits_per_pixel) {
+ config->mode_changed = true;
+- } else
++ } else {
+ config->fb_changed = true;
++ }
+ }
+
+ if (set->fb && (set->x != set->crtc->x || set->y != set->crtc->y))
--- /dev/null
+From 2eb3a81eef0510511a3211bb3da560f446a8c8de Mon Sep 17 00:00:00 2001
+From: Michael Hennerich <michael.hennerich@analog.com>
+Date: Mon, 3 Jun 2013 14:30:00 +0100
+Subject: iio: frequency: ad4350: Fix bug / typo in mask
+
+From: Michael Hennerich <michael.hennerich@analog.com>
+
+commit 2eb3a81eef0510511a3211bb3da560f446a8c8de upstream.
+
+Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
+Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
+Signed-off-by: Jonathan Cameron <jic23@kernel.org>
+Signed-off-by: Jonghwan Choi <jhbird.choi@samsung.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/iio/frequency/adf4350.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/iio/frequency/adf4350.c
++++ b/drivers/iio/frequency/adf4350.c
+@@ -212,7 +212,7 @@ static int adf4350_set_freq(struct adf43
+ (pdata->r2_user_settings & (ADF4350_REG2_PD_POLARITY_POS |
+ ADF4350_REG2_LDP_6ns | ADF4350_REG2_LDF_INT_N |
+ ADF4350_REG2_CHARGE_PUMP_CURR_uA(5000) |
+- ADF4350_REG2_MUXOUT(0x7) | ADF4350_REG2_NOISE_MODE(0x9)));
++ ADF4350_REG2_MUXOUT(0x7) | ADF4350_REG2_NOISE_MODE(0x3)));
+
+ st->regs[ADF4350_REG3] = pdata->r3_user_settings &
+ (ADF4350_REG3_12BIT_CLKDIV(0xFFF) |
--- /dev/null
+From 6c5d4c96f979611f0165dc825af9e1cea8dd35b9 Mon Sep 17 00:00:00 2001
+From: Michael Hennerich <michael.hennerich@analog.com>
+Date: Mon, 3 Jun 2013 09:04:00 +0100
+Subject: iio:inkern: Fix typo/bug in convert raw to processed.
+
+From: Michael Hennerich <michael.hennerich@analog.com>
+
+commit 6c5d4c96f979611f0165dc825af9e1cea8dd35b9 upstream.
+
+Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
+Signed-off-by: Jonathan Cameron <jic23@kernel.org>
+Signed-off-by: Jonghwan Choi <jhbird.choi@samsung.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/iio/inkern.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/iio/inkern.c
++++ b/drivers/iio/inkern.c
+@@ -279,7 +279,7 @@ static int iio_convert_raw_to_processed_
+ s64 raw64 = raw;
+ int ret;
+
+- ret = iio_channel_read(chan, &offset, NULL, IIO_CHAN_INFO_SCALE);
++ ret = iio_channel_read(chan, &offset, NULL, IIO_CHAN_INFO_OFFSET);
+ if (ret == 0)
+ raw64 += offset;
+
--- /dev/null
+From 88e7b167a079f090405ab4390b629b5effdab41a Mon Sep 17 00:00:00 2001
+From: Brian King <brking@linux.vnet.ibm.com>
+Date: Mon, 8 Apr 2013 03:05:07 +0000
+Subject: pci: Set dev->dev.type in alloc_pci_dev
+
+From: Brian King <brking@linux.vnet.ibm.com>
+
+commit 88e7b167a079f090405ab4390b629b5effdab41a upstream.
+
+Set dev->dev.type in alloc_pci_dev so that archs that have their own
+versions of pci_setup_device get this set properly in order to ensure
+things like the boot_vga sysfs parameter get created as expected.
+
+Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
+Acked-by: Bjorn Helgaas <bhelgaas@google.com>
+Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
+Signed-off-by: Kleber Sacilotto de Souza <klebers@linux.vnet.ibm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/pci/probe.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/pci/probe.c
++++ b/drivers/pci/probe.c
+@@ -988,7 +988,6 @@ int pci_setup_device(struct pci_dev *dev
+ dev->sysdata = dev->bus->sysdata;
+ dev->dev.parent = dev->bus->bridge;
+ dev->dev.bus = &pci_bus_type;
+- dev->dev.type = &pci_dev_type;
+ dev->hdr_type = hdr_type & 0x7f;
+ dev->multifunction = !!(hdr_type & 0x80);
+ dev->error_state = pci_channel_io_normal;
+@@ -1208,6 +1207,7 @@ struct pci_dev *alloc_pci_dev(void)
+ return NULL;
+
+ INIT_LIST_HEAD(&dev->bus_list);
++ dev->dev.type = &pci_dev_type;
+
+ return dev;
+ }
--- /dev/null
+From 8ce3edac0a86f103bd1037110662d5d80a42dd5b Mon Sep 17 00:00:00 2001
+From: Guenter Roeck <linux@roeck-us.net>
+Date: Sat, 8 Jun 2013 07:23:47 -0700
+Subject: powerpc: Fix build error in stable/3.9
+
+From: Guenter Roeck <linux@roeck-us.net>
+
+Commit e71c42189 (powerpc/tm: Abort on emulation and alignment faults)
+introduced a powerpc build error in 3.9.5.
+
+Signed-off-by: Guenter Roeck <linux@roeck-us.net>
+Acked-by: Michael Neuling <mikey@neuling.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/powerpc/kernel/traps.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/arch/powerpc/kernel/traps.c
++++ b/arch/powerpc/kernel/traps.c
+@@ -1151,7 +1151,7 @@ void alignment_exception(struct pt_regs
+ local_irq_enable();
+
+ if (tm_abort_check(regs, TM_CAUSE_ALIGNMENT | TM_CAUSE_PERSISTENT))
+- goto bail;
++ return;
+
+ /* we don't implement logging of alignment exceptions */
+ if (!(current->thread.align_ctl & PR_UNALIGN_SIGBUS))
--- /dev/null
+From e61133dda480062d221f09e4fc18f66763f8ecd0 Mon Sep 17 00:00:00 2001
+From: Brian King <brking@linux.vnet.ibm.com>
+Date: Fri, 3 May 2013 11:30:59 +0000
+Subject: powerpc/pseries: Force 32 bit MSIs for devices that require it
+
+From: Brian King <brking@linux.vnet.ibm.com>
+
+commit e61133dda480062d221f09e4fc18f66763f8ecd0 upstream.
+
+The following patch implements a new PAPR change which allows
+the OS to force the use of 32 bit MSIs, regardless of what
+the PCI capabilities indicate. This is required for some
+devices that advertise support for 64 bit MSIs but don't
+actually support them.
+
+Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
+Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
+Signed-off-by: Kleber Sacilotto de Souza <klebers@linux.vnet.ibm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/powerpc/include/asm/pci-bridge.h | 2 ++
+ arch/powerpc/platforms/pseries/msi.c | 21 ++++++++++++++++++---
+ 2 files changed, 20 insertions(+), 3 deletions(-)
+
+--- a/arch/powerpc/include/asm/pci-bridge.h
++++ b/arch/powerpc/include/asm/pci-bridge.h
+@@ -154,6 +154,8 @@ struct pci_dn {
+
+ int pci_ext_config_space; /* for pci devices */
+
++ int force_32bit_msi:1;
++
+ struct pci_dev *pcidev; /* back-pointer to the pci device */
+ #ifdef CONFIG_EEH
+ struct eeh_dev *edev; /* eeh device */
+--- a/arch/powerpc/platforms/pseries/msi.c
++++ b/arch/powerpc/platforms/pseries/msi.c
+@@ -24,6 +24,7 @@ static int query_token, change_token;
+ #define RTAS_RESET_FN 2
+ #define RTAS_CHANGE_MSI_FN 3
+ #define RTAS_CHANGE_MSIX_FN 4
++#define RTAS_CHANGE_32MSI_FN 5
+
+ static struct pci_dn *get_pdn(struct pci_dev *pdev)
+ {
+@@ -58,7 +59,8 @@ static int rtas_change_msi(struct pci_dn
+
+ seq_num = 1;
+ do {
+- if (func == RTAS_CHANGE_MSI_FN || func == RTAS_CHANGE_MSIX_FN)
++ if (func == RTAS_CHANGE_MSI_FN || func == RTAS_CHANGE_MSIX_FN ||
++ func == RTAS_CHANGE_32MSI_FN)
+ rc = rtas_call(change_token, 6, 4, rtas_ret, addr,
+ BUID_HI(buid), BUID_LO(buid),
+ func, num_irqs, seq_num);
+@@ -426,9 +428,12 @@ static int rtas_setup_msi_irqs(struct pc
+ */
+ again:
+ if (type == PCI_CAP_ID_MSI) {
+- rc = rtas_change_msi(pdn, RTAS_CHANGE_MSI_FN, nvec);
++ if (pdn->force_32bit_msi)
++ rc = rtas_change_msi(pdn, RTAS_CHANGE_32MSI_FN, nvec);
++ else
++ rc = rtas_change_msi(pdn, RTAS_CHANGE_MSI_FN, nvec);
+
+- if (rc < 0) {
++ if (rc < 0 && !pdn->force_32bit_msi) {
+ pr_debug("rtas_msi: trying the old firmware call.\n");
+ rc = rtas_change_msi(pdn, RTAS_CHANGE_FN, nvec);
+ }
+@@ -512,3 +517,13 @@ static int rtas_msi_init(void)
+ return 0;
+ }
+ arch_initcall(rtas_msi_init);
++
++static void quirk_radeon(struct pci_dev *dev)
++{
++ struct pci_dn *pdn = get_pdn(dev);
++
++ if (pdn)
++ pdn->force_32bit_msi = 1;
++}
++DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x68f2, quirk_radeon);
++DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0xaa68, quirk_radeon);
--- /dev/null
+From f1dd153121dcb872ae6cba8d52bec97519eb7d97 Mon Sep 17 00:00:00 2001
+From: Brian King <brking@linux.vnet.ibm.com>
+Date: Wed, 22 May 2013 11:07:46 +0000
+Subject: powerpc/pseries: Make 32-bit MSI quirk work on systems lacking firmware support
+
+From: Brian King <brking@linux.vnet.ibm.com>
+
+commit f1dd153121dcb872ae6cba8d52bec97519eb7d97 upstream.
+
+Recent commit e61133dda480062d221f09e4fc18f66763f8ecd0 added support
+for a new firmware feature to force an adapter to use 32 bit MSIs.
+However, this firmware is not available for all systems. The hack below
+allows devices needing 32 bit MSIs to work on these systems as well.
+It is careful to only enable this on Gen2 slots, which should limit
+this to configurations where this hack is needed and tested to work.
+
+[Small change to factor out the hack into a separate function -- BenH]
+
+Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
+Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
+Signed-off-by: Kleber Sacilotto de Souza <klebers@linux.vnet.ibm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/powerpc/platforms/pseries/msi.c | 40 ++++++++++++++++++++++++++++++++---
+ 1 file changed, 37 insertions(+), 3 deletions(-)
+
+--- a/arch/powerpc/platforms/pseries/msi.c
++++ b/arch/powerpc/platforms/pseries/msi.c
+@@ -394,6 +394,23 @@ static int check_msix_entries(struct pci
+ return 0;
+ }
+
++static void rtas_hack_32bit_msi_gen2(struct pci_dev *pdev)
++{
++ u32 addr_hi, addr_lo;
++
++ /*
++ * We should only get in here for IODA1 configs. This is based on the
++ * fact that we using RTAS for MSIs, we don't have the 32 bit MSI RTAS
++ * support, and we are in a PCIe Gen2 slot.
++ */
++ dev_info(&pdev->dev,
++ "rtas_msi: No 32 bit MSI firmware support, forcing 32 bit MSI\n");
++ pci_read_config_dword(pdev, pdev->msi_cap + PCI_MSI_ADDRESS_HI, &addr_hi);
++ addr_lo = 0xffff0000 | ((addr_hi >> (48 - 32)) << 4);
++ pci_write_config_dword(pdev, pdev->msi_cap + PCI_MSI_ADDRESS_LO, addr_lo);
++ pci_write_config_dword(pdev, pdev->msi_cap + PCI_MSI_ADDRESS_HI, 0);
++}
++
+ static int rtas_setup_msi_irqs(struct pci_dev *pdev, int nvec_in, int type)
+ {
+ struct pci_dn *pdn;
+@@ -401,6 +418,7 @@ static int rtas_setup_msi_irqs(struct pc
+ struct msi_desc *entry;
+ struct msi_msg msg;
+ int nvec = nvec_in;
++ int use_32bit_msi_hack = 0;
+
+ pdn = get_pdn(pdev);
+ if (!pdn)
+@@ -428,15 +446,31 @@ static int rtas_setup_msi_irqs(struct pc
+ */
+ again:
+ if (type == PCI_CAP_ID_MSI) {
+- if (pdn->force_32bit_msi)
++ if (pdn->force_32bit_msi) {
+ rc = rtas_change_msi(pdn, RTAS_CHANGE_32MSI_FN, nvec);
+- else
++ if (rc < 0) {
++ /*
++ * We only want to run the 32 bit MSI hack below if
++ * the max bus speed is Gen2 speed
++ */
++ if (pdev->bus->max_bus_speed != PCIE_SPEED_5_0GT)
++ return rc;
++
++ use_32bit_msi_hack = 1;
++ }
++ } else
++ rc = -1;
++
++ if (rc < 0)
+ rc = rtas_change_msi(pdn, RTAS_CHANGE_MSI_FN, nvec);
+
+- if (rc < 0 && !pdn->force_32bit_msi) {
++ if (rc < 0) {
+ pr_debug("rtas_msi: trying the old firmware call.\n");
+ rc = rtas_change_msi(pdn, RTAS_CHANGE_FN, nvec);
+ }
++
++ if (use_32bit_msi_hack && rc > 0)
++ rtas_hack_32bit_msi_gen2(pdev);
+ } else
+ rc = rtas_change_msi(pdn, RTAS_CHANGE_MSIX_FN, nvec);
+
--- /dev/null
+From d82fb31abc46620b7c22758c75707069f2763646 Mon Sep 17 00:00:00 2001
+From: Kleber Sacilotto de Souza <klebers@linux.vnet.ibm.com>
+Date: Fri, 3 May 2013 12:43:12 +0000
+Subject: powerpc/pseries: Perform proper max_bus_speed detection
+
+From: Kleber Sacilotto de Souza <klebers@linux.vnet.ibm.com>
+
+commit d82fb31abc46620b7c22758c75707069f2763646 upstream.
+
+On pseries machines the detection for max_bus_speed should be done
+through an OpenFirmware property. This patch adds a function to perform
+this detection and a hook to perform dynamic adding of the function only
+for pseries. This is done by overwriting the weak
+pcibios_root_bridge_prepare function which is called by
+pci_create_root_bus().
+
+From: Lucas Kannebley Tavares <lucaskt@linux.vnet.ibm.com>
+Signed-off-by: Kleber Sacilotto de Souza <klebers@linux.vnet.ibm.com>
+Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/powerpc/include/asm/machdep.h | 3 +
+ arch/powerpc/kernel/pci-common.c | 8 ++++
+ arch/powerpc/platforms/pseries/pci.c | 53 +++++++++++++++++++++++++++++++
+ arch/powerpc/platforms/pseries/pseries.h | 4 ++
+ arch/powerpc/platforms/pseries/setup.c | 2 +
+ 5 files changed, 70 insertions(+)
+
+--- a/arch/powerpc/include/asm/machdep.h
++++ b/arch/powerpc/include/asm/machdep.h
+@@ -29,6 +29,7 @@ struct rtc_time;
+ struct file;
+ struct pci_controller;
+ struct kimage;
++struct pci_host_bridge;
+
+ struct machdep_calls {
+ char *name;
+@@ -107,6 +108,8 @@ struct machdep_calls {
+ void (*pcibios_fixup)(void);
+ int (*pci_probe_mode)(struct pci_bus *);
+ void (*pci_irq_fixup)(struct pci_dev *dev);
++ int (*pcibios_root_bridge_prepare)(struct pci_host_bridge
++ *bridge);
+
+ /* To setup PHBs when using automatic OF platform driver for PCI */
+ int (*pci_setup_phb)(struct pci_controller *host);
+--- a/arch/powerpc/kernel/pci-common.c
++++ b/arch/powerpc/kernel/pci-common.c
+@@ -845,6 +845,14 @@ int pci_proc_domain(struct pci_bus *bus)
+ return 1;
+ }
+
++int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
++{
++ if (ppc_md.pcibios_root_bridge_prepare)
++ return ppc_md.pcibios_root_bridge_prepare(bridge);
++
++ return 0;
++}
++
+ /* This header fixup will do the resource fixup for all devices as they are
+ * probed, but not for bridge ranges
+ */
+--- a/arch/powerpc/platforms/pseries/pci.c
++++ b/arch/powerpc/platforms/pseries/pci.c
+@@ -108,3 +108,56 @@ static void fixup_winbond_82c105(struct
+ }
+ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
+ fixup_winbond_82c105);
++
++int pseries_root_bridge_prepare(struct pci_host_bridge *bridge)
++{
++ struct device_node *dn, *pdn;
++ struct pci_bus *bus;
++ const uint32_t *pcie_link_speed_stats;
++
++ bus = bridge->bus;
++
++ dn = pcibios_get_phb_of_node(bus);
++ if (!dn)
++ return 0;
++
++ for (pdn = dn; pdn != NULL; pdn = of_get_next_parent(pdn)) {
++ pcie_link_speed_stats = (const uint32_t *) of_get_property(pdn,
++ "ibm,pcie-link-speed-stats", NULL);
++ if (pcie_link_speed_stats)
++ break;
++ }
++
++ of_node_put(pdn);
++
++ if (!pcie_link_speed_stats) {
++ pr_err("no ibm,pcie-link-speed-stats property\n");
++ return 0;
++ }
++
++ switch (pcie_link_speed_stats[0]) {
++ case 0x01:
++ bus->max_bus_speed = PCIE_SPEED_2_5GT;
++ break;
++ case 0x02:
++ bus->max_bus_speed = PCIE_SPEED_5_0GT;
++ break;
++ default:
++ bus->max_bus_speed = PCI_SPEED_UNKNOWN;
++ break;
++ }
++
++ switch (pcie_link_speed_stats[1]) {
++ case 0x01:
++ bus->cur_bus_speed = PCIE_SPEED_2_5GT;
++ break;
++ case 0x02:
++ bus->cur_bus_speed = PCIE_SPEED_5_0GT;
++ break;
++ default:
++ bus->cur_bus_speed = PCI_SPEED_UNKNOWN;
++ break;
++ }
++
++ return 0;
++}
+--- a/arch/powerpc/platforms/pseries/pseries.h
++++ b/arch/powerpc/platforms/pseries/pseries.h
+@@ -60,4 +60,8 @@ extern int dlpar_detach_node(struct devi
+ /* Snooze Delay, pseries_idle */
+ DECLARE_PER_CPU(long, smt_snooze_delay);
+
++/* PCI root bridge prepare function override for pseries */
++struct pci_host_bridge;
++int pseries_root_bridge_prepare(struct pci_host_bridge *bridge);
++
+ #endif /* _PSERIES_PSERIES_H */
+--- a/arch/powerpc/platforms/pseries/setup.c
++++ b/arch/powerpc/platforms/pseries/setup.c
+@@ -466,6 +466,8 @@ static void __init pSeries_setup_arch(vo
+ else
+ ppc_md.enable_pmcs = power4_enable_pmcs;
+
++ ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare;
++
+ if (firmware_has_feature(FW_FEATURE_SET_MODE)) {
+ long rc;
+ if ((rc = pSeries_enable_reloc_on_exc()) != H_SUCCESS) {
--- /dev/null
+From c2e1d84523ad2a19e5be08c1f01999cc9e82652e Mon Sep 17 00:00:00 2001
+From: Brian King <brking@linux.vnet.ibm.com>
+Date: Mon, 8 Apr 2013 03:05:10 +0000
+Subject: powerpc: Set default VGA device
+
+From: Brian King <brking@linux.vnet.ibm.com>
+
+commit c2e1d84523ad2a19e5be08c1f01999cc9e82652e upstream.
+
+Add a PCI quirk for VGA devices on Power to set the default VGA device.
+Ensures a default VGA is always set if a graphics adapter is present,
+even if firmware did not initialize it. If more than one graphics
+adapter is present, ensure the one initialized by firmware is set
+as the default VGA device. This ensures that X autoconfiguration
+will work.
+
+Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
+Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
+Signed-off-by: Kleber Sacilotto de Souza <klebers@linux.vnet.ibm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/powerpc/kernel/pci-common.c | 13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+--- a/arch/powerpc/kernel/pci-common.c
++++ b/arch/powerpc/kernel/pci-common.c
+@@ -30,6 +30,7 @@
+ #include <linux/irq.h>
+ #include <linux/vmalloc.h>
+ #include <linux/slab.h>
++#include <linux/vgaarb.h>
+
+ #include <asm/processor.h>
+ #include <asm/io.h>
+@@ -1725,3 +1726,15 @@ static void fixup_hide_host_resource_fsl
+ }
+ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MOTOROLA, PCI_ANY_ID, fixup_hide_host_resource_fsl);
+ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_FREESCALE, PCI_ANY_ID, fixup_hide_host_resource_fsl);
++
++static void fixup_vga(struct pci_dev *pdev)
++{
++ u16 cmd;
++
++ pci_read_config_word(pdev, PCI_COMMAND, &cmd);
++ if ((cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) || !vga_default_device())
++ vga_set_default_device(pdev);
++
++}
++DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID,
++ PCI_CLASS_DISPLAY_VGA, 8, fixup_vga);
--- /dev/null
+From 7e0e41963740525af702bb23edede8ae9afc4ac0 Mon Sep 17 00:00:00 2001
+From: Kleber Sacilotto de Souza <klebers@linux.vnet.ibm.com>
+Date: Fri, 3 May 2013 19:43:13 -0300
+Subject: radeon: use max_bus_speed to activate gen2 speeds
+
+From: Kleber Sacilotto de Souza <klebers@linux.vnet.ibm.com>
+
+commit 7e0e41963740525af702bb23edede8ae9afc4ac0 upstream.
+
+radeon currently uses a drm function to get the speed capabilities for
+the bus, drm_pcie_get_speed_cap_mask. However, this is a non-standard
+method of performing this detection and this patch changes it to use
+the max_bus_speed attribute.
+
+From: Lucas Kannebley Tavares <lucaskt@linux.vnet.ibm.com>
+Signed-off-by: Kleber Sacilotto de Souza <klebers@linux.vnet.ibm.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/drm/radeon/evergreen.c | 10 +++-------
+ drivers/gpu/drm/radeon/r600.c | 9 ++-------
+ drivers/gpu/drm/radeon/rv770.c | 9 ++-------
+ 3 files changed, 7 insertions(+), 21 deletions(-)
+
+--- a/drivers/gpu/drm/radeon/evergreen.c
++++ b/drivers/gpu/drm/radeon/evergreen.c
+@@ -3946,8 +3946,7 @@ void evergreen_fini(struct radeon_device
+
+ void evergreen_pcie_gen2_enable(struct radeon_device *rdev)
+ {
+- u32 link_width_cntl, speed_cntl, mask;
+- int ret;
++ u32 link_width_cntl, speed_cntl;
+
+ if (radeon_pcie_gen2 == 0)
+ return;
+@@ -3962,11 +3961,8 @@ void evergreen_pcie_gen2_enable(struct r
+ if (ASIC_IS_X2(rdev))
+ return;
+
+- ret = drm_pcie_get_speed_cap_mask(rdev->ddev, &mask);
+- if (ret != 0)
+- return;
+-
+- if (!(mask & DRM_PCIE_SPEED_50))
++ if ((rdev->pdev->bus->max_bus_speed != PCIE_SPEED_5_0GT) &&
++ (rdev->pdev->bus->max_bus_speed != PCIE_SPEED_8_0GT))
+ return;
+
+ speed_cntl = RREG32_PCIE_P(PCIE_LC_SPEED_CNTL);
+--- a/drivers/gpu/drm/radeon/r600.c
++++ b/drivers/gpu/drm/radeon/r600.c
+@@ -4353,8 +4353,6 @@ static void r600_pcie_gen2_enable(struct
+ {
+ u32 link_width_cntl, lanes, speed_cntl, training_cntl, tmp;
+ u16 link_cntl2;
+- u32 mask;
+- int ret;
+
+ if (radeon_pcie_gen2 == 0)
+ return;
+@@ -4373,11 +4371,8 @@ static void r600_pcie_gen2_enable(struct
+ if (rdev->family <= CHIP_R600)
+ return;
+
+- ret = drm_pcie_get_speed_cap_mask(rdev->ddev, &mask);
+- if (ret != 0)
+- return;
+-
+- if (!(mask & DRM_PCIE_SPEED_50))
++ if ((rdev->pdev->bus->max_bus_speed != PCIE_SPEED_5_0GT) &&
++ (rdev->pdev->bus->max_bus_speed != PCIE_SPEED_8_0GT))
+ return;
+
+ speed_cntl = RREG32_PCIE_P(PCIE_LC_SPEED_CNTL);
+--- a/drivers/gpu/drm/radeon/rv770.c
++++ b/drivers/gpu/drm/radeon/rv770.c
+@@ -1240,8 +1240,6 @@ static void rv770_pcie_gen2_enable(struc
+ {
+ u32 link_width_cntl, lanes, speed_cntl, tmp;
+ u16 link_cntl2;
+- u32 mask;
+- int ret;
+
+ if (radeon_pcie_gen2 == 0)
+ return;
+@@ -1256,11 +1254,8 @@ static void rv770_pcie_gen2_enable(struc
+ if (ASIC_IS_X2(rdev))
+ return;
+
+- ret = drm_pcie_get_speed_cap_mask(rdev->ddev, &mask);
+- if (ret != 0)
+- return;
+-
+- if (!(mask & DRM_PCIE_SPEED_50))
++ if ((rdev->pdev->bus->max_bus_speed != PCIE_SPEED_5_0GT) &&
++ (rdev->pdev->bus->max_bus_speed != PCIE_SPEED_8_0GT))
+ return;
+
+ DRM_INFO("enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n");
drm-i915-no-lvds-quirk-for-hp-t5740.patch
drm-i915-fix-spurious-eio-sigbus-on-wedged-gpus.patch
revert-acpi-scan-do-not-match-drivers-against-objects-having-scan-handlers.patch
+powerpc-fix-build-error-in-stable-3.9.patch
+usb-dwc3-gadget-free-trb-pool-only-from-epnum-2.patch
+drm-gma500-increase-max-resolution-for-mode-setting.patch
+pci-set-dev-dev.type-in-alloc_pci_dev.patch
+powerpc-set-default-vga-device.patch
+powerpc-pseries-force-32-bit-msis-for-devices-that-require-it.patch
+powerpc-pseries-make-32-bit-msi-quirk-work-on-systems-lacking-firmware-support.patch
+powerpc-pseries-perform-proper-max_bus_speed-detection.patch
+radeon-use-max_bus_speed-to-activate-gen2-speeds.patch
+iio-inkern-fix-typo-bug-in-convert-raw-to-processed.patch
+iio-frequency-ad4350-fix-bug-typo-in-mask.patch
+drm-i915-force-full-modeset-if-the-connector-is-in-dpms-off-mode.patch
+usb-serial-add-wait_until_sent-operation.patch
+usb-serial-add-generic-wait_until_sent-implementation.patch
--- /dev/null
+From 5bf8fae33d14cc5c3c53a926f9079f92c8b082b0 Mon Sep 17 00:00:00 2001
+From: George Cherian <george.cherian@ti.com>
+Date: Mon, 27 May 2013 14:35:49 +0530
+Subject: usb: dwc3: gadget: free trb pool only from epnum 2
+
+From: George Cherian <george.cherian@ti.com>
+
+commit 5bf8fae33d14cc5c3c53a926f9079f92c8b082b0 upstream.
+
+we never allocate a TRB pool for physical endpoints
+0 and 1 so trying to free it (a invalid TRB pool pointer)
+will lead us in a warning while removing dwc3.ko module.
+
+In order to fix the situation, all we have to do is skip
+dwc3_free_trb_pool() for physical endpoints 0 and 1 just
+as we while deleting endpoints from the endpoints list.
+
+Signed-off-by: George Cherian <george.cherian@ti.com>
+Signed-off-by: Felipe Balbi <balbi@ti.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+
+---
+ drivers/usb/dwc3/gadget.c | 14 ++++++++++++--
+ 1 file changed, 12 insertions(+), 2 deletions(-)
+
+--- a/drivers/usb/dwc3/gadget.c
++++ b/drivers/usb/dwc3/gadget.c
+@@ -1637,10 +1637,20 @@ static void dwc3_gadget_free_endpoints(s
+
+ for (epnum = 0; epnum < DWC3_ENDPOINTS_NUM; epnum++) {
+ dep = dwc->eps[epnum];
+- dwc3_free_trb_pool(dep);
+
+- if (epnum != 0 && epnum != 1)
++ /*
++ * Physical endpoints 0 and 1 are special; they form the
++ * bi-directional USB endpoint 0.
++ *
++ * For those two physical endpoints, we don't allocate a TRB
++ * pool nor do we add them the endpoints list. Due to that, we
++ * shouldn't do these two operations otherwise we would end up
++ * with all sorts of bugs when removing dwc3.ko.
++ */
++ if (epnum != 0 && epnum != 1) {
++ dwc3_free_trb_pool(dep);
+ list_del(&dep->endpoint.ep_list);
++ }
+
+ kfree(dep);
+ }
--- /dev/null
+From dcf0105039660e951dfea348d317043d17988dfc Mon Sep 17 00:00:00 2001
+From: Johan Hovold <jhovold@gmail.com>
+Date: Wed, 8 May 2013 17:51:43 +0200
+Subject: USB: serial: add generic wait_until_sent implementation
+
+From: Johan Hovold <jhovold@gmail.com>
+
+commit dcf0105039660e951dfea348d317043d17988dfc upstream.
+
+Add generic wait_until_sent implementation which polls for empty
+hardware buffers using the new port-operation tx_empty.
+
+The generic implementation will be used for all sub-drivers that
+implement tx_empty but does not define wait_until_sent.
+
+Signed-off-by: Johan Hovold <jhovold@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/serial/generic.c | 31 +++++++++++++++++++++++++++++++
+ drivers/usb/serial/usb-serial.c | 2 ++
+ include/linux/usb/serial.h | 3 +++
+ 3 files changed, 36 insertions(+)
+
+--- a/drivers/usb/serial/generic.c
++++ b/drivers/usb/serial/generic.c
+@@ -264,6 +264,37 @@ int usb_serial_generic_chars_in_buffer(s
+ }
+ EXPORT_SYMBOL_GPL(usb_serial_generic_chars_in_buffer);
+
++void usb_serial_generic_wait_until_sent(struct tty_struct *tty, long timeout)
++{
++ struct usb_serial_port *port = tty->driver_data;
++ unsigned int bps;
++ unsigned long period;
++ unsigned long expire;
++
++ bps = tty_get_baud_rate(tty);
++ if (!bps)
++ bps = 9600; /* B0 */
++ /*
++ * Use a poll-period of roughly the time it takes to send one
++ * character or at least one jiffy.
++ */
++ period = max_t(unsigned long, (10 * HZ / bps), 1);
++ period = min_t(unsigned long, period, timeout);
++
++ dev_dbg(&port->dev, "%s - timeout = %u ms, period = %u ms\n",
++ __func__, jiffies_to_msecs(timeout),
++ jiffies_to_msecs(period));
++ expire = jiffies + timeout;
++ while (!port->serial->type->tx_empty(port)) {
++ schedule_timeout_interruptible(period);
++ if (signal_pending(current))
++ break;
++ if (time_after(jiffies, expire))
++ break;
++ }
++}
++EXPORT_SYMBOL_GPL(usb_serial_generic_wait_until_sent);
++
+ static int usb_serial_generic_submit_read_urb(struct usb_serial_port *port,
+ int index, gfp_t mem_flags)
+ {
+--- a/drivers/usb/serial/usb-serial.c
++++ b/drivers/usb/serial/usb-serial.c
+@@ -1346,6 +1346,8 @@ static void fixup_generic(struct usb_ser
+ set_to_generic_if_null(device, close);
+ set_to_generic_if_null(device, write_room);
+ set_to_generic_if_null(device, chars_in_buffer);
++ if (device->tx_empty)
++ set_to_generic_if_null(device, wait_until_sent);
+ set_to_generic_if_null(device, read_bulk_callback);
+ set_to_generic_if_null(device, write_bulk_callback);
+ set_to_generic_if_null(device, disconnect);
+--- a/include/linux/usb/serial.h
++++ b/include/linux/usb/serial.h
+@@ -268,6 +268,7 @@ struct usb_serial_driver {
+ void (*break_ctl)(struct tty_struct *tty, int break_state);
+ int (*chars_in_buffer)(struct tty_struct *tty);
+ void (*wait_until_sent)(struct tty_struct *tty, long timeout);
++ bool (*tx_empty)(struct usb_serial_port *port);
+ void (*throttle)(struct tty_struct *tty);
+ void (*unthrottle)(struct tty_struct *tty);
+ int (*tiocmget)(struct tty_struct *tty);
+@@ -326,6 +327,8 @@ extern void usb_serial_generic_close(str
+ extern int usb_serial_generic_resume(struct usb_serial *serial);
+ extern int usb_serial_generic_write_room(struct tty_struct *tty);
+ extern int usb_serial_generic_chars_in_buffer(struct tty_struct *tty);
++extern void usb_serial_generic_wait_until_sent(struct tty_struct *tty,
++ long timeout);
+ extern void usb_serial_generic_read_bulk_callback(struct urb *urb);
+ extern void usb_serial_generic_write_bulk_callback(struct urb *urb);
+ extern void usb_serial_generic_throttle(struct tty_struct *tty);
--- /dev/null
+From 0693196fe7bbb5e6cafd255dfce91ff6d10bc18f Mon Sep 17 00:00:00 2001
+From: Johan Hovold <jhovold@gmail.com>
+Date: Sun, 5 May 2013 20:32:27 +0200
+Subject: USB: serial: add wait_until_sent operation
+
+From: Johan Hovold <jhovold@gmail.com>
+
+commit 0693196fe7bbb5e6cafd255dfce91ff6d10bc18f upstream.
+
+Add wait_until_sent operation which can be used to wait for hardware
+buffers to drain.
+
+Signed-off-by: Johan Hovold <jhovold@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/usb/serial/usb-serial.c | 17 +++++++++++++++++
+ include/linux/usb/serial.h | 1 +
+ 2 files changed, 18 insertions(+)
+
+--- a/drivers/usb/serial/usb-serial.c
++++ b/drivers/usb/serial/usb-serial.c
+@@ -379,6 +379,22 @@ static int serial_chars_in_buffer(struct
+ return count;
+ }
+
++static void serial_wait_until_sent(struct tty_struct *tty, int timeout)
++{
++ struct usb_serial_port *port = tty->driver_data;
++ struct usb_serial *serial = port->serial;
++
++ dev_dbg(tty->dev, "%s\n", __func__);
++
++ if (!port->serial->type->wait_until_sent)
++ return;
++
++ mutex_lock(&serial->disc_mutex);
++ if (!serial->disconnected)
++ port->serial->type->wait_until_sent(tty, timeout);
++ mutex_unlock(&serial->disc_mutex);
++}
++
+ static void serial_throttle(struct tty_struct *tty)
+ {
+ struct usb_serial_port *port = tty->driver_data;
+@@ -1204,6 +1220,7 @@ static const struct tty_operations seria
+ .unthrottle = serial_unthrottle,
+ .break_ctl = serial_break,
+ .chars_in_buffer = serial_chars_in_buffer,
++ .wait_until_sent = serial_wait_until_sent,
+ .tiocmget = serial_tiocmget,
+ .tiocmset = serial_tiocmset,
+ .get_icount = serial_get_icount,
+--- a/include/linux/usb/serial.h
++++ b/include/linux/usb/serial.h
+@@ -267,6 +267,7 @@ struct usb_serial_driver {
+ struct usb_serial_port *port, struct ktermios *old);
+ void (*break_ctl)(struct tty_struct *tty, int break_state);
+ int (*chars_in_buffer)(struct tty_struct *tty);
++ void (*wait_until_sent)(struct tty_struct *tty, long timeout);
+ void (*throttle)(struct tty_struct *tty);
+ void (*unthrottle)(struct tty_struct *tty);
+ int (*tiocmget)(struct tty_struct *tty);