Re: [ 094/136 ] e1000e: fix runtime power management transitions

2013-05-17 Thread Jeff Kirsher
On Sat, 2013-05-18 at 09:35 +0400, Konstantin Khlebnikov wrote:
> Steven Rostedt wrote:
> > 3.6.11.4 stable review patch.
> > If anyone has any objections, please let me know.
> 
> I don't think that 3.6.y needs this. That was fix for problem which appeared
> in 3.8 after some changes in PCI power management code. Probably it depends
> on these changes. If no one complains about problems we should leave it as is.

My thoughts are the same as Konstantin, but I would like Bruce Allan to
weigh in on this since he is the e1000e maintainer.  Since it is late
Friday night, Bruce probably won't see this until Monday to respond.

> >
> > --
> >
> > From: Konstantin Khlebnikov
> >
> > [ Upstream commit 66148babe728f3e00e13c56f6b0ecf325abd80da ]
> >
> > This patch removes redundant actions from driver and fixes its interaction
> > with actions in pci-bus runtime power management code.
> >
> > It removes pci_save_state() from __e1000_shutdown() for normal adapters,
> > PCI bus callbacks pci_pm_*() will do all this for us. Now __e1000_shutdown()
> > switches to D3-state only quad-port adapters, because they needs quirk for
> > clearing false-positive error from downsteam pci-e port.
> >
> > pci_save_state() now called after clearing bus-master bit, thus 
> > __e1000_resume()
> > and e1000_io_slot_reset() must set it back after restoring configuration 
> > space.
> >
> > This patch set get_link_status before calling pm_runtime_put() in 
> > e1000_open()
> > to allow e1000_idle() get real link status and schedule first runtime 
> > suspend.
> >
> > This patch also enables wakeup for device if management mode is enabled
> > (like for WoL) as result pci_prepare_to_sleep() would setup wakeup without
> > special actions like custom 'enable_wakeup' sign.
> >
> > Cc: Bruce Allan
> > Signed-off-by: Konstantin Khlebnikov
> > Acked-by: Rafael J. Wysocki
> > Tested-by: Borislav Petkov
> > Tested-by: Aaron Brown
> > Signed-off-by: Jeff Kirsher
> > Signed-off-by: Steven Rostedt
> 




signature.asc
Description: This is a digitally signed message part


Re: [ 094/136 ] e1000e: fix runtime power management transitions

2013-05-17 Thread Konstantin Khlebnikov

Steven Rostedt wrote:

3.6.11.4 stable review patch.
If anyone has any objections, please let me know.


I don't think that 3.6.y needs this. That was fix for problem which appeared
in 3.8 after some changes in PCI power management code. Probably it depends
on these changes. If no one complains about problems we should leave it as is.



--

From: Konstantin Khlebnikov

[ Upstream commit 66148babe728f3e00e13c56f6b0ecf325abd80da ]

This patch removes redundant actions from driver and fixes its interaction
with actions in pci-bus runtime power management code.

It removes pci_save_state() from __e1000_shutdown() for normal adapters,
PCI bus callbacks pci_pm_*() will do all this for us. Now __e1000_shutdown()
switches to D3-state only quad-port adapters, because they needs quirk for
clearing false-positive error from downsteam pci-e port.

pci_save_state() now called after clearing bus-master bit, thus __e1000_resume()
and e1000_io_slot_reset() must set it back after restoring configuration space.

This patch set get_link_status before calling pm_runtime_put() in e1000_open()
to allow e1000_idle() get real link status and schedule first runtime suspend.

This patch also enables wakeup for device if management mode is enabled
(like for WoL) as result pci_prepare_to_sleep() would setup wakeup without
special actions like custom 'enable_wakeup' sign.

Cc: Bruce Allan
Signed-off-by: Konstantin Khlebnikov
Acked-by: Rafael J. Wysocki
Tested-by: Borislav Petkov
Tested-by: Aaron Brown
Signed-off-by: Jeff Kirsher
Signed-off-by: Steven Rostedt


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V4 22/30] thermal: exynos: Add support for exynos5440 TMU sensor.

2013-05-17 Thread jonghwa3 . lee
On 2013년 05월 14일 18:58, Amit Daniel Kachhap wrote:

> This patch modifies TMU controller to add changes needed to work with
> exynos5440 platform. This sensor registers 3 instance of the tmu controller
> with the thermal zone and hence reports 3 temperature output. This controller
> supports upto five trip points. For critical threshold the driver uses the
> core driver thermal framework for shutdown.
> 
> Acked-by: Kukjin Kim 
> Signed-off-by: Amit Daniel Kachhap 
> ---
>  .../devicetree/bindings/thermal/exynos-thermal.txt |   28 -
>  drivers/thermal/samsung/exynos_tmu.c   |   43 +--
>  drivers/thermal/samsung/exynos_tmu.h   |6 +++
>  drivers/thermal/samsung/exynos_tmu_data.h  |2 +
>  4 files changed, 72 insertions(+), 7 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt 
> b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
> index 535fd0e..970eeba 100644
> --- a/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
> +++ b/Documentation/devicetree/bindings/thermal/exynos-thermal.txt
> @@ -6,13 +6,16 @@
>  "samsung,exynos4412-tmu"
>  "samsung,exynos4210-tmu"
>  "samsung,exynos5250-tmu"
> +"samsung,exynos5440-tmu"
>  - interrupt-parent : The phandle for the interrupt controller
> -- reg : Address range of the thermal registers
> +- reg : Address range of the thermal registers. For exynos5440-tmu which has 
> 3
> + instances of TMU, 2 set of register has to supplied. First set belongs
> + to each instance of TMU and second set belongs to common TMU registers.
>  - interrupts : Should contain interrupt for thermal system
>  - clocks : The main clock for TMU device
>  - clock-names : Thermal system clock name
>  
> -Example:
> +Example 1):
>  
>   tmu@100C {
>   compatible = "samsung,exynos4412-tmu";
> @@ -23,3 +26,24 @@ Example:
>   clock-names = "tmu_apbif";
>   status = "disabled";
>   };
> +
> +Example 2):
> +
> + tmuctrl_0: tmuctrl@160118 {
> + compatible = "samsung,exynos5440-tmu";
> + reg = <0x160118 0x230>, <0x160368 0x10>;
> + interrupts = <0 58 0>;
> + clocks = < 21>;
> + clock-names = "tmu_apbif";
> + };
> +
> +Note: For multi-instance tmu each instance should have an alias correctly
> +numbered in "aliases" node.
> +
> +Example:
> +
> +aliases {
> + tmuctrl0 = _0;
> + tmuctrl1 = _1;
> + tmuctrl2 = _2;
> +};
> diff --git a/drivers/thermal/samsung/exynos_tmu.c 
> b/drivers/thermal/samsung/exynos_tmu.c
> index 7f7b1cf..7ca9c4d 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c
> @@ -185,9 +185,11 @@ static int exynos_tmu_initialize(struct platform_device 
> *pdev)
>   reg->threshold_th0 + i * sizeof(reg->threshold_th0));
>  
>   writel(reg->inten_rise_mask, data->base + reg->tmu_intclear);
> - } else if (data->soc == SOC_ARCH_EXYNOS) {
> + } else if (data->soc == SOC_ARCH_EXYNOS ||
> + data->soc == SOC_ARCH_EXYNOS5440) {
>   /* Write temperature code for rising and falling threshold */
> - for (i = 0; i < trigger_levs; i++) {
> + for (i = 0;
> + i < trigger_levs && i < EXYNOS_MAX_TRIGGER_PER_REG; i++) {
>   threshold_code = temp_to_code(data,
>   pdata->trigger_levels[i]);
>   if (threshold_code < 0) {
> @@ -218,7 +220,30 @@ static int exynos_tmu_initialize(struct platform_device 
> *pdev)
>   writel((reg->inten_rise_mask << reg->inten_rise_shift) |
>   (reg->inten_fall_mask << reg->inten_fall_shift),
>   data->base + reg->tmu_intclear);
> +
> + /* if 5th threshold limit is also present, use TH2 register */
> + i = EXYNOS_MAX_TRIGGER_PER_REG;
> + if (pdata->trigger_levels[i]) {
> + threshold_code = temp_to_code(data,
> + pdata->trigger_levels[i]);
> + if (threshold_code < 0) {
> + ret = threshold_code;
> + goto out;
> + }
> + rising_threshold =
> + threshold_code << reg->threshold_th3_l0_shift;
> + writel(rising_threshold,
> + data->base + reg->threshold_th2);
> + if (pdata->trigger_type[i] == HW_TRIP) {
> + con = readl(data->base + reg->tmu_ctrl);
> + con |= (1 << reg->therm_trip_en_shift);
> + writel(con, data->base + reg->tmu_ctrl);
> + }
> + }
>   }
> + /*Clear the PMIN 

Re: [PATCH net-next] net: netdev_pick_tx: use get_xps_q if xps map is set

2013-05-17 Thread govind

On 05/18/2013 03:33 AM, Eric Dumazet wrote:
On Sat, 2013-05-18 at 01:20 +0530, govind wrote:


I see. In ixgbe_select_queue we use __netdev_pick_tx only if packet is not
FCOE & FIP.

If you see
bnx2x_select_queue in drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c, line 1832
and mlx4_en_select_queue in drivers/net/ethernet/mellanox/mlx4/en_tx.c, line 
547.
we cannot have xps working with these drivers.

This needs to be fixed by replacing __skb_tx_hash with __netdev_pick_tx. Am i
correct?


Yes, this seems better.


thanks eric, i will send patch soon.

//govind
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance issue since 3.2.6

2013-05-17 Thread Srivatsa S. Bhat
On 05/18/2013 05:21 AM, Rafael J. Wysocki wrote:
> On Saturday, May 18, 2013 01:20:10 AM Srivatsa S. Bhat wrote:
>> On 05/17/2013 11:47 PM, Olivier Doucet wrote:
>>> Hello,
>>>
>>> This performance penalty is still present in kernel 3.9.2. And
>>> CONFIG_PM cannot be deactivated anymore.
>>>
>>> I was able to make a working 3.9.2 (meaning with no penalty)  with
>>> following config and patch :
>>> CONFIG_PM=y
>>> CONFIG_PM_SLEEP=y
>>> CONFIG_PM_SLEEP_SMP=y
>>> CONFIG_CPU_IDLE=y
>>> CONFIG_ACPI=y
>>> CONFIG_ACPI_PROCESSOR=y
>>>
>>> Patch : https://gist.github.com/odoucet/5600630
>>>
[...]
>> So, to summarize my thoughts:
>>  - IMHO there is no regression here, you just depended on a bug included
>>in 3.2.0 (which made it behave like idle=poll with CONFIG_PM=n) and
>>started your comparisons from there. The later kernels (3.2.6+) got
>>that bug fixed which is why you saw "performance drops".
>>
>>  - As much as we would like to do it, we can't set the value of
>>PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE to 0 when CONFIG_PM=n, because
>>CONFIG_PM doesn't encompass all power-management features (which is
>>a pity). Doing that would need a big overhaul of all the relevant
>>Kconfigs, which might or might not be worth the effort. (Because, who
>>says that CONFIG_PM=n kernels are supposed to eat power like crazy??)
> 
> I think it *is* worth the effort.  We could drop some CONFIG_PM* options in 
> the
> process which would simplify things quite a bit too.
>

Ah, ok..
 
>> So here is my suggestion - use the interfaces provided by the kernel to
>> fix your problem:
>>- you can give idle=poll in the kernel command line,
>>- OR you can echo 0 > /dev/cpu_dma_latency
>>
>> Irrespective of your kernel configuration options (CONFIG_PM=y/n), the
>> CPUs will not enter deep idle states, giving you the performance
>> improvement that you are looking for.
> 
> Thanks a lot for the very clear explanation of this!
> 

No problem! :-)

Regards,
Srivatsa S. Bhat

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv8 2/3] net: velocity: Convert to generic dma functions

2013-05-17 Thread Tony Prisk
Remove the pci_* dma functions and replace with the more generic
versions.

In preparation of adding platform support, a new struct device *dev
is added to struct velocity_info which can be used by both the pci
and platform code.

Signed-off-by: Tony Prisk 
---
 drivers/net/ethernet/via/via-velocity.c |   51 +++
 drivers/net/ethernet/via/via-velocity.h |1 +
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/via/via-velocity.c 
b/drivers/net/ethernet/via/via-velocity.c
index 187eef3..5996cee 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c
@@ -46,6 +46,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1459,7 +1460,6 @@ static int velocity_init_dma_rings(struct velocity_info 
*vptr)
struct velocity_opt *opt = >options;
const unsigned int rx_ring_size = opt->numrx * sizeof(struct rx_desc);
const unsigned int tx_ring_size = opt->numtx * sizeof(struct tx_desc);
-   struct pci_dev *pdev = vptr->pdev;
dma_addr_t pool_dma;
void *pool;
unsigned int i;
@@ -1467,13 +1467,13 @@ static int velocity_init_dma_rings(struct velocity_info 
*vptr)
/*
 * Allocate all RD/TD rings a single pool.
 *
-* pci_alloc_consistent() fulfills the requirement for 64 bytes
+* dma_alloc_coherent() fulfills the requirement for 64 bytes
 * alignment
 */
-   pool = pci_alloc_consistent(pdev, tx_ring_size * vptr->tx.numq +
-   rx_ring_size, _dma);
+   pool = dma_alloc_coherent(vptr->dev, tx_ring_size * vptr->tx.numq +
+   rx_ring_size, _dma, GFP_ATOMIC);
if (!pool) {
-   dev_err(>dev, "%s : DMA memory allocation failed.\n",
+   dev_err(vptr->dev, "%s : DMA memory allocation failed.\n",
vptr->netdev->name);
return -ENOMEM;
}
@@ -1524,8 +1524,8 @@ static int velocity_alloc_rx_buf(struct velocity_info 
*vptr, int idx)
 */
skb_reserve(rd_info->skb,
64 - ((unsigned long) rd_info->skb->data & 63));
-   rd_info->skb_dma = pci_map_single(vptr->pdev, rd_info->skb->data,
-   vptr->rx.buf_sz, PCI_DMA_FROMDEVICE);
+   rd_info->skb_dma = dma_map_single(vptr->dev, rd_info->skb->data,
+   vptr->rx.buf_sz, DMA_FROM_DEVICE);
 
/*
 *  Fill in the descriptor to match
@@ -1588,8 +1588,8 @@ static void velocity_free_rd_ring(struct velocity_info 
*vptr)
 
if (!rd_info->skb)
continue;
-   pci_unmap_single(vptr->pdev, rd_info->skb_dma, vptr->rx.buf_sz,
-PCI_DMA_FROMDEVICE);
+   dma_unmap_single(vptr->dev, rd_info->skb_dma, vptr->rx.buf_sz,
+DMA_FROM_DEVICE);
rd_info->skb_dma = 0;
 
dev_kfree_skb(rd_info->skb);
@@ -1670,7 +1670,7 @@ static void velocity_free_dma_rings(struct velocity_info 
*vptr)
const int size = vptr->options.numrx * sizeof(struct rx_desc) +
vptr->options.numtx * sizeof(struct tx_desc) * vptr->tx.numq;
 
-   pci_free_consistent(vptr->pdev, size, vptr->rx.ring, vptr->rx.pool_dma);
+   dma_free_coherent(vptr->dev, size, vptr->rx.ring, vptr->rx.pool_dma);
 }
 
 static int velocity_init_rings(struct velocity_info *vptr, int mtu)
@@ -1727,8 +1727,8 @@ static void velocity_free_tx_buf(struct velocity_info 
*vptr,
pktlen = max_t(size_t, pktlen,
td->td_buf[i].size & ~TD_QUEUE);
 
-   pci_unmap_single(vptr->pdev, tdinfo->skb_dma[i],
-   le16_to_cpu(pktlen), PCI_DMA_TODEVICE);
+   dma_unmap_single(vptr->dev, tdinfo->skb_dma[i],
+   le16_to_cpu(pktlen), DMA_TO_DEVICE);
}
}
dev_kfree_skb_irq(skb);
@@ -1750,8 +1750,8 @@ static void velocity_free_td_ring_entry(struct 
velocity_info *vptr,
if (td_info->skb) {
for (i = 0; i < td_info->nskb_dma; i++) {
if (td_info->skb_dma[i]) {
-   pci_unmap_single(vptr->pdev, 
td_info->skb_dma[i],
-   td_info->skb->len, PCI_DMA_TODEVICE);
+   dma_unmap_single(vptr->dev, td_info->skb_dma[i],
+   td_info->skb->len, DMA_TO_DEVICE);
td_info->skb_dma[i] = 0;
}
}
@@ -2029,7 +2029,6 @@ static inline void velocity_iph_realign(struct 
velocity_info *vptr,
  */
 static int velocity_receive_frame(struct velocity_info *vptr, int idx)
 {
-   void 

[PATCHv8 1/3] net: velocity: Rename vptr->dev to vptr->netdev

2013-05-17 Thread Tony Prisk
Improve the clarity of the code in preparation for converting the
dma functions to generic versions, which require a struct device *.

This makes it possible to store a 'struct device *dev' in the
velocity_info structure.

Signed-off-by: Tony Prisk 
---
 drivers/net/ethernet/via/via-velocity.c |   66 +++
 drivers/net/ethernet/via/via-velocity.h |4 +-
 2 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/drivers/net/ethernet/via/via-velocity.c 
b/drivers/net/ethernet/via/via-velocity.c
index fb62489..187eef3 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c
@@ -998,9 +998,9 @@ static void velocity_print_link_status(struct velocity_info 
*vptr)
 {
 
if (vptr->mii_status & VELOCITY_LINK_FAIL) {
-   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: failed to detect 
cable link\n", vptr->dev->name);
+   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: failed to detect 
cable link\n", vptr->netdev->name);
} else if (vptr->options.spd_dpx == SPD_DPX_AUTO) {
-   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: Link 
auto-negotiation", vptr->dev->name);
+   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: Link 
auto-negotiation", vptr->netdev->name);
 
if (vptr->mii_status & VELOCITY_SPEED_1000)
VELOCITY_PRT(MSG_LEVEL_INFO, " speed 1000M bps");
@@ -1014,7 +1014,7 @@ static void velocity_print_link_status(struct 
velocity_info *vptr)
else
VELOCITY_PRT(MSG_LEVEL_INFO, " half duplex\n");
} else {
-   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: Link forced", 
vptr->dev->name);
+   VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: Link forced", 
vptr->netdev->name);
switch (vptr->options.spd_dpx) {
case SPD_DPX_1000_FULL:
VELOCITY_PRT(MSG_LEVEL_INFO, " speed 1000M bps full 
duplex\n");
@@ -1319,7 +1319,7 @@ static void velocity_init_registers(struct velocity_info 
*vptr,
case VELOCITY_INIT_RESET:
case VELOCITY_INIT_WOL:
 
-   netif_stop_queue(vptr->dev);
+   netif_stop_queue(vptr->netdev);
 
/*
 *  Reset RX to prevent RX pointer not on the 4X location
@@ -1332,7 +1332,7 @@ static void velocity_init_registers(struct velocity_info 
*vptr,
if (velocity_set_media_mode(vptr, mii_status) != 
VELOCITY_LINK_CHANGE) {
velocity_print_link_status(vptr);
if (!(vptr->mii_status & VELOCITY_LINK_FAIL))
-   netif_wake_queue(vptr->dev);
+   netif_wake_queue(vptr->netdev);
}
 
enable_flow_control_ability(vptr);
@@ -1354,7 +1354,7 @@ static void velocity_init_registers(struct velocity_info 
*vptr,
 
mac_eeprom_reload(regs);
for (i = 0; i < 6; i++)
-   writeb(vptr->dev->dev_addr[i], &(regs->PAR[i]));
+   writeb(vptr->netdev->dev_addr[i], &(regs->PAR[i]));
 
/*
 *  clear Pre_ACPI bit.
@@ -1377,7 +1377,7 @@ static void velocity_init_registers(struct velocity_info 
*vptr,
/*
 *  Set packet filter: Receive directed and broadcast 
address
 */
-   velocity_set_multi(vptr->dev);
+   velocity_set_multi(vptr->netdev);
 
/*
 *  Enable MII auto-polling
@@ -1404,14 +1404,14 @@ static void velocity_init_registers(struct 
velocity_info *vptr,
writel((CR0_DPOLL | CR0_TXON | CR0_RXON | CR0_STRT), 
>CR0Set);
 
mii_status = velocity_get_opt_media_mode(vptr);
-   netif_stop_queue(vptr->dev);
+   netif_stop_queue(vptr->netdev);
 
mii_init(vptr, mii_status);
 
if (velocity_set_media_mode(vptr, mii_status) != 
VELOCITY_LINK_CHANGE) {
velocity_print_link_status(vptr);
if (!(vptr->mii_status & VELOCITY_LINK_FAIL))
-   netif_wake_queue(vptr->dev);
+   netif_wake_queue(vptr->netdev);
}
 
enable_flow_control_ability(vptr);
@@ -1474,7 +1474,7 @@ static int velocity_init_dma_rings(struct velocity_info 
*vptr)
rx_ring_size, _dma);
if (!pool) {
dev_err(>dev, "%s : DMA memory allocation failed.\n",
-   vptr->dev->name);
+   vptr->netdev->name);
return -ENOMEM;
}
 
@@ -1514,7 +1514,7 @@ static int velocity_alloc_rx_buf(struct velocity_info 
*vptr, int idx)
struct rx_desc *rd = &(vptr->rx.ring[idx]);
struct velocity_rd_info *rd_info = &(vptr->rx.info[idx]);
 
-   

[PATCHv8 0/3] Add support for velocity network driver on platform devices

2013-05-17 Thread Tony Prisk
v8 changes:
Remove velocity_choose_state from via-velocity.h: unused function.

v7 changes:
Forgot to merge a patch to fix an error with the pm ops changes. Apologies Dave.

v6 changes:
Remove more bus specific code from velocity_probe()
Make velocity_(suspend/resume) accept a struct device *
Simplify PM code to use velocity_(suspend/resume) - remove the individual
pci and platform functions.
Add a struct pci_dev variable to velocity_get_pci_info() to reduce churn

v5 changes:
Remove velocity_info union. Change velocity_info->pdev back to struct pci_dev.
Remove more 'if (pci)' sections.
Remove 'void *pdev' function parameters.
Pass correct variable to velocity_choose_state()

v4 changes:
Code tidyup as requested by Francois Romieu
Removed '#ifdef PCI' around PCI code. Compile tested on (!)PCI and (!)PM.

v3 changes:
Rebased against net-next.
Fix errors in pm code.

v2 changes:
Drop patch #1 as requested by David Miller.
Correct the PHYID_ICPLUS_IP101A MII bits - should be ON, rather than OFF.
Read the platform rev_id from the correct register [regs->rev_id]. It's possible
this would work for the PCI version as well and would remove the need for the
'if (pci)' test to set vptr->rev_id.

v1:
The first three patches are general tidyup.

[DROPPED] Patch ## just alphabetizes the #includes to make it easier to read.

Patch #1 replaces vptr->dev with vptr->netdev, in preparation of adding a
struct device *dev in Patch #2

Patch #2 replaces the pci dma functions with the generic versions.

I have build tested these patches but don't have a PCI velocity to run-test it.
I can't see that they should introduce any problems as it is all renames and
function swapping.

Patch #3 adds support for the velocity driver on devicetree platform devices.
Binding document included. This patch is compile-tested for PCI, and boot
tested on a VIA APC8750.

I think it would be pertinent to get some tested-by's for PCI users.

Regards
Tony Prisk

Tony Prisk (3):
  net: velocity: Rename vptr->dev to vptr->netdev
  net: velocity: Convert to generic dma functions
  net: velocity: Add platform device support to VIA velocity driver

 .../devicetree/bindings/net/via-velocity.txt   |   20 +
 drivers/net/ethernet/via/Kconfig   |3 +-
 drivers/net/ethernet/via/via-velocity.c|  496 +---
 drivers/net/ethernet/via/via-velocity.h|   14 +-
 4 files changed, 355 insertions(+), 178 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/via-velocity.txt

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv8 3/3] net: velocity: Add platform device support to VIA velocity driver

2013-05-17 Thread Tony Prisk
Add support for the VIA Velocity network driver to be bound to a
OF created platform device.

Signed-off-by: Tony Prisk 
---
 .../devicetree/bindings/net/via-velocity.txt   |   20 +
 drivers/net/ethernet/via/Kconfig   |3 +-
 drivers/net/ethernet/via/via-velocity.c|  387 ++--
 drivers/net/ethernet/via/via-velocity.h|   11 +-
 4 files changed, 299 insertions(+), 122 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/via-velocity.txt

diff --git a/Documentation/devicetree/bindings/net/via-velocity.txt 
b/Documentation/devicetree/bindings/net/via-velocity.txt
new file mode 100644
index 000..b3db469
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/via-velocity.txt
@@ -0,0 +1,20 @@
+* VIA Velocity 10/100/1000 Network Controller
+
+Required properties:
+- compatible : Should be "via,velocity-vt6110"
+- reg : Address and length of the io space
+- interrupts : Should contain the controller interrupt line
+
+Optional properties:
+- no-eeprom : PCI network cards use an external EEPROM to store data. Embedded
+   devices quite often set this data in uboot and do not provide an eeprom.
+   Specify this option if you have no external eeprom.
+
+Examples:
+
+eth0@d8004000 {
+   compatible = "via,velocity-vt6110";
+   reg = <0xd8004000 0x400>;
+   interrupts = <10>;
+   no-eeprom;
+};
diff --git a/drivers/net/ethernet/via/Kconfig b/drivers/net/ethernet/via/Kconfig
index 68a9ba6..6a87097 100644
--- a/drivers/net/ethernet/via/Kconfig
+++ b/drivers/net/ethernet/via/Kconfig
@@ -5,7 +5,6 @@
 config NET_VENDOR_VIA
bool "VIA devices"
default y
-   depends on PCI
---help---
  If you have a network (Ethernet) card belonging to this class, say Y
  and read the Ethernet-HOWTO, available from
@@ -45,7 +44,7 @@ config VIA_RHINE_MMIO
 
 config VIA_VELOCITY
tristate "VIA Velocity support"
-   depends on PCI
+   depends on (PCI || USE_OF)
select CRC32
select CRC_CCITT
select NET_CORE
diff --git a/drivers/net/ethernet/via/via-velocity.c 
b/drivers/net/ethernet/via/via-velocity.c
index 5996cee..d8d5bc5 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c
@@ -65,7 +65,11 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -84,6 +88,16 @@
 static int velocity_nics;
 static int msglevel = MSG_LEVEL_INFO;
 
+static void velocity_set_power_state(struct velocity_info *vptr, char state)
+{
+   void *addr = vptr->mac_regs;
+
+   if (vptr->bustype == BUS_PCI)
+   pci_set_power_state(vptr->pdev, state);
+   else
+   writeb(state, addr + 0x154);
+}
+
 /**
  * mac_get_cam_mask-   Read a CAM mask
  * @regs: register block for this velocity
@@ -362,12 +376,23 @@ static struct velocity_info_tbl chip_info_table[] = {
  * Describe the PCI device identifiers that we support in this
  * device driver. Used for hotplug autoloading.
  */
-static DEFINE_PCI_DEVICE_TABLE(velocity_id_table) = {
+
+static DEFINE_PCI_DEVICE_TABLE(velocity_pci_id_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_612X) },
{ }
 };
 
-MODULE_DEVICE_TABLE(pci, velocity_id_table);
+MODULE_DEVICE_TABLE(pci, velocity_pci_id_table);
+
+/**
+ * Describe the OF device identifiers that we support in this
+ * device driver. Used for devicetree nodes.
+ */
+static struct of_device_id velocity_of_ids[] = {
+   { .compatible = "via,velocity-vt6110", .data = _info_table[0] },
+   { /* Sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, velocity_of_ids);
 
 /**
  * get_chip_name   -   identifier to name
@@ -386,29 +411,6 @@ static const char *get_chip_name(enum chip_type chip_id)
 }
 
 /**
- * velocity_remove1-   device unplug
- * @pdev: PCI device being removed
- *
- * Device unload callback. Called on an unplug or on module
- * unload for each active device that is present. Disconnects
- * the device from the network layer and frees all the resources
- */
-static void velocity_remove1(struct pci_dev *pdev)
-{
-   struct net_device *dev = pci_get_drvdata(pdev);
-   struct velocity_info *vptr = netdev_priv(dev);
-
-   unregister_netdev(dev);
-   iounmap(vptr->mac_regs);
-   pci_release_regions(pdev);
-   pci_disable_device(pdev);
-   pci_set_drvdata(pdev, NULL);
-   free_netdev(dev);
-
-   velocity_nics--;
-}
-
-/**
  * velocity_set_int_opt-   parser for integer options
  * @opt: pointer to option value
  * @val: value the user requested (or -1 for default)
@@ -1181,6 +1183,17 @@ static void mii_init(struct velocity_info *vptr, u32 
mii_status)
u16 BMCR;
 
switch (PHYID_GET_PHY_ID(vptr->phy_id)) {
+   case PHYID_ICPLUS_IP101A:
+   

Re: [PATCHv7 0/3] Add support for velocity network driver on platform devices

2013-05-17 Thread Tony Prisk

On 18/05/13 14:23, Tony Prisk wrote:

v7 changes:
Forgot to merge a patch to fix an error with the pm ops changes. Apologies Dave.

v6 changes:
Remove more bus specific code from velocity_probe()
Make velocity_(suspend/resume) accept a struct device *
Simplify PM code to use velocity_(suspend/resume) - remove the individual
pci and platform functions.
Add a struct pci_dev variable to velocity_get_pci_info() to reduce churn

v5 changes:
Remove velocity_info union. Change velocity_info->pdev back to struct pci_dev.
Remove more 'if (pci)' sections.
Remove 'void *pdev' function parameters.
Pass correct variable to velocity_choose_state()

v4 changes:
Code tidyup as requested by Francois Romieu
Removed '#ifdef PCI' around PCI code. Compile tested on (!)PCI and (!)PM.

v3 changes:
Rebased against net-next.
Fix errors in pm code.

v2 changes:
Drop patch #1 as requested by David Miller.
Correct the PHYID_ICPLUS_IP101A MII bits - should be ON, rather than OFF.
Read the platform rev_id from the correct register [regs->rev_id]. It's possible
this would work for the PCI version as well and would remove the need for the
'if (pci)' test to set vptr->rev_id.

v1:
The first three patches are general tidyup.

[DROPPED] Patch ## just alphabetizes the #includes to make it easier to read.

Patch #1 replaces vptr->dev with vptr->netdev, in preparation of adding a
struct device *dev in Patch #2

Patch #2 replaces the pci dma functions with the generic versions.

I have build tested these patches but don't have a PCI velocity to run-test it.
I can't see that they should introduce any problems as it is all renames and
function swapping.

Patch #3 adds support for the velocity driver on devicetree platform devices.
Binding document included. This patch is compile-tested for PCI, and boot
tested on a VIA APC8750.

I think it would be pertinent to get some tested-by's for PCI users.

Regards
Tony Prisk


Tony Prisk (3):
   net: velocity: Rename vptr->dev to vptr->netdev
   net: velocity: Convert to generic dma functions
   net: velocity: Add platform device support to VIA velocity driver

  .../devicetree/bindings/net/via-velocity.txt   |   20 +
  drivers/net/ethernet/via/Kconfig   |3 +-
  drivers/net/ethernet/via/via-velocity.c|  496 +---
  drivers/net/ethernet/via/via-velocity.h|   35 +-
  4 files changed, 376 insertions(+), 178 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/net/via-velocity.txt



Please don't apply this version either Dave.
I noticed that velocity_choose_state is defined in via-velocity.h but is 
never used.


Will resend v8.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


3.10-rc1: commit ccdfcc398594 broke uClibc build.

2013-05-17 Thread Rob Landley
The #include  added to include/uapi/linux/netlink.h  
causes the uClibc build to go:


In file included from include/linux/kernel.h:4,
 from include/linux/netlink.h:4,
 from include/linux/rtnetlink.h:5,
 from libc/inet/netlinkaccess.h:27,
 from libc/inet/if_index.c:37:
include/linux/sysinfo.h:8: error: expected specifier-qualifier-list  
before '__kernel_long_t'

make: *** [libc/inet/if_index.o] Error 1

If I comment out that line, it builds fine. The kernel builds (for my  
config) either way.


Rob--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] memcg: update TODO list in Documentation

2013-05-17 Thread Rob Landley

On 05/16/2013 10:29:33 PM, Li Zefan wrote:

hugetlb cgroup has already been implemented.

Signed-off-by: Li Zefan 
---
 Documentation/cgroups/memory.txt | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/Documentation/cgroups/memory.txt  
b/Documentation/cgroups/memory.txt

index ddf4f93..327acec 100644
--- a/Documentation/cgroups/memory.txt
+++ b/Documentation/cgroups/memory.txt
@@ -834,10 +834,9 @@ Test:

 12. TODO

-1. Add support for accounting huge pages (as a separate controller)
-2. Make per-cgroup scanner reclaim not-shared pages first
-3. Teach controller to account for shared-pages
-4. Start reclamation in the background when the limit is
+1. Make per-cgroup scanner reclaim not-shared pages first
+2. Teach controller to account for shared-pages
+3. Start reclamation in the background when the limit is
not yet hit but the usage is getting closer

 Summary


Acked-by: Rob Landley 

If the memcg guys don't grab this, please send to triv...@kernel.org.

Rob--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 134/136 ] kernel/audit_tree.c: tree will leak memory when failure occurs in audit_trim_trees()

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Chen Gang 

[ Upstream commit 12b2f117f3bf738c1a00a6f64393f1953a740bd4 ]

audit_trim_trees() calls get_tree().  If a failure occurs we must call
put_tree().

[a...@linux-foundation.org: run put_tree() before mutex_lock() for small 
scalability improvement]
Signed-off-by: Chen Gang 
Cc: Al Viro 
Cc: Eric Paris 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Steven Rostedt 
---
 kernel/audit_tree.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
index ed206fd..23b8c66 100644
--- a/kernel/audit_tree.c
+++ b/kernel/audit_tree.c
@@ -609,9 +609,9 @@ void audit_trim_trees(void)
}
spin_unlock(_lock);
trim_marked(tree);
-   put_tree(tree);
drop_collected_mounts(root_mnt);
 skip_it:
+   put_tree(tree);
mutex_lock(_filter_mutex);
}
list_del();
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 133/136 ] Btrfs: compare relevant parts of delayed tree refs

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Josef Bacik 

[ Upstream commit 41b0fc42800569f63e029549b75c4c9cb63f2dfd ]

A user reported a panic while running a balance.  What was happening was he was
relocating a block, which added the reference to the relocation tree.  Then
relocation would walk through the relocation tree and drop that reference and
free that block, and then it would walk down a snapshot which referenced the
same block and add another ref to the block.  The problem is this was all
happening in the same transaction, so the parent block was free'ed up when we
drop our reference which was immediately available for allocation, and then it
was used _again_ to add a reference for the same block from a different
snapshot.  This resulted in something like this in the delayed ref tree

add ref to 90234880, parent=2067398656, ref_root 1766, level 1
del ref to 90234880, parent=2067398656, ref_root 18446744073709551608, level 1
add ref to 90234880, parent=2067398656, ref_root 1767, level 1

as you can see the ref_root's don't match, because when we inc the ref we use
the header owner, which is the original tree the block belonged to, instead of
the data reloc tree.  Then when we remove the extent we use the reloc tree
objectid.  But none of this matters, since it is a shared reference which means
only the parent matters.  When the delayed ref stuff runs it adds all the
increments first, and then does all the drops, to make sure that we don't delete
the ref if we net a positive ref count.  But tree blocks aren't allowed to have
multiple refs from the same block, so this panics when it tries to add the
second ref.  We need the add and the drop to cancel each other out in memory so
we only do the final add.

So to fix this we need to adjust how the delayed refs are added to the tree.
Only the ref_root matters when it is a normal backref, and only the parent
matters when it is a shared backref.  So make our decision based on what ref
type we have.  This allows us to keep the ref_root in memory in case anybody
wants to use it for something else, and it allows the delayed refs to be merged
properly so we don't end up with this panic.

With this patch the users image no longer panics on mount, and it has a clean
fsck after a normal mount/umount cycle.  Thanks,

Cc: sta...@vger.kernel.org
Reported-by: Roman Mamedov 
Signed-off-by: Josef Bacik 
Signed-off-by: Steven Rostedt 
---
 fs/btrfs/delayed-ref.c |   24 ++--
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index ae94117..105b265 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -36,16 +36,19 @@
  * compare two delayed tree backrefs with same bytenr and type
  */
 static int comp_tree_refs(struct btrfs_delayed_tree_ref *ref2,
- struct btrfs_delayed_tree_ref *ref1)
+ struct btrfs_delayed_tree_ref *ref1, int type)
 {
-   if (ref1->root < ref2->root)
-   return -1;
-   if (ref1->root > ref2->root)
-   return 1;
-   if (ref1->parent < ref2->parent)
-   return -1;
-   if (ref1->parent > ref2->parent)
-   return 1;
+   if (type == BTRFS_TREE_BLOCK_REF_KEY) {
+   if (ref1->root < ref2->root)
+   return -1;
+   if (ref1->root > ref2->root)
+   return 1;
+   } else {
+   if (ref1->parent < ref2->parent)
+   return -1;
+   if (ref1->parent > ref2->parent)
+   return 1;
+   }
return 0;
 }
 
@@ -109,7 +112,8 @@ static int comp_entry(struct btrfs_delayed_ref_node *ref2,
if (ref1->type == BTRFS_TREE_BLOCK_REF_KEY ||
ref1->type == BTRFS_SHARED_BLOCK_REF_KEY) {
return comp_tree_refs(btrfs_delayed_node_to_tree_ref(ref2),
- btrfs_delayed_node_to_tree_ref(ref1));
+ btrfs_delayed_node_to_tree_ref(ref1),
+ ref1->type);
} else if (ref1->type == BTRFS_EXTENT_DATA_REF_KEY ||
   ref1->type == BTRFS_SHARED_DATA_REF_KEY) {
return comp_data_refs(btrfs_delayed_node_to_data_ref(ref2),
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 132/136 ] tracing: Fix ftrace_dump()

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: "Steven Rostedt (Red Hat)" 

[ Upstream commit 7fe70b579c9e3daba71635e31b6189394e7b79d3 ]

ftrace_dump() had a lot of issues. What ftrace_dump() does, is when
ftrace_dump_on_oops is set (via a kernel parameter or sysctl), it
will dump out the ftrace buffers to the console when either a oops,
panic, or a sysrq-z occurs.

This was written a long time ago when ftrace was fragile to recursion.
But it wasn't written well even for that.

There's a possible deadlock that can occur if a ftrace_dump() is happening
and an NMI triggers another dump. This is because it grabs a lock
before checking if the dump ran.

It also totally disables ftrace, and tracing for no good reasons.

As the ring_buffer now checks if it is read via a oops or NMI, where
there's a chance that the buffer gets corrupted, it will disable
itself. No need to have ftrace_dump() do the same.

ftrace_dump() is now cleaned up where it uses an atomic counter to
make sure only one dump happens at a time. A simple atomic_inc_return()
is enough that is needed for both other CPUs and NMIs. No need for
a spinlock, as if one CPU is running the dump, no other CPU needs
to do it too.

The tracing_on variable is turned off and not turned on. The original
code did this, but it wasn't pretty. By just disabling this variable
we get the result of not seeing traces that happen between crashes.

For sysrq-z, it doesn't get turned on, but the user can always write
a '1' to the tracing_on file. If they are using sysrq-z, then they should
know about tracing_on.

The new code is much easier to read and less error prone. No more
deadlock possibility when an NMI triggers here.

Reported-by: zhangwei(Jovi) 
Cc: sta...@vger.kernel.org
Cc: Thomas Gleixner 
Cc: Peter Zijlstra 
Cc: Frederic Weisbecker 
Signed-off-by: Steven Rostedt 
---
 kernel/trace/trace.c  |   62 +
 kernel/trace/trace_selftest.c |9 +++---
 2 files changed, 31 insertions(+), 40 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 4a568ba..6fbd63a 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4986,36 +4986,32 @@ void trace_init_global_iter(struct trace_iterator *iter)
iter->cpu_file = TRACE_PIPE_ALL_CPU;
 }
 
-static void
-__ftrace_dump(bool disable_tracing, enum ftrace_dump_mode oops_dump_mode)
+void ftrace_dump(enum ftrace_dump_mode oops_dump_mode)
 {
-   static arch_spinlock_t ftrace_dump_lock =
-   (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
/* use static because iter can be a bit big for the stack */
static struct trace_iterator iter;
+   static atomic_t dump_running;
unsigned int old_userobj;
-   static int dump_ran;
unsigned long flags;
int cnt = 0, cpu;
 
-   /* only one dump */
-   local_irq_save(flags);
-   arch_spin_lock(_dump_lock);
-   if (dump_ran)
-   goto out;
-
-   dump_ran = 1;
+   /* Only allow one dump user at a time. */
+   if (atomic_inc_return(_running) != 1) {
+   atomic_dec(_running);
+   return;
+   }
 
+   /*
+* Always turn off tracing when we dump.
+* We don't need to show trace output of what happens
+* between multiple crashes.
+*
+* If the user does a sysrq-z, then they can re-enable
+* tracing with echo 1 > tracing_on.
+*/
tracing_off();
 
-   /* Did function tracer already get disabled? */
-   if (ftrace_is_dead()) {
-   printk("# WARNING: FUNCTION TRACING IS CORRUPTED\n");
-   printk("#  MAY BE MISSING FUNCTION EVENTS\n");
-   }
-
-   if (disable_tracing)
-   ftrace_kill();
+   local_irq_save(flags);
 
trace_init_global_iter();
 
@@ -5048,6 +5044,12 @@ __ftrace_dump(bool disable_tracing, enum 
ftrace_dump_mode oops_dump_mode)
 
printk(KERN_TRACE "Dumping ftrace buffer:\n");
 
+   /* Did function tracer already get disabled? */
+   if (ftrace_is_dead()) {
+   printk("# WARNING: FUNCTION TRACING IS CORRUPTED\n");
+   printk("#  MAY BE MISSING FUNCTION EVENTS\n");
+   }
+
/*
 * We need to stop all tracing on all CPUS to read the
 * the next buffer. This is a bit expensive, but is
@@ -5087,26 +5089,14 @@ __ftrace_dump(bool disable_tracing, enum 
ftrace_dump_mode oops_dump_mode)
printk(KERN_TRACE "-\n");
 
  out_enable:
-   /* Re-enable tracing if requested */
-   if (!disable_tracing) {
-   trace_flags |= old_userobj;
+   trace_flags |= old_userobj;
 
-   for_each_tracing_cpu(cpu) {
-   atomic_dec(>data[cpu]->disabled);
-   }
-   tracing_on();
+   for_each_tracing_cpu(cpu) {
+   

[ 131/136 ] drm/radeon: fix handling of v6 power tables

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Alex Deucher 

[ Upstream commit 441e76ca83ac604eaf0f046def96d8e3a27eea28 ]

The code was mis-handling variable sized arrays.

Reported-by: Sylvain BERTRAND 
Signed-off-by: Alex Deucher 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/radeon/radeon_atombios.c |   11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c 
b/drivers/gpu/drm/radeon/radeon_atombios.c
index 77fec04..3e3b3df 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -2507,6 +2507,7 @@ static int radeon_atombios_parse_power_table_6(struct 
radeon_device *rdev)
int index = GetIndexIntoMasterTable(DATA, PowerPlayInfo);
 u16 data_offset;
u8 frev, crev;
+   u8 *power_state_offset;
 
if (!atom_parse_data_header(mode_info->atom_context, index, NULL,
   , , _offset))
@@ -2529,11 +2530,11 @@ static int radeon_atombios_parse_power_table_6(struct 
radeon_device *rdev)
   state_array->ucNumEntries, GFP_KERNEL);
if (!rdev->pm.power_state)
return state_index;
+   power_state_offset = (u8 *)state_array->states;
for (i = 0; i < state_array->ucNumEntries; i++) {
mode_index = 0;
-   power_state = (union pplib_power_state 
*)_array->states[i];
-   /* XXX this might be an inagua bug... */
-   non_clock_array_index = i; /* power_state->v2.nonClockInfoIndex 
*/
+   power_state = (union pplib_power_state *)power_state_offset;
+   non_clock_array_index = power_state->v2.nonClockInfoIndex;
non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *)

_clock_info_array->nonClockInfo[non_clock_array_index];
rdev->pm.power_state[i].clock_info = kzalloc(sizeof(struct 
radeon_pm_clock_info) *
@@ -2545,9 +2546,6 @@ static int radeon_atombios_parse_power_table_6(struct 
radeon_device *rdev)
if (power_state->v2.ucNumDPMLevels) {
for (j = 0; j < power_state->v2.ucNumDPMLevels; j++) {
clock_array_index = 
power_state->v2.clockInfoIndex[j];
-   /* XXX this might be an inagua bug... */
-   if (clock_array_index >= 
clock_info_array->ucNumEntries)
-   continue;
clock_info = (union pplib_clock_info *)

_info_array->clockInfo[clock_array_index * clock_info_array->ucEntrySize];
valid = 
radeon_atombios_parse_pplib_clock_info(rdev,
@@ -2569,6 +2567,7 @@ static int radeon_atombios_parse_power_table_6(struct 
radeon_device *rdev)
   
non_clock_info);
state_index++;
}
+   power_state_offset += 2 + power_state->v2.ucNumDPMLevels;
}
/* if multiple clock modes, mark the lowest as no display */
for (i = 0; i < state_index; i++) {
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 130/136 ] drm/radeon: add new richland pci ids

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Alex Deucher 

[ Upstream commit 62d1f92e06aef9665d71ca7e986b3047ecf0b3c7 ]

Signed-off-by: Alex Deucher 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/radeon/ni.c |6 --
 include/drm/drm_pciids.h|2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index 338b71f..62ff39f 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -471,7 +471,8 @@ static void cayman_gpu_init(struct radeon_device *rdev)
(rdev->pdev->device == 0x990F) ||
(rdev->pdev->device == 0x9910) ||
(rdev->pdev->device == 0x9917) ||
-   (rdev->pdev->device == 0x)) {
+   (rdev->pdev->device == 0x) ||
+   (rdev->pdev->device == 0x999C)) {
rdev->config.cayman.max_simds_per_se = 6;
rdev->config.cayman.max_backends_per_se = 2;
} else if ((rdev->pdev->device == 0x9903) ||
@@ -480,7 +481,8 @@ static void cayman_gpu_init(struct radeon_device *rdev)
   (rdev->pdev->device == 0x990D) ||
   (rdev->pdev->device == 0x990E) ||
   (rdev->pdev->device == 0x9913) ||
-  (rdev->pdev->device == 0x9918)) {
+  (rdev->pdev->device == 0x9918) ||
+  (rdev->pdev->device == 0x999D)) {
rdev->config.cayman.max_simds_per_se = 4;
rdev->config.cayman.max_backends_per_se = 2;
} else if ((rdev->pdev->device == 0x9919) ||
diff --git a/include/drm/drm_pciids.h b/include/drm/drm_pciids.h
index 36e5b94..d7da55c 100644
--- a/include/drm/drm_pciids.h
+++ b/include/drm/drm_pciids.h
@@ -593,6 +593,8 @@
{0x1002, 0x, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x999A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x999B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
+   {0x1002, 0x999C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
+   {0x1002, 0x999D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x99A0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x99A2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
{0x1002, 0x99A4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 127/136 ] drm/radeon: fix typo in si_select_se_sh()

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Alex Deucher 

[ Upstream commit 79b52d6a7085a3e430c6de450a5847fdbe04159b ]

Signed-off-by: Alex Deucher 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/radeon/si.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index 992e60c..f2b256c 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -1374,7 +1374,7 @@ static void si_select_se_sh(struct radeon_device *rdev,
u32 data = INSTANCE_BROADCAST_WRITES;
 
if ((se_num == 0x) && (sh_num == 0x))
-   data = SH_BROADCAST_WRITES | SE_BROADCAST_WRITES;
+   data |= SH_BROADCAST_WRITES | SE_BROADCAST_WRITES;
else if (se_num == 0x)
data |= SE_BROADCAST_WRITES | SH_INDEX(sh_num);
else if (sh_num == 0x)
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 129/136 ] drm/radeon: fix possible segfault when parsing pm tables

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Alex Deucher 

[ Upstream commit f8e6bfc2ce162855fa4f9822a45659f4b542c960 ]

If we have a empty power table, bail early and allocate
the default power state.

Should fix:
https://bugs.freedesktop.org/show_bug.cgi?id=63865

Signed-off-by: Alex Deucher 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/radeon/radeon_atombios.c |   10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c 
b/drivers/gpu/drm/radeon/radeon_atombios.c
index d67d4f3..77fec04 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -2023,6 +2023,8 @@ static int radeon_atombios_parse_power_table_1_3(struct 
radeon_device *rdev)
num_modes = power_info->info.ucNumOfPowerModeEntries;
if (num_modes > ATOM_MAX_NUMBEROF_POWER_BLOCK)
num_modes = ATOM_MAX_NUMBEROF_POWER_BLOCK;
+   if (num_modes == 0)
+   return state_index;
rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) * 
num_modes, GFP_KERNEL);
if (!rdev->pm.power_state)
return state_index;
@@ -2421,6 +2423,8 @@ static int radeon_atombios_parse_power_table_4_5(struct 
radeon_device *rdev)
power_info = (union power_info *)(mode_info->atom_context->bios + 
data_offset);
 
radeon_atombios_add_pplib_thermal_controller(rdev, 
_info->pplib.sThermalController);
+   if (power_info->pplib.ucNumStates == 0)
+   return state_index;
rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) *
   power_info->pplib.ucNumStates, 
GFP_KERNEL);
if (!rdev->pm.power_state)
@@ -2519,6 +2523,8 @@ static int radeon_atombios_parse_power_table_6(struct 
radeon_device *rdev)
non_clock_info_array = (struct _NonClockInfoArray *)
(mode_info->atom_context->bios + data_offset +
 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
+   if (state_array->ucNumEntries == 0)
+   return state_index;
rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) *
   state_array->ucNumEntries, GFP_KERNEL);
if (!rdev->pm.power_state)
@@ -2609,7 +2615,9 @@ void radeon_atombios_get_power_modes(struct radeon_device 
*rdev)
default:
break;
}
-   } else {
+   }
+
+   if (state_index == 0) {
rdev->pm.power_state = kzalloc(sizeof(struct 
radeon_power_state), GFP_KERNEL);
if (rdev->pm.power_state) {
rdev->pm.power_state[0].clock_info =
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 125/136 ] drm/radeon: cleanup properly if mmio mapping fails

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Alex Deucher 

[ Upstream commit 0cd9cb76ae26a19df21abc6f94f5fff141e689c7 ]

If we fail to map the mmio BAR, skip driver tear down
that requires mmio.

Should fix:
https://bugzilla.kernel.org/show_bug.cgi?id=56541

Signed-off-by: Alex Deucher 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/radeon/radeon_kms.c |4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/radeon/radeon_kms.c 
b/drivers/gpu/drm/radeon/radeon_kms.c
index 414b4ac..e32f4c2 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -51,8 +51,12 @@ int radeon_driver_unload_kms(struct drm_device *dev)
 
if (rdev == NULL)
return 0;
+   if (rdev->rmmio == NULL)
+   goto done_free;
radeon_modeset_fini(rdev);
radeon_device_fini(rdev);
+
+done_free:
kfree(rdev);
dev->dev_private = NULL;
return 0;
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 126/136 ] drm/radeon: fix hdmi mode enable on RS600/RS690/RS740

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Alex Deucher 

[ Upstream commit dcb852905772416e322536ced5cb3c796d176af5 ]

These chips were previously skipped since they are
pre-R600.

Signed-off-by: Alex Deucher 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/radeon/r600_hdmi.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c 
b/drivers/gpu/drm/radeon/r600_hdmi.c
index e3558c3..ecf263f 100644
--- a/drivers/gpu/drm/radeon/r600_hdmi.c
+++ b/drivers/gpu/drm/radeon/r600_hdmi.c
@@ -489,7 +489,7 @@ void r600_hdmi_enable(struct drm_encoder *encoder)
offset = dig->afmt->offset;
 
/* Older chipsets require setting HDMI and routing manually */
-   if (rdev->family >= CHIP_R600 && !ASIC_IS_DCE3(rdev)) {
+   if (ASIC_IS_DCE2(rdev) && !ASIC_IS_DCE3(rdev)) {
hdmi = HDMI0_ERROR_ACK | HDMI0_ENABLE;
switch (radeon_encoder->encoder_id) {
case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
@@ -558,7 +558,7 @@ void r600_hdmi_disable(struct drm_encoder *encoder)
radeon_irq_kms_disable_afmt(rdev, dig->afmt->id);
 
/* Older chipsets not handled by AtomBIOS */
-   if (rdev->family >= CHIP_R600 && !ASIC_IS_DCE3(rdev)) {
+   if (ASIC_IS_DCE2(rdev) && !ASIC_IS_DCE3(rdev)) {
switch (radeon_encoder->encoder_id) {
case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
WREG32_P(AVIVO_TMDSA_CNTL, 0,
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 124/136 ] drm/radeon/evergreen+: dont enable HPD interrupts on eDP/LVDS

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Alex Deucher 

[ Upstream commit 2e97be73e5f74a317232740ae82eb8f95326a660 ]

Avoids potential interrupt storms when the display is disabled.

May fix:
https://bugzilla.kernel.org/show_bug.cgi?id=56041

Signed-off-by: Alex Deucher 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/radeon/evergreen.c |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/radeon/evergreen.c 
b/drivers/gpu/drm/radeon/evergreen.c
index cbbaaf6..5c23991 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -569,6 +569,16 @@ void evergreen_hpd_init(struct radeon_device *rdev)
 
list_for_each_entry(connector, >mode_config.connector_list, head) {
struct radeon_connector *radeon_connector = 
to_radeon_connector(connector);
+
+   if (connector->connector_type == DRM_MODE_CONNECTOR_eDP ||
+   connector->connector_type == DRM_MODE_CONNECTOR_LVDS) {
+   /* don't try to enable hpd on eDP or LVDS avoid 
breaking the
+* aux dp channel on imac and help (but not completely 
fix)
+* https://bugzilla.redhat.com/show_bug.cgi?id=726143
+* also avoid interrupt storms during dpms.
+*/
+   continue;
+   }
switch (radeon_connector->hpd.hpd) {
case RADEON_HPD_1:
WREG32(DC_HPD1_CONTROL, tmp);
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 123/136 ] drm/radeon: add some new SI PCI ids

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Alex Deucher 

[ Upstream commit 18932a28419596bc9403770f5d8a108c5433fe59 ]

Signed-off-by: Alex Deucher 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 include/drm/drm_pciids.h |3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/drm/drm_pciids.h b/include/drm/drm_pciids.h
index 1cdbfe9..36e5b94 100644
--- a/include/drm/drm_pciids.h
+++ b/include/drm/drm_pciids.h
@@ -227,6 +227,7 @@
{0x1002, 0x6819, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6820, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6821, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
+   {0x1002, 0x6822, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6823, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6824, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
@@ -234,11 +235,13 @@
{0x1002, 0x6827, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_VERDE|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6829, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_VERDE|RADEON_NEW_MEMMAP}, \
+   {0x1002, 0x682A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x682B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x682D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x682F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6830, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6831, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
+   {0x1002, 0x6835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_VERDE|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6837, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_VERDE|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6838, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_VERDE|RADEON_NEW_MEMMAP}, \
{0x1002, 0x6839, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 
CHIP_VERDE|RADEON_NEW_MEMMAP}, \
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 121/136 ] drm/radeon: update wait_for_vblank for r1xx-r4xx

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Alex Deucher 

[ Upstream commit 2b48b968c0d00aa5ab520b65a15a4f374cda7dda ]

Properly wait for the next vblank region.  The previous
code didn't always wait long enough depending on the timing.

Signed-off-by: Alex Deucher 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/radeon/r100.c |   77 -
 1 file changed, 53 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 8d7e33a..b08b5b9 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -70,6 +70,38 @@ MODULE_FIRMWARE(FIRMWARE_R520);
  * and others in some cases.
  */
 
+static bool r100_is_in_vblank(struct radeon_device *rdev, int crtc)
+{
+   if (crtc == 0) {
+   if (RREG32(RADEON_CRTC_STATUS) & RADEON_CRTC_VBLANK_CUR)
+   return true;
+   else
+   return false;
+   } else {
+   if (RREG32(RADEON_CRTC2_STATUS) & RADEON_CRTC2_VBLANK_CUR)
+   return true;
+   else
+   return false;
+   }
+}
+
+static bool r100_is_counter_moving(struct radeon_device *rdev, int crtc)
+{
+   u32 vline1, vline2;
+
+   if (crtc == 0) {
+   vline1 = (RREG32(RADEON_CRTC_VLINE_CRNT_VLINE) >> 16) & 
RADEON_CRTC_V_TOTAL;
+   vline2 = (RREG32(RADEON_CRTC_VLINE_CRNT_VLINE) >> 16) & 
RADEON_CRTC_V_TOTAL;
+   } else {
+   vline1 = (RREG32(RADEON_CRTC2_VLINE_CRNT_VLINE) >> 16) & 
RADEON_CRTC_V_TOTAL;
+   vline2 = (RREG32(RADEON_CRTC2_VLINE_CRNT_VLINE) >> 16) & 
RADEON_CRTC_V_TOTAL;
+   }
+   if (vline1 != vline2)
+   return true;
+   else
+   return false;
+}
+
 /**
  * r100_wait_for_vblank - vblank wait asic callback.
  *
@@ -81,33 +113,30 @@ MODULE_FIRMWARE(FIRMWARE_R520);
 void r100_wait_for_vblank(struct radeon_device *rdev, int crtc)
 {
struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc];
-   int i;
+   unsigned i = 0;
 
if (radeon_crtc->crtc_id == 0) {
-   if (RREG32(RADEON_CRTC_GEN_CNTL) & RADEON_CRTC_EN) {
-   for (i = 0; i < rdev->usec_timeout; i++) {
-   if (!(RREG32(RADEON_CRTC_STATUS) & 
RADEON_CRTC_VBLANK_CUR))
-   break;
-   udelay(1);
-   }
-   for (i = 0; i < rdev->usec_timeout; i++) {
-   if (RREG32(RADEON_CRTC_STATUS) & 
RADEON_CRTC_VBLANK_CUR)
-   break;
-   udelay(1);
-   }
-   }
+   if (!(RREG32(RADEON_CRTC_GEN_CNTL) & RADEON_CRTC_EN))
+   return;
} else {
-   if (RREG32(RADEON_CRTC2_GEN_CNTL) & RADEON_CRTC2_EN) {
-   for (i = 0; i < rdev->usec_timeout; i++) {
-   if (!(RREG32(RADEON_CRTC2_STATUS) & 
RADEON_CRTC2_VBLANK_CUR))
-   break;
-   udelay(1);
-   }
-   for (i = 0; i < rdev->usec_timeout; i++) {
-   if (RREG32(RADEON_CRTC2_STATUS) & 
RADEON_CRTC2_VBLANK_CUR)
-   break;
-   udelay(1);
-   }
+   if (!(RREG32(RADEON_CRTC2_GEN_CNTL) & RADEON_CRTC2_EN))
+   return;
+   }
+
+   /* depending on when we hit vblank, we may be close to active; if so,
+* wait for another frame.
+*/
+   while (r100_is_in_vblank(rdev, crtc)) {
+   if (i++ % 100 == 0) {
+   if (!r100_is_counter_moving(rdev, crtc))
+   break;
+   }
+   }
+
+   while (!r100_is_in_vblank(rdev, crtc)) {
+   if (i++ % 100 == 0) {
+   if (!r100_is_counter_moving(rdev, crtc))
+   break;
}
}
 }
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 122/136 ] drm/radeon: disable the crtcs in mc_stop (evergreen+) (v2)

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Alex Deucher 

[ Upstream commit abf1457bbbe4c62066bd03c6d31837dea28644dc ]

Just disabling the mem requests should be enough, but
that doesn't seem to work correctly on efi systems.

May fix:
https://bugs.freedesktop.org/show_bug.cgi?id=57567
https://bugs.freedesktop.org/show_bug.cgi?id=43655
https://bugzilla.kernel.org/show_bug.cgi?id=56441

v2: blank displays first, then disable.

Signed-off-by: Alex Deucher 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/radeon/evergreen.c |   12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/radeon/evergreen.c 
b/drivers/gpu/drm/radeon/evergreen.c
index 6cb958b..cbbaaf6 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -1286,6 +1286,7 @@ void evergreen_mc_stop(struct radeon_device *rdev, struct 
evergreen_mc_save *sav
tmp = RREG32(EVERGREEN_CRTC_BLANK_CONTROL + 
crtc_offsets[i]);
if (!(tmp & EVERGREEN_CRTC_BLANK_DATA_EN)) {
radeon_wait_for_vblank(rdev, i);
+   WREG32(EVERGREEN_CRTC_UPDATE_LOCK + 
crtc_offsets[i], 1);
tmp |= EVERGREEN_CRTC_BLANK_DATA_EN;
WREG32(EVERGREEN_CRTC_BLANK_CONTROL + 
crtc_offsets[i], tmp);
}
@@ -1293,8 +1294,10 @@ void evergreen_mc_stop(struct radeon_device *rdev, 
struct evergreen_mc_save *sav
tmp = RREG32(EVERGREEN_CRTC_CONTROL + 
crtc_offsets[i]);
if (!(tmp & 
EVERGREEN_CRTC_DISP_READ_REQUEST_DISABLE)) {
radeon_wait_for_vblank(rdev, i);
+   WREG32(EVERGREEN_CRTC_UPDATE_LOCK + 
crtc_offsets[i], 1);
tmp |= 
EVERGREEN_CRTC_DISP_READ_REQUEST_DISABLE;
WREG32(EVERGREEN_CRTC_CONTROL + 
crtc_offsets[i], tmp);
+   WREG32(EVERGREEN_CRTC_UPDATE_LOCK + 
crtc_offsets[i], 0);
}
}
/* wait for the next frame */
@@ -1304,6 +1307,15 @@ void evergreen_mc_stop(struct radeon_device *rdev, 
struct evergreen_mc_save *sav
break;
udelay(1);
}
+
+   /* XXX this is a hack to avoid strange behavior with 
EFI on certain systems */
+   WREG32(EVERGREEN_CRTC_UPDATE_LOCK + crtc_offsets[i], 1);
+   tmp = RREG32(EVERGREEN_CRTC_CONTROL + crtc_offsets[i]);
+   tmp &= ~EVERGREEN_CRTC_MASTER_EN;
+   WREG32(EVERGREEN_CRTC_CONTROL + crtc_offsets[i], tmp);
+   WREG32(EVERGREEN_CRTC_UPDATE_LOCK + crtc_offsets[i], 0);
+   save->crtc_enabled[i] = false;
+   /* * */
} else {
save->crtc_enabled[i] = false;
}
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 120/136 ] drm/radeon: update wait_for_vblank for evergreen+

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Alex Deucher 

[ Upstream commit 10257a6d8359c41407eb26b7ad7bf710a7e00155 ]

Properly wait for the next vblank region.  The previous
code didn't always wait long enough depending on the timing.

Signed-off-by: Alex Deucher 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/radeon/evergreen.c |   44 +---
 1 file changed, 36 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/radeon/evergreen.c 
b/drivers/gpu/drm/radeon/evergreen.c
index 5528fea..6cb958b 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -109,6 +109,27 @@ void evergreen_fix_pci_max_read_req_size(struct 
radeon_device *rdev)
}
 }
 
+static bool dce4_is_in_vblank(struct radeon_device *rdev, int crtc)
+{
+   if (RREG32(EVERGREEN_CRTC_STATUS + crtc_offsets[crtc]) & 
EVERGREEN_CRTC_V_BLANK)
+   return true;
+   else
+   return false;
+}
+
+static bool dce4_is_counter_moving(struct radeon_device *rdev, int crtc)
+{
+   u32 pos1, pos2;
+
+   pos1 = RREG32(EVERGREEN_CRTC_STATUS_POSITION + crtc_offsets[crtc]);
+   pos2 = RREG32(EVERGREEN_CRTC_STATUS_POSITION + crtc_offsets[crtc]);
+
+   if (pos1 != pos2)
+   return true;
+   else
+   return false;
+}
+
 /**
  * dce4_wait_for_vblank - vblank wait asic callback.
  *
@@ -119,21 +140,28 @@ void evergreen_fix_pci_max_read_req_size(struct 
radeon_device *rdev)
  */
 void dce4_wait_for_vblank(struct radeon_device *rdev, int crtc)
 {
-   int i;
+   unsigned i = 0;
 
if (crtc >= rdev->num_crtc)
return;
 
-   if (RREG32(EVERGREEN_CRTC_CONTROL + crtc_offsets[crtc]) & 
EVERGREEN_CRTC_MASTER_EN) {
-   for (i = 0; i < rdev->usec_timeout; i++) {
-   if (!(RREG32(EVERGREEN_CRTC_STATUS + 
crtc_offsets[crtc]) & EVERGREEN_CRTC_V_BLANK))
+   if (!(RREG32(EVERGREEN_CRTC_CONTROL + crtc_offsets[crtc]) & 
EVERGREEN_CRTC_MASTER_EN))
+   return;
+
+   /* depending on when we hit vblank, we may be close to active; if so,
+* wait for another frame.
+*/
+   while (dce4_is_in_vblank(rdev, crtc)) {
+   if (i++ % 100 == 0) {
+   if (!dce4_is_counter_moving(rdev, crtc))
break;
-   udelay(1);
}
-   for (i = 0; i < rdev->usec_timeout; i++) {
-   if (RREG32(EVERGREEN_CRTC_STATUS + crtc_offsets[crtc]) 
& EVERGREEN_CRTC_V_BLANK)
+   }
+
+   while (!dce4_is_in_vblank(rdev, crtc)) {
+   if (i++ % 100 == 0) {
+   if (!dce4_is_counter_moving(rdev, crtc))
break;
-   udelay(1);
}
}
 }
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 119/136 ] drm/radeon: update wait_for_vblank for r5xx-r7xx

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Alex Deucher 

[ Upstream commit bea5497bfc1067620c8c8e9d37a42e0bb6d7d7fa ]

Properly wait for the next vblank region.  The previous
code didn't always wait long enough depending on the timing.

Signed-off-by: Alex Deucher 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/radeon/rs600.c |   54 ++--
 1 file changed, 47 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c
index 5301b3d..78aa835 100644
--- a/drivers/gpu/drm/radeon/rs600.c
+++ b/drivers/gpu/drm/radeon/rs600.c
@@ -46,21 +46,61 @@
 void rs600_gpu_init(struct radeon_device *rdev);
 int rs600_mc_wait_for_idle(struct radeon_device *rdev);
 
+static bool avivo_is_in_vblank(struct radeon_device *rdev, int crtc)
+{
+   struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc];
+
+   if (RREG32(AVIVO_D1CRTC_STATUS + radeon_crtc->crtc_offset) & 
AVIVO_D1CRTC_V_BLANK)
+   return true;
+   else
+   return false;
+}
+
+static bool avivo_is_counter_moving(struct radeon_device *rdev, int crtc)
+{
+   struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc];
+   u32 pos1, pos2;
+
+   pos1 = RREG32(AVIVO_D1CRTC_STATUS_POSITION + radeon_crtc->crtc_offset);
+   pos2 = RREG32(AVIVO_D1CRTC_STATUS_POSITION + radeon_crtc->crtc_offset);
+
+   if (pos1 != pos2)
+   return true;
+   else
+   return false;
+}
+
+/**
+ * avivo_wait_for_vblank - vblank wait asic callback.
+ *
+ * @rdev: radeon_device pointer
+ * @crtc: crtc to wait for vblank on
+ *
+ * Wait for vblank on the requested crtc (r5xx-r7xx).
+ */
 void avivo_wait_for_vblank(struct radeon_device *rdev, int crtc)
 {
struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc];
-   int i;
+   unsigned i = 0;
+
+   if (!(RREG32(AVIVO_D1CRTC_CONTROL + radeon_crtc->crtc_offset) & 
AVIVO_CRTC_EN))
+   return;
 
-   if (RREG32(AVIVO_D1CRTC_CONTROL + radeon_crtc->crtc_offset) & 
AVIVO_CRTC_EN) {
-   for (i = 0; i < rdev->usec_timeout; i++) {
-   if (!(RREG32(AVIVO_D1CRTC_STATUS + 
radeon_crtc->crtc_offset) & AVIVO_D1CRTC_V_BLANK))
+   /* depending on when we hit vblank, we may be close to active; if so,
+* wait for another frame.
+*/
+   while (avivo_is_in_vblank(rdev, crtc)) {
+   if (i++ % 100 == 0) {
+   if (!avivo_is_counter_moving(rdev, crtc))
break;
udelay(1);
}
-   for (i = 0; i < rdev->usec_timeout; i++) {
-   if (RREG32(AVIVO_D1CRTC_STATUS + 
radeon_crtc->crtc_offset) & AVIVO_D1CRTC_V_BLANK)
+   }
+
+   while (!avivo_is_in_vblank(rdev, crtc)) {
+   if (i++ % 100 == 0) {
+   if (!avivo_is_counter_moving(rdev, crtc))
break;
-   udelay(1);
}
}
 }
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 117/136 ] drm/radeon: use frac fb div on RS780/RS880

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Alex Deucher 

[ Upstream commit 411678288d61ba17afe1f8afed92200be6bbc65d ]

Monitors seem to prefer it.  Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=37696

Signed-off-by: Alex Deucher 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/radeon/atombios_crtc.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c 
b/drivers/gpu/drm/radeon/atombios_crtc.c
index 2817101..3a3d3f8 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -569,6 +569,9 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
/* use frac fb div on APUs */
if (ASIC_IS_DCE41(rdev) || ASIC_IS_DCE61(rdev))
pll->flags |= RADEON_PLL_USE_FRAC_FB_DIV;
+   /* use frac fb div on RS780/RS880 */
+   if ((rdev->family == CHIP_RS780) || (rdev->family == 
CHIP_RS880))
+   pll->flags |= RADEON_PLL_USE_FRAC_FB_DIV;
} else {
pll->flags |= RADEON_PLL_LEGACY;
 
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 115/136 ] drm/i915: Fall back to bit banging mode for DVO transmitter detection

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: =?UTF-8?q?"David=20M=C3=BCller=20(ELSOFT=20AG)"?= 

[ Upstream commit e4bfff54ed3f5de88f5358504c78c2cb037813aa ]

As discussed in this thread
http://lists.freedesktop.org/archives/dri-devel/2013-April/037411.html
GMBUS based DVO transmitter detection seems to be unreliable which could
result in an unusable DVO port.

The attached patch fixes this by falling back to bit banging mode for
the time DVO transmitter detection is in progress.

Signed-off-by: David Müller 
Tested-by: David Müller 
Cc: sta...@vger.kernel.org
Signed-off-by: Daniel Vetter 
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/i915/intel_dvo.c |   13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/intel_dvo.c b/drivers/gpu/drm/i915/intel_dvo.c
index 36c542e..5f1d7ef 100644
--- a/drivers/gpu/drm/i915/intel_dvo.c
+++ b/drivers/gpu/drm/i915/intel_dvo.c
@@ -370,6 +370,7 @@ void intel_dvo_init(struct drm_device *dev)
const struct intel_dvo_device *dvo = _dvo_devices[i];
struct i2c_adapter *i2c;
int gpio;
+   bool dvoinit;
 
/* Allow the I2C driver info to specify the GPIO to be used in
 * special cases, but otherwise default to what's defined
@@ -389,7 +390,17 @@ void intel_dvo_init(struct drm_device *dev)
i2c = intel_gmbus_get_adapter(dev_priv, gpio);
 
intel_dvo->dev = *dvo;
-   if (!dvo->dev_ops->init(_dvo->dev, i2c))
+
+   /* GMBUS NAK handling seems to be unstable, hence let the
+* transmitter detection run in bit banging mode for now.
+*/
+   intel_gmbus_force_bit(i2c, true);
+
+   dvoinit = dvo->dev_ops->init(_dvo->dev, i2c);
+
+   intel_gmbus_force_bit(i2c, false);
+
+   if (!dvoinit)
continue;
 
intel_encoder->type = INTEL_OUTPUT_DVO;
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 116/136 ] drm/radeon: dont use get_engine_clock() on APUs

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Alex Deucher 

[ Upstream commit bf05d9985111f85ed6922c134567b96eb789283b ]

It doesn't work reliably.  Just report back the currently
selected engine clock.

Partially fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=62493

Signed-off-by: Alex Deucher 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/radeon/radeon_pm.c |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/radeon_pm.c 
b/drivers/gpu/drm/radeon/radeon_pm.c
index 395d7e0..8c89481 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -856,7 +856,11 @@ static int radeon_debugfs_pm_info(struct seq_file *m, void 
*data)
struct radeon_device *rdev = dev->dev_private;
 
seq_printf(m, "default engine clock: %u0 kHz\n", rdev->pm.default_sclk);
-   seq_printf(m, "current engine clock: %u0 kHz\n", 
radeon_get_engine_clock(rdev));
+   /* radeon_get_engine_clock is not reliable on APUs so just print the 
current clock */
+   if ((rdev->family >= CHIP_PALM) && (rdev->flags & RADEON_IS_IGP))
+   seq_printf(m, "current engine clock: %u0 kHz\n", 
rdev->pm.current_sclk);
+   else
+   seq_printf(m, "current engine clock: %u0 kHz\n", 
radeon_get_engine_clock(rdev));
seq_printf(m, "default memory clock: %u0 kHz\n", rdev->pm.default_mclk);
if (rdev->asic->pm.get_memory_clock)
seq_printf(m, "current memory clock: %u0 kHz\n", 
radeon_get_memory_clock(rdev));
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 093/136 ] PCI/PM: Clear state_saved during suspend

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: "Rafael J. Wysocki" 

[ Upstream commit 82fee4d67ab86d6fe5eb0f9a9e988ca9d654d765 ]

This patch clears pci_dev->state_saved at the beginning of suspending.
PCI config state may be saved long before that.  Some drivers call
pci_save_state() from the ->probe() callback to get snapshot of sane
configuration space to use in the ->slot_reset() callback.

Signed-off-by: Konstantin Khlebnikov  # add comment
Signed-off-by: Bjorn Helgaas 
Signed-off-by: Steven Rostedt 
---
 drivers/pci/pci-driver.c |4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 729e038..97d0f03d 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -685,6 +685,7 @@ static int pci_pm_suspend(struct device *dev)
goto Fixup;
}
 
+   pci_dev->state_saved = false;
if (pm->suspend) {
pci_power_t prev = pci_dev->current_state;
int error;
@@ -831,6 +832,7 @@ static int pci_pm_freeze(struct device *dev)
return 0;
}
 
+   pci_dev->state_saved = false;
if (pm->freeze) {
int error;
 
@@ -919,6 +921,7 @@ static int pci_pm_poweroff(struct device *dev)
goto Fixup;
}
 
+   pci_dev->state_saved = false;
if (pm->poweroff) {
int error;
 
@@ -1037,6 +1040,7 @@ static int pci_pm_runtime_suspend(struct device *dev)
if (!pm || !pm->runtime_suspend)
return -ENOSYS;
 
+   pci_dev->state_saved = false;
pci_dev->no_d3cold = false;
error = pm->runtime_suspend(dev);
suspend_report_result(pm->runtime_suspend, error);
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 114/136 ] drm/i915: set CPT FDI RX polarity bits based on VBT

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Paulo Zanoni 

[ Upstream commit 3f704fa2778d3fe45e6529825a5c7a8bcbc686f4 ]

Check the VBT to see if the machine has inverted FDI RX polarity on
CPT. Based on this bit, set the appropriate bit on the TRANS_CHICKEN2
registers.

This should fix some machines that were showing black screens on all
outputs.

Cc: sta...@vger.kernel.org
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=60029
Signed-off-by: Paulo Zanoni 
Reviewed-by: Imre Deak 
Signed-off-by: Daniel Vetter 
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/i915/i915_drv.h   |1 +
 drivers/gpu/drm/i915/i915_reg.h   |1 +
 drivers/gpu/drm/i915/intel_bios.c |6 --
 drivers/gpu/drm/i915/intel_bios.h |4 +++-
 drivers/gpu/drm/i915/intel_pm.c   |9 +++--
 5 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index ae85929..ec7cc29 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -464,6 +464,7 @@ typedef struct drm_i915_private {
unsigned int int_crt_support:1;
unsigned int lvds_use_ssc:1;
unsigned int display_clock_mode:1;
+   unsigned int fdi_rx_polarity_inverted:1;
int lvds_ssc_freq;
unsigned int bios_lvds_val; /* initial [PCH_]LVDS reg val in VBIOS */
unsigned int lvds_val; /* used for checking LVDS channel mode */
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index f02cfad..3814aa3 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -3758,6 +3758,7 @@
 #define _TRANSB_CHICKEN20xf1064
 #define TRANS_CHICKEN2(pipe) _PIPE(pipe, _TRANSA_CHICKEN2, _TRANSB_CHICKEN2)
 #define   TRANS_AUTOTRAIN_GEN_STALL_DIS(1<<31)
+#define  TRANS_CHICKEN2_FDI_POLARITY_REVERSED  (1<<29)
 
 #define SOUTH_CHICKEN1 0xc2000
 #define  FDIA_PHASE_SYNC_SHIFT_OVR 19
diff --git a/drivers/gpu/drm/i915/intel_bios.c 
b/drivers/gpu/drm/i915/intel_bios.c
index d0df62a..d10cf1d 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -352,12 +352,14 @@ parse_general_features(struct drm_i915_private *dev_priv,
dev_priv->lvds_ssc_freq =
intel_bios_ssc_frequency(dev, general->ssc_freq);
dev_priv->display_clock_mode = general->display_clock_mode;
-   DRM_DEBUG_KMS("BDB_GENERAL_FEATURES int_tv_support %d 
int_crt_support %d lvds_use_ssc %d lvds_ssc_freq %d display_clock_mode %d\n",
+   dev_priv->fdi_rx_polarity_inverted = 
general->fdi_rx_polarity_inverted;
+   DRM_DEBUG_KMS("BDB_GENERAL_FEATURES int_tv_support %d 
int_crt_support %d lvds_use_ssc %d lvds_ssc_freq %d display_clock_mode %d 
fdi_rx_polarity_inverted %d\n",
  dev_priv->int_tv_support,
  dev_priv->int_crt_support,
  dev_priv->lvds_use_ssc,
  dev_priv->lvds_ssc_freq,
- dev_priv->display_clock_mode);
+ dev_priv->display_clock_mode,
+ dev_priv->fdi_rx_polarity_inverted);
}
 }
 
diff --git a/drivers/gpu/drm/i915/intel_bios.h 
b/drivers/gpu/drm/i915/intel_bios.h
index 31c2107..e0af201 100644
--- a/drivers/gpu/drm/i915/intel_bios.h
+++ b/drivers/gpu/drm/i915/intel_bios.h
@@ -127,7 +127,9 @@ struct bdb_general_features {
 /* bits 3 */
u8 disable_smooth_vision:1;
u8 single_dvi:1;
-   u8 rsvd9:6; /* finish byte */
+   u8 rsvd9:1;
+   u8 fdi_rx_polarity_inverted:1;
+   u8 rsvd10:4; /* finish byte */
 
 /* bits 4 */
u8 legacy_monitor_detect;
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index c23c9ea..e782b76 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -3712,6 +3712,7 @@ static void cpt_init_clock_gating(struct drm_device *dev)
 {
struct drm_i915_private *dev_priv = dev->dev_private;
int pipe;
+   uint32_t val;
 
/*
 * On Ibex Peak and Cougar Point, we need to disable clock
@@ -3722,8 +3723,12 @@ static void cpt_init_clock_gating(struct drm_device *dev)
I915_WRITE(SOUTH_CHICKEN2, I915_READ(SOUTH_CHICKEN2) |
   DPLS_EDP_PPS_FIX_DIS);
/* Without this, mode sets may fail silently on FDI */
-   for_each_pipe(pipe)
-   I915_WRITE(TRANS_CHICKEN2(pipe), TRANS_AUTOTRAIN_GEN_STALL_DIS);
+   for_each_pipe(pipe) {
+   val = TRANS_AUTOTRAIN_GEN_STALL_DIS;
+   if (dev_priv->fdi_rx_polarity_inverted)
+   val |= TRANS_CHICKEN2_FDI_POLARITY_REVERSED;
+   I915_WRITE(TRANS_CHICKEN2(pipe), val);
+   }
 }
 
 void intel_init_clock_gating(struct drm_device *dev)
-- 
1.7.10.4



[ 066/136 ] NFSv4: Handle NFS4ERR_DELAY and NFS4ERR_GRACE in nfs4_open_delegation_recall

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Trond Myklebust 

[ Upstream commit 8b6cc4d6f841d31f72fe7478453759166d366274 ]

A server shouldn't normally return NFS4ERR_GRACE if the client holds a
delegation, since no conflicting lock reclaims can be granted, however
the spec does not require the server to grant the open in this
instance

Signed-off-by: Trond Myklebust 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 fs/nfs/nfs4proc.c |6 ++
 1 file changed, 6 insertions(+)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 2c6c214..4d135ef 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1383,6 +1383,12 @@ int nfs4_open_delegation_recall(struct nfs_open_context 
*ctx, struct nfs4_state
case -ENOMEM:
err = 0;
goto out;
+   case -NFS4ERR_DELAY:
+   case -NFS4ERR_GRACE:
+   set_bit(NFS_DELEGATED_STATE, >flags);
+   ssleep(1);
+   err = -EAGAIN;
+   goto out;
}
err = nfs4_handle_exception(server, err, );
} while (exception.retry);
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 128/136 ] drm/radeon: fix endian bugs in atom_allocate_fb_scratch()

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Alex Deucher 

[ Upstream commit beb71fc61c2cad64e347f164991b8ef476529e64 ]

Reviwed-by: Michel Dänzer 
Signed-off-by: Alex Deucher 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/radeon/atom.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/radeon/atom.c b/drivers/gpu/drm/radeon/atom.c
index 5ce9bf5..43672b6 100644
--- a/drivers/gpu/drm/radeon/atom.c
+++ b/drivers/gpu/drm/radeon/atom.c
@@ -1389,10 +1389,10 @@ int atom_allocate_fb_scratch(struct atom_context *ctx)
firmware_usage = (struct _ATOM_VRAM_USAGE_BY_FIRMWARE 
*)(ctx->bios + data_offset);
 
DRM_DEBUG("atom firmware requested %08x %dkb\n",
- 
firmware_usage->asFirmwareVramReserveInfo[0].ulStartAddrUsedByFirmware,
- 
firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb);
+ 
le32_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].ulStartAddrUsedByFirmware),
+ 
le16_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb));
 
-   usage_bytes = 
firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb * 1024;
+   usage_bytes = 
le16_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb) * 
1024;
}
ctx->scratch_size_bytes = 0;
if (usage_bytes == 0)
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 113/136 ] drm/i915: Use MLC (l3$) for context objects

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Chris Wilson 

[ Upstream commit 4615d4c9e27eda42c3e965f208a4b4065841498c ]

Enabling context support increases SwapBuffers latency by about 20%
(measured on an i7-3720qm). We can offset that loss slightly by enabling
faster caching for the contexts. As they are not backed by any
particular cache (such as the sampler or render caches) our only option
is to select the generic mid-level cache. This reduces the latency of
the swap by about 5%.

Oddly this effect can be observed running smokin-guns on IVB at
1280x1024:
Using BLT copies for swaps: 151.67 fps
Using Render copies for swaps (unpatched):  141.70 fps
With contexts disabled: 150.23 fps
With contexts in L3$: 150.77 fps

Signed-off-by: Chris Wilson 
Cc: Ben Widawsky 
Cc: Kenneth Graunke 
Reviewed-by: Kenneth Graunke 
Signed-off-by: Daniel Vetter 
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/i915/i915_gem_context.c |7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_gem_context.c 
b/drivers/gpu/drm/i915/i915_gem_context.c
index a9d58d7..dda0d35 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -155,6 +155,13 @@ create_hw_context(struct drm_device *dev,
return ERR_PTR(-ENOMEM);
}
 
+   if (INTEL_INFO(dev)->gen >= 7) {
+   ret = i915_gem_object_set_cache_level(ctx->obj,
+ I915_CACHE_LLC_MLC);
+   if (ret)
+   goto err_out;
+   }
+
/* The ring associated with the context object is handled by the normal
 * object tracking code. We give an initial ring value simple to pass an
 * assertion in the context switch code.
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 112/136 ] drm/i915: Workaround incoherence between fences and LLC across multiple CPUs

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Chris Wilson 

[ Upstream commit 25ff1195f8a0b3724541ae7bbe331b4296de9c06 ]

In order to fully serialize access to the fenced region and the update
to the fence register we need to take extreme measures on SNB+, and
manually flush writes to memory prior to writing the fence register in
conjunction with the memory barriers placed around the register write.

Fixes i-g-t/gem_fence_thrash

v2: Bring a bigger gun
v3: Switch the bigger gun for heavier bullets (Arjan van de Ven)
v4: Remove changes for working generations.
v5: Reduce to a per-cpu wbinvd() call prior to updating the fences.
v6: Rewrite comments to ellide forgotten history.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=62191
Signed-off-by: Chris Wilson 
Cc: Jon Bloomfield 
Tested-by: Jon Bloomfield  (v2)
Cc: sta...@vger.kernel.org
Reviewed-by: Jesse Barnes 
Signed-off-by: Daniel Vetter 
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/i915/i915_gem.c |   28 +++-
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 97d4f4b..18da42c 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2525,17 +2525,35 @@ static inline int fence_number(struct drm_i915_private 
*dev_priv,
return fence - dev_priv->fence_regs;
 }
 
+static void i915_gem_write_fence__ipi(void *data)
+{
+   wbinvd();
+}
+
 static void i915_gem_object_update_fence(struct drm_i915_gem_object *obj,
 struct drm_i915_fence_reg *fence,
 bool enable)
 {
-   struct drm_i915_private *dev_priv = obj->base.dev->dev_private;
-   int reg = fence_number(dev_priv, fence);
-
-   i915_gem_write_fence(obj->base.dev, reg, enable ? obj : NULL);
+   struct drm_device *dev = obj->base.dev;
+   struct drm_i915_private *dev_priv = dev->dev_private;
+   int fence_reg = fence_number(dev_priv, fence);
+
+   /* In order to fully serialize access to the fenced region and
+* the update to the fence register we need to take extreme
+* measures on SNB+. In theory, the write to the fence register
+* flushes all memory transactions before, and coupled with the
+* mb() placed around the register write we serialise all memory
+* operations with respect to the changes in the tiler. Yet, on
+* SNB+ we need to take a step further and emit an explicit wbinvd()
+* on each processor in order to manually flush all memory
+* transactions before updating the fence register.
+*/
+   if (HAS_LLC(obj->base.dev))
+   on_each_cpu(i915_gem_write_fence__ipi, NULL, 1);
+   i915_gem_write_fence(dev, fence_reg, enable ? obj : NULL);
 
if (enable) {
-   obj->fence_reg = reg;
+   obj->fence_reg = fence_reg;
fence->obj = obj;
list_move_tail(>lru_list, _priv->mm.fence_list);
} else {
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 054/136 ] swap: redirty page if page write fails on swap file

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Jerome Marchand 

[ Upstream commit 2d30d31ea3c5be426ce25607b9bd1835acb85e0a ]

Since commit 62c230bc1790 ("mm: add support for a filesystem to activate
swap files and use direct_IO for writing swap pages"), swap_writepage()
calls direct_IO on swap files.  However, in that case the page isn't
redirtied if I/O fails, and is therefore handled afterwards as if it has
been successfully written to the swap file, leading to memory corruption
when the page is eventually swapped back in.

This patch sets the page dirty when direct_IO() fails.  It fixes a
memory corruption that happened while using swap-over-NFS.

Signed-off-by: Jerome Marchand 
Acked-by: Johannes Weiner 
Acked-by: Mel Gorman 
Cc: Hugh Dickins 
Cc: [3.6+]
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Steven Rostedt 
---
 mm/page_io.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/page_io.c b/mm/page_io.c
index 78eee32..04ca00d 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -222,6 +222,8 @@ int swap_writepage(struct page *page, struct 
writeback_control *wbc)
if (ret == PAGE_SIZE) {
count_vm_event(PSWPOUT);
ret = 0;
+   } else {
+   set_page_dirty(page);
}
return ret;
}
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 111/136 ] drm/i915: Add no-lvds quirk for Fujitsu Esprimo Q900

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Christian Lamparter 

[ Upstream commit 9e9dd0e889c76c786e8f2e164c825c3c06dea30c ]

The "Mobile Sandy Bridge CPUs" in the Fujitsu Esprimo Q900
mini desktop PCs are probably misleading the LVDS detection
code in intel_lvds_supported. Nothing is connected to the
LVDS ports in these systems.

Signed-off-by: Christian Lamparter 
Cc: sta...@vger.kernel.org
Signed-off-by: Daniel Vetter 
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/i915/intel_lvds.c |8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_lvds.c 
b/drivers/gpu/drm/i915/intel_lvds.c
index 0c52448..c78c988 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -796,6 +796,14 @@ static const struct dmi_system_id intel_no_lvds[] = {
DMI_MATCH(DMI_PRODUCT_NAME, "X7SPA-H"),
},
},
+   {
+   .callback = intel_no_lvds_dmi_callback,
+   .ident = "Fujitsu Esprimo Q900",
+   .matches = {
+   DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
+   DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Q900"),
+   },
+   },
 
{ } /* terminating entry */
 };
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 106/136 ] drm/mgag200: deal with bo reserve fail in dirty update path

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Dave Airlie 

[ Upstream commit 641719599528d806e00de8ae8c8453361266a312 ]

On F19 testing, it was noticed we get a lot of errors in dmesg
about being unable to reserve the buffer when plymouth starts,
this is due to the buffer being in the process of migrating,
so it makes sense we can't reserve it.

In order to deal with it, this adds delayed updates for the dirty
updates, when the bo is unreservable, in the normal console case
this shouldn't ever happen, its just when plymouth or X is
pushing the console bo to system memory.

Cc: sta...@vger.kernel.org
Signed-off-by: Dave Airlie 
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/mgag200/mgag200_drv.h |2 ++
 drivers/gpu/drm/mgag200/mgag200_fb.c  |   43 ++---
 drivers/gpu/drm/mgag200/mgag200_ttm.c |4 +--
 3 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h 
b/drivers/gpu/drm/mgag200/mgag200_drv.h
index 6f13b35..aa2fa4d 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.h
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.h
@@ -116,6 +116,8 @@ struct mga_fbdev {
void *sysram;
int size;
struct ttm_bo_kmap_obj mapping;
+   int x1, y1, x2, y2; /* dirty rect */
+   spinlock_t dirty_lock;
 };
 
 struct mga_crtc {
diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c 
b/drivers/gpu/drm/mgag200/mgag200_fb.c
index 880d336..f5f0366 100644
--- a/drivers/gpu/drm/mgag200/mgag200_fb.c
+++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
@@ -29,16 +29,52 @@ static void mga_dirty_update(struct mga_fbdev *mfbdev,
int bpp = (mfbdev->mfb.base.bits_per_pixel + 7)/8;
int ret;
bool unmap = false;
+   bool store_for_later = false;
+   int x2, y2;
+   unsigned long flags;
 
obj = mfbdev->mfb.obj;
bo = gem_to_mga_bo(obj);
 
+   /*
+* try and reserve the BO, if we fail with busy
+* then the BO is being moved and we should
+* store up the damage until later.
+*/
ret = mgag200_bo_reserve(bo, true);
if (ret) {
-   DRM_ERROR("failed to reserve fb bo\n");
+   if (ret != -EBUSY)
+   return;
+
+   store_for_later = true;
+   }
+
+   x2 = x + width - 1;
+   y2 = y + height - 1;
+   spin_lock_irqsave(>dirty_lock, flags);
+
+   if (mfbdev->y1 < y)
+   y = mfbdev->y1;
+   if (mfbdev->y2 > y2)
+   y2 = mfbdev->y2;
+   if (mfbdev->x1 < x)
+   x = mfbdev->x1;
+   if (mfbdev->x2 > x2)
+   x2 = mfbdev->x2;
+
+   if (store_for_later) {
+   mfbdev->x1 = x;
+   mfbdev->x2 = x2;
+   mfbdev->y1 = y;
+   mfbdev->y2 = y2;
+   spin_unlock_irqrestore(>dirty_lock, flags);
return;
}
 
+   mfbdev->x1 = mfbdev->y1 = INT_MAX;
+   mfbdev->x2 = mfbdev->y2 = 0;
+   spin_unlock_irqrestore(>dirty_lock, flags);
+
if (!bo->kmap.virtual) {
ret = ttm_bo_kmap(>bo, 0, bo->bo.num_pages, >kmap);
if (ret) {
@@ -48,10 +84,10 @@ static void mga_dirty_update(struct mga_fbdev *mfbdev,
}
unmap = true;
}
-   for (i = y; i < y + height; i++) {
+   for (i = y; i <= y2; i++) {
/* assume equal stride for now */
src_offset = dst_offset = i * mfbdev->mfb.base.pitches[0] + (x 
* bpp);
-   memcpy_toio(bo->kmap.virtual + src_offset, mfbdev->sysram + 
src_offset, width * bpp);
+   memcpy_toio(bo->kmap.virtual + src_offset, mfbdev->sysram + 
src_offset, (x2 - x + 1) * bpp);
 
}
if (unmap)
@@ -270,6 +306,7 @@ int mgag200_fbdev_init(struct mga_device *mdev)
 
mdev->mfbdev = mfbdev;
mfbdev->helper.funcs = _fb_helper_funcs;
+   spin_lock_init(>dirty_lock);
 
ret = drm_fb_helper_init(mdev->dev, >helper,
 mdev->num_crtc, MGAG200FB_CONN_LIMIT);
diff --git a/drivers/gpu/drm/mgag200/mgag200_ttm.c 
b/drivers/gpu/drm/mgag200/mgag200_ttm.c
index b223dcb..a707394 100644
--- a/drivers/gpu/drm/mgag200/mgag200_ttm.c
+++ b/drivers/gpu/drm/mgag200/mgag200_ttm.c
@@ -315,8 +315,8 @@ int mgag200_bo_reserve(struct mgag200_bo *bo, bool no_wait)
 
ret = ttm_bo_reserve(>bo, true, no_wait, false, 0);
if (ret) {
-   if (ret != -ERESTARTSYS)
-   DRM_ERROR("reserve failed %p\n", bo);
+   if (ret != -ERESTARTSYS && ret != -EBUSY)
+   DRM_ERROR("reserve failed %p %d\n", bo, ret);
return ret;
}
return 0;
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[ 108/136 ] drm/prime: keep a reference from the handle to exported dma-buf (v6)

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Dave Airlie 

[ Upstream commit 219b47339ced80ca580bb6ce7d1636166984afa7 ]

Currently we have a problem with this:
1. i915: create gem object
2. i915: export gem object to prime
3. radeon: import gem object
4. close prime fd
5. radeon: unref object
6. i915: unref object

i915 has an imported object reference in its file priv, that isn't
cleaned up properly until fd close. The reference gets added at step 2,
but at step 6 we don't have enough info to clean it up.

The solution is to take a reference on the dma-buf when we export it,
and drop the reference when the gem handle goes away.

So when we export a dma_buf from a gem object, we keep track of it
with the handle, we take a reference to the dma_buf. When we close
the handle (i.e. userspace is finished with the buffer), we drop
the reference to the dma_buf, and it gets collected.

This patch isn't meant to fix any other problem or bikesheds, and it doesn't
fix any races with other scenarios.

v1.1: move export symbol line back up.

v2: okay I had to do a bit more, as the first patch showed a leak
on one of my tests, that I found using the dma-buf debugfs support,
the problem case is exporting a buffer twice with the same handle,
we'd add another export handle for it unnecessarily, however
we now fail if we try to export the same object with a different gem handle,
however I'm not sure if that is a case I want to support, and I've
gotten the code to WARN_ON if we hit something like that.

v2.1: rebase this patch, write better commit msg.
v3: cleanup error handling, track import vs export in linked list,
these two patches were separate previously, but seem to work better
like this.
v4: danvet is correct, this code is no longer useful, since the buffer
better exist, so remove it.
v5: always take a reference to the dma buf object, import or export.
(Imre Deak contributed this originally)
v6: square the circle, remove import vs export tracking now
that there is no difference

Reviewed-by: Daniel Vetter 
Cc: sta...@vger.kernel.org
Signed-off-by: Dave Airlie 
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/drm_gem.c   |4 +--
 drivers/gpu/drm/drm_prime.c |   76 +++
 include/drm/drmP.h  |5 ++-
 3 files changed, 44 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index fbe0842..730b93f 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -205,11 +205,11 @@ static void
 drm_gem_remove_prime_handles(struct drm_gem_object *obj, struct drm_file *filp)
 {
if (obj->import_attach) {
-   drm_prime_remove_imported_buf_handle(>prime,
+   drm_prime_remove_buf_handle(>prime,
obj->import_attach->dmabuf);
}
if (obj->export_dma_buf) {
-   drm_prime_remove_imported_buf_handle(>prime,
+   drm_prime_remove_buf_handle(>prime,
obj->export_dma_buf);
}
 }
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index f546ff9..6497c53 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -61,6 +61,7 @@ struct drm_prime_member {
struct dma_buf *dma_buf;
uint32_t handle;
 };
+static int drm_prime_add_buf_handle(struct drm_prime_file_private 
*prime_fpriv, struct dma_buf *dma_buf, uint32_t handle);
 
 int drm_gem_prime_handle_to_fd(struct drm_device *dev,
struct drm_file *file_priv, uint32_t handle, uint32_t flags,
@@ -68,7 +69,8 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev,
 {
struct drm_gem_object *obj;
void *buf;
-   int ret;
+   int ret = 0;
+   struct dma_buf *dmabuf;
 
obj = drm_gem_object_lookup(dev, file_priv, handle);
if (!obj)
@@ -77,43 +79,44 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev,
mutex_lock(_priv->prime.lock);
/* re-export the original imported object */
if (obj->import_attach) {
-   get_dma_buf(obj->import_attach->dmabuf);
-   *prime_fd = dma_buf_fd(obj->import_attach->dmabuf, flags);
-   drm_gem_object_unreference_unlocked(obj);
-   mutex_unlock(_priv->prime.lock);
-   return 0;
+   dmabuf = obj->import_attach->dmabuf;
+   goto out_have_obj;
}
 
if (obj->export_dma_buf) {
-   get_dma_buf(obj->export_dma_buf);
-   *prime_fd = dma_buf_fd(obj->export_dma_buf, flags);
-   drm_gem_object_unreference_unlocked(obj);
-   } else {
-   buf = dev->driver->gem_prime_export(dev, obj, flags);
-   if (IS_ERR(buf)) {
-   /* normally the created dma-buf takes ownership of the 
ref,
-* but if that fails then drop the ref
-

[ 107/136 ] drm/gma500: fix backlight hotkeys behaviour on netbooks

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Anisse Astier 

[ Upstream commit e127dc28cc3057575da0216cde85687153ca180f ]

Backlight hotkeys weren't working before on certain cedartrail laptops.

The source of this problem is that the hotkeys' ASLE opregion interrupts
were simply ignored. Driver seemed to expect the interrupt to be
associated with a pipe, but it wasn't.

Accepting the ASLE interrupt without an associated pipe event flag fixes
the issue, the backlight code is called when needed, making the
brightness keys work properly.

[patrik: This patch affects irq handling on any netbook with opregion support]

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=833597
Reference: http://lists.freedesktop.org/archives/dri-devel/2012-July/025279.html
Cc: sta...@kernel.org
Signed-off-by: Anisse Astier 
Signed-off-by: Patrik Jakobsson 
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/gma500/psb_irq.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/gma500/psb_irq.c b/drivers/gpu/drm/gma500/psb_irq.c
index 8652cdf..029eccf 100644
--- a/drivers/gpu/drm/gma500/psb_irq.c
+++ b/drivers/gpu/drm/gma500/psb_irq.c
@@ -211,7 +211,7 @@ irqreturn_t psb_irq_handler(DRM_IRQ_ARGS)
 
vdc_stat = PSB_RVDC32(PSB_INT_IDENTITY_R);
 
-   if (vdc_stat & _PSB_PIPE_EVENT_FLAG)
+   if (vdc_stat & (_PSB_PIPE_EVENT_FLAG|_PSB_IRQ_ASLE))
dsp_int = 1;
 
/* FIXME: Handle Medfield
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 136/136 ] s390: move dummy io_remap_pfn_range() to asm/pgtable.h

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Linus Torvalds 

[ Upstream commit 4f2e29031e6c67802e7370292dd050fd62f337ee ]

Commit b4cbb197c7e7 ("vm: add vm_iomap_memory() helper function") added
a helper function wrapper around io_remap_pfn_range(), and every other
architecture defined it in .

The s390 choice of  may make sense, but is not very convenient
for this case, and gratuitous differences like that cause unexpected errors 
like this:

   mm/memory.c: In function 'vm_iomap_memory':
   mm/memory.c:2439:2: error: implicit declaration of function 
'io_remap_pfn_range' [-Werror=implicit-function-declaration]

Glory be the kbuild test robot who noticed this, bisected it, and
reported it to the guilty parties (ie me).

Cc: Martin Schwidefsky 
Cc: Heiko Carstens 
Signed-off-by: Linus Torvalds 
Signed-off-by: Steven Rostedt 
---
 arch/s390/include/asm/pgtable.h |4 
 1 file changed, 4 insertions(+)

diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index 6bd7d74..fb433eb 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -65,6 +65,10 @@ static inline int is_zero_pfn(unsigned long pfn)
 
 #define my_zero_pfn(addr)  page_to_pfn(ZERO_PAGE(addr))
 
+/* TODO: s390 cannot support io_remap_pfn_range... */
+#define io_remap_pfn_range(vma, vaddr, pfn, size, prot)   \
+   remap_pfn_range(vma, vaddr, pfn, size, prot)
+
 #endif /* !__ASSEMBLY__ */
 
 /*
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 103/136 ] ext4: add check for inodes_count overflow in new resize ioctl

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Theodore Ts'o 

[ Upstream commit 3f8a6411fbada1fa482276591e037f3b1adcf55b ]

Addresses-Red-Hat-Bugzilla: #913245

Reported-by: Eric Sandeen 
Signed-off-by: "Theodore Ts'o" 
Reviewed-by: Carlos Maiolino 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 fs/ext4/resize.c |4 
 1 file changed, 4 insertions(+)

diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 14de511..744097d 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1680,6 +1680,10 @@ int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t 
n_blocks_count)
return 0;
 
ext4_get_group_no_and_offset(sb, n_blocks_count - 1, _group, );
+   if (n_group > (0xUL / EXT4_INODES_PER_GROUP(sb))) {
+   ext4_warning(sb, "resize would cause inodes_count overflow");
+   return -EINVAL;
+   }
ext4_get_group_no_and_offset(sb, o_blocks_count - 1, _group, );
 
n_desc_blocks = (n_group + EXT4_DESC_PER_BLOCK(sb)) /
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 105/136 ] drm/cirrus: deal with bo reserve fail in dirty update path

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Dave Airlie 

[ Upstream commit f3b2bbdc8a87a080ccd23d27fca4b87d61340dd4 ]

Port over the mgag200 fix to cirrus as it suffers the same issue.

On F19 testing, it was noticed we get a lot of errors in dmesg
about being unable to reserve the buffer when plymouth starts,
this is due to the buffer being in the process of migrating,
so it makes sense we can't reserve it.

In order to deal with it, this adds delayed updates for the dirty
updates, when the bo is unreservable, in the normal console case
this shouldn't ever happen, its just when plymouth or X is
pushing the console bo to system memory.

Cc: sta...@vger.kernel.org
Signed-off-by: Dave Airlie 
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/cirrus/cirrus_drv.h   |2 ++
 drivers/gpu/drm/cirrus/cirrus_fbdev.c |   38 -
 drivers/gpu/drm/cirrus/cirrus_ttm.c   |2 +-
 3 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h 
b/drivers/gpu/drm/cirrus/cirrus_drv.h
index 64ea597..9f29a90 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.h
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.h
@@ -155,6 +155,8 @@ struct cirrus_fbdev {
struct list_head fbdev_list;
void *sysram;
int size;
+   int x1, y1, x2, y2; /* dirty rect */
+   spinlock_t dirty_lock;
 };
 
 struct cirrus_bo {
diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c 
b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 9a276a5..774bade 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -27,16 +27,51 @@ static void cirrus_dirty_update(struct cirrus_fbdev *afbdev,
int bpp = (afbdev->gfb.base.bits_per_pixel + 7)/8;
int ret;
bool unmap = false;
+   bool store_for_later = false;
+   int x2, y2;
+   unsigned long flags;
 
obj = afbdev->gfb.obj;
bo = gem_to_cirrus_bo(obj);
 
+   /*
+* try and reserve the BO, if we fail with busy
+* then the BO is being moved and we should
+* store up the damage until later.
+*/
ret = cirrus_bo_reserve(bo, true);
if (ret) {
-   DRM_ERROR("failed to reserve fb bo\n");
+   if (ret != -EBUSY)
+   return;
+   store_for_later = true;
+   }
+
+   x2 = x + width - 1;
+   y2 = y + height - 1;
+   spin_lock_irqsave(>dirty_lock, flags);
+
+   if (afbdev->y1 < y)
+   y = afbdev->y1;
+   if (afbdev->y2 > y2)
+   y2 = afbdev->y2;
+   if (afbdev->x1 < x)
+   x = afbdev->x1;
+   if (afbdev->x2 > x2)
+   x2 = afbdev->x2;
+
+   if (store_for_later) {
+   afbdev->x1 = x;
+   afbdev->x2 = x2;
+   afbdev->y1 = y;
+   afbdev->y2 = y2;
+   spin_unlock_irqrestore(>dirty_lock, flags);
return;
}
 
+   afbdev->x1 = afbdev->y1 = INT_MAX;
+   afbdev->x2 = afbdev->y2 = 0;
+   spin_unlock_irqrestore(>dirty_lock, flags);
+
if (!bo->kmap.virtual) {
ret = ttm_bo_kmap(>bo, 0, bo->bo.num_pages, >kmap);
if (ret) {
@@ -283,6 +318,7 @@ int cirrus_fbdev_init(struct cirrus_device *cdev)
 
cdev->mode_info.gfbdev = gfbdev;
gfbdev->helper.funcs = _fb_helper_funcs;
+   spin_lock_init(>dirty_lock);
 
ret = drm_fb_helper_init(cdev->dev, >helper,
 cdev->num_crtc, CIRRUSFB_CONN_LIMIT);
diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c 
b/drivers/gpu/drm/cirrus/cirrus_ttm.c
index 50e170f..d4b1b1d 100644
--- a/drivers/gpu/drm/cirrus/cirrus_ttm.c
+++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c
@@ -321,7 +321,7 @@ int cirrus_bo_reserve(struct cirrus_bo *bo, bool no_wait)
 
ret = ttm_bo_reserve(>bo, true, no_wait, false, 0);
if (ret) {
-   if (ret != -ERESTARTSYS)
+   if (ret != -ERESTARTSYS && ret != -EBUSY)
DRM_ERROR("reserve failed %p\n", bo);
return ret;
}
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 104/136 ] r8169: fix 8168evl frame padding.

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Stefan Bader 

[ Upstream commit e5195c1f31f399289347e043d6abf3ffa80f0005 ]

Signed-off-by: Stefan Bader 
Acked-by: Francois Romieu 
Cc: hayeswang 
Signed-off-by: David S. Miller 
Signed-off-by: Steven Rostedt 
---
 drivers/net/ethernet/realtek/r8169.c |9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/realtek/r8169.c 
b/drivers/net/ethernet/realtek/r8169.c
index 886b52f..74ca124 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -5806,6 +5806,14 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff 
*skb,
goto err_stop_0;
}
 
+   /* 8168evl does not automatically pad to minimum length. */
+   if (unlikely(tp->mac_version == RTL_GIGA_MAC_VER_34 &&
+skb->len < ETH_ZLEN)) {
+   if (skb_padto(skb, ETH_ZLEN))
+   goto err_update_stats;
+   skb_put(skb, ETH_ZLEN - skb->len);
+   }
+
if (unlikely(le32_to_cpu(txd->opts1) & DescOwn))
goto err_stop_0;
 
@@ -5877,6 +5885,7 @@ err_dma_1:
rtl8169_unmap_tx_skb(d, tp->tx_skb + entry, txd);
 err_dma_0:
dev_kfree_skb(skb);
+err_update_stats:
dev->stats.tx_dropped++;
return NETDEV_TX_OK;
 
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 102/136 ] netfilter: xt_rpfilter: skip locally generated broadcast/multicast, too

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Florian Westphal 

[ Upstream commit f83a7ea2075ca896f2dbf07672bac9cf3682ff74 ]

Alex Efros reported rpfilter module doesn't match following packets:
IN=br.qemu SRC=192.168.2.1 DST=192.168.2.255 [ .. ]
(netfilter bugzilla #814).

Problem is that network stack arranges for the locally generated broadcasts
to appear on the interface they were sent out, so the IFF_LOOPBACK check
doesn't trigger.

As -m rpfilter is restricted to PREROUTING, we can check for existing
rtable instead, it catches locally-generated broad/multicast case, too.

Signed-off-by: Florian Westphal 
Signed-off-by: Pablo Neira Ayuso 
Signed-off-by: Steven Rostedt 
---
 net/ipv4/netfilter/ipt_rpfilter.c  |8 +++-
 net/ipv6/netfilter/ip6t_rpfilter.c |8 +++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/netfilter/ipt_rpfilter.c 
b/net/ipv4/netfilter/ipt_rpfilter.c
index 31371be..5d60ca1 100644
--- a/net/ipv4/netfilter/ipt_rpfilter.c
+++ b/net/ipv4/netfilter/ipt_rpfilter.c
@@ -66,6 +66,12 @@ static bool rpfilter_lookup_reverse(struct flowi4 *fl4,
return dev_match;
 }
 
+static bool rpfilter_is_local(const struct sk_buff *skb)
+{
+   const struct rtable *rt = skb_rtable(skb);
+   return rt && (rt->rt_flags & RTCF_LOCAL);
+}
+
 static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
 {
const struct xt_rpfilter_info *info;
@@ -76,7 +82,7 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct 
xt_action_param *par)
info = par->matchinfo;
invert = info->flags & XT_RPFILTER_INVERT;
 
-   if (par->in->flags & IFF_LOOPBACK)
+   if (rpfilter_is_local(skb))
return true ^ invert;
 
iph = ip_hdr(skb);
diff --git a/net/ipv6/netfilter/ip6t_rpfilter.c 
b/net/ipv6/netfilter/ip6t_rpfilter.c
index 5d1d8b0..a7b522f 100644
--- a/net/ipv6/netfilter/ip6t_rpfilter.c
+++ b/net/ipv6/netfilter/ip6t_rpfilter.c
@@ -71,6 +71,12 @@ static bool rpfilter_lookup_reverse6(const struct sk_buff 
*skb,
return ret;
 }
 
+static bool rpfilter_is_local(const struct sk_buff *skb)
+{
+   const struct rt6_info *rt = (const void *) skb_dst(skb);
+   return rt && (rt->rt6i_flags & RTF_LOCAL);
+}
+
 static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
 {
const struct xt_rpfilter_info *info = par->matchinfo;
@@ -78,7 +84,7 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct 
xt_action_param *par)
struct ipv6hdr *iph;
bool invert = info->flags & XT_RPFILTER_INVERT;
 
-   if (par->in->flags & IFF_LOOPBACK)
+   if (rpfilter_is_local(skb))
return true ^ invert;
 
iph = ipv6_hdr(skb);
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 100/136 ] netfilter: nf_ct_helper: dont discard helper if it is actually the same

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Florian Westphal 

[ Upstream commit 6e2f0aa8cf8892868bf2c19349cb5d7c407f690d ]

commit (32f5376 netfilter: nf_ct_helper: disable automatic helper
re-assignment of different type) broke transparent proxy scenarios.

For example, initial helper lookup might yield "ftp" (dport 21),
while re-lookup after REDIRECT yields "ftp-2121".

This causes the autoassign code to toss the ftp helper, even
though these are just different instances of the same helper.

Change the test to check for the helper function address instead
of the helper address, as suggested by Pablo.

Signed-off-by: Florian Westphal 
Signed-off-by: Pablo Neira Ayuso 
Signed-off-by: Steven Rostedt 
---
 net/netfilter/nf_conntrack_helper.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/nf_conntrack_helper.c 
b/net/netfilter/nf_conntrack_helper.c
index c4bc637..622dd4d 100644
--- a/net/netfilter/nf_conntrack_helper.c
+++ b/net/netfilter/nf_conntrack_helper.c
@@ -232,7 +232,9 @@ int __nf_ct_try_assign_helper(struct nf_conn *ct, struct 
nf_conn *tmpl,
/* We only allow helper re-assignment of the same sort since
 * we cannot reallocate the helper extension area.
 */
-   if (help->helper != helper) {
+   struct nf_conntrack_helper *tmp = rcu_dereference(help->helper);
+
+   if (tmp && tmp->help != helper->help) {
RCU_INIT_POINTER(help->helper, NULL);
goto out;
}
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 101/136 ] netfilter: ctnetlink: dont permit ct creation with random tuple

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Florian Westphal 

[ Upstream commit 442fad9423b78319e0019a7f5047eddf3317afbc ]

Userspace can cause kernel panic by not specifying orig/reply
tuple: kernel will create a tuple with random stack values.

Problem is that tuple.dst.dir will be random, too, which
causes nf_ct_tuplehash_to_ctrack() to return garbage.

Signed-off-by: Florian Westphal 
Signed-off-by: Pablo Neira Ayuso 
Signed-off-by: Steven Rostedt 
---
 net/netfilter/nf_conntrack_netlink.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/netfilter/nf_conntrack_netlink.c 
b/net/netfilter/nf_conntrack_netlink.c
index 9807f32..0f15779 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1579,6 +1579,9 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff 
*skb,
if (nlh->nlmsg_flags & NLM_F_CREATE) {
enum ip_conntrack_events events;
 
+   if (!cda[CTA_TUPLE_ORIG] || !cda[CTA_TUPLE_REPLY])
+   return -EINVAL;
+
ct = ctnetlink_create_conntrack(net, zone, cda, ,
, u3);
if (IS_ERR(ct))
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 099/136 ] netfilter: ipset: "Directory not empty" error message

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Jozsef Kadlecsik 

[ Upstream commit dd82088dab3646ed28e4aa43d1a5b5d5ffc2afba ]

When an entry flagged with "nomatch" was tested by ipset, it
returned the error message "Kernel error received:
Directory not empty" instead of " is NOT in set "
(reported by John Brendler).

The internal error code was not properly transformed before returning
to userspace, fixed.

Signed-off-by: Jozsef Kadlecsik 
Signed-off-by: Steven Rostedt 
---
 net/netfilter/ipset/ip_set_core.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/ipset/ip_set_core.c 
b/net/netfilter/ipset/ip_set_core.c
index 9730882..eaabc58 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -1387,7 +1387,8 @@ ip_set_utest(struct sock *ctnl, struct sk_buff *skb,
if (ret == -EAGAIN)
ret = 1;
 
-   return ret < 0 ? ret : ret > 0 ? 0 : -IPSET_ERR_EXIST;
+   return (ret < 0 && ret != -ENOTEMPTY) ? ret :
+   ret > 0 ? 0 : -IPSET_ERR_EXIST;
 }
 
 /* Get headed data of a set */
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 098/136 ] netfilter: nf_ct_sip: dont drop packets with offsets pointing outside the packet

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Patrick McHardy 

[ Upstream commit 3a7b21eaf4fb3c971bdb47a98f570550ddfe4471 ]

Some Cisco phones create huge messages that are spread over multiple packets.
After calculating the offset of the SIP body, it is validated to be within
the packet and the packet is dropped otherwise. This breaks operation of
these phones. Since connection tracking is supposed to be passive, just let
those packets pass unmodified and untracked.

Signed-off-by: Patrick McHardy 
Signed-off-by: Pablo Neira Ayuso 
Signed-off-by: Steven Rostedt 
---
 net/netfilter/nf_conntrack_sip.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c
index 5c0a112..8ec43a7 100644
--- a/net/netfilter/nf_conntrack_sip.c
+++ b/net/netfilter/nf_conntrack_sip.c
@@ -1521,7 +1521,7 @@ static int sip_help_tcp(struct sk_buff *skb, unsigned int 
protoff,
 
msglen = origlen = end - dptr;
if (msglen > datalen)
-   return NF_DROP;
+   return NF_ACCEPT;
 
ret = process_sip_msg(skb, ct, dataoff, , );
if (ret != NF_ACCEPT)
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 096/136 ] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Hans Schillstrom 

[ Upstream commit f7a1dd6e3ad59f0cfd51da29dfdbfd54122c5916 ]

The reason for this patch is crash in kmemdup
caused by returning from get_callid with uniialized
matchoff and matchlen.

Removing Zero check of matchlen since it's done by ct_sip_get_header()

BUG: unable to handle kernel paging request at 880457b5763f
IP: [] kmemdup+0x2e/0x35
PGD 27f6067 PUD 0
Oops:  [#1] PREEMPT SMP
Modules linked in: xt_state xt_helper nf_conntrack_ipv6 nf_defrag_ipv6 
ip6table_mangle xt_connmark xt_conntrack ip6_tables nf_conntrack_ftp ip_vs_ftp 
nf_nat xt_tcpudp iptable_mangle xt_mark ip_tables x_tables ip_vs_rr ip_vs_lblcr 
ip_vs_pe_sip ip_vs nf_conntrack_sip nf_conntrack bonding igb i2c_algo_bit 
i2c_core
CPU 5
Pid: 0, comm: swapper/5 Not tainted 3.9.0-rc5+ #5  /S1200KP
RIP: 0010:[]  [] kmemdup+0x2e/0x35
RSP: 0018:8803fea03648  EFLAGS: 00010282
RAX: 8803d61063e0 RBX: 0003 RCX: 0003
RDX: 0003 RSI: 880457b5763f RDI: 8803d61063e0
RBP: 8803fea03658 R08: 0008 R09: 0011
R10: 0011 R11: 0081a8a3 R12: 880457b5763f
R13: 8803d67f786a R14: 8803fea03730 R15: a0098e90
FS:  () GS:8803fea0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 880457b5763f CR3: 01a0c000 CR4: 001407e0
DR0:  DR1:  DR2: 
DR3:  DR6: 0ff0 DR7: 0400
Process swapper/5 (pid: 0, threadinfo 8803ee18c000, task 8803ee18a480)
Stack:
 8803d822a080 001c 8803fea036c8 a000937a
 81f0d8a0 00038135fdd5 88030014 88030011
 150118ac 8803d7e8a000 88031e0118ac 
Call Trace:
 

 [] ip_vs_sip_fill_param+0x13a/0x187 [ip_vs_pe_sip]
 [] ip_vs_sched_persist+0x2c6/0x9c3 [ip_vs]
 [] ? __lock_acquire+0x677/0x1697
 [] ? native_sched_clock+0x3c/0x7d
 [] ? native_sched_clock+0x3c/0x7d
 [] ? sched_clock_cpu+0x43/0xcf
 [] ip_vs_schedule+0x181/0x4ba [ip_vs]
...

Signed-off-by: Hans Schillstrom 
Acked-by: Julian Anastasov 
Signed-off-by: Simon Horman 
Signed-off-by: David S. Miller 
Signed-off-by: Steven Rostedt 
---
 net/netfilter/ipvs/ip_vs_pe_sip.c |6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_pe_sip.c 
b/net/netfilter/ipvs/ip_vs_pe_sip.c
index 1aa5cac..55add93 100644
--- a/net/netfilter/ipvs/ip_vs_pe_sip.c
+++ b/net/netfilter/ipvs/ip_vs_pe_sip.c
@@ -37,14 +37,10 @@ static int get_callid(const char *dptr, unsigned int 
dataoff,
if (ret > 0)
break;
if (!ret)
-   return 0;
+   return -EINVAL;
dataoff += *matchoff;
}
 
-   /* Empty callid is useless */
-   if (!*matchlen)
-   return -EINVAL;
-
/* Too large is useless */
if (*matchlen > IP_VS_PEDATA_MAXLEN)
return -EINVAL;
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 095/136 ] xhci: Dont warn on empty ring for suspended devices.

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Sarah Sharp 

[ Upstream commit a83d6755814e4614ba77e15d82796af0f695c6b8 ]

When a device attached to the roothub is suspended, the endpoint rings
are stopped.  The host may generate a completion event with the
completion code set to 'Stopped' or 'Stopped Invalid' when the ring is
halted.  The current xHCI code prints a warning in that case, which can
be really annoying if the USB device is coming into and out of suspend.

Remove the unnecessary warning.

Signed-off-by: Sarah Sharp 
Tested-by: Stephen Hemminger 
Signed-off-by: Steven Rostedt 
---
 drivers/usb/host/xhci-ring.c |   23 +++
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index b9ade46..8848616 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2450,14 +2450,21 @@ static int handle_tx_event(struct xhci_hcd *xhci,
 * TD list.
 */
if (list_empty(_ring->td_list)) {
-   xhci_warn(xhci, "WARN Event TRB for slot %d ep %d "
-   "with no TDs queued?\n",
- TRB_TO_SLOT_ID(le32_to_cpu(event->flags)),
- ep_index);
-   xhci_dbg(xhci, "Event TRB with TRB type ID %u\n",
-(le32_to_cpu(event->flags) &
- TRB_TYPE_BITMASK)>>10);
-   xhci_print_trb_offsets(xhci, (union xhci_trb *) event);
+   /*
+* A stopped endpoint may generate an extra completion
+* event if the device was suspended.  Don't print
+* warnings.
+*/
+   if (!(trb_comp_code == COMP_STOP ||
+   trb_comp_code == 
COMP_STOP_INVAL)) {
+   xhci_warn(xhci, "WARN Event TRB for slot %d ep 
%d with no TDs queued?\n",
+   
TRB_TO_SLOT_ID(le32_to_cpu(event->flags)),
+   ep_index);
+   xhci_dbg(xhci, "Event TRB with TRB type ID 
%u\n",
+   (le32_to_cpu(event->flags) &
+TRB_TYPE_BITMASK)>>10);
+   xhci_print_trb_offsets(xhci, (union xhci_trb *) 
event);
+   }
if (ep->skip) {
ep->skip = false;
xhci_dbg(xhci, "td_list is empty while skip "
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 094/136 ] e1000e: fix runtime power management transitions

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Konstantin Khlebnikov 

[ Upstream commit 66148babe728f3e00e13c56f6b0ecf325abd80da ]

This patch removes redundant actions from driver and fixes its interaction
with actions in pci-bus runtime power management code.

It removes pci_save_state() from __e1000_shutdown() for normal adapters,
PCI bus callbacks pci_pm_*() will do all this for us. Now __e1000_shutdown()
switches to D3-state only quad-port adapters, because they needs quirk for
clearing false-positive error from downsteam pci-e port.

pci_save_state() now called after clearing bus-master bit, thus __e1000_resume()
and e1000_io_slot_reset() must set it back after restoring configuration space.

This patch set get_link_status before calling pm_runtime_put() in e1000_open()
to allow e1000_idle() get real link status and schedule first runtime suspend.

This patch also enables wakeup for device if management mode is enabled
(like for WoL) as result pci_prepare_to_sleep() would setup wakeup without
special actions like custom 'enable_wakeup' sign.

Cc: Bruce Allan 
Signed-off-by: Konstantin Khlebnikov 
Acked-by: Rafael J. Wysocki 
Tested-by: Borislav Petkov 
Tested-by: Aaron Brown 
Signed-off-by: Jeff Kirsher 
Signed-off-by: Steven Rostedt 
---
 drivers/net/ethernet/intel/e1000e/netdev.c |   78 +++-
 1 file changed, 18 insertions(+), 60 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c 
b/drivers/net/ethernet/intel/e1000e/netdev.c
index a46e75e..d191a63 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -3951,6 +3951,7 @@ static int e1000_open(struct net_device *netdev)
netif_start_queue(netdev);
 
adapter->idle_check = true;
+   hw->mac.get_link_status = true;
pm_runtime_put(>dev);
 
/* fire a link status change interrupt to start the watchdog */
@@ -5454,8 +5455,7 @@ release:
return retval;
 }
 
-static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake,
-   bool runtime)
+static int __e1000_shutdown(struct pci_dev *pdev, bool runtime)
 {
struct net_device *netdev = pci_get_drvdata(pdev);
struct e1000_adapter *adapter = netdev_priv(netdev);
@@ -5479,10 +5479,6 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool 
*enable_wake,
}
e1000e_reset_interrupt_capability(adapter);
 
-   retval = pci_save_state(pdev);
-   if (retval)
-   return retval;
-
status = er32(STATUS);
if (status & E1000_STATUS_LU)
wufc &= ~E1000_WUFC_LNKC;
@@ -5538,13 +5534,6 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool 
*enable_wake,
ew32(WUFC, 0);
}
 
-   *enable_wake = !!wufc;
-
-   /* make sure adapter isn't asleep if manageability is enabled */
-   if ((adapter->flags & FLAG_MNG_PT_ENABLED) ||
-   (hw->mac.ops.check_mng_mode(hw)))
-   *enable_wake = true;
-
if (adapter->hw.phy.type == e1000_phy_igp_3)
e1000e_igp3_phy_powerdown_workaround_ich8lan(>hw);
 
@@ -5556,26 +5545,6 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool 
*enable_wake,
 
pci_disable_device(pdev);
 
-   return 0;
-}
-
-static void e1000_power_off(struct pci_dev *pdev, bool sleep, bool wake)
-{
-   if (sleep && wake) {
-   pci_prepare_to_sleep(pdev);
-   return;
-   }
-
-   pci_wake_from_d3(pdev, wake);
-   pci_set_power_state(pdev, PCI_D3hot);
-}
-
-static void e1000_complete_shutdown(struct pci_dev *pdev, bool sleep,
-bool wake)
-{
-   struct net_device *netdev = pci_get_drvdata(pdev);
-   struct e1000_adapter *adapter = netdev_priv(netdev);
-
/*
 * The pci-e switch on some quad port adapters will report a
 * correctable error when the MAC transitions from D0 to D3.  To
@@ -5591,12 +5560,13 @@ static void e1000_complete_shutdown(struct pci_dev 
*pdev, bool sleep,
pci_write_config_word(us_dev, pos + PCI_EXP_DEVCTL,
  (devctl & ~PCI_EXP_DEVCTL_CERE));
 
-   e1000_power_off(pdev, sleep, wake);
+   pci_save_state(pdev);
+   pci_prepare_to_sleep(pdev);
 
pci_write_config_word(us_dev, pos + PCI_EXP_DEVCTL, devctl);
-   } else {
-   e1000_power_off(pdev, sleep, wake);
}
+
+   return 0;
 }
 
 #ifdef CONFIG_PCIEASPM
@@ -5658,9 +5628,7 @@ static int __e1000_resume(struct pci_dev *pdev)
if (aspm_disable_flag)
e1000e_disable_aspm(pdev, aspm_disable_flag);
 
-   pci_set_power_state(pdev, PCI_D0);
-   pci_restore_state(pdev);
-   pci_save_state(pdev);
+   pci_set_master(pdev);
 
e1000e_set_interrupt_capability(adapter);
if (netif_running(netdev)) {
@@ 

[ 092/136 ] perf/x86/intel/lbr: Demand proper privileges for PERF_SAMPLE_BRANCH_KERNEL

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Peter Zijlstra 

[ Upstream commit 7cc23cd6c0c7d7f4bee057607e7ce01568925717 ]

We should always have proper privileges when requesting kernel
data.

Signed-off-by: Peter Zijlstra 
Cc: 
Cc: Andi Kleen 
Cc: eran...@google.com
Link: http://lkml.kernel.org/r/20130503121256.230745...@chello.nl
Signed-off-by: Steven Rostedt 
[ Fix build error reported by fengguang...@intel.com, propagate error code 
back. ]
Signed-off-by: Ingo Molnar 
Link: http://lkml.kernel.org/n/tip-v0x9ky3ahzr6nm3c6ilwr...@git.kernel.org
---
 arch/x86/kernel/cpu/perf_event_intel_lbr.c |   13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_lbr.c 
b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
index de341d4..d978353 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_lbr.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
@@ -310,7 +310,7 @@ void intel_pmu_lbr_read(void)
  * - in case there is no HW filter
  * - in case the HW filter has errata or limitations
  */
-static void intel_pmu_setup_sw_lbr_filter(struct perf_event *event)
+static int intel_pmu_setup_sw_lbr_filter(struct perf_event *event)
 {
u64 br_type = event->attr.branch_sample_type;
int mask = 0;
@@ -318,8 +318,11 @@ static void intel_pmu_setup_sw_lbr_filter(struct 
perf_event *event)
if (br_type & PERF_SAMPLE_BRANCH_USER)
mask |= X86_BR_USER;
 
-   if (br_type & PERF_SAMPLE_BRANCH_KERNEL)
+   if (br_type & PERF_SAMPLE_BRANCH_KERNEL) {
+   if (perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN))
+   return -EACCES;
mask |= X86_BR_KERNEL;
+   }
 
/* we ignore BRANCH_HV here */
 
@@ -339,6 +342,8 @@ static void intel_pmu_setup_sw_lbr_filter(struct perf_event 
*event)
 * be used by fixup code for some CPU
 */
event->hw.branch_reg.reg = mask;
+
+   return 0;
 }
 
 /*
@@ -386,7 +391,9 @@ int intel_pmu_setup_lbr_filter(struct perf_event *event)
/*
 * setup SW LBR filter
 */
-   intel_pmu_setup_sw_lbr_filter(event);
+   ret = intel_pmu_setup_sw_lbr_filter(event);
+   if (ret)
+   return ret;
 
/*
 * setup HW LBR filter, if any
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 090/136 ] perf/x86/intel: Fix unintended variable name reuse

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= 

[ Upstream commit 1b0dac2ac6debdbf1541e15f2cede03613cf4465 ]

The variable name events_group is already in used and led to a
compilation error when using clang to build the Linux Kernel .
The fix is just to rename the var. No functional change. Please
apply.

Fix suggested in discussion by PaX Team 

Signed-off-by: Jan-Simon Möller 
Cc: rost...@goodmis.org
Cc: a.p.zijls...@chello.nl
Cc: pau...@samba.org
Cc: a...@ghostprotocols.net
Link: http://lkml.kernel.org/r/1367316153-14808-1-git-send-email-dl...@gmx.de
Cc: 
Signed-off-by: Ingo Molnar 
Signed-off-by: Steven Rostedt 
---
 arch/x86/kernel/cpu/perf_event_intel_uncore.c |   16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c 
b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index 906b553..0c0957d 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -2398,7 +2398,7 @@ static void __init uncore_types_exit(struct 
intel_uncore_type **types)
 static int __init uncore_type_init(struct intel_uncore_type *type)
 {
struct intel_uncore_pmu *pmus;
-   struct attribute_group *events_group;
+   struct attribute_group *attr_group;
struct attribute **attrs;
int i, j;
 
@@ -2425,19 +2425,19 @@ static int __init uncore_type_init(struct 
intel_uncore_type *type)
while (type->event_descs[i].attr.attr.name)
i++;
 
-   events_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
-   sizeof(*events_group), GFP_KERNEL);
-   if (!events_group)
+   attr_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
+   sizeof(*attr_group), GFP_KERNEL);
+   if (!attr_group)
goto fail;
 
-   attrs = (struct attribute **)(events_group + 1);
-   events_group->name = "events";
-   events_group->attrs = attrs;
+   attrs = (struct attribute **)(attr_group + 1);
+   attr_group->name = "events";
+   attr_group->attrs = attrs;
 
for (j = 0; j < i; j++)
attrs[j] = >event_descs[j].attr.attr;
 
-   type->attr_groups[1] = events_group;
+   type->attr_groups[1] = attr_group;
}
 
type->pmus = pmus;
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 091/136 ] perf/x86/intel/lbr: Fix LBR filter

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Peter Zijlstra 

[ Upstream commit 6e15eb3ba6c0249c9e8c783517d131b47db995ca ]

The LBR 'from' adddress is under full userspace control; ensure
we validate it before reading from it.

Note: is_module_text_address() can potentially be quite
expensive; for those running into that with high overhead
in modules optimize it using an RCU backed rb-tree.

Reported-by: Andi Kleen 
Signed-off-by: Peter Zijlstra 
Cc: 
Cc: eran...@google.com
Link: http://lkml.kernel.org/r/20130503121256.158211...@chello.nl
Signed-off-by: Ingo Molnar 
Link: http://lkml.kernel.org/n/tip-mk8i82ffzax01cnqo829i...@git.kernel.org
Signed-off-by: Steven Rostedt 
---
 arch/x86/kernel/cpu/perf_event_intel_lbr.c |   14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_lbr.c 
b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
index da02e9c..de341d4 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_lbr.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
@@ -442,8 +442,18 @@ static int branch_type(unsigned long from, unsigned long 
to)
return X86_BR_NONE;
 
addr = buf;
-   } else
-   addr = (void *)from;
+   } else {
+   /*
+* The LBR logs any address in the IP, even if the IP just
+* faulted. This means userspace can control the from address.
+* Ensure we don't blindy read any address by validating it is
+* a known text address.
+*/
+   if (kernel_text_address(from))
+   addr = (void *)from;
+   else
+   return X86_BR_NONE;
+   }
 
/*
 * decoder needs to know the ABI especially
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 089/136 ] perf/x86/intel: Add support for IvyBridge model 58 Uncore

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Vince Weaver 

[ Upstream commit 9a6bc14350b130427725f33e371e86212fa56c85 ]

According to Intel Vol3b 18.9, the IvyBridge model 58 uncore is
the same as that of SandyBridge.

I've done some simple tests and with this patch things seem to
work on my mac-mini.

Signed-off-by: Vince Weaver 
Cc: Peter Zijlstra 
Cc: Paul Mackerras 
Cc: Arnaldo Carvalho de Melo 
Cc: Stephane Eranian 
Link: 
http://lkml.kernel.org/r/alpine.deb.2.02.1304291549320.15...@vincent-weaver-1.um.maine.edu
Cc: 
Signed-off-by: Ingo Molnar 
Signed-off-by: Steven Rostedt 
---
 arch/x86/kernel/cpu/perf_event_intel_uncore.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c 
b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index 38e4894..906b553 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -2820,6 +2820,7 @@ static int __init uncore_cpu_init(void)
msr_uncores = nhm_msr_uncores;
break;
case 42: /* Sandy Bridge */
+   case 58: /* Ivy Bridge */
if (snb_uncore_cbox.num_boxes > max_cores)
snb_uncore_cbox.num_boxes = max_cores;
msr_uncores = snb_msr_uncores;
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 088/136 ] net/eth/ibmveth: Fixup retrieval of MAC address

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Benjamin Herrenschmidt 

[ Upstream commit 13f85203e1060da83d9ec1c1c5a63343eaab8de4 ]

Some ancient pHyp versions used to create a 8 bytes local-mac-address
property in the device-tree instead of a 6 bytes one for veth.

The Linux driver code to deal with that is an insane hack which also
happens to break with some choices of MAC addresses in qemu by testing
for a bit in the address rather than just looking at the size of the
property.

Sanitize this by doing the latter instead.

Signed-off-by: Benjamin Herrenschmidt 
CC: 
Signed-off-by: David S. Miller 
Signed-off-by: Steven Rostedt 
---
 drivers/net/ethernet/ibm/ibmveth.c |   23 ++-
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmveth.c 
b/drivers/net/ethernet/ibm/ibmveth.c
index b68d28a..33a1760 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -1327,7 +1327,7 @@ static const struct net_device_ops ibmveth_netdev_ops = {
 static int __devinit ibmveth_probe(struct vio_dev *dev,
   const struct vio_device_id *id)
 {
-   int rc, i;
+   int rc, i, mac_len;
struct net_device *netdev;
struct ibmveth_adapter *adapter;
unsigned char *mac_addr_p;
@@ -1337,11 +1337,19 @@ static int __devinit ibmveth_probe(struct vio_dev *dev,
dev->unit_address);
 
mac_addr_p = (unsigned char *)vio_get_attribute(dev, VETH_MAC_ADDR,
-   NULL);
+   _len);
if (!mac_addr_p) {
dev_err(>dev, "Can't find VETH_MAC_ADDR attribute\n");
return -EINVAL;
}
+   /* Workaround for old/broken pHyp */
+   if (mac_len == 8)
+   mac_addr_p += 2;
+   else if (mac_len != 6) {
+   dev_err(>dev, "VETH_MAC_ADDR attribute wrong len %d\n",
+   mac_len);
+   return -EINVAL;
+   }
 
mcastFilterSize_p = (unsigned int *)vio_get_attribute(dev,
VETH_MCAST_FILTER_SIZE, NULL);
@@ -1366,17 +1374,6 @@ static int __devinit ibmveth_probe(struct vio_dev *dev,
 
netif_napi_add(netdev, >napi, ibmveth_poll, 16);
 
-   /*
-* Some older boxes running PHYP non-natively have an OF that returns
-* a 8-byte local-mac-address field (and the first 2 bytes have to be
-* ignored) while newer boxes' OF return a 6-byte field. Note that
-* IEEE 1275 specifies that local-mac-address must be a 6-byte field.
-* The RPA doc specifies that the first byte must be 10b, so we'll
-* just look for it to solve this 8 vs. 6 byte field issue
-*/
-   if ((*mac_addr_p & 0x3) != 0x02)
-   mac_addr_p += 2;
-
adapter->mac_addr = 0;
memcpy(>mac_addr, mac_addr_p, 6);
 
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 087/136 ] autofs - remove autofs dentry mount check

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: David Jeffery 

[ Upstream commit ce8a5dbdf9e709bdaf4618d7ef8cceb91e8adc69 ]

When checking if an autofs mount point is busy it isn't sufficient to
only check if it's a mount point.

For example, if the mount of an offset mountpoint in a tree is denied
for this host by its export and the dentry becomes a process working
directory the check incorrectly returns the mount as not in use at
expire.

This can happen since the default when mounting within a tree is
nostrict, which means ingnore mount fails on mounts within the tree and
continue.  The nostrict option is meant to allow mounting in this case.

Signed-off-by: David Jeffery 
Signed-off-by: Ian Kent 
Cc: sta...@vger.kernel.org
Signed-off-by: Linus Torvalds 
Signed-off-by: Steven Rostedt 
---
 fs/autofs4/expire.c |9 -
 1 file changed, 9 deletions(-)

diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
index 842d000..c7ada0d 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -61,15 +61,6 @@ static int autofs4_mount_busy(struct vfsmount *mnt, struct 
dentry *dentry)
/* This is an autofs submount, we can't expire it */
if (autofs_type_indirect(sbi->type))
goto done;
-
-   /*
-* Otherwise it's an offset mount and we need to check
-* if we can umount its mount, if there is one.
-*/
-   if (!d_mountpoint(path.dentry)) {
-   status = 0;
-   goto done;
-   }
}
 
/* Update the expiry counter if fs is busy */
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 085/136 ] powerpc: Emulate non privileged DSCR read and write

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Anton Blanchard 

[ Upstream commit 73d2fb758e678c93bc76d40876c2359f0729b0ef ]

POWER8 allows read and write of the DSCR in userspace. We added
kernel emulation so applications could always use the instructions
regardless of the CPU type.

Unfortunately there are two SPRs for the DSCR and we only added
emulation for the privileged one. Add code to match the non
privileged one.

A simple test was created to verify the fix:

http://ozlabs.org/~anton/junkcode/user_dscr_test.c

Without the patch we get a SIGILL and it passes with the patch.

Signed-off-by: Anton Blanchard 
Cc: 
Signed-off-by: Benjamin Herrenschmidt 
Signed-off-by: Steven Rostedt 
---
 arch/powerpc/include/asm/ppc-opcode.h |4 
 arch/powerpc/kernel/traps.c   |   10 --
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/ppc-opcode.h 
b/arch/powerpc/include/asm/ppc-opcode.h
index 4c25319..d486ec3 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -111,6 +111,10 @@
 #define PPC_INST_MFSPR_DSCR_MASK   0xfc1f
 #define PPC_INST_MTSPR_DSCR0x7c1103a6
 #define PPC_INST_MTSPR_DSCR_MASK   0xfc1f
+#define PPC_INST_MFSPR_DSCR_USER   0x7c0302a6
+#define PPC_INST_MFSPR_DSCR_USER_MASK  0xfc1f
+#define PPC_INST_MTSPR_DSCR_USER   0x7c0303a6
+#define PPC_INST_MTSPR_DSCR_USER_MASK  0xfc1f
 #define PPC_INST_SLBFEE0x7c0007a7
 
 #define PPC_INST_STRING0x7c00042a
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index ae0843f..3bb7197 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -960,7 +960,10 @@ static int emulate_instruction(struct pt_regs *regs)
 
 #ifdef CONFIG_PPC64
/* Emulate the mfspr rD, DSCR. */
-   if (((instword & PPC_INST_MFSPR_DSCR_MASK) == PPC_INST_MFSPR_DSCR) &&
+   if instword & PPC_INST_MFSPR_DSCR_USER_MASK) ==
+   PPC_INST_MFSPR_DSCR_USER) ||
+((instword & PPC_INST_MFSPR_DSCR_MASK) ==
+   PPC_INST_MFSPR_DSCR)) &&
cpu_has_feature(CPU_FTR_DSCR)) {
PPC_WARN_EMULATED(mfdscr, regs);
rd = (instword >> 21) & 0x1f;
@@ -968,7 +971,10 @@ static int emulate_instruction(struct pt_regs *regs)
return 0;
}
/* Emulate the mtspr DSCR, rD. */
-   if (((instword & PPC_INST_MTSPR_DSCR_MASK) == PPC_INST_MTSPR_DSCR) &&
+   if instword & PPC_INST_MTSPR_DSCR_USER_MASK) ==
+   PPC_INST_MTSPR_DSCR_USER) ||
+((instword & PPC_INST_MTSPR_DSCR_MASK) ==
+   PPC_INST_MTSPR_DSCR)) &&
cpu_has_feature(CPU_FTR_DSCR)) {
PPC_WARN_EMULATED(mtdscr, regs);
rd = (instword >> 21) & 0x1f;
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 084/136 ] mfd: adp5520: Restore mode bits on resume

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Lars-Peter Clausen 

[ Upstream commit c6cc25fda58da8685ecef3f179adc7b99c8253b2 ]

The adp5520 unfortunately also clears the BL_EN bit when the nSTNDBY bit is
cleared. So we need to make sure to restore it during resume if it was set
before suspend.

Cc: sta...@vger.kernel.org
Signed-off-by: Lars-Peter Clausen 
Acked-by: Michael Hennerich 
Signed-off-by: Samuel Ortiz 
Signed-off-by: Steven Rostedt 
---
 drivers/mfd/adp5520.c |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/adp5520.c b/drivers/mfd/adp5520.c
index ea8b947..7e41d54 100644
--- a/drivers/mfd/adp5520.c
+++ b/drivers/mfd/adp5520.c
@@ -36,6 +36,7 @@ struct adp5520_chip {
struct blocking_notifier_head notifier_list;
int irq;
unsigned long id;
+   uint8_t mode;
 };
 
 static int __adp5520_read(struct i2c_client *client,
@@ -326,7 +327,10 @@ static int adp5520_suspend(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct adp5520_chip *chip = dev_get_drvdata(>dev);
 
-   adp5520_clr_bits(chip->dev, ADP5520_MODE_STATUS, ADP5520_nSTNBY);
+   adp5520_read(chip->dev, ADP5520_MODE_STATUS, >mode);
+   /* All other bits are W1C */
+   chip->mode &= ADP5520_BL_EN | ADP5520_DIM_EN | ADP5520_nSTNBY;
+   adp5520_write(chip->dev, ADP5520_MODE_STATUS, 0);
return 0;
 }
 
@@ -335,7 +339,7 @@ static int adp5520_resume(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct adp5520_chip *chip = dev_get_drvdata(>dev);
 
-   adp5520_set_bits(chip->dev, ADP5520_MODE_STATUS, ADP5520_nSTNBY);
+   adp5520_write(chip->dev, ADP5520_MODE_STATUS, chip->mode);
return 0;
 }
 #endif
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 083/136 ] mmc: atmel-mci: pio hang on block errors

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Terry Barnaby 

[ Upstream commit bdbc5d0c60f3e9de3eeccf1c1a18bdc11dca62cc ]

The driver is doing, by default, multi-block reads. When a block error
occurs, card/block.c instigates a single block read: "mmcblk0: retrying
using single block read".  It leaves the sg chain intact and just changes
the length attribute for the first sg entry and the overall sg_len
parameter.  When atmci_read_data_pio is called to read the single block
of data it ignores the sg_len and expects to read more than 512 bytes as
it sees there are multiple items in the sg list. No more data comes as
the controller has only been commanded to get one block.

Signed-off-by: Terry Barnaby 
Acked-by: Ludovic Desroches 
Cc: stable  # 3.2+
Signed-off-by: Chris Ball 
Signed-off-by: Steven Rostedt 
---
 drivers/mmc/host/atmel-mci.c |   14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 79d0095..8e8afe4 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -175,6 +175,7 @@ struct atmel_mci {
void __iomem*regs;
 
struct scatterlist  *sg;
+   unsigned intsg_len;
unsigned intpio_offset;
unsigned int*buffer;
unsigned intbuf_size;
@@ -825,6 +826,7 @@ static u32 atmci_prepare_data(struct atmel_mci *host, 
struct mmc_data *data)
data->error = -EINPROGRESS;
 
host->sg = data->sg;
+   host->sg_len = data->sg_len;
host->data = data;
host->data_chan = NULL;
 
@@ -1757,7 +1759,8 @@ static void atmci_read_data_pio(struct atmel_mci *host)
if (offset == sg->length) {
flush_dcache_page(sg_page(sg));
host->sg = sg = sg_next(sg);
-   if (!sg)
+   host->sg_len--;
+   if (!sg || !host->sg_len)
goto done;
 
offset = 0;
@@ -1770,7 +1773,8 @@ static void atmci_read_data_pio(struct atmel_mci *host)
 
flush_dcache_page(sg_page(sg));
host->sg = sg = sg_next(sg);
-   if (!sg)
+   host->sg_len--;
+   if (!sg || !host->sg_len)
goto done;
 
offset = 4 - remaining;
@@ -1821,7 +1825,8 @@ static void atmci_write_data_pio(struct atmel_mci *host)
nbytes += 4;
if (offset == sg->length) {
host->sg = sg = sg_next(sg);
-   if (!sg)
+   host->sg_len--;
+   if (!sg || !host->sg_len)
goto done;
 
offset = 0;
@@ -1835,7 +1840,8 @@ static void atmci_write_data_pio(struct atmel_mci *host)
nbytes += remaining;
 
host->sg = sg = sg_next(sg);
-   if (!sg) {
+   host->sg_len--;
+   if (!sg || !host->sg_len) {
atmci_writel(host, ATMCI_TDR, value);
goto done;
}
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 082/136 ] mmc: core: Fix bit width test failing on old eMMC cards

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Philip Rakity 

[ Upstream commit 836dc2fe89c968c10cada87e0dfae6626f8f9da3 ]

PARTITION_SUPPORT needs to be set before doing the compare on version
number so the bit width test does not get invalid data.  Before this
patch, a Sandisk iNAND eMMC card would detect 1-bit width although
the hardware supports 4-bit.

Only affects old emmc devices - pre 4.4 devices.

Reported-by: Elad Yi 
Signed-off-by: Philip Rakity 
Cc: stable 
Signed-off-by: Chris Ball 
Signed-off-by: Steven Rostedt 
---
 drivers/mmc/core/mmc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 396b258..246750e 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -368,13 +368,13 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 
*ext_csd)
ext_csd[EXT_CSD_SEC_FEATURE_SUPPORT];
card->ext_csd.raw_trim_mult =
ext_csd[EXT_CSD_TRIM_MULT];
+   card->ext_csd.raw_partition_support = 
ext_csd[EXT_CSD_PARTITION_SUPPORT];
if (card->ext_csd.rev >= 4) {
/*
 * Enhanced area feature support -- check whether the eMMC
 * card has the Enhanced area enabled.  If so, export enhanced
 * area offset and size to user by adding sysfs interface.
 */
-   card->ext_csd.raw_partition_support = 
ext_csd[EXT_CSD_PARTITION_SUPPORT];
if ((ext_csd[EXT_CSD_PARTITION_SUPPORT] & 0x2) &&
(ext_csd[EXT_CSD_PARTITION_ATTRIBUTE] & 0x1)) {
hc_erase_grp_sz =
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 080/136 ] KVM: X86 emulator: fix source operand decoding for 8bit mov[zs]x instructions

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Gleb Natapov 

[ Upstream commit 660696d1d16a71e15549ce1bf74953be1592bcd3 ]

Source operand for one byte mov[zs]x is decoded incorrectly if it is in
high byte register. Fix that.

Cc: sta...@vger.kernel.org
Signed-off-by: Gleb Natapov 
Signed-off-by: Steven Rostedt 
---
 arch/x86/kvm/emulate.c |4 
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index a3b57a2..2386209 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -3970,6 +3970,10 @@ static int decode_operand(struct x86_emulate_ctxt *ctxt, 
struct operand *op,
break;
case OpMem8:
ctxt->memop.bytes = 1;
+   if (ctxt->memop.type == OP_REG) {
+   ctxt->memop.addr.reg = decode_register(ctxt, 
ctxt->modrm_rm, 1);
+   fetch_register_operand(>memop);
+   }
goto mem_common;
case OpMem16:
ctxt->memop.bytes = 2;
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 110/136 ] drm/i915: Fix detection of base of stolen memory

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Chris Wilson 

[ Upstream commit e12a2d53ae45a69aea499b64f75e7222cca0f12f ]

The routine to query the base of stolen memory was using the wrong
registers and the wrong encodings on virtually every platform.

It was not until the G33 refresh, that a PCI config register was
introduced that explicitly said where the stolen memory was. Prior to
865G there was not even a register that said where the end of usable
low memory was and where the stolen memory began (or ended depending
upon chipset). Before then, one has to look at the BIOS memory maps to
find the Top of Memory. Alas that is not exported by arch/x86 and so we
have to resort to disabling stolen memory on gen2 for the time being.

Then SandyBridge enlarged the PCI register to a full 32-bits and change
the encoding of the address, so even though we happened to be querying
the right register, we read the wrong bits and ended up using address 0
for our stolen data, i.e. notably FBC.

Signed-off-by: Chris Wilson 
Signed-off-by: Daniel Vetter 
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/i915/i915_drv.h|1 +
 drivers/gpu/drm/i915/i915_gem_stolen.c |   81 
 2 files changed, 42 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 627fe35..ae85929 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -672,6 +672,7 @@ typedef struct drm_i915_private {
unsigned long gtt_start;
unsigned long gtt_mappable_end;
unsigned long gtt_end;
+   unsigned long stolen_base; /* limited to low memory (32-bit) */
 
struct io_mapping *gtt_mapping;
phys_addr_t gtt_base_addr;
diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c 
b/drivers/gpu/drm/i915/i915_gem_stolen.c
index ada2e90..d023ed6 100644
--- a/drivers/gpu/drm/i915/i915_gem_stolen.c
+++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
@@ -43,56 +43,50 @@
  * for is a boon.
  */
 
-#define PTE_ADDRESS_MASK   0xf000
-#define PTE_ADDRESS_MASK_HIGH  0x00f0 /* i915+ */
-#define PTE_MAPPING_TYPE_UNCACHED  (0 << 1)
-#define PTE_MAPPING_TYPE_DCACHE(1 << 1) /* i830 only */
-#define PTE_MAPPING_TYPE_CACHED(3 << 1)
-#define PTE_MAPPING_TYPE_MASK  (3 << 1)
-#define PTE_VALID  (1 << 0)
-
-/**
- * i915_stolen_to_phys - take an offset into stolen memory and turn it into
- *   a physical one
- * @dev: drm device
- * @offset: address to translate
- *
- * Some chip functions require allocations from stolen space and need the
- * physical address of the memory in question.
- */
-static unsigned long i915_stolen_to_phys(struct drm_device *dev, u32 offset)
+static unsigned long i915_stolen_to_physical(struct drm_device *dev)
 {
struct drm_i915_private *dev_priv = dev->dev_private;
struct pci_dev *pdev = dev_priv->bridge_dev;
u32 base;
 
-#if 0
/* On the machines I have tested the Graphics Base of Stolen Memory
-* is unreliable, so compute the base by subtracting the stolen memory
-* from the Top of Low Usable DRAM which is where the BIOS places
-* the graphics stolen memory.
+* is unreliable, so on those compute the base by subtracting the
+* stolen memory from the Top of Low Usable DRAM which is where the
+* BIOS places the graphics stolen memory.
+*
+* On gen2, the layout is slightly different with the Graphics Segment
+* immediately following Top of Memory (or Top of Usable DRAM). Note
+* it appears that TOUD is only reported by 865g, so we just use the
+* top of memory as determined by the e820 probe.
+*
+* XXX gen2 requires an unavailable symbol and 945gm fails with
+* its value of TOLUD.
 */
-   if (INTEL_INFO(dev)->gen > 3 || IS_G33(dev)) {
-   /* top 32bits are reserved = 0 */
+   base = 0;
+   if (INTEL_INFO(dev)->gen >= 6) {
+   /* Read Base Data of Stolen Memory Register (BDSM) directly.
+* Note that there is also a MCHBAR miror at 0x1080c0 or
+* we could use device 2:0x5c instead.
+   */
+   pci_read_config_dword(pdev, 0xB0, );
+   base &= ~4095; /* lower bits used for locking register */
+   } else if (INTEL_INFO(dev)->gen > 3 || IS_G33(dev)) {
+   /* Read Graphics Base of Stolen Memory directly */
pci_read_config_dword(pdev, 0xA4, );
-   } else {
-   /* XXX presume 8xx is the same as i915 */
-   pci_bus_read_config_dword(pdev->bus, 2, 0x5C, );
-   }
-#else
-   if (INTEL_INFO(dev)->gen > 3 || IS_G33(dev)) {
-   u16 val;
-   

[ 109/136 ] drm/ast: deal with bo reserve fail in dirty update path

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Dave Airlie 

[ Upstream commit 306373b645d80625335b8e684fa09b14ba460cec ]

Port over the mgag200 fix to ast as it suffers the same issue.

On F19 testing, it was noticed we get a lot of errors in dmesg
about being unable to reserve the buffer when plymouth starts,
this is due to the buffer being in the process of migrating,
so it makes sense we can't reserve it.

In order to deal with it, this adds delayed updates for the dirty
updates, when the bo is unreservable, in the normal console case
this shouldn't ever happen, its just when plymouth or X is
pushing the console bo to system memory.

Cc: sta...@vger.kernel.org
Signed-off-by: Dave Airlie 
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/ast/ast_drv.h |2 ++
 drivers/gpu/drm/ast/ast_fb.c  |   43 ++---
 drivers/gpu/drm/ast/ast_ttm.c |2 +-
 3 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index d4af9ed..85a6eeb 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -240,6 +240,8 @@ struct ast_fbdev {
void *sysram;
int size;
struct ttm_bo_kmap_obj mapping;
+   int x1, y1, x2, y2; /* dirty rect */
+   spinlock_t dirty_lock;
 };
 
 #define to_ast_crtc(x) container_of(x, struct ast_crtc, base)
diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c
index 2fc8e9e..853f831 100644
--- a/drivers/gpu/drm/ast/ast_fb.c
+++ b/drivers/gpu/drm/ast/ast_fb.c
@@ -53,16 +53,52 @@ static void ast_dirty_update(struct ast_fbdev *afbdev,
int bpp = (afbdev->afb.base.bits_per_pixel + 7)/8;
int ret;
bool unmap = false;
+   bool store_for_later = false;
+   int x2, y2;
+   unsigned long flags;
 
obj = afbdev->afb.obj;
bo = gem_to_ast_bo(obj);
 
+   /*
+* try and reserve the BO, if we fail with busy
+* then the BO is being moved and we should
+* store up the damage until later.
+*/
ret = ast_bo_reserve(bo, true);
if (ret) {
-   DRM_ERROR("failed to reserve fb bo\n");
+   if (ret != -EBUSY)
+   return;
+
+   store_for_later = true;
+   }
+
+   x2 = x + width - 1;
+   y2 = y + height - 1;
+   spin_lock_irqsave(>dirty_lock, flags);
+
+   if (afbdev->y1 < y)
+   y = afbdev->y1;
+   if (afbdev->y2 > y2)
+   y2 = afbdev->y2;
+   if (afbdev->x1 < x)
+   x = afbdev->x1;
+   if (afbdev->x2 > x2)
+   x2 = afbdev->x2;
+
+   if (store_for_later) {
+   afbdev->x1 = x;
+   afbdev->x2 = x2;
+   afbdev->y1 = y;
+   afbdev->y2 = y2;
+   spin_unlock_irqrestore(>dirty_lock, flags);
return;
}
 
+   afbdev->x1 = afbdev->y1 = INT_MAX;
+   afbdev->x2 = afbdev->y2 = 0;
+   spin_unlock_irqrestore(>dirty_lock, flags);
+
if (!bo->kmap.virtual) {
ret = ttm_bo_kmap(>bo, 0, bo->bo.num_pages, >kmap);
if (ret) {
@@ -72,10 +108,10 @@ static void ast_dirty_update(struct ast_fbdev *afbdev,
}
unmap = true;
}
-   for (i = y; i < y + height; i++) {
+   for (i = y; i <= y2; i++) {
/* assume equal stride for now */
src_offset = dst_offset = i * afbdev->afb.base.pitches[0] + (x 
* bpp);
-   memcpy_toio(bo->kmap.virtual + src_offset, afbdev->sysram + 
src_offset, width * bpp);
+   memcpy_toio(bo->kmap.virtual + src_offset, afbdev->sysram + 
src_offset, (x2 - x + 1) * bpp);
 
}
if (unmap)
@@ -306,6 +342,7 @@ int ast_fbdev_init(struct drm_device *dev)
 
ast->fbdev = afbdev;
afbdev->helper.funcs = _fb_helper_funcs;
+   spin_lock_init(>dirty_lock);
ret = drm_fb_helper_init(dev, >helper,
 1, 1);
if (ret) {
diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c
index 6cf2ade..2a6027c 100644
--- a/drivers/gpu/drm/ast/ast_ttm.c
+++ b/drivers/gpu/drm/ast/ast_ttm.c
@@ -316,7 +316,7 @@ int ast_bo_reserve(struct ast_bo *bo, bool no_wait)
 
ret = ttm_bo_reserve(>bo, true, no_wait, false, 0);
if (ret) {
-   if (ret != -ERESTARTSYS)
+   if (ret != -ERESTARTSYS && ret != -EBUSY)
DRM_ERROR("reserve failed %p\n", bo);
return ret;
}
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 135/136 ] x86/mm: account for PGDIR_SIZE alignment

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Jerry Hoemann 

Patch for -stable.  Function find_early_table_space removed upstream.

Fixes panic in alloc_low_page due to pgt_buf overflow during
init_memory_mapping.

find_early_table_space sizes pgt_buf based upon the size of the
memory being mapped, but it does not take into account the alignment
of the memory.  When the region being mapped spans a 512GB (PGDIR_SIZE)
alignment, a panic from alloc_low_pages occurs.

kernel_physical_mapping_init takes into account PGDIR_SIZE alignment.
This causes an extra call to alloc_low_page to be made.  This extra call
isn't accounted for by find_early_table_space and causes a kernel panic.

Change is to take into account PGDIR_SIZE alignment in find_early_table_space.

Signed-off-by: Jerry Hoemann 
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Steven Rostedt 
---
 arch/x86/mm/init.c |5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index d7aea41..7d7a36d 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -45,11 +45,15 @@ static void __init find_early_table_space(struct map_range 
*mr, int nr_range)
int i;
unsigned long puds = 0, pmds = 0, ptes = 0, tables;
unsigned long start = 0, good_end;
+   unsigned long pgd_extra = 0;
phys_addr_t base;
 
for (i = 0; i < nr_range; i++) {
unsigned long range, extra;
 
+   if ((mr[i].end >> PGDIR_SHIFT) - (mr[i].start >> PGDIR_SHIFT))
+   pgd_extra++;
+
range = mr[i].end - mr[i].start;
puds += (range + PUD_SIZE - 1) >> PUD_SHIFT;
 
@@ -74,6 +78,7 @@ static void __init find_early_table_space(struct map_range 
*mr, int nr_range)
tables = roundup(puds * sizeof(pud_t), PAGE_SIZE);
tables += roundup(pmds * sizeof(pmd_t), PAGE_SIZE);
tables += roundup(ptes * sizeof(pte_t), PAGE_SIZE);
+   tables += (pgd_extra * PAGE_SIZE);
 
 #ifdef CONFIG_X86_32
/* for fixmap */
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 118/136 ] drm/radeon/dce6: add missing display reg for tiling setup

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Alex Deucher 

[ Upstream commit 7c1c7c18fc752b2a1d07597286467ef186312463 ]

A new tiling config register for the display blocks was
added on DCE6.

May fix:
https://bugs.freedesktop.org/show_bug.cgi?id=62889
https://bugs.freedesktop.org/show_bug.cgi?id=57919

Signed-off-by: Alex Deucher 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 drivers/gpu/drm/radeon/ni.c  |2 ++
 drivers/gpu/drm/radeon/nid.h |4 
 drivers/gpu/drm/radeon/si.c  |1 +
 drivers/gpu/drm/radeon/sid.h |2 ++
 4 files changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index eecf30f..338b71f 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -619,6 +619,8 @@ static void cayman_gpu_init(struct radeon_device *rdev)
 
WREG32(GB_ADDR_CONFIG, gb_addr_config);
WREG32(DMIF_ADDR_CONFIG, gb_addr_config);
+   if (ASIC_IS_DCE6(rdev))
+   WREG32(DMIF_ADDR_CALC, gb_addr_config);
WREG32(HDP_ADDR_CONFIG, gb_addr_config);
 
tmp = gb_addr_config & NUM_PIPES_MASK;
diff --git a/drivers/gpu/drm/radeon/nid.h b/drivers/gpu/drm/radeon/nid.h
index 870db34..e17d4dd 100644
--- a/drivers/gpu/drm/radeon/nid.h
+++ b/drivers/gpu/drm/radeon/nid.h
@@ -45,6 +45,10 @@
 #define ARUBA_GB_ADDR_CONFIG_GOLDEN0x12010001
 
 #define DMIF_ADDR_CONFIG   0xBD4
+
+/* DCE6 only */
+#define DMIF_ADDR_CALC 0xC00
+
 #defineSRBM_GFX_CNTL   0x0E44
 #defineRINGID(x)   (((x) & 
0x3) << 0)
 #defineVMID(x) (((x) & 
0x7) << 0)
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index 6ab4a90..992e60c 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -1659,6 +1659,7 @@ static void si_gpu_init(struct radeon_device *rdev)
 
WREG32(GB_ADDR_CONFIG, gb_addr_config);
WREG32(DMIF_ADDR_CONFIG, gb_addr_config);
+   WREG32(DMIF_ADDR_CALC, gb_addr_config);
WREG32(HDP_ADDR_CONFIG, gb_addr_config);
 
si_tiling_mode_table_init(rdev);
diff --git a/drivers/gpu/drm/radeon/sid.h b/drivers/gpu/drm/radeon/sid.h
index 6f0083a..778b7de 100644
--- a/drivers/gpu/drm/radeon/sid.h
+++ b/drivers/gpu/drm/radeon/sid.h
@@ -60,6 +60,8 @@
 
 #define DMIF_ADDR_CONFIG   0xBD4
 
+#define DMIF_ADDR_CALC 0xC00
+
 #defineSRBM_STATUS 0xE50
 
 #defineCC_SYS_RB_BACKEND_DISABLE   0xe80
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 081/136 ] x86: Eliminate irq_mis_count counted in arch_irq_stat

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Li Fei 

[ Upstream commit f7b0e1055574ce06ab53391263b4e205bf38daf3 ]

With the current implementation, kstat_cpu(cpu).irqs_sum is also
increased in case of irq_mis_count increment.

So there is no need to count irq_mis_count in arch_irq_stat,
otherwise irq_mis_count will be counted twice in the sum of
/proc/stat.

Reported-by: Liu Chuansheng 
Signed-off-by: Li Fei 
Acked-by: Liu Chuansheng 
Cc: tomoki.sekiyama...@hitachi.com
Cc: j...@perches.com
Link: 
http://lkml.kernel.org/r/1366980611.32469.7.camel@fli24-HP-Compaq-8100-Elite-CMT-PC
Cc: 
Signed-off-by: Ingo Molnar 
Signed-off-by: Steven Rostedt 
---
 arch/x86/kernel/irq.c |4 
 1 file changed, 4 deletions(-)

diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
index d44f782..e62cf16 100644
--- a/arch/x86/kernel/irq.c
+++ b/arch/x86/kernel/irq.c
@@ -165,10 +165,6 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
 u64 arch_irq_stat(void)
 {
u64 sum = atomic_read(_err_count);
-
-#ifdef CONFIG_X86_IO_APIC
-   sum += atomic_read(_mis_count);
-#endif
return sum;
 }
 
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 078/136 ] ext4: fix Kconfig documentation for CONFIG_EXT4_DEBUG

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Theodore Ts'o 

[ Upstream commit 7f3e3c7cfcec148ccca9c0dd2dbfd7b00b7ac10f ]

Fox the Kconfig documentation for CONFIG_EXT4_DEBUG to match the
change made by commit a0b30c1229: ext4: use module parameters instead
of debugfs for mballoc_debug

Signed-off-by: "Theodore Ts'o" 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 fs/ext4/Kconfig |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/Kconfig b/fs/ext4/Kconfig
index c22f170..e38370b 100644
--- a/fs/ext4/Kconfig
+++ b/fs/ext4/Kconfig
@@ -84,4 +84,5 @@ config EXT4_DEBUG
  Enables run-time debugging support for the ext4 filesystem.
 
  If you select Y here, then you will be able to turn on debugging
- with a command such as "echo 1 > /sys/kernel/debug/ext4/mballoc-debug"
+ with a command such as:
+   echo 1 > /sys/module/ext4/parameters/mballoc_debug
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 079/136 ] mmc: at91/avr32/atmel-mci: fix DMA-channel leak on module unload

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Johan Hovold 

[ Upstream commit 91cf54feecf815bec0b6a8d6d9dbd0e219f2f2cc ]

Fix regression introduced by commit 796211b7953 ("mmc: atmel-mci: add
pdc support and runtime capabilities detection") which removed the need
for CONFIG_MMC_ATMELMCI_DMA but kept the Kconfig-entry as well as the
compile guards around dma_release_channel() in remove(). Consequently,
DMA is always enabled (if supported), but the DMA-channel is not
released on module unload unless the DMA-config option is selected.

Remove the no longer used CONFIG_MMC_ATMELMCI_DMA option completely.

Signed-off-by: Johan Hovold 
Acked-by: Ludovic Desroches 
Cc: stable 
Signed-off-by: Chris Ball 
Signed-off-by: Steven Rostedt 
---
 arch/arm/configs/at91sam9g45_defconfig |1 -
 arch/avr32/configs/favr-32_defconfig   |1 -
 arch/avr32/configs/merisc_defconfig|1 -
 drivers/mmc/host/Kconfig   |   10 --
 drivers/mmc/host/atmel-mci.c   |2 --
 5 files changed, 15 deletions(-)

diff --git a/arch/arm/configs/at91sam9g45_defconfig 
b/arch/arm/configs/at91sam9g45_defconfig
index 606d48f..8aab786 100644
--- a/arch/arm/configs/at91sam9g45_defconfig
+++ b/arch/arm/configs/at91sam9g45_defconfig
@@ -173,7 +173,6 @@ CONFIG_MMC=y
 # CONFIG_MMC_BLOCK_BOUNCE is not set
 CONFIG_SDIO_UART=m
 CONFIG_MMC_ATMELMCI=y
-CONFIG_MMC_ATMELMCI_DMA=y
 CONFIG_LEDS_ATMEL_PWM=y
 CONFIG_LEDS_GPIO=y
 CONFIG_LEDS_TRIGGER_TIMER=y
diff --git a/arch/avr32/configs/favr-32_defconfig 
b/arch/avr32/configs/favr-32_defconfig
index 19973b0..59e4cc9 100644
--- a/arch/avr32/configs/favr-32_defconfig
+++ b/arch/avr32/configs/favr-32_defconfig
@@ -122,7 +122,6 @@ CONFIG_USB_G_SERIAL=m
 CONFIG_USB_CDC_COMPOSITE=m
 CONFIG_MMC=y
 CONFIG_MMC_ATMELMCI=y
-CONFIG_MMC_ATMELMCI_DMA=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
 CONFIG_LEDS_ATMEL_PWM=m
diff --git a/arch/avr32/configs/merisc_defconfig 
b/arch/avr32/configs/merisc_defconfig
index 3befab9..65de443 100644
--- a/arch/avr32/configs/merisc_defconfig
+++ b/arch/avr32/configs/merisc_defconfig
@@ -102,7 +102,6 @@ CONFIG_FRAMEBUFFER_CONSOLE=y
 CONFIG_LOGO=y
 CONFIG_MMC=y
 CONFIG_MMC_ATMELMCI=y
-CONFIG_MMC_ATMELMCI_DMA=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
 CONFIG_LEDS_ATMEL_PWM=y
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index aa131b3..1449469 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -300,16 +300,6 @@ config MMC_ATMELMCI
 
 endchoice
 
-config MMC_ATMELMCI_DMA
-   bool "Atmel MCI DMA support"
-   depends on MMC_ATMELMCI && (AVR32 || ARCH_AT91SAM9G45) && DMA_ENGINE
-   help
- Say Y here to have the Atmel MCI driver use a DMA engine to
- do data transfers and thus increase the throughput and
- reduce the CPU utilization.
-
- If unsure, say N.
-
 config MMC_MSM
tristate "Qualcomm SDCC Controller Support"
depends on MMC && ARCH_MSM
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index a53c7c4..79d0095 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -2407,10 +2407,8 @@ static int __exit atmci_remove(struct platform_device 
*pdev)
atmci_readl(host, ATMCI_SR);
clk_disable(host->mck);
 
-#ifdef CONFIG_MMC_ATMELMCI_DMA
if (host->dma.chan)
dma_release_channel(host->dma.chan);
-#endif
 
free_irq(platform_get_irq(pdev, 0), host);
iounmap(host->regs);
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 077/136 ] ext4: fix online resizing for ext3-compat file systems

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Theodore Ts'o 

[ Upstream commit c5c72d814cf0f650010337c73638b25e6d14d2d4 ]

Commit fb0a387dcdc restricts block allocations for indirect-mapped
files to block groups less than s_blockfile_groups.  However, the
online resizing code wasn't setting s_blockfile_groups, so the newly
added block groups were not available for non-extent mapped files.

Reported-by: Eric Sandeen 
Signed-off-by: "Theodore Ts'o" 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 fs/ext4/resize.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 82e1fde3..14de511 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1255,6 +1255,8 @@ static void ext4_update_super(struct super_block *sb,
 
/* Update the global fs size fields */
sbi->s_groups_count += flex_gd->count;
+   sbi->s_blockfile_groups = min_t(ext4_group_t, sbi->s_groups_count,
+   (EXT4_MAX_BLOCK_FILE_PHYS / EXT4_BLOCKS_PER_GROUP(sb)));
 
/* Update the reserved block counts only once the new group is
 * active. */
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 076/136 ] ext4: fix big-endian bug in metadata checksum calculations

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Dmitry Monakhov 

[ Upstream commit 171a7f21a76a0958c225b97c00a97a10390d40ee ]

Signed-off-by: Dmitry Monakhov 
Signed-off-by: "Theodore Ts'o" 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 fs/ext4/inode.c |8 
 fs/ext4/mmp.c   |2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 0113b16..72c9d8d 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -55,21 +55,21 @@ static __u32 ext4_inode_csum(struct inode *inode, struct 
ext4_inode *raw,
__u16 csum_hi = 0;
__u32 csum;
 
-   csum_lo = raw->i_checksum_lo;
+   csum_lo = le16_to_cpu(raw->i_checksum_lo);
raw->i_checksum_lo = 0;
if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE &&
EXT4_FITS_IN_INODE(raw, ei, i_checksum_hi)) {
-   csum_hi = raw->i_checksum_hi;
+   csum_hi = le16_to_cpu(raw->i_checksum_hi);
raw->i_checksum_hi = 0;
}
 
csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)raw,
   EXT4_INODE_SIZE(inode->i_sb));
 
-   raw->i_checksum_lo = csum_lo;
+   raw->i_checksum_lo = cpu_to_le16(csum_lo);
if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE &&
EXT4_FITS_IN_INODE(raw, ei, i_checksum_hi))
-   raw->i_checksum_hi = csum_hi;
+   raw->i_checksum_hi = cpu_to_le16(csum_hi);
 
return csum;
 }
diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
index fe7c63f..b96e6b05 100644
--- a/fs/ext4/mmp.c
+++ b/fs/ext4/mmp.c
@@ -7,7 +7,7 @@
 #include "ext4.h"
 
 /* Checksumming functions */
-static __u32 ext4_mmp_csum(struct super_block *sb, struct mmp_struct *mmp)
+static __le32 ext4_mmp_csum(struct super_block *sb, struct mmp_struct *mmp)
 {
struct ext4_sb_info *sbi = EXT4_SB(sb);
int offset = offsetof(struct mmp_struct, mmp_checksum);
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 075/136 ] ext4: fix journal callback list traversal

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Dmitry Monakhov 

[ Upstream commit 5d3ee20855e28169d711b394857ee608a5023094 ]

It is incorrect to use list_for_each_entry_safe() for journal callback
traversial because ->next may be removed by other task:
->ext4_mb_free_metadata()
  ->ext4_mb_free_metadata()
->ext4_journal_callback_del()

This results in the following issue:

WARNING: at lib/list_debug.c:62 __list_del_entry+0x1c0/0x250()
Hardware name:
list_del corruption. prev->next should be 88019a4ec198, but was 
6b6b6b6b6b6b6b6b
Modules linked in: cpufreq_ondemand acpi_cpufreq freq_table mperf coretemp 
kvm_intel kvm crc32c_intel ghash_clmulni_intel microcode sg xhci_hcd button 
sd_mod crc_t10dif aesni_intel ablk_helper cryptd lrw aes_x86_64 xts gf128mul 
ahci libahci pata_acpi ata_generic dm_mirror dm_region_hash dm_log dm_mod
Pid: 16400, comm: jbd2/dm-1-8 Tainted: GW3.8.0-rc3+ #107
Call Trace:
 [] warn_slowpath_common+0xad/0xf0
 [] warn_slowpath_fmt+0x46/0x50
 [] ? ext4_journal_commit_callback+0x99/0xc0
 [] __list_del_entry+0x1c0/0x250
 [] ext4_journal_commit_callback+0x6f/0xc0
 [] jbd2_journal_commit_transaction+0x23a6/0x2570
 [] ? try_to_del_timer_sync+0x82/0xa0
 [] ? del_timer_sync+0x91/0x1e0
 [] kjournald2+0x19f/0x6a0
 [] ? wake_up_bit+0x40/0x40
 [] ? bit_spin_lock+0x80/0x80
 [] kthread+0x10e/0x120
 [] ? __init_kthread_worker+0x70/0x70
 [] ret_from_fork+0x7c/0xb0
 [] ? __init_kthread_worker+0x70/0x70

This patch fix the issue as follows:
- ext4_journal_commit_callback() make list truly traversial safe
  simply by always starting from list_head
- fix race between two ext4_journal_callback_del() and
  ext4_journal_callback_try_del()

Signed-off-by: Dmitry Monakhov 
Signed-off-by: "Theodore Ts'o" 
Reviewed-by: Jan Kara 
Cc: sta...@vger.kernel.com
Signed-off-by: Steven Rostedt 
---
 fs/ext4/ext4_jbd2.h |6 +-
 fs/ext4/mballoc.c   |8 
 fs/ext4/super.c |7 +--
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h
index 56d258c..1a27af3 100644
--- a/fs/ext4/ext4_jbd2.h
+++ b/fs/ext4/ext4_jbd2.h
@@ -170,16 +170,20 @@ static inline void ext4_journal_callback_add(handle_t 
*handle,
  * ext4_journal_callback_del: delete a registered callback
  * @handle: active journal transaction handle on which callback was registered
  * @jce: registered journal callback entry to unregister
+ * Return true if object was sucessfully removed
  */
-static inline void ext4_journal_callback_del(handle_t *handle,
+static inline bool ext4_journal_callback_try_del(handle_t *handle,
 struct ext4_journal_cb_entry *jce)
 {
+   bool deleted;
struct ext4_sb_info *sbi =
EXT4_SB(handle->h_transaction->t_journal->j_private);
 
spin_lock(>s_md_lock);
+   deleted = !list_empty(>jce_list);
list_del_init(>jce_list);
spin_unlock(>s_md_lock);
+   return deleted;
 }
 
 int
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 87b5519..773d341 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4438,11 +4438,11 @@ ext4_mb_free_metadata(handle_t *handle, struct 
ext4_buddy *e4b,
node = rb_prev(new_node);
if (node) {
entry = rb_entry(node, struct ext4_free_data, efd_node);
-   if (can_merge(entry, new_entry)) {
+   if (can_merge(entry, new_entry) &&
+   ext4_journal_callback_try_del(handle, >efd_jce)) {
new_entry->efd_start_cluster = entry->efd_start_cluster;
new_entry->efd_count += entry->efd_count;
rb_erase(node, &(db->bb_free_root));
-   ext4_journal_callback_del(handle, >efd_jce);
kmem_cache_free(ext4_free_data_cachep, entry);
}
}
@@ -4450,10 +4450,10 @@ ext4_mb_free_metadata(handle_t *handle, struct 
ext4_buddy *e4b,
node = rb_next(new_node);
if (node) {
entry = rb_entry(node, struct ext4_free_data, efd_node);
-   if (can_merge(new_entry, entry)) {
+   if (can_merge(new_entry, entry) &&
+   ext4_journal_callback_try_del(handle, >efd_jce)) {
new_entry->efd_count += entry->efd_count;
rb_erase(node, &(db->bb_free_root));
-   ext4_journal_callback_del(handle, >efd_jce);
kmem_cache_free(ext4_free_data_cachep, entry);
}
}
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index f581886..f9b129c 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -452,10 +452,13 @@ static void ext4_journal_commit_callback(journal_t 
*journal, transaction_t *txn)
struct super_block  *sb = journal->j_private;
struct ext4_sb_info *sbi = EXT4_SB(sb);

[ 074/136 ] jbd2: fix race between jbd2_journal_remove_checkpoint and ->j_commit_callback

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Dmitry Monakhov 

[ Upstream commit 794446c6946513c684d448205fbd76fa35f38b72 ]

The following race is possible:

[kjournald2]  other_task
jbd2_journal_commit_transaction()
  j_state = T_FINISHED;
  spin_unlock(>j_list_lock);
 ->jbd2_journal_remove_checkpoint()
   ->jbd2_journal_free_transaction();
 ->kmem_cache_free(transaction)
  ->j_commit_callback(journal, transaction);
-> USE_AFTER_FREE

WARNING: at lib/list_debug.c:62 __list_del_entry+0x1c0/0x250()
Hardware name:
list_del corruption. prev->next should be 88019a4ec198, but was 
6b6b6b6b6b6b6b6b
Modules linked in: cpufreq_ondemand acpi_cpufreq freq_table mperf coretemp 
kvm_intel kvm crc32c_intel ghash_clmulni_intel microcode sg xhci_hcd button 
sd_mod crc_t10dif aesni_intel ablk_helper cryptd lrw aes_x86_64 xts gf128mul 
ahci libahci pata_acpi ata_generic dm_mirror dm_region_hash dm_log dm_mod
Pid: 16400, comm: jbd2/dm-1-8 Tainted: GW3.8.0-rc3+ #107
Call Trace:
 [] warn_slowpath_common+0xad/0xf0
 [] warn_slowpath_fmt+0x46/0x50
 [] ? ext4_journal_commit_callback+0x99/0xc0
 [] __list_del_entry+0x1c0/0x250
 [] ext4_journal_commit_callback+0x6f/0xc0
 [] jbd2_journal_commit_transaction+0x23a6/0x2570
 [] ? try_to_del_timer_sync+0x82/0xa0
 [] ? del_timer_sync+0x91/0x1e0
 [] kjournald2+0x19f/0x6a0
 [] ? wake_up_bit+0x40/0x40
 [] ? bit_spin_lock+0x80/0x80
 [] kthread+0x10e/0x120
 [] ? __init_kthread_worker+0x70/0x70
 [] ret_from_fork+0x7c/0xb0
 [] ? __init_kthread_worker+0x70/0x70

In order to demonstrace this issue one should mount ext4 with mount -o
discard option on SSD disk.  This makes callback longer and race
window becomes wider.

In order to fix this we should mark transaction as finished only after
callbacks have completed

Signed-off-by: Dmitry Monakhov 
Signed-off-by: "Theodore Ts'o" 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 fs/jbd2/commit.c |   50 --
 include/linux/jbd2.h |1 +
 2 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index af5280f..aa608d9 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -382,7 +382,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
int space_left = 0;
int first_tag = 0;
int tag_flag;
-   int i, to_free = 0;
+   int i;
int tag_bytes = journal_tag_bytes(journal);
struct buffer_head *cbh = NULL; /* For transactional checksums */
__u32 crc32_sum = ~0;
@@ -1108,7 +1108,7 @@ restart_loop:
journal->j_stats.run.rs_blocks_logged += stats.run.rs_blocks_logged;
spin_unlock(>j_history_lock);
 
-   commit_transaction->t_state = T_FINISHED;
+   commit_transaction->t_state = T_COMMIT_CALLBACK;
J_ASSERT(commit_transaction == journal->j_committing_transaction);
journal->j_commit_sequence = commit_transaction->t_tid;
journal->j_committing_transaction = NULL;
@@ -1123,38 +1123,44 @@ restart_loop:
journal->j_average_commit_time*3) / 4;
else
journal->j_average_commit_time = commit_time;
+
write_unlock(>j_state_lock);
 
-   if (commit_transaction->t_checkpoint_list == NULL &&
-   commit_transaction->t_checkpoint_io_list == NULL) {
-   __jbd2_journal_drop_transaction(journal, commit_transaction);
-   to_free = 1;
+   if (journal->j_checkpoint_transactions == NULL) {
+   journal->j_checkpoint_transactions = commit_transaction;
+   commit_transaction->t_cpnext = commit_transaction;
+   commit_transaction->t_cpprev = commit_transaction;
} else {
-   if (journal->j_checkpoint_transactions == NULL) {
-   journal->j_checkpoint_transactions = commit_transaction;
-   commit_transaction->t_cpnext = commit_transaction;
-   commit_transaction->t_cpprev = commit_transaction;
-   } else {
-   commit_transaction->t_cpnext =
-   journal->j_checkpoint_transactions;
-   commit_transaction->t_cpprev =
-   commit_transaction->t_cpnext->t_cpprev;
-   commit_transaction->t_cpnext->t_cpprev =
-   commit_transaction;
-   commit_transaction->t_cpprev->t_cpnext =
+   commit_transaction->t_cpnext =
+   journal->j_checkpoint_transactions;
+   commit_transaction->t_cpprev =
+   commit_transaction->t_cpnext->t_cpprev;
+   commit_transaction->t_cpnext->t_cpprev =
+   

[ 073/136 ] ext4/jbd2: dont wait (forever) for stale tid caused by wraparound

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Theodore Ts'o 

[ Upstream commit d76a3a77113db020d9bb1e894822869410450bd9 ]

In the case where an inode has a very stale transaction id (tid) in
i_datasync_tid or i_sync_tid, it's possible that after a very large
(2**31) number of transactions, that the tid number space might wrap,
causing tid_geq()'s calculations to fail.

Commit deeeaf13 "jbd2: fix fsync() tid wraparound bug", later modified
by commit e7b04ac0 "jbd2: don't wake kjournald unnecessarily",
attempted to fix this problem, but it only avoided kjournald spinning
forever by fixing the logic in jbd2_log_start_commit().

Unfortunately, in the codepaths in fs/ext4/fsync.c and fs/ext4/inode.c
that might call jbd2_log_start_commit() with a stale tid, those
functions will subsequently call jbd2_log_wait_commit() with the same
stale tid, and then wait for a very long time.  To fix this, we
replace the calls to jbd2_log_start_commit() and
jbd2_log_wait_commit() with a call to a new function,
jbd2_complete_transaction(), which will correctly handle stale tid's.

As a bonus, jbd2_complete_transaction() will avoid locking
j_state_lock for writing unless a commit needs to be started.  This
should have a small (but probably not measurable) improvement for
ext4's scalability.

Signed-off-by: "Theodore Ts'o" 
Reported-by: Ben Hutchings 
Reported-by: George Barnett 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 fs/ext4/fsync.c  |3 +--
 fs/ext4/inode.c  |3 +--
 fs/jbd2/journal.c|   31 +++
 include/linux/jbd2.h |1 +
 4 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
index 2a1dcea..3d28be5 100644
--- a/fs/ext4/fsync.c
+++ b/fs/ext4/fsync.c
@@ -253,8 +253,7 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t 
end, int datasync)
if (journal->j_flags & JBD2_BARRIER &&
!jbd2_trans_will_send_data_barrier(journal, commit_tid))
needs_barrier = true;
-   jbd2_log_start_commit(journal, commit_tid);
-   ret = jbd2_log_wait_commit(journal, commit_tid);
+   ret = jbd2_complete_transaction(journal, commit_tid);
if (needs_barrier)
blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
  out:
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 5cf441c..0113b16 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -216,8 +216,7 @@ void ext4_evict_inode(struct inode *inode)
journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
tid_t commit_tid = EXT4_I(inode)->i_datasync_tid;
 
-   jbd2_log_start_commit(journal, commit_tid);
-   jbd2_log_wait_commit(journal, commit_tid);
+   jbd2_complete_transaction(journal, commit_tid);
filemap_write_and_wait(>i_data);
}
truncate_inode_pages(>i_data, 0);
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 484b8d1..b2d3cbe 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -699,6 +699,37 @@ int jbd2_log_wait_commit(journal_t *journal, tid_t tid)
 }
 
 /*
+ * When this function returns the transaction corresponding to tid
+ * will be completed.  If the transaction has currently running, start
+ * committing that transaction before waiting for it to complete.  If
+ * the transaction id is stale, it is by definition already completed,
+ * so just return SUCCESS.
+ */
+int jbd2_complete_transaction(journal_t *journal, tid_t tid)
+{
+   int need_to_wait = 1;
+
+   read_lock(>j_state_lock);
+   if (journal->j_running_transaction &&
+   journal->j_running_transaction->t_tid == tid) {
+   if (journal->j_commit_request != tid) {
+   /* transaction not yet started, so request it */
+   read_unlock(>j_state_lock);
+   jbd2_log_start_commit(journal, tid);
+   goto wait_commit;
+   }
+   } else if (!(journal->j_committing_transaction &&
+journal->j_committing_transaction->t_tid == tid))
+   need_to_wait = 0;
+   read_unlock(>j_state_lock);
+   if (!need_to_wait)
+   return 0;
+wait_commit:
+   return jbd2_log_wait_commit(journal, tid);
+}
+EXPORT_SYMBOL(jbd2_complete_transaction);
+
+/*
  * Log buffer allocation routines:
  */
 
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 3efc43f..deee02a 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -1211,6 +1211,7 @@ int __jbd2_log_start_commit(journal_t *journal, tid_t 
tid);
 int jbd2_journal_start_commit(journal_t *journal, tid_t *tid);
 int jbd2_journal_force_commit_nested(journal_t *journal);
 int jbd2_log_wait_commit(journal_t *journal, tid_t tid);
+int jbd2_complete_transaction(journal_t *journal, tid_t tid);
 int 

[ 072/136 ] ixgbe: fix EICR write in ixgbe_msix_other

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Jacob Keller 

[ Upstream commit d87d830720a1446403ed38bfc2da268be0d356d1 ]

Previously, the ixgbe_msix_other was writing the full 32bits of the set
interrupts, instead of only the ones which the ixgbe_msix_other is
handling. This resulted in a loss of performance when the X540's PPS feature is
enabled due to sometimes clearing queue interrupts which resulted in the driver
not getting the interrupt for cleaning the q_vector rings often enough. The fix
is to simply mask the lower 16bits off so that this handler does not write them
in the EICR, which causes them to remain high and be properly handled by the
clean_rings interrupt routine as normal.

Signed-off-by: Jacob Keller 
Cc: stable 
Tested-by: Phil Schmitt 
Signed-off-by: Jeff Kirsher 
Signed-off-by: Steven Rostedt 
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 1fff36d..926f0d0 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -2283,6 +2283,16 @@ static irqreturn_t ixgbe_msix_other(int irq, void *data)
 * with the write to EICR.
 */
eicr = IXGBE_READ_REG(hw, IXGBE_EICS);
+
+   /* The lower 16bits of the EICR register are for the queue interrupts
+* which should be masked here in order to not accidently clear them if
+* the bits are high when ixgbe_msix_other is called. There is a race
+* condition otherwise which results in possible performance loss
+* especially if the ixgbe_msix_other interrupt is triggering
+* consistently (as it would when PPS is turned on for the X540 device)
+*/
+   eicr &= 0x;
+
IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr);
 
if (eicr & IXGBE_EICR_LSC)
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 071/136 ] ipc: sysv shared memory limited to 8TiB

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Robin Holt 

[ Upstream commit d69f3bad4675ac519d41ca2b11e1c00ca115cecd ]

Trying to run an application which was trying to put data into half of
memory using shmget(), we found that having a shmall value below 8EiB-8TiB
would prevent us from using anything more than 8TiB.  By setting
kernel.shmall greater than 8EiB-8TiB would make the job work.

In the newseg() function, ns->shm_tot which, at 8TiB is INT_MAX.

ipc/shm.c:
 458 static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
 459 {
...
 465 int numpages = (size + PAGE_SIZE -1) >> PAGE_SHIFT;
...
 474 if (ns->shm_tot + numpages > ns->shm_ctlall)
 475 return -ENOSPC;

[a...@linux-foundation.org: make ipc/shm.c:newseg()'s numpages size_t, not int]
Signed-off-by: Robin Holt 
Reported-by: Alex Thorlton 
Cc: 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Steven Rostedt 
---
 include/linux/ipc_namespace.h |2 +-
 ipc/shm.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
index 5499c92..c731973 100644
--- a/include/linux/ipc_namespace.h
+++ b/include/linux/ipc_namespace.h
@@ -42,8 +42,8 @@ struct ipc_namespace {
 
size_t  shm_ctlmax;
size_t  shm_ctlall;
+   unsigned long   shm_tot;
int shm_ctlmni;
-   int shm_tot;
/*
 * Defines whether IPC_RMID is forced for _all_ shm segments regardless
 * of shmctl()
diff --git a/ipc/shm.c b/ipc/shm.c
index 00faa05..9f753fc4 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -462,7 +462,7 @@ static int newseg(struct ipc_namespace *ns, struct 
ipc_params *params)
size_t size = params->u.size;
int error;
struct shmid_kernel *shp;
-   int numpages = (size + PAGE_SIZE -1) >> PAGE_SHIFT;
+   size_t numpages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
struct file * file;
char name[13];
int id;
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 070/136 ] wireless: regulatory: fix channel disabling race condition

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Johannes Berg 

[ Upstream commit 990de49f74e772b6db5208457b7aa712a5f4db86 ]

When a full scan 2.4 and 5 GHz scan is scheduled, but then the 2.4 GHz
part of the scan disables a 5.2 GHz channel due to, e.g. receiving
country or frequency information, that 5.2 GHz channel might already
be in the list of channels to scan next. Then, when the driver checks
if it should do a passive scan, that will return false and attempt an
active scan. This is not only wrong but can also lead to the iwlwifi
device firmware crashing since it checks regulatory as well.

Fix this by not setting the channel flags to just disabled but rather
OR'ing in the disabled flag. That way, even if the race happens, the
channel will be scanned passively which is still (mostly) correct.

Cc: sta...@vger.kernel.org
Signed-off-by: Johannes Berg 
Signed-off-by: Steven Rostedt 
---
 net/wireless/reg.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 3062b88..633806e 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -874,7 +874,7 @@ static void handle_channel(struct wiphy *wiphy,
return;
 
REG_DBG_PRINT("Disabling freq %d MHz\n", chan->center_freq);
-   chan->flags = IEEE80211_CHAN_DISABLED;
+   chan->flags |= IEEE80211_CHAN_DISABLED;
return;
}
 
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 069/136 ] nfsd: Decode and send 64bit time values

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Bryan Schumaker 

[ Upstream commit bf8d909705e9d9bac31d9b8eac6734d2b51332a7 ]

The seconds field of an nfstime4 structure is 64bit, but we are assuming
that the first 32bits are zero-filled.  So if the client tries to set
atime to a value before the epoch (touch -t 196001010101), then the
server will save the wrong value on disk.

Signed-off-by: Bryan Schumaker 
Cc: sta...@kernel.org
Signed-off-by: J. Bruce Fields 
Signed-off-by: Steven Rostedt 
---
 fs/nfsd/nfs4xdr.c |   19 +--
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 551b061..348937b 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -343,10 +343,7 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 
*bmval,
   all 32 bits of 'nseconds'. */
READ_BUF(12);
len += 12;
-   READ32(dummy32);
-   if (dummy32)
-   return nfserr_inval;
-   READ32(iattr->ia_atime.tv_sec);
+   READ64(iattr->ia_atime.tv_sec);
READ32(iattr->ia_atime.tv_nsec);
if (iattr->ia_atime.tv_nsec >= (u32)10)
return nfserr_inval;
@@ -369,10 +366,7 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 
*bmval,
   all 32 bits of 'nseconds'. */
READ_BUF(12);
len += 12;
-   READ32(dummy32);
-   if (dummy32)
-   return nfserr_inval;
-   READ32(iattr->ia_mtime.tv_sec);
+   READ64(iattr->ia_mtime.tv_sec);
READ32(iattr->ia_mtime.tv_nsec);
if (iattr->ia_mtime.tv_nsec >= (u32)10)
return nfserr_inval;
@@ -2397,8 +2391,7 @@ out_acl:
if (bmval1 & FATTR4_WORD1_TIME_ACCESS) {
if ((buflen -= 12) < 0)
goto out_resource;
-   WRITE32(0);
-   WRITE32(stat.atime.tv_sec);
+   WRITE64((s64)stat.atime.tv_sec);
WRITE32(stat.atime.tv_nsec);
}
if (bmval1 & FATTR4_WORD1_TIME_DELTA) {
@@ -2411,15 +2404,13 @@ out_acl:
if (bmval1 & FATTR4_WORD1_TIME_METADATA) {
if ((buflen -= 12) < 0)
goto out_resource;
-   WRITE32(0);
-   WRITE32(stat.ctime.tv_sec);
+   WRITE64((s64)stat.ctime.tv_sec);
WRITE32(stat.ctime.tv_nsec);
}
if (bmval1 & FATTR4_WORD1_TIME_MODIFY) {
if ((buflen -= 12) < 0)
goto out_resource;
-   WRITE32(0);
-   WRITE32(stat.mtime.tv_sec);
+   WRITE64((s64)stat.mtime.tv_sec);
WRITE32(stat.mtime.tv_nsec);
}
if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) {
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 086/136 ] powerpc: fix numa distance for form0 device tree

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Vaidyanathan Srinivasan 

[ Upstream commit 7122b7bc1757682049780179d7c216dd1c83 ]

The following commit breaks numa distance setup for old powerpc
systems that use form0 encoding in device tree.

commit 41eab6f88f24124df89e38067b3766b7bef06ddb
powerpc/numa: Use form 1 affinity to setup node distance

Device tree node /rtas/ibm,associativity-reference-points would
index into /cpus/PowerPC/ibm,associativity based on form0 or
form1 encoding detected by ibm,architecture-vec-5 property.

All modern systems use form1 and current kernel code is correct.
However, on older systems with form0 encoding, the numa distance
will get hard coded as LOCAL_DISTANCE for all nodes.  This causes
task scheduling anomaly since scheduler will skip building numa
level domain (topmost domain with all cpus) if all numa distances
are same.  (value of 'level' in sched_init_numa() will remain 0)

Prior to the above commit:
((from) == (to) ? LOCAL_DISTANCE : REMOTE_DISTANCE)

Restoring compatible behavior with this patch for old powerpc systems
with device tree where numa distance are encoded as form0.

Signed-off-by: Vaidyanathan Srinivasan 
Signed-off-by: Michael Ellerman 
Signed-off-by: Steven Rostedt 
---
 arch/powerpc/mm/numa.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 59213cf..d53fa78 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -201,7 +201,7 @@ int __node_distance(int a, int b)
int distance = LOCAL_DISTANCE;
 
if (!form1_affinity)
-   return distance;
+   return ((a == b) ? LOCAL_DISTANCE : REMOTE_DISTANCE);
 
for (i = 0; i < distance_ref_points_depth; i++) {
if (distance_lookup_table[a][i] == distance_lookup_table[b][i])
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 097/136 ] netfilter: ipset: list:set: fix reference counter update

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Jozsef Kadlecsik 

[ Upstream commit 02f815cb6d3f57914228be84df9613ee5a01c2e6 ]

The last element can be replaced or pushed off and in both
cases the reference counter must be updated.

Signed-off-by: Jozsef Kadlecsik 
Signed-off-by: Pablo Neira Ayuso 
Signed-off-by: Steven Rostedt 
---
 net/netfilter/ipset/ip_set_list_set.c |   10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/net/netfilter/ipset/ip_set_list_set.c 
b/net/netfilter/ipset/ip_set_list_set.c
index 6cb1225..19bf0fe 100644
--- a/net/netfilter/ipset/ip_set_list_set.c
+++ b/net/netfilter/ipset/ip_set_list_set.c
@@ -171,9 +171,13 @@ list_set_add(struct list_set *map, u32 i, ip_set_id_t id,
 {
const struct set_elem *e = list_set_elem(map, i);
 
-   if (i == map->size - 1 && e->id != IPSET_INVALID_ID)
-   /* Last element replaced: e.g. add new,before,last */
-   ip_set_put_byindex(e->id);
+   if (e->id != IPSET_INVALID_ID) {
+   const struct set_elem *x = list_set_elem(map, map->size - 1);
+
+   /* Last element replaced or pushed off */
+   if (x->id != IPSET_INVALID_ID)
+   ip_set_put_byindex(x->id);
+   }
if (with_timeout(map->timeout))
list_elem_tadd(map, i, id, ip_set_timeout_set(timeout));
else
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 067/136 ] nfsd4: dont close read-write opens too soon

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: "J. Bruce Fields" 

[ Upstream commit 0c7c3e67ab91ec6caa44bdf1fc89a48012ceb0c5 ]

Don't actually close any opens until we don't need them at all.

This means being left with write access when it's not really necessary,
but that's better than putting a file that might still have posix locks
held on it, as we have been.

Reported-by: Toralf Förster 
Cc: sta...@kernel.org
Signed-off-by: J. Bruce Fields 
Signed-off-by: Steven Rostedt 
---
 fs/nfsd/nfs4state.c |8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 5b3224c..0ecd408 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -217,13 +217,7 @@ static void __nfs4_file_put_access(struct nfs4_file *fp, 
int oflag)
 {
if (atomic_dec_and_test(>fi_access[oflag])) {
nfs4_file_put_fd(fp, oflag);
-   /*
-* It's also safe to get rid of the RDWR open *if*
-* we no longer have need of the other kind of access
-* or if we already have the other kind of open:
-*/
-   if (fp->fi_fds[1-oflag]
-   || atomic_read(>fi_access[1 - oflag]) == 0)
+   if (atomic_read(>fi_access[1 - oflag]) == 0)
nfs4_file_put_fd(fp, O_RDWR);
}
 }
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 068/136 ] nfsd: dont run get_file if nfs4_preprocess_stateid_op return error

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: fanchaoting 

[ Upstream commit b022032e195ffca83d7002d6b84297d796ed443b ]

we should return error status directly when nfs4_preprocess_stateid_op
return error.

Signed-off-by: fanchaoting 
Cc: sta...@vger.kernel.org
Signed-off-by: J. Bruce Fields 
Signed-off-by: Steven Rostedt 
---
 fs/nfsd/nfs4proc.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index c9c1c0a..4445c66 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -893,14 +893,14 @@ nfsd4_write(struct svc_rqst *rqstp, struct 
nfsd4_compound_state *cstate,
nfs4_lock_state();
status = nfs4_preprocess_stateid_op(SVC_NET(rqstp),
cstate, stateid, WR_STATE, );
-   if (filp)
-   get_file(filp);
-   nfs4_unlock_state();
-
if (status) {
+   nfs4_unlock_state();
dprintk("NFSD: nfsd4_write: couldn't process stateid!\n");
return status;
}
+   if (filp)
+   get_file(filp);
+   nfs4_unlock_state();
 
cnt = write->wr_buflen;
write->wr_how_written = write->wr_stable_how;
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 059/136 ] clockevents: Set dummy handler on CPU_DEAD shutdown

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Thomas Gleixner 

[ Upstream commit 6f7a05d7018de222e40ca003721037a530979974 ]

Vitaliy reported that a per cpu HPET timer interrupt crashes the
system during hibernation. What happens is that the per cpu HPET timer
gets shut down when the nonboot cpus are stopped. When the nonboot
cpus are onlined again the HPET code sets up the MSI interrupt which
fires before the clock event device is registered. The event handler
is still set to hrtimer_interrupt, which then crashes the machine due
to highres mode not being active.

See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=700333

There is no real good way to avoid that in the HPET code. The HPET
code alrady has a mechanism to detect spurious interrupts when event
handler == NULL for a similar reason.

We can handle that in the clockevent/tick layer and replace the
previous functional handler with a dummy handler like we do in
tick_setup_new_device().

The original clockevents code did this in clockevents_exchange_device(),
but that got removed by commit 7c1e76897 (clockevents: prevent
clockevent event_handler ending up handler_noop) which forgot to fix
it up in tick_shutdown(). Same issue with the broadcast device.

Reported-by: Vitaliy Fillipov 
Cc: Ben Hutchings 
Cc: sta...@vger.kernel.org
Cc: 700...@bugs.debian.org
Signed-off-by: Thomas Gleixner 
Signed-off-by: Steven Rostedt 
---
 kernel/time/tick-broadcast.c |4 
 kernel/time/tick-common.c|1 +
 2 files changed, 5 insertions(+)

diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index a13987a..239a323 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -66,6 +66,8 @@ static void tick_broadcast_start_periodic(struct 
clock_event_device *bc)
  */
 int tick_check_broadcast_device(struct clock_event_device *dev)
 {
+   struct clock_event_device *cur = tick_broadcast_device.evtdev;
+
if ((dev->features & CLOCK_EVT_FEAT_DUMMY) ||
(tick_broadcast_device.evtdev &&
 tick_broadcast_device.evtdev->rating >= dev->rating) ||
@@ -73,6 +75,8 @@ int tick_check_broadcast_device(struct clock_event_device 
*dev)
return 0;
 
clockevents_exchange_device(tick_broadcast_device.evtdev, dev);
+   if (cur)
+   cur->event_handler = clockevents_handle_noop;
tick_broadcast_device.evtdev = dev;
if (!cpumask_empty(tick_get_broadcast_mask()))
tick_broadcast_start_periodic(dev);
diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
index da6c9ec..ead79bc 100644
--- a/kernel/time/tick-common.c
+++ b/kernel/time/tick-common.c
@@ -323,6 +323,7 @@ static void tick_shutdown(unsigned int *cpup)
 */
dev->mode = CLOCK_EVT_MODE_UNUSED;
clockevents_exchange_device(dev, NULL);
+   dev->event_handler = clockevents_handle_noop;
td->evtdev = NULL;
}
raw_spin_unlock_irqrestore(_device_lock, flags);
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 063/136 ] LOCKD: Ensure that nlmclnt_block resets block->b_status after a server reboot

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Trond Myklebust 

[ Upstream commit 1dfd89af8697a299e7982ae740d4695ecd917eef ]

After a server reboot, the reclaimer thread will recover all the existing
locks. For locks that are blocked, however, it will change the value
of block->b_status to nlm_lck_denied_grace_period in order to signal that
they need to wake up and resend the original blocking lock request.

Due to a bug, however, the block->b_status never gets reset after the
blocked locks have been woken up, and so the process goes into an
infinite loop of resends until the blocked lock is satisfied.

Reported-by: Marc Eshel 
Signed-off-by: Trond Myklebust 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 fs/lockd/clntlock.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c
index ca0a080..193f04c 100644
--- a/fs/lockd/clntlock.c
+++ b/fs/lockd/clntlock.c
@@ -144,6 +144,9 @@ int nlmclnt_block(struct nlm_wait *block, struct nlm_rqst 
*req, long timeout)
timeout);
if (ret < 0)
return -ERESTARTSYS;
+   /* Reset the lock status after a server reboot so we resend */
+   if (block->b_status == nlm_lck_denied_grace_period)
+   block->b_status = nlm_lck_blocked;
req->a_res.status = block->b_status;
return 0;
 }
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 057/136 ] acpi: make ata_ap_acpi_handle not block

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Aaron Lu 

[ Upstream commit d66af4df0837f21bf267305dc5ccab2d29e24d86 ]

Since commit 30dcf76acc, ata_ap_acpi_handle will always do a namespace
walk, which requires acquiring an acpi namespace mutex. This made it
impossible to be used when calling path has held a spinlock.

For example, it can occur in the following code path for pata_acpi:
ata_scsi_queuecmd (ap->lock is acquired)
  __ata_scsi_queuecmd
ata_scsi_translate
  ata_qc_issue
pacpi_qc_issue
  ata_acpi_stm
ata_ap_acpi_handle
  acpi_get_child
acpi_walk_namespace
  acpi_ut_acquire_mutex (acquire mutex while holding lock)
This caused scheduling while atomic bug, as reported in bug #56781.

Actually, ata_ap_acpi_handle doesn't have to walk the namespace every
time it is called, it can simply return the bound acpi handle on the
corresponding SCSI host. The reason previously it is not done this way
is, ata_ap_acpi_handle is used in the binding function
ata_acpi_bind_host by ata_acpi_gtm when the handle is not bound to the
SCSI host yet. Since we already have the ATA port's handle in its
binding function, we can simply use it instead of calling
ata_ap_acpi_handle there. So introduce a new function __ata_acpi_gtm,
where it will receive an acpi handle param in addition to the ATA port
which is solely used for debug statement. With this change, we can make
ata_ap_acpi_handle simply return the bound handle for SCSI host instead
of walking the acpi namespace now.

Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=56781
Reported-and-tested-by: 
Cc: 
Signed-off-by: Aaron Lu 
Signed-off-by: Jeff Garzik 
Signed-off-by: Steven Rostedt 
---
 drivers/ata/libata-acpi.c |   45 +++--
 1 file changed, 27 insertions(+), 18 deletions(-)

diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 5b0ba3f..926c9f5 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -60,7 +60,8 @@ acpi_handle ata_ap_acpi_handle(struct ata_port *ap)
if (ap->flags & ATA_FLAG_ACPI_SATA)
return NULL;
 
-   return acpi_get_child(DEVICE_ACPI_HANDLE(ap->host->dev), ap->port_no);
+   return ap->scsi_host ?
+   DEVICE_ACPI_HANDLE(>scsi_host->shost_gendev) : NULL;
 }
 EXPORT_SYMBOL(ata_ap_acpi_handle);
 
@@ -236,28 +237,15 @@ void ata_acpi_dissociate(struct ata_host *host)
}
 }
 
-/**
- * ata_acpi_gtm - execute _GTM
- * @ap: target ATA port
- * @gtm: out parameter for _GTM result
- *
- * Evaluate _GTM and store the result in @gtm.
- *
- * LOCKING:
- * EH context.
- *
- * RETURNS:
- * 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure.
- */
-int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm)
+static int __ata_acpi_gtm(struct ata_port *ap, acpi_handle handle,
+ struct ata_acpi_gtm *gtm)
 {
struct acpi_buffer output = { .length = ACPI_ALLOCATE_BUFFER };
union acpi_object *out_obj;
acpi_status status;
int rc = 0;
 
-   status = acpi_evaluate_object(ata_ap_acpi_handle(ap), "_GTM", NULL,
- );
+   status = acpi_evaluate_object(handle, "_GTM", NULL, );
 
rc = -ENOENT;
if (status == AE_NOT_FOUND)
@@ -291,6 +279,27 @@ int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm 
*gtm)
return rc;
 }
 
+/**
+ * ata_acpi_gtm - execute _GTM
+ * @ap: target ATA port
+ * @gtm: out parameter for _GTM result
+ *
+ * Evaluate _GTM and store the result in @gtm.
+ *
+ * LOCKING:
+ * EH context.
+ *
+ * RETURNS:
+ * 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure.
+ */
+int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm)
+{
+   if (ata_ap_acpi_handle(ap))
+   return __ata_acpi_gtm(ap, ata_ap_acpi_handle(ap), gtm);
+   else
+   return -EINVAL;
+}
+
 EXPORT_SYMBOL_GPL(ata_acpi_gtm);
 
 /**
@@ -1091,7 +1100,7 @@ static int ata_acpi_bind_host(struct ata_port *ap, 
acpi_handle *handle)
if (!*handle)
return -ENODEV;
 
-   if (ata_acpi_gtm(ap, >__acpi_init_gtm) == 0)
+   if (__ata_acpi_gtm(ap, *handle, >__acpi_init_gtm) == 0)
ap->pflags |= ATA_PFLAG_INIT_GTM_VALID;
 
return 0;
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 055/136 ] mm: swap: mark swap pages writeback before queueing for direct IO

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Mel Gorman 

[ Upstream commit 0cdc444a67ccdbd58bfbcba865cb17a9f17a7691 ]

As pointed out by Andrew Morton, the swap-over-NFS writeback is not
setting PageWriteback before it is queued for direct IO.  While swap
pages do not participate in BDI or process dirty accounting and the IO
is synchronous, the writeback bit is still required and not setting it
in this case was an oversight.  swapoff depends on the page writeback to
synchronoise all pending writes on a swap page before it is reused.
Swapcache freeing and reuse depend on checking the PageWriteback under
lock to ensure the page is safe to reuse.

Direct IO handlers and the direct IO handler for NFS do not deal with
PageWriteback as they are synchronous writes.  In the case of NFS, it
schedules pages (or a page in the case of swap) for IO and then waits
synchronously for IO to complete in nfs_direct_write().  It is
recognised that this is a slowdown from normal swap handling which is
asynchronous and uses a completion handler.  Shoving PageWriteback
handling down into direct IO handlers looks like a bad fit to handle the
swap case although it may have to be dealt with some day if swap is
converted to use direct IO in general and bmap is finally done away
with.  At that point it will be necessary to refit asynchronous direct
IO with completion handlers onto the swap subsystem.

As swapcache currently depends on PageWriteback to protect against
races, this patch sets PageWriteback under the page lock before queueing
it for direct IO.  It is cleared when the direct IO handler returns.  IO
errors are treated similarly to the direct-to-bio case except PageError
is not set as in the case of swap-over-NFS, it is likely to be a
transient error.

It was asked what prevents such a page being reclaimed in parallel.
With this patch applied, such a page will now be skipped (most of the
time) or blocked until the writeback completes.  Reclaim checks
PageWriteback under the page lock before calling try_to_free_swap and
the page lock should prevent the page being requeued for IO before it is
freed.

This and Jerome's related patch should considered for -stable as far
back as 3.6 when swap-over-NFS was introduced.

[a...@linux-foundation.org: use pr_err_ratelimited()]
[a...@linux-foundation.org: remove hopefully-unneeded cast in printk]
Signed-off-by: Mel Gorman 
Cc: Jerome Marchand 
Cc: Hugh Dickins 
Cc: [3.6+]
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Steven Rostedt 
---
 mm/page_io.c |   15 +++
 1 file changed, 15 insertions(+)

diff --git a/mm/page_io.c b/mm/page_io.c
index 04ca00d..6182870 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -214,6 +214,7 @@ int swap_writepage(struct page *page, struct 
writeback_control *wbc)
kiocb.ki_left = PAGE_SIZE;
kiocb.ki_nbytes = PAGE_SIZE;
 
+   set_page_writeback(page);
unlock_page(page);
ret = mapping->a_ops->direct_IO(KERNEL_WRITE,
, ,
@@ -223,8 +224,22 @@ int swap_writepage(struct page *page, struct 
writeback_control *wbc)
count_vm_event(PSWPOUT);
ret = 0;
} else {
+   /*
+* In the case of swap-over-nfs, this can be a
+* temporary failure if the system has limited
+* memory for allocating transmit buffers.
+* Mark the page dirty and avoid
+* rotate_reclaimable_page but rate-limit the
+* messages but do not flag PageError like
+* the normal direct-to-bio case as it could
+* be temporary.
+*/
set_page_dirty(page);
+   ClearPageReclaim(page);
+   pr_err_ratelimited("Write error on dio swapfile 
(%Lu)\n",
+   page_file_offset(page));
}
+   end_page_writeback(page);
return ret;
}
 
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 065/136 ] MD: ignore discard request for hard disks of hybid raid1/raid10 array

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Shaohua Li 

[ Upstream commit 32f9f570d04461a41bdcd5c1d93b41ebc5ce182a ]

In SSD/hard disk hybid storage, discard request should be ignored for hard
disk. We used to be doing this way, but the unplug path forgets it.

This is suitable for stable tree since v3.6.

Cc: sta...@vger.kernel.org
Reported-and-tested-by: Markus 
Signed-off-by: Shaohua Li 
Signed-off-by: NeilBrown 
Signed-off-by: Steven Rostedt 
---
 drivers/md/raid1.c  |7 ++-
 drivers/md/raid10.c |6 ++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 7077dcf..36c6003 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -976,7 +976,12 @@ static void raid1_unplug(struct blk_plug_cb *cb, bool 
from_schedule)
while (bio) { /* submit pending writes */
struct bio *next = bio->bi_next;
bio->bi_next = NULL;
-   generic_make_request(bio);
+   if (unlikely((bio->bi_rw & REQ_DISCARD) &&
+   !blk_queue_discard(bdev_get_queue(bio->bi_bdev
+   /* Just ignore it */
+   bio_endio(bio, 0);
+   else
+   generic_make_request(bio);
bio = next;
}
kfree(plug);
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index c52d893..bec9db8 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -912,6 +912,12 @@ static void flush_pending_writes(struct r10conf *conf)
struct bio *next = bio->bi_next;
bio->bi_next = NULL;
generic_make_request(bio);
+   if (unlikely((bio->bi_rw & REQ_DISCARD) &&
+
!blk_queue_discard(bdev_get_queue(bio->bi_bdev
+   /* Just ignore it */
+   bio_endio(bio, 0);
+   else
+   generic_make_request(bio);
bio = next;
}
} else
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 058/136 ] cgroup: fix an off-by-one bug which may trigger BUG_ON()

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Li Zefan 

[ Upstream commit 3ac1707a13a3da9cfc8f242a15b2fae6df2c5f88 ]

The 3rd parameter of flex_array_prealloc() is the number of elements,
not the index of the last element.

The effect of the bug is, when opening cgroup.procs, a flex array will
be allocated and all elements of the array is allocated with
GFP_KERNEL flag, but the last one is GFP_ATOMIC, and if we fail to
allocate memory for it, it'll trigger a BUG_ON().

Signed-off-by: Li Zefan 
Signed-off-by: Tejun Heo 
Cc: sta...@vger.kernel.org
Signed-off-by: Steven Rostedt 
---
 kernel/cgroup.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index ff2bce5..bfc0578 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2067,7 +2067,7 @@ static int cgroup_attach_proc(struct cgroup *cgrp, struct 
task_struct *leader)
if (!group)
return -ENOMEM;
/* pre-allocate to guarantee space while iterating in rcu read-side. */
-   retval = flex_array_prealloc(group, 0, group_size - 1, GFP_KERNEL);
+   retval = flex_array_prealloc(group, 0, group_size, GFP_KERNEL);
if (retval)
goto out_free_group_list;
 
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 061/136 ] fs/dcache.c: add cond_resched() to shrink_dcache_parent()

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Greg Thelen 

[ Upstream commit 421348f1ca0bf17769dee0aed4d991845ae0536d ]

Call cond_resched() in shrink_dcache_parent() to maintain interactivity.

Before this patch:

void shrink_dcache_parent(struct dentry * parent)
{
while ((found = select_parent(parent, )) != 0)
shrink_dentry_list();
}

select_parent() populates the dispose list with dentries which
shrink_dentry_list() then deletes.  select_parent() carefully uses
need_resched() to avoid doing too much work at once.  But neither
shrink_dcache_parent() nor its called functions call cond_resched().  So
once need_resched() is set select_parent() will return single dentry
dispose list which is then deleted by shrink_dentry_list().  This is
inefficient when there are a lot of dentry to process.  This can cause
softlockup and hurts interactivity on non preemptable kernels.

This change adds cond_resched() in shrink_dcache_parent().  The benefit
of this is that need_resched() is quickly cleared so that future calls
to select_parent() are able to efficiently return a big batch of dentry.

These additional cond_resched() do not seem to impact performance, at
least for the workload below.

Here is a program which can cause soft lockup if other system activity
sets need_resched().

int main()
{
struct rlimit rlim;
int i;
int f[10];
char buf[20];
struct timeval t1, t2;
double diff;

/* cleanup past run */
system("rm -rf x");

/* boost nfile rlimit */
rlim.rlim_cur = 20;
rlim.rlim_max = 20;
if (setrlimit(RLIMIT_NOFILE, ))
err(1, "setrlimit");

/* make directory for files */
if (mkdir("x", 0700))
err(1, "mkdir");

if (gettimeofday(, NULL))
err(1, "gettimeofday");

/* populate directory with open files */
for (i = 0; i < 10; i++) {
snprintf(buf, sizeof(buf), "x/%d", i);
f[i] = open(buf, O_CREAT);
if (f[i] == -1)
err(1, "open");
}

/* close some of the files */
for (i = 0; i < 85000; i++)
close(f[i]);

/* unlink all files, even open ones */
system("rm -rf x");

if (gettimeofday(, NULL))
err(1, "gettimeofday");

diff = (((double)t2.tv_sec * 100 + t2.tv_usec) -
((double)t1.tv_sec * 100 + t1.tv_usec));

printf("done: %g elapsed\n", diff/1e6);
return 0;
}

Signed-off-by: Greg Thelen 
Signed-off-by: Dave Chinner 
Cc: 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Steven Rostedt 
---
 fs/dcache.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 2488c47..0578ce2 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1256,8 +1256,10 @@ void shrink_dcache_parent(struct dentry * parent)
LIST_HEAD(dispose);
int found;
 
-   while ((found = select_parent(parent, )) != 0)
+   while ((found = select_parent(parent, )) != 0) {
shrink_dentry_list();
+   cond_resched();
+   }
 }
 EXPORT_SYMBOL(shrink_dcache_parent);
 
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[ 056/136 ] drivers/rtc/rtc-cmos.c: dont disable hpet emulation on suspend

2013-05-17 Thread Steven Rostedt
3.6.11.4 stable review patch.
If anyone has any objections, please let me know.

--

From: Derek Basehore 

[ Upstream commit e005715efaf674660ae59af83b13822567e3a758 ]

There's a bug where rtc alarms are ignored after the rtc cmos suspends
but before the system finishes suspend.  Since hpet emulation is
disabled and it still handles the interrupts, a wake event is never
registered which is done from the rtc layer.

This patch reverts commit d1b2efa83fbf ("rtc: disable hpet emulation on
suspend") which disabled hpet emulation.  To fix the problem mentioned
in that commit, hpet_rtc_timer_init() is called directly on resume.

Signed-off-by: Derek Basehore 
Cc: Maxim Levitsky 
Cc: "H. Peter Anvin" 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: "Rafael J. Wysocki" 
Cc: 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Steven Rostedt 
---
 drivers/rtc/rtc-cmos.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index 4267789..6a4adf7 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -805,9 +805,8 @@ static int cmos_suspend(struct device *dev)
mask = RTC_IRQMASK;
tmp &= ~mask;
CMOS_WRITE(tmp, RTC_CONTROL);
+   hpet_mask_rtc_irq_bit(mask);
 
-   /* shut down hpet emulation - we don't need it for alarm */
-   hpet_mask_rtc_irq_bit(RTC_PIE|RTC_AIE|RTC_UIE);
cmos_checkintr(cmos, tmp);
}
spin_unlock_irq(_lock);
@@ -872,6 +871,7 @@ static int cmos_resume(struct device *dev)
rtc_update_irq(cmos->rtc, 1, mask);
tmp &= ~RTC_AIE;
hpet_mask_rtc_irq_bit(RTC_AIE);
+   hpet_rtc_timer_init();
} while (mask & RTC_AIE);
spin_unlock_irq(_lock);
}
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3.9-stable] NTB: Multiple NTB client fix

2013-05-17 Thread Jonghwan Choi
From: Jon Mason 

This patch looks like it should be in the 3.9-stable tree, should we apply
it?

--

From: "Jon Mason "

commit 8b19d450ad188d402a183ff4a4d40f31c3916fbf upstream

Fix issue with adding multiple ntb client devices to the ntb virtual
bus.  Previously, multiple devices would be added with the same name,
resulting in crashes.  To get around this issue, add a unique number to
the device when it is added.

Cc:  # 3.9.x: ad3e2751: ntb: off by one
Cc:  # 3.9.x: cc0f868d: NTB: fix pointer math
Cc:  # 3.9.x: 113fc505: NTB: Handle 64bit BAR
Cc:  # 3.9.x: b77b2637: NTB: Link toggle memory
Cc:  # 3.9.x: 90f9e934: NTB: reset tx_index on
Cc:  # 3.9.x: c9d534c8: NTB: Correctly handle receive
Cc:  # 3.9.x: c336acd3: NTB: memcpy lockup workaround
Cc:  # 3.9.x: 904435cf: ntb_netdev: remove from list
Signed-off-by: Jon Mason 
Signed-off-by: Jonghwan Choi 
---
 drivers/ntb/ntb_transport.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index 0f66daa..f365b2f 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -300,7 +300,7 @@ int ntb_register_client_dev(char *device_name)
 {
struct ntb_transport_client_dev *client_dev;
struct ntb_transport *nt;
-   int rc;
+   int rc, i = 0;
 
if (list_empty(_transport_list))
return -ENODEV;
@@ -318,7 +318,7 @@ int ntb_register_client_dev(char *device_name)
dev = _dev->dev;
 
/* setup and register client devices */
-   dev_set_name(dev, "%s", device_name);
+   dev_set_name(dev, "%s%d", device_name, i);
dev->bus = _bus_type;
dev->release = ntb_client_release;
dev->parent = _query_pdev(nt->ndev)->dev;
@@ -330,6 +330,7 @@ int ntb_register_client_dev(char *device_name)
}
 
list_add_tail(_dev->entry, >client_devs);
+   i++;
}
 
return 0;
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3.9-stable] ntb_netdev: remove from list on exit

2013-05-17 Thread Jonghwan Choi
From: Jon Mason 

This patch looks like it should be in the 3.9-stable tree, should we apply
it?

--

From: "Jon Mason "

commit 904435cf76a9bdd5eb41b1c4e049d5a64f3a8400 upstream

The ntb_netdev device is not removed from the global list of devices
upon device removal.  If the device is re-added, the removal code would
find the first instance and try to remove an already removed device.

Cc:  # 3.9.x: ad3e2751: ntb: off by one
Cc:  # 3.9.x: cc0f868d: NTB: fix pointer math
Cc:  # 3.9.x: 113fc505: NTB: Handle 64bit BAR
Cc:  # 3.9.x: b77b2637: NTB: Link toggle memory
Cc:  # 3.9.x: 90f9e934: NTB: reset tx_index on
Cc:  # 3.9.x: c9d534c8: NTB: Correctly handle receive
Cc:  # 3.9.x: c336acd3: NTB: memcpy lockup workaround
Signed-off-by: Jon Mason 
Signed-off-by: Jonghwan Choi 
---
 drivers/net/ntb_netdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ntb_netdev.c b/drivers/net/ntb_netdev.c
index ed947dd..f3cdf64 100644
--- a/drivers/net/ntb_netdev.c
+++ b/drivers/net/ntb_netdev.c
@@ -375,6 +375,8 @@ static void ntb_netdev_remove(struct pci_dev *pdev)
if (dev == NULL)
return;
 
+   list_del(>list);
+
ndev = dev->ndev;
 
unregister_netdev(ndev);
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3.9-stable] NTB: memcpy lockup workaround

2013-05-17 Thread Jonghwan Choi
From: Jon Mason 

This patch looks like it should be in the 3.9-stable tree, should we apply
it?

--

From: "Jon Mason "

commit c336acd3331dcc191a97dbc66a557d47741657c7 upstream

The system will appear to lockup for long periods of time due to the NTB
driver spending too much time in memcpy.  Avoid this by reducing the
number of packets that can be serviced on a given interrupt.

Cc:  # 3.9.x: ad3e2751: ntb: off by one
Cc:  # 3.9.x: cc0f868d: NTB: fix pointer math
Cc:  # 3.9.x: 113fc505: NTB: Handle 64bit BAR
Cc:  # 3.9.x: b77b2637: NTB: Link toggle memory
Cc:  # 3.9.x: 90f9e934: NTB: reset tx_index on
Cc:  # 3.9.x: c9d534c8: NTB: Correctly handle receive
Signed-off-by: Jon Mason 
Signed-off-by: Jonghwan Choi 
---
 drivers/ntb/ntb_transport.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index a288a26..0f66daa 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -1034,11 +1034,16 @@ out:
 static void ntb_transport_rx(unsigned long data)
 {
struct ntb_transport_qp *qp = (struct ntb_transport_qp *)data;
-   int rc;
+   int rc, i;
 
-   do {
+   /* Limit the number of packets processed in a single interrupt to
+* provide fairness to others
+*/
+   for (i = 0; i < qp->rx_max_entry; i++) {
rc = ntb_process_rxc(qp);
-   } while (!rc);
+   if (rc)
+   break;
+   }
 }
 
 static void ntb_transport_rxc_db(void *data, int db_num)
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3.9-table] NTB: Correctly handle receive buffers of the minimal size

2013-05-17 Thread Jonghwan Choi
From: Jon Mason 

This patch looks like it should be in the 3.9-stable tree, should we apply
it?

--

From: "Jon Mason "

commit c9d534c8cbaedbb522a1d2cb037c6c394f610317 upstream

The ring logic of the NTB receive buffer/transmit memory window requires
there to be at least 2 payload sized allotments.  For the minimal size
case, split the buffer into two and set the transport_mtu to the
appropriate size.

Cc:  # 3.9.x: ad3e2751: ntb: off by one
Cc:  # 3.9.x: cc0f868d: NTB: fix pointer math
Cc:  # 3.9.x: 113fc505: NTB: Handle 64bit BAR
Cc:  # 3.9.x: b77b2637: NTB: Link toggle memory
Cc:  # 3.9.x: 90f9e934: NTB: reset tx_index on
Signed-off-by: Jon Mason 
Signed-off-by: Jonghwan Choi 
---
 drivers/ntb/ntb_transport.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index 0828124..a288a26 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -490,11 +490,12 @@ static void ntb_transport_setup_qp_mw(struct 
ntb_transport *nt,
rx_size -= sizeof(struct ntb_rx_info);
 
qp->rx_buff = qp->remote_rx_info + 1;
-   qp->rx_max_frame = min(transport_mtu, rx_size);
+   /* Due to housekeeping, there must be atleast 2 buffs */
+   qp->rx_max_frame = min(transport_mtu, rx_size / 2);
qp->rx_max_entry = rx_size / qp->rx_max_frame;
qp->rx_index = 0;
 
-   qp->remote_rx_info->entry = qp->rx_max_entry;
+   qp->remote_rx_info->entry = qp->rx_max_entry - 1;
 
/* setup the hdr offsets with 0's */
for (i = 0; i < qp->rx_max_entry; i++) {
@@ -818,7 +819,8 @@ static void ntb_transport_init_queue(struct ntb_transport 
*nt,
tx_size -= sizeof(struct ntb_rx_info);
 
qp->tx_mw = qp->rx_info + 1;
-   qp->tx_max_frame = min(transport_mtu, tx_size);
+   /* Due to housekeeping, there must be atleast 2 buffs */
+   qp->tx_max_frame = min(transport_mtu, tx_size / 2);
qp->tx_max_entry = tx_size / qp->tx_max_frame;
 
if (nt->debugfs_dir) {
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3.9-stable] NTB: reset tx_index on link toggle

2013-05-17 Thread Jonghwan Choi
From: Jon Mason 

This patch looks like it should be in the 3.9-stable tree, should we apply
it?

--

From: "Jon Mason "

commit 90f9e934647e652a69396e18c779215a493271cf upstream

If the NTB link toggles, the driver could stop receiving due to the
tx_index not being set to 0 on the transmitting size on a link-up event.
This is due to the driver expecting the incoming data to start at the
beginning of the receive buffer and not at a random place.

Cc:  # 3.9.x: ad3e2751: ntb: off by one
Cc:  # 3.9.x: cc0f868d: NTB: fix pointer math
Cc:  # 3.9.x: 113fc505: NTB: Handle 64bit BAR
Cc:  # 3.9.x: b77b2637: NTB: Link toggle memory
Signed-off-by: Jon Mason 
Signed-off-by: Jonghwan Choi 
---
 drivers/ntb/ntb_transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index f5a424d..0828124 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -505,6 +505,7 @@ static void ntb_transport_setup_qp_mw(struct ntb_transport 
*nt,
 
qp->rx_pkts = 0;
qp->tx_pkts = 0;
+   qp->tx_index = 0;
 }
 
 static void ntb_free_mw(struct ntb_transport *nt, int num_mw)
@@ -819,7 +820,6 @@ static void ntb_transport_init_queue(struct ntb_transport 
*nt,
qp->tx_mw = qp->rx_info + 1;
qp->tx_max_frame = min(transport_mtu, tx_size);
qp->tx_max_entry = tx_size / qp->tx_max_frame;
-   qp->tx_index = 0;
 
if (nt->debugfs_dir) {
char debugfs_name[4];
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3.9-table] NTB: Link toggle memory leak

2013-05-17 Thread Jonghwan Choi
From: Jon Mason 

This patch looks like it should be in the 3.9-stable tree, should we apply
it?

--

From: "Jon Mason "

commit b77b2637b39ecc380bb08992380d7d48452b0872 upstream

Each link-up will allocate a new NTB receive buffer when the NTB
properties are negotiated with the remote system.  These allocations did
not check for existing buffers and thus did not free them.  Now, the
driver will check for an existing buffer and free it if not of the
correct size, before trying to alloc a new one.

Cc:  # 3.9.x: ad3e2751: ntb: off by one
Cc:  # 3.9.x: cc0f868d: NTB: fix pointer math
Cc:  # 3.9.x: 113fc505: NTB: Handle 64bit BAR
Signed-off-by: Jon Mason 
Signed-off-by: Jonghwan Choi 
---
 drivers/ntb/ntb_transport.c | 32 
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index 2258649..f5a424d 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -507,17 +507,37 @@ static void ntb_transport_setup_qp_mw(struct 
ntb_transport *nt,
qp->tx_pkts = 0;
 }
 
+static void ntb_free_mw(struct ntb_transport *nt, int num_mw)
+{
+   struct ntb_transport_mw *mw = >mw[num_mw];
+   struct pci_dev *pdev = ntb_query_pdev(nt->ndev);
+
+   if (!mw->virt_addr)
+   return;
+
+   dma_free_coherent(>dev, mw->size, mw->virt_addr, mw->dma_addr);
+   mw->virt_addr = NULL;
+}
+
 static int ntb_set_mw(struct ntb_transport *nt, int num_mw, unsigned int size)
 {
struct ntb_transport_mw *mw = >mw[num_mw];
struct pci_dev *pdev = ntb_query_pdev(nt->ndev);
 
+   /* No need to re-setup */
+   if (mw->size == ALIGN(size, 4096))
+   return 0;
+
+   if (mw->size != 0)
+   ntb_free_mw(nt, num_mw);
+
/* Alloc memory for receiving data.  Must be 4k aligned */
mw->size = ALIGN(size, 4096);
 
mw->virt_addr = dma_alloc_coherent(>dev, mw->size, >dma_addr,
   GFP_KERNEL);
if (!mw->virt_addr) {
+   mw->size = 0;
dev_err(>dev, "Unable to allocate MW buffer of size %d\n",
   (int) mw->size);
return -ENOMEM;
@@ -529,18 +549,6 @@ static int ntb_set_mw(struct ntb_transport *nt, int 
num_mw, unsigned int size)
return 0;
 }
 
-static void ntb_free_mw(struct ntb_transport *nt, int num_mw)
-{
-   struct ntb_transport_mw *mw = >mw[num_mw];
-   struct pci_dev *pdev = ntb_query_pdev(nt->ndev);
-
-   if (!mw->virt_addr)
-   return;
-
-   dma_free_coherent(>dev, mw->size, mw->virt_addr, mw->dma_addr);
-   mw->virt_addr = NULL;
-}
-
 static void ntb_qp_link_cleanup(struct work_struct *work)
 {
struct ntb_transport_qp *qp = container_of(work,
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3.9-table] NTB: Handle 64bit BAR sizes

2013-05-17 Thread Jonghwan Choi
From: Jon Mason 

This patch looks like it should be in the 3.9-stable tree, should we apply
it?

--

From: "Jon Mason "

commit 113fc505b83b2d16e820ca74fa07f99a34877b1d upstream

64bit BAR sizes are permissible with an NTB device.  To support them
various modifications and clean-ups were required, most significantly
using 2 32bit scratch pad registers for each BAR.

Also, modify the driver to allow more than 2 Memory Windows.

Cc:  # 3.9.x: ad3e2751: ntb: off by one
Cc:  # 3.9.x: cc0f868d: NTB: fix pointer math
Signed-off-by: Jon Mason 
Signed-off-by: Jonghwan Choi 
---
 drivers/ntb/ntb_hw.c|   4 +-
 drivers/ntb/ntb_transport.c | 121 ++--
 2 files changed, 75 insertions(+), 50 deletions(-)

diff --git a/drivers/ntb/ntb_hw.c b/drivers/ntb/ntb_hw.c
index 195cc51..2dacd19 100644
--- a/drivers/ntb/ntb_hw.c
+++ b/drivers/ntb/ntb_hw.c
@@ -1027,8 +1027,8 @@ static int ntb_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
ndev->mw[i].vbase =
ioremap_wc(pci_resource_start(pdev, MW_TO_BAR(i)),
   ndev->mw[i].bar_sz);
-   dev_info(>dev, "MW %d size %d\n", i,
-(u32) pci_resource_len(pdev, MW_TO_BAR(i)));
+   dev_info(>dev, "MW %d size %llu\n", i,
+pci_resource_len(pdev, MW_TO_BAR(i)));
if (!ndev->mw[i].vbase) {
dev_warn(>dev, "Cannot remap BAR %d\n",
 MW_TO_BAR(i));
diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index 676ee16..2258649 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -58,7 +58,7 @@
 #include 
 #include "ntb_hw.h"
 
-#define NTB_TRANSPORT_VERSION  2
+#define NTB_TRANSPORT_VERSION  3
 
 static unsigned int transport_mtu = 0x401E;
 module_param(transport_mtu, uint, 0644);
@@ -173,10 +173,13 @@ struct ntb_payload_header {
 
 enum {
VERSION = 0,
-   MW0_SZ,
-   MW1_SZ,
-   NUM_QPS,
QP_LINKS,
+   NUM_QPS,
+   NUM_MWS,
+   MW0_SZ_HIGH,
+   MW0_SZ_LOW,
+   MW1_SZ_HIGH,
+   MW1_SZ_LOW,
MAX_SPAD,
 };
 
@@ -526,6 +529,18 @@ static int ntb_set_mw(struct ntb_transport *nt, int 
num_mw, unsigned int size)
return 0;
 }
 
+static void ntb_free_mw(struct ntb_transport *nt, int num_mw)
+{
+   struct ntb_transport_mw *mw = >mw[num_mw];
+   struct pci_dev *pdev = ntb_query_pdev(nt->ndev);
+
+   if (!mw->virt_addr)
+   return;
+
+   dma_free_coherent(>dev, mw->size, mw->virt_addr, mw->dma_addr);
+   mw->virt_addr = NULL;
+}
+
 static void ntb_qp_link_cleanup(struct work_struct *work)
 {
struct ntb_transport_qp *qp = container_of(work,
@@ -604,25 +619,31 @@ static void ntb_transport_link_work(struct work_struct 
*work)
u32 val;
int rc, i;
 
-   /* send the local info */
-   rc = ntb_write_remote_spad(ndev, VERSION, NTB_TRANSPORT_VERSION);
-   if (rc) {
-   dev_err(>dev, "Error writing %x to remote spad %d\n",
-   0, VERSION);
-   goto out;
-   }
+   /* send the local info, in the opposite order of the way we read it */
+   for (i = 0; i < NTB_NUM_MW; i++) {
+   rc = ntb_write_remote_spad(ndev, MW0_SZ_HIGH + (i * 2),
+  ntb_get_mw_size(ndev, i) >> 32);
+   if (rc) {
+   dev_err(>dev, "Error writing %u to remote spad 
%d\n",
+   (u32)(ntb_get_mw_size(ndev, i) >> 32),
+   MW0_SZ_HIGH + (i * 2));
+   goto out;
+   }
 
-   rc = ntb_write_remote_spad(ndev, MW0_SZ, ntb_get_mw_size(ndev, 0));
-   if (rc) {
-   dev_err(>dev, "Error writing %x to remote spad %d\n",
-   (u32) ntb_get_mw_size(ndev, 0), MW0_SZ);
-   goto out;
+   rc = ntb_write_remote_spad(ndev, MW0_SZ_LOW + (i * 2),
+  (u32) ntb_get_mw_size(ndev, i));
+   if (rc) {
+   dev_err(>dev, "Error writing %u to remote spad 
%d\n",
+   (u32) ntb_get_mw_size(ndev, i),
+   MW0_SZ_LOW + (i * 2));
+   goto out;
+   }
}
 
-   rc = ntb_write_remote_spad(ndev, MW1_SZ, ntb_get_mw_size(ndev, 1));
+   rc = ntb_write_remote_spad(ndev, NUM_MWS, NTB_NUM_MW);
if (rc) {
dev_err(>dev, "Error writing %x to remote spad %d\n",
-   (u32) ntb_get_mw_size(ndev, 1), MW1_SZ);
+   NTB_NUM_MW, NUM_MWS);
goto out;
}
 
@@ -633,16 +654,10 @@ static void ntb_transport_link_work(struct work_struct 
*work)
goto out;
}
 
-   rc = ntb_read_local_spad(nt->ndev, QP_LINKS, 

[PATCH 3.9-table] NTB: fix pointer math issues

2013-05-17 Thread Jonghwan Choi
From: Dan Carpenter 

This patch looks like it should be in the 3.9-stable tree, should we apply
it?

--

From: "Dan Carpenter "

commit cc0f868d8adef7bdc12cda132654870086d766bc upstream

->remote_rx_info and ->rx_info are struct ntb_rx_info pointers.  If we
add sizeof(struct ntb_rx_info) then it goes too far.

Cc:  # 3.9.x: ad3e2751: ntb: off by one
Signed-off-by: Dan Carpenter 
Signed-off-by: Jon Mason 
Signed-off-by: Jonghwan Choi 
---
 drivers/ntb/ntb_transport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index e0bdfd7..676ee16 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -486,7 +486,7 @@ static void ntb_transport_setup_qp_mw(struct ntb_transport 
*nt,
 (qp_num / NTB_NUM_MW * rx_size);
rx_size -= sizeof(struct ntb_rx_info);
 
-   qp->rx_buff = qp->remote_rx_info + sizeof(struct ntb_rx_info);
+   qp->rx_buff = qp->remote_rx_info + 1;
qp->rx_max_frame = min(transport_mtu, rx_size);
qp->rx_max_entry = rx_size / qp->rx_max_frame;
qp->rx_index = 0;
@@ -780,7 +780,7 @@ static void ntb_transport_init_queue(struct ntb_transport 
*nt,
  (qp_num / NTB_NUM_MW * tx_size);
tx_size -= sizeof(struct ntb_rx_info);
 
-   qp->tx_mw = qp->rx_info + sizeof(struct ntb_rx_info);
+   qp->tx_mw = qp->rx_info + 1;
qp->tx_max_frame = min(transport_mtu, tx_size);
qp->tx_max_entry = tx_size / qp->tx_max_frame;
qp->tx_index = 0;
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   5   6   7   8   9   10   >