Re: [PATCH 0/8] qcom: spmi/ssbi gpio: correct gpio hogging

2019-04-26 Thread Bjorn Andersson
On Tue 05 Mar 16:53 PST 2019, Brian Masney wrote:

> Here are some patches that fix gpio hogging for all boards that use
> spmi-gpio and ssbi-gpio. These depend on the following two patches
> that were merged in 4.20-rc1:
> 
> commit 149a96047237 ("pinctrl: qcom: spmi-gpio: fix gpio-hog related
> boot issues")
> 
> commit 7ed078557738 ("pinctrl: qcom: ssbi-gpio: fix gpio-hog related
> boot issues")
> 
> I've already fixed pm8941 for the Nexus 5 and that fix is queued to go
> into v5.1 during this merge window:
> 
> https://lore.kernel.org/lkml/20181101001149.13453-7-masn...@onstation.org/
> 
> Andy: You may want to consider submitting these post rc1 as a fix for
> v5.1 and possibly marking these for stable.
> 
> Brian Masney (8):
>   ARM: dts: qcom: apq8064: add gpio-ranges
>   ARM: dts: qcom: mdm9615: add gpio-ranges
>   ARM: dts: qcom: msm8660: add gpio-ranges
>   ARM: dts: qcom: pma8084: add gpio-ranges

Looks like I missed the ARM patches before. All 8 picked up now, with
Linus' r-b.

Thanks,
Bjorn

>   arm64: dts: qcom: pm8005: add gpio-ranges
>   arm64: dts: qcom: pm8998: add gpio-ranges
>   arm64: dts: qcom: pmi8994: add gpio-ranges
>   arm64: dts: qcom: pmi8998: add gpio-ranges
> 
>  arch/arm/boot/dts/qcom-apq8064.dtsi   | 1 +
>  arch/arm/boot/dts/qcom-mdm9615.dtsi   | 1 +
>  arch/arm/boot/dts/qcom-msm8660.dtsi   | 1 +
>  arch/arm/boot/dts/qcom-pma8084.dtsi   | 1 +
>  arch/arm64/boot/dts/qcom/pm8005.dtsi  | 1 +
>  arch/arm64/boot/dts/qcom/pm8998.dtsi  | 1 +
>  arch/arm64/boot/dts/qcom/pmi8994.dtsi | 1 +
>  arch/arm64/boot/dts/qcom/pmi8998.dtsi | 1 +
>  8 files changed, 8 insertions(+)
> 
> -- 
> 2.20.1
> 


Re: [PATCH] arm64: dts: pms405: increase s3 max voltage

2019-04-26 Thread Bjorn Andersson
On Thu 25 Apr 05:18 PDT 2019, Niklas Cassel wrote:

> The commit description should be: arm64: dts: qcom: qcs404-evb:
> 
> (The s3 regulator node moved during upstreaming.)
> 
> Andy/Bjorn, could you please fix this before applying?
> 

Picked up with the subject change.

Thanks,
Bjorn

> Kind regards,
> Niklas
> 
> On Thu, Apr 25, 2019 at 01:34:29PM +0200, Niklas Cassel wrote:
> > Increase s3 max voltage in accordance to QCS404 CPR Fusing Guide Rev 6.0
> > 
> > Signed-off-by: Niklas Cassel 
> > ---
> >  arch/arm64/boot/dts/qcom/qcs404-evb.dtsi | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/arm64/boot/dts/qcom/qcs404-evb.dtsi 
> > b/arch/arm64/boot/dts/qcom/qcs404-evb.dtsi
> > index 2c3127167e3c..6910fc663fe1 100644
> > --- a/arch/arm64/boot/dts/qcom/qcs404-evb.dtsi
> > +++ b/arch/arm64/boot/dts/qcom/qcs404-evb.dtsi
> > @@ -64,7 +64,7 @@
> > regulator-boot-on;
> > regulator-name = "vdd_apc";
> > regulator-min-microvolt = <1048000>;
> > -   regulator-max-microvolt = <1352000>;
> > +   regulator-max-microvolt = <1384000>;
> > };
> >  };
> >  
> > -- 
> > 2.20.1
> > 


Re: [PATCH] arm64: dts: qcom: qcs404-evb: fix l3 min voltage

2019-04-26 Thread Bjorn Andersson
On Thu 25 Apr 05:34 PDT 2019, Niklas Cassel wrote:

> The current l3 min voltage level is not supported by
> the regulator (the voltage is not a multiple of the regulator step size),
> so a driver requesting this exact voltage would fail, see discussion in:
> https://patchwork.kernel.org/comment/22461199/
> 
> It was agreed upon to set a min voltage level that is a multiple of the
> regulator step size.
> 
> There was actually a patch sent that did this:
> https://patchwork.kernel.org/patch/10819313/
> 
> However, the commit 331ab98f8c4a ("arm64: dts: qcom: qcs404:
> Fix voltages l3") that was applied is not identical to that patch.
> 
> Signed-off-by: Niklas Cassel 

Thanks for spotting and sorting this out, picked up.

Regards,
Bjorn

> ---
>  arch/arm64/boot/dts/qcom/qcs404-evb.dtsi | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/boot/dts/qcom/qcs404-evb.dtsi 
> b/arch/arm64/boot/dts/qcom/qcs404-evb.dtsi
> index 6910fc663fe1..9a7d930dcd23 100644
> --- a/arch/arm64/boot/dts/qcom/qcs404-evb.dtsi
> +++ b/arch/arm64/boot/dts/qcom/qcs404-evb.dtsi
> @@ -118,7 +118,7 @@
>   };
>  
>   vreg_l3_1p05: l3 {
> - regulator-min-microvolt = <105>;
> + regulator-min-microvolt = <1048000>;
>   regulator-max-microvolt = <116>;
>   };
>  
> -- 
> 2.20.1
> 


Re: [PATCH v3 3/3] arm64: dts: qcom: Add Lenovo Miix 630

2019-04-26 Thread Bjorn Andersson
On Mon 15 Apr 09:11 PDT 2019, Jeffrey Hugo wrote:
> diff --git a/arch/arm64/boot/dts/qcom/msm8998-clamshell.dtsi 
> b/arch/arm64/boot/dts/qcom/msm8998-clamshell.dtsi
[..]
> + thermal-zones {
> + battery-thermal {
> + polling-delay-passive = <250>;
> + polling-delay = <1000>;
> +
> + thermal-sensors = < 0>;

I guess you inherited the battery and skin thermal nodes from my MTP
dts. Unfortunately after talking to Amit I think I got these wrong, and
they should be _adc 0 and 5 instead.

Can you confirm this?

> +
> + trips {
> + battery_crit: trip0 {
> + temperature = <6>;
> + hysteresis = <2000>;
> + type = "critical";
> + };
> + };
> + };

Regards,
Bjorn


Re: [PATCHv1 0/2] qcom: pms405: adc fixes

2019-04-26 Thread Bjorn Andersson
On Wed 20 Mar 06:39 PDT 2019, Amit Kucheria wrote:

> A couple of fixes to the adc node in PMS405 to get thermistors to work
> correctly.
> 
> Amit Kucheria (2):
>   arm64: dts: qcom: pms405: calibrate the VADC correctly
>   arm64: dts: qcom: pms405: Rename adc outputs as per schematics
> 

Picked up the pair

Thanks,
Bjorn

>  arch/arm64/boot/dts/qcom/pms405.dtsi | 20 +---
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> -- 
> 2.17.1
> 


[PATCH RFC] staging: fieldbus: anybus-s: use proper type for wait_for_completion_timeout

2019-04-26 Thread Nicholas Mc Guire
wait_for_completion_timeout() returns unsigned long (0 on timeout or
remaining jiffies) not int. thus there is no negative case to check for 
here.

Signed-off-by: Nicholas Mc Guire 
---

Problem located with experimental API conformance checking cocci script

Q: It is not really clear if the proposed fix is the right thing here or if
   this should not be using wait_for_completion_interruptible - which would
   return -ERESTARTSYS on interruption. Someone that knows the details of
   this driver would need to check what condition should initiate the
   goto err_reset; which was actually unreachable in the current code.

Patch was compile-tested with. x86_64_defconfig + FIELDBUS_DEV=m,
HMS_ANYBUSS_BUS=m
(some unrelated sparse warnings (cast to restricted __be16))

Patch is against 5.1-rc6 (localversion-next is next-20190426)

 drivers/staging/fieldbus/anybuss/host.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/fieldbus/anybuss/host.c 
b/drivers/staging/fieldbus/anybuss/host.c
index e34d424..c52d715 100644
--- a/drivers/staging/fieldbus/anybuss/host.c
+++ b/drivers/staging/fieldbus/anybuss/host.c
@@ -1263,6 +1263,7 @@ anybuss_host_common_probe(struct device *dev,
  const struct anybuss_ops *ops)
 {
int ret, i;
+   unsigned long time_left;
u8 val[4];
u16 fieldbus_type;
struct anybuss_host *cd;
@@ -1325,11 +1326,9 @@ anybuss_host_common_probe(struct device *dev,
 *   interrupt came in: ready to go !
 */
reset_deassert(cd);
-   ret = wait_for_completion_timeout(>card_boot, TIMEOUT);
-   if (ret == 0)
+   time_left = wait_for_completion_timeout(>card_boot, TIMEOUT);
+   if (time_left == 0)
ret = -ETIMEDOUT;
-   if (ret < 0)
-   goto err_reset;
/*
 * according to the anybus docs, we're allowed to read these
 * without handshaking / reserving the area
-- 
2.1.4



Re: [PATCH v2 1/1] MAINTAINERS: fix typo in file name

2019-04-26 Thread Bjorn Andersson
On Fri 29 Mar 01:47 PDT 2019, Amit Kucheria wrote:

> Commit e31f941cf977 ("MAINTAINERS: update list of qcom drivers") had a
> typo in the filename, replace the underscore with dash.
> 
> Fixes: e31f941cf977 ("MAINTAINERS: update list of qcom drivers")
> Reported-by: Joe Perches 
> Signed-off-by: Amit Kucheria 
> Reviewed-by: Vinod Koul 
> Reviewed-by: Mukesh Ojha 

Picked up

Thanks,
Bjorn

> ---
>  MAINTAINERS | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 3e5a5d263f29..d2c5852a3c8d 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -2007,7 +2007,7 @@ F:  drivers/i2c/busses/i2c-qup.c
>  F:   drivers/i2c/busses/i2c-qcom-geni.c
>  F:   drivers/mfd/ssbi.c
>  F:   drivers/mmc/host/mmci_qcom*
> -F:   drivers/mmc/host/sdhci_msm.c
> +F:   drivers/mmc/host/sdhci-msm.c
>  F:   drivers/pci/controller/dwc/pcie-qcom.c
>  F:   drivers/phy/qualcomm/
>  F:   drivers/power/*/msm*
> -- 
> 2.17.1
> 


Re: [RFC PATCH v2 00/17] Core scheduling v2

2019-04-26 Thread Aubrey Li
On Thu, Apr 25, 2019 at 5:55 PM Ingo Molnar  wrote:
> * Aubrey Li  wrote:
> > On Wed, Apr 24, 2019 at 10:00 PM Julien Desfossez
> >  wrote:
> > >
> > > On 24-Apr-2019 09:13:10 PM, Aubrey Li wrote:
> > > > On Wed, Apr 24, 2019 at 12:18 AM Vineeth Remanan Pillai
> > > >  wrote:
> > > > >
> > > > > Second iteration of the core-scheduling feature.
> > > > >
> > > > > This version fixes apparent bugs and performance issues in v1. This
> > > > > doesn't fully address the issue of core sharing between processes
> > > > > with different tags. Core sharing still happens 1% to 5% of the time
> > > > > based on the nature of workload and timing of the runnable processes.
> > > > >
> > > > > Changes in v2
> > > > > -
> > > > > - rebased on mainline commit: 6d906f99817951e2257d577656899da02bb33105
> > > >
> > > > Thanks to post v2, based on this version, here is my benchmarks result.
> > > >
> > > > Environment setup
> > > > --
> > > > Skylake server, 2 numa nodes, 104 CPUs (HT on)
> > > > cgroup1 workload, sysbench (CPU intensive non AVX workload)
> > > > cgroup2 workload, gemmbench (AVX512 workload)
> > > >
> > > > Case 1: task number < CPU num
> > > > 
> > > > 36 sysbench threads in cgroup1
> > > > 36 gemmbench threads in cgroup2
> > > >
> > > > core sched off:
> > > > - sysbench 95th percentile latency(ms): avg = 4.952, stddev = 0.55342
> > > > core sched on:
> > > > - sysbench 95th percentile latency(ms): avg = 3.549, stddev = 0.04449
> > > >
> > > > Due to core cookie matching, sysbench tasks won't be affect by AVX512
> > > > tasks, latency has ~28% improvement!!!
> > > >
> > > > Case 2: task number > CPU number
> > > > -
> > > > 72 sysbench threads in cgroup1
> > > > 72 gemmbench threads in cgroup2
> > > >
> > > > core sched off:
> > > > - sysbench 95th percentile latency(ms): avg = 11.914, stddev = 3.259
> > > > core sched on:
> > > > - sysbench 95th percentile latency(ms): avg = 13.289, stddev = 4.863
> > > >
> > > > So not only power, now security and performance is a pair of 
> > > > contradictions.
> > > > Due to core cookie not matching and forced idle introduced, latency has 
> > > > ~12%
> > > > regression.
> > > >
> > > > Any comments?
> > >
> > > Would it be possible to post the results with HT off as well ?
> >
> > What's the point here to turn HT off? The latency is sensitive to the
> > relationship
> > between the task number and CPU number. Usually less CPU number, more run
> > queue wait time, and worse result.
>
> HT-off numbers are mandatory: turning HT off is by far the simplest way
> to solve the security bugs in these CPUs.
>
> Any core-scheduling solution *must* perform better than HT-off for all
> relevant workloads, otherwise what's the point?
>
I have the same environment setup above, for nosmt cases, I used
/sys interface Thomas mentioned, below is the result:

NA/AVX  baseline(std%)  coresched(std%) +/- nosmt(std%) +/-
1/1  1.987( 1.97%)   2.043( 1.76%) -2.84% 1.985( 1.70%)  0.12%
NA/AVX  baseline(std%)  coresched(std%) +/- nosmt(std%) +/-
2/2  2.074( 1.16%)   2.057( 2.09%)  0.81% 2.072( 0.77%)  0.10%
NA/AVX  baseline(std%)  coresched(std%) +/- nosmt(std%) +/-
4/4  2.140( 0.00%)   2.138( 0.49%)  0.09% 2.137( 0.89%)  0.12%
NA/AVX  baseline(std%)  coresched(std%) +/- nosmt(std%) +/-
8/8  2.140( 0.00%)   2.144( 0.53%) -0.17% 2.140( 0.00%)  0.00%
NA/AVX  baseline(std%)  coresched(std%) +/- nosmt(std%) +/-
16/162.361( 2.99%)   2.369( 2.65%) -0.30% 2.406( 2.53%) -1.87%
NA/AVX  baseline(std%)  coresched(std%) +/- nosmt(std%) +/-
32/325.032( 8.68%)   3.485( 0.49%) 30.76% 6.002(27.21%) -19.27%
NA/AVX  baseline(std%)  coresched(std%) +/- nosmt(std%) +/-
64/647.577(34.35%)   3.972(23.18%) 47.57% 18.235(14.14%) -140.68%
NA/AVX  baseline(std%)  coresched(std%) +/- nosmt(std%) +/-
128/128 24.639(14.28%)  27.440( 8.24%) -11.37% 34.746( 6.92%) -41.02%
NA/AVX  baseline(std%)  coresched(std%) +/- nosmt(std%) +/-
256/256 38.797( 8.59%)  44.067(16.20%) -13.58% 42.536( 7.57%) -9.64%

Thanks,
-Aubrey


[PATCH 4/4] serial: 8250-mtk: modify uart DMA rx

2019-04-26 Thread Long Cheng
Modify uart rx and complete for DMA.

Signed-off-by: Long Cheng 
---
 drivers/tty/serial/8250/8250_mtk.c |   53 
 1 file changed, 23 insertions(+), 30 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_mtk.c 
b/drivers/tty/serial/8250/8250_mtk.c
index c1fdbc0..04081a6 100644
--- a/drivers/tty/serial/8250/8250_mtk.c
+++ b/drivers/tty/serial/8250/8250_mtk.c
@@ -30,7 +30,6 @@
 #define MTK_UART_DMA_EN_TX 0x2
 #define MTK_UART_DMA_EN_RX 0x5
 
-#define MTK_UART_TX_SIZE   UART_XMIT_SIZE
 #define MTK_UART_RX_SIZE   0x8000
 #define MTK_UART_TX_TRIGGER1
 #define MTK_UART_RX_TRIGGERMTK_UART_RX_SIZE
@@ -64,28 +63,30 @@ static void mtk8250_dma_rx_complete(void *param)
struct mtk8250_data *data = up->port.private_data;
struct tty_port *tty_port = >port.state->port;
struct dma_tx_state state;
+   int copied, cnt, tmp;
unsigned char *ptr;
-   int copied;
 
-   dma_sync_single_for_cpu(dma->rxchan->device->dev, dma->rx_addr,
-   dma->rx_size, DMA_FROM_DEVICE);
+   if (data->rx_status == DMA_RX_SHUTDOWN)
+   return;
 
dmaengine_tx_status(dma->rxchan, dma->rx_cookie, );
+   cnt = dma->rx_size - state.residue;
+   tmp = cnt;
 
-   if (data->rx_status == DMA_RX_SHUTDOWN)
-   return;
+   if ((data->rx_pos + cnt) > dma->rx_size)
+   tmp = dma->rx_size - data->rx_pos;
 
-   if ((data->rx_pos + state.residue) <= dma->rx_size) {
-   ptr = (unsigned char *)(data->rx_pos + dma->rx_buf);
-   copied = tty_insert_flip_string(tty_port, ptr, state.residue);
-   } else {
-   ptr = (unsigned char *)(data->rx_pos + dma->rx_buf);
-   copied = tty_insert_flip_string(tty_port, ptr,
-   dma->rx_size - data->rx_pos);
+   ptr = (unsigned char *)(data->rx_pos + dma->rx_buf);
+   copied = tty_insert_flip_string(tty_port, ptr, tmp);
+   data->rx_pos += tmp;
+
+   if (cnt > tmp) {
ptr = (unsigned char *)(dma->rx_buf);
-   copied += tty_insert_flip_string(tty_port, ptr,
-   data->rx_pos + state.residue - dma->rx_size);
+   tmp = cnt - tmp;
+   copied += tty_insert_flip_string(tty_port, ptr, tmp);
+   data->rx_pos = tmp;
}
+
up->port.icount.rx += copied;
 
tty_flip_buffer_push(tty_port);
@@ -96,9 +97,7 @@ static void mtk8250_dma_rx_complete(void *param)
 static void mtk8250_rx_dma(struct uart_8250_port *up)
 {
struct uart_8250_dma *dma = up->dma;
-   struct mtk8250_data *data = up->port.private_data;
struct dma_async_tx_descriptor  *desc;
-   struct dma_tx_state  state;
 
desc = dmaengine_prep_slave_single(dma->rxchan, dma->rx_addr,
   dma->rx_size, DMA_DEV_TO_MEM,
@@ -113,12 +112,6 @@ static void mtk8250_rx_dma(struct uart_8250_port *up)
 
dma->rx_cookie = dmaengine_submit(desc);
 
-   dmaengine_tx_status(dma->rxchan, dma->rx_cookie, );
-   data->rx_pos = state.residue;
-
-   dma_sync_single_for_device(dma->rxchan->device->dev, dma->rx_addr,
-  dma->rx_size, DMA_FROM_DEVICE);
-
dma_async_issue_pending(dma->rxchan);
 }
 
@@ -131,13 +124,13 @@ static void mtk8250_dma_enable(struct uart_8250_port *up)
if (data->rx_status != DMA_RX_START)
return;
 
-   dma->rxconf.direction   = DMA_DEV_TO_MEM;
-   dma->rxconf.src_addr_width  = dma->rx_size / 1024;
-   dma->rxconf.src_addr= dma->rx_addr;
+   dma->rxconf.direction   = DMA_DEV_TO_MEM;
+   dma->rxconf.src_port_window_size= dma->rx_size;
+   dma->rxconf.src_addr= dma->rx_addr;
 
-   dma->txconf.direction   = DMA_MEM_TO_DEV;
-   dma->txconf.dst_addr_width  = MTK_UART_TX_SIZE / 1024;
-   dma->txconf.dst_addr= dma->tx_addr;
+   dma->txconf.direction   = DMA_MEM_TO_DEV;
+   dma->txconf.dst_port_window_size= UART_XMIT_SIZE;
+   dma->txconf.dst_addr= dma->tx_addr;
 
serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR |
UART_FCR_CLEAR_XMIT);
@@ -217,7 +210,7 @@ static void mtk8250_shutdown(struct uart_port *port)
 * Mediatek UARTs use an extra highspeed register (UART_MTK_HIGHS)
 *
 * We need to recalcualte the quot register, as the claculation depends
-* on the vaule in the highspeed register.
+* on the value in the highspeed register.
 *
 * Some baudrates are not supported by the chip, so we use the next
 * lower rate supported and update termios c_flag.
-- 
1.7.9.5



[PATCH 1/4] dmaengine: mediatek: Add MediaTek UART APDMA support

2019-04-26 Thread Long Cheng
Add 8250 UART APDMA to support MediaTek UART. If MediaTek UART is
enabled by SERIAL_8250_MT6577, and we can enable this driver to offload
the UART device moving bytes.

Signed-off-by: Long Cheng 
Signed-off-by: Sean Wang 
---
 drivers/dma/mediatek/Kconfig  |   11 +
 drivers/dma/mediatek/Makefile |1 +
 drivers/dma/mediatek/mtk-uart-apdma.c |  666 +
 3 files changed, 678 insertions(+)
 create mode 100644 drivers/dma/mediatek/mtk-uart-apdma.c

diff --git a/drivers/dma/mediatek/Kconfig b/drivers/dma/mediatek/Kconfig
index 680fc05..ac49eb6 100644
--- a/drivers/dma/mediatek/Kconfig
+++ b/drivers/dma/mediatek/Kconfig
@@ -24,3 +24,14 @@ config MTK_CQDMA
 
  This controller provides the channels which is dedicated to
  memory-to-memory transfer to offload from CPU.
+
+config MTK_UART_APDMA
+   tristate "MediaTek SoCs APDMA support for UART"
+   depends on OF && SERIAL_8250_MT6577
+   select DMA_ENGINE
+   select DMA_VIRTUAL_CHANNELS
+   help
+ Support for the UART DMA engine found on MediaTek MTK SoCs.
+ When SERIAL_8250_MT6577 is enabled, and if you want to use DMA,
+ you can enable the config. The DMA engine can only be used
+ with MediaTek SoCs.
diff --git a/drivers/dma/mediatek/Makefile b/drivers/dma/mediatek/Makefile
index 41bb381..61a6d29 100644
--- a/drivers/dma/mediatek/Makefile
+++ b/drivers/dma/mediatek/Makefile
@@ -1,2 +1,3 @@
+obj-$(CONFIG_MTK_UART_APDMA) += mtk-uart-apdma.o
 obj-$(CONFIG_MTK_HSDMA) += mtk-hsdma.o
 obj-$(CONFIG_MTK_CQDMA) += mtk-cqdma.o
diff --git a/drivers/dma/mediatek/mtk-uart-apdma.c 
b/drivers/dma/mediatek/mtk-uart-apdma.c
new file mode 100644
index 000..546995c
--- /dev/null
+++ b/drivers/dma/mediatek/mtk-uart-apdma.c
@@ -0,0 +1,666 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * MediaTek UART APDMA driver.
+ *
+ * Copyright (c) 2019 MediaTek Inc.
+ * Author: Long Cheng 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../virt-dma.h"
+
+/* The default number of virtual channel */
+#define MTK_UART_APDMA_NR_VCHANS   8
+
+#define VFF_EN_B   BIT(0)
+#define VFF_STOP_B BIT(0)
+#define VFF_FLUSH_BBIT(0)
+#define VFF_4G_EN_BBIT(0)
+/* rx valid size >=  vff thre */
+#define VFF_RX_INT_EN_B(BIT(0) | BIT(1))
+/* tx left size >= vff thre */
+#define VFF_TX_INT_EN_BBIT(0)
+#define VFF_WARM_RST_B BIT(0)
+#define VFF_RX_INT_CLR_B   (BIT(0) | BIT(1))
+#define VFF_TX_INT_CLR_B   0
+#define VFF_STOP_CLR_B 0
+#define VFF_EN_CLR_B   0
+#define VFF_INT_EN_CLR_B   0
+#define VFF_4G_SUPPORT_CLR_B   0
+
+/*
+ * interrupt trigger level for tx
+ * if threshold is n, no polling is required to start tx.
+ * otherwise need polling VFF_FLUSH.
+ */
+#define VFF_TX_THRE(n) (n)
+/* interrupt trigger level for rx */
+#define VFF_RX_THRE(n) ((n) * 3 / 4)
+
+#define VFF_RING_SIZE  0x
+/* invert this bit when wrap ring head again */
+#define VFF_RING_WRAP  0x1
+
+#define VFF_INT_FLAG   0x00
+#define VFF_INT_EN 0x04
+#define VFF_EN 0x08
+#define VFF_RST0x0c
+#define VFF_STOP   0x10
+#define VFF_FLUSH  0x14
+#define VFF_ADDR   0x1c
+#define VFF_LEN0x24
+#define VFF_THRE   0x28
+#define VFF_WPT0x2c
+#define VFF_RPT0x30
+/* TX: the buffer size HW can read. RX: the buffer size SW can read. */
+#define VFF_VALID_SIZE 0x3c
+/* TX: the buffer size SW can write. RX: the buffer size HW can write. */
+#define VFF_LEFT_SIZE  0x40
+#define VFF_DEBUG_STATUS   0x50
+#define VFF_4G_SUPPORT 0x54
+
+struct mtk_uart_apdmadev {
+   struct dma_device ddev;
+   struct clk *clk;
+   bool support_33bits;
+   unsigned int dma_requests;
+};
+
+struct mtk_uart_apdma_desc {
+   struct virt_dma_desc vd;
+
+   dma_addr_t addr;
+   unsigned int avail_len;
+};
+
+struct mtk_chan {
+   struct virt_dma_chan vc;
+   struct dma_slave_config cfg;
+   struct mtk_uart_apdma_desc *desc;
+   enum dma_transfer_direction dir;
+
+   void __iomem *base;
+   unsigned int irq;
+
+   unsigned int rx_status;
+};
+
+static inline struct mtk_uart_apdmadev *
+to_mtk_uart_apdma_dev(struct dma_device *d)
+{
+   return container_of(d, struct mtk_uart_apdmadev, ddev);
+}
+
+static inline struct mtk_chan *to_mtk_uart_apdma_chan(struct dma_chan *c)
+{
+   return container_of(c, struct mtk_chan, vc.chan);
+}
+
+static inline struct mtk_uart_apdma_desc *to_mtk_uart_apdma_desc
+   (struct dma_async_tx_descriptor *t)
+{
+   return container_of(t, struct mtk_uart_apdma_desc, vd.tx);
+}
+
+static 

Suggestion to the 100,000 Unemployed Persons in Singapore

2019-04-26 Thread Turritopsis Dohrnii Teo En Ming
Subject/Topic: Suggestion to the 100,000 Unemployed Persons in Singapore

For Immediate World-Wide Release 26th April 2019 Singapore Time

I would like to suggest the 100,000 unemployed persons in Singapore to
apply for refugee status in developed countries outside of Singapore.

I believe many or most of the 100,000 unemployed persons in Singapore
are TARGETED INDIVIDUALS (TIs).

-BEGIN EMAIL SIGNATURE-

The Gospel for all Targeted Individuals (TIs):

[The New York Times] Microwave Weapons Are Prime Suspect in Ills of
U.S. Embassy Workers

Link: 
https://www.nytimes.com/2018/09/01/science/sonic-attack-cuba-microwave.html



Singaporean Mr. Turritopsis Dohrnii Teo En Ming's Academic
Qualifications as at 14 Feb 2019

[1] https://tdtemcerts.wordpress.com/

[2] https://tdtemcerts.blogspot.sg/

[3] https://www.scribd.com/user/270125049/Teo-En-Ming

-END EMAIL SIGNATURE-


[PATCH 3/4] dt-bindings: dma: uart: rename binding

2019-04-26 Thread Long Cheng
The filename matches mtk-uart-apdma.c.
So using "mtk-uart-apdma.txt" should be better.
And add some property.

Signed-off-by: Long Cheng 
---
 .../devicetree/bindings/dma/8250_mtk_dma.txt   |   33 
 .../devicetree/bindings/dma/mtk-uart-apdma.txt |   55 
 2 files changed, 55 insertions(+), 33 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/dma/8250_mtk_dma.txt
 create mode 100644 Documentation/devicetree/bindings/dma/mtk-uart-apdma.txt

diff --git a/Documentation/devicetree/bindings/dma/8250_mtk_dma.txt 
b/Documentation/devicetree/bindings/dma/8250_mtk_dma.txt
deleted file mode 100644
index 3fe0961..000
--- a/Documentation/devicetree/bindings/dma/8250_mtk_dma.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-* Mediatek UART APDMA Controller
-
-Required properties:
-- compatible should contain:
-  * "mediatek,mt2712-uart-dma" for MT2712 compatible APDMA
-  * "mediatek,mt6577-uart-dma" for MT6577 and all of the above
-
-- reg: The base address of the APDMA register bank.
-
-- interrupts: A single interrupt specifier.
-
-- clocks : Must contain an entry for each entry in clock-names.
-  See ../clocks/clock-bindings.txt for details.
-- clock-names: The APDMA clock for register accesses
-
-Examples:
-
-   apdma: dma-controller@11000380 {
-   compatible = "mediatek,mt2712-uart-dma";
-   reg = <0 0x11000380 0 0x400>;
-   interrupts = ,
-,
-,
-,
-,
-,
-,
-;
-   clocks = < CLK_PERI_AP_DMA>;
-   clock-names = "apdma";
-   #dma-cells = <1>;
-   };
-
diff --git a/Documentation/devicetree/bindings/dma/mtk-uart-apdma.txt 
b/Documentation/devicetree/bindings/dma/mtk-uart-apdma.txt
new file mode 100644
index 000..e0424b3
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/mtk-uart-apdma.txt
@@ -0,0 +1,55 @@
+* Mediatek UART APDMA Controller
+
+Required properties:
+- compatible should contain:
+  * "mediatek,mt2712-uart-dma" for MT2712 compatible APDMA
+  * "mediatek,mt6577-uart-dma" for MT6577 and all of the above
+
+- reg: The base address of the APDMA register bank.
+
+- interrupts: A single interrupt specifier.
+ One interrupt per dma-requests, or 8 if no dma-requests property is present
+
+- dma-requests: The number of DMA channels
+
+- clocks : Must contain an entry for each entry in clock-names.
+  See ../clocks/clock-bindings.txt for details.
+- clock-names: The APDMA clock for register accesses
+
+- mediatek,dma-33bits: Present if the DMA requires support
+
+Examples:
+
+   apdma: dma-controller@11000400 {
+   compatible = "mediatek,mt2712-uart-dma";
+   reg = <0 0x11000400 0 0x80>,
+ <0 0x11000480 0 0x80>,
+ <0 0x11000500 0 0x80>,
+ <0 0x11000580 0 0x80>,
+ <0 0x11000600 0 0x80>,
+ <0 0x11000680 0 0x80>,
+ <0 0x11000700 0 0x80>,
+ <0 0x11000780 0 0x80>,
+ <0 0x11000800 0 0x80>,
+ <0 0x11000880 0 0x80>,
+ <0 0x11000900 0 0x80>,
+ <0 0x11000980 0 0x80>;
+   interrupts = ,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+;
+   dma-requests = <12>;
+   clocks = < CLK_PERI_AP_DMA>;
+   clock-names = "apdma";
+   mediatek,dma-33bits;
+   #dma-cells = <1>;
+   };
+
-- 
1.7.9.5



[PATCH v12 0/4] add uart DMA function

2019-04-26 Thread Long Cheng
In Mediatek SOCs, the uart can support DMA function.
Base on DMA engine formwork, we add the DMA code to support uart. And put the 
code under drivers/dma/mediatek.

This series contains document bindings, Kconfig to control the function enable 
or not,
device tree including interrupt and dma device node, the code of UART DMA

Changes compared to v11
-modify TX/RX
-pause function by software
Changes compared to v10
-modify DMA tx status function
-modify 8250_mtk for DMA rx
-add notes to binding Document.
Changes compared to v9
-rename dt-bindings file
-remove direction from device_config
-simplified code
Changes compared to v8
-revise missing items
Changes compared to v7:
-modify apdma uart tx
Changes compared to v6:
-Correct spelling
Changes compared to v5:
-move 'requst irqs' to alloc channel
-remove tasklet.
Changes compared to v4:
-modify Kconfig depends on.
Changes compared to v3:
-fix CONFIG_PM, will cause build fail
Changes compared to v2:
-remove unimportant parameters
-instead of cookie, use APIs of virtual channel.
-use of_dma_xlate_by_chan_id.
Changes compared to v1:
-mian revised file, 8250_mtk_dma.c
--parameters renamed for standard
--remove atomic operation

Long Cheng (4):
  dmaengine: mediatek: Add MediaTek UART APDMA support
  arm: dts: mt2712: add uart APDMA to device tree
  dt-bindings: dma: uart: rename binding
  serial: 8250-mtk: modify uart DMA rx

 .../devicetree/bindings/dma/8250_mtk_dma.txt   |   33 -
 .../devicetree/bindings/dma/mtk-uart-apdma.txt |   55 ++
 arch/arm64/boot/dts/mediatek/mt2712e.dtsi  |   51 ++
 drivers/dma/mediatek/Kconfig   |   11 +
 drivers/dma/mediatek/Makefile  |1 +
 drivers/dma/mediatek/mtk-uart-apdma.c  |  666 
 drivers/tty/serial/8250/8250_mtk.c |   53 +-
 7 files changed, 807 insertions(+), 63 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/dma/8250_mtk_dma.txt
 create mode 100644 Documentation/devicetree/bindings/dma/mtk-uart-apdma.txt
 create mode 100644 drivers/dma/mediatek/mtk-uart-apdma.c

-- 
1.7.9.5




[PATCH 2/4] arm: dts: mt2712: add uart APDMA to device tree

2019-04-26 Thread Long Cheng
1. add uart APDMA controller device node
2. add uart 0/1/2/3/4/5 DMA function

Signed-off-by: Long Cheng 
---
 arch/arm64/boot/dts/mediatek/mt2712e.dtsi |   51 +
 1 file changed, 51 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi 
b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi
index 976d92a..f1e419e 100644
--- a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi
@@ -300,6 +300,9 @@
interrupts = ;
clocks = <_clk>, <_clk>;
clock-names = "baud", "bus";
+   dmas = < 10
+11>;
+   dma-names = "tx", "rx";
status = "disabled";
};
 
@@ -369,6 +372,39 @@
 (GIC_CPU_MASK_RAW(0x13) | IRQ_TYPE_LEVEL_HIGH)>;
};
 
+   apdma: dma-controller@11000400 {
+   compatible = "mediatek,mt2712-uart-dma",
+"mediatek,mt6577-uart-dma";
+   reg = <0 0x11000400 0 0x80>,
+ <0 0x11000480 0 0x80>,
+ <0 0x11000500 0 0x80>,
+ <0 0x11000580 0 0x80>,
+ <0 0x11000600 0 0x80>,
+ <0 0x11000680 0 0x80>,
+ <0 0x11000700 0 0x80>,
+ <0 0x11000780 0 0x80>,
+ <0 0x11000800 0 0x80>,
+ <0 0x11000880 0 0x80>,
+ <0 0x11000900 0 0x80>,
+ <0 0x11000980 0 0x80>;
+   interrupts = ,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+,
+;
+   dma-requests = <12>;
+   clocks = < CLK_PERI_AP_DMA>;
+   clock-names = "apdma";
+   #dma-cells = <1>;
+   };
+
auxadc: adc@11001000 {
compatible = "mediatek,mt2712-auxadc";
reg = <0 0x11001000 0 0x1000>;
@@ -385,6 +421,9 @@
interrupts = ;
clocks = <_clk>, <_clk>;
clock-names = "baud", "bus";
+   dmas = < 0
+1>;
+   dma-names = "tx", "rx";
status = "disabled";
};
 
@@ -395,6 +434,9 @@
interrupts = ;
clocks = <_clk>, <_clk>;
clock-names = "baud", "bus";
+   dmas = < 2
+3>;
+   dma-names = "tx", "rx";
status = "disabled";
};
 
@@ -405,6 +447,9 @@
interrupts = ;
clocks = <_clk>, <_clk>;
clock-names = "baud", "bus";
+   dmas = < 4
+5>;
+   dma-names = "tx", "rx";
status = "disabled";
};
 
@@ -415,6 +460,9 @@
interrupts = ;
clocks = <_clk>, <_clk>;
clock-names = "baud", "bus";
+   dmas = < 6
+7>;
+   dma-names = "tx", "rx";
status = "disabled";
};
 
@@ -629,6 +677,9 @@
interrupts = ;
clocks = <_clk>, <_clk>;
clock-names = "baud", "bus";
+   dmas = < 8
+9>;
+   dma-names = "tx", "rx";
status = "disabled";
};
 
-- 
1.7.9.5



[PATCH 2/5] kbuild: move Documentation to vmlinux-alldirs

2019-04-26 Thread Masahiro Yamada
A minor code cleanup.

Signed-off-by: Masahiro Yamada 
---

 Makefile | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 251ded5..334ef8a 100644
--- a/Makefile
+++ b/Makefile
@@ -988,8 +988,9 @@ vmlinux-dirs:= $(patsubst %/,%,$(filter %/, 
$(init-y) $(init-m) \
 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
 $(net-y) $(net-m) $(libs-y) $(libs-m) $(virt-y)))
 
-vmlinux-alldirs:= $(sort $(vmlinux-dirs) $(patsubst %/,%,$(filter %/, \
-$(init-) $(core-) $(drivers-) $(net-) $(libs-) $(virt-
+vmlinux-alldirs:= $(sort $(vmlinux-dirs) Documentation \
+$(patsubst %/,%,$(filter %/, $(init-) $(core-) \
+   $(drivers-) $(net-) $(libs-) $(virt-
 
 init-y := $(patsubst %/, %/built-in.a, $(init-y))
 core-y := $(patsubst %/, %/built-in.a, $(core-y))
@@ -1006,7 +1007,7 @@ export KBUILD_VMLINUX_LIBS := $(libs-y1)
 export KBUILD_LDS  := arch/$(SRCARCH)/kernel/vmlinux.lds
 export LDFLAGS_vmlinux
 # used by scripts/package/Makefile
-export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch 
Documentation include scripts tools)
+export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch 
include scripts tools)
 
 vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
 
@@ -1360,7 +1361,7 @@ MRPROPER_FILES += .config .config.old .version \
 #
 clean: rm-dirs  := $(CLEAN_DIRS)
 clean: rm-files := $(CLEAN_FILES)
-clean-dirs  := $(addprefix _clean_, . $(vmlinux-alldirs) Documentation)
+clean-dirs  := $(addprefix _clean_, . $(vmlinux-alldirs))
 
 PHONY += $(clean-dirs) clean archclean vmlinuxclean
 $(clean-dirs):
-- 
2.7.4



[PATCH 5/5] samples: kobject: allow CONFIG_SAMPLE_KOBJECT to become y

2019-04-26 Thread Masahiro Yamada
This sample works well as builtin.

Signed-off-by: Masahiro Yamada 
---

 samples/Kconfig | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/samples/Kconfig b/samples/Kconfig
index b98a763..399ae53 100644
--- a/samples/Kconfig
+++ b/samples/Kconfig
@@ -20,8 +20,7 @@ config SAMPLE_TRACE_PRINTK
 test various trace_printk() calls from a module.
 
 config SAMPLE_KOBJECT
-   tristate "Build kobject examples -- loadable modules only"
-   depends on m
+   tristate "Build kobject examples"
help
  This config option will allow you to build a number of
  different kobject sample modules showing how to use kobjects,
-- 
2.7.4



[PATCH 4/5] samples: seccomp: turn CONFIG_SAMPLE_SECCOMP into a bool option

2019-04-26 Thread Masahiro Yamada
The prompt of CONFIG_SAMPLE_SECCOMP claims this is "loadable module
only", which is invalid.

samples/seccomp/ only contains host programs, so having it tristate
is pointless.

Signed-off-by: Masahiro Yamada 
---

 samples/Kconfig  | 4 ++--
 samples/seccomp/Makefile | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/samples/Kconfig b/samples/Kconfig
index d19754c..b98a763 100644
--- a/samples/Kconfig
+++ b/samples/Kconfig
@@ -103,8 +103,8 @@ config SAMPLE_CONNECTOR
  See also Documentation/connector/connector.txt
 
 config SAMPLE_SECCOMP
-   tristate "Build seccomp sample code -- loadable modules only"
-   depends on SECCOMP_FILTER && m
+   bool "Build seccomp sample code"
+   depends on SECCOMP_FILTER
help
  Build samples of seccomp filters using various methods of
  BPF filter construction.
diff --git a/samples/seccomp/Makefile b/samples/seccomp/Makefile
index fb43a81..00e0b5e 100644
--- a/samples/seccomp/Makefile
+++ b/samples/seccomp/Makefile
@@ -40,5 +40,5 @@ HOSTLDLIBS_bpf-fancy += $(MFLAG)
 HOSTLDLIBS_dropper += $(MFLAG)
 HOSTLDLIBS_user-trap += $(MFLAG)
 endif
-always := $(hostprogs-m)
+always := $(hostprogs-y)
 endif
-- 
2.7.4



[PATCH 3/5] samples: guard sub-directories with CONFIG options

2019-04-26 Thread Masahiro Yamada
Do not descend to sub-directories when unneeded.

I used subdir-$(CONFIG_...) for hidraw, seccomp, and statx because
they only contain host programs.

While we are here, let's add SPDX License tag, and sort the directories
alphabetically.

Signed-off-by: Masahiro Yamada 
---

 samples/Makefile | 23 +++
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/samples/Makefile b/samples/Makefile
index 50f8586..0f2d70d 100644
--- a/samples/Makefile
+++ b/samples/Makefile
@@ -1,6 +1,21 @@
+# SPDX-License-Identifier: GPL-2.0
 # Makefile for Linux samples code
 
-obj-y  += kobject/ kprobes/ trace_events/ livepatch/ \
-  hw_breakpoint/ kfifo/ kdb/ hidraw/ rpmsg/ seccomp/ \
-  configfs/ connector/ v4l/ trace_printk/ \
-  vfio-mdev/ statx/ qmi/ binderfs/
+obj-$(CONFIG_SAMPLE_ANDROID_BINDERFS)  += binderfs/
+obj-$(CONFIG_SAMPLE_CONFIGFS)  += configfs/
+obj-$(CONFIG_SAMPLE_CONNECTOR) += connector/
+subdir-y   += hidraw
+obj-$(CONFIG_SAMPLE_HW_BREAKPOINT) += hw_breakpoint/
+obj-$(CONFIG_SAMPLE_KDB)   += kdb/
+obj-$(CONFIG_SAMPLE_KFIFO) += kfifo/
+obj-$(CONFIG_SAMPLE_KOBJECT)   += kobject/
+obj-$(CONFIG_SAMPLE_KPROBES)   += kprobes/
+obj-$(CONFIG_SAMPLE_LIVEPATCH) += livepatch/
+obj-$(CONFIG_SAMPLE_QMI_CLIENT)+= qmi/
+obj-$(CONFIG_SAMPLE_RPMSG_CLIENT)  += rpmsg/
+subdir-$(CONFIG_SAMPLE_SECCOMP)+= seccomp
+subdir-$(CONFIG_SAMPLE_STATX)  += statx
+obj-$(CONFIG_SAMPLE_TRACE_EVENTS)  += trace_events/
+obj-$(CONFIG_SAMPLE_TRACE_PRINTK)  += trace_printk/
+obj-$(CONFIG_VIDEO_PCI_SKELETON)   += v4l/
+obj-y  += vfio-mdev/
-- 
2.7.4



[PATCH 1/5] kbuild: move samples/ to KBUILD_VMLINUX_OBJS

2019-04-26 Thread Masahiro Yamada
Handle samples/ like the other top-level directories to simplify
the Makefile.

Include include/config/auto.conf earlier to evaluate
drivers-$(CONFIG_SAMPLES).

Signed-off-by: Masahiro Yamada 
---

 Makefile | 18 --
 samples/Makefile |  2 +-
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/Makefile b/Makefile
index 15e17b4..251ded5 100644
--- a/Makefile
+++ b/Makefile
@@ -598,20 +598,21 @@ endif
 
 export KBUILD_MODULES KBUILD_BUILTIN
 
+ifeq ($(dot-config),1)
+include include/config/auto.conf
+endif
+
 ifeq ($(KBUILD_EXTMOD),)
 # Objects we will link into vmlinux / subdirs we need to visit
 init-y := init/
 drivers-y  := drivers/ sound/
+drivers-$(CONFIG_SAMPLES) += samples/
 net-y  := net/
 libs-y := lib/
 core-y := usr/
 virt-y := virt/
 endif # KBUILD_EXTMOD
 
-ifeq ($(dot-config),1)
-include include/config/auto.conf
-endif
-
 # The all: target is the default when no target is given on the
 # command line.
 # This allow a user to issue only 'make' to build a kernel including modules
@@ -1005,7 +1006,7 @@ export KBUILD_VMLINUX_LIBS := $(libs-y1)
 export KBUILD_LDS  := arch/$(SRCARCH)/kernel/vmlinux.lds
 export LDFLAGS_vmlinux
 # used by scripts/package/Makefile
-export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch 
Documentation include samples scripts tools)
+export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch 
Documentation include scripts tools)
 
 vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
 
@@ -1042,11 +1043,8 @@ vmlinux: scripts/link-vmlinux.sh autoksyms_recursive 
$(vmlinux-deps) FORCE
 
 targets := vmlinux
 
-# Build samples along the rest of the kernel. This needs headers_install.
-ifdef CONFIG_SAMPLES
-vmlinux-dirs += samples
+# Some samples need headers_install.
 samples: headers_install
-endif
 
 # The actual objects are generated when descending,
 # make sure no implicit rule kicks in
@@ -1362,7 +1360,7 @@ MRPROPER_FILES += .config .config.old .version \
 #
 clean: rm-dirs  := $(CLEAN_DIRS)
 clean: rm-files := $(CLEAN_FILES)
-clean-dirs  := $(addprefix _clean_, . $(vmlinux-alldirs) Documentation 
samples)
+clean-dirs  := $(addprefix _clean_, . $(vmlinux-alldirs) Documentation)
 
 PHONY += $(clean-dirs) clean archclean vmlinuxclean
 $(clean-dirs):
diff --git a/samples/Makefile b/samples/Makefile
index b1142a9..50f8586 100644
--- a/samples/Makefile
+++ b/samples/Makefile
@@ -1,6 +1,6 @@
 # Makefile for Linux samples code
 
-obj-$(CONFIG_SAMPLES)  += kobject/ kprobes/ trace_events/ livepatch/ \
+obj-y  += kobject/ kprobes/ trace_events/ livepatch/ \
   hw_breakpoint/ kfifo/ kdb/ hidraw/ rpmsg/ seccomp/ \
   configfs/ connector/ v4l/ trace_printk/ \
   vfio-mdev/ statx/ qmi/ binderfs/
-- 
2.7.4



[PATCH] staging: greybus: use proper return type for wait_for_completion_timeout

2019-04-26 Thread Nicholas Mc Guire
wait_for_completion_timeout() returns unsigned long (0 on timeout or
remaining jiffies) not int. 

Signed-off-by: Nicholas Mc Guire 
---
Problem located with experimental API conformance checking cocci script

Patch was compile-tested with: x86_64_defconfig + GREYBUS=m

Patch is against 5.1-rc6 (localversion-next is next-20190426)

 drivers/staging/greybus/uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index b3bffe9..ff18112 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -323,7 +323,7 @@ static int send_break(struct gb_tty *gb_tty, u8 state)
 
 static int gb_uart_wait_for_all_credits(struct gb_tty *gb_tty)
 {
-   int ret;
+   unsigned long ret;
 
if (gb_tty->credits == GB_UART_FIRMWARE_CREDITS)
return 0;
-- 
2.1.4



Re: [PATCH v3 1/3] clk: analogbits: add Wide-Range PLL library

2019-04-26 Thread Paul Walmsley
On Fri, 26 Apr 2019, Stephen Boyd wrote:

> Quoting Paul Walmsley (2019-04-11 01:27:32)
> > Add common library code for the Analog Bits Wide-Range PLL (WRPLL) IP
> > block, as implemented in TSMC CLN28HPC.
> 
> I haven't deeply reviewed at all, but I already get two problems when
> compile testing these patches. I can fix them up if nothing else needs
> fixing.
> 
> drivers/clk/analogbits/wrpll-cln28hpc.c:165 __wrpll_calc_divq() warn: should 
> 'target_rate << divq' be a 64 bit type?
> drivers/clk/sifive/fu540-prci.c:214:16: error: return expression in void 
> function

Hmm, that's odd.  I will definitely take a look and repost.

- Paul


Re: [PATCH v4 4/5] dt-bindings: mtd: Add bindings for TI's AM654 HyperBus memory controller

2019-04-26 Thread Vignesh Raghavendra



On 27/04/19 1:50 AM, Rob Herring wrote:
> On Tue, Apr 23, 2019 at 04:18:13PM +0530, Vignesh Raghavendra wrote:
>> Add binding documentation for TI's HyperBus memory controller present on
>> AM654 SoC.
>>
>> Signed-off-by: Vignesh Raghavendra 
>> ---
>>  .../devicetree/bindings/mtd/ti,am654-hbmc.txt | 32 +++
>>  MAINTAINERS   |  1 +
>>  2 files changed, 33 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/mtd/ti,am654-hbmc.txt
>>
>> diff --git a/Documentation/devicetree/bindings/mtd/ti,am654-hbmc.txt 
>> b/Documentation/devicetree/bindings/mtd/ti,am654-hbmc.txt
>> new file mode 100644
>> index ..fc87c7918389
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/mtd/ti,am654-hbmc.txt
>> @@ -0,0 +1,32 @@
>> +Bindings for HyperBus Memory Controller (HBMC) on TI's K3 family of SoCs
>> +
>> +Required properties:
>> +- compatible : "ti,am654-hbmc" for AM654 SoC
>> +- reg : Two entries:
>> +First entry pointed to the register space of HBMC controller
>> +Second entry pointing to the memory map region dedicated for
>> +MMIO access to attached flash devices
>> +- ranges : Address range allocated for each chipselect in the MMIO space
>> +
>> +Optional properties:
>> +- mux-controls : phandle to the multiplexer that controls selection of
>> + HBMC vs OSPI. Mux state of 1 indicates HBMC is selected.
> 
> So 1 is also the default because your example doesn't have the property?
> 

No default is 0. Will fix the example.

>> +
>> +Example:
>> +
>> +hbmc: hbmc@47034000 {
>> +compatible = "ti,am654-hbmc";
>> +reg = <0x0 0x47034000 0x0 0x100>,
>> +<0x5 0x 0x1 0x000>;
>> +power-domains = <_pds 55>;
>> +#address-cells = <1>;
>> +#size-cells = <1>;
>> +ranges = <0x0 0x5 0x 0x400>, /* CS0 - 64MB */
>> + <0x1 0x5 0x0400 0x400>; /* CS1 - 64MB
> 
> This is wrong. You need 2 cells for the child address. The first cell is 
> the CS and the 2nd cell is the offset (typically 0). Otherwise you have 
> overlapping addresses with child addresses 0 and 1.
> 

Oops, didn't think of that. Will fix in the next version.

>> +
>> +/* Slave flash node */
>> +flash@0 {
> 
> And then the unit-address here would be '0,0'.
> 
>> +compatible = "cypress,hyperflash";
> 
> Doesn't match what you defined for this binding.

Will update. Thanks for the review!

> 
>> +reg = <0x0 0x400>;
>> +};
>> +};
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index a5f22f85c848..1ade81f9a32a 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -7258,6 +7258,7 @@ S: Supported
>>  F:  drivers/mtd/hyperbus/
>>  F:  include/linux/mtd/hyperbus.h
>>  F:  Documentation/devicetree/bindings/mtd/cypress,hyperflash.txt
>> +F:  Documentation/devicetree/bindings/mtd/ti,am654-hbmc.txt
>>  
>>  HYPERVISOR VIRTUAL CONSOLE DRIVER
>>  L:  linuxppc-...@lists.ozlabs.org
>> -- 
>> 2.21.0
>>

-- 
Regards
Vignesh


[PATCH RFC] staging: kpc2000: use int for wait_for_completion_interruptible

2019-04-26 Thread Nicholas Mc Guire
weit_for_completion_interruptible returns in (0 on completion and 
-ERESTARTSYS on interruption) - so use an int not long for API conformance
and simplify the logic here a bit: need not check explicitly for == 0 as
this is either -ERESTARTSYS or 0.

Signed-off-by: Nicholas Mc Guire 
---

Problem located with experimental API conformance checking cocci script

Not sure if making such point-wise fixes makes much sense - this driver has
a number of issues both style-wise and API compliance wise.

Note that kpc_dma_transfer() returns int not long - currently rv (long) is
being returned in most places (some places do return int) - so the return
handling here is a bit inconsistent.

Patch was compile-tested with: x86_64_defconfig + KPC2000=y, KPC2000_DMA=y
(with a number of unrelated sparse warnings about non-declared symbols, and
 smatch warnings about overflowing constants as well as coccicheck warning
 about usless casting)

Patch is against 5.1-rc6 (localversion-next is next-20190426)

 drivers/staging/kpc2000/kpc_dma/fileops.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c 
b/drivers/staging/kpc2000/kpc_dma/fileops.c
index 5741d2b..66f0d5a 100644
--- a/drivers/staging/kpc2000/kpc_dma/fileops.c
+++ b/drivers/staging/kpc2000/kpc_dma/fileops.c
@@ -38,6 +38,7 @@ int  kpc_dma_transfer(struct dev_private_data *priv, struct 
kiocb *kcb, unsigned
 {
unsigned int i = 0;
long rv = 0;
+   int ret = 0;
struct kpc_dma_device *ldev;
struct aio_cb_data *acd;
DECLARE_COMPLETION_ONSTACK(done);
@@ -180,16 +181,17 @@ int  kpc_dma_transfer(struct dev_private_data *priv, 
struct kiocb *kcb, unsigned

// If this is a synchronous kiocb, we need to put the calling process 
to sleep until the transfer is complete
if (kcb == NULL || is_sync_kiocb(kcb)){
-   rv = wait_for_completion_interruptible();
-   // If the user aborted (rv == -ERESTARTSYS), we're no longer 
responsible for cleaning up the acd
-   if (rv == -ERESTARTSYS){
+   ret = wait_for_completion_interruptible();
+   /* If the user aborted (ret == -ERESTARTSYS), we're
+* no longer responsible for cleaning up the acd
+*
+   if (ret){
acd->cpl = NULL;
-   }
-   if (rv == 0){
-   rv = acd->len;
+   } else {
+   ret = acd->len;
kfree(acd);
}
-   return rv;
+   return ret
}

return -EIOCBQUEUED;
-- 
2.1.4



Re: [RFC PATCH RESEND] i2c-piix4: Add Hygon Dhyana SMBus support

2019-04-26 Thread Pu Wen

On 2019/4/27 0:48, Jean Delvare wrote:

On Fri, 2019-04-26 at 22:23 +0800, Pu Wen wrote:

On 2019/4/26 17:38, Jean Delvare wrote:

I would like you to also document the new supported chipset in
drivers/i2c/busses/Kconfig and Documentation/i2c/busses/i2c-piix4 as
well as in the header comment of i2c-piix4.c itself. I know it seems
redundant but it helps the user know which driver they need.


Because Hygon uses the same PCI device ID of AMD's, so is it appropriate
to document with the name "Hygon CZ" or just "Hygon"?


"Hygon CZ" please, as Hygon is the vendor not the device, and I can


Okay.


imagine you may create more devices in the future.


Surely.

--
Regards,
Pu Wen


[PATCH AUTOSEL 5.0 04/79] ASoC: stm32: sai: fix iec958 controls indexation

2019-04-26 Thread Sasha Levin
From: Olivier Moysan 

[ Upstream commit 5f8a1000c3e630c3ac06f1d664eeaa755bce8823 ]

Allow indexation of sai iec958 controls according
to device id.

Signed-off-by: Olivier Moysan 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/stm/stm32_sai_sub.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c
index d4825700b63f..8746a22841f0 100644
--- a/sound/soc/stm/stm32_sai_sub.c
+++ b/sound/soc/stm/stm32_sai_sub.c
@@ -100,7 +100,7 @@
  * @slot_mask: rx or tx active slots mask. set at init or at runtime
  * @data_size: PCM data width. corresponds to PCM substream width.
  * @spdif_frm_cnt: S/PDIF playback frame counter
- * @snd_aes_iec958: iec958 data
+ * @iec958: iec958 data
  * @ctrl_lock: control lock
  */
 struct stm32_sai_sub_data {
@@ -1070,11 +1070,12 @@ static int stm32_sai_pcm_new(struct snd_soc_pcm_runtime 
*rtd,
 struct snd_soc_dai *cpu_dai)
 {
struct stm32_sai_sub_data *sai = dev_get_drvdata(cpu_dai->dev);
+   struct snd_kcontrol_new knew = iec958_ctls;
 
if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) {
dev_dbg(>pdev->dev, "%s: register iec controls", __func__);
-   return snd_ctl_add(rtd->pcm->card,
-  snd_ctl_new1(_ctls, sai));
+   knew.device = rtd->pcm->device;
+   return snd_ctl_add(rtd->pcm->card, snd_ctl_new1(, sai));
}
 
return 0;
-- 
2.19.1



[PATCH AUTOSEL 5.0 05/79] ASoC: stm32: sai: fix exposed capabilities in spdif mode

2019-04-26 Thread Sasha Levin
From: Olivier Moysan 

[ Upstream commit b8468192971807c43a80d6e2c41f83141cb7b211 ]

Change capabilities exposed in SAI S/PDIF mode, to match
actually supported formats.
In S/PDIF mode only 32 bits stereo is supported.

Signed-off-by: Olivier Moysan 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/stm/stm32_sai_sub.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c
index 8746a22841f0..de4855b30e36 100644
--- a/sound/soc/stm/stm32_sai_sub.c
+++ b/sound/soc/stm/stm32_sai_sub.c
@@ -682,6 +682,14 @@ static int stm32_sai_startup(struct snd_pcm_substream 
*substream,
 
sai->substream = substream;
 
+   if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) {
+   snd_pcm_hw_constraint_mask64(substream->runtime,
+SNDRV_PCM_HW_PARAM_FORMAT,
+SNDRV_PCM_FMTBIT_S32_LE);
+   snd_pcm_hw_constraint_single(substream->runtime,
+SNDRV_PCM_HW_PARAM_CHANNELS, 2);
+   }
+
ret = clk_prepare_enable(sai->sai_ck);
if (ret < 0) {
dev_err(cpu_dai->dev, "Failed to enable clock: %d\n", ret);
-- 
2.19.1



[PATCH AUTOSEL 5.0 12/79] ASoC: nau8810: fix the issue of widget with prefixed name

2019-04-26 Thread Sasha Levin
From: John Hsu 

[ Upstream commit 54d1cf78b0f4ba348a7c7fb8b7d0708d71b6cc8a ]

The driver changes the stream name of DAC and ADC to avoid the issue of
widget with prefixed name. When the machine adds prefixed name for codec,
the stream name of DAI may not find the widgets.

Signed-off-by: John Hsu 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/codecs/nau8810.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/nau8810.c b/sound/soc/codecs/nau8810.c
index bfd74b86c9d2..645aa0794123 100644
--- a/sound/soc/codecs/nau8810.c
+++ b/sound/soc/codecs/nau8810.c
@@ -411,9 +411,9 @@ static const struct snd_soc_dapm_widget 
nau8810_dapm_widgets[] = {
SND_SOC_DAPM_MIXER("Mono Mixer", NAU8810_REG_POWER3,
NAU8810_MOUTMX_EN_SFT, 0, _mono_mixer_controls[0],
ARRAY_SIZE(nau8810_mono_mixer_controls)),
-   SND_SOC_DAPM_DAC("DAC", "HiFi Playback", NAU8810_REG_POWER3,
+   SND_SOC_DAPM_DAC("DAC", "Playback", NAU8810_REG_POWER3,
NAU8810_DAC_EN_SFT, 0),
-   SND_SOC_DAPM_ADC("ADC", "HiFi Capture", NAU8810_REG_POWER2,
+   SND_SOC_DAPM_ADC("ADC", "Capture", NAU8810_REG_POWER2,
NAU8810_ADC_EN_SFT, 0),
SND_SOC_DAPM_PGA("SpkN Out", NAU8810_REG_POWER3,
NAU8810_NSPK_EN_SFT, 0, NULL, 0),
-- 
2.19.1



[PATCH AUTOSEL 5.0 07/79] ASoC:soc-pcm:fix a codec fixup issue in TDM case

2019-04-26 Thread Sasha Levin
From: Rander Wang 

[ Upstream commit 570f18b6a8d1f0e60e8caf30e66161b6438dcc91 ]

On HDaudio platforms, if playback is started when capture is working,
there is no audible output.

This can be root-caused to the use of the rx|tx_mask to store an HDaudio
stream tag.

If capture is stared before playback, rx_mask would be non-zero on HDaudio
platform, then the channel number of playback, which is in the same codec
dai with the capture, would be changed by soc_pcm_codec_params_fixup based
on the tx_mask at first, then overwritten by this function based on rx_mask
at last.

According to the author of tx|rx_mask, tx_mask is for playback and rx_mask
is for capture. And stream direction is checked at all other references of
tx|rx_mask in ASoC, so here should be an error. This patch checks stream
direction for tx|rx_mask for fixup function.

This issue would affect not only HDaudio+ASoC, but also I2S codecs if the
channel number based on rx_mask is not equal to the one for tx_mask. It could
be rarely reproduecd because most drivers in kernel set the same channel number
to tx|rx_mask or rx_mask is zero.

Tested on all platforms using stream_tag & HDaudio and intel I2S platforms.

Signed-off-by: Rander Wang 
Acked-by: Pierre-Louis Bossart 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/soc-pcm.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 03f36e534050..0b6ade426516 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -954,10 +954,13 @@ static int soc_pcm_hw_params(struct snd_pcm_substream 
*substream,
codec_params = *params;
 
/* fixup params based on TDM slot masks */
-   if (codec_dai->tx_mask)
+   if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
+   codec_dai->tx_mask)
soc_pcm_codec_params_fixup(_params,
   codec_dai->tx_mask);
-   if (codec_dai->rx_mask)
+
+   if (substream->stream == SNDRV_PCM_STREAM_CAPTURE &&
+   codec_dai->rx_mask)
soc_pcm_codec_params_fixup(_params,
   codec_dai->rx_mask);
 
-- 
2.19.1



[PATCH AUTOSEL 5.0 08/79] ASoC:hdac_hda:use correct format to setup hda codec

2019-04-26 Thread Sasha Levin
From: Rander Wang 

[ Upstream commit 03d0aa4d4fddce4a5d865d819a4d98bfc3d451e6 ]

The current implementation of the hdac_hda codec results in zero-valued
samples on capture and noise with headset playback when SOF is used on
platforms with an on-board HDaudio codec. This is root-caused to SOF
using be_hw_params_fixup, and the prepare() call using invalid runtime
fields to determine the format.

This patch moves the format handling to the hw_params() callback, as
done already for hdac_hdmi, to make sure the fixed-up information is
taken into account but keeps the codec initialization in prepare() as
the stream_tag is only available at that time. Moving everything in the
prepare() callback is possible but the code is less elegant so this
two-step solution was chosen.

The solution was tested with the SST driver with no regressions, and all
the issues with SOF playback and capture are solved.

Signed-off-by: Rander Wang 
Acked-by: Pierre-Louis Bossart 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/codecs/hdac_hda.c | 53 +++--
 sound/soc/codecs/hdac_hda.h |  1 +
 2 files changed, 40 insertions(+), 14 deletions(-)

diff --git a/sound/soc/codecs/hdac_hda.c b/sound/soc/codecs/hdac_hda.c
index ffecdaaa8cf2..f889d94c8e3c 100644
--- a/sound/soc/codecs/hdac_hda.c
+++ b/sound/soc/codecs/hdac_hda.c
@@ -38,6 +38,9 @@ static void hdac_hda_dai_close(struct snd_pcm_substream 
*substream,
   struct snd_soc_dai *dai);
 static int hdac_hda_dai_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai);
+static int hdac_hda_dai_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params,
+ struct snd_soc_dai *dai);
 static int hdac_hda_dai_hw_free(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai);
 static int hdac_hda_dai_set_tdm_slot(struct snd_soc_dai *dai,
@@ -50,6 +53,7 @@ static const struct snd_soc_dai_ops hdac_hda_dai_ops = {
.startup = hdac_hda_dai_open,
.shutdown = hdac_hda_dai_close,
.prepare = hdac_hda_dai_prepare,
+   .hw_params = hdac_hda_dai_hw_params,
.hw_free = hdac_hda_dai_hw_free,
.set_tdm_slot = hdac_hda_dai_set_tdm_slot,
 };
@@ -139,6 +143,39 @@ static int hdac_hda_dai_set_tdm_slot(struct snd_soc_dai 
*dai,
return 0;
 }
 
+static int hdac_hda_dai_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params,
+ struct snd_soc_dai *dai)
+{
+   struct snd_soc_component *component = dai->component;
+   struct hdac_hda_priv *hda_pvt;
+   unsigned int format_val;
+   unsigned int maxbps;
+
+   if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+   maxbps = dai->driver->playback.sig_bits;
+   else
+   maxbps = dai->driver->capture.sig_bits;
+
+   hda_pvt = snd_soc_component_get_drvdata(component);
+   format_val = snd_hdac_calc_stream_format(params_rate(params),
+params_channels(params),
+params_format(params),
+maxbps,
+0);
+   if (!format_val) {
+   dev_err(dai->dev,
+   "invalid format_val, rate=%d, ch=%d, format=%d, 
maxbps=%d\n",
+   params_rate(params), params_channels(params),
+   params_format(params), maxbps);
+
+   return -EINVAL;
+   }
+
+   hda_pvt->pcm[dai->id].format_val[substream->stream] = format_val;
+   return 0;
+}
+
 static int hdac_hda_dai_hw_free(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
 {
@@ -162,10 +199,9 @@ static int hdac_hda_dai_prepare(struct snd_pcm_substream 
*substream,
struct snd_soc_dai *dai)
 {
struct snd_soc_component *component = dai->component;
+   struct hda_pcm_stream *hda_stream;
struct hdac_hda_priv *hda_pvt;
-   struct snd_pcm_runtime *runtime = substream->runtime;
struct hdac_device *hdev;
-   struct hda_pcm_stream *hda_stream;
unsigned int format_val;
struct hda_pcm *pcm;
unsigned int stream;
@@ -179,19 +215,8 @@ static int hdac_hda_dai_prepare(struct snd_pcm_substream 
*substream,
 
hda_stream = >stream[substream->stream];
 
-   format_val = snd_hdac_calc_stream_format(runtime->rate,
-runtime->channels,
-runtime->format,
-hda_stream->maxbps,
-0);
-   if (!format_val) {
-   

[PATCH AUTOSEL 5.0 09/79] ASoC:intel:skl:fix a simultaneous playback & capture issue on hda platform

2019-04-26 Thread Sasha Levin
From: Rander Wang 

[ Upstream commit c899df3e9b0bf7b76e642aed1a214582ea7012d5 ]

If playback and capture are enabled concurrently, when the capture stops
the output becomes inaudile. The playback application will become stuck
and underrun after a timeout.

This is caused by mistaken use of the stream_id, which should only be
set for playback and not for capture

Tested on Apollolake and Kabylake with SST driver.

Signed-off-by: Rander Wang 
Acked-by: Pierre-Louis Bossart 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/intel/skylake/skl-pcm.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-pcm.c 
b/sound/soc/intel/skylake/skl-pcm.c
index 557f80c0bfe5..5cd308d622f6 100644
--- a/sound/soc/intel/skylake/skl-pcm.c
+++ b/sound/soc/intel/skylake/skl-pcm.c
@@ -181,6 +181,7 @@ int skl_pcm_link_dma_prepare(struct device *dev, struct 
skl_pipe_params *params)
struct hdac_stream *hstream;
struct hdac_ext_stream *stream;
struct hdac_ext_link *link;
+   unsigned char stream_tag;
 
hstream = snd_hdac_get_stream(bus, params->stream,
params->link_dma_id + 1);
@@ -199,10 +200,13 @@ int skl_pcm_link_dma_prepare(struct device *dev, struct 
skl_pipe_params *params)
 
snd_hdac_ext_link_stream_setup(stream, format_val);
 
-   list_for_each_entry(link, >hlink_list, list) {
-   if (link->index == params->link_index)
-   snd_hdac_ext_link_set_stream_id(link,
-   hstream->stream_tag);
+   stream_tag = hstream->stream_tag;
+   if (stream->hstream.direction == SNDRV_PCM_STREAM_PLAYBACK) {
+   list_for_each_entry(link, >hlink_list, list) {
+   if (link->index == params->link_index)
+   snd_hdac_ext_link_set_stream_id(link,
+   stream_tag);
+   }
}
 
stream->link_prepared = 1;
@@ -645,6 +649,7 @@ static int skl_link_hw_free(struct snd_pcm_substream 
*substream,
struct hdac_ext_stream *link_dev =
snd_soc_dai_get_dma_data(dai, substream);
struct hdac_ext_link *link;
+   unsigned char stream_tag;
 
dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
 
@@ -654,7 +659,11 @@ static int skl_link_hw_free(struct snd_pcm_substream 
*substream,
if (!link)
return -EINVAL;
 
-   snd_hdac_ext_link_clear_stream_id(link, 
hdac_stream(link_dev)->stream_tag);
+   if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+   stream_tag = hdac_stream(link_dev)->stream_tag;
+   snd_hdac_ext_link_clear_stream_id(link, stream_tag);
+   }
+
snd_hdac_ext_stream_release(link_dev, HDAC_EXT_STREAM_TYPE_LINK);
return 0;
 }
-- 
2.19.1



[PATCH AUTOSEL 5.0 06/79] ASoC: stm32: sai: fix race condition in irq handler

2019-04-26 Thread Sasha Levin
From: Olivier Moysan 

[ Upstream commit 26f98e82dd49b7c3cc5ef0edd882aa732a62b672 ]

When snd_pcm_stop_xrun() is called in interrupt routine,
substream context may have already been released.
Add protection on substream context.

Signed-off-by: Olivier Moysan 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/stm/stm32_sai_sub.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c
index de4855b30e36..cc56102881be 100644
--- a/sound/soc/stm/stm32_sai_sub.c
+++ b/sound/soc/stm/stm32_sai_sub.c
@@ -102,6 +102,7 @@
  * @spdif_frm_cnt: S/PDIF playback frame counter
  * @iec958: iec958 data
  * @ctrl_lock: control lock
+ * @irq_lock: prevent race condition with IRQ
  */
 struct stm32_sai_sub_data {
struct platform_device *pdev;
@@ -133,6 +134,7 @@ struct stm32_sai_sub_data {
unsigned int spdif_frm_cnt;
struct snd_aes_iec958 iec958;
struct mutex ctrl_lock; /* protect resources accessed by controls */
+   spinlock_t irq_lock; /* used to prevent race condition with IRQ */
 };
 
 enum stm32_sai_fifo_th {
@@ -474,8 +476,10 @@ static irqreturn_t stm32_sai_isr(int irq, void *devid)
status = SNDRV_PCM_STATE_XRUN;
}
 
-   if (status != SNDRV_PCM_STATE_RUNNING)
+   spin_lock(>irq_lock);
+   if (status != SNDRV_PCM_STATE_RUNNING && sai->substream)
snd_pcm_stop_xrun(sai->substream);
+   spin_unlock(>irq_lock);
 
return IRQ_HANDLED;
 }
@@ -679,8 +683,11 @@ static int stm32_sai_startup(struct snd_pcm_substream 
*substream,
 {
struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai);
int imr, cr2, ret;
+   unsigned long flags;
 
+   spin_lock_irqsave(>irq_lock, flags);
sai->substream = substream;
+   spin_unlock_irqrestore(>irq_lock, flags);
 
if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) {
snd_pcm_hw_constraint_mask64(substream->runtime,
@@ -1061,6 +1068,7 @@ static void stm32_sai_shutdown(struct snd_pcm_substream 
*substream,
   struct snd_soc_dai *cpu_dai)
 {
struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai);
+   unsigned long flags;
 
regmap_update_bits(sai->regmap, STM_SAI_IMR_REGX, SAI_XIMR_MASK, 0);
 
@@ -1071,7 +1079,9 @@ static void stm32_sai_shutdown(struct snd_pcm_substream 
*substream,
 
clk_rate_exclusive_put(sai->sai_mclk);
 
+   spin_lock_irqsave(>irq_lock, flags);
sai->substream = NULL;
+   spin_unlock_irqrestore(>irq_lock, flags);
 }
 
 static int stm32_sai_pcm_new(struct snd_soc_pcm_runtime *rtd,
@@ -1435,6 +1445,7 @@ static int stm32_sai_sub_probe(struct platform_device 
*pdev)
 
sai->pdev = pdev;
mutex_init(>ctrl_lock);
+   spin_lock_init(>irq_lock);
platform_set_drvdata(pdev, sai);
 
sai->pdata = dev_get_drvdata(pdev->dev.parent);
-- 
2.19.1



[PATCH AUTOSEL 5.0 13/79] ASoC: samsung: odroid: Fix clock configuration for 44100 sample rate

2019-04-26 Thread Sasha Levin
From: Sylwester Nawrocki 

[ Upstream commit 2b13bee3884926cba22061efa75bd315e871de24 ]

After commit fbeec965b8d1c ("ASoC: samsung: odroid: Fix 32000 sample rate
handling") the audio root clock frequency is configured improperly for
44100 sample rate. Due to clock rate rounding it's 20070401 Hz instead
of 22579000 Hz. This results in a too low value of the PSR clock divider
in the CPU DAI driver and too fast actual sample rate for fs=44100. E.g.
1 kHz tone has actual 1780 Hz frequency (1 kHz * 20070401/22579000 * 2).

Fix this by increasing the correction passed to clk_set_rate() to take
into account inaccuracy of the EPLL frequency properly.

Fixes: fbeec965b8d1c ("ASoC: samsung: odroid: Fix 32000 sample rate handling")
Reported-by: JaeChul Lee 
Signed-off-by: Sylwester Nawrocki 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/samsung/odroid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c
index e7b371b07230..45c6d7396785 100644
--- a/sound/soc/samsung/odroid.c
+++ b/sound/soc/samsung/odroid.c
@@ -64,11 +64,11 @@ static int odroid_card_hw_params(struct snd_pcm_substream 
*substream,
return ret;
 
/*
-*  We add 1 to the rclk_freq value in order to avoid too low clock
+*  We add 2 to the rclk_freq value in order to avoid too low clock
 *  frequency values due to the EPLL output frequency not being exact
 *  multiple of the audio sampling rate.
 */
-   rclk_freq = params_rate(params) * rfs + 1;
+   rclk_freq = params_rate(params) * rfs + 2;
 
ret = clk_set_rate(priv->sclk_i2s, rclk_freq);
if (ret < 0)
-- 
2.19.1



[PATCH AUTOSEL 5.0 14/79] ASoC: rt5682: Check JD status when system resume

2019-04-26 Thread Sasha Levin
From: Shuming Fan 

[ Upstream commit 4834d7070c85a5fb69637265dbbb05d13043280c ]

The IRQ function may not work when system suspend.
We remove snd_soc_dapm_force_enable_pin function call to
make sure the bias off when idle and run into suspend/resume function.

Signed-off-by: Shuming Fan 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/codecs/rt5682.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
index a9b91bcfcc09..49ff5e52db58 100644
--- a/sound/soc/codecs/rt5682.c
+++ b/sound/soc/codecs/rt5682.c
@@ -904,13 +904,20 @@ static int rt5682_headset_detect(struct snd_soc_component 
*component,
int jack_insert)
 {
struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
-   struct snd_soc_dapm_context *dapm =
-   snd_soc_component_get_dapm(component);
unsigned int val, count;
 
if (jack_insert) {
-   snd_soc_dapm_force_enable_pin(dapm, "CBJ Power");
-   snd_soc_dapm_sync(dapm);
+
+   snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1,
+   RT5682_PWR_VREF2, RT5682_PWR_VREF2);
+   snd_soc_component_update_bits(component,
+   RT5682_PWR_ANLG_1, RT5682_PWR_FV2, 0);
+   usleep_range(15000, 2);
+   snd_soc_component_update_bits(component,
+   RT5682_PWR_ANLG_1, RT5682_PWR_FV2, 
RT5682_PWR_FV2);
+   snd_soc_component_update_bits(component, RT5682_PWR_ANLG_3,
+   RT5682_PWR_CBJ, RT5682_PWR_CBJ);
+
snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,
RT5682_TRIG_JD_MASK, RT5682_TRIG_JD_HIGH);
 
@@ -938,8 +945,10 @@ static int rt5682_headset_detect(struct snd_soc_component 
*component,
rt5682_enable_push_button_irq(component, false);
snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_1,
RT5682_TRIG_JD_MASK, RT5682_TRIG_JD_LOW);
-   snd_soc_dapm_disable_pin(dapm, "CBJ Power");
-   snd_soc_dapm_sync(dapm);
+   snd_soc_component_update_bits(component, RT5682_PWR_ANLG_1,
+   RT5682_PWR_VREF2, 0);
+   snd_soc_component_update_bits(component, RT5682_PWR_ANLG_3,
+   RT5682_PWR_CBJ, 0);
 
rt5682->jack_type = 0;
}
@@ -1585,8 +1594,6 @@ static const struct snd_soc_dapm_widget 
rt5682_dapm_widgets[] = {
0, NULL, 0),
SND_SOC_DAPM_SUPPLY("Vref1", RT5682_PWR_ANLG_1, RT5682_PWR_VREF1_BIT, 0,
rt5655_set_verf, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
-   SND_SOC_DAPM_SUPPLY("Vref2", RT5682_PWR_ANLG_1, RT5682_PWR_VREF2_BIT, 0,
-   rt5655_set_verf, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
 
/* ASRC */
SND_SOC_DAPM_SUPPLY_S("DAC STO1 ASRC", 1, RT5682_PLL_TRACK_1,
@@ -1621,9 +1628,6 @@ static const struct snd_soc_dapm_widget 
rt5682_dapm_widgets[] = {
SND_SOC_DAPM_PGA("BST1 CBJ", SND_SOC_NOPM,
0, 0, NULL, 0),
 
-   SND_SOC_DAPM_SUPPLY("CBJ Power", RT5682_PWR_ANLG_3,
-   RT5682_PWR_CBJ_BIT, 0, NULL, 0),
-
/* REC Mixer */
SND_SOC_DAPM_MIXER("RECMIX1L", SND_SOC_NOPM, 0, 0, rt5682_rec1_l_mix,
ARRAY_SIZE(rt5682_rec1_l_mix)),
@@ -1786,17 +1790,13 @@ static const struct snd_soc_dapm_route 
rt5682_dapm_routes[] = {
 
/*Vref*/
{"MICBIAS1", NULL, "Vref1"},
-   {"MICBIAS1", NULL, "Vref2"},
{"MICBIAS2", NULL, "Vref1"},
-   {"MICBIAS2", NULL, "Vref2"},
 
{"CLKDET SYS", NULL, "CLKDET"},
 
{"IN1P", NULL, "LDO2"},
 
{"BST1 CBJ", NULL, "IN1P"},
-   {"BST1 CBJ", NULL, "CBJ Power"},
-   {"CBJ Power", NULL, "Vref2"},
 
{"RECMIX1L", "CBJ Switch", "BST1 CBJ"},
{"RECMIX1L", NULL, "RECMIX1L Power"},
@@ -1906,9 +1906,7 @@ static const struct snd_soc_dapm_route 
rt5682_dapm_routes[] = {
{"HP Amp", NULL, "Capless"},
{"HP Amp", NULL, "Charge Pump"},
{"HP Amp", NULL, "CLKDET SYS"},
-   {"HP Amp", NULL, "CBJ Power"},
{"HP Amp", NULL, "Vref1"},
-   {"HP Amp", NULL, "Vref2"},
{"HPOL Playback", "Switch", "HP Amp"},
{"HPOR Playback", "Switch", "HP Amp"},
{"HPOL", NULL, "HPOL Playback"},
@@ -2357,6 +2355,8 @@ static int rt5682_resume(struct snd_soc_component 
*component)
regcache_cache_only(rt5682->regmap, false);
regcache_sync(rt5682->regmap);
 
+   rt5682_irq(0, rt5682);
+
return 0;
 }
 #else
-- 
2.19.1



[PATCH AUTOSEL 5.0 11/79] ASoC: nau8824: fix the issue of the widget with prefix name

2019-04-26 Thread Sasha Levin
From: John Hsu 

[ Upstream commit 844a4a362dbec166b44d6b9b3dd45b08cb273703 ]

The driver has two issues when machine add prefix name for codec.
(1)The stream name of DAI can't find the AIF widgets.
(2)The drivr can enable/disalbe the MICBIAS and SAR widgets.

The patch will fix these issues caused by prefixed name added.

Signed-off-by: John Hsu 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/codecs/nau8824.c | 46 +++---
 1 file changed, 38 insertions(+), 8 deletions(-)

diff --git a/sound/soc/codecs/nau8824.c b/sound/soc/codecs/nau8824.c
index 468d5143e2c4..663a208c2f78 100644
--- a/sound/soc/codecs/nau8824.c
+++ b/sound/soc/codecs/nau8824.c
@@ -681,8 +681,8 @@ static const struct snd_soc_dapm_widget 
nau8824_dapm_widgets[] = {
SND_SOC_DAPM_ADC("ADCR", NULL, NAU8824_REG_ANALOG_ADC_2,
NAU8824_ADCR_EN_SFT, 0),
 
-   SND_SOC_DAPM_AIF_OUT("AIFTX", "HiFi Capture", 0, SND_SOC_NOPM, 0, 0),
-   SND_SOC_DAPM_AIF_IN("AIFRX", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0),
+   SND_SOC_DAPM_AIF_OUT("AIFTX", "Capture", 0, SND_SOC_NOPM, 0, 0),
+   SND_SOC_DAPM_AIF_IN("AIFRX", "Playback", 0, SND_SOC_NOPM, 0, 0),
 
SND_SOC_DAPM_DAC("DACL", NULL, NAU8824_REG_RDAC,
NAU8824_DACL_EN_SFT, 0),
@@ -831,6 +831,36 @@ static void nau8824_int_status_clear_all(struct regmap 
*regmap)
}
 }
 
+static void nau8824_dapm_disable_pin(struct nau8824 *nau8824, const char *pin)
+{
+   struct snd_soc_dapm_context *dapm = nau8824->dapm;
+   const char *prefix = dapm->component->name_prefix;
+   char prefixed_pin[80];
+
+   if (prefix) {
+   snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
+prefix, pin);
+   snd_soc_dapm_disable_pin(dapm, prefixed_pin);
+   } else {
+   snd_soc_dapm_disable_pin(dapm, pin);
+   }
+}
+
+static void nau8824_dapm_enable_pin(struct nau8824 *nau8824, const char *pin)
+{
+   struct snd_soc_dapm_context *dapm = nau8824->dapm;
+   const char *prefix = dapm->component->name_prefix;
+   char prefixed_pin[80];
+
+   if (prefix) {
+   snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
+prefix, pin);
+   snd_soc_dapm_force_enable_pin(dapm, prefixed_pin);
+   } else {
+   snd_soc_dapm_force_enable_pin(dapm, pin);
+   }
+}
+
 static void nau8824_eject_jack(struct nau8824 *nau8824)
 {
struct snd_soc_dapm_context *dapm = nau8824->dapm;
@@ -839,8 +869,8 @@ static void nau8824_eject_jack(struct nau8824 *nau8824)
/* Clear all interruption status */
nau8824_int_status_clear_all(regmap);
 
-   snd_soc_dapm_disable_pin(dapm, "SAR");
-   snd_soc_dapm_disable_pin(dapm, "MICBIAS");
+   nau8824_dapm_disable_pin(nau8824, "SAR");
+   nau8824_dapm_disable_pin(nau8824, "MICBIAS");
snd_soc_dapm_sync(dapm);
 
/* Enable the insertion interruption, disable the ejection
@@ -870,8 +900,8 @@ static void nau8824_jdet_work(struct work_struct *work)
struct regmap *regmap = nau8824->regmap;
int adc_value, event = 0, event_mask = 0;
 
-   snd_soc_dapm_force_enable_pin(dapm, "MICBIAS");
-   snd_soc_dapm_force_enable_pin(dapm, "SAR");
+   nau8824_dapm_enable_pin(nau8824, "MICBIAS");
+   nau8824_dapm_enable_pin(nau8824, "SAR");
snd_soc_dapm_sync(dapm);
 
msleep(100);
@@ -882,8 +912,8 @@ static void nau8824_jdet_work(struct work_struct *work)
if (adc_value < HEADSET_SARADC_THD) {
event |= SND_JACK_HEADPHONE;
 
-   snd_soc_dapm_disable_pin(dapm, "SAR");
-   snd_soc_dapm_disable_pin(dapm, "MICBIAS");
+   nau8824_dapm_disable_pin(nau8824, "SAR");
+   nau8824_dapm_disable_pin(nau8824, "MICBIAS");
snd_soc_dapm_sync(dapm);
} else {
event |= SND_JACK_HEADSET;
-- 
2.19.1



[PATCH AUTOSEL 5.0 16/79] ASoC: rt5682: recording has no sound after booting

2019-04-26 Thread Sasha Levin
From: Shuming Fan 

[ Upstream commit 1c5b6a27e432e4fe170a924c8b41012271496a4c ]

If ASRC turns on, HW will use clk_dac as the reference clock
whether recording or playback.
Both of clk_dac and clk_adc should set proper clock while using ASRC.

Signed-off-by: Shuming Fan 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/codecs/rt5682.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
index 9331c13d2017..72ef2a0f6387 100644
--- a/sound/soc/codecs/rt5682.c
+++ b/sound/soc/codecs/rt5682.c
@@ -1202,7 +1202,7 @@ static int set_filter_clk(struct snd_soc_dapm_widget *w,
struct snd_soc_component *component =
snd_soc_dapm_to_component(w->dapm);
struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
-   int ref, val, reg, sft, mask, idx = -EINVAL;
+   int ref, val, reg, idx = -EINVAL;
static const int div_f[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48};
static const int div_o[] = {1, 2, 4, 6, 8, 12, 16, 24, 32, 48};
 
@@ -1216,15 +1216,10 @@ static int set_filter_clk(struct snd_soc_dapm_widget *w,
 
idx = rt5682_div_sel(rt5682, ref, div_f, ARRAY_SIZE(div_f));
 
-   if (w->shift == RT5682_PWR_ADC_S1F_BIT) {
+   if (w->shift == RT5682_PWR_ADC_S1F_BIT)
reg = RT5682_PLL_TRACK_3;
-   sft = RT5682_ADC_OSR_SFT;
-   mask = RT5682_ADC_OSR_MASK;
-   } else {
+   else
reg = RT5682_PLL_TRACK_2;
-   sft = RT5682_DAC_OSR_SFT;
-   mask = RT5682_DAC_OSR_MASK;
-   }
 
snd_soc_component_update_bits(component, reg,
RT5682_FILTER_CLK_DIV_MASK, idx << RT5682_FILTER_CLK_DIV_SFT);
@@ -1236,7 +1231,8 @@ static int set_filter_clk(struct snd_soc_dapm_widget *w,
}
 
snd_soc_component_update_bits(component, RT5682_ADDA_CLK_1,
-   mask, idx << sft);
+   RT5682_ADC_OSR_MASK | RT5682_DAC_OSR_MASK,
+   (idx << RT5682_ADC_OSR_SFT) | (idx << RT5682_DAC_OSR_SFT));
 
return 0;
 }
-- 
2.19.1



[PATCH AUTOSEL 5.0 10/79] ASoC: dpcm: prevent snd_soc_dpcm use after free

2019-04-26 Thread Sasha Levin
From: KaiChieh Chuang 

[ Upstream commit a9764869779081e8bf24da07ac040e8f3efcf13a ]

The dpcm get from fe_clients/be_clients
may be free before use

Add a spin lock at snd_soc_card level,
to protect the dpcm instance.
The lock may be used in atomic context, so use spin lock.

Use irq spin lock version,
since the lock may be used in interrupts.

possible race condition between
void dpcm_be_disconnect(
...
list_del(>list_be);
list_del(>list_fe);
kfree(dpcm);
...

and
for_each_dpcm_fe()
for_each_dpcm_be*()

race condition example
Thread 1:
snd_soc_dapm_mixer_update_power()
-> soc_dpcm_runtime_update()
-> dpcm_be_disconnect()
-> kfree(dpcm);
Thread 2:
dpcm_fe_dai_trigger()
-> dpcm_be_dai_trigger()
-> snd_soc_dpcm_can_be_free_stop()
-> if (dpcm->fe == fe)

Excpetion Scenario:
two FE link to same BE
FE1 -> BE
FE2 ->

Thread 1: switch of mixer between FE2 -> BE
Thread 2: pcm_stop FE1

Exception:

Unable to handle kernel paging request at virtual address dead00e0

pc=<> [] dpcm_be_dai_trigger+0x29c/0x47c
sound/soc/soc-pcm.c:3226
if (dpcm->fe == fe)
lr=<> [] dpcm_fe_dai_do_trigger+0x94/0x26c

Backtrace:
[] notify_die+0x68/0xb8
[] die+0x118/0x2a8
[] __do_kernel_fault+0x13c/0x14c
[] do_translation_fault+0x64/0xa0
[] do_mem_abort+0x4c/0xd0
[] el1_da+0x24/0x40
[] dpcm_be_dai_trigger+0x29c/0x47c
[] dpcm_fe_dai_do_trigger+0x94/0x26c
[] dpcm_fe_dai_trigger+0x3c/0x44
[] snd_pcm_do_stop+0x50/0x5c
[] snd_pcm_action+0xb4/0x13c
[] snd_pcm_drop+0xa0/0x128
[] snd_pcm_common_ioctl+0x9d8/0x30f0
[] snd_pcm_ioctl_compat+0x29c/0x2f14
[] compat_SyS_ioctl+0x128/0x244
[] el0_svc_naked+0x34/0x38
[] 0x

Signed-off-by: KaiChieh Chuang 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 include/sound/soc.h  |  2 ++
 sound/soc/soc-core.c |  1 +
 sound/soc/soc-pcm.c  | 40 +---
 3 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index e665f111b0d2..fa82d6215328 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1043,6 +1043,8 @@ struct snd_soc_card {
struct mutex mutex;
struct mutex dapm_mutex;
 
+   spinlock_t dpcm_lock;
+
bool instantiated;
bool topology_shortname_created;
 
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 50617db05c46..416c371fa01a 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2790,6 +2790,7 @@ int snd_soc_register_card(struct snd_soc_card *card)
card->instantiated = 0;
mutex_init(>mutex);
mutex_init(>dapm_mutex);
+   spin_lock_init(>dpcm_lock);
 
return snd_soc_bind_card(card);
 }
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 0b6ade426516..4c24b13c1016 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1212,6 +1212,7 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe,
struct snd_soc_pcm_runtime *be, int stream)
 {
struct snd_soc_dpcm *dpcm;
+   unsigned long flags;
 
/* only add new dpcms */
for_each_dpcm_be(fe, stream, dpcm) {
@@ -1227,8 +1228,10 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime 
*fe,
dpcm->fe = fe;
be->dpcm[stream].runtime = fe->dpcm[stream].runtime;
dpcm->state = SND_SOC_DPCM_LINK_STATE_NEW;
+   spin_lock_irqsave(>card->dpcm_lock, flags);
list_add(>list_be, >dpcm[stream].be_clients);
list_add(>list_fe, >dpcm[stream].fe_clients);
+   spin_unlock_irqrestore(>card->dpcm_lock, flags);
 
dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n",
stream ? "capture" : "playback",  fe->dai_link->name,
@@ -1274,6 +1277,7 @@ static void dpcm_be_reparent(struct snd_soc_pcm_runtime 
*fe,
 void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream)
 {
struct snd_soc_dpcm *dpcm, *d;
+   unsigned long flags;
 
for_each_dpcm_be_safe(fe, stream, dpcm, d) {
dev_dbg(fe->dev, "ASoC: BE %s disconnect check for %s\n",
@@ -1293,8 +1297,10 @@ void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, 
int stream)
 #ifdef CONFIG_DEBUG_FS
debugfs_remove(dpcm->debugfs_state);
 #endif
+   spin_lock_irqsave(>card->dpcm_lock, flags);
list_del(>list_be);
list_del(>list_fe);
+   spin_unlock_irqrestore(>card->dpcm_lock, flags);
kfree(dpcm);
}
 }
@@ -1546,10 +1552,13 @@ int dpcm_process_paths(struct snd_soc_pcm_runtime *fe,
 void dpcm_clear_pending_state(struct snd_soc_pcm_runtime *fe, int stream)
 {
struct snd_soc_dpcm *dpcm;
+   unsigned long flags;
 
+   spin_lock_irqsave(>card->dpcm_lock, flags);
for_each_dpcm_be(fe, stream, dpcm)

[PATCH AUTOSEL 5.0 18/79] clk: meson-gxbb: round the vdec dividers to closest

2019-04-26 Thread Sasha Levin
From: Maxime Jourdan 

[ Upstream commit 9b70c697e87286ade406e6a02091757307dd4b7c ]

We want the video decoder clocks to always round to closest. While the
muxes are already using CLK_MUX_ROUND_CLOSEST, the corresponding
CLK_DIVIDER_ROUND_CLOSEST was forgotten for the dividers.

Fix this by adding the flag to the two vdec dividers.

Fixes: a565242eb9fc ("clk: meson: gxbb: add the video decoder clocks")
Signed-off-by: Maxime Jourdan 
Acked-by: Neil Armstrong 
Signed-off-by: Neil Armstrong 
Link: https://lkml.kernel.org/r/20190319102537.2043-1-mjour...@baylibre.com
Signed-off-by: Sasha Levin 
---
 drivers/clk/meson/gxbb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c
index 65f2599e5243..08824b2cd142 100644
--- a/drivers/clk/meson/gxbb.c
+++ b/drivers/clk/meson/gxbb.c
@@ -2213,6 +2213,7 @@ static struct clk_regmap gxbb_vdec_1_div = {
.offset = HHI_VDEC_CLK_CNTL,
.shift = 0,
.width = 7,
+   .flags = CLK_DIVIDER_ROUND_CLOSEST,
},
.hw.init = &(struct clk_init_data){
.name = "vdec_1_div",
@@ -2258,6 +2259,7 @@ static struct clk_regmap gxbb_vdec_hevc_div = {
.offset = HHI_VDEC2_CLK_CNTL,
.shift = 16,
.width = 7,
+   .flags = CLK_DIVIDER_ROUND_CLOSEST,
},
.hw.init = &(struct clk_init_data){
.name = "vdec_hevc_div",
-- 
2.19.1



[PATCH AUTOSEL 5.0 21/79] ASoC: cs4270: Set auto-increment bit for register writes

2019-04-26 Thread Sasha Levin
From: Daniel Mack 

[ Upstream commit f0f2338a9cfaf71db895fa989ea7234e8a9b471d ]

The CS4270 does not by default increment the register address on
consecutive writes. During normal operation it doesn't matter as all
register accesses are done individually. At resume time after suspend,
however, the regcache code gathers the biggest possible block of
registers to sync and sends them one on one go.

To fix this, set the INCR bit in all cases.

Signed-off-by: Daniel Mack 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/codecs/cs4270.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c
index 33d74f163bd7..793a14d58667 100644
--- a/sound/soc/codecs/cs4270.c
+++ b/sound/soc/codecs/cs4270.c
@@ -642,6 +642,7 @@ static const struct regmap_config cs4270_regmap = {
.reg_defaults = cs4270_reg_defaults,
.num_reg_defaults = ARRAY_SIZE(cs4270_reg_defaults),
.cache_type =   REGCACHE_RBTREE,
+   .write_flag_mask =  CS4270_I2C_INCR,
 
.readable_reg = cs4270_reg_is_readable,
.volatile_reg = cs4270_reg_is_volatile,
-- 
2.19.1



[PATCH AUTOSEL 5.0 30/79] ASoC: dpcm: skip missing substream while applying symmetry

2019-04-26 Thread Sasha Levin
From: Jerome Brunet 

[ Upstream commit 6246f283d5e02ac757bd8d9bacde8fdc54c4582d ]

If for any reason, the backend does not have the requested substream
(like capture on a playback only backend), the BE will be skipped in
dpcm_be_dai_startup().

However, dpcm_apply_symmetry() does not skip those BE and will
dereference the be_substream (NULL) pointer anyway.

Like in dpcm_be_dai_startup(), just skip those BE.

Fixes: 906c7d690c3b ("ASoC: dpcm: Apply symmetry for DPCM")
Signed-off-by: Jerome Brunet 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/soc-pcm.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 4c24b13c1016..22946493a11f 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1907,10 +1907,15 @@ static int dpcm_apply_symmetry(struct snd_pcm_substream 
*fe_substream,
struct snd_soc_pcm_runtime *be = dpcm->be;
struct snd_pcm_substream *be_substream =
snd_soc_dpcm_get_substream(be, stream);
-   struct snd_soc_pcm_runtime *rtd = be_substream->private_data;
+   struct snd_soc_pcm_runtime *rtd;
struct snd_soc_dai *codec_dai;
int i;
 
+   /* A backend may not have the requested substream */
+   if (!be_substream)
+   continue;
+
+   rtd = be_substream->private_data;
if (rtd->dai_link->be_hw_params_fixup)
continue;
 
-- 
2.19.1



[PATCH AUTOSEL 5.0 20/79] ASoC: stm32: dfsdm: fix debugfs warnings on entry creation

2019-04-26 Thread Sasha Levin
From: Olivier Moysan 

[ Upstream commit c47255b61129857b74b0d86eaf59335348be05e0 ]

Register platform component with a prefix, to avoid warnings
on debugfs entries creation, due to component name
redundancy.

Signed-off-by: Olivier Moysan 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/stm/stm32_adfsdm.c | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/sound/soc/stm/stm32_adfsdm.c b/sound/soc/stm/stm32_adfsdm.c
index 71d341b732a4..24948b95eb19 100644
--- a/sound/soc/stm/stm32_adfsdm.c
+++ b/sound/soc/stm/stm32_adfsdm.c
@@ -304,6 +304,7 @@ MODULE_DEVICE_TABLE(of, stm32_adfsdm_of_match);
 static int stm32_adfsdm_probe(struct platform_device *pdev)
 {
struct stm32_adfsdm_priv *priv;
+   struct snd_soc_component *component;
int ret;
 
priv = devm_kzalloc(>dev, sizeof(*priv), GFP_KERNEL);
@@ -331,9 +332,15 @@ static int stm32_adfsdm_probe(struct platform_device *pdev)
if (IS_ERR(priv->iio_cb))
return PTR_ERR(priv->iio_cb);
 
-   ret = devm_snd_soc_register_component(>dev,
- _adfsdm_soc_platform,
- NULL, 0);
+   component = devm_kzalloc(>dev, sizeof(*component), GFP_KERNEL);
+   if (!component)
+   return -ENOMEM;
+#ifdef CONFIG_DEBUG_FS
+   component->debugfs_prefix = "pcm";
+#endif
+
+   ret = snd_soc_add_component(>dev, component,
+   _adfsdm_soc_platform, NULL, 0);
if (ret < 0)
dev_err(>dev, "%s: Failed to register PCM platform\n",
__func__);
@@ -341,12 +348,20 @@ static int stm32_adfsdm_probe(struct platform_device 
*pdev)
return ret;
 }
 
+static int stm32_adfsdm_remove(struct platform_device *pdev)
+{
+   snd_soc_unregister_component(>dev);
+
+   return 0;
+}
+
 static struct platform_driver stm32_adfsdm_driver = {
.driver = {
   .name = STM32_ADFSDM_DRV_NAME,
   .of_match_table = stm32_adfsdm_of_match,
   },
.probe = stm32_adfsdm_probe,
+   .remove = stm32_adfsdm_remove,
 };
 
 module_platform_driver(stm32_adfsdm_driver);
-- 
2.19.1



[PATCH AUTOSEL 5.0 19/79] ASoC: stm32: dfsdm: manage multiple prepare

2019-04-26 Thread Sasha Levin
From: Olivier Moysan 

[ Upstream commit 19441e35a43b616ea6afad91ed0d9e77268d8f6a ]

The DFSDM must be stopped when a new setting is applied.
restart systematically DFSDM on multiple prepare calls,
to apply changes.

Signed-off-by: Olivier Moysan 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/stm/stm32_adfsdm.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/sound/soc/stm/stm32_adfsdm.c b/sound/soc/stm/stm32_adfsdm.c
index 706ff005234f..71d341b732a4 100644
--- a/sound/soc/stm/stm32_adfsdm.c
+++ b/sound/soc/stm/stm32_adfsdm.c
@@ -9,6 +9,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -37,6 +38,8 @@ struct stm32_adfsdm_priv {
/* PCM buffer */
unsigned char *pcm_buff;
unsigned int pos;
+
+   struct mutex lock; /* protect against race condition on iio state */
 };
 
 static const struct snd_pcm_hardware stm32_adfsdm_pcm_hw = {
@@ -62,10 +65,12 @@ static void stm32_adfsdm_shutdown(struct snd_pcm_substream 
*substream,
 {
struct stm32_adfsdm_priv *priv = snd_soc_dai_get_drvdata(dai);
 
+   mutex_lock(>lock);
if (priv->iio_active) {
iio_channel_stop_all_cb(priv->iio_cb);
priv->iio_active = false;
}
+   mutex_unlock(>lock);
 }
 
 static int stm32_adfsdm_dai_prepare(struct snd_pcm_substream *substream,
@@ -74,13 +79,19 @@ static int stm32_adfsdm_dai_prepare(struct 
snd_pcm_substream *substream,
struct stm32_adfsdm_priv *priv = snd_soc_dai_get_drvdata(dai);
int ret;
 
+   mutex_lock(>lock);
+   if (priv->iio_active) {
+   iio_channel_stop_all_cb(priv->iio_cb);
+   priv->iio_active = false;
+   }
+
ret = iio_write_channel_attribute(priv->iio_ch,
  substream->runtime->rate, 0,
  IIO_CHAN_INFO_SAMP_FREQ);
if (ret < 0) {
dev_err(dai->dev, "%s: Failed to set %d sampling rate\n",
__func__, substream->runtime->rate);
-   return ret;
+   goto out;
}
 
if (!priv->iio_active) {
@@ -92,6 +103,9 @@ static int stm32_adfsdm_dai_prepare(struct snd_pcm_substream 
*substream,
__func__, ret);
}
 
+out:
+   mutex_unlock(>lock);
+
return ret;
 }
 
@@ -298,6 +312,7 @@ static int stm32_adfsdm_probe(struct platform_device *pdev)
 
priv->dev = >dev;
priv->dai_drv = stm32_adfsdm_dai;
+   mutex_init(>lock);
 
dev_set_drvdata(>dev, priv);
 
-- 
2.19.1



[PATCH AUTOSEL 5.0 31/79] perf/x86/intel: Fix handling of wakeup_events for multi-entry PEBS

2019-04-26 Thread Sasha Levin
From: Stephane Eranian 

[ Upstream commit 583feb08e7f7ac9d533b446882eb3a54737a6dbb ]

When an event is programmed with attr.wakeup_events=N (N>0), it means
the caller is interested in getting a user level notification after
N samples have been recorded in the kernel sampling buffer.

With precise events on Intel processors, the kernel uses PEBS.
The kernel tries minimize sampling overhead by verifying
if the event configuration is compatible with multi-entry PEBS mode.
If so, the kernel is notified only when the buffer has reached its threshold.
Other PEBS operates in single-entry mode, the kenrel is notified for each
PEBS sample.

The problem is that the current implementation look at frequency
mode and event sample_type but ignores the wakeup_events field. Thus,
it may not be possible to receive a notification after each precise event.

This patch fixes this problem by disabling multi-entry PEBS if wakeup_events
is non-zero.

Signed-off-by: Stephane Eranian 
Signed-off-by: Peter Zijlstra (Intel) 
Reviewed-by: Andi Kleen 
Cc: Alexander Shishkin 
Cc: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vince Weaver 
Cc: kan.li...@intel.com
Link: https://lkml.kernel.org/r/20190306195048.189514-1-eran...@google.com
Signed-off-by: Ingo Molnar 
Signed-off-by: Sasha Levin 
---
 arch/x86/events/intel/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index 2480feb07df3..c647595666c2 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3184,7 +3184,7 @@ static int intel_pmu_hw_config(struct perf_event *event)
return ret;
 
if (event->attr.precise_ip) {
-   if (!event->attr.freq) {
+   if (!(event->attr.freq || event->attr.wakeup_events)) {
event->hw.flags |= PERF_X86_EVENT_AUTO_RELOAD;
if (!(event->attr.sample_type &
  ~intel_pmu_large_pebs_flags(event)))
-- 
2.19.1



[PATCH AUTOSEL 5.0 33/79] linux/kernel.h: Use parentheses around argument in u64_to_user_ptr()

2019-04-26 Thread Sasha Levin
From: Jann Horn 

[ Upstream commit a0fe2c6479aab5723239b315ef1b552673f434a3 ]

Use parentheses around uses of the argument in u64_to_user_ptr() to
ensure that the cast doesn't apply to part of the argument.

There are existing uses of the macro of the form

  u64_to_user_ptr(A + B)

which expands to

  (void __user *)(uintptr_t)A + B

(the cast applies to the first operand of the addition, the addition
is a pointer addition). This happens to still work as intended, the
semantic difference doesn't cause a difference in behavior.

But I want to use u64_to_user_ptr() with a ternary operator in the
argument, like so:

  u64_to_user_ptr(A ? B : C)

This currently doesn't work as intended.

Signed-off-by: Jann Horn 
Signed-off-by: Borislav Petkov 
Reviewed-by: Mukesh Ojha 
Cc: Andrei Vagin 
Cc: Andrew Morton 
Cc: Dan Carpenter 
Cc: Greg Kroah-Hartman 
Cc: "H. Peter Anvin" 
Cc: Ingo Molnar 
Cc: Jani Nikula 
Cc: Kees Cook 
Cc: Masahiro Yamada 
Cc: NeilBrown 
Cc: Peter Zijlstra 
Cc: Qiaowei Ren 
Cc: Thomas Gleixner 
Cc: x86-ml 
Link: https://lkml.kernel.org/r/20190329214652.258477-1-ja...@google.com
Signed-off-by: Sasha Levin 
---
 include/linux/kernel.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 8f0e68e250a7..fd827b240059 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -73,8 +73,8 @@
 
 #define u64_to_user_ptr(x) (   \
 {  \
-   typecheck(u64, x);  \
-   (void __user *)(uintptr_t)x;\
+   typecheck(u64, (x));\
+   (void __user *)(uintptr_t)(x);  \
 }  \
 )
 
-- 
2.19.1



[PATCH AUTOSEL 5.0 37/79] ASoC: rockchip: pdm: fix regmap_ops hang issue

2019-04-26 Thread Sasha Levin
From: Sugar Zhang 

[ Upstream commit c85064435fe7a216ec0f0238ef2b8f7cd850a450 ]

This is because set_fmt ops maybe called when PD is off,
and in such case, regmap_ops will lead system hang.
enale PD before doing regmap_ops.

Signed-off-by: Sugar Zhang 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/rockchip/rockchip_pdm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/soc/rockchip/rockchip_pdm.c 
b/sound/soc/rockchip/rockchip_pdm.c
index 400e29edb1c9..8a2e3bbce3a1 100644
--- a/sound/soc/rockchip/rockchip_pdm.c
+++ b/sound/soc/rockchip/rockchip_pdm.c
@@ -208,7 +208,9 @@ static int rockchip_pdm_set_fmt(struct snd_soc_dai *cpu_dai,
return -EINVAL;
}
 
+   pm_runtime_get_sync(cpu_dai->dev);
regmap_update_bits(pdm->regmap, PDM_CLK_CTRL, mask, val);
+   pm_runtime_put(cpu_dai->dev);
 
return 0;
 }
-- 
2.19.1



[PATCH AUTOSEL 5.0 35/79] iov_iter: Fix build error without CONFIG_CRYPTO

2019-04-26 Thread Sasha Levin
From: YueHaibing 

[ Upstream commit 27fad74a5a77fe2e1f876db7bf27efcf2ec304b2 ]

If CONFIG_CRYPTO is not set or set to m,
gcc building warn this:

lib/iov_iter.o: In function `hash_and_copy_to_iter':
iov_iter.c:(.text+0x9129): undefined reference to `crypto_stats_get'
iov_iter.c:(.text+0x9152): undefined reference to `crypto_stats_ahash_update'

Reported-by: Hulk Robot 
Fixes: d05f443554b3 ("iov_iter: introduce hash_and_copy_to_iter helper")
Suggested-by: Al Viro 
Signed-off-by: YueHaibing 
Signed-off-by: Al Viro 
Signed-off-by: Sasha Levin 
---
 lib/iov_iter.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index be4bd627caf0..a0d1cd88f903 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -1515,6 +1515,7 @@ EXPORT_SYMBOL(csum_and_copy_to_iter);
 size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp,
struct iov_iter *i)
 {
+#ifdef CONFIG_CRYPTO
struct ahash_request *hash = hashp;
struct scatterlist sg;
size_t copied;
@@ -1524,6 +1525,9 @@ size_t hash_and_copy_to_iter(const void *addr, size_t 
bytes, void *hashp,
ahash_request_set_crypt(hash, , NULL, copied);
crypto_ahash_update(hash);
return copied;
+#else
+   return 0;
+#endif
 }
 EXPORT_SYMBOL(hash_and_copy_to_iter);
 
-- 
2.19.1



[PATCH AUTOSEL 5.0 45/79] slab: fix a crash by reading /proc/slab_allocators

2019-04-26 Thread Sasha Levin
From: Qian Cai 

[ Upstream commit fcf88917dd435c6a4cb2830cb086ee58605a1d85 ]

The commit 510ded33e075 ("slab: implement slab_root_caches list")
changes the name of the list node within "struct kmem_cache" from "list"
to "root_caches_node", but leaks_show() still use the "list" which
causes a crash when reading /proc/slab_allocators.

You need to have CONFIG_SLAB=y and CONFIG_MEMCG=y to see the problem,
because without MEMCG all slab caches are root caches, and the "list"
node happens to be the right one.

Fixes: 510ded33e075 ("slab: implement slab_root_caches list")
Signed-off-by: Qian Cai 
Reviewed-by: Tobin C. Harding 
Cc: Tejun Heo 
Cc: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Sasha Levin 
---
 mm/slab.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/slab.c b/mm/slab.c
index 2f2aa8eaf7d9..188c4b65255d 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -4297,7 +4297,8 @@ static void show_symbol(struct seq_file *m, unsigned long 
address)
 
 static int leaks_show(struct seq_file *m, void *p)
 {
-   struct kmem_cache *cachep = list_entry(p, struct kmem_cache, list);
+   struct kmem_cache *cachep = list_entry(p, struct kmem_cache,
+  root_caches_node);
struct page *page;
struct kmem_cache_node *n;
const char *name;
-- 
2.19.1



[PATCH AUTOSEL 5.0 42/79] ASoC: cs35l35: Disable regulators on driver removal

2019-04-26 Thread Sasha Levin
From: Charles Keepax 

[ Upstream commit 47c4cc08cb5b34e93ab337b924c5ede77ca3c936 ]

The chips main power supplies VA and VP are enabled during probe but
then never disabled, this will cause warnings from the regulator
framework on driver removal. Fix this by adding a remove callback and
disabling the supplies, whilst doing so follow best practice and put the
chip back into reset as well.

Signed-off-by: Charles Keepax 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/codecs/cs35l35.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/sound/soc/codecs/cs35l35.c b/sound/soc/codecs/cs35l35.c
index 9f4a59871cee..c71696146c5e 100644
--- a/sound/soc/codecs/cs35l35.c
+++ b/sound/soc/codecs/cs35l35.c
@@ -1635,6 +1635,16 @@ err:
return ret;
 }
 
+static int cs35l35_i2c_remove(struct i2c_client *i2c_client)
+{
+   struct cs35l35_private *cs35l35 = i2c_get_clientdata(i2c_client);
+
+   regulator_bulk_disable(cs35l35->num_supplies, cs35l35->supplies);
+   gpiod_set_value_cansleep(cs35l35->reset_gpio, 0);
+
+   return 0;
+}
+
 static const struct of_device_id cs35l35_of_match[] = {
{.compatible = "cirrus,cs35l35"},
{},
@@ -1655,6 +1665,7 @@ static struct i2c_driver cs35l35_i2c_driver = {
},
.id_table = cs35l35_id,
.probe = cs35l35_i2c_probe,
+   .remove = cs35l35_i2c_remove,
 };
 
 module_i2c_driver(cs35l35_i2c_driver);
-- 
2.19.1



[PATCH AUTOSEL 5.0 43/79] objtool: Add rewind_stack_do_exit() to the noreturn list

2019-04-26 Thread Sasha Levin
From: Josh Poimboeuf 

[ Upstream commit 4fa5ecda2bf96be7464eb406df8aba9d89260227 ]

This fixes the following warning seen on GCC 7.3:

  arch/x86/kernel/dumpstack.o: warning: objtool: oops_end() falls through to 
next function show_regs()

Reported-by: kbuild test robot 
Signed-off-by: Josh Poimboeuf 
Signed-off-by: Thomas Gleixner 
Cc: Peter Zijlstra 
Link: 
https://lkml.kernel.org/r/3418ebf5a5a9f6ed7e80954c741c0b904b67b5dc.1554398240.git.jpoim...@redhat.com
Signed-off-by: Sasha Levin 
---
 tools/objtool/check.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 5dde107083c6..479196aeb409 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -165,6 +165,7 @@ static int __dead_end_function(struct objtool_file *file, 
struct symbol *func,
"fortify_panic",
"usercopy_abort",
"machine_real_restart",
+   "rewind_stack_do_exit",
};
 
if (func->bind == STB_WEAK)
-- 
2.19.1



[PATCH AUTOSEL 5.0 49/79] RDMA/vmw_pvrdma: Fix memory leak on pvrdma_pci_remove

2019-04-26 Thread Sasha Levin
From: Kamal Heib 

[ Upstream commit ea7a5c706fa49273cf6d1d9def053ecb50db2076 ]

Make sure to free the DSR on pvrdma_pci_remove() to avoid the memory leak.

Fixes: 29c8d9eba550 ("IB: Add vmw_pvrdma driver")
Signed-off-by: Kamal Heib 
Acked-by: Adit Ranadive 
Signed-off-by: Jason Gunthorpe 
Signed-off-by: Sasha Levin 
---
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c 
b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c
index 39c37b6fd715..76b8dda40edd 100644
--- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c
+++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c
@@ -1125,6 +1125,8 @@ static void pvrdma_pci_remove(struct pci_dev *pdev)
pvrdma_page_dir_cleanup(dev, >cq_pdir);
pvrdma_page_dir_cleanup(dev, >async_pdir);
pvrdma_free_slots(dev);
+   dma_free_coherent(>dev, sizeof(*dev->dsr), dev->dsr,
+ dev->dsrbase);
 
iounmap(dev->regs);
kfree(dev->sgid_tbl);
-- 
2.19.1



[PATCH AUTOSEL 5.0 47/79] drm/sun4i: tcon top: Fix NULL/invalid pointer dereference in sun8i_tcon_top_un/bind

2019-04-26 Thread Sasha Levin
From: Ondrej Jirman 

[ Upstream commit 1a07a94b47b1f528f39c3e6187b5eaf02efe44ea ]

There are two problems here:

1. Not all clk_data->hws[] need to be initialized, depending on various
   configured quirks. This leads to NULL ptr deref in
   clk_hw_unregister_gate() in sun8i_tcon_top_unbind()
2. If there is error when registering the clk_data->hws[],
   err_unregister_gates error path will try to unregister
   IS_ERR()=true (invalid) pointer.

For problem (1) I have this stack trace:

Unable to handle kernel NULL pointer dereference at virtual
  address 0008
Call trace:
 clk_hw_unregister+0x8/0x18
 clk_hw_unregister_gate+0x14/0x28
 sun8i_tcon_top_unbind+0x2c/0x60
 component_unbind.isra.4+0x2c/0x50
 component_bind_all+0x1d4/0x230
 sun4i_drv_bind+0xc4/0x1a0
 try_to_bring_up_master+0x164/0x1c0
 __component_add+0xa0/0x168
 component_add+0x10/0x18
 sun8i_dw_hdmi_probe+0x18/0x20
 platform_drv_probe+0x3c/0x70
 really_probe+0xcc/0x278
 driver_probe_device+0x34/0xa8

Problem (2) was identified by head scratching.

Signed-off-by: Ondrej Jirman 
Signed-off-by: Maxime Ripard 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20190405233048.3823-1-meg...@megous.com
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/sun4i/sun8i_tcon_top.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c 
b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
index fc36e0c10a37..b1e7c76e9c17 100644
--- a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
+++ b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
@@ -227,7 +227,7 @@ static int sun8i_tcon_top_bind(struct device *dev, struct 
device *master,
 
 err_unregister_gates:
for (i = 0; i < CLK_NUM; i++)
-   if (clk_data->hws[i])
+   if (!IS_ERR_OR_NULL(clk_data->hws[i]))
clk_hw_unregister_gate(clk_data->hws[i]);
clk_disable_unprepare(tcon_top->bus);
 err_assert_reset:
@@ -245,7 +245,8 @@ static void sun8i_tcon_top_unbind(struct device *dev, 
struct device *master,
 
of_clk_del_provider(dev->of_node);
for (i = 0; i < CLK_NUM; i++)
-   clk_hw_unregister_gate(clk_data->hws[i]);
+   if (clk_data->hws[i])
+   clk_hw_unregister_gate(clk_data->hws[i]);
 
clk_disable_unprepare(tcon_top->bus);
reset_control_assert(tcon_top->rst);
-- 
2.19.1



[PATCH AUTOSEL 5.0 50/79] RDMA/hns: Fix bug that caused srq creation to fail

2019-04-26 Thread Sasha Levin
From: Lijun Ou 

[ Upstream commit 4772e03d239484f3461e33c79d721c8ea03f7416 ]

Due to the incorrect use of the seg and obj information, the position of
the mtt is calculated incorrectly, and the free space of the page is not
enough to store the entire mtt, resulting in access to the next page. This
patch fixes this problem.

 Unable to handle kernel paging request at virtual address 6e3cd000
 ...
 Call trace:
  hns_roce_write_mtt+0x154/0x2f0 [hns_roce]
  hns_roce_buf_write_mtt+0xa8/0xd8 [hns_roce]
  hns_roce_create_srq+0x74c/0x808 [hns_roce]
  ib_create_srq+0x28/0xc8

Fixes: 0203b14c4f32 ("RDMA/hns: Unify the calculation for hem index in hip08")
Signed-off-by: chenglang 
Signed-off-by: Lijun Ou 
Signed-off-by: Jason Gunthorpe 
Signed-off-by: Sasha Levin 
---
 drivers/infiniband/hw/hns/hns_roce_hem.c | 6 --
 drivers/infiniband/hw/hns/hns_roce_mr.c  | 4 ++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hem.c 
b/drivers/infiniband/hw/hns/hns_roce_hem.c
index 4cdbcafa5915..cae23364cfea 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hem.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hem.c
@@ -763,6 +763,8 @@ void *hns_roce_table_find(struct hns_roce_dev *hr_dev,
idx_offset = (obj & (table->num_obj - 1)) % obj_per_chunk;
dma_offset = offset = idx_offset * table->obj_size;
} else {
+   u32 seg_size = 64; /* 8 bytes per BA and 8 BA per segment */
+
hns_roce_calc_hem_mhop(hr_dev, table, _obj, );
/* mtt mhop */
i = mhop.l0_idx;
@@ -774,8 +776,8 @@ void *hns_roce_table_find(struct hns_roce_dev *hr_dev,
hem_idx = i;
 
hem = table->hem[hem_idx];
-   dma_offset = offset = (obj & (table->num_obj - 1)) *
-  table->obj_size % mhop.bt_chunk_size;
+   dma_offset = offset = (obj & (table->num_obj - 1)) * seg_size %
+  mhop.bt_chunk_size;
if (mhop.hop_num == 2)
dma_offset = offset = 0;
}
diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c 
b/drivers/infiniband/hw/hns/hns_roce_mr.c
index ee5991bd4171..dd4bb0ec6113 100644
--- a/drivers/infiniband/hw/hns/hns_roce_mr.c
+++ b/drivers/infiniband/hw/hns/hns_roce_mr.c
@@ -746,7 +746,6 @@ static int hns_roce_write_mtt_chunk(struct hns_roce_dev 
*hr_dev,
struct hns_roce_hem_table *table;
dma_addr_t dma_handle;
__le64 *mtts;
-   u32 s = start_index * sizeof(u64);
u32 bt_page_size;
u32 i;
 
@@ -780,7 +779,8 @@ static int hns_roce_write_mtt_chunk(struct hns_roce_dev 
*hr_dev,
return -EINVAL;
 
mtts = hns_roce_table_find(hr_dev, table,
-   mtt->first_seg + s / hr_dev->caps.mtt_entry_sz,
+   mtt->first_seg +
+   start_index / HNS_ROCE_MTT_ENTRY_PER_SEG,
_handle);
if (!mtts)
return -ENOMEM;
-- 
2.19.1



[PATCH AUTOSEL 5.0 48/79] virtio_pci: fix a NULL pointer reference in vp_del_vqs

2019-04-26 Thread Sasha Levin
From: Longpeng 

[ Upstream commit 6a8aae68c87349dbbcd46eac380bc43cdb98a13b ]

If the msix_affinity_masks is alloced failed, then we'll
try to free some resources in vp_free_vectors() that may
access it directly.

We met the following stack in our production:
[   29.296767] BUG: unable to handle kernel NULL pointer dereference at  (null)
[   29.311151] IP: [] vp_free_vectors+0x6a/0x150 [virtio_pci]
[   29.324787] PGD 0
[   29.333224] Oops:  [#1] SMP
[...]
[   29.425175] RIP: 0010:[]  [] 
vp_free_vectors+0x6a/0x150 [virtio_pci]
[   29.441405] RSP: 0018:9a55c2dcfa10  EFLAGS: 00010206
[   29.453491] RAX:  RBX: 9a55c322c400 RCX: 
[   29.467488] RDX:  RSI:  RDI: 9a55c322c400
[   29.481461] RBP: 9a55c2dcfa20 R08:  R09: c1b6806ff020
[   29.495427] R10: 0e95 R11: 00aa R12: 
[   29.509414] R13: 0001 R14: 9a55bd2d9e98 R15: 9a55c322c400
[   29.523407] FS:  7fdcba69f8c0() GS:9a55c284() 
knlGS:
[   29.538472] CS:  0010 DS:  ES:  CR0: 80050033
[   29.551621] CR2:  CR3: 3ce52000 CR4: 003607a0
[   29.565886] DR0:  DR1:  DR2: 
[   29.580055] DR3:  DR6: fffe0ff0 DR7: 0400
[   29.594122] Call Trace:
[   29.603446]  [] vp_request_msix_vectors+0xe2/0x260 
[virtio_pci]
[   29.618017]  [] vp_try_to_find_vqs+0x95/0x3b0 [virtio_pci]
[   29.632152]  [] vp_find_vqs+0x37/0xb0 [virtio_pci]
[   29.645582]  [] init_vq+0x153/0x260 [virtio_blk]
[   29.658831]  [] virtblk_probe+0xe8/0x87f [virtio_blk]
[...]

Cc: Gonglei 
Signed-off-by: Longpeng 
Signed-off-by: Michael S. Tsirkin 
Reviewed-by: Gonglei 
Signed-off-by: Sasha Levin 
---
 drivers/virtio/virtio_pci_common.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/virtio/virtio_pci_common.c 
b/drivers/virtio/virtio_pci_common.c
index d0584c040c60..7a0398bb84f7 100644
--- a/drivers/virtio/virtio_pci_common.c
+++ b/drivers/virtio/virtio_pci_common.c
@@ -255,9 +255,11 @@ void vp_del_vqs(struct virtio_device *vdev)
for (i = 0; i < vp_dev->msix_used_vectors; ++i)
free_irq(pci_irq_vector(vp_dev->pci_dev, i), vp_dev);
 
-   for (i = 0; i < vp_dev->msix_vectors; i++)
-   if (vp_dev->msix_affinity_masks[i])
-   free_cpumask_var(vp_dev->msix_affinity_masks[i]);
+   if (vp_dev->msix_affinity_masks) {
+   for (i = 0; i < vp_dev->msix_vectors; i++)
+   if (vp_dev->msix_affinity_masks[i])
+   
free_cpumask_var(vp_dev->msix_affinity_masks[i]);
+   }
 
if (vp_dev->msix_enabled) {
/* Disable the vector used for configuration */
-- 
2.19.1



[PATCH AUTOSEL 5.0 52/79] KEYS: trusted: fix -Wvarags warning

2019-04-26 Thread Sasha Levin
From: "ndesaulni...@google.com" 

[ Upstream commit be24b37e22c20cbaa891971616784dd0f35211e8 ]

Fixes the warning reported by Clang:
security/keys/trusted.c:146:17: warning: passing an object that
undergoes default
  argument promotion to 'va_start' has undefined behavior [-Wvarargs]
va_start(argp, h3);
   ^
security/keys/trusted.c:126:37: note: parameter of type 'unsigned
char' is declared here
unsigned char *h2, unsigned char h3, ...)
   ^
Specifically, it seems that both the C90 (4.8.1.1) and C11 (7.16.1.4)
standards explicitly call this out as undefined behavior:

The parameter parmN is the identifier of the rightmost parameter in
the variable parameter list in the function definition (the one just
before the ...). If the parameter parmN is declared with ... or with a
type that is not compatible with the type that results after
application of the default argument promotions, the behavior is
undefined.

Link: https://github.com/ClangBuiltLinux/linux/issues/41
Link: https://www.eskimo.com/~scs/cclass/int/sx11c.html
Suggested-by: David Laight 
Suggested-by: Denis Kenzior 
Suggested-by: James Bottomley 
Suggested-by: Nathan Chancellor 
Signed-off-by: Nick Desaulniers 
Reviewed-by: Nathan Chancellor 
Tested-by: Nathan Chancellor 
Reviewed-by: Jarkko Sakkinen 
Signed-off-by: Jarkko Sakkinen 
Signed-off-by: James Morris 
Signed-off-by: Sasha Levin 
---
 include/keys/trusted.h  | 2 +-
 security/keys/trusted.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/keys/trusted.h b/include/keys/trusted.h
index adbcb6817826..0071298b9b28 100644
--- a/include/keys/trusted.h
+++ b/include/keys/trusted.h
@@ -38,7 +38,7 @@ enum {
 
 int TSS_authhmac(unsigned char *digest, const unsigned char *key,
unsigned int keylen, unsigned char *h1,
-   unsigned char *h2, unsigned char h3, ...);
+   unsigned char *h2, unsigned int h3, ...);
 int TSS_checkhmac1(unsigned char *buffer,
  const uint32_t command,
  const unsigned char *ononce,
diff --git a/security/keys/trusted.c b/security/keys/trusted.c
index 4d98f4f87236..94d2b28c7c22 100644
--- a/security/keys/trusted.c
+++ b/security/keys/trusted.c
@@ -123,7 +123,7 @@ out:
  */
 int TSS_authhmac(unsigned char *digest, const unsigned char *key,
unsigned int keylen, unsigned char *h1,
-   unsigned char *h2, unsigned char h3, ...)
+   unsigned char *h2, unsigned int h3, ...)
 {
unsigned char paramdigest[SHA1_DIGEST_SIZE];
struct sdesc *sdesc;
@@ -139,7 +139,7 @@ int TSS_authhmac(unsigned char *digest, const unsigned char 
*key,
return PTR_ERR(sdesc);
}
 
-   c = h3;
+   c = !!h3;
ret = crypto_shash_init(>shash);
if (ret < 0)
goto out;
-- 
2.19.1



[PATCH AUTOSEL 5.0 53/79] scsi: csiostor: fix missing data copy in csio_scsi_err_handler()

2019-04-26 Thread Sasha Levin
From: Varun Prakash 

[ Upstream commit 5c2442fd78998af60e13aba506d103f7f43f8701 ]

If scsi cmd sglist is not suitable for DDP then csiostor driver uses
preallocated buffers for DDP, because of this data copy is required from
DDP buffer to scsi cmd sglist before calling ->scsi_done().

Signed-off-by: Varun Prakash 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/scsi/csiostor/csio_scsi.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/csiostor/csio_scsi.c 
b/drivers/scsi/csiostor/csio_scsi.c
index bc5547a62c00..c54c6cd504c4 100644
--- a/drivers/scsi/csiostor/csio_scsi.c
+++ b/drivers/scsi/csiostor/csio_scsi.c
@@ -1713,8 +1713,11 @@ csio_scsi_err_handler(struct csio_hw *hw, struct 
csio_ioreq *req)
}
 
 out:
-   if (req->nsge > 0)
+   if (req->nsge > 0) {
scsi_dma_unmap(cmnd);
+   if (req->dcopy && (host_status == DID_OK))
+   host_status = csio_scsi_copy_to_sgl(hw, req);
+   }
 
cmnd->result = (((host_status) << 16) | scsi_status);
cmnd->scsi_done(cmnd);
-- 
2.19.1



[PATCH AUTOSEL 5.0 57/79] drm/mediatek: remove flag CLK_SET_RATE_PARENT for MT2701 hdmi phy

2019-04-26 Thread Sasha Levin
From: Wangyan Wang 

[ Upstream commit 827abdd024207146822f66ba3ba74867135866b9 ]

This is the first step to make MT2701 hdmi stable.
The parent rate of hdmi phy had set by DPI driver.
We should not set or change the parent rate of MT2701 hdmi phy,
as a result we should remove the flags of "CLK_SET_RATE_PARENT"
from the clock of MT2701 hdmi phy.

Signed-off-by: Wangyan Wang 
Signed-off-by: CK Hu 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/mediatek/mtk_hdmi_phy.c| 13 +
 drivers/gpu/drm/mediatek/mtk_hdmi_phy.h|  1 +
 drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c |  1 +
 drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c |  1 +
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi_phy.c 
b/drivers/gpu/drm/mediatek/mtk_hdmi_phy.c
index efc400ebbb90..08b029772c5a 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi_phy.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi_phy.c
@@ -102,13 +102,11 @@ mtk_hdmi_phy_dev_get_ops(const struct mtk_hdmi_phy 
*hdmi_phy)
return NULL;
 }
 
-static void mtk_hdmi_phy_clk_get_ops(struct mtk_hdmi_phy *hdmi_phy,
-const struct clk_ops **ops)
+static void mtk_hdmi_phy_clk_get_data(struct mtk_hdmi_phy *hdmi_phy,
+ struct clk_init_data *clk_init)
 {
-   if (hdmi_phy && hdmi_phy->conf && hdmi_phy->conf->hdmi_phy_clk_ops)
-   *ops = hdmi_phy->conf->hdmi_phy_clk_ops;
-   else
-   dev_err(hdmi_phy->dev, "Failed to get clk ops of phy\n");
+   clk_init->flags = hdmi_phy->conf->flags;
+   clk_init->ops = hdmi_phy->conf->hdmi_phy_clk_ops;
 }
 
 static int mtk_hdmi_phy_probe(struct platform_device *pdev)
@@ -121,7 +119,6 @@ static int mtk_hdmi_phy_probe(struct platform_device *pdev)
struct clk_init_data clk_init = {
.num_parents = 1,
.parent_names = (const char * const *)_clk_name,
-   .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE,
};
 
struct phy *phy;
@@ -159,7 +156,7 @@ static int mtk_hdmi_phy_probe(struct platform_device *pdev)
hdmi_phy->dev = dev;
hdmi_phy->conf =
(struct mtk_hdmi_phy_conf *)of_device_get_match_data(dev);
-   mtk_hdmi_phy_clk_get_ops(hdmi_phy, _init.ops);
+   mtk_hdmi_phy_clk_get_data(hdmi_phy, _init);
hdmi_phy->pll_hw.init = _init;
hdmi_phy->pll = devm_clk_register(dev, _phy->pll_hw);
if (IS_ERR(hdmi_phy->pll)) {
diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi_phy.h 
b/drivers/gpu/drm/mediatek/mtk_hdmi_phy.h
index 71430691ffe4..d28b8d5ed2b4 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi_phy.h
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi_phy.h
@@ -21,6 +21,7 @@ struct mtk_hdmi_phy;
 
 struct mtk_hdmi_phy_conf {
bool tz_disabled;
+   unsigned long flags;
const struct clk_ops *hdmi_phy_clk_ops;
void (*hdmi_phy_enable_tmds)(struct mtk_hdmi_phy *hdmi_phy);
void (*hdmi_phy_disable_tmds)(struct mtk_hdmi_phy *hdmi_phy);
diff --git a/drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c 
b/drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c
index feb6a7ed63d1..31f3175f032b 100644
--- a/drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c
+++ b/drivers/gpu/drm/mediatek/mtk_mt2701_hdmi_phy.c
@@ -232,6 +232,7 @@ static void mtk_hdmi_phy_disable_tmds(struct mtk_hdmi_phy 
*hdmi_phy)
 
 struct mtk_hdmi_phy_conf mtk_hdmi_phy_2701_conf = {
.tz_disabled = true,
+   .flags = CLK_SET_RATE_GATE,
.hdmi_phy_clk_ops = _hdmi_phy_pll_ops,
.hdmi_phy_enable_tmds = mtk_hdmi_phy_enable_tmds,
.hdmi_phy_disable_tmds = mtk_hdmi_phy_disable_tmds,
diff --git a/drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c 
b/drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c
index 83662a208491..37f9503d7643 100644
--- a/drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c
+++ b/drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c
@@ -317,6 +317,7 @@ static void mtk_hdmi_phy_disable_tmds(struct mtk_hdmi_phy 
*hdmi_phy)
 }
 
 struct mtk_hdmi_phy_conf mtk_hdmi_phy_8173_conf = {
+   .flags = CLK_SET_RATE_PARENT | CLK_SET_RATE_GATE,
.hdmi_phy_clk_ops = _hdmi_phy_pll_ops,
.hdmi_phy_enable_tmds = mtk_hdmi_phy_enable_tmds,
.hdmi_phy_disable_tmds = mtk_hdmi_phy_disable_tmds,
-- 
2.19.1



[PATCH AUTOSEL 5.0 60/79] Bluetooth: btusb: request wake pin with NOAUTOEN

2019-04-26 Thread Sasha Levin
From: Brian Norris 

[ Upstream commit 771acc7e4a6e5dba779cb1a7fd851a164bc81033 ]

Badly-designed systems might have (for example) active-high wake pins
that default to high (e.g., because of external pull ups) until they
have an active firmware which starts driving it low.  This can cause an
interrupt storm in the time between request_irq() and disable_irq().

We don't support shared interrupts here, so let's just pre-configure the
interrupt to avoid auto-enabling it.

Fixes: fd913ef7ce61 ("Bluetooth: btusb: Add out-of-band wakeup support")
Fixes: 5364a0b4f4be ("arm64: dts: rockchip: move QCA6174A wakeup pin into its 
USB node")
Signed-off-by: Brian Norris 
Reviewed-by: Matthias Kaehlcke 
Signed-off-by: Linus Torvalds 
Signed-off-by: Sasha Levin 
---
 drivers/bluetooth/btusb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 4761499db9ee..470ee68555d9 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2885,6 +2885,7 @@ static int btusb_config_oob_wake(struct hci_dev *hdev)
return 0;
}
 
+   irq_set_status_flags(irq, IRQ_NOAUTOEN);
ret = devm_request_irq(>dev, irq, btusb_oob_wake_handler,
   0, "OOB Wake-on-BT", data);
if (ret) {
@@ -2899,7 +2900,6 @@ static int btusb_config_oob_wake(struct hci_dev *hdev)
}
 
data->oob_wake_irq = irq;
-   disable_irq(irq);
bt_dev_info(hdev, "OOB Wake-on-BT configured at IRQ %u", irq);
return 0;
 }
-- 
2.19.1



[PATCH AUTOSEL 5.0 68/79] clk: x86: Add system specific quirk to mark clocks as critical

2019-04-26 Thread Sasha Levin
From: David Müller 

[ Upstream commit 7c2e07130090ae001a97a6b65597830d6815e93e ]

Since commit 648e921888ad ("clk: x86: Stop marking clocks as
CLK_IS_CRITICAL"), the pmc_plt_clocks of the Bay Trail SoC are
unconditionally gated off. Unfortunately this will break systems where these
clocks are used for external purposes beyond the kernel's knowledge. Fix it
by implementing a system specific quirk to mark the necessary pmc_plt_clks as
critical.

Fixes: 648e921888ad ("clk: x86: Stop marking clocks as CLK_IS_CRITICAL")
Signed-off-by: David Müller 
Signed-off-by: Hans de Goede 
Reviewed-by: Andy Shevchenko 
Signed-off-by: Stephen Boyd 
Signed-off-by: Sasha Levin 
---
 drivers/clk/x86/clk-pmc-atom.c| 14 ++---
 drivers/platform/x86/pmc_atom.c   | 21 +++
 .../linux/platform_data/x86/clk-pmc-atom.h|  3 +++
 3 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/x86/clk-pmc-atom.c b/drivers/clk/x86/clk-pmc-atom.c
index d977193842df..19174835693b 100644
--- a/drivers/clk/x86/clk-pmc-atom.c
+++ b/drivers/clk/x86/clk-pmc-atom.c
@@ -165,7 +165,7 @@ static const struct clk_ops plt_clk_ops = {
 };
 
 static struct clk_plt *plt_clk_register(struct platform_device *pdev, int id,
-   void __iomem *base,
+   const struct pmc_clk_data *pmc_data,
const char **parent_names,
int num_parents)
 {
@@ -184,9 +184,17 @@ static struct clk_plt *plt_clk_register(struct 
platform_device *pdev, int id,
init.num_parents = num_parents;
 
pclk->hw.init = 
-   pclk->reg = base + PMC_CLK_CTL_OFFSET + id * PMC_CLK_CTL_SIZE;
+   pclk->reg = pmc_data->base + PMC_CLK_CTL_OFFSET + id * PMC_CLK_CTL_SIZE;
spin_lock_init(>lock);
 
+   /*
+* On some systems, the pmc_plt_clocks already enabled by the
+* firmware are being marked as critical to avoid them being
+* gated by the clock framework.
+*/
+   if (pmc_data->critical && plt_clk_is_enabled(>hw))
+   init.flags |= CLK_IS_CRITICAL;
+
ret = devm_clk_hw_register(>dev, >hw);
if (ret) {
pclk = ERR_PTR(ret);
@@ -332,7 +340,7 @@ static int plt_clk_probe(struct platform_device *pdev)
return PTR_ERR(parent_names);
 
for (i = 0; i < PMC_CLK_NUM; i++) {
-   data->clks[i] = plt_clk_register(pdev, i, pmc_data->base,
+   data->clks[i] = plt_clk_register(pdev, i, pmc_data,
 parent_names, data->nparents);
if (IS_ERR(data->clks[i])) {
err = PTR_ERR(data->clks[i]);
diff --git a/drivers/platform/x86/pmc_atom.c b/drivers/platform/x86/pmc_atom.c
index 8f018b3f3cd4..eaec2d306481 100644
--- a/drivers/platform/x86/pmc_atom.c
+++ b/drivers/platform/x86/pmc_atom.c
@@ -17,6 +17,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -391,11 +392,27 @@ static int pmc_dbgfs_register(struct pmc_dev *pmc)
 }
 #endif /* CONFIG_DEBUG_FS */
 
+/*
+ * Some systems need one or more of their pmc_plt_clks to be
+ * marked as critical.
+ */
+static const struct dmi_system_id critclk_systems[] __initconst = {
+   {
+   .ident = "MPL CEC1x",
+   .matches = {
+   DMI_MATCH(DMI_SYS_VENDOR, "MPL AG"),
+   DMI_MATCH(DMI_PRODUCT_NAME, "CEC10 Family"),
+   },
+   },
+   { /*sentinel*/ }
+};
+
 static int pmc_setup_clks(struct pci_dev *pdev, void __iomem *pmc_regmap,
  const struct pmc_data *pmc_data)
 {
struct platform_device *clkdev;
struct pmc_clk_data *clk_data;
+   const struct dmi_system_id *d = dmi_first_match(critclk_systems);
 
clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL);
if (!clk_data)
@@ -403,6 +420,10 @@ static int pmc_setup_clks(struct pci_dev *pdev, void 
__iomem *pmc_regmap,
 
clk_data->base = pmc_regmap; /* offset is added by client */
clk_data->clks = pmc_data->clks;
+   if (d) {
+   clk_data->critical = true;
+   pr_info("%s critclks quirk enabled\n", d->ident);
+   }
 
clkdev = platform_device_register_data(>dev, "clk-pmc-atom",
   PLATFORM_DEVID_NONE,
diff --git a/include/linux/platform_data/x86/clk-pmc-atom.h 
b/include/linux/platform_data/x86/clk-pmc-atom.h
index 3ab892208343..7a37ac27d0fb 100644
--- a/include/linux/platform_data/x86/clk-pmc-atom.h
+++ b/include/linux/platform_data/x86/clk-pmc-atom.h
@@ -35,10 +35,13 @@ struct pmc_clk {
  *
  * @base:  PMC clock register base offset
  * @clks:  pointer to set of registered clocks, typically 0..5
+ * @critical:  flag to indicate if firmware enabled pmc_plt_clks
+ * should be marked as critial or not
  */
 struct 

[PATCH AUTOSEL 5.0 61/79] ASoC: Intel: kbl: fix wrong number of channels

2019-04-26 Thread Sasha Levin
From: Tzung-Bi Shih 

[ Upstream commit d6ba3f815bc5f3c4249d15c8bc5fbb012651b4a4 ]

Fix wrong setting on number of channels.  The context wants to set
constraint to 2 channels instead of 4.

Signed-off-by: Tzung-Bi Shih 
Acked-by: Pierre-Louis Bossart 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c 
b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
index 7044d8c2b187..879f14257a3e 100644
--- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
+++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
@@ -405,7 +405,7 @@ static const struct snd_pcm_hw_constraint_list 
constraints_dmic_channels = {
 };
 
 static const unsigned int dmic_2ch[] = {
-   4,
+   2,
 };
 
 static const struct snd_pcm_hw_constraint_list constraints_dmic_2ch = {
-- 
2.19.1



[PATCH AUTOSEL 5.0 71/79] platform/x86: pmc_atom: Drop __initconst on dmi table

2019-04-26 Thread Sasha Levin
From: Stephen Boyd 

[ Upstream commit b995dcca7cf12f208cfd95fd9d5768dca7cccec7 ]

It's used by probe and that isn't an init function. Drop this so that we
don't get a section mismatch.

Reported-by: kbuild test robot 
Cc: David Müller 
Cc: Hans de Goede 
Cc: Andy Shevchenko 
Fixes: 7c2e07130090 ("clk: x86: Add system specific quirk to mark clocks as 
critical")
Signed-off-by: Stephen Boyd 
Signed-off-by: Sasha Levin 
---
 drivers/platform/x86/pmc_atom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/pmc_atom.c b/drivers/platform/x86/pmc_atom.c
index eaec2d306481..c7039f52ad51 100644
--- a/drivers/platform/x86/pmc_atom.c
+++ b/drivers/platform/x86/pmc_atom.c
@@ -396,7 +396,7 @@ static int pmc_dbgfs_register(struct pmc_dev *pmc)
  * Some systems need one or more of their pmc_plt_clks to be
  * marked as critical.
  */
-static const struct dmi_system_id critclk_systems[] __initconst = {
+static const struct dmi_system_id critclk_systems[] = {
{
.ident = "MPL CEC1x",
.matches = {
-- 
2.19.1



[PATCH AUTOSEL 4.19 02/53] ASoC: hdmi-codec: fix S/PDIF DAI

2019-04-26 Thread Sasha Levin
From: Russell King 

[ Upstream commit 2e95f984aae4cf0608d0ba2189c756f2bd50b44a ]

When using the S/PDIF DAI, there is no requirement to call
snd_soc_dai_set_fmt() as there is no DAI format definition that defines
S/PDIF.  In any case, S/PDIF does not have separate clocks, this is
embedded into the data stream.

Consequently, when attempting to use TDA998x in S/PDIF mode, the attempt
to configure TDA998x via the hw_params callback fails as the
hdmi_codec_daifmt is left initialised to zero.

Since the S/PDIF DAI will only be used by S/PDIF, prepare the
hdmi_codec_daifmt structure for this format.

Signed-off-by: Russell King 
Reviewed-by: Jyri Sarha 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/codecs/hdmi-codec.c | 118 +-
 1 file changed, 59 insertions(+), 59 deletions(-)

diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index e5b6769b9797..d5f73c837281 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -529,73 +529,71 @@ static int hdmi_codec_set_fmt(struct snd_soc_dai *dai,
 {
struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
struct hdmi_codec_daifmt cf = { 0 };
-   int ret = 0;
 
dev_dbg(dai->dev, "%s()\n", __func__);
 
-   if (dai->id == DAI_ID_SPDIF) {
-   cf.fmt = HDMI_SPDIF;
-   } else {
-   switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
-   case SND_SOC_DAIFMT_CBM_CFM:
-   cf.bit_clk_master = 1;
-   cf.frame_clk_master = 1;
-   break;
-   case SND_SOC_DAIFMT_CBS_CFM:
-   cf.frame_clk_master = 1;
-   break;
-   case SND_SOC_DAIFMT_CBM_CFS:
-   cf.bit_clk_master = 1;
-   break;
-   case SND_SOC_DAIFMT_CBS_CFS:
-   break;
-   default:
-   return -EINVAL;
-   }
+   if (dai->id == DAI_ID_SPDIF)
+   return 0;
+
+   switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
+   case SND_SOC_DAIFMT_CBM_CFM:
+   cf.bit_clk_master = 1;
+   cf.frame_clk_master = 1;
+   break;
+   case SND_SOC_DAIFMT_CBS_CFM:
+   cf.frame_clk_master = 1;
+   break;
+   case SND_SOC_DAIFMT_CBM_CFS:
+   cf.bit_clk_master = 1;
+   break;
+   case SND_SOC_DAIFMT_CBS_CFS:
+   break;
+   default:
+   return -EINVAL;
+   }
 
-   switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
-   case SND_SOC_DAIFMT_NB_NF:
-   break;
-   case SND_SOC_DAIFMT_NB_IF:
-   cf.frame_clk_inv = 1;
-   break;
-   case SND_SOC_DAIFMT_IB_NF:
-   cf.bit_clk_inv = 1;
-   break;
-   case SND_SOC_DAIFMT_IB_IF:
-   cf.frame_clk_inv = 1;
-   cf.bit_clk_inv = 1;
-   break;
-   }
+   switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
+   case SND_SOC_DAIFMT_NB_NF:
+   break;
+   case SND_SOC_DAIFMT_NB_IF:
+   cf.frame_clk_inv = 1;
+   break;
+   case SND_SOC_DAIFMT_IB_NF:
+   cf.bit_clk_inv = 1;
+   break;
+   case SND_SOC_DAIFMT_IB_IF:
+   cf.frame_clk_inv = 1;
+   cf.bit_clk_inv = 1;
+   break;
+   }
 
-   switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
-   case SND_SOC_DAIFMT_I2S:
-   cf.fmt = HDMI_I2S;
-   break;
-   case SND_SOC_DAIFMT_DSP_A:
-   cf.fmt = HDMI_DSP_A;
-   break;
-   case SND_SOC_DAIFMT_DSP_B:
-   cf.fmt = HDMI_DSP_B;
-   break;
-   case SND_SOC_DAIFMT_RIGHT_J:
-   cf.fmt = HDMI_RIGHT_J;
-   break;
-   case SND_SOC_DAIFMT_LEFT_J:
-   cf.fmt = HDMI_LEFT_J;
-   break;
-   case SND_SOC_DAIFMT_AC97:
-   cf.fmt = HDMI_AC97;
-   break;
-   default:
-   dev_err(dai->dev, "Invalid DAI interface format\n");
-   return -EINVAL;
-   }
+   switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
+   case SND_SOC_DAIFMT_I2S:
+   cf.fmt = HDMI_I2S;
+   break;
+   case SND_SOC_DAIFMT_DSP_A:
+   cf.fmt = HDMI_DSP_A;
+   break;
+   case SND_SOC_DAIFMT_DSP_B:
+   cf.fmt = HDMI_DSP_B;
+   break;
+   case SND_SOC_DAIFMT_RIGHT_J:
+   cf.fmt = HDMI_RIGHT_J;
+   break;
+   case SND_SOC_DAIFMT_LEFT_J:
+ 

[PATCH AUTOSEL 5.0 64/79] block, bfq: fix use after free in bfq_bfqq_expire

2019-04-26 Thread Sasha Levin
From: Paolo Valente 

[ Upstream commit eed47d19d9362bdd958e4ab56af480b9dbf6b2b6 ]

The function bfq_bfqq_expire() invokes the function
__bfq_bfqq_expire(), and the latter may free the in-service bfq-queue.
If this happens, then no other instruction of bfq_bfqq_expire() must
be executed, or a use-after-free will occur.

Basing on the assumption that __bfq_bfqq_expire() invokes
bfq_put_queue() on the in-service bfq-queue exactly once, the queue is
assumed to be freed if its refcounter is equal to one right before
invoking __bfq_bfqq_expire().

But, since commit 9dee8b3b057e ("block, bfq: fix queue removal from
weights tree") this assumption is false. __bfq_bfqq_expire() may also
invoke bfq_weights_tree_remove() and, since commit 9dee8b3b057e
("block, bfq: fix queue removal from weights tree"), also
the latter function may invoke bfq_put_queue(). So __bfq_bfqq_expire()
may invoke bfq_put_queue() twice, and this is the actual case where
the in-service queue may happen to be freed.

To address this issue, this commit moves the check on the refcounter
of the queue right around the last bfq_put_queue() that may be invoked
on the queue.

Fixes: 9dee8b3b057e ("block, bfq: fix queue removal from weights tree")
Reported-by: Dmitrii Tcvetkov 
Reported-by: Douglas Anderson 
Tested-by: Dmitrii Tcvetkov 
Tested-by: Douglas Anderson 
Signed-off-by: Paolo Valente 
Signed-off-by: Jens Axboe 
Signed-off-by: Sasha Levin 
---
 block/bfq-iosched.c | 15 +++
 block/bfq-iosched.h |  2 +-
 block/bfq-wf2q.c| 17 +++--
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index e5ed28629271..72510c470001 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -2804,7 +2804,7 @@ static void bfq_dispatch_remove(struct request_queue *q, 
struct request *rq)
bfq_remove_request(q, rq);
 }
 
-static void __bfq_bfqq_expire(struct bfq_data *bfqd, struct bfq_queue *bfqq)
+static bool __bfq_bfqq_expire(struct bfq_data *bfqd, struct bfq_queue *bfqq)
 {
/*
 * If this bfqq is shared between multiple processes, check
@@ -2837,9 +2837,11 @@ static void __bfq_bfqq_expire(struct bfq_data *bfqd, 
struct bfq_queue *bfqq)
/*
 * All in-service entities must have been properly deactivated
 * or requeued before executing the next function, which
-* resets all in-service entites as no more in service.
+* resets all in-service entities as no more in service. This
+* may cause bfqq to be freed. If this happens, the next
+* function returns true.
 */
-   __bfq_bfqd_reset_in_service(bfqd);
+   return __bfq_bfqd_reset_in_service(bfqd);
 }
 
 /**
@@ -3244,7 +3246,6 @@ void bfq_bfqq_expire(struct bfq_data *bfqd,
bool slow;
unsigned long delta = 0;
struct bfq_entity *entity = >entity;
-   int ref;
 
/*
 * Check whether the process is slow (see bfq_bfqq_is_slow).
@@ -3313,10 +3314,8 @@ void bfq_bfqq_expire(struct bfq_data *bfqd,
 * reason.
 */
__bfq_bfqq_recalc_budget(bfqd, bfqq, reason);
-   ref = bfqq->ref;
-   __bfq_bfqq_expire(bfqd, bfqq);
-
-   if (ref == 1) /* bfqq is gone, no more actions on it */
+   if (__bfq_bfqq_expire(bfqd, bfqq))
+   /* bfqq is gone, no more actions on it */
return;
 
bfqq->injected_service = 0;
diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
index 746bd570b85a..ca98c98a8179 100644
--- a/block/bfq-iosched.h
+++ b/block/bfq-iosched.h
@@ -993,7 +993,7 @@ bool __bfq_deactivate_entity(struct bfq_entity *entity,
 bool ins_into_idle_tree);
 bool next_queue_may_preempt(struct bfq_data *bfqd);
 struct bfq_queue *bfq_get_next_queue(struct bfq_data *bfqd);
-void __bfq_bfqd_reset_in_service(struct bfq_data *bfqd);
+bool __bfq_bfqd_reset_in_service(struct bfq_data *bfqd);
 void bfq_deactivate_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq,
 bool ins_into_idle_tree, bool expiration);
 void bfq_activate_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq);
diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c
index 4aab1a8191f0..8077bf71d2ac 100644
--- a/block/bfq-wf2q.c
+++ b/block/bfq-wf2q.c
@@ -1599,7 +1599,8 @@ struct bfq_queue *bfq_get_next_queue(struct bfq_data 
*bfqd)
return bfqq;
 }
 
-void __bfq_bfqd_reset_in_service(struct bfq_data *bfqd)
+/* returns true if the in-service queue gets freed */
+bool __bfq_bfqd_reset_in_service(struct bfq_data *bfqd)
 {
struct bfq_queue *in_serv_bfqq = bfqd->in_service_queue;
struct bfq_entity *in_serv_entity = _serv_bfqq->entity;
@@ -1623,8 +1624,20 @@ void __bfq_bfqd_reset_in_service(struct bfq_data *bfqd)
 * service tree either, then release the service reference to
 * the queue it represents (taken with bfq_get_entity).
 */
-   if (!in_serv_entity->on_st)
+   if (!in_serv_entity->on_st) {
+  

[PATCH AUTOSEL 5.0 72/79] NFS: Forbid setting AF_INET6 to "struct sockaddr_in"->sin_family.

2019-04-26 Thread Sasha Levin
From: Tetsuo Handa 

[ Upstream commit 7c2bd9a39845bfb6d72ddb55ce737650271f6f96 ]

syzbot is reporting uninitialized value at rpc_sockaddr2uaddr() [1]. This
is because syzbot is setting AF_INET6 to "struct sockaddr_in"->sin_family
(which is embedded into user-visible "struct nfs_mount_data" structure)
despite nfs23_validate_mount_data() cannot pass sizeof(struct sockaddr_in6)
bytes of AF_INET6 address to rpc_sockaddr2uaddr().

Since "struct nfs_mount_data" structure is user-visible, we can't change
"struct nfs_mount_data" to use "struct sockaddr_storage". Therefore,
assuming that everybody is using AF_INET family when passing address via
"struct nfs_mount_data"->addr, reject if its sin_family is not AF_INET.

[1] 
https://syzkaller.appspot.com/bug?id=53614e7cbbf66bc2656a919ab2a95fb5d75c

Reported-by: syzbot 
Signed-off-by: Tetsuo Handa 
Signed-off-by: Trond Myklebust 
Signed-off-by: Sasha Levin 
---
 fs/nfs/super.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 0570391eaa16..15c025c1a305 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2041,7 +2041,8 @@ static int nfs23_validate_mount_data(void *options,
memcpy(sap, >addr, sizeof(data->addr));
args->nfs_server.addrlen = sizeof(data->addr);
args->nfs_server.port = ntohs(data->addr.sin_port);
-   if (!nfs_verify_server_address(sap))
+   if (sap->sa_family != AF_INET ||
+   !nfs_verify_server_address(sap))
goto out_no_address;
 
if (!(data->flags & NFS_MOUNT_TCP))
-- 
2.19.1



[PATCH AUTOSEL 5.0 66/79] blk-mq: introduce blk_mq_complete_request_sync()

2019-04-26 Thread Sasha Levin
From: Ming Lei 

[ Upstream commit 1b8f21b74c3c9c82fce5a751d7aefb7cc0b8d33d ]

In NVMe's error handler, follows the typical steps of tearing down
hardware for recovering controller:

1) stop blk_mq hw queues
2) stop the real hw queues
3) cancel in-flight requests via
blk_mq_tagset_busy_iter(tags, cancel_request, ...)
cancel_request():
mark the request as abort
blk_mq_complete_request(req);
4) destroy real hw queues

However, there may be race between #3 and #4, because blk_mq_complete_request()
may run q->mq_ops->complete(rq) remotelly and asynchronously, and
->complete(rq) may be run after #4.

This patch introduces blk_mq_complete_request_sync() for fixing the
above race.

Cc: Sagi Grimberg 
Cc: Bart Van Assche 
Cc: James Smart 
Cc: linux-n...@lists.infradead.org
Reviewed-by: Keith Busch 
Reviewed-by: Christoph Hellwig 
Signed-off-by: Ming Lei 
Signed-off-by: Jens Axboe 
Signed-off-by: Sasha Levin 
---
 block/blk-mq.c | 7 +++
 include/linux/blk-mq.h | 1 +
 2 files changed, 8 insertions(+)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 16f9675c57e6..ce462c313806 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -657,6 +657,13 @@ bool blk_mq_complete_request(struct request *rq)
 }
 EXPORT_SYMBOL(blk_mq_complete_request);
 
+void blk_mq_complete_request_sync(struct request *rq)
+{
+   WRITE_ONCE(rq->state, MQ_RQ_COMPLETE);
+   rq->q->mq_ops->complete(rq);
+}
+EXPORT_SYMBOL_GPL(blk_mq_complete_request_sync);
+
 int blk_mq_request_started(struct request *rq)
 {
return blk_mq_rq_state(rq) != MQ_RQ_IDLE;
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 0e030f5f76b6..7e092bdac27f 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -306,6 +306,7 @@ void blk_mq_add_to_requeue_list(struct request *rq, bool 
at_head,
 void blk_mq_kick_requeue_list(struct request_queue *q);
 void blk_mq_delay_kick_requeue_list(struct request_queue *q, unsigned long 
msecs);
 bool blk_mq_complete_request(struct request *rq);
+void blk_mq_complete_request_sync(struct request *rq);
 bool blk_mq_bio_list_merge(struct request_queue *q, struct list_head *list,
   struct bio *bio);
 bool blk_mq_queue_stopped(struct request_queue *q);
-- 
2.19.1



[PATCH AUTOSEL 5.0 69/79] nvme-fc: correct csn initialization and increments on error

2019-04-26 Thread Sasha Levin
From: James Smart 

[ Upstream commit 67f471b6ed3b09033c4ac77ea03f92afdb1989fe ]

This patch fixes a long-standing bug that initialized the FC-NVME
cmnd iu CSN value to 1. Early FC-NVME specs had the connection starting
with CSN=1. By the time the spec reached approval, the language had
changed to state a connection should start with CSN=0.  This patch
corrects the initialization value for FC-NVME connections.

Additionally, in reviewing the transport, the CSN value is assigned to
the new IU early in the start routine. It's possible that a later dma
map request may fail, causing the command to never be sent to the
controller.  Change the location of the assignment so that it is
immediately prior to calling the lldd. Add a comment block to explain
the impacts if the lldd were to additionally fail sending the command.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
Reviewed-by: Ewan D. Milne 
Signed-off-by: Christoph Hellwig 
Signed-off-by: Sasha Levin 
---
 drivers/nvme/host/fc.c | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index c37d5bbd72ab..8625b73d94bf 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -1857,7 +1857,7 @@ nvme_fc_init_queue(struct nvme_fc_ctrl *ctrl, int idx)
memset(queue, 0, sizeof(*queue));
queue->ctrl = ctrl;
queue->qnum = idx;
-   atomic_set(>csn, 1);
+   atomic_set(>csn, 0);
queue->dev = ctrl->dev;
 
if (idx > 0)
@@ -1899,7 +1899,7 @@ nvme_fc_free_queue(struct nvme_fc_queue *queue)
 */
 
queue->connection_id = 0;
-   atomic_set(>csn, 1);
+   atomic_set(>csn, 0);
 }
 
 static void
@@ -2195,7 +2195,6 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct 
nvme_fc_queue *queue,
 {
struct nvme_fc_cmd_iu *cmdiu = >cmd_iu;
struct nvme_command *sqe = >sqe;
-   u32 csn;
int ret, opstate;
 
/*
@@ -2210,8 +2209,6 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct 
nvme_fc_queue *queue,
 
/* format the FC-NVME CMD IU and fcp_req */
cmdiu->connection_id = cpu_to_be64(queue->connection_id);
-   csn = atomic_inc_return(>csn);
-   cmdiu->csn = cpu_to_be32(csn);
cmdiu->data_len = cpu_to_be32(data_len);
switch (io_dir) {
case NVMEFC_FCP_WRITE:
@@ -2269,11 +2266,24 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct 
nvme_fc_queue *queue,
if (!(op->flags & FCOP_FLAGS_AEN))
blk_mq_start_request(op->rq);
 
+   cmdiu->csn = cpu_to_be32(atomic_inc_return(>csn));
ret = ctrl->lport->ops->fcp_io(>lport->localport,
>rport->remoteport,
queue->lldd_handle, >fcp_req);
 
if (ret) {
+   /*
+* If the lld fails to send the command is there an issue with
+* the csn value?  If the command that fails is the Connect,
+* no - as the connection won't be live.  If it is a command
+* post-connect, it's possible a gap in csn may be created.
+* Does this matter?  As Linux initiators don't send fused
+* commands, no.  The gap would exist, but as there's nothing
+* that depends on csn order to be delivered on the target
+* side, it shouldn't hurt.  It would be difficult for a
+* target to even detect the csn gap as it has no idea when the
+* cmd with the csn was supposed to arrive.
+*/
opstate = atomic_xchg(>state, FCPOP_STATE_COMPLETE);
__nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate);
 
-- 
2.19.1



[PATCH AUTOSEL 5.0 76/79] mm: make page ref count overflow check tighter and more explicit

2019-04-26 Thread Sasha Levin
From: Linus Torvalds 

[ Upstream commit f958d7b528b1b40c44cfda5eabe2d82760d868c3 ]

We have a VM_BUG_ON() to check that the page reference count doesn't
underflow (or get close to overflow) by checking the sign of the count.

That's all fine, but we actually want to allow people to use a "get page
ref unless it's already very high" helper function, and we want that one
to use the sign of the page ref (without triggering this VM_BUG_ON).

Change the VM_BUG_ON to only check for small underflows (or _very_ close
to overflowing), and ignore overflows which have strayed into negative
territory.

Acked-by: Matthew Wilcox 
Cc: Jann Horn 
Cc: sta...@kernel.org
Signed-off-by: Linus Torvalds 
Signed-off-by: Sasha Levin 
---
 include/linux/mm.h | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 80bb6408fe73..541d99b86aea 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -965,6 +965,10 @@ static inline bool is_pci_p2pdma_page(const struct page 
*page)
 }
 #endif /* CONFIG_DEV_PAGEMAP_OPS */
 
+/* 127: arbitrary random number, small enough to assemble well */
+#define page_ref_zero_or_close_to_overflow(page) \
+   ((unsigned int) page_ref_count(page) + 127u <= 127u)
+
 static inline void get_page(struct page *page)
 {
page = compound_head(page);
@@ -972,7 +976,7 @@ static inline void get_page(struct page *page)
 * Getting a normal page or the head of a compound page
 * requires to already have an elevated page->_refcount.
 */
-   VM_BUG_ON_PAGE(page_ref_count(page) <= 0, page);
+   VM_BUG_ON_PAGE(page_ref_zero_or_close_to_overflow(page), page);
page_ref_inc(page);
 }
 
-- 
2.19.1



[PATCH AUTOSEL 5.0 75/79] iommu/amd: Set exclusion range correctly

2019-04-26 Thread Sasha Levin
From: Joerg Roedel 

[ Upstream commit 3c677d206210f53a4be972211066c0f1cd47fe12 ]

The exlcusion range limit register needs to contain the
base-address of the last page that is part of the range, as
bits 0-11 of this register are treated as 0xfff by the
hardware for comparisons.

So correctly set the exclusion range in the hardware to the
last page which is _in_ the range.

Fixes: b2026aa2dce44 ('x86, AMD IOMMU: add functions for programming IOMMU MMIO 
space')
Signed-off-by: Joerg Roedel 
Signed-off-by: Sasha Levin 
---
 drivers/iommu/amd_iommu_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 66123b911ec8..8ae6b350e64c 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -358,7 +358,7 @@ static void iommu_write_l2(struct amd_iommu *iommu, u8 
address, u32 val)
 static void iommu_set_exclusion_range(struct amd_iommu *iommu)
 {
u64 start = iommu->exclusion_start & PAGE_MASK;
-   u64 limit = (start + iommu->exclusion_length) & PAGE_MASK;
+   u64 limit = (start + iommu->exclusion_length - 1) & PAGE_MASK;
u64 entry;
 
if (!iommu->exclusion_start)
-- 
2.19.1



[PATCH AUTOSEL 4.19 24/53] perf/x86/intel: Fix handling of wakeup_events for multi-entry PEBS

2019-04-26 Thread Sasha Levin
From: Stephane Eranian 

[ Upstream commit 583feb08e7f7ac9d533b446882eb3a54737a6dbb ]

When an event is programmed with attr.wakeup_events=N (N>0), it means
the caller is interested in getting a user level notification after
N samples have been recorded in the kernel sampling buffer.

With precise events on Intel processors, the kernel uses PEBS.
The kernel tries minimize sampling overhead by verifying
if the event configuration is compatible with multi-entry PEBS mode.
If so, the kernel is notified only when the buffer has reached its threshold.
Other PEBS operates in single-entry mode, the kenrel is notified for each
PEBS sample.

The problem is that the current implementation look at frequency
mode and event sample_type but ignores the wakeup_events field. Thus,
it may not be possible to receive a notification after each precise event.

This patch fixes this problem by disabling multi-entry PEBS if wakeup_events
is non-zero.

Signed-off-by: Stephane Eranian 
Signed-off-by: Peter Zijlstra (Intel) 
Reviewed-by: Andi Kleen 
Cc: Alexander Shishkin 
Cc: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Vince Weaver 
Cc: kan.li...@intel.com
Link: https://lkml.kernel.org/r/20190306195048.189514-1-eran...@google.com
Signed-off-by: Ingo Molnar 
Signed-off-by: Sasha Levin 
---
 arch/x86/events/intel/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index 12453cf7c11b..c02a8e6aff52 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3068,7 +3068,7 @@ static int intel_pmu_hw_config(struct perf_event *event)
return ret;
 
if (event->attr.precise_ip) {
-   if (!event->attr.freq) {
+   if (!(event->attr.freq || event->attr.wakeup_events)) {
event->hw.flags |= PERF_X86_EVENT_AUTO_RELOAD;
if (!(event->attr.sample_type &
  ~intel_pmu_large_pebs_flags(event)))
-- 
2.19.1



[PATCH AUTOSEL 4.19 09/53] ASoC: nau8810: fix the issue of widget with prefixed name

2019-04-26 Thread Sasha Levin
From: John Hsu 

[ Upstream commit 54d1cf78b0f4ba348a7c7fb8b7d0708d71b6cc8a ]

The driver changes the stream name of DAC and ADC to avoid the issue of
widget with prefixed name. When the machine adds prefixed name for codec,
the stream name of DAI may not find the widgets.

Signed-off-by: John Hsu 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/codecs/nau8810.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/nau8810.c b/sound/soc/codecs/nau8810.c
index bfd74b86c9d2..645aa0794123 100644
--- a/sound/soc/codecs/nau8810.c
+++ b/sound/soc/codecs/nau8810.c
@@ -411,9 +411,9 @@ static const struct snd_soc_dapm_widget 
nau8810_dapm_widgets[] = {
SND_SOC_DAPM_MIXER("Mono Mixer", NAU8810_REG_POWER3,
NAU8810_MOUTMX_EN_SFT, 0, _mono_mixer_controls[0],
ARRAY_SIZE(nau8810_mono_mixer_controls)),
-   SND_SOC_DAPM_DAC("DAC", "HiFi Playback", NAU8810_REG_POWER3,
+   SND_SOC_DAPM_DAC("DAC", "Playback", NAU8810_REG_POWER3,
NAU8810_DAC_EN_SFT, 0),
-   SND_SOC_DAPM_ADC("ADC", "HiFi Capture", NAU8810_REG_POWER2,
+   SND_SOC_DAPM_ADC("ADC", "Capture", NAU8810_REG_POWER2,
NAU8810_ADC_EN_SFT, 0),
SND_SOC_DAPM_PGA("SpkN Out", NAU8810_REG_POWER3,
NAU8810_NSPK_EN_SFT, 0, NULL, 0),
-- 
2.19.1



[PATCH AUTOSEL 4.19 19/53] IB/hfi1: Eliminate opcode tests on mr deref

2019-04-26 Thread Sasha Levin
From: Kaike Wan 

[ Upstream commit a8639a79e85c18c16c10089edd589c7948f19bbd ]

When an old ack_queue entry is used to store an incoming request, it may
need to clean up the old entry if it is still referencing the
MR. Originally only RDMA READ request needed to reference MR on the
responder side and therefore the opcode was tested when cleaning up the
old entry. The introduction of tid rdma specific operations in the
ack_queue makes the specific opcode tests wrong.  Multiple opcodes (RDMA
READ, TID RDMA READ, and TID RDMA WRITE) may need MR ref cleanup.

Remove the opcode specific tests associated with the ack_queue.

Fixes: f48ad614c100 ("IB/hfi1: Move driver out of staging")
Signed-off-by: Mike Marciniszyn 
Signed-off-by: Kaike Wan 
Signed-off-by: Dennis Dalessandro 
Signed-off-by: Jason Gunthorpe 
Signed-off-by: Sasha Levin 
---
 drivers/infiniband/hw/hfi1/rc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/rc.c b/drivers/infiniband/hw/hfi1/rc.c
index 6f013a565353..770c78c65730 100644
--- a/drivers/infiniband/hw/hfi1/rc.c
+++ b/drivers/infiniband/hw/hfi1/rc.c
@@ -2303,7 +2303,7 @@ void hfi1_rc_rcv(struct hfi1_packet *packet)
update_ack_queue(qp, next);
}
e = >s_ack_queue[qp->r_head_ack_queue];
-   if (e->opcode == OP(RDMA_READ_REQUEST) && e->rdma_sge.mr) {
+   if (e->rdma_sge.mr) {
rvt_put_mr(e->rdma_sge.mr);
e->rdma_sge.mr = NULL;
}
@@ -2377,7 +2377,7 @@ void hfi1_rc_rcv(struct hfi1_packet *packet)
update_ack_queue(qp, next);
}
e = >s_ack_queue[qp->r_head_ack_queue];
-   if (e->opcode == OP(RDMA_READ_REQUEST) && e->rdma_sge.mr) {
+   if (e->rdma_sge.mr) {
rvt_put_mr(e->rdma_sge.mr);
e->rdma_sge.mr = NULL;
}
-- 
2.19.1



[PATCH AUTOSEL 4.19 08/53] ASoC: nau8824: fix the issue of the widget with prefix name

2019-04-26 Thread Sasha Levin
From: John Hsu 

[ Upstream commit 844a4a362dbec166b44d6b9b3dd45b08cb273703 ]

The driver has two issues when machine add prefix name for codec.
(1)The stream name of DAI can't find the AIF widgets.
(2)The drivr can enable/disalbe the MICBIAS and SAR widgets.

The patch will fix these issues caused by prefixed name added.

Signed-off-by: John Hsu 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/codecs/nau8824.c | 46 +++---
 1 file changed, 38 insertions(+), 8 deletions(-)

diff --git a/sound/soc/codecs/nau8824.c b/sound/soc/codecs/nau8824.c
index 468d5143e2c4..663a208c2f78 100644
--- a/sound/soc/codecs/nau8824.c
+++ b/sound/soc/codecs/nau8824.c
@@ -681,8 +681,8 @@ static const struct snd_soc_dapm_widget 
nau8824_dapm_widgets[] = {
SND_SOC_DAPM_ADC("ADCR", NULL, NAU8824_REG_ANALOG_ADC_2,
NAU8824_ADCR_EN_SFT, 0),
 
-   SND_SOC_DAPM_AIF_OUT("AIFTX", "HiFi Capture", 0, SND_SOC_NOPM, 0, 0),
-   SND_SOC_DAPM_AIF_IN("AIFRX", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0),
+   SND_SOC_DAPM_AIF_OUT("AIFTX", "Capture", 0, SND_SOC_NOPM, 0, 0),
+   SND_SOC_DAPM_AIF_IN("AIFRX", "Playback", 0, SND_SOC_NOPM, 0, 0),
 
SND_SOC_DAPM_DAC("DACL", NULL, NAU8824_REG_RDAC,
NAU8824_DACL_EN_SFT, 0),
@@ -831,6 +831,36 @@ static void nau8824_int_status_clear_all(struct regmap 
*regmap)
}
 }
 
+static void nau8824_dapm_disable_pin(struct nau8824 *nau8824, const char *pin)
+{
+   struct snd_soc_dapm_context *dapm = nau8824->dapm;
+   const char *prefix = dapm->component->name_prefix;
+   char prefixed_pin[80];
+
+   if (prefix) {
+   snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
+prefix, pin);
+   snd_soc_dapm_disable_pin(dapm, prefixed_pin);
+   } else {
+   snd_soc_dapm_disable_pin(dapm, pin);
+   }
+}
+
+static void nau8824_dapm_enable_pin(struct nau8824 *nau8824, const char *pin)
+{
+   struct snd_soc_dapm_context *dapm = nau8824->dapm;
+   const char *prefix = dapm->component->name_prefix;
+   char prefixed_pin[80];
+
+   if (prefix) {
+   snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
+prefix, pin);
+   snd_soc_dapm_force_enable_pin(dapm, prefixed_pin);
+   } else {
+   snd_soc_dapm_force_enable_pin(dapm, pin);
+   }
+}
+
 static void nau8824_eject_jack(struct nau8824 *nau8824)
 {
struct snd_soc_dapm_context *dapm = nau8824->dapm;
@@ -839,8 +869,8 @@ static void nau8824_eject_jack(struct nau8824 *nau8824)
/* Clear all interruption status */
nau8824_int_status_clear_all(regmap);
 
-   snd_soc_dapm_disable_pin(dapm, "SAR");
-   snd_soc_dapm_disable_pin(dapm, "MICBIAS");
+   nau8824_dapm_disable_pin(nau8824, "SAR");
+   nau8824_dapm_disable_pin(nau8824, "MICBIAS");
snd_soc_dapm_sync(dapm);
 
/* Enable the insertion interruption, disable the ejection
@@ -870,8 +900,8 @@ static void nau8824_jdet_work(struct work_struct *work)
struct regmap *regmap = nau8824->regmap;
int adc_value, event = 0, event_mask = 0;
 
-   snd_soc_dapm_force_enable_pin(dapm, "MICBIAS");
-   snd_soc_dapm_force_enable_pin(dapm, "SAR");
+   nau8824_dapm_enable_pin(nau8824, "MICBIAS");
+   nau8824_dapm_enable_pin(nau8824, "SAR");
snd_soc_dapm_sync(dapm);
 
msleep(100);
@@ -882,8 +912,8 @@ static void nau8824_jdet_work(struct work_struct *work)
if (adc_value < HEADSET_SARADC_THD) {
event |= SND_JACK_HEADPHONE;
 
-   snd_soc_dapm_disable_pin(dapm, "SAR");
-   snd_soc_dapm_disable_pin(dapm, "MICBIAS");
+   nau8824_dapm_disable_pin(nau8824, "SAR");
+   nau8824_dapm_disable_pin(nau8824, "MICBIAS");
snd_soc_dapm_sync(dapm);
} else {
event |= SND_JACK_HEADSET;
-- 
2.19.1



[PATCH AUTOSEL 4.19 10/53] ASoC: samsung: odroid: Fix clock configuration for 44100 sample rate

2019-04-26 Thread Sasha Levin
From: Sylwester Nawrocki 

[ Upstream commit 2b13bee3884926cba22061efa75bd315e871de24 ]

After commit fbeec965b8d1c ("ASoC: samsung: odroid: Fix 32000 sample rate
handling") the audio root clock frequency is configured improperly for
44100 sample rate. Due to clock rate rounding it's 20070401 Hz instead
of 22579000 Hz. This results in a too low value of the PSR clock divider
in the CPU DAI driver and too fast actual sample rate for fs=44100. E.g.
1 kHz tone has actual 1780 Hz frequency (1 kHz * 20070401/22579000 * 2).

Fix this by increasing the correction passed to clk_set_rate() to take
into account inaccuracy of the EPLL frequency properly.

Fixes: fbeec965b8d1c ("ASoC: samsung: odroid: Fix 32000 sample rate handling")
Reported-by: JaeChul Lee 
Signed-off-by: Sylwester Nawrocki 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/samsung/odroid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c
index e7b371b07230..45c6d7396785 100644
--- a/sound/soc/samsung/odroid.c
+++ b/sound/soc/samsung/odroid.c
@@ -64,11 +64,11 @@ static int odroid_card_hw_params(struct snd_pcm_substream 
*substream,
return ret;
 
/*
-*  We add 1 to the rclk_freq value in order to avoid too low clock
+*  We add 2 to the rclk_freq value in order to avoid too low clock
 *  frequency values due to the EPLL output frequency not being exact
 *  multiple of the audio sampling rate.
 */
-   rclk_freq = params_rate(params) * rfs + 1;
+   rclk_freq = params_rate(params) * rfs + 2;
 
ret = clk_set_rate(priv->sclk_i2s, rclk_freq);
if (ret < 0)
-- 
2.19.1



[PATCH AUTOSEL 4.19 11/53] ASoC: rt5682: recording has no sound after booting

2019-04-26 Thread Sasha Levin
From: Shuming Fan 

[ Upstream commit 1c5b6a27e432e4fe170a924c8b41012271496a4c ]

If ASRC turns on, HW will use clk_dac as the reference clock
whether recording or playback.
Both of clk_dac and clk_adc should set proper clock while using ASRC.

Signed-off-by: Shuming Fan 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/codecs/rt5682.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
index 79ebcc239786..6f5dac09cede 100644
--- a/sound/soc/codecs/rt5682.c
+++ b/sound/soc/codecs/rt5682.c
@@ -1196,7 +1196,7 @@ static int set_filter_clk(struct snd_soc_dapm_widget *w,
struct snd_soc_component *component =
snd_soc_dapm_to_component(w->dapm);
struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
-   int ref, val, reg, sft, mask, idx = -EINVAL;
+   int ref, val, reg, idx = -EINVAL;
static const int div_f[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48};
static const int div_o[] = {1, 2, 4, 6, 8, 12, 16, 24, 32, 48};
 
@@ -1210,15 +1210,10 @@ static int set_filter_clk(struct snd_soc_dapm_widget *w,
 
idx = rt5682_div_sel(rt5682, ref, div_f, ARRAY_SIZE(div_f));
 
-   if (w->shift == RT5682_PWR_ADC_S1F_BIT) {
+   if (w->shift == RT5682_PWR_ADC_S1F_BIT)
reg = RT5682_PLL_TRACK_3;
-   sft = RT5682_ADC_OSR_SFT;
-   mask = RT5682_ADC_OSR_MASK;
-   } else {
+   else
reg = RT5682_PLL_TRACK_2;
-   sft = RT5682_DAC_OSR_SFT;
-   mask = RT5682_DAC_OSR_MASK;
-   }
 
snd_soc_component_update_bits(component, reg,
RT5682_FILTER_CLK_DIV_MASK, idx << RT5682_FILTER_CLK_DIV_SFT);
@@ -1230,7 +1225,8 @@ static int set_filter_clk(struct snd_soc_dapm_widget *w,
}
 
snd_soc_component_update_bits(component, RT5682_ADDA_CLK_1,
-   mask, idx << sft);
+   RT5682_ADC_OSR_MASK | RT5682_DAC_OSR_MASK,
+   (idx << RT5682_ADC_OSR_SFT) | (idx << RT5682_DAC_OSR_SFT));
 
return 0;
 }
-- 
2.19.1



[PATCH AUTOSEL 4.19 23/53] drm/mediatek: Fix an error code in mtk_hdmi_dt_parse_pdata()

2019-04-26 Thread Sasha Levin
From: Dan Carpenter 

[ Upstream commit 2d85978341e6a32e7443d9f28639da254d53f400 ]

We don't want to overwrite "ret", it already holds the correct error
code.  The "regmap" variable might be a valid pointer as this point.

Fixes: 8f83f26891e1 ("drm/mediatek: Add HDMI support")
Signed-off-by: Dan Carpenter 
Signed-off-by: CK Hu 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/mediatek/mtk_hdmi.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c 
b/drivers/gpu/drm/mediatek/mtk_hdmi.c
index 643f5edd68fe..c7a77d6f612b 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -1473,7 +1473,6 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
if (IS_ERR(regmap))
ret = PTR_ERR(regmap);
if (ret) {
-   ret = PTR_ERR(regmap);
dev_err(dev,
"Failed to get system configuration registers: %d\n",
ret);
-- 
2.19.1



[PATCH AUTOSEL 4.19 13/53] clk: meson-gxbb: round the vdec dividers to closest

2019-04-26 Thread Sasha Levin
From: Maxime Jourdan 

[ Upstream commit 9b70c697e87286ade406e6a02091757307dd4b7c ]

We want the video decoder clocks to always round to closest. While the
muxes are already using CLK_MUX_ROUND_CLOSEST, the corresponding
CLK_DIVIDER_ROUND_CLOSEST was forgotten for the dividers.

Fix this by adding the flag to the two vdec dividers.

Fixes: a565242eb9fc ("clk: meson: gxbb: add the video decoder clocks")
Signed-off-by: Maxime Jourdan 
Acked-by: Neil Armstrong 
Signed-off-by: Neil Armstrong 
Link: https://lkml.kernel.org/r/20190319102537.2043-1-mjour...@baylibre.com
Signed-off-by: Sasha Levin 
---
 drivers/clk/meson/gxbb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c
index 6628ffa31383..4d4f6d842c31 100644
--- a/drivers/clk/meson/gxbb.c
+++ b/drivers/clk/meson/gxbb.c
@@ -1571,6 +1571,7 @@ static struct clk_regmap gxbb_vdec_1_div = {
.offset = HHI_VDEC_CLK_CNTL,
.shift = 0,
.width = 7,
+   .flags = CLK_DIVIDER_ROUND_CLOSEST,
},
.hw.init = &(struct clk_init_data){
.name = "vdec_1_div",
@@ -1616,6 +1617,7 @@ static struct clk_regmap gxbb_vdec_hevc_div = {
.offset = HHI_VDEC2_CLK_CNTL,
.shift = 16,
.width = 7,
+   .flags = CLK_DIVIDER_ROUND_CLOSEST,
},
.hw.init = &(struct clk_init_data){
.name = "vdec_hevc_div",
-- 
2.19.1



[PATCH AUTOSEL 4.19 17/53] ASoC: dapm: Fix NULL pointer dereference in snd_soc_dapm_free_kcontrol

2019-04-26 Thread Sasha Levin
From: Pankaj Bharadiya 

[ Upstream commit cacea3a90e211f0c111975535508d446a4a928d2 ]

w_text_param can be NULL and it is being dereferenced without checking.
Add the missing sanity check to prevent  NULL pointer dereference.

Signed-off-by: Pankaj Bharadiya 
Acked-by: Pierre-Louis Bossart 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/soc-dapm.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 9b78fb3daa7b..2257b1b0151c 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3847,6 +3847,10 @@ snd_soc_dapm_free_kcontrol(struct snd_soc_card *card,
int count;
 
devm_kfree(card->dev, (void *)*private_value);
+
+   if (!w_param_text)
+   return;
+
for (count = 0 ; count < num_params; count++)
devm_kfree(card->dev, (void *)w_param_text[count]);
devm_kfree(card->dev, w_param_text);
-- 
2.19.1



[PATCH AUTOSEL 4.19 12/53] ASoC: wm_adsp: Add locking to wm_adsp2_bus_error

2019-04-26 Thread Sasha Levin
From: Charles Keepax 

[ Upstream commit a2225a6d155fcb247fe4c6d87f7c91807462966d ]

Best to lock across handling the bus error to ensure the DSP doesn't
change power state as we are reading the status registers.

Signed-off-by: Charles Keepax 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/codecs/wm_adsp.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 4d3ec295679d..2716022c6bc3 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -3819,11 +3819,13 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)
struct regmap *regmap = dsp->regmap;
int ret = 0;
 
+   mutex_lock(>pwr_lock);
+
ret = regmap_read(regmap, dsp->base + ADSP2_LOCK_REGION_CTRL, );
if (ret) {
adsp_err(dsp,
"Failed to read Region Lock Ctrl register: %d\n", ret);
-   return IRQ_HANDLED;
+   goto error;
}
 
if (val & ADSP2_WDT_TIMEOUT_STS_MASK) {
@@ -3842,7 +3844,7 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)
adsp_err(dsp,
 "Failed to read Bus Err Addr register: %d\n",
 ret);
-   return IRQ_HANDLED;
+   goto error;
}
 
adsp_err(dsp, "bus error address = 0x%x\n",
@@ -3855,7 +3857,7 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)
adsp_err(dsp,
 "Failed to read Pmem Xmem Err Addr register: 
%d\n",
 ret);
-   return IRQ_HANDLED;
+   goto error;
}
 
adsp_err(dsp, "xmem error address = 0x%x\n",
@@ -3868,6 +3870,9 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)
regmap_update_bits(regmap, dsp->base + ADSP2_LOCK_REGION_CTRL,
   ADSP2_CTRL_ERR_EINT, ADSP2_CTRL_ERR_EINT);
 
+error:
+   mutex_unlock(>pwr_lock);
+
return IRQ_HANDLED;
 }
 EXPORT_SYMBOL_GPL(wm_adsp2_bus_error);
-- 
2.19.1



[PATCH AUTOSEL 4.19 16/53] ASoC: cs4270: Set auto-increment bit for register writes

2019-04-26 Thread Sasha Levin
From: Daniel Mack 

[ Upstream commit f0f2338a9cfaf71db895fa989ea7234e8a9b471d ]

The CS4270 does not by default increment the register address on
consecutive writes. During normal operation it doesn't matter as all
register accesses are done individually. At resume time after suspend,
however, the regcache code gathers the biggest possible block of
registers to sync and sends them one on one go.

To fix this, set the INCR bit in all cases.

Signed-off-by: Daniel Mack 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/codecs/cs4270.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c
index 3c266eeb89bf..007ce9f48e44 100644
--- a/sound/soc/codecs/cs4270.c
+++ b/sound/soc/codecs/cs4270.c
@@ -642,6 +642,7 @@ static const struct regmap_config cs4270_regmap = {
.reg_defaults = cs4270_reg_defaults,
.num_reg_defaults = ARRAY_SIZE(cs4270_reg_defaults),
.cache_type =   REGCACHE_RBTREE,
+   .write_flag_mask =  CS4270_I2C_INCR,
 
.readable_reg = cs4270_reg_is_readable,
.volatile_reg = cs4270_reg_is_volatile,
-- 
2.19.1



[PATCH AUTOSEL 4.19 14/53] ASoC: stm32: dfsdm: manage multiple prepare

2019-04-26 Thread Sasha Levin
From: Olivier Moysan 

[ Upstream commit 19441e35a43b616ea6afad91ed0d9e77268d8f6a ]

The DFSDM must be stopped when a new setting is applied.
restart systematically DFSDM on multiple prepare calls,
to apply changes.

Signed-off-by: Olivier Moysan 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/stm/stm32_adfsdm.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/sound/soc/stm/stm32_adfsdm.c b/sound/soc/stm/stm32_adfsdm.c
index 706ff005234f..71d341b732a4 100644
--- a/sound/soc/stm/stm32_adfsdm.c
+++ b/sound/soc/stm/stm32_adfsdm.c
@@ -9,6 +9,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -37,6 +38,8 @@ struct stm32_adfsdm_priv {
/* PCM buffer */
unsigned char *pcm_buff;
unsigned int pos;
+
+   struct mutex lock; /* protect against race condition on iio state */
 };
 
 static const struct snd_pcm_hardware stm32_adfsdm_pcm_hw = {
@@ -62,10 +65,12 @@ static void stm32_adfsdm_shutdown(struct snd_pcm_substream 
*substream,
 {
struct stm32_adfsdm_priv *priv = snd_soc_dai_get_drvdata(dai);
 
+   mutex_lock(>lock);
if (priv->iio_active) {
iio_channel_stop_all_cb(priv->iio_cb);
priv->iio_active = false;
}
+   mutex_unlock(>lock);
 }
 
 static int stm32_adfsdm_dai_prepare(struct snd_pcm_substream *substream,
@@ -74,13 +79,19 @@ static int stm32_adfsdm_dai_prepare(struct 
snd_pcm_substream *substream,
struct stm32_adfsdm_priv *priv = snd_soc_dai_get_drvdata(dai);
int ret;
 
+   mutex_lock(>lock);
+   if (priv->iio_active) {
+   iio_channel_stop_all_cb(priv->iio_cb);
+   priv->iio_active = false;
+   }
+
ret = iio_write_channel_attribute(priv->iio_ch,
  substream->runtime->rate, 0,
  IIO_CHAN_INFO_SAMP_FREQ);
if (ret < 0) {
dev_err(dai->dev, "%s: Failed to set %d sampling rate\n",
__func__, substream->runtime->rate);
-   return ret;
+   goto out;
}
 
if (!priv->iio_active) {
@@ -92,6 +103,9 @@ static int stm32_adfsdm_dai_prepare(struct snd_pcm_substream 
*substream,
__func__, ret);
}
 
+out:
+   mutex_unlock(>lock);
+
return ret;
 }
 
@@ -298,6 +312,7 @@ static int stm32_adfsdm_probe(struct platform_device *pdev)
 
priv->dev = >dev;
priv->dai_drv = stm32_adfsdm_dai;
+   mutex_init(>lock);
 
dev_set_drvdata(>dev, priv);
 
-- 
2.19.1



[PATCH AUTOSEL 4.19 07/53] ASoC:intel:skl:fix a simultaneous playback & capture issue on hda platform

2019-04-26 Thread Sasha Levin
From: Rander Wang 

[ Upstream commit c899df3e9b0bf7b76e642aed1a214582ea7012d5 ]

If playback and capture are enabled concurrently, when the capture stops
the output becomes inaudile. The playback application will become stuck
and underrun after a timeout.

This is caused by mistaken use of the stream_id, which should only be
set for playback and not for capture

Tested on Apollolake and Kabylake with SST driver.

Signed-off-by: Rander Wang 
Acked-by: Pierre-Louis Bossart 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/intel/skylake/skl-pcm.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-pcm.c 
b/sound/soc/intel/skylake/skl-pcm.c
index 823e39103edd..6b2c8c6e7a00 100644
--- a/sound/soc/intel/skylake/skl-pcm.c
+++ b/sound/soc/intel/skylake/skl-pcm.c
@@ -180,6 +180,7 @@ int skl_pcm_link_dma_prepare(struct device *dev, struct 
skl_pipe_params *params)
struct hdac_stream *hstream;
struct hdac_ext_stream *stream;
struct hdac_ext_link *link;
+   unsigned char stream_tag;
 
hstream = snd_hdac_get_stream(bus, params->stream,
params->link_dma_id + 1);
@@ -198,10 +199,13 @@ int skl_pcm_link_dma_prepare(struct device *dev, struct 
skl_pipe_params *params)
 
snd_hdac_ext_link_stream_setup(stream, format_val);
 
-   list_for_each_entry(link, >hlink_list, list) {
-   if (link->index == params->link_index)
-   snd_hdac_ext_link_set_stream_id(link,
-   hstream->stream_tag);
+   stream_tag = hstream->stream_tag;
+   if (stream->hstream.direction == SNDRV_PCM_STREAM_PLAYBACK) {
+   list_for_each_entry(link, >hlink_list, list) {
+   if (link->index == params->link_index)
+   snd_hdac_ext_link_set_stream_id(link,
+   stream_tag);
+   }
}
 
stream->link_prepared = 1;
@@ -640,6 +644,7 @@ static int skl_link_hw_free(struct snd_pcm_substream 
*substream,
struct hdac_ext_stream *link_dev =
snd_soc_dai_get_dma_data(dai, substream);
struct hdac_ext_link *link;
+   unsigned char stream_tag;
 
dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
 
@@ -649,7 +654,11 @@ static int skl_link_hw_free(struct snd_pcm_substream 
*substream,
if (!link)
return -EINVAL;
 
-   snd_hdac_ext_link_clear_stream_id(link, 
hdac_stream(link_dev)->stream_tag);
+   if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+   stream_tag = hdac_stream(link_dev)->stream_tag;
+   snd_hdac_ext_link_clear_stream_id(link, stream_tag);
+   }
+
snd_hdac_ext_stream_release(link_dev, HDAC_EXT_STREAM_TYPE_LINK);
return 0;
 }
-- 
2.19.1



[PATCH AUTOSEL 4.19 28/53] ASoC: rockchip: pdm: fix regmap_ops hang issue

2019-04-26 Thread Sasha Levin
From: Sugar Zhang 

[ Upstream commit c85064435fe7a216ec0f0238ef2b8f7cd850a450 ]

This is because set_fmt ops maybe called when PD is off,
and in such case, regmap_ops will lead system hang.
enale PD before doing regmap_ops.

Signed-off-by: Sugar Zhang 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/rockchip/rockchip_pdm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/soc/rockchip/rockchip_pdm.c 
b/sound/soc/rockchip/rockchip_pdm.c
index 400e29edb1c9..8a2e3bbce3a1 100644
--- a/sound/soc/rockchip/rockchip_pdm.c
+++ b/sound/soc/rockchip/rockchip_pdm.c
@@ -208,7 +208,9 @@ static int rockchip_pdm_set_fmt(struct snd_soc_dai *cpu_dai,
return -EINVAL;
}
 
+   pm_runtime_get_sync(cpu_dai->dev);
regmap_update_bits(pdm->regmap, PDM_CLK_CTRL, mask, val);
+   pm_runtime_put(cpu_dai->dev);
 
return 0;
 }
-- 
2.19.1



[PATCH AUTOSEL 4.19 26/53] linux/kernel.h: Use parentheses around argument in u64_to_user_ptr()

2019-04-26 Thread Sasha Levin
From: Jann Horn 

[ Upstream commit a0fe2c6479aab5723239b315ef1b552673f434a3 ]

Use parentheses around uses of the argument in u64_to_user_ptr() to
ensure that the cast doesn't apply to part of the argument.

There are existing uses of the macro of the form

  u64_to_user_ptr(A + B)

which expands to

  (void __user *)(uintptr_t)A + B

(the cast applies to the first operand of the addition, the addition
is a pointer addition). This happens to still work as intended, the
semantic difference doesn't cause a difference in behavior.

But I want to use u64_to_user_ptr() with a ternary operator in the
argument, like so:

  u64_to_user_ptr(A ? B : C)

This currently doesn't work as intended.

Signed-off-by: Jann Horn 
Signed-off-by: Borislav Petkov 
Reviewed-by: Mukesh Ojha 
Cc: Andrei Vagin 
Cc: Andrew Morton 
Cc: Dan Carpenter 
Cc: Greg Kroah-Hartman 
Cc: "H. Peter Anvin" 
Cc: Ingo Molnar 
Cc: Jani Nikula 
Cc: Kees Cook 
Cc: Masahiro Yamada 
Cc: NeilBrown 
Cc: Peter Zijlstra 
Cc: Qiaowei Ren 
Cc: Thomas Gleixner 
Cc: x86-ml 
Link: https://lkml.kernel.org/r/20190329214652.258477-1-ja...@google.com
Signed-off-by: Sasha Levin 
---
 include/linux/kernel.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index d6aac75b51ba..3d83ebb302cf 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -73,8 +73,8 @@
 
 #define u64_to_user_ptr(x) (   \
 {  \
-   typecheck(u64, x);  \
-   (void __user *)(uintptr_t)x;\
+   typecheck(u64, (x));\
+   (void __user *)(uintptr_t)(x);  \
 }  \
 )
 
-- 
2.19.1



[PATCH AUTOSEL 4.19 31/53] ASoC: cs35l35: Disable regulators on driver removal

2019-04-26 Thread Sasha Levin
From: Charles Keepax 

[ Upstream commit 47c4cc08cb5b34e93ab337b924c5ede77ca3c936 ]

The chips main power supplies VA and VP are enabled during probe but
then never disabled, this will cause warnings from the regulator
framework on driver removal. Fix this by adding a remove callback and
disabling the supplies, whilst doing so follow best practice and put the
chip back into reset as well.

Signed-off-by: Charles Keepax 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/codecs/cs35l35.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/sound/soc/codecs/cs35l35.c b/sound/soc/codecs/cs35l35.c
index bd6226bde45f..17e0101081ef 100644
--- a/sound/soc/codecs/cs35l35.c
+++ b/sound/soc/codecs/cs35l35.c
@@ -1634,6 +1634,16 @@ static int cs35l35_i2c_probe(struct i2c_client 
*i2c_client,
return ret;
 }
 
+static int cs35l35_i2c_remove(struct i2c_client *i2c_client)
+{
+   struct cs35l35_private *cs35l35 = i2c_get_clientdata(i2c_client);
+
+   regulator_bulk_disable(cs35l35->num_supplies, cs35l35->supplies);
+   gpiod_set_value_cansleep(cs35l35->reset_gpio, 0);
+
+   return 0;
+}
+
 static const struct of_device_id cs35l35_of_match[] = {
{.compatible = "cirrus,cs35l35"},
{},
@@ -1654,6 +1664,7 @@ static struct i2c_driver cs35l35_i2c_driver = {
},
.id_table = cs35l35_id,
.probe = cs35l35_i2c_probe,
+   .remove = cs35l35_i2c_remove,
 };
 
 module_i2c_driver(cs35l35_i2c_driver);
-- 
2.19.1



[PATCH AUTOSEL 4.19 20/53] IB/hfi1: Fix the allocation of RSM table

2019-04-26 Thread Sasha Levin
From: Kaike Wan 

[ Upstream commit d0294344470e6b52d097aa7369173f32d11f2f52 ]

The receive side mapping (RSM) on hfi1 hardware is a special
matching mechanism to direct an incoming packet to a given
hardware receive context. It has 4 instances of matching capabilities
(RSM0 - RSM3) that share the same RSM table (RMT). The RMT has a total of
256 entries, each of which points to a receive context.

Currently, three instances of RSM have been used:
1. RSM0 by QOS;
2. RSM1 by PSM FECN;
3. RSM2 by VNIC.

Each RSM instance should reserve enough entries in RMT to function
properly. Since both PSM and VNIC could allocate any receive context
between dd->first_dyn_alloc_ctxt and dd->num_rcv_contexts, PSM FECN must
reserve enough RMT entries to cover the entire receive context index
range (dd->num_rcv_contexts - dd->first_dyn_alloc_ctxt) instead of only
the user receive contexts allocated for PSM
(dd->num_user_contexts). Consequently, the sizing of
dd->num_user_contexts in set_up_context_variables is incorrect.

Fixes: 2280740f01ae ("IB/hfi1: Virtual Network Interface Controller (VNIC) HW 
support")
Reviewed-by: Mike Marciniszyn 
Reviewed-by: Michael J. Ruhl 
Signed-off-by: Kaike Wan 
Signed-off-by: Dennis Dalessandro 
Signed-off-by: Jason Gunthorpe 
Signed-off-by: Sasha Levin 
---
 drivers/infiniband/hw/hfi1/chip.c | 26 +++---
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/chip.c 
b/drivers/infiniband/hw/hfi1/chip.c
index 902d12d6d88b..b12c8ff8ed66 100644
--- a/drivers/infiniband/hw/hfi1/chip.c
+++ b/drivers/infiniband/hw/hfi1/chip.c
@@ -13388,7 +13388,7 @@ static int set_up_context_variables(struct hfi1_devdata 
*dd)
int total_contexts;
int ret;
unsigned ngroups;
-   int qos_rmt_count;
+   int rmt_count;
int user_rmt_reduced;
u32 n_usr_ctxts;
u32 send_contexts = chip_send_contexts(dd);
@@ -13450,10 +13450,20 @@ static int set_up_context_variables(struct 
hfi1_devdata *dd)
n_usr_ctxts = rcv_contexts - total_contexts;
}
 
-   /* each user context requires an entry in the RMT */
-   qos_rmt_count = qos_rmt_entries(dd, NULL, NULL);
-   if (qos_rmt_count + n_usr_ctxts > NUM_MAP_ENTRIES) {
-   user_rmt_reduced = NUM_MAP_ENTRIES - qos_rmt_count;
+   /*
+* The RMT entries are currently allocated as shown below:
+* 1. QOS (0 to 128 entries);
+* 2. FECN for PSM (num_user_contexts + num_vnic_contexts);
+* 3. VNIC (num_vnic_contexts).
+* It should be noted that PSM FECN oversubscribe num_vnic_contexts
+* entries of RMT because both VNIC and PSM could allocate any receive
+* context between dd->first_dyn_alloc_text and dd->num_rcv_contexts,
+* and PSM FECN must reserve an RMT entry for each possible PSM receive
+* context.
+*/
+   rmt_count = qos_rmt_entries(dd, NULL, NULL) + (num_vnic_contexts * 2);
+   if (rmt_count + n_usr_ctxts > NUM_MAP_ENTRIES) {
+   user_rmt_reduced = NUM_MAP_ENTRIES - rmt_count;
dd_dev_err(dd,
   "RMT size is reducing the number of user receive 
contexts from %u to %d\n",
   n_usr_ctxts,
@@ -14441,9 +14451,11 @@ static void init_user_fecn_handling(struct 
hfi1_devdata *dd,
u64 reg;
int i, idx, regoff, regidx;
u8 offset;
+   u32 total_cnt;
 
/* there needs to be enough room in the map table */
-   if (rmt->used + dd->num_user_contexts >= NUM_MAP_ENTRIES) {
+   total_cnt = dd->num_rcv_contexts - dd->first_dyn_alloc_ctxt;
+   if (rmt->used + total_cnt >= NUM_MAP_ENTRIES) {
dd_dev_err(dd, "User FECN handling disabled - too many user 
contexts allocated\n");
return;
}
@@ -14497,7 +14509,7 @@ static void init_user_fecn_handling(struct hfi1_devdata 
*dd,
/* add rule 1 */
add_rsm_rule(dd, RSM_INS_FECN, );
 
-   rmt->used += dd->num_user_contexts;
+   rmt->used += total_cnt;
 }
 
 /* Initialize RSM for VNIC */
-- 
2.19.1



[PATCH AUTOSEL 4.19 27/53] xtensa: fix initialization of pt_regs::syscall in start_thread

2019-04-26 Thread Sasha Levin
From: Max Filippov 

[ Upstream commit 2663147dc7465cb29040a05cc4286fdd839978b5 ]

New pt_regs should indicate that there's no syscall, not that there's
syscall #0. While at it wrap macro body in do/while and parenthesize
macro arguments.

Signed-off-by: Max Filippov 
Signed-off-by: Sasha Levin 
---
 arch/xtensa/include/asm/processor.h | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/arch/xtensa/include/asm/processor.h 
b/arch/xtensa/include/asm/processor.h
index 677bc76c1d70..6e709fb56283 100644
--- a/arch/xtensa/include/asm/processor.h
+++ b/arch/xtensa/include/asm/processor.h
@@ -194,15 +194,18 @@ struct thread_struct {
 
 /* Clearing a0 terminates the backtrace. */
 #define start_thread(regs, new_pc, new_sp) \
-   memset(regs, 0, sizeof(*regs)); \
-   regs->pc = new_pc; \
-   regs->ps = USER_PS_VALUE; \
-   regs->areg[1] = new_sp; \
-   regs->areg[0] = 0; \
-   regs->wmask = 1; \
-   regs->depc = 0; \
-   regs->windowbase = 0; \
-   regs->windowstart = 1;
+   do { \
+   memset((regs), 0, sizeof(*(regs))); \
+   (regs)->pc = (new_pc); \
+   (regs)->ps = USER_PS_VALUE; \
+   (regs)->areg[1] = (new_sp); \
+   (regs)->areg[0] = 0; \
+   (regs)->wmask = 1; \
+   (regs)->depc = 0; \
+   (regs)->windowbase = 0; \
+   (regs)->windowstart = 1; \
+   (regs)->syscall = NO_SYSCALL; \
+   } while (0)
 
 /* Forward declaration */
 struct task_struct;
-- 
2.19.1



[PATCH AUTOSEL 4.19 30/53] drm/amd/display: fix cursor black issue

2019-04-26 Thread Sasha Levin
From: tiancyin 

[ Upstream commit c1cefe115d1cdc460014483319d440b2f0d07c68 ]

[Why]
the member sdr_white_level of struct dc_cursor_attributes was not
initialized, then the random value result that
dcn10_set_cursor_sdr_white_level() set error hw_scale value 0x20D9(normal
value is 0x3c00), this cause the black cursor issue.

[how]
just initilize the obj of struct dc_cursor_attributes to zero to avoid
the random value.

Reviewed-by: Nicholas Kazlauskas 
Signed-off-by: Tianci Yin 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 2b8b892eb846..76ee2de43ea6 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4028,6 +4028,7 @@ static void handle_cursor_update(struct drm_plane *plane,
amdgpu_crtc->cursor_width = plane->state->crtc_w;
amdgpu_crtc->cursor_height = plane->state->crtc_h;
 
+   memset(, 0, sizeof(attributes));
attributes.address.high_part = upper_32_bits(address);
attributes.address.low_part  = lower_32_bits(address);
attributes.width = plane->state->crtc_w;
-- 
2.19.1



[PATCH AUTOSEL 4.19 32/53] objtool: Add rewind_stack_do_exit() to the noreturn list

2019-04-26 Thread Sasha Levin
From: Josh Poimboeuf 

[ Upstream commit 4fa5ecda2bf96be7464eb406df8aba9d89260227 ]

This fixes the following warning seen on GCC 7.3:

  arch/x86/kernel/dumpstack.o: warning: objtool: oops_end() falls through to 
next function show_regs()

Reported-by: kbuild test robot 
Signed-off-by: Josh Poimboeuf 
Signed-off-by: Thomas Gleixner 
Cc: Peter Zijlstra 
Link: 
https://lkml.kernel.org/r/3418ebf5a5a9f6ed7e80954c741c0b904b67b5dc.1554398240.git.jpoim...@redhat.com
Signed-off-by: Sasha Levin 
---
 tools/objtool/check.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 550f17611bd7..ef152daccc33 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -165,6 +165,7 @@ static int __dead_end_function(struct objtool_file *file, 
struct symbol *func,
"fortify_panic",
"usercopy_abort",
"machine_real_restart",
+   "rewind_stack_do_exit",
};
 
if (func->bind == STB_WEAK)
-- 
2.19.1



[PATCH AUTOSEL 4.19 38/53] RDMA/vmw_pvrdma: Fix memory leak on pvrdma_pci_remove

2019-04-26 Thread Sasha Levin
From: Kamal Heib 

[ Upstream commit ea7a5c706fa49273cf6d1d9def053ecb50db2076 ]

Make sure to free the DSR on pvrdma_pci_remove() to avoid the memory leak.

Fixes: 29c8d9eba550 ("IB: Add vmw_pvrdma driver")
Signed-off-by: Kamal Heib 
Acked-by: Adit Ranadive 
Signed-off-by: Jason Gunthorpe 
Signed-off-by: Sasha Levin 
---
 drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c 
b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c
index a5719899f49a..ed99f0a08dc4 100644
--- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c
+++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c
@@ -1123,6 +1123,8 @@ static void pvrdma_pci_remove(struct pci_dev *pdev)
pvrdma_page_dir_cleanup(dev, >cq_pdir);
pvrdma_page_dir_cleanup(dev, >async_pdir);
pvrdma_free_slots(dev);
+   dma_free_coherent(>dev, sizeof(*dev->dsr), dev->dsr,
+ dev->dsrbase);
 
iounmap(dev->regs);
kfree(dev->sgid_tbl);
-- 
2.19.1



[PATCH AUTOSEL 4.19 49/53] perf/core: Fix perf_event_disable_inatomic() race

2019-04-26 Thread Sasha Levin
From: Peter Zijlstra 

[ Upstream commit 1d54ad944074010609562da5c89e4f5df2f4e5db ]

Thomas-Mich Richter reported he triggered a WARN()ing from 
event_function_local()
on his s390. The problem boils down to:

CPU-A   CPU-B

perf_event_overflow()
  perf_event_disable_inatomic()
@pending_disable = 1
irq_work_queue();

sched-out
  event_sched_out()
@pending_disable = 0

sched-in
perf_event_overflow()
  perf_event_disable_inatomic()
@pending_disable = 1;
irq_work_queue(); // FAILS

irq_work_run()
  perf_pending_event()
if (@pending_disable)
  perf_event_disable_local(); // WHOOPS

The problem exists in generic, but s390 is particularly sensitive
because it doesn't implement arch_irq_work_raise(), nor does it call
irq_work_run() from it's PMU interrupt handler (nor would that be
sufficient in this case, because s390 also generates
perf_event_overflow() from pmu::stop). Add to that the fact that s390
is a virtual architecture and (virtual) CPU-A can stall long enough
for the above race to happen, even if it would self-IPI.

Adding a irq_work_sync() to event_sched_in() would work for all hardare
PMUs that properly use irq_work_run() but fails for software PMUs.

Instead encode the CPU number in @pending_disable, such that we can
tell which CPU requested the disable. This then allows us to detect
the above scenario and even redirect the IPI to make up for the failed
queue.

Reported-by: Thomas-Mich Richter 
Tested-by: Thomas Richter 
Signed-off-by: Peter Zijlstra (Intel) 
Acked-by: Mark Rutland 
Cc: Alexander Shishkin 
Cc: Arnaldo Carvalho de Melo 
Cc: Heiko Carstens 
Cc: Hendrik Brueckner 
Cc: Jiri Olsa 
Cc: Kees Cook 
Cc: Linus Torvalds 
Cc: Martin Schwidefsky 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Signed-off-by: Ingo Molnar 
Signed-off-by: Sasha Levin 
---
 kernel/events/core.c| 52 ++---
 kernel/events/ring_buffer.c |  4 +--
 2 files changed, 45 insertions(+), 11 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 87bd96399d1c..171b83ebed4a 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -2007,8 +2007,8 @@ event_sched_out(struct perf_event *event,
event->pmu->del(event, 0);
event->oncpu = -1;
 
-   if (event->pending_disable) {
-   event->pending_disable = 0;
+   if (READ_ONCE(event->pending_disable) >= 0) {
+   WRITE_ONCE(event->pending_disable, -1);
state = PERF_EVENT_STATE_OFF;
}
perf_event_set_state(event, state);
@@ -2196,7 +2196,8 @@ EXPORT_SYMBOL_GPL(perf_event_disable);
 
 void perf_event_disable_inatomic(struct perf_event *event)
 {
-   event->pending_disable = 1;
+   WRITE_ONCE(event->pending_disable, smp_processor_id());
+   /* can fail, see perf_pending_event_disable() */
irq_work_queue(>pending);
 }
 
@@ -5803,10 +5804,45 @@ void perf_event_wakeup(struct perf_event *event)
}
 }
 
+static void perf_pending_event_disable(struct perf_event *event)
+{
+   int cpu = READ_ONCE(event->pending_disable);
+
+   if (cpu < 0)
+   return;
+
+   if (cpu == smp_processor_id()) {
+   WRITE_ONCE(event->pending_disable, -1);
+   perf_event_disable_local(event);
+   return;
+   }
+
+   /*
+*  CPU-A   CPU-B
+*
+*  perf_event_disable_inatomic()
+*@pending_disable = CPU-A;
+*irq_work_queue();
+*
+*  sched-out
+*@pending_disable = -1;
+*
+*  sched-in
+*  perf_event_disable_inatomic()
+*@pending_disable = CPU-B;
+*irq_work_queue(); // FAILS
+*
+*  irq_work_run()
+*perf_pending_event()
+*
+* But the event runs on CPU-B and wants disabling there.
+*/
+   irq_work_queue_on(>pending, cpu);
+}
+
 static void perf_pending_event(struct irq_work *entry)
 {
-   struct perf_event *event = container_of(entry,
-   struct perf_event, pending);
+   struct perf_event *event = container_of(entry, struct perf_event, 
pending);
int rctx;
 
rctx = perf_swevent_get_recursion_context();
@@ -5815,10 +5851,7 @@ static void perf_pending_event(struct irq_work *entry)
 * and we won't recurse 'further'.
 */
 
-   if (event->pending_disable) {
-   event->pending_disable = 0;
-   perf_event_disable_local(event);
-   }
+   

[PATCH AUTOSEL 4.19 40/53] scsi: csiostor: fix missing data copy in csio_scsi_err_handler()

2019-04-26 Thread Sasha Levin
From: Varun Prakash 

[ Upstream commit 5c2442fd78998af60e13aba506d103f7f43f8701 ]

If scsi cmd sglist is not suitable for DDP then csiostor driver uses
preallocated buffers for DDP, because of this data copy is required from
DDP buffer to scsi cmd sglist before calling ->scsi_done().

Signed-off-by: Varun Prakash 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Sasha Levin 
---
 drivers/scsi/csiostor/csio_scsi.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/csiostor/csio_scsi.c 
b/drivers/scsi/csiostor/csio_scsi.c
index dab0d3f9bee1..e09c7f360dbd 100644
--- a/drivers/scsi/csiostor/csio_scsi.c
+++ b/drivers/scsi/csiostor/csio_scsi.c
@@ -1713,8 +1713,11 @@ csio_scsi_err_handler(struct csio_hw *hw, struct 
csio_ioreq *req)
}
 
 out:
-   if (req->nsge > 0)
+   if (req->nsge > 0) {
scsi_dma_unmap(cmnd);
+   if (req->dcopy && (host_status == DID_OK))
+   host_status = csio_scsi_copy_to_sgl(hw, req);
+   }
 
cmnd->result = (((host_status) << 16) | scsi_status);
cmnd->scsi_done(cmnd);
-- 
2.19.1



[PATCH AUTOSEL 4.19 48/53] NFS: Forbid setting AF_INET6 to "struct sockaddr_in"->sin_family.

2019-04-26 Thread Sasha Levin
From: Tetsuo Handa 

[ Upstream commit 7c2bd9a39845bfb6d72ddb55ce737650271f6f96 ]

syzbot is reporting uninitialized value at rpc_sockaddr2uaddr() [1]. This
is because syzbot is setting AF_INET6 to "struct sockaddr_in"->sin_family
(which is embedded into user-visible "struct nfs_mount_data" structure)
despite nfs23_validate_mount_data() cannot pass sizeof(struct sockaddr_in6)
bytes of AF_INET6 address to rpc_sockaddr2uaddr().

Since "struct nfs_mount_data" structure is user-visible, we can't change
"struct nfs_mount_data" to use "struct sockaddr_storage". Therefore,
assuming that everybody is using AF_INET family when passing address via
"struct nfs_mount_data"->addr, reject if its sin_family is not AF_INET.

[1] 
https://syzkaller.appspot.com/bug?id=53614e7cbbf66bc2656a919ab2a95fb5d75c

Reported-by: syzbot 
Signed-off-by: Tetsuo Handa 
Signed-off-by: Trond Myklebust 
Signed-off-by: Sasha Levin 
---
 fs/nfs/super.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 6b666d187907..6df9b85caf20 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2052,7 +2052,8 @@ static int nfs23_validate_mount_data(void *options,
memcpy(sap, >addr, sizeof(data->addr));
args->nfs_server.addrlen = sizeof(data->addr);
args->nfs_server.port = ntohs(data->addr.sin_port);
-   if (!nfs_verify_server_address(sap))
+   if (sap->sa_family != AF_INET ||
+   !nfs_verify_server_address(sap))
goto out_no_address;
 
if (!(data->flags & NFS_MOUNT_TCP))
-- 
2.19.1



[PATCH AUTOSEL 4.19 44/53] virtio-blk: limit number of hw queues by nr_cpu_ids

2019-04-26 Thread Sasha Levin
From: Dongli Zhang 

[ Upstream commit bf348f9b78d413e75bb079462751a1d86b6de36c ]

When tag_set->nr_maps is 1, the block layer limits the number of hw queues
by nr_cpu_ids. No matter how many hw queues are used by virtio-blk, as it
has (tag_set->nr_maps == 1), it can use at most nr_cpu_ids hw queues.

In addition, specifically for pci scenario, when the 'num-queues' specified
by qemu is more than maxcpus, virtio-blk would not be able to allocate more
than maxcpus vectors in order to have a vector for each queue. As a result,
it falls back into MSI-X with one vector for config and one shared for
queues.

Considering above reasons, this patch limits the number of hw queues used
by virtio-blk by nr_cpu_ids.

Reviewed-by: Stefan Hajnoczi 
Signed-off-by: Dongli Zhang 
Signed-off-by: Jens Axboe 
Signed-off-by: Sasha Levin 
---
 drivers/block/virtio_blk.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 23752dc99b00..dd64f586679e 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -446,6 +446,8 @@ static int init_vq(struct virtio_blk *vblk)
if (err)
num_vqs = 1;
 
+   num_vqs = min_t(unsigned int, nr_cpu_ids, num_vqs);
+
vblk->vqs = kmalloc_array(num_vqs, sizeof(*vblk->vqs), GFP_KERNEL);
if (!vblk->vqs)
return -ENOMEM;
-- 
2.19.1



[PATCH AUTOSEL 4.19 42/53] Bluetooth: btusb: request wake pin with NOAUTOEN

2019-04-26 Thread Sasha Levin
From: Brian Norris 

[ Upstream commit 771acc7e4a6e5dba779cb1a7fd851a164bc81033 ]

Badly-designed systems might have (for example) active-high wake pins
that default to high (e.g., because of external pull ups) until they
have an active firmware which starts driving it low.  This can cause an
interrupt storm in the time between request_irq() and disable_irq().

We don't support shared interrupts here, so let's just pre-configure the
interrupt to avoid auto-enabling it.

Fixes: fd913ef7ce61 ("Bluetooth: btusb: Add out-of-band wakeup support")
Fixes: 5364a0b4f4be ("arm64: dts: rockchip: move QCA6174A wakeup pin into its 
USB node")
Signed-off-by: Brian Norris 
Reviewed-by: Matthias Kaehlcke 
Signed-off-by: Linus Torvalds 
Signed-off-by: Sasha Levin 
---
 drivers/bluetooth/btusb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 77b67a5f21ee..40a4f95f6178 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2888,6 +2888,7 @@ static int btusb_config_oob_wake(struct hci_dev *hdev)
return 0;
}
 
+   irq_set_status_flags(irq, IRQ_NOAUTOEN);
ret = devm_request_irq(>dev, irq, btusb_oob_wake_handler,
   0, "OOB Wake-on-BT", data);
if (ret) {
@@ -2902,7 +2903,6 @@ static int btusb_config_oob_wake(struct hci_dev *hdev)
}
 
data->oob_wake_irq = irq;
-   disable_irq(irq);
bt_dev_info(hdev, "OOB Wake-on-BT configured at IRQ %u", irq);
return 0;
 }
-- 
2.19.1



[PATCH AUTOSEL 4.19 39/53] RDMA/hns: Fix bug that caused srq creation to fail

2019-04-26 Thread Sasha Levin
From: Lijun Ou 

[ Upstream commit 4772e03d239484f3461e33c79d721c8ea03f7416 ]

Due to the incorrect use of the seg and obj information, the position of
the mtt is calculated incorrectly, and the free space of the page is not
enough to store the entire mtt, resulting in access to the next page. This
patch fixes this problem.

 Unable to handle kernel paging request at virtual address 6e3cd000
 ...
 Call trace:
  hns_roce_write_mtt+0x154/0x2f0 [hns_roce]
  hns_roce_buf_write_mtt+0xa8/0xd8 [hns_roce]
  hns_roce_create_srq+0x74c/0x808 [hns_roce]
  ib_create_srq+0x28/0xc8

Fixes: 0203b14c4f32 ("RDMA/hns: Unify the calculation for hem index in hip08")
Signed-off-by: chenglang 
Signed-off-by: Lijun Ou 
Signed-off-by: Jason Gunthorpe 
Signed-off-by: Sasha Levin 
---
 drivers/infiniband/hw/hns/hns_roce_hem.c | 6 --
 drivers/infiniband/hw/hns/hns_roce_mr.c  | 4 ++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hem.c 
b/drivers/infiniband/hw/hns/hns_roce_hem.c
index f6faefed96e8..a73d388b7093 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hem.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hem.c
@@ -745,6 +745,8 @@ void *hns_roce_table_find(struct hns_roce_dev *hr_dev,
idx_offset = (obj & (table->num_obj - 1)) % obj_per_chunk;
dma_offset = offset = idx_offset * table->obj_size;
} else {
+   u32 seg_size = 64; /* 8 bytes per BA and 8 BA per segment */
+
hns_roce_calc_hem_mhop(hr_dev, table, _obj, );
/* mtt mhop */
i = mhop.l0_idx;
@@ -756,8 +758,8 @@ void *hns_roce_table_find(struct hns_roce_dev *hr_dev,
hem_idx = i;
 
hem = table->hem[hem_idx];
-   dma_offset = offset = (obj & (table->num_obj - 1)) *
-  table->obj_size % mhop.bt_chunk_size;
+   dma_offset = offset = (obj & (table->num_obj - 1)) * seg_size %
+  mhop.bt_chunk_size;
if (mhop.hop_num == 2)
dma_offset = offset = 0;
}
diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c 
b/drivers/infiniband/hw/hns/hns_roce_mr.c
index eb26a5f6fc58..41a538d23b80 100644
--- a/drivers/infiniband/hw/hns/hns_roce_mr.c
+++ b/drivers/infiniband/hw/hns/hns_roce_mr.c
@@ -707,7 +707,6 @@ static int hns_roce_write_mtt_chunk(struct hns_roce_dev 
*hr_dev,
struct hns_roce_hem_table *table;
dma_addr_t dma_handle;
__le64 *mtts;
-   u32 s = start_index * sizeof(u64);
u32 bt_page_size;
u32 i;
 
@@ -730,7 +729,8 @@ static int hns_roce_write_mtt_chunk(struct hns_roce_dev 
*hr_dev,
table = _dev->mr_table.mtt_cqe_table;
 
mtts = hns_roce_table_find(hr_dev, table,
-   mtt->first_seg + s / hr_dev->caps.mtt_entry_sz,
+   mtt->first_seg +
+   start_index / HNS_ROCE_MTT_ENTRY_PER_SEG,
_handle);
if (!mtts)
return -ENOMEM;
-- 
2.19.1



[PATCH AUTOSEL 4.14 03/32] ASoC:soc-pcm:fix a codec fixup issue in TDM case

2019-04-26 Thread Sasha Levin
From: Rander Wang 

[ Upstream commit 570f18b6a8d1f0e60e8caf30e66161b6438dcc91 ]

On HDaudio platforms, if playback is started when capture is working,
there is no audible output.

This can be root-caused to the use of the rx|tx_mask to store an HDaudio
stream tag.

If capture is stared before playback, rx_mask would be non-zero on HDaudio
platform, then the channel number of playback, which is in the same codec
dai with the capture, would be changed by soc_pcm_codec_params_fixup based
on the tx_mask at first, then overwritten by this function based on rx_mask
at last.

According to the author of tx|rx_mask, tx_mask is for playback and rx_mask
is for capture. And stream direction is checked at all other references of
tx|rx_mask in ASoC, so here should be an error. This patch checks stream
direction for tx|rx_mask for fixup function.

This issue would affect not only HDaudio+ASoC, but also I2S codecs if the
channel number based on rx_mask is not equal to the one for tx_mask. It could
be rarely reproduecd because most drivers in kernel set the same channel number
to tx|rx_mask or rx_mask is zero.

Tested on all platforms using stream_tag & HDaudio and intel I2S platforms.

Signed-off-by: Rander Wang 
Acked-by: Pierre-Louis Bossart 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/soc-pcm.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 6fc85199ac73..584b7ffe78f5 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -894,10 +894,13 @@ static int soc_pcm_hw_params(struct snd_pcm_substream 
*substream,
codec_params = *params;
 
/* fixup params based on TDM slot masks */
-   if (codec_dai->tx_mask)
+   if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
+   codec_dai->tx_mask)
soc_pcm_codec_params_fixup(_params,
   codec_dai->tx_mask);
-   if (codec_dai->rx_mask)
+
+   if (substream->stream == SNDRV_PCM_STREAM_CAPTURE &&
+   codec_dai->rx_mask)
soc_pcm_codec_params_fixup(_params,
   codec_dai->rx_mask);
 
-- 
2.19.1



[PATCH AUTOSEL 4.14 11/32] ASoC: tlv320aic32x4: Fix Common Pins

2019-04-26 Thread Sasha Levin
From: Annaliese McDermond 

[ Upstream commit c63adb28f6d913310430f14c69f0a2ea55eed0cc ]

The common pins were mistakenly not added to the DAPM graph.
Adding these pins will allow valid graphs to be created.

Signed-off-by: Annaliese McDermond 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/codecs/tlv320aic32x4.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c
index e694f5f04eb9..628621fc3386 100644
--- a/sound/soc/codecs/tlv320aic32x4.c
+++ b/sound/soc/codecs/tlv320aic32x4.c
@@ -462,6 +462,8 @@ static const struct snd_soc_dapm_widget 
aic32x4_dapm_widgets[] = {
SND_SOC_DAPM_INPUT("IN2_R"),
SND_SOC_DAPM_INPUT("IN3_L"),
SND_SOC_DAPM_INPUT("IN3_R"),
+   SND_SOC_DAPM_INPUT("CM_L"),
+   SND_SOC_DAPM_INPUT("CM_R"),
 };
 
 static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = {
-- 
2.19.1



[PATCH AUTOSEL 4.14 01/32] ASoC: hdmi-codec: fix S/PDIF DAI

2019-04-26 Thread Sasha Levin
From: Russell King 

[ Upstream commit 2e95f984aae4cf0608d0ba2189c756f2bd50b44a ]

When using the S/PDIF DAI, there is no requirement to call
snd_soc_dai_set_fmt() as there is no DAI format definition that defines
S/PDIF.  In any case, S/PDIF does not have separate clocks, this is
embedded into the data stream.

Consequently, when attempting to use TDA998x in S/PDIF mode, the attempt
to configure TDA998x via the hw_params callback fails as the
hdmi_codec_daifmt is left initialised to zero.

Since the S/PDIF DAI will only be used by S/PDIF, prepare the
hdmi_codec_daifmt structure for this format.

Signed-off-by: Russell King 
Reviewed-by: Jyri Sarha 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/codecs/hdmi-codec.c | 118 +-
 1 file changed, 59 insertions(+), 59 deletions(-)

diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index cf3b905b4ead..7406695ee5dc 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -536,73 +536,71 @@ static int hdmi_codec_set_fmt(struct snd_soc_dai *dai,
 {
struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
struct hdmi_codec_daifmt cf = { 0 };
-   int ret = 0;
 
dev_dbg(dai->dev, "%s()\n", __func__);
 
-   if (dai->id == DAI_ID_SPDIF) {
-   cf.fmt = HDMI_SPDIF;
-   } else {
-   switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
-   case SND_SOC_DAIFMT_CBM_CFM:
-   cf.bit_clk_master = 1;
-   cf.frame_clk_master = 1;
-   break;
-   case SND_SOC_DAIFMT_CBS_CFM:
-   cf.frame_clk_master = 1;
-   break;
-   case SND_SOC_DAIFMT_CBM_CFS:
-   cf.bit_clk_master = 1;
-   break;
-   case SND_SOC_DAIFMT_CBS_CFS:
-   break;
-   default:
-   return -EINVAL;
-   }
+   if (dai->id == DAI_ID_SPDIF)
+   return 0;
+
+   switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
+   case SND_SOC_DAIFMT_CBM_CFM:
+   cf.bit_clk_master = 1;
+   cf.frame_clk_master = 1;
+   break;
+   case SND_SOC_DAIFMT_CBS_CFM:
+   cf.frame_clk_master = 1;
+   break;
+   case SND_SOC_DAIFMT_CBM_CFS:
+   cf.bit_clk_master = 1;
+   break;
+   case SND_SOC_DAIFMT_CBS_CFS:
+   break;
+   default:
+   return -EINVAL;
+   }
 
-   switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
-   case SND_SOC_DAIFMT_NB_NF:
-   break;
-   case SND_SOC_DAIFMT_NB_IF:
-   cf.frame_clk_inv = 1;
-   break;
-   case SND_SOC_DAIFMT_IB_NF:
-   cf.bit_clk_inv = 1;
-   break;
-   case SND_SOC_DAIFMT_IB_IF:
-   cf.frame_clk_inv = 1;
-   cf.bit_clk_inv = 1;
-   break;
-   }
+   switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
+   case SND_SOC_DAIFMT_NB_NF:
+   break;
+   case SND_SOC_DAIFMT_NB_IF:
+   cf.frame_clk_inv = 1;
+   break;
+   case SND_SOC_DAIFMT_IB_NF:
+   cf.bit_clk_inv = 1;
+   break;
+   case SND_SOC_DAIFMT_IB_IF:
+   cf.frame_clk_inv = 1;
+   cf.bit_clk_inv = 1;
+   break;
+   }
 
-   switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
-   case SND_SOC_DAIFMT_I2S:
-   cf.fmt = HDMI_I2S;
-   break;
-   case SND_SOC_DAIFMT_DSP_A:
-   cf.fmt = HDMI_DSP_A;
-   break;
-   case SND_SOC_DAIFMT_DSP_B:
-   cf.fmt = HDMI_DSP_B;
-   break;
-   case SND_SOC_DAIFMT_RIGHT_J:
-   cf.fmt = HDMI_RIGHT_J;
-   break;
-   case SND_SOC_DAIFMT_LEFT_J:
-   cf.fmt = HDMI_LEFT_J;
-   break;
-   case SND_SOC_DAIFMT_AC97:
-   cf.fmt = HDMI_AC97;
-   break;
-   default:
-   dev_err(dai->dev, "Invalid DAI interface format\n");
-   return -EINVAL;
-   }
+   switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
+   case SND_SOC_DAIFMT_I2S:
+   cf.fmt = HDMI_I2S;
+   break;
+   case SND_SOC_DAIFMT_DSP_A:
+   cf.fmt = HDMI_DSP_A;
+   break;
+   case SND_SOC_DAIFMT_DSP_B:
+   cf.fmt = HDMI_DSP_B;
+   break;
+   case SND_SOC_DAIFMT_RIGHT_J:
+   cf.fmt = HDMI_RIGHT_J;
+   break;
+   case SND_SOC_DAIFMT_LEFT_J:
+ 

[PATCH AUTOSEL 4.14 06/32] ASoC: samsung: odroid: Fix clock configuration for 44100 sample rate

2019-04-26 Thread Sasha Levin
From: Sylwester Nawrocki 

[ Upstream commit 2b13bee3884926cba22061efa75bd315e871de24 ]

After commit fbeec965b8d1c ("ASoC: samsung: odroid: Fix 32000 sample rate
handling") the audio root clock frequency is configured improperly for
44100 sample rate. Due to clock rate rounding it's 20070401 Hz instead
of 22579000 Hz. This results in a too low value of the PSR clock divider
in the CPU DAI driver and too fast actual sample rate for fs=44100. E.g.
1 kHz tone has actual 1780 Hz frequency (1 kHz * 20070401/22579000 * 2).

Fix this by increasing the correction passed to clk_set_rate() to take
into account inaccuracy of the EPLL frequency properly.

Fixes: fbeec965b8d1c ("ASoC: samsung: odroid: Fix 32000 sample rate handling")
Reported-by: JaeChul Lee 
Signed-off-by: Sylwester Nawrocki 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/samsung/odroid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c
index 06a31a9585a0..32c9e197ca95 100644
--- a/sound/soc/samsung/odroid.c
+++ b/sound/soc/samsung/odroid.c
@@ -66,11 +66,11 @@ static int odroid_card_hw_params(struct snd_pcm_substream 
*substream,
return ret;
 
/*
-*  We add 1 to the rclk_freq value in order to avoid too low clock
+*  We add 2 to the rclk_freq value in order to avoid too low clock
 *  frequency values due to the EPLL output frequency not being exact
 *  multiple of the audio sampling rate.
 */
-   rclk_freq = params_rate(params) * rfs + 1;
+   rclk_freq = params_rate(params) * rfs + 2;
 
ret = clk_set_rate(priv->sclk_i2s, rclk_freq);
if (ret < 0)
-- 
2.19.1



[PATCH AUTOSEL 4.14 08/32] ASoC: cs4270: Set auto-increment bit for register writes

2019-04-26 Thread Sasha Levin
From: Daniel Mack 

[ Upstream commit f0f2338a9cfaf71db895fa989ea7234e8a9b471d ]

The CS4270 does not by default increment the register address on
consecutive writes. During normal operation it doesn't matter as all
register accesses are done individually. At resume time after suspend,
however, the regcache code gathers the biggest possible block of
registers to sync and sends them one on one go.

To fix this, set the INCR bit in all cases.

Signed-off-by: Daniel Mack 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/codecs/cs4270.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c
index 84f86745c30e..828bc615a190 100644
--- a/sound/soc/codecs/cs4270.c
+++ b/sound/soc/codecs/cs4270.c
@@ -643,6 +643,7 @@ static const struct regmap_config cs4270_regmap = {
.reg_defaults = cs4270_reg_defaults,
.num_reg_defaults = ARRAY_SIZE(cs4270_reg_defaults),
.cache_type =   REGCACHE_RBTREE,
+   .write_flag_mask =  CS4270_I2C_INCR,
 
.readable_reg = cs4270_reg_is_readable,
.volatile_reg = cs4270_reg_is_volatile,
-- 
2.19.1



[PATCH AUTOSEL 4.14 09/32] IB/hfi1: Eliminate opcode tests on mr deref

2019-04-26 Thread Sasha Levin
From: Kaike Wan 

[ Upstream commit a8639a79e85c18c16c10089edd589c7948f19bbd ]

When an old ack_queue entry is used to store an incoming request, it may
need to clean up the old entry if it is still referencing the
MR. Originally only RDMA READ request needed to reference MR on the
responder side and therefore the opcode was tested when cleaning up the
old entry. The introduction of tid rdma specific operations in the
ack_queue makes the specific opcode tests wrong.  Multiple opcodes (RDMA
READ, TID RDMA READ, and TID RDMA WRITE) may need MR ref cleanup.

Remove the opcode specific tests associated with the ack_queue.

Fixes: f48ad614c100 ("IB/hfi1: Move driver out of staging")
Signed-off-by: Mike Marciniszyn 
Signed-off-by: Kaike Wan 
Signed-off-by: Dennis Dalessandro 
Signed-off-by: Jason Gunthorpe 
Signed-off-by: Sasha Levin 
---
 drivers/infiniband/hw/hfi1/rc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/rc.c b/drivers/infiniband/hw/hfi1/rc.c
index d3b8cb92fd6d..28eb7003c297 100644
--- a/drivers/infiniband/hw/hfi1/rc.c
+++ b/drivers/infiniband/hw/hfi1/rc.c
@@ -2309,7 +2309,7 @@ void hfi1_rc_rcv(struct hfi1_packet *packet)
update_ack_queue(qp, next);
}
e = >s_ack_queue[qp->r_head_ack_queue];
-   if (e->opcode == OP(RDMA_READ_REQUEST) && e->rdma_sge.mr) {
+   if (e->rdma_sge.mr) {
rvt_put_mr(e->rdma_sge.mr);
e->rdma_sge.mr = NULL;
}
@@ -2383,7 +2383,7 @@ void hfi1_rc_rcv(struct hfi1_packet *packet)
update_ack_queue(qp, next);
}
e = >s_ack_queue[qp->r_head_ack_queue];
-   if (e->opcode == OP(RDMA_READ_REQUEST) && e->rdma_sge.mr) {
+   if (e->rdma_sge.mr) {
rvt_put_mr(e->rdma_sge.mr);
e->rdma_sge.mr = NULL;
}
-- 
2.19.1



[PATCH AUTOSEL 4.14 05/32] ASoC: nau8810: fix the issue of widget with prefixed name

2019-04-26 Thread Sasha Levin
From: John Hsu 

[ Upstream commit 54d1cf78b0f4ba348a7c7fb8b7d0708d71b6cc8a ]

The driver changes the stream name of DAC and ADC to avoid the issue of
widget with prefixed name. When the machine adds prefixed name for codec,
the stream name of DAI may not find the widgets.

Signed-off-by: John Hsu 
Signed-off-by: Mark Brown 
Signed-off-by: Sasha Levin 
---
 sound/soc/codecs/nau8810.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/nau8810.c b/sound/soc/codecs/nau8810.c
index c8e2451ae0a3..193588eb9835 100644
--- a/sound/soc/codecs/nau8810.c
+++ b/sound/soc/codecs/nau8810.c
@@ -414,9 +414,9 @@ static const struct snd_soc_dapm_widget 
nau8810_dapm_widgets[] = {
SND_SOC_DAPM_MIXER("Mono Mixer", NAU8810_REG_POWER3,
NAU8810_MOUTMX_EN_SFT, 0, _mono_mixer_controls[0],
ARRAY_SIZE(nau8810_mono_mixer_controls)),
-   SND_SOC_DAPM_DAC("DAC", "HiFi Playback", NAU8810_REG_POWER3,
+   SND_SOC_DAPM_DAC("DAC", "Playback", NAU8810_REG_POWER3,
NAU8810_DAC_EN_SFT, 0),
-   SND_SOC_DAPM_ADC("ADC", "HiFi Capture", NAU8810_REG_POWER2,
+   SND_SOC_DAPM_ADC("ADC", "Capture", NAU8810_REG_POWER2,
NAU8810_ADC_EN_SFT, 0),
SND_SOC_DAPM_PGA("SpkN Out", NAU8810_REG_POWER3,
NAU8810_NSPK_EN_SFT, 0, NULL, 0),
-- 
2.19.1



  1   2   3   4   5   6   7   8   9   >