Re: [RFC][PATCHv5 07/13] printk: register syscore notifier

2017-08-15 Thread Sergey Senozhatsky
On (08/15/17 13:56), Rafael J. Wysocki wrote:
[..]
> > +static int printk_syscore_suspend(void)
> > +{
> > +   printk_emergency_begin();
> > +   return 0;
> > +}
> 
> Somebody looking at suspend/resume code paths only will be wondering why
> you need this, because we should be in the emergency mode already when
> it is called.
> 
> It would be good to add a comment about the kexec context here.

ok, will add.

> > +static void printk_syscore_resume(void)
> > +{
> > +   printk_emergency_end();
> > +}
> 
> This will turn the emergency mode off during resume before the notifier
> added by the previous patch AFAICS.  Is this intentional?

emergency modes can nest. so it's OK to have

printk_emergency_begin()   +1   // on
  printk_emergency_begin()   +1
  printk_emergency_end() -1
printk_emergency_end() -1   // off

or did I misunderstand your question?

-ss


Re: [PATCH 2/2] cpufreq: dt-platdev: Drop few entries from whitelist

2017-08-15 Thread Geert Uytterhoeven
Hi Viresh,

On Wed, Aug 16, 2017 at 7:37 AM, Viresh Kumar  wrote:
> Drop few ARM (32 and 64 bit) platforms from the whitelist which always
> use "operating-points-v2" property from their DT. They should continue
> to work after this patch.
>
> Tested on Hikey platform (only the "hisilicon,hi6220" entry).
>
> Signed-off-by: Viresh Kumar 
> ---
>  drivers/cpufreq/cpufreq-dt-platdev.c | 11 ---
>  1 file changed, 11 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c 
> b/drivers/cpufreq/cpufreq-dt-platdev.c
> index 061b468512a2..45f2ec3b7f7a 100644
> --- a/drivers/cpufreq/cpufreq-dt-platdev.c
> +++ b/drivers/cpufreq/cpufreq-dt-platdev.c
> @@ -27,7 +27,6 @@ static const struct of_device_id whitelist[] __initconst = {
> { .compatible = "allwinner,sun6i-a31s", },
> { .compatible = "allwinner,sun7i-a20", },
> { .compatible = "allwinner,sun8i-a23", },
> -   { .compatible = "allwinner,sun8i-a33", },
> { .compatible = "allwinner,sun8i-a83t", },
> { .compatible = "allwinner,sun8i-h3", },

I think "renesas,r8a7795" can be removed again, too.
Simon?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH] i2c: aspeed: Retain delay/setup/hold values when configuring bus frequency

2017-08-15 Thread Joel Stanley
On Tue, Aug 15, 2017 at 4:51 PM, Andrew Jeffery  wrote:
> In addition to the base, low and high clock configuration, the AC timing
> register #1 on the AST2400 houses fields controlling:
>
> 1. tBUF: Minimum delay between Stop and Start conditions
> 2. tHDSTA: Hold time for the Start condition
> 3. tACST: Setup time for Start and Stop conditions, and hold time for the
>Repeated Start condition
>
> These values are defined in hardware on the AST2500 and therefore don't
> need to be set.
>
> aspeed_i2c_init_clk() was performing a direct write of the generated
> clock values rather than a read/mask/modify/update sequence to retain
> tBUF, tHDSTA and tACST, and therefore cleared the tBUF, tHDSTA and tACST
> fields on the AST2400. This resulted in a delay/setup/hold time of 1
> base clock, which in some configurations is not enough for some devices
> (e.g. the MAX31785 fan controller, with an APB of 48MHz and a desired
> bus speed of 100kHz).
>
> Signed-off-by: Andrew Jeffery 
> ---
>  drivers/i2c/busses/i2c-aspeed.c | 9 -
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
> index ee76e6dddc4b..284f8670dbeb 100644
> --- a/drivers/i2c/busses/i2c-aspeed.c
> +++ b/drivers/i2c/busses/i2c-aspeed.c
> @@ -53,6 +53,9 @@
>  #define ASPEED_I2CD_MASTER_EN  BIT(0)
>
>  /* 0x04 : I2CD Clock and AC Timing Control Register #1 */
> +#define ASPEED_I2CD_TIME_TBUF_MASK GENMASK(31, 28)
> +#define ASPEED_I2CD_TIME_THDSTA_MASK   GENMASK(27, 24)
> +#define ASPEED_I2CD_TIME_TACST_MASKGENMASK(23, 20)
>  #define ASPEED_I2CD_TIME_SCL_HIGH_SHIFT16
>  #define ASPEED_I2CD_TIME_SCL_HIGH_MASK GENMASK(19, 16)
>  #define ASPEED_I2CD_TIME_SCL_LOW_SHIFT 12
> @@ -744,7 +747,11 @@ static int aspeed_i2c_init_clk(struct aspeed_i2c_bus 
> *bus)
> u32 divisor, clk_reg_val;
>
> divisor = DIV_ROUND_UP(bus->parent_clk_frequency, bus->bus_frequency);
> -   clk_reg_val = bus->get_clk_reg_val(divisor);
> +   clk_reg_val = readl(bus->base + ASPEED_I2C_AC_TIMING_REG1);
> +   clk_reg_val &= (ASPEED_I2CD_TIME_TBUF_MASK |
> +   ASPEED_I2CD_TIME_THDSTA_MASK |
> +   ASPEED_I2CD_TIME_TACST_MASK);

Instead of keeping the u-boot values (which appear to be hard-coded),
should we instead put the known working values in the register?

Cheers,

Joel


[PATCH V2] KVM/x86: Increase max vcpu number to 8192

2017-08-15 Thread Lan Tianyu
For HPC usage case, it will create a huge VM with vcpus number as same as host
cpus and this requires more vcpus support in a single VM. This patch is to
increase max vcpu number from 288 to 8192 which is current default maximum cpu
number for Linux kernel.

Signed-off-by: Lan Tianyu 
---
 arch/x86/include/asm/kvm_host.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 87ac4fb..7946394 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -35,7 +35,7 @@
 #include 
 #include 
 
-#define KVM_MAX_VCPUS 288
+#define KVM_MAX_VCPUS 8192
 #define KVM_SOFT_MAX_VCPUS 240
 #define KVM_MAX_VCPU_ID 1023
 #define KVM_USER_MEM_SLOTS 509
-- 
1.8.3.1



Re: [PATCH v6 2/5] drm/vc4: Avoid using vrefresh==0 mode in DSI htotal math.

2017-08-15 Thread Andrzej Hajda
On 16.08.2017 01:47, Eric Anholt wrote:
> The incoming mode might have a missing vrefresh field if it came from
> drmModeSetCrtc(), which the kernel is supposed to calculate using
> drm_mode_vrefresh().  We could either use that or the adjusted_mode's
> original vrefresh value.
>
> However, we can maintain a more exact vrefresh value (not just the
> integer approximation), by scaling by the ratio of our clocks.
>
> v2: Use math suggested by Andrzej Hajda instead.
> v3: Simplify math now that adjusted_mode->clock isn't padded.
>
> Signed-off-by: Eric Anholt 
> ---
>  drivers/gpu/drm/vc4/vc4_dsi.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c
> index eb787eed8abe..2516cd3a1d87 100644
> --- a/drivers/gpu/drm/vc4/vc4_dsi.c
> +++ b/drivers/gpu/drm/vc4/vc4_dsi.c
> @@ -862,7 +862,8 @@ static bool vc4_dsi_encoder_mode_fixup(struct drm_encoder 
> *encoder,
>   adjusted_mode->clock = pixel_clock_hz / 1000;
>  
>   /* Given the new pixel clock, adjust HFP to keep vrefresh the same. */
> - adjusted_mode->htotal = pixel_clock_hz / (mode->vrefresh * 
> mode->vtotal);
> + adjusted_mode->htotal = (adjusted_mode->clock * mode->htotal /
> +  mode->clock);

Parentheses can be removed.
Beside this:

Reviewed-by: Andrzej Hajda 

 --
Regards
Andrzej

>   adjusted_mode->hsync_end += adjusted_mode->htotal - mode->htotal;
>   adjusted_mode->hsync_start += adjusted_mode->htotal - mode->htotal;
>  




Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature

2017-08-15 Thread Byungchul Park
On Wed, Aug 16, 2017 at 01:40:51PM +0800, Boqun Feng wrote:
> > > > Worker A : acquired of wfc.work -> wait for cpu_hotplug_lock to be 
> > > > released
> > > > Task   B : acquired of cpu_hotplug_lock -> wait for lock#3 to be 
> > > > released
> > > > Task   C : acquired of lock#3 -> wait for completion of barr->done
> > > 
> > > >From the stack trace below, this barr->done is for flush_work() in
> > > lru_add_drain_all_cpuslocked(), i.e. for work 
> > > "per_cpu(lru_add_drain_work)"
> > > 
> > > > Worker D : wait for wfc.work to be released -> will complete barr->done
> > > 
> > > and this barr->done is for work "wfc.work".
> > 
> > I think it can be the same instance. wait_for_completion() in flush_work()
> > e.g. at task C in my example, waits for completion which we expect to be
> > done by a worker e.g. worker D in my example.
> > 
> > I think the problem is caused by a write-acquisition of wfc.work in
> > process_one_work(). The acquisition of wfc.work should be reenterable,
> > that is, read-acquisition, shouldn't it?
> > 
> 
> The only thing is that wfc.work is not a real and please see code in
> flush_work(). And if a task C do a flush_work() for "wfc.work" with
> lock#3 held, it needs to "acquire" wfc.work before it
> wait_for_completion(), which is already a deadlock case:
> 
>   lock#3 -> wfc.work -> cpu_hotplug_lock -+
>   ^ |
> | |
> +-+
> 
> , without crossrelease enabled. So the task C didn't flush work wfc.work
> in the previous case, which implies barr->done in Task C and Worker D
> are not the same instance.
> 
> Make sense?

Thank you very much for your explanation. I misunderstood how flush_work()
works. Yes, it seems to be led by incorrect class of completion.

Thanks,
Byungchul

> 
> Regards,
> Boqun
> 
> > I might be wrong... Please fix me if so.
> > 
> > Thank you,
> > Byungchul
> > 
> > > So those two barr->done could not be the same instance, IIUC. Therefore
> > > the deadlock case is not possible.
> > > 
> > > The problem here is all barr->done instances are initialized at
> > > insert_wq_barrier() and they belongs to the same lock class, to fix
> > > this, we need to differ barr->done with different lock classes based on
> > > the corresponding works.
> > > 
> > > How about the this(only compilation test):
> > > 
> > > ->8
> > > diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> > > index e86733a8b344..d14067942088 100644
> > > --- a/kernel/workqueue.c
> > > +++ b/kernel/workqueue.c
> > > @@ -2431,6 +2431,27 @@ struct wq_barrier {
> > >   struct task_struct  *task;  /* purely informational */
> > >  };
> > >  
> > > +#ifdef CONFIG_LOCKDEP_COMPLETE
> > > +# define INIT_WQ_BARRIER_ONSTACK(barr, func, target) 
> > > \
> > > +do { 
> > > \
> > > + INIT_WORK_ONSTACK(&(barr)->work, func); 
> > > \
> > > + __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&(barr)->work));  
> > > \
> > > + lockdep_init_map_crosslock((struct lockdep_map *)&(barr)->done.map, 
> > > \
> > > +"(complete)" #barr,  
> > > \
> > > +(target)->lockdep_map.key, 1);   
> > > \
> > > + __init_completion(&barr->done); 
> > > \
> > > + barr->task = current;   
> > > \
> > > +} while (0)
> > > +#else
> > > +# define INIT_WQ_BARRIER_ONSTACK(barr, func, target) 
> > > \
> > > +do { 
> > > \
> > > + INIT_WORK_ONSTACK(&(barr)->work, func); 
> > > \
> > > + __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&(barr)->work));  
> > > \
> > > + init_completion(&barr->done);   
> > > \
> > > + barr->task = current;   
> > > \
> > > +} while (0)
> > > +#endif
> > > +
> > >  static void wq_barrier_func(struct work_struct *work)
> > >  {
> > >   struct wq_barrier *barr = container_of(work, struct wq_barrier, work);
> > > @@ -2474,10 +2495,7 @@ static void insert_wq_barrier(struct 
> > > pool_workqueue *pwq,
> > >* checks and call back into the fixup functions where we
> > >* might deadlock.
> > >*/
> > > - INIT_WORK_ONSTACK(&barr->work, wq_barrier_func);
> > > - __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&barr->work));
> > > - init_completion(&barr->done);
> > > - barr->task = current;
> > > + INIT_WQ_BARRIER_ONSTACK(barr, wq_barrier_func, target);
> > >  
> > >   /*
> > >* If @target is currently being executed, schedule the




Re: [PATCH V3 3/9] cpufreq: Cap the default transition delay value to 10 ms

2017-08-15 Thread Viresh Kumar
On 28-07-17, 10:58, Viresh Kumar wrote:
> At this point I really feel that this is a hardware specific problem
> and it was working by chance until now. And I am not sure if we
> shouldn't be stopping this patch from getting merged just because of
> that.
> 
> At least you can teach your distribution to go increase the sampling
> rate from userspace to make it all work.

Its been 3 weeks since my last email on this thread and no reply yet
from any of the IMX maintainers. Can someone please help here ?

@Shawn: Can you help debugging a bit here, to see what's get screwed
up due to this commit ? Its just that your platform isn't able to
change freq at 10 ms rate.

@Rafael: I am not sure, but should we be stopping this patch because
some hardware isn't able to change freq at 10ms interval and is just
faking the transition delay to start with ?

Maybe we get this merged again and the IMX guys can figure out what's
wrong on their platform and how to fix it ?

-- 
viresh


Re: [PATCH] i2c: aspeed: Retain delay/setup/hold values when configuring bus frequency

2017-08-15 Thread Brendan Higgins
On Tue, Aug 15, 2017 at 10:21 AM, Andrew Jeffery  wrote:
> In addition to the base, low and high clock configuration, the AC timing
> register #1 on the AST2400 houses fields controlling:
>
> 1. tBUF: Minimum delay between Stop and Start conditions
> 2. tHDSTA: Hold time for the Start condition
> 3. tACST: Setup time for Start and Stop conditions, and hold time for the
>Repeated Start condition
>
> These values are defined in hardware on the AST2500 and therefore don't
> need to be set.
>
> aspeed_i2c_init_clk() was performing a direct write of the generated
> clock values rather than a read/mask/modify/update sequence to retain
> tBUF, tHDSTA and tACST, and therefore cleared the tBUF, tHDSTA and tACST
> fields on the AST2400. This resulted in a delay/setup/hold time of 1
> base clock, which in some configurations is not enough for some devices
> (e.g. the MAX31785 fan controller, with an APB of 48MHz and a desired
> bus speed of 100kHz).
>
> Signed-off-by: Andrew Jeffery 
> ---
>  drivers/i2c/busses/i2c-aspeed.c | 9 -
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
> index ee76e6dddc4b..284f8670dbeb 100644
> --- a/drivers/i2c/busses/i2c-aspeed.c
> +++ b/drivers/i2c/busses/i2c-aspeed.c
> @@ -53,6 +53,9 @@
>  #define ASPEED_I2CD_MASTER_EN  BIT(0)
>
>  /* 0x04 : I2CD Clock and AC Timing Control Register #1 */
> +#define ASPEED_I2CD_TIME_TBUF_MASK GENMASK(31, 28)
> +#define ASPEED_I2CD_TIME_THDSTA_MASK   GENMASK(27, 24)
> +#define ASPEED_I2CD_TIME_TACST_MASKGENMASK(23, 20)
>  #define ASPEED_I2CD_TIME_SCL_HIGH_SHIFT16
>  #define ASPEED_I2CD_TIME_SCL_HIGH_MASK GENMASK(19, 16)
>  #define ASPEED_I2CD_TIME_SCL_LOW_SHIFT 12
> @@ -744,7 +747,11 @@ static int aspeed_i2c_init_clk(struct aspeed_i2c_bus 
> *bus)
> u32 divisor, clk_reg_val;
>
> divisor = DIV_ROUND_UP(bus->parent_clk_frequency, bus->bus_frequency);
> -   clk_reg_val = bus->get_clk_reg_val(divisor);
> +   clk_reg_val = readl(bus->base + ASPEED_I2C_AC_TIMING_REG1);
> +   clk_reg_val &= (ASPEED_I2CD_TIME_TBUF_MASK |
> +   ASPEED_I2CD_TIME_THDSTA_MASK |
> +   ASPEED_I2CD_TIME_TACST_MASK);
> +   clk_reg_val |= bus->get_clk_reg_val(divisor);
> writel(clk_reg_val, bus->base + ASPEED_I2C_AC_TIMING_REG1);
> writel(ASPEED_NO_TIMEOUT_CTRL, bus->base + ASPEED_I2C_AC_TIMING_REG2);
>
> --
> 2.11.0
>

Awesome! I think this might fix an issue we saw on one of our boards.
I am out of the country right now, so I cannot test this myself, until Monday.


Re: [PATCH 2/2] dmaengine: at_xdmac: Handle return value of clk_prepare_enable.

2017-08-15 Thread Ludovic Desroches
On Mon, Aug 07, 2017 at 01:15:19PM +0530, Arvind Yadav wrote:
> clk_prepare_enable() can fail here and we must check its return value.
> 
> Signed-off-by: Arvind Yadav 
Acked-by: Ludovic Desroches 

Thanks
> ---
>  drivers/dma/at_xdmac.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
> index 6a3cf97..c00e392 100644
> --- a/drivers/dma/at_xdmac.c
> +++ b/drivers/dma/at_xdmac.c
> @@ -1883,8 +1883,11 @@ static int atmel_xdmac_resume(struct device *dev)
>   struct at_xdmac_chan*atchan;
>   struct dma_chan *chan, *_chan;
>   int i;
> + int ret;
>  
> - clk_prepare_enable(atxdmac->clk);
> + ret = clk_prepare_enable(atxdmac->clk);
> + if (ret)
> + return ret;
>  
>   /* Clear pending interrupts. */
>   for (i = 0; i < atxdmac->dma.chancnt; i++) {
> -- 
> 1.9.1
> 


Re: [PATCH 1/2] dmaengine: at_xdmac: Fix compilation warning.

2017-08-15 Thread Ludovic Desroches
On Mon, Aug 07, 2017 at 01:15:18PM +0530, Arvind Yadav wrote:
> Replace '%d' by '%zu' to fix the compilation warning:-
>"format ‘%d’ expects argument of type ‘int’,but argument has type ‘size_t’ 
> [-Wformat=]"
> 
> Signed-off-by: Arvind Yadav 
Acked-by: Ludovic Desroches 

Thanks
> ---
>  drivers/dma/at_xdmac.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
> index 7d4e0bc..6a3cf97 100644
> --- a/drivers/dma/at_xdmac.c
> +++ b/drivers/dma/at_xdmac.c
> @@ -875,7 +875,7 @@ static inline u32 at_xdmac_align_width(struct dma_chan 
> *chan, dma_addr_t addr)
>   dwidth = at_xdmac_align_width(chan, src | dst | chunk->size);
>   if (chunk->size >= (AT_XDMAC_MBR_UBC_UBLEN_MAX << dwidth)) {
>   dev_dbg(chan2dev(chan),
> - "%s: chunk too big (%d, max size %lu)...\n",
> + "%s: chunk too big (%zu, max size %lu)...\n",
>   __func__, chunk->size,
>   AT_XDMAC_MBR_UBC_UBLEN_MAX << dwidth);
>   return NULL;
> @@ -956,7 +956,7 @@ static inline u32 at_xdmac_align_width(struct dma_chan 
> *chan, dma_addr_t addr)
>   if ((xt->numf > 1) && (xt->frame_size > 1))
>   return NULL;
>  
> - dev_dbg(chan2dev(chan), "%s: src=%pad, dest=%pad, numf=%d, 
> frame_size=%d, flags=0x%lx\n",
> + dev_dbg(chan2dev(chan), "%s: src=%pad, dest=%pad, numf=%zu, 
> frame_size=%zu, flags=0x%lx\n",
>   __func__, &xt->src_start, &xt->dst_start,   xt->numf,
>   xt->frame_size, flags);
>  
> @@ -990,7 +990,7 @@ static inline u32 at_xdmac_align_width(struct dma_chan 
> *chan, dma_addr_t addr)
>   dst_skip = chunk->size + dst_icg;
>  
>   dev_dbg(chan2dev(chan),
> - "%s: chunk size=%d, src icg=%d, dst icg=%d\n",
> + "%s: chunk size=%zu, src icg=%zu, dst 
> icg=%zu\n",
>   __func__, chunk->size, src_icg, dst_icg);
>  
>   desc = at_xdmac_interleaved_queue_desc(chan, atchan,
> @@ -1207,7 +1207,7 @@ static struct at_xdmac_desc 
> *at_xdmac_memset_create_desc(struct dma_chan *chan,
>   struct at_xdmac_chan*atchan = to_at_xdmac_chan(chan);
>   struct at_xdmac_desc*desc;
>  
> - dev_dbg(chan2dev(chan), "%s: dest=%pad, len=%d, pattern=0x%x, 
> flags=0x%lx\n",
> + dev_dbg(chan2dev(chan), "%s: dest=%pad, len=%zu, pattern=0x%x, 
> flags=0x%lx\n",
>   __func__, &dest, len, value, flags);
>  
>   if (unlikely(!len))
> -- 
> 1.9.1
> 
> 
> ___
> linux-arm-kernel mailing list
> linux-arm-ker...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel


[PATCH v2 1/4] usb: mtu3: add generic compatible string

2017-08-15 Thread Chunfeng Yun
The mtu3 driver is a generic driver for MediaTek usb3 DRD IP, add
a generic compatible to avoid confusion when support new SoCs but
use a compatible with specific SoC's name "mt8173".

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/mtu3/mtu3_plat.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
index 0d3ebb3..088e3e6 100644
--- a/drivers/usb/mtu3/mtu3_plat.c
+++ b/drivers/usb/mtu3/mtu3_plat.c
@@ -500,6 +500,7 @@ static int __maybe_unused mtu3_resume(struct device *dev)
 
 static const struct of_device_id mtu3_of_match[] = {
{.compatible = "mediatek,mt8173-mtu3",},
+   {.compatible = "mediatek,mtu3",},
{},
 };
 
-- 
1.7.9.5



Re: [PATCH] gpio: brcmstb: check return value of gpiochip_irqchip_add()

2017-08-15 Thread Gregory Fong
On Wed, Aug 9, 2017 at 3:51 PM, Masahiro Yamada
 wrote:
> Because gpiochip_irqchip_add() may fail, its return value should
> be checked.
>
> Signed-off-by: Masahiro Yamada 

Acked-by: Gregory Fong 


[PATCH v2 4/4] dt-bindings: mt8173-xhci: add generic compatible and rename file

2017-08-15 Thread Chunfeng Yun
The mt8173-xhci.txt actually holds the bindings for all mediatek
SoCs with xHCI controller, so add a generic compatible and change
the name to mediatek,mtk-xhci.txt to reflect that.

Signed-off-by: Chunfeng Yun 
---
 .../usb/{mt8173-xhci.txt => mediatek,mtk-xhci.txt} |   14 +++---
 .../devicetree/bindings/usb/mediatek,mtu3.txt  |2 +-
 2 files changed, 12 insertions(+), 4 deletions(-)
 rename Documentation/devicetree/bindings/usb/{mt8173-xhci.txt => 
mediatek,mtk-xhci.txt} (85%)

diff --git a/Documentation/devicetree/bindings/usb/mt8173-xhci.txt 
b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
similarity index 85%
rename from Documentation/devicetree/bindings/usb/mt8173-xhci.txt
rename to Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
index 0acfc8a..ff21135 100644
--- a/Documentation/devicetree/bindings/usb/mt8173-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
@@ -11,7 +11,11 @@ into two parts.
 
 
 Required properties:
- - compatible : should contain "mediatek,mt8173-xhci"
+ - compatible : should be "mediatek,soc-model-xhci", "mediatek,mtk-xhci",
+   soc-model is the name of SoC, such as mt8173, mt2712 etc, when using
+   "mediatek,mtk-xhci" compatible string, you need SoC specific ones in
+   addition, one of:
+   - "mediatek,mt8173-xhci"
  - reg : specifies physical base address and size of the registers
  - reg-names: should be "mac" for xHCI MAC and "ippc" for IP port control
  - interrupts : interrupt used by the controller
@@ -68,10 +72,14 @@ usb30: usb@1127 {
 
 In the case, xhci is added as subnode to mtu3. An example and the DT binding
 details of mtu3 can be found in:
-Documentation/devicetree/bindings/usb/mt8173-mtu3.txt
+Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
 
 Required properties:
- - compatible : should contain "mediatek,mt8173-xhci"
+ - compatible : should be "mediatek,soc-model-xhci", "mediatek,mtk-xhci",
+   soc-model is the name of SoC, such as mt8173, mt2712 etc, when using
+   "mediatek,mtk-xhci" compatible string, you need SoC specific ones in
+   addition, one of:
+   - "mediatek,mt8173-xhci"
  - reg : specifies physical base address and size of the registers
  - reg-names: should be "mac" for xHCI MAC
  - interrupts : interrupt used by the host controller
diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt 
b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
index 545251e..722a029 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
@@ -48,7 +48,7 @@ Optional properties:
 Sub-nodes:
 The xhci should be added as subnode to mtu3 as shown in the following example
 if host mode is enabled. The DT binding details of xhci can be found in:
-Documentation/devicetree/bindings/usb/mt8173-xhci.txt
+Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
 
 Example:
 ssusb: usb@11271000 {
-- 
1.7.9.5



[PATCH] tools: fix compile error of freq-step.c

2017-08-15 Thread Thomas Richter
The compilation of the file freq-step.c in directory
tools/testing/selftests/timers fails with this error message:

[root@s8360046 timers]# make
gcc -O3 -Wl,-no-as-needed -Wall -DKTEST  -lrt -lpthread -lm  freq-step.c
  -o freq-step
freq-step.c: In function ‘init_test’:
freq-step.c:234:3: error: too few arguments to function ‘ksft_exit_skip’
   ksft_exit_skip();
   ^~
In file included from freq-step.c:26:0:
../kselftest.h:142:19: note: declared here
 static inline int ksft_exit_skip(const char *msg, ...)
   ^~
: recipe for target 'freq-step' failed
make: *** [freq-step] Error 1
[root@s8360046 timers]#

This is the case for Intel and s390x. I have not tested other
platforms.

Which this patch the compilation succeeds:

[root@s8360046 timers]# make
gcc -O3 -Wl,-no-as-needed -Wall -DKTEST  -lrt -lpthread -lm  freq-step.c   -o 
freq-step
[root@s8360046 timers]# ./freq-step
CLOCK_MONOTONIC_RAW+CLOCK_MONOTONIC precision: 348 ns   [SKIP]
1..0 # Skipped: [SKIP]
[root@s8360046 timers]#

Signed-off-by: Thomas Richter 
---
 tools/testing/selftests/timers/freq-step.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/timers/freq-step.c 
b/tools/testing/selftests/timers/freq-step.c
index e8c6183..bda9744 100644
--- a/tools/testing/selftests/timers/freq-step.c
+++ b/tools/testing/selftests/timers/freq-step.c
@@ -231,7 +231,7 @@ static void init_test(void)
 
if (precision > MAX_PRECISION) {
printf("[SKIP]\n");
-   ksft_exit_skip();
+   ksft_exit_skip("[SKIP]\n");
}
 
printf("[OK]\n");
-- 
2.9.3



[PATCH v2 2/4] usb: xhci-mtk: add generic compatible string

2017-08-15 Thread Chunfeng Yun
The xhci-mtk driver is a generic driver for MediaTek xHCI IP, add
a generic compatible to avoid confusion when support new SoCs but
use a compatible with specific SoC's name "mt8173".

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mtk.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 67d5dc7..8fb6065 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -795,6 +795,7 @@ static int __maybe_unused xhci_mtk_resume(struct device 
*dev)
 #ifdef CONFIG_OF
 static const struct of_device_id mtk_xhci_of_match[] = {
{ .compatible = "mediatek,mt8173-xhci"},
+   { .compatible = "mediatek,mtk-xhci"},
{ },
 };
 MODULE_DEVICE_TABLE(of, mtk_xhci_of_match);
-- 
1.7.9.5



Re: [PATCH v5 3/3] drm/rockchip: Add support for Rockchip Soc LVDS

2017-08-15 Thread Sandy Huang



在 2017/8/15 17:08, Wadim Egorov 写道:



Am 15.08.2017 um 05:49 schrieb Sandy Huang:

This adds support for Rockchip soc lvds found on rk3288
Based on the patches from Mark yao and Heiko Stuebner

Signed-off-by: Sandy Huang 
Signed-off-by: Mark Yao 
Signed-off-by: Heiko Stuebner 
---
  drivers/gpu/drm/rockchip/Kconfig|   9 +
  drivers/gpu/drm/rockchip/Makefile   |   1 +
  drivers/gpu/drm/rockchip/rockchip_drm_drv.c |   2 +
  drivers/gpu/drm/rockchip/rockchip_drm_drv.h |   1 +
  drivers/gpu/drm/rockchip/rockchip_lvds.c| 599 
  drivers/gpu/drm/rockchip/rockchip_lvds.h| 109 +
  6 files changed, 721 insertions(+)
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.c
  create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.h


I have tested this with an ETM0700G0DH6 7.0" LCD panel on the
phyCORE-RK3288.

Tested-by: Wadim Egorov 




Hi Wadim Egorov,
Thanks for your test.



[PATCH v2 3/4] dt-bindings: mt8173-mtu3: add generic compatible and rename file

2017-08-15 Thread Chunfeng Yun
The mt8173-mtu3.txt actually holds the bindings for all mediatek
SoCs with usb3 DRD IP, so add a generic compatible and change the
name to mediatek,mtu3.txt.

Signed-off-by: Chunfeng Yun 
---
 .../usb/{mt8173-mtu3.txt => mediatek,mtu3.txt} |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)
 rename Documentation/devicetree/bindings/usb/{mt8173-mtu3.txt => 
mediatek,mtu3.txt} (92%)

diff --git a/Documentation/devicetree/bindings/usb/mt8173-mtu3.txt 
b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
similarity index 92%
rename from Documentation/devicetree/bindings/usb/mt8173-mtu3.txt
rename to Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
index 1d7c3bc..545251e 100644
--- a/Documentation/devicetree/bindings/usb/mt8173-mtu3.txt
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
@@ -1,7 +1,11 @@
 The device node for Mediatek USB3.0 DRD controller
 
 Required properties:
- - compatible : should be "mediatek,mt8173-mtu3"
+ - compatible : should be "mediatek,soc-model-mtu3", "mediatek,mtu3",
+   soc-model is the name of SoC, such as mt8173, mt2712 etc,
+   when using "mediatek,mtu3" compatible string, you need SoC specific
+   ones in addition, one of:
+   - "mediatek,mt8173-mtu3"
  - reg : specifies physical base address and size of the registers
  - reg-names: should be "mac" for device IP and "ippc" for IP port control
  - interrupts : interrupt used by the device IP
-- 
1.7.9.5



[PATCH v2] pinctrl: qcom: General Purpose clocks for apq8064

2017-08-15 Thread Vinay Simha BN
Add support for general purpose (GP) clocks
for apq8064

DT binding documentation updated for
qcom,apq8064-pinctrl general purpose (GP) clocks.

Acked-by: Bjorn Andersson 
Signed-off-by: Vinay Simha BN 

---
v1:
* only gp_clk_1b tested in nexus7 anx7808 slimport.

v2:
* bjorn review comments incorporated
  added gp clock functions
  merged documentation and driver to single patch
---
---
 .../bindings/pinctrl/qcom,apq8064-pinctrl.txt  |  3 +-
 drivers/pinctrl/qcom/pinctrl-apq8064.c | 42 ++
 2 files changed, 38 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/pinctrl/qcom,apq8064-pinctrl.txt 
b/Documentation/devicetree/bindings/pinctrl/qcom,apq8064-pinctrl.txt
index a7bde64..a752a47 100644
--- a/Documentation/devicetree/bindings/pinctrl/qcom,apq8064-pinctrl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/qcom,apq8064-pinctrl.txt
@@ -46,7 +46,8 @@ Valid values for pins are:
   gpio0-gpio89
 
 Valid values for function are:
-  cam_mclk, codec_mic_i2s, codec_spkr_i2s, gpio, gsbi1, gsbi2, gsbi3, gsbi4,
+  cam_mclk, codec_mic_i2s, codec_spkr_i2s, gp_clk_0a, gp_clk_0b, gp_clk_1a,
+  gp_clk_1b, gp_clk_2a, gp_clk_2b, gpio, gsbi1, gsbi2, gsbi3, gsbi4,
   gsbi4_cam_i2c, gsbi5, gsbi5_spi_cs1, gsbi5_spi_cs2, gsbi5_spi_cs3, gsbi6,
   gsbi6_spi_cs1, gsbi6_spi_cs2, gsbi6_spi_cs3, gsbi7, gsbi7_spi_cs1,
   gsbi7_spi_cs2, gsbi7_spi_cs3, gsbi_cam_i2c, hdmi, mi2s, riva_bt, riva_fm,
diff --git a/drivers/pinctrl/qcom/pinctrl-apq8064.c 
b/drivers/pinctrl/qcom/pinctrl-apq8064.c
index cd96699..bcf9e61 100644
--- a/drivers/pinctrl/qcom/pinctrl-apq8064.c
+++ b/drivers/pinctrl/qcom/pinctrl-apq8064.c
@@ -295,6 +295,12 @@ enum apq8064_functions {
APQ_MUX_cam_mclk,
APQ_MUX_codec_mic_i2s,
APQ_MUX_codec_spkr_i2s,
+   APQ_MUX_gp_clk_0a,
+   APQ_MUX_gp_clk_0b,
+   APQ_MUX_gp_clk_1a,
+   APQ_MUX_gp_clk_1b,
+   APQ_MUX_gp_clk_2a,
+   APQ_MUX_gp_clk_2b,
APQ_MUX_gpio,
APQ_MUX_gsbi1,
APQ_MUX_gsbi2,
@@ -354,6 +360,24 @@ static const char * const gpio_groups[] = {
"gpio78", "gpio79", "gpio80", "gpio81", "gpio82", "gpio83", "gpio84",
"gpio85", "gpio86", "gpio87", "gpio88", "gpio89"
 };
+static const char * const gp_clk_0a_groups[] = {
+   "gpio3"
+};
+static const char * const gp_clk_0b_groups[] = {
+   "gpio34"
+};
+static const char * const gp_clk_1a_groups[] = {
+   "gpio4"
+};
+static const char * const gp_clk_1b_groups[] = {
+   "gpio50"
+};
+static const char * const gp_clk_2a_groups[] = {
+   "gpio32"
+};
+static const char * const gp_clk_2b_groups[] = {
+   "gpio25"
+};
 static const char * const ps_hold_groups[] = {
"gpio78"
 };
@@ -452,6 +476,12 @@ static const struct msm_function apq8064_functions[] = {
FUNCTION(cam_mclk),
FUNCTION(codec_mic_i2s),
FUNCTION(codec_spkr_i2s),
+   FUNCTION(gp_clk_0a),
+   FUNCTION(gp_clk_0b),
+   FUNCTION(gp_clk_1a),
+   FUNCTION(gp_clk_1b),
+   FUNCTION(gp_clk_2a),
+   FUNCTION(gp_clk_2b),
FUNCTION(gpio),
FUNCTION(gsbi1),
FUNCTION(gsbi2),
@@ -490,8 +520,8 @@ static const struct msm_pingroup apq8064_groups[] = {
PINGROUP(0, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
PINGROUP(1, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
PINGROUP(2, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-   PINGROUP(3, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-   PINGROUP(4, NA, NA, cam_mclk, NA, NA, NA, NA, NA, NA, NA),
+   PINGROUP(3, NA, gp_clk_0a, NA, NA, NA, NA, NA, NA, NA, NA),
+   PINGROUP(4, NA, NA, cam_mclk, gp_clk_1a, NA, NA, NA, NA, NA, NA),
PINGROUP(5, NA, cam_mclk, NA, NA, NA, NA, NA, NA, NA, NA),
PINGROUP(6, gsbi3, NA, NA, NA, NA, NA, NA, NA, NA, NA),
PINGROUP(7, gsbi3, NA, NA, NA, NA, NA, NA, NA, NA, NA),
@@ -512,16 +542,16 @@ static const struct msm_pingroup apq8064_groups[] = {
PINGROUP(22, gsbi2, NA, NA, NA, NA, NA, NA, NA, NA, NA),
PINGROUP(23, gsbi2, NA, NA, NA, NA, NA, NA, NA, NA, NA),
PINGROUP(24, gsbi2, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-   PINGROUP(25, gsbi2, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+   PINGROUP(25, gsbi2, gp_clk_2b, NA, NA, NA, NA, NA, NA, NA, NA),
PINGROUP(26, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
PINGROUP(27, mi2s, NA, NA, NA, NA, NA, NA, NA, NA, NA),
PINGROUP(28, mi2s, NA, NA, NA, NA, NA, NA, NA, NA, NA),
PINGROUP(29, mi2s, NA, NA, NA, NA, NA, NA, NA, NA, NA),
PINGROUP(30, mi2s, NA, NA, NA, NA, NA, NA, NA, NA, NA),
PINGROUP(31, mi2s, NA, gsbi5_spi_cs2, gsbi6_spi_cs2, gsbi7_spi_cs2, NA, 
NA, NA, NA, NA),
-   PINGROUP(32, mi2s, NA, NA, NA, NA, gsbi5_spi_cs3, gsbi6_spi_cs3, 
gsbi7_spi_cs3, NA, NA),
+   PINGROUP(32, mi2s, gp_clk_2a, NA, NA, NA, gsbi5_spi_cs3, gsbi6_spi_cs3, 
gsbi7_spi_cs3, NA, NA),
PINGROUP(33, mi2s, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-   PINGROUP(34, codec_mic_i2s, 

Re: [PATCH v4 19/20] mtd: nand: qcom: support for IPQ4019 QPIC NAND controller

2017-08-15 Thread Archit Taneja



On 08/11/2017 05:09 PM, Abhishek Sahu wrote:

Add the compatible string for IPQ4019 QPIC NAND controller
version 1.4.0 which uses BAM DMA.



Reviewed-by: Archit Taneja 

Thanks,
Archit



Signed-off-by: Abhishek Sahu 
---
  drivers/mtd/nand/qcom_nandc.c | 10 ++
  1 file changed, 10 insertions(+)

diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
index f2cb696..03e671e 100644
--- a/drivers/mtd/nand/qcom_nandc.c
+++ b/drivers/mtd/nand/qcom_nandc.c
@@ -2857,6 +2857,12 @@ static int qcom_nandc_remove(struct platform_device 
*pdev)
.flash_dev_offset = 0x0,
  };
  
+static const struct qcom_nandc_props ipq4019_nandc_props = {

+   .ecc_modes = (ECC_BCH_4BIT | ECC_BCH_8BIT),
+   .is_bam = true,
+   .flash_dev_offset = 0x0,
+};
+
  /*
   * data will hold a struct pointer containing more differences once we support
   * more controller variants
@@ -2866,6 +2872,10 @@ static int qcom_nandc_remove(struct platform_device 
*pdev)
.compatible = "qcom,ipq806x-nand",
.data = &ipq806x_nandc_props,
},
+   {
+   .compatible = "qcom,ipq4019-nand",
+   .data = &ipq4019_nandc_props,
+   },
{}
  };
  MODULE_DEVICE_TABLE(of, qcom_nandc_of_match);



--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


Re: [PATCH v4 20/20] mtd: nand: qcom: support for IPQ8074 QPIC NAND controller

2017-08-15 Thread Archit Taneja



On 08/11/2017 05:09 PM, Abhishek Sahu wrote:

Add the compatible string for IPQ8074 QPIC NAND controller
version 1.5.0 which uses BAM DMA and its FLASH_DEV_CMD registers
starting offset is 0x7000.


Reviewed-by: Archit Taneja 

Thanks,
Archit



Signed-off-by: Abhishek Sahu 
---
  drivers/mtd/nand/qcom_nandc.c | 10 ++
  1 file changed, 10 insertions(+)

diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
index 03e671e..1484fb4 100644
--- a/drivers/mtd/nand/qcom_nandc.c
+++ b/drivers/mtd/nand/qcom_nandc.c
@@ -2863,6 +2863,12 @@ static int qcom_nandc_remove(struct platform_device 
*pdev)
.flash_dev_offset = 0x0,
  };
  
+static const struct qcom_nandc_props ipq8074_nandc_props = {

+   .ecc_modes = (ECC_BCH_4BIT | ECC_BCH_8BIT),
+   .is_bam = true,
+   .flash_dev_offset = 0x7000,
+};
+
  /*
   * data will hold a struct pointer containing more differences once we support
   * more controller variants
@@ -2876,6 +2882,10 @@ static int qcom_nandc_remove(struct platform_device 
*pdev)
.compatible = "qcom,ipq4019-nand",
.data = &ipq4019_nandc_props,
},
+   {
+   .compatible = "qcom,ipq8074-nand",
+   .data = &ipq8074_nandc_props,
+   },
{}
  };
  MODULE_DEVICE_TABLE(of, qcom_nandc_of_match);



--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


Re: [PATCH v4 15/20] mtd: nand: qcom: support for command descriptor formation

2017-08-15 Thread Archit Taneja



On 08/11/2017 05:09 PM, Abhishek Sahu wrote:

1. Add the function for command descriptor preparation which will
be used only by BAM DMA and it will form the DMA descriptors
containing command elements
2. DMA_PREP_CMD flag should be used for forming command DMA
descriptors




Reviewed-by: Archit Taneja 

Thanks,
Archit


Signed-off-by: Abhishek Sahu 
---
  drivers/mtd/nand/qcom_nandc.c | 108 +++---
  1 file changed, 92 insertions(+), 16 deletions(-)

diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
index d17c466..f2cb696 100644
--- a/drivers/mtd/nand/qcom_nandc.c
+++ b/drivers/mtd/nand/qcom_nandc.c
@@ -194,6 +194,14 @@
  ((size) << READ_LOCATION_SIZE) |\
  ((is_last) << READ_LOCATION_LAST))
  
+/* Returns the NAND register physical address */

+#define nandc_reg_phys(chip, offset) ((chip)->base_phys + (offset))
+
+/* Returns the dma address for reg read buffer */
+#define reg_buf_dma_addr(chip, vaddr) \
+   ((chip)->reg_read_dma + \
+   ((uint8_t *)(vaddr) - (uint8_t *)(chip)->reg_read_buf))
+
  /* Returns the actual register address for NAND_FLASH_DEV_* */
  #define nandc_dev_addr(nandc, reg) ((nandc)->props->flash_dev_offset + (reg))
  
@@ -311,7 +319,8 @@ struct nandc_regs {

   *controller
   * @dev:  parent device
   * @base: MMIO base
- * @base_dma:  physical base address of controller registers
+ * @base_phys: physical base address of controller registers
+ * @base_dma:  dma base address of controller registers
   * @core_clk: controller clock
   * @aon_clk:  another controller clock
   *
@@ -344,6 +353,7 @@ struct qcom_nand_controller {
struct device *dev;
  
  	void __iomem *base;

+   phys_addr_t base_phys;
dma_addr_t base_dma;
  
  	struct clk *core_clk;

@@ -745,6 +755,66 @@ static int prepare_bam_async_desc(struct 
qcom_nand_controller *nandc,
  }
  
  /*

+ * Prepares the command descriptor for BAM DMA which will be used for NAND
+ * register reads and writes. The command descriptor requires the command
+ * to be formed in command element type so this function uses the command
+ * element from bam transaction ce array and fills the same with required
+ * data. A single SGL can contain multiple command elements so
+ * NAND_BAM_NEXT_SGL will be used for starting the separate SGL
+ * after the current command element.
+ */
+static int prep_bam_dma_desc_cmd(struct qcom_nand_controller *nandc, bool read,
+int reg_off, const void *vaddr,
+int size, unsigned int flags)
+{
+   int bam_ce_size;
+   int i, ret;
+   struct bam_cmd_element *bam_ce_buffer;
+   struct bam_transaction *bam_txn = nandc->bam_txn;
+
+   bam_ce_buffer = &bam_txn->bam_ce[bam_txn->bam_ce_pos];
+
+   /* fill the command desc */
+   for (i = 0; i < size; i++) {
+   if (read)
+   bam_prep_ce(&bam_ce_buffer[i],
+   nandc_reg_phys(nandc, reg_off + 4 * i),
+   BAM_READ_COMMAND,
+   reg_buf_dma_addr(nandc,
+(__le32 *)vaddr + i));
+   else
+   bam_prep_ce_le32(&bam_ce_buffer[i],
+nandc_reg_phys(nandc, reg_off + 4 * i),
+BAM_WRITE_COMMAND,
+*((__le32 *)vaddr + i));
+   }
+
+   bam_txn->bam_ce_pos += size;
+
+   /* use the separate sgl after this command */
+   if (flags & NAND_BAM_NEXT_SGL) {
+   bam_ce_buffer = &bam_txn->bam_ce[bam_txn->bam_ce_start];
+   bam_ce_size = (bam_txn->bam_ce_pos -
+   bam_txn->bam_ce_start) *
+   sizeof(struct bam_cmd_element);
+   sg_set_buf(&bam_txn->cmd_sgl[bam_txn->cmd_sgl_pos],
+  bam_ce_buffer, bam_ce_size);
+   bam_txn->cmd_sgl_pos++;
+   bam_txn->bam_ce_start = bam_txn->bam_ce_pos;
+
+   if (flags & NAND_BAM_NWD) {
+   ret = prepare_bam_async_desc(nandc, nandc->cmd_chan,
+DMA_PREP_FENCE |
+DMA_PREP_CMD);
+   if (ret)
+   return ret;
+   }
+   }
+
+   return 0;
+}
+
+/*
   * Prepares the data descriptor for BAM DMA which will be used for NAND
   * data reads and writes.
   */
@@ -861,19 +931,22 @@ static int read_reg_dma(struct qcom_nand_controller 
*nandc, int first,
  {
bool flow_control = false;
void *vaddr;
-   int size

Re: [PATCH v3] Fix missing PCI ID; Necessary for Lenovo Yoga 720-15 Touchpad.

2017-08-15 Thread Andrew Donnellan

Hi Florian,

As Daniel said, good work on figuring out how to get this far!

There's a couple of minor issues with the formatting of this patch.

Firstly, as Lee said in response to the last version, you should change 
the summary line of the commit to indicate the contents of the patch 
more accurately.


Based on what I see in the git log, I'd suggest:

"mfd: intel-lpss: Add missing PCI ID"

The previous commits to this file also mention the type of chipset - I 
*think* this is Sunrise Point, but I don't work for Intel. :)


Don't mention the Lenovo touchpad in the summary - in the main body of 
the commit message is better.


On 13/08/17 06:16, Hoeze wrote:

From: Hoeze 


The name and email here is what's going to appear in the git commit log 
as the author of the commit. Generally, it should be the same as both 
the details in your Signed-off-by line, and the email should be the same 
as the email address you're sending from. If the name/email address in 
the commit is the same as the name/email address you're sending from, 
git send-email will actually skip this line completely.


You should probably try:

$ git config --global user.name "Florian R. Hölzlwimmer"
$ git config --global user.email "git@frhoelzlwimmer.de"
$ git commit --amend --reset-author

This will set your details in your git configuration, and then re-create 
the last commit using the correct authorship details.


If you then re-send it, it should skip this From: line and everything 
should be fine.



Andrew

--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited



Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature

2017-08-15 Thread Boqun Feng
On Wed, Aug 16, 2017 at 02:05:06PM +0900, Byungchul Park wrote:
> On Wed, Aug 16, 2017 at 12:05:31PM +0800, Boqun Feng wrote:
> > > I see...
> > > 
> > > Worker A : acquired of wfc.work -> wait for cpu_hotplug_lock to be 
> > > released
> > > Task   B : acquired of cpu_hotplug_lock -> wait for lock#3 to be released
> > > Task   C : acquired of lock#3 -> wait for completion of barr->done
> > 
> > >From the stack trace below, this barr->done is for flush_work() in
> > lru_add_drain_all_cpuslocked(), i.e. for work "per_cpu(lru_add_drain_work)"
> > 
> > > Worker D : wait for wfc.work to be released -> will complete barr->done
> > 
> > and this barr->done is for work "wfc.work".
> > 
> > So those two barr->done could not be the same instance, IIUC. Therefore
> > the deadlock case is not possible.
> > 
> > The problem here is all barr->done instances are initialized at
> > insert_wq_barrier() and they belongs to the same lock class, to fix
> 
> I'm not sure this caused the lockdep warning but, if they belongs to the
> same class even though they couldn't be the same instance as you said, I
> also think that is another problem and should be fixed.
> 

My point was more like this is a false positive case, which we should
avoid as hard as we can, because this very case doesn't look like a
deadlock to me.

Maybe the pattern above does exist in current kernel, but we need to
guide/adjust lockdep to find the real case showing it's happening.

Regards,
Boqun

> > this, we need to differ barr->done with different lock classes based on
> > the corresponding works.
> > 
> > How about the this(only compilation test):
> > 
> > ->8
> > diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> > index e86733a8b344..d14067942088 100644
> > --- a/kernel/workqueue.c
> > +++ b/kernel/workqueue.c
> > @@ -2431,6 +2431,27 @@ struct wq_barrier {
> > struct task_struct  *task;  /* purely informational */
> >  };
> >  
> > +#ifdef CONFIG_LOCKDEP_COMPLETE
> > +# define INIT_WQ_BARRIER_ONSTACK(barr, func, target)   
> > \
> > +do {   
> > \
> > +   INIT_WORK_ONSTACK(&(barr)->work, func); 
> > \
> > +   __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&(barr)->work));  
> > \
> > +   lockdep_init_map_crosslock((struct lockdep_map *)&(barr)->done.map, 
> > \
> > +  "(complete)" #barr,  
> > \
> > +  (target)->lockdep_map.key, 1);   
> > \
> > +   __init_completion(&barr->done); 
> > \
> > +   barr->task = current;   
> > \
> > +} while (0)
> > +#else
> > +# define INIT_WQ_BARRIER_ONSTACK(barr, func, target)   
> > \
> > +do {   
> > \
> > +   INIT_WORK_ONSTACK(&(barr)->work, func); 
> > \
> > +   __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&(barr)->work));  
> > \
> > +   init_completion(&barr->done);   
> > \
> > +   barr->task = current;   
> > \
> > +} while (0)
> > +#endif
> > +
> >  static void wq_barrier_func(struct work_struct *work)
> >  {
> > struct wq_barrier *barr = container_of(work, struct wq_barrier, work);
> > @@ -2474,10 +2495,7 @@ static void insert_wq_barrier(struct pool_workqueue 
> > *pwq,
> >  * checks and call back into the fixup functions where we
> >  * might deadlock.
> >  */
> > -   INIT_WORK_ONSTACK(&barr->work, wq_barrier_func);
> > -   __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&barr->work));
> > -   init_completion(&barr->done);
> > -   barr->task = current;
> > +   INIT_WQ_BARRIER_ONSTACK(barr, wq_barrier_func, target);
> >  
> > /*
> >  * If @target is currently being executed, schedule the


signature.asc
Description: PGP signature


Re: [virtio-dev] [PATCH v13 0/5] Virtio-balloon Enhancement

2017-08-15 Thread Adam Tao
On Thu, Aug 03, 2017 at 02:38:14PM +0800, Wei Wang wrote:
> This patch series enhances the existing virtio-balloon with the following
> new features:
> 1) fast ballooning: transfer ballooned pages between the guest and host in
> chunks using sgs, instead of one by one; and
> 2) free_page_vq: a new virtqueue to report guest free pages to the host.
> 
Hi wei,
The reason we add the new vq for the migration feature is based on
what(original design based on inflate and deflate vq)?
I am wondering if we add new feature in the future do we still need to add new 
type
of vq?
Do we need to add one command queue for the common purpose(including
different type of requests except the in/deflate ones)?
Thanks
Adam
> The second feature can be used to accelerate live migration of VMs. Here
> are some details:
> 
> Live migration needs to transfer the VM's memory from the source machine
> to the destination round by round. For the 1st round, all the VM's memory
> is transferred. From the 2nd round, only the pieces of memory that were
> written by the guest (after the 1st round) are transferred. One method
> that is popularly used by the hypervisor to track which part of memory is
> written is to write-protect all the guest memory.
> 
> The second feature  enables the optimization of the 1st round memory
> transfer - the hypervisor can skip the transfer of guest free pages in the
> 1st round. It is not concerned that the memory pages are used after they
> are given to the hypervisor as a hint of the free pages, because they will
> be tracked by the hypervisor and transferred in the next round if they are
> used and written.
> 
> Change Log:
> v12->v13:
> 1) mm: use a callback function to handle the the free page blocks from the
> report function. This avoids exposing the zone internal to a kernel module.
> 2) virtio-balloon: send balloon pages or a free page block using a single sg
> each time. This has the benefits of simpler implementation with no new APIs.
> 3) virtio-balloon: the free_page_vq is used to report free pages only (no
> multiple usages interleaving)
> 4) virtio-balloon: Balloon pages and free page blocks are sent via input sgs,
> and the completion signal to the host is sent via an output sg.
> 
> v11->v12:
> 1) xbitmap: use the xbitmap from Matthew Wilcox to record ballooned pages.
> 2) virtio-ring: enable the driver to build up a desc chain using vring desc.
> 3) virtio-ring: Add locking to the existing START_USE() and END_USE() macro
> to lock/unlock the vq when a vq operation starts/ends.
> 4) virtio-ring: add virtqueue_kick_sync() and virtqueue_kick_async()
> 5) virtio-balloon: describe chunks of ballooned pages and free pages blocks
> directly using one or more chains of desc from the vq.
> 
> v10->v11:
> 1) virtio_balloon: use vring_desc to describe a chunk;
> 2) virtio_ring: support to add an indirect desc table to virtqueue;
> 3)  virtio_balloon: use cmdq to report guest memory statistics.
> 
> v9->v10:
> 1) mm: put report_unused_page_block() under CONFIG_VIRTIO_BALLOON;
> 2) virtio-balloon: add virtballoon_validate();
> 3) virtio-balloon: msg format change;
> 4) virtio-balloon: move miscq handling to a task on system_freezable_wq;
> 5) virtio-balloon: code cleanup.
> 
> v8->v9:
> 1) Split the two new features, VIRTIO_BALLOON_F_BALLOON_CHUNKS and
> VIRTIO_BALLOON_F_MISC_VQ, which were mixed together in the previous
> implementation;
> 2) Simpler function to get the free page block.
> 
> v7->v8:
> 1) Use only one chunk format, instead of two.
> 2) re-write the virtio-balloon implementation patch.
> 3) commit changes
> 4) patch re-org
> 
> Matthew Wilcox (1):
>   Introduce xbitmap
> 
> Wei Wang (4):
>   xbitmap: add xb_find_next_bit() and xb_zero()
>   virtio-balloon: VIRTIO_BALLOON_F_SG
>   mm: support reporting free page blocks
>   virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_VQ
> 
>  drivers/virtio/virtio_balloon.c | 302 
> +++-
>  include/linux/mm.h  |   7 +
>  include/linux/mmzone.h  |   5 +
>  include/linux/radix-tree.h  |   2 +
>  include/linux/xbitmap.h |  53 +++
>  include/uapi/linux/virtio_balloon.h |   2 +
>  lib/radix-tree.c| 167 +++-
>  mm/page_alloc.c | 109 +
>  8 files changed, 609 insertions(+), 38 deletions(-)
>  create mode 100644 include/linux/xbitmap.h
> 
> -- 
> 2.7.4
> 
> 
> -
> To unsubscribe, e-mail: virtio-dev-unsubscr...@lists.oasis-open.org
> For additional commands, e-mail: virtio-dev-h...@lists.oasis-open.org


Re: [PATCHv3] perf bpf: Fix endianness problem when loading parameters in prologue

2017-08-15 Thread Thomas-Mich Richter
On 08/15/2017 05:25 PM, Arnaldo Carvalho de Melo wrote:
> Em Tue, Aug 15, 2017 at 11:21:59AM +0200, Thomas Richter escreveu:
> 
> Ok, I'm applying this, the only missing bit was the following line,
> right at the start of the patch message body;
> 
> From: Wang Nan 
> 
> To state that the patch was wrote by Wang, the fact that you
> participated in it with some adjustment is implied by having you sign
> off the patch, ok?
> 
> - Arnaldo


Thanks Arnaldo,

will /hopefully) remember next time.

-- 
Thomas Richter, Dept 3303, IBM LTC Boeblingen Germany
--
Vorsitzende des Aufsichtsrats: Martina Koederitz 
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 
243294



Re: [PATCH v4 14/20] mtd: nand: qcom: add command elements in BAM transaction

2017-08-15 Thread Archit Taneja



On 08/11/2017 05:09 PM, Abhishek Sahu wrote:

All the QPIC register read/write through BAM DMA requires
command descriptor which contains the array of command elements.


Reviewed-by: Archit Taneja 

Thanks,
Archit



Signed-off-by: Abhishek Sahu 
---
  drivers/mtd/nand/qcom_nandc.c | 19 ++-
  1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
index c0c140b..d17c466 100644
--- a/drivers/mtd/nand/qcom_nandc.c
+++ b/drivers/mtd/nand/qcom_nandc.c
@@ -22,6 +22,7 @@
  #include 
  #include 
  #include 
+#include 
  
  /* NANDc reg offsets */

  #define   NAND_FLASH_CMD  0x00
@@ -196,6 +197,7 @@
  /* Returns the actual register address for NAND_FLASH_DEV_* */
  #define nandc_dev_addr(nandc, reg) ((nandc)->props->flash_dev_offset + (reg))
  
+#define QPIC_PER_CW_CMD_ELEMENTS	32

  #define QPIC_PER_CW_CMD_SGL   32
  #define QPIC_PER_CW_DATA_SGL  8
  
@@ -215,8 +217,13 @@

  /*
   * This data type corresponds to the BAM transaction which will be used for 
all
   * NAND transfers.
+ * @bam_ce - the array of BAM command elements
   * @cmd_sgl - sgl for NAND BAM command pipe
   * @data_sgl - sgl for NAND BAM consumer/producer pipe
+ * @bam_ce_pos - the index in bam_ce which is available for next sgl
+ * @bam_ce_start - the index in bam_ce which marks the start position ce
+ *for current sgl. It will be used for size calculation
+ *for current sgl
   * @cmd_sgl_pos - current index in command sgl.
   * @cmd_sgl_start - start index in command sgl.
   * @tx_sgl_pos - current index in data sgl for tx.
@@ -225,8 +232,11 @@
   * @rx_sgl_start - start index in data sgl for rx.
   */
  struct bam_transaction {
+   struct bam_cmd_element *bam_ce;
struct scatterlist *cmd_sgl;
struct scatterlist *data_sgl;
+   u32 bam_ce_pos;
+   u32 bam_ce_start;
u32 cmd_sgl_pos;
u32 cmd_sgl_start;
u32 tx_sgl_pos;
@@ -456,7 +466,8 @@ static void free_bam_transaction(struct 
qcom_nand_controller *nandc)
  
  	bam_txn_size =

sizeof(*bam_txn) + num_cw *
-   ((sizeof(*bam_txn->cmd_sgl) * QPIC_PER_CW_CMD_SGL) +
+   ((sizeof(*bam_txn->bam_ce) * QPIC_PER_CW_CMD_ELEMENTS) +
+   (sizeof(*bam_txn->cmd_sgl) * QPIC_PER_CW_CMD_SGL) +
(sizeof(*bam_txn->data_sgl) * QPIC_PER_CW_DATA_SGL));
  
  	bam_txn_buf = devm_kzalloc(nandc->dev, bam_txn_size, GFP_KERNEL);

@@ -466,6 +477,10 @@ static void free_bam_transaction(struct 
qcom_nand_controller *nandc)
bam_txn = bam_txn_buf;
bam_txn_buf += sizeof(*bam_txn);
  
+	bam_txn->bam_ce = bam_txn_buf;

+   bam_txn_buf +=
+   sizeof(*bam_txn->bam_ce) * QPIC_PER_CW_CMD_ELEMENTS * num_cw;
+
bam_txn->cmd_sgl = bam_txn_buf;
bam_txn_buf +=
sizeof(*bam_txn->cmd_sgl) * QPIC_PER_CW_CMD_SGL * num_cw;
@@ -483,6 +498,8 @@ static void clear_bam_transaction(struct 
qcom_nand_controller *nandc)
if (!nandc->props->is_bam)
return;
  
+	bam_txn->bam_ce_pos = 0;

+   bam_txn->bam_ce_start = 0;
bam_txn->cmd_sgl_pos = 0;
bam_txn->cmd_sgl_start = 0;
bam_txn->tx_sgl_pos = 0;



--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


Re: [PATCH v4 13/20] mtd: nand: qcom: support for different DEV_CMD register offsets

2017-08-15 Thread Archit Taneja



On 08/11/2017 05:09 PM, Abhishek Sahu wrote:

The FLASH_DEV_CMD registers starting offset is not same in
different QPIC NAND controller versions. This patch adds
the starting offset in NAND controller properties and uses
the same for calculating the actual offset of these registers.

Signed-off-by: Abhishek Sahu 
---
  drivers/mtd/nand/qcom_nandc.c | 22 --
  1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
index 85fbe00..c0c140b 100644
--- a/drivers/mtd/nand/qcom_nandc.c
+++ b/drivers/mtd/nand/qcom_nandc.c
@@ -193,6 +193,9 @@
  ((size) << READ_LOCATION_SIZE) |\
  ((is_last) << READ_LOCATION_LAST))
  
+/* Returns the actual register address for NAND_FLASH_DEV_* */


There aren't any registers starting with NAND_FLASH_DEV_* in the registers
defined above, it might get confusing for someone who doesn't have access
to the HW docs. Could you explicitly mention in this comment all the register
names that are required to go through this translation, it should make things
more readable. With that:

Reviewed-by: Archit Taneja 

Thanks,
Archit



+#define nandc_dev_addr(nandc, reg) ((nandc)->props->flash_dev_offset + (reg))
+
  #define QPIC_PER_CW_CMD_SGL   32
  #define QPIC_PER_CW_DATA_SGL  8
  
@@ -426,10 +429,12 @@ struct qcom_nand_host {

   * among different NAND controllers.
   * @ecc_modes - ecc mode for NAND
   * @is_bam - whether NAND controller is using BAM
+ * @flash_dev_offset - NAND_FLASH_DEV_* registers start offset
   */
  struct qcom_nandc_props {
u32 ecc_modes;
bool is_bam;
+   u32 flash_dev_offset;
  };
  
  /* Frees the BAM transaction memory */

@@ -844,6 +849,9 @@ static int read_reg_dma(struct qcom_nand_controller *nandc, 
int first,
if (first == NAND_READ_ID || first == NAND_FLASH_STATUS)
flow_control = true;
  
+	if (first == NAND_DEV_CMD_VLD || first == NAND_DEV_CMD1)

+   first = nandc_dev_addr(nandc, first);
+
size = num_regs * sizeof(u32);
vaddr = nandc->reg_read_buf + nandc->reg_read_pos;
nandc->reg_read_pos += num_regs;
@@ -881,11 +889,11 @@ static int write_reg_dma(struct qcom_nand_controller 
*nandc, int first,
if (first == NAND_EXEC_CMD)
flags |= NAND_BAM_NWD;
  
-	if (first == NAND_DEV_CMD1_RESTORE)

-   first = NAND_DEV_CMD1;
+   if (first == NAND_DEV_CMD1_RESTORE || first == NAND_DEV_CMD1)
+   first = nandc_dev_addr(nandc, NAND_DEV_CMD1);
  
-	if (first == NAND_DEV_CMD_VLD_RESTORE)

-   first = NAND_DEV_CMD_VLD;
+   if (first == NAND_DEV_CMD_VLD_RESTORE || first == NAND_DEV_CMD_VLD)
+   first = nandc_dev_addr(nandc, NAND_DEV_CMD_VLD);
  
  	size = num_regs * sizeof(u32);
  
@@ -2492,7 +2500,8 @@ static int qcom_nandc_setup(struct qcom_nand_controller *nandc)
  
  	/* kill onenand */

nandc_write(nandc, SFLASHC_BURST_CFG, 0);
-   nandc_write(nandc, NAND_DEV_CMD_VLD, NAND_DEV_CMD_VLD_VAL);
+   nandc_write(nandc, nandc_dev_addr(nandc, NAND_DEV_CMD_VLD),
+   NAND_DEV_CMD_VLD_VAL);
  
  	/* enable ADM or BAM DMA */

if (nandc->props->is_bam) {
@@ -2503,7 +2512,7 @@ static int qcom_nandc_setup(struct qcom_nand_controller 
*nandc)
}
  
  	/* save the original values of these registers */

-   nandc->cmd1 = nandc_read(nandc, NAND_DEV_CMD1);
+   nandc->cmd1 = nandc_read(nandc, nandc_dev_addr(nandc, NAND_DEV_CMD1));
nandc->vld = NAND_DEV_CMD_VLD_VAL;
  
  	return 0;

@@ -2752,6 +2761,7 @@ static int qcom_nandc_remove(struct platform_device *pdev)
  static const struct qcom_nandc_props ipq806x_nandc_props = {
.ecc_modes = (ECC_RS_4BIT | ECC_BCH_8BIT),
.is_bam = false,
+   .flash_dev_offset = 0x0,
  };
  
  /*




--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


linux-next: Tree for Aug 16

2017-08-15 Thread Stephen Rothwell
Hi all,

There will be no linux-next releases this coming Friday or Monday.

Changes since 20170815:

The pci tree gained a conflict against the net tree.

The net-next tree still had its build failure for which I reverted
a commit.

The akpm-current tree gained a build failure due to an interaction with
the drm-intel tree for which I applied a merge fix patch.

Non-merge commits (relative to Linus' tree): 6210
 6210 files changed, 241398 insertions(+), 119623 deletions(-)



I have created today's linux-next tree at
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
(patches at http://www.kernel.org/pub/linux/kernel/next/ ).  If you
are tracking the linux-next tree using git, you should not use "git pull"
to do so as that will try to merge the new linux-next release with the
old one.  You should use "git fetch" and checkout or reset to the new
master.

You can see which trees have been included by looking in the Next/Trees
file in the source.  There are also quilt-import.log and merge.log
files in the Next directory.  Between each merge, the tree was built
with a ppc64_defconfig for powerpc and an allmodconfig (with
CONFIG_BUILD_DOCSRC=n) for x86_64, a multi_v7_defconfig for arm and a
native build of tools/perf. After the final fixups (if any), I do an
x86_64 modules_install followed by builds for x86_64 allnoconfig,
powerpc allnoconfig (32 and 64 bit), ppc44x_defconfig, allyesconfig
and pseries_le_defconfig and i386, sparc and sparc64 defconfig. And
finally, a simple boot test of the powerpc pseries_le_defconfig kernel
in qemu.

Below is a summary of the state of the merge.

I am currently merging 268 trees (counting Linus' and 41 trees of bug
fix patches pending for the current merge release).

Stats about the size of the tree over time can be seen at
http://neuling.org/linux-next-size.html .

Status of my local build tests will be at
http://kisskb.ellerman.id.au/linux-next .  If maintainers want to give
advice about cross compilers/configs that work, we are always open to add
more builds.

Thanks to Randy Dunlap for doing many randconfig builds.  And to Paul
Gortmaker for triage and bug fixes.

-- 
Cheers,
Stephen Rothwell

$ git checkout master
$ git reset --hard stable
Merging origin/master (40c6d1b9e2fc Merge tag 'linux-kselftest-4.13-rc6-fixes' 
of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest)
Merging fixes/master (b4b8cbf679c4 Cavium CNN55XX: fix broken default Kconfig 
entry)
Merging kbuild-current/fixes (4e433fc4d1a9 fixdep: trivial: typo fix and 
correction)
Merging arc-current/for-curr (a8ec3ee861b6 arc: Mask individual IRQ lines 
during core INTC init)
Merging arm-current/fixes (1abd35023763 ARM: align .data section)
Merging m68k-current/for-linus (204a2be30a7a m68k: Remove ptrace_signal_deliver)
Merging metag-fixes/fixes (b884a190afce metag/usercopy: Add missing fixups)
Merging powerpc-fixes/fixes (96ea91e7b6ee powerpc/watchdog: add locking around 
init/exit functions)
Merging sparc/master (9157259d16a8 mm: add pmd_t initializer __pmd() to work 
around a GCC bug.)
Merging fscrypt-current/for-stable (42d97eb0ade3 fscrypt: fix renaming and 
linking special files)
Merging net/master (0a6f04184d3d Merge tag 
'wireless-drivers-for-davem-2017-08-15' of 
git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers)
Merging ipsec/master (4ff0308f06da esp: Fix error handling on layer 2 xmit.)
Merging netfilter/master (9beceb54fa2c netfilter: x_tables: Fix use-after-free 
in ipt_do_table.)
Merging ipvs/master (f7fb77fc1235 netfilter: nft_compat: check extension hook 
mask only if set)
Merging wireless-drivers/master (e9bf53ab1ee3 brcmfmac: feature check for 
multi-scheduled scan fails on bcm4343x devices)
Merging mac80211/master (d7f13f745036 cfg80211: Validate frequencies nested in 
NL80211_ATTR_SCAN_FREQUENCIES)
Merging sound-current/for-linus (a8e800fe0f68 ALSA: usb-audio: Apply sample 
rate quirk to Sennheiser headset)
Merging pci-current/for-linus (8466489ef5ba xhci: Reset Renesas uPD72020x USB 
controller for 32-bit DMA issue)
Merging driver-core.current/driver-core-linus (ef954844c7ac Linux 4.13-rc5)
Merging tty.current/tty-linus (ef954844c7ac Linux 4.13-rc5)
Merging usb.current/usb-linus (ef954844c7ac Linux 4.13-rc5)
Merging usb-gadget-fixes/fixes (b7d44c36a6f6 usb: renesas_usbhs: gadget: fix 
unused-but-set-variable warning)
Merging usb-serial-fixes/usb-linus (fd1b8668af59 USB: serial: option: add 
D-Link DWM-222 device ID)
Merging usb-chipidea-fixes/ci-for-usb-stable (cbb22ebcfb99 usb: chipidea: core: 
check before accessing ci_role in ci_role_show)
Merging phy/fixes (5771a8c08880 Linux v4.13-rc1)
Merging staging.current/staging-linus (ef954844c7ac Linux 4.13-rc5)
Merging char-misc.current/char-misc-linus (ef954844c7ac Linux 4.13-rc5)
Merging input-current/for-linus (76988690402d Input: elan_i2c - Add antoher 
Lenovo

[PATCH] Input: i8042: constify pnp_device_id

2017-08-15 Thread Arvind Yadav
pnp_device_id are not supposed to change at runtime. All functions
working with pnp_device_id provided by  work with
const pnp_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/input/serio/i8042-x86ia64io.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/input/serio/i8042-x86ia64io.h 
b/drivers/input/serio/i8042-x86ia64io.h
index f932a83..ae81e57 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -927,7 +927,7 @@ static int i8042_pnp_aux_probe(struct pnp_dev *dev, const 
struct pnp_device_id *
return 0;
 }
 
-static struct pnp_device_id pnp_kbd_devids[] = {
+static const struct pnp_device_id pnp_kbd_devids[] = {
{ .id = "PNP0300", .driver_data = 0 },
{ .id = "PNP0301", .driver_data = 0 },
{ .id = "PNP0302", .driver_data = 0 },
@@ -957,7 +957,7 @@ static struct pnp_driver i8042_pnp_kbd_driver = {
},
 };
 
-static struct pnp_device_id pnp_aux_devids[] = {
+static const struct pnp_device_id pnp_aux_devids[] = {
{ .id = "AUI0200", .driver_data = 0 },
{ .id = "FJC6000", .driver_data = 0 },
{ .id = "FJC6001", .driver_data = 0 },
-- 
2.7.4



Re: [PATCH v4 12/20] mtd: nand: qcom: QPIC data descriptors handling

2017-08-15 Thread Archit Taneja



On 08/11/2017 05:09 PM, Abhishek Sahu wrote:

1. Add the data descriptor preparation function which will be used
only by BAM DMA for forming the data SGL’s
2. Add clear BAM transaction and call it before every new request
3. Check DMA mode for ADM or BAM and call the appropriate
descriptor formation function.


Reviewed-by: Archit Taneja 

Thanks,
Archit



Signed-off-by: Abhishek Sahu 
---
  drivers/mtd/nand/qcom_nandc.c | 76 +++
  1 file changed, 76 insertions(+)

diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
index ae873d3..85fbe00 100644
--- a/drivers/mtd/nand/qcom_nandc.c
+++ b/drivers/mtd/nand/qcom_nandc.c
@@ -470,6 +470,27 @@ static void free_bam_transaction(struct 
qcom_nand_controller *nandc)
return bam_txn;
  }
  
+/* Clears the BAM transaction indexes */

+static void clear_bam_transaction(struct qcom_nand_controller *nandc)
+{
+   struct bam_transaction *bam_txn = nandc->bam_txn;
+
+   if (!nandc->props->is_bam)
+   return;
+
+   bam_txn->cmd_sgl_pos = 0;
+   bam_txn->cmd_sgl_start = 0;
+   bam_txn->tx_sgl_pos = 0;
+   bam_txn->tx_sgl_start = 0;
+   bam_txn->rx_sgl_pos = 0;
+   bam_txn->rx_sgl_start = 0;
+
+   sg_init_table(bam_txn->cmd_sgl, nandc->max_cwperpage *
+ QPIC_PER_CW_CMD_SGL);
+   sg_init_table(bam_txn->data_sgl, nandc->max_cwperpage *
+ QPIC_PER_CW_DATA_SGL);
+}
+
  static inline struct qcom_nand_host *to_qcom_nand_host(struct nand_chip *chip)
  {
return container_of(chip, struct qcom_nand_host, chip);
@@ -701,6 +722,41 @@ static int prepare_bam_async_desc(struct 
qcom_nand_controller *nandc,
return 0;
  }
  
+/*

+ * Prepares the data descriptor for BAM DMA which will be used for NAND
+ * data reads and writes.
+ */
+static int prep_bam_dma_desc_data(struct qcom_nand_controller *nandc, bool 
read,
+ const void *vaddr,
+ int size, unsigned int flags)
+{
+   int ret;
+   struct bam_transaction *bam_txn = nandc->bam_txn;
+
+   if (read) {
+   sg_set_buf(&bam_txn->data_sgl[bam_txn->rx_sgl_pos],
+  vaddr, size);
+   bam_txn->rx_sgl_pos++;
+   } else {
+   sg_set_buf(&bam_txn->data_sgl[bam_txn->tx_sgl_pos],
+  vaddr, size);
+   bam_txn->tx_sgl_pos++;
+
+   /*
+* BAM will only set EOT for DMA_PREP_INTERRUPT so if this flag
+* is not set, form the DMA descriptor
+*/
+   if (!(flags & NAND_BAM_NO_EOT)) {
+   ret = prepare_bam_async_desc(nandc, nandc->tx_chan,
+DMA_PREP_INTERRUPT);
+   if (ret)
+   return ret;
+   }
+   }
+
+   return 0;
+}
+
  static int prep_adm_dma_desc(struct qcom_nand_controller *nandc, bool read,
 int reg_off, const void *vaddr, int size,
 bool flow_control)
@@ -848,6 +904,9 @@ static int write_reg_dma(struct qcom_nand_controller 
*nandc, int first,
  static int read_data_dma(struct qcom_nand_controller *nandc, int reg_off,
 const u8 *vaddr, int size, unsigned int flags)
  {
+   if (nandc->props->is_bam)
+   return prep_bam_dma_desc_data(nandc, true, vaddr, size, flags);
+
return prep_adm_dma_desc(nandc, true, reg_off, vaddr, size, false);
  }
  
@@ -862,6 +921,9 @@ static int read_data_dma(struct qcom_nand_controller *nandc, int reg_off,

  static int write_data_dma(struct qcom_nand_controller *nandc, int reg_off,
  const u8 *vaddr, int size, unsigned int flags)
  {
+   if (nandc->props->is_bam)
+   return prep_bam_dma_desc_data(nandc, false, vaddr, size, flags);
+
return prep_adm_dma_desc(nandc, false, reg_off, vaddr, size, false);
  }
  
@@ -1149,6 +1211,10 @@ static void pre_command(struct qcom_nand_host *host, int command)

host->last_command = command;
  
  	clear_read_regs(nandc);

+
+   if (command == NAND_CMD_RESET || command == NAND_CMD_READID ||
+   command == NAND_CMD_PARAM || command == NAND_CMD_ERASE1)
+   clear_bam_transaction(nandc);
  }
  
  /*

@@ -1553,6 +1619,7 @@ static int qcom_nandc_read_page(struct mtd_info *mtd, 
struct nand_chip *chip,
data_buf = buf;
oob_buf = oob_required ? chip->oob_poi : NULL;
  
+	clear_bam_transaction(nandc);

ret = read_page_ecc(host, data_buf, oob_buf);
if (ret) {
dev_err(nandc->dev, "failure to read page\n");
@@ -1578,6 +1645,8 @@ static int qcom_nandc_read_page_raw(struct mtd_info *mtd,
oob_buf = chip->oob_poi;
  
  	host->use_ecc = false;

+
+   clear_bam_transaction(nandc);
update_rw_regs(host, e

[PATCH] sg: protect against races between mmap() and SG_SET_RESERVED_SIZE

2017-08-15 Thread Todd Poynor
Take f_mutex around mmap() processing to protect against races with
the SG_SET_RESERVED_SIZE ioctl.  Ensure the reserve buffer length
remains consistent during the mapping operation, and set the
"mmap called" flag to prevent further changes to the reserved buffer
size as an atomic operation with the mapping.

Signed-off-by: Todd Poynor 
---
 drivers/scsi/sg.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 3a44b4bc872b..a20718e9f1f4 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1233,6 +1233,7 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma)
unsigned long req_sz, len, sa;
Sg_scatter_hold *rsv_schp;
int k, length;
+int ret = 0;
 
if ((!filp) || (!vma) || (!(sfp = (Sg_fd *) filp->private_data)))
return -ENXIO;
@@ -1243,8 +1244,11 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma)
if (vma->vm_pgoff)
return -EINVAL; /* want no offset */
rsv_schp = &sfp->reserve;
-   if (req_sz > rsv_schp->bufflen)
-   return -ENOMEM; /* cannot map more than reserved buffer */
+   mutex_lock(&sfp->f_mutex);
+   if (req_sz > rsv_schp->bufflen) {
+   ret = -ENOMEM;  /* cannot map more than reserved buffer */
+   goto out;
+   }
 
sa = vma->vm_start;
length = 1 << (PAGE_SHIFT + rsv_schp->page_order);
@@ -1258,7 +1262,9 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma)
vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP;
vma->vm_private_data = sfp;
vma->vm_ops = &sg_mmap_vm_ops;
-   return 0;
+out:
+   mutex_unlock(&sfp->f_mutex);
+   return ret;
 }
 
 static void
-- 
2.14.1.480.gb18f417b89-goog



Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature

2017-08-15 Thread Boqun Feng
On Wed, Aug 16, 2017 at 01:37:46PM +0900, Byungchul Park wrote:
> On Wed, Aug 16, 2017 at 12:05:31PM +0800, Boqun Feng wrote:
> > On Wed, Aug 16, 2017 at 09:16:37AM +0900, Byungchul Park wrote:
> > > On Tue, Aug 15, 2017 at 10:20:20AM +0200, Ingo Molnar wrote:
> > > > 
> > > > So with the latest fixes there's a new lockdep warning on one of my 
> > > > testboxes:
> > > > 
> > > > [   11.322487] EXT4-fs (sda2): mounted filesystem with ordered data 
> > > > mode. Opts: (null)
> > > > 
> > > > [   11.495661] ==
> > > > [   11.502093] WARNING: possible circular locking dependency detected
> > > > [   11.508507] 4.13.0-rc5-00497-g73135c58-dirty #1 Not tainted
> > > > [   11.514313] --
> > > > [   11.520725] umount/533 is trying to acquire lock:
> > > > [   11.525657]  ((complete)&barr->done){+.+.}, at: [] 
> > > > flush_work+0x213/0x2f0
> > > > [   11.534411] 
> > > >but task is already holding lock:
> > > > [   11.540661]  (lock#3){+.+.}, at: [] 
> > > > lru_add_drain_all_cpuslocked+0x3d/0x190
> > > > [   11.549613] 
> > > >which lock already depends on the new lock.
> > > > 
> > > > The full splat is below. The kernel config is nothing fancy - distro 
> > > > derived, 
> > > > pretty close to defconfig, with lockdep enabled.
> > > 
> > > I see...
> > > 
> > > Worker A : acquired of wfc.work -> wait for cpu_hotplug_lock to be 
> > > released
> > > Task   B : acquired of cpu_hotplug_lock -> wait for lock#3 to be released
> > > Task   C : acquired of lock#3 -> wait for completion of barr->done
> > 
> > >From the stack trace below, this barr->done is for flush_work() in
> > lru_add_drain_all_cpuslocked(), i.e. for work "per_cpu(lru_add_drain_work)"
> > 
> > > Worker D : wait for wfc.work to be released -> will complete barr->done
> > 
> > and this barr->done is for work "wfc.work".
> 
> I think it can be the same instance. wait_for_completion() in flush_work()
> e.g. at task C in my example, waits for completion which we expect to be
> done by a worker e.g. worker D in my example.
> 
> I think the problem is caused by a write-acquisition of wfc.work in
> process_one_work(). The acquisition of wfc.work should be reenterable,
> that is, read-acquisition, shouldn't it?
> 

The only thing is that wfc.work is not a real and please see code in
flush_work(). And if a task C do a flush_work() for "wfc.work" with
lock#3 held, it needs to "acquire" wfc.work before it
wait_for_completion(), which is already a deadlock case:

lock#3 -> wfc.work -> cpu_hotplug_lock -+
  ^ |
  | |
  +-+

, without crossrelease enabled. So the task C didn't flush work wfc.work
in the previous case, which implies barr->done in Task C and Worker D
are not the same instance.

Make sense?

Regards,
Boqun

> I might be wrong... Please fix me if so.
> 
> Thank you,
> Byungchul
> 
> > So those two barr->done could not be the same instance, IIUC. Therefore
> > the deadlock case is not possible.
> > 
> > The problem here is all barr->done instances are initialized at
> > insert_wq_barrier() and they belongs to the same lock class, to fix
> > this, we need to differ barr->done with different lock classes based on
> > the corresponding works.
> > 
> > How about the this(only compilation test):
> > 
> > ->8
> > diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> > index e86733a8b344..d14067942088 100644
> > --- a/kernel/workqueue.c
> > +++ b/kernel/workqueue.c
> > @@ -2431,6 +2431,27 @@ struct wq_barrier {
> > struct task_struct  *task;  /* purely informational */
> >  };
> >  
> > +#ifdef CONFIG_LOCKDEP_COMPLETE
> > +# define INIT_WQ_BARRIER_ONSTACK(barr, func, target)   
> > \
> > +do {   
> > \
> > +   INIT_WORK_ONSTACK(&(barr)->work, func); 
> > \
> > +   __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&(barr)->work));  
> > \
> > +   lockdep_init_map_crosslock((struct lockdep_map *)&(barr)->done.map, 
> > \
> > +  "(complete)" #barr,  
> > \
> > +  (target)->lockdep_map.key, 1);   
> > \
> > +   __init_completion(&barr->done); 
> > \
> > +   barr->task = current;   
> > \
> > +} while (0)
> > +#else
> > +# define INIT_WQ_BARRIER_ONSTACK(barr, func, target)   
> > \
> > +do {   
> > \
> > +   INIT_WORK_ONSTACK(&(barr)->work, func); 
> > \
> > +   __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&(barr

[PATCH 1/2] cpufreq: dt-platdev: Automatically create cpufreq device with OPP v2

2017-08-15 Thread Viresh Kumar
The initial idea of creating the cpufreq-dt-platdev.c file was to keep a
list of platforms that use the "operating-points" (V1) bindings and
create cpufreq device for them only, as we weren't sure which platforms
would want the device to get created automatically as some had their own
cpufreq drivers as well, or wanted to initialize cpufreq after doing
some stuff from platform code.

But that wasn't the case with platforms using "operating-points-v2"
property. We wanted the device to get created automatically without the
need of adding them to the whitelist. Though, we will still have some
exceptions where we don't want to create the device automatically.

Rename the earlier platform list as *whitelist* and create a new
*blacklist* as well.

The cpufreq-dt device will get created if:
- The platform is there in the whitelist OR
- The platform has "operating-points-v2" property in CPU0's DT node and
  isn't part of the blacklist .

Reported-by: Geert Uytterhoeven 
Signed-off-by: Viresh Kumar 
---
 drivers/cpufreq/cpufreq-dt-platdev.c | 45 
 1 file changed, 40 insertions(+), 5 deletions(-)

diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c 
b/drivers/cpufreq/cpufreq-dt-platdev.c
index bcee384b3251..061b468512a2 100644
--- a/drivers/cpufreq/cpufreq-dt-platdev.c
+++ b/drivers/cpufreq/cpufreq-dt-platdev.c
@@ -9,11 +9,16 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include "cpufreq-dt.h"
 
-static const struct of_device_id machines[] __initconst = {
+/*
+ * Machines for which the cpufreq device is *always* created, mostly used for
+ * platforms using "operating-points" (V1) property.
+ */
+static const struct of_device_id whitelist[] __initconst = {
{ .compatible = "allwinner,sun4i-a10", },
{ .compatible = "allwinner,sun5i-a10s", },
{ .compatible = "allwinner,sun5i-a13", },
@@ -101,21 +106,51 @@ static const struct of_device_id machines[] __initconst = 
{
{ }
 };
 
+/*
+ * Machines for which the cpufreq device is *not* created, mostly used for
+ * platforms using "operating-points-v2" property.
+ */
+static const struct of_device_id blacklist[] __initconst = {
+   { }
+};
+
+static bool __init cpu0_node_has_opp_v2_prop(void)
+{
+   struct device_node *np = of_cpu_device_node_get(0);
+   bool ret = false;
+
+   if (of_get_property(np, "operating-points-v2", NULL))
+   ret = true;
+
+   of_node_put(np);
+   return ret;
+}
+
 static int __init cpufreq_dt_platdev_init(void)
 {
struct device_node *np = of_find_node_by_path("/");
const struct of_device_id *match;
+   const void *data = NULL;
 
if (!np)
return -ENODEV;
 
-   match = of_match_node(machines, np);
+   match = of_match_node(whitelist, np);
+   if (match) {
+   data = match->data;
+   goto create_pdev;
+   }
+
+   if (cpu0_node_has_opp_v2_prop() && !of_match_node(blacklist, np))
+   goto create_pdev;
+
of_node_put(np);
-   if (!match)
-   return -ENODEV;
+   return -ENODEV;
 
+create_pdev:
+   of_node_put(np);
return PTR_ERR_OR_ZERO(platform_device_register_data(NULL, "cpufreq-dt",
-  -1, match->data,
+  -1, data,
   sizeof(struct cpufreq_dt_platform_data)));
 }
 device_initcall(cpufreq_dt_platdev_init);
-- 
2.7.4



[PATCH 2/2] cpufreq: dt-platdev: Drop few entries from whitelist

2017-08-15 Thread Viresh Kumar
Drop few ARM (32 and 64 bit) platforms from the whitelist which always
use "operating-points-v2" property from their DT. They should continue
to work after this patch.

Tested on Hikey platform (only the "hisilicon,hi6220" entry).

Signed-off-by: Viresh Kumar 
---
 drivers/cpufreq/cpufreq-dt-platdev.c | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c 
b/drivers/cpufreq/cpufreq-dt-platdev.c
index 061b468512a2..45f2ec3b7f7a 100644
--- a/drivers/cpufreq/cpufreq-dt-platdev.c
+++ b/drivers/cpufreq/cpufreq-dt-platdev.c
@@ -27,7 +27,6 @@ static const struct of_device_id whitelist[] __initconst = {
{ .compatible = "allwinner,sun6i-a31s", },
{ .compatible = "allwinner,sun7i-a20", },
{ .compatible = "allwinner,sun8i-a23", },
-   { .compatible = "allwinner,sun8i-a33", },
{ .compatible = "allwinner,sun8i-a83t", },
{ .compatible = "allwinner,sun8i-h3", },
 
@@ -37,7 +36,6 @@ static const struct of_device_id whitelist[] __initconst = {
{ .compatible = "arm,integrator-cp", },
 
{ .compatible = "hisilicon,hi3660", },
-   { .compatible = "hisilicon,hi6220", },
 
{ .compatible = "fsl,imx27", },
{ .compatible = "fsl,imx51", },
@@ -51,11 +49,8 @@ static const struct of_device_id whitelist[] __initconst = {
{ .compatible = "samsung,exynos3250", },
{ .compatible = "samsung,exynos4210", },
{ .compatible = "samsung,exynos4212", },
-   { .compatible = "samsung,exynos4412", },
{ .compatible = "samsung,exynos5250", },
 #ifndef CONFIG_BL_SWITCHER
-   { .compatible = "samsung,exynos5420", },
-   { .compatible = "samsung,exynos5433", },
{ .compatible = "samsung,exynos5800", },
 #endif
 
@@ -87,11 +82,7 @@ static const struct of_device_id whitelist[] __initconst = {
{ .compatible = "rockchip,rk3368", },
{ .compatible = "rockchip,rk3399", },
 
-   { .compatible = "socionext,uniphier-pro5", },
-   { .compatible = "socionext,uniphier-pxs2", },
{ .compatible = "socionext,uniphier-ld6b", },
-   { .compatible = "socionext,uniphier-ld11", },
-   { .compatible = "socionext,uniphier-ld20", },
 
{ .compatible = "ti,omap2", },
{ .compatible = "ti,omap3", },
@@ -101,8 +92,6 @@ static const struct of_device_id whitelist[] __initconst = {
{ .compatible = "xlnx,zynq-7000", },
{ .compatible = "xlnx,zynqmp", },
 
-   { .compatible = "zte,zx296718", },
-
{ }
 };
 
-- 
2.7.4



Re: [PATCH] scsi: cxlflash: Fix an error handling path in 'cxlflash_disk_attach()'

2017-08-15 Thread Andrew Donnellan

On 16/08/17 06:18, Christophe JAILLET wrote:

'rc' is known to be 0 at this point.
If 'create_context()' fails, returns -ENOMEM instead of 0 which means
success.

Signed-off-by: Christophe JAILLET 


ENOMEM seems right here.

Reviewed-by: Andrew Donnellan 


---
  drivers/scsi/cxlflash/superpipe.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/cxlflash/superpipe.c 
b/drivers/scsi/cxlflash/superpipe.c
index ad0f9968ccfb..08da593cb2f6 100644
--- a/drivers/scsi/cxlflash/superpipe.c
+++ b/drivers/scsi/cxlflash/superpipe.c
@@ -1390,6 +1390,7 @@ static int cxlflash_disk_attach(struct scsi_device *sdev,
if (unlikely(!ctxi)) {
dev_err(dev, "%s: Failed to create context ctxid=%d\n",
__func__, ctxid);
+   rc = -ENOMEM;
goto err;
}
  



--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited



[PATCH] sata: ahci-da850: Fix some error handling paths in 'ahci_da850_probe()'

2017-08-15 Thread Christophe JAILLET
'rc' is known to be 0 at this point.
If 'platform_get_resource()' or 'devm_ioremap()' fail, return -ENOMEM
instead of 0 which means success.

Signed-off-by: Christophe JAILLET 
---
 drivers/ata/ahci_da850.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/ahci_da850.c b/drivers/ata/ahci_da850.c
index 1a50cd3b4233..eb46cad4d514 100644
--- a/drivers/ata/ahci_da850.c
+++ b/drivers/ata/ahci_da850.c
@@ -216,12 +216,16 @@ static int ahci_da850_probe(struct platform_device *pdev)
return rc;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-   if (!res)
+   if (!res) {
+   rc = -ENOMEM;
goto disable_resources;
+   }
 
pwrdn_reg = devm_ioremap(dev, res->start, resource_size(res));
-   if (!pwrdn_reg)
+   if (!pwrdn_reg) {
+   rc = -ENOMEM;
goto disable_resources;
+   }
 
da850_sata_init(dev, pwrdn_reg, hpriv->mmio, mpy);
 
-- 
2.11.0



[PATCH] [media] radio: constify pnp_device_id

2017-08-15 Thread Arvind Yadav
pnp_device_id are not supposed to change at runtime. All functions
working with pnp_device_id provided by  work with
const pnp_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/media/radio/radio-cadet.c| 2 +-
 drivers/media/radio/radio-gemtek.c   | 2 +-
 drivers/media/radio/radio-sf16fmr2.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/radio/radio-cadet.c 
b/drivers/media/radio/radio-cadet.c
index cbaf850..6888b7d 100644
--- a/drivers/media/radio/radio-cadet.c
+++ b/drivers/media/radio/radio-cadet.c
@@ -528,7 +528,7 @@ static const struct v4l2_ctrl_ops cadet_ctrl_ops = {
 
 #ifdef CONFIG_PNP
 
-static struct pnp_device_id cadet_pnp_devices[] = {
+static const struct pnp_device_id cadet_pnp_devices[] = {
/* ADS Cadet AM/FM Radio Card */
{.id = "MSM0c24", .driver_data = 0},
{.id = ""}
diff --git a/drivers/media/radio/radio-gemtek.c 
b/drivers/media/radio/radio-gemtek.c
index ca051ccb..ddc12b1 100644
--- a/drivers/media/radio/radio-gemtek.c
+++ b/drivers/media/radio/radio-gemtek.c
@@ -281,7 +281,7 @@ static const struct radio_isa_ops gemtek_ops = {
 static const int gemtek_ioports[] = { 0x20c, 0x30c, 0x24c, 0x34c, 0x248, 0x28c 
};
 
 #ifdef CONFIG_PNP
-static struct pnp_device_id gemtek_pnp_devices[] = {
+static const struct pnp_device_id gemtek_pnp_devices[] = {
/* AOpen FX-3D/Pro Radio */
{.id = "ADS7183", .driver_data = 0},
{.id = ""}
diff --git a/drivers/media/radio/radio-sf16fmr2.c 
b/drivers/media/radio/radio-sf16fmr2.c
index dc81d42..de79d55 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -197,7 +197,7 @@ static int fmr2_tea_ext_init(struct snd_tea575x *tea)
return 0;
 }
 
-static struct pnp_device_id fmr2_pnp_ids[] = {
+static const struct pnp_device_id fmr2_pnp_ids[] = {
{ .id = "MFRad13" }, /* tuner subdevice of SF16-FMD2 */
{ .id = "" }
 };
-- 
2.7.4



[PATCH v2 4/4] staging: pi433: Remove camel case variable names

2017-08-15 Thread Rishabh Hardas
Remove Camel casing by renaming variables.

Signed-off-by: Rishabh Hardas 
---
 drivers/staging/pi433/pi433_if.c | 4 ++--
 drivers/staging/pi433/pi433_if.h | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index ed737f4..11c042b 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -192,7 +192,7 @@ struct pi433_instance {
SET_CHECKED(rf69_set_modulation (dev->spi, rx_cfg->modulation));
SET_CHECKED(rf69_set_antenna_impedance   (dev->spi, 
rx_cfg->antenna_impedance));
SET_CHECKED(rf69_set_rssi_threshold  (dev->spi, 
rx_cfg->rssi_threshold));
-   SET_CHECKED(rf69_set_ook_threshold_dec   (dev->spi, 
rx_cfg->thresholdDecrement));
+   SET_CHECKED(rf69_set_ook_threshold_dec   (dev->spi, 
rx_cfg->threshold_decrement));
SET_CHECKED(rf69_set_bandwidth   (dev->spi, 
rx_cfg->bw_mantisse, rx_cfg->bw_exponent));
SET_CHECKED(rf69_set_bandwidth_during_afc(dev->spi, 
rx_cfg->bw_mantisse, rx_cfg->bw_exponent));
SET_CHECKED(rf69_set_dagc(dev->spi, rx_cfg->dagc));
@@ -254,7 +254,7 @@ struct pi433_instance {
SET_CHECKED(rf69_set_modulation (dev->spi, tx_cfg->modulation));
SET_CHECKED(rf69_set_deviation  (dev->spi, tx_cfg->dev_frequency));
SET_CHECKED(rf69_set_pa_ramp(dev->spi, tx_cfg->pa_ramp));
-   SET_CHECKED(rf69_set_modulation_shaping(dev->spi, tx_cfg->modShaping));
+   SET_CHECKED(rf69_set_modulation_shaping(dev->spi, tx_cfg->mod_shaping));
SET_CHECKED(rf69_set_tx_start_condition(dev->spi, 
tx_cfg->tx_start_condition));

/* packet format enable */
diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h
index 2929de0..7f57e7d 100644
--- a/drivers/staging/pi433/pi433_if.h
+++ b/drivers/staging/pi433/pi433_if.h
@@ -62,7 +62,7 @@ struct pi433_tx_cfg {
__u16   bit_rate;
__u32   dev_frequency;
enum modulation modulation;
-   enum mod_shapingmodShaping;
+   enum mod_shapingmod_shaping;

enum pa_ramppa_ramp;

@@ -114,8 +114,8 @@ struct pi433_rx_cfg {

__u8rssi_threshold;

-   enum threshold_decrementthresholdDecrement;
-   enum antenna_impedance  antenna_impedance;
+   enum threshold_decrementthreshold_decrement;
+   enum antenna_impedance  antenna_impedance;
enum lna_gain   lna_gain;
enum mantisse   bw_mantisse;/* normal: 0x50 */
__u8bw_exponent;/* during AFC: 0x8b */
--
1.9.1



[PATCH v2 3/4] staging: pi433: Renaming Enums

2017-08-15 Thread Rishabh Hardas
Remove camel casing by renaming enums.

Signed-off-by: Rishabh Hardas 
---
 drivers/staging/pi433/pi433_if.h  | 36 
 drivers/staging/pi433/rf69.c  | 26 +-
 drivers/staging/pi433/rf69.h  | 26 +-
 drivers/staging/pi433/rf69_enum.h | 16 
 4 files changed, 50 insertions(+), 54 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h
index 84032f3..2929de0 100644
--- a/drivers/staging/pi433/pi433_if.h
+++ b/drivers/staging/pi433/pi433_if.h
@@ -62,21 +62,20 @@ struct pi433_tx_cfg {
__u16   bit_rate;
__u32   dev_frequency;
enum modulation modulation;
-   enum modShaping modShaping;
+   enum mod_shapingmodShaping;

-   enum paRamp pa_ramp;
+   enum pa_ramppa_ramp;

-   enum txStartCondition   tx_start_condition;
+   enum tx_start_condition tx_start_condition;

__u16   repetitions;

-
/* packet format */
-   enum optionOnOffenable_preamble;
-   enum optionOnOffenable_sync;
-   enum optionOnOffenable_length_byte;
-   enum optionOnOffenable_address_byte;
-   enum optionOnOffenable_crc;
+   enum option_on_off  enable_preamble;
+   enum option_on_off  enable_sync;
+   enum option_on_off  enable_length_byte;
+   enum option_on_off  enable_address_byte;
+   enum option_on_off  enable_crc;

__u16   preamble_length;
__u8sync_length;
@@ -86,7 +85,6 @@ struct pi433_tx_cfg {
__u8address_byte;
 };

-
 /**
  * struct pi433_rx_config - describes the configuration of the radio module for
  * sending
@@ -115,25 +113,24 @@ struct pi433_rx_cfg {
enum modulation modulation;

__u8rssi_threshold;
-   enum thresholdDecrement thresholdDecrement;
-   enum antennaImpedance   antenna_impedance;
-   enum lnaGainlna_gain;
+
+   enum threshold_decrementthresholdDecrement;
+   enum antenna_impedance  antenna_impedance;
+   enum lna_gain   lna_gain;
enum mantisse   bw_mantisse;/* normal: 0x50 */
__u8bw_exponent;/* during AFC: 0x8b */
enum dagc   dagc;

-
-
/* packet format */
-   enum optionOnOffenable_sync;
-   enum optionOnOffenable_length_byte;   /* should be used in
+   enum option_on_off  enable_sync;
+   enum option_on_off  enable_length_byte;   /* should be used in
   * combination with
   * sync, only
   */
-   enum addressFiltering   enable_address_filtering; /* operational
+   enum address_filtering  enable_address_filtering; /* operational
   * with sync, only
   */
-   enum optionOnOffenable_crc;   /* only operational,
+   enum option_on_off  enable_crc;   /* only operational,
   *if sync on and fixed
   * length or length
   * byte is used
@@ -148,7 +145,6 @@ struct pi433_rx_cfg {
__u8broadcast_address;
 };

-
 #define PI433_IOC_MAGIC'r'

 #define PI433_IOC_RD_TX_CFG_IOR(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR,\
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index f83523e..b7b8c7c 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -109,7 +109,7 @@ enum modulation rf69_get_modulation(struct spi_device *spi)
}
 }

-int rf69_set_modulation_shaping(struct spi_device *spi, enum modShaping 
modShaping)
+int rf69_set_modulation_shaping(struct spi_device *spi, enum mod_shaping 
modShaping)
 {
#ifdef DEBUG
dev_dbg(&spi->dev, "set: mod shaping");
@@ -264,7 +264,7 @@ int rf69_set_frequency(struct spi_device *spi, u32 
frequency)
return 0;
 }

-int rf69_set_amplifier_0(struct spi_device *spi, enum optionOnOff optionOnOff)
+int rf69_set_amplifier_0(struct spi_device *spi, enum option_on_off 
optionOnOff)
 {
#ifdef DEBUG
dev_dbg(&spi->dev, "set: amp #0");
@@ -277,7 +277,7 @@ int rf69_set_amplifier_0(struct spi_device *spi, enum 
optionOnOff optionOnOff)
}
 }

-int rf69_set_amplifier_1(struct spi_device *spi, enum optionOnOff optionOnOff)
+int rf69_set_amplifier_1(struct spi

[PATCH v2 2/4] staging: pi433: Change Comments

2017-08-15 Thread Rishabh Hardas
Shorten long comments and format them in kernel style comments.

Signed-off-by: Rishabh Hardas 
---
 drivers/staging/pi433/pi433_if.h | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h
index 91e4a01..84032f3 100644
--- a/drivers/staging/pi433/pi433_if.h
+++ b/drivers/staging/pi433/pi433_if.h
@@ -126,9 +126,18 @@ struct pi433_rx_cfg {

/* packet format */
enum optionOnOffenable_sync;
-   enum optionOnOffenable_length_byte;   /* should be used in 
combination with sync, only */
-   enum addressFiltering   enable_address_filtering; /* operational with 
sync, only */
-   enum optionOnOffenable_crc;   /* only operational, 
if sync on and fixed length or length byte is used */
+   enum optionOnOffenable_length_byte;   /* should be used in
+  * combination with
+  * sync, only
+  */
+   enum addressFiltering   enable_address_filtering; /* operational
+  * with sync, only
+  */
+   enum optionOnOffenable_crc;   /* only operational,
+  *if sync on and fixed
+  * length or length
+  * byte is used
+  */

__u8sync_length;
__u8fixed_message_length;
--
1.9.1



[PATCH v2 1/4] staging: pi433: Style fix - Correct long lines

2017-08-15 Thread Rishabh Hardas
Correct lines above 80 characters in pi433_if.h

Signed-off-by: Rishabh Hardas 
---
 drivers/staging/pi433/pi433_if.h | 28 +++-
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h
index e6ed3cd..91e4a01 100644
--- a/drivers/staging/pi433/pi433_if.h
+++ b/drivers/staging/pi433/pi433_if.h
@@ -33,14 +33,13 @@
 #include "rf69_enum.h"

 /*---*/
-
-
 /*---*/

 /* IOCTL structs and commands */

 /**
- * struct pi433_tx_config - describes the configuration of the radio module 
for sending
+ * struct pi433_tx_config - describes the configuration of the radio module for
+ * sending
  * @frequency:
  * @bit_rate:
  * @modulation:
@@ -57,9 +56,8 @@
  *
  * NOTE: struct layout is the same in 64bit and 32bit userspace.
  */
-#define PI433_TX_CFG_IOCTL_NR  0
-struct pi433_tx_cfg
-{
+#define PI433_TX_CFG_IOCTL_NR  0
+struct pi433_tx_cfg {
__u32   frequency;
__u16   bit_rate;
__u32   dev_frequency;
@@ -90,7 +88,8 @@ struct pi433_tx_cfg


 /**
- * struct pi433_rx_config - describes the configuration of the radio module 
for sending
+ * struct pi433_rx_config - describes the configuration of the radio module for
+ * sending
  * @frequency:
  * @bit_rate:
  * @modulation:
@@ -107,7 +106,7 @@ struct pi433_tx_cfg
  *
  * NOTE: struct layout is the same in 64bit and 32bit userspace.
  */
-#define PI433_RX_CFG_IOCTL_NR  1
+#define PI433_RX_CFG_IOCTL_NR  1
 struct pi433_rx_cfg {
__u32   frequency;
__u16   bit_rate;
@@ -143,10 +142,13 @@ struct pi433_rx_cfg {

 #define PI433_IOC_MAGIC'r'

-#define PI433_IOC_RD_TX_CFG_IOR(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, 
char[sizeof(struct pi433_tx_cfg)])
-#define PI433_IOC_WR_TX_CFG_IOW(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, 
char[sizeof(struct pi433_tx_cfg)])
-
-#define PI433_IOC_RD_RX_CFG_IOR(PI433_IOC_MAGIC, PI433_RX_CFG_IOCTL_NR, 
char[sizeof(struct pi433_rx_cfg)])
-#define PI433_IOC_WR_RX_CFG_IOW(PI433_IOC_MAGIC, PI433_RX_CFG_IOCTL_NR, 
char[sizeof(struct pi433_rx_cfg)])
+#define PI433_IOC_RD_TX_CFG_IOR(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR,\
+char[sizeof(struct pi433_tx_cfg)])
+#define PI433_IOC_WR_TX_CFG_IOW(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR,\
+char[sizeof(struct pi433_tx_cfg)])
+#define PI433_IOC_RD_RX_CFG_IOR(PI433_IOC_MAGIC, PI433_RX_CFG_IOCTL_NR,\
+char[sizeof(struct pi433_rx_cfg)])
+#define PI433_IOC_WR_RX_CFG_IOW(PI433_IOC_MAGIC, PI433_RX_CFG_IOCTL_NR,\
+char[sizeof(struct pi433_rx_cfg)])

 #endif /* PI433_H */
--
1.9.1



[PATCH v2 0/4] staging: pi433: Rename camel case and other style issues

2017-08-15 Thread Rishabh Hardas
Hi,

This series pf patches solves some of the coding style
issues. I have corrected long lines, changed comment style,
renamed enums and variables that were in camel case.

Tried to get zero erros and warnings on the pi433_if.h file.

Regards,
Rishabh Hardas

Rishabh Hardas (4):
  staging: pi433: Style fix - Correct long lines
  staging: pi433: Change Comments
  staging: pi433: Renaming Enums
  staging: pi433: Remove camel case variable names

 drivers/staging/pi433/pi433_if.c  |  4 +--
 drivers/staging/pi433/pi433_if.h  | 73 +--
 drivers/staging/pi433/rf69.c  | 26 +++---
 drivers/staging/pi433/rf69.h  | 26 +++---
 drivers/staging/pi433/rf69_enum.h | 16 -
 5 files changed, 76 insertions(+), 69 deletions(-)

--
1.9.1



Re: [PATCH 2/3] libnvdimm, pfn, dax: show supported dax/pfn region alignments in sysfs

2017-08-15 Thread Oliver
On Wed, Aug 16, 2017 at 1:47 AM, Dan Williams  wrote:
> On Mon, Aug 14, 2017 at 11:46 PM, Oliver  wrote:
>> On Tue, Aug 15, 2017 at 4:02 PM, kbuild test robot  wrote:
> [..]
>>>114  static const unsigned long *nd_pfn_supported_alignments(void)
>>>115  {
>>>116  /*
>>>117   * This needs to be a local variable because the *_SIZE 
>>> macros
>>>118   * aren't always constants.
>>>119   */
>>
>> I probably should have been clearer, "local" here really means
>> "non-static". Otherwise the array could have been made a global.
>>
>
> Whoops, my fault. How about this:
>
> @@ -127,8 +127,11 @@ static const unsigned long
> *nd_pfn_supported_alignments(void)
>  #endif
> 0,
> };
> +   static unsigned long data[ARRAY_SIZE(supported_alignments)];
>
> -   return supported_alignments;
> +   memcpy(data, supported_alignments, sizeof(data));
> +
> +   return data;
>  }

That should do the trick, but you'll need to fix up the source array
declaration too.


[rcu:rcu/dev 14/15] kernel/time/tick-sched.c:820: undefined reference to `__divdi3'

2017-08-15 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git 
rcu/dev
head:   551164572a4a41968abd020ec24499085cc2adf7
commit: 33103e7b1f89ef432dfe3337d2a6932cdf5c1312 [14/15] EXP: Trace tick return 
from tick_nohz_stop_sched_tick
config: mips-nlm_xlr_defconfig (attached as .config)
compiler: mips-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 33103e7b1f89ef432dfe3337d2a6932cdf5c1312
# save the attached .config to linux build tree
make.cross ARCH=mips 

All errors (new ones prefixed by >>):

   kernel/time/tick-sched.o: In function `tick_nohz_stop_sched_tick':
>> kernel/time/tick-sched.c:820: undefined reference to `__divdi3'

vim +820 kernel/time/tick-sched.c

   758  
   759  /* Calculate the next expiry time */
   760  if (delta < (KTIME_MAX - basemono))
   761  expires = basemono + delta;
   762  else
   763  expires = KTIME_MAX;
   764  
   765  expires = min_t(u64, expires, next_tick);
   766  tick = expires;
   767  
   768  /* Skip reprogram of event if its not changed */
   769  if (ts->tick_stopped && (expires == ts->next_tick)) {
   770  /* Sanity check: make sure clockevent is actually 
programmed */
   771  if (tick == KTIME_MAX || ts->next_tick == 
hrtimer_get_expires(&ts->sched_timer))
   772  goto out;
   773  
   774  WARN_ON_ONCE(1);
   775  printk_once("basemono: %llu ts->next_tick: %llu 
dev->next_event: %llu timer->active: %d timer->expires: %llu\n",
   776  basemono, ts->next_tick, dev->next_event,
   777  hrtimer_active(&ts->sched_timer), 
hrtimer_get_expires(&ts->sched_timer));
   778  }
   779  
   780  /*
   781   * nohz_stop_sched_tick can be called several times before
   782   * the nohz_restart_sched_tick is called. This happens when
   783   * interrupts arrive which do not cause a reschedule. In the
   784   * first call we save the current tick time, so we can restart
   785   * the scheduler tick in nohz_restart_sched_tick.
   786   */
   787  if (!ts->tick_stopped) {
   788  calc_load_nohz_start();
   789  cpu_load_update_nohz_start();
   790  
   791  ts->last_tick = hrtimer_get_expires(&ts->sched_timer);
   792  ts->tick_stopped = 1;
   793  trace_tick_stop(1, TICK_DEP_MASK_NONE);
   794  }
   795  
   796  ts->next_tick = tick;
   797  
   798  /*
   799   * If the expiration time == KTIME_MAX, then we simply stop
   800   * the tick timer.
   801   */
   802  if (unlikely(expires == KTIME_MAX)) {
   803  if (ts->nohz_mode == NOHZ_MODE_HIGHRES)
   804  hrtimer_cancel(&ts->sched_timer);
   805  goto out;
   806  }
   807  
   808  hrtimer_set_expires(&ts->sched_timer, tick);
   809  
   810  if (ts->nohz_mode == NOHZ_MODE_HIGHRES)
   811  hrtimer_start_expires(&ts->sched_timer, 
HRTIMER_MODE_ABS_PINNED);
   812  else
   813  tick_program_event(tick, 1);
   814  out:
   815  /*
   816   * Update the estimated sleep length until the next timer
   817   * (not only the tick).
   818   */
   819  ts->sleep_length = ktime_sub(dev->next_event, now);
 > 820  trace_printk("tick_nohz_stop_sched_tick: %lld\n", (tick - 
 > ktime_get()) / 1000);
   821  return tick;
   822  }
   823  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


[PATCH] crypto: cavium/nitrox - Fix an error handling path in 'nitrox_probe()'

2017-08-15 Thread Christophe JAILLET
'err' is known to be 0 at this point.
If 'kzalloc()' fails, returns -ENOMEM instead of 0 which means success.

Signed-off-by: Christophe JAILLET 
---
 drivers/crypto/cavium/nitrox/nitrox_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/cavium/nitrox/nitrox_main.c 
b/drivers/crypto/cavium/nitrox/nitrox_main.c
index 9ccefb9b7232..fee7cb2ce747 100644
--- a/drivers/crypto/cavium/nitrox/nitrox_main.c
+++ b/drivers/crypto/cavium/nitrox/nitrox_main.c
@@ -513,8 +513,10 @@ static int nitrox_probe(struct pci_dev *pdev,
pci_set_master(pdev);
 
ndev = kzalloc(sizeof(*ndev), GFP_KERNEL);
-   if (!ndev)
+   if (!ndev) {
+   err = -ENOMEM;
goto ndev_fail;
+   }
 
pci_set_drvdata(pdev, ndev);
ndev->pdev = pdev;
-- 
2.11.0



[PATCH] bpf: Update sysctl documentation to list all supported architectures

2017-08-15 Thread Michael Ellerman
The sysctl documentation states that the JIT is only available on
x86_64, which is no longer correct.

Update the list to include all architectures that enable HAVE_CBPF_JIT
or HAVE_EBPF_JIT under some configuration.

Signed-off-by: Michael Ellerman 
---
 Documentation/sysctl/net.txt | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Documentation/sysctl/net.txt b/Documentation/sysctl/net.txt
index 14db18c970b1..f68356024d09 100644
--- a/Documentation/sysctl/net.txt
+++ b/Documentation/sysctl/net.txt
@@ -36,8 +36,9 @@ bpf_jit_enable
 --
 
 This enables Berkeley Packet Filter Just in Time compiler.
-Currently supported on x86_64 architecture, bpf_jit provides a framework
-to speed packet filtering, the one used by tcpdump/libpcap for example.
+Currently supported on arm, arm64, mips, powerpc, s390, sparc and x86_64
+architectures, bpf_jit provides a framework to speed packet filtering, the one
+used by tcpdump/libpcap for example.
 Values :
0 - disable the JIT (default value)
1 - enable the JIT
-- 
2.7.4



RE: [PATCH v2 19/22] fpga: intel: afu: add header sub feature support

2017-08-15 Thread Wu, Hao
>  On Sun, Jun 25, 2017 at 8:52 PM, Wu Hao  wrote:
> 
> Hi Hao,
> 
> > The header register set is always present for the Port/AFU, it is mainly
> > for capability, control and status of the ports that AFU connected to.
> 
> So just to be clear, the reset function is acting on the Port, not the
> AFU, right?

Hi Alan

AFU will be reset as well. Once port reset is issued, a compliant HW
AFU will reset all its state and stop sending requests, and HW will set
port reset ack bit when all outstanding requests initiated have been
drained.

Will add some notes here.

> 
> >
> > This patch implements header sub feature support.
> 
> Please add a brief reminder here what the 'header' is.  It's defined
> in patch 7 as being part of the feature list, but hardly mentioned
> when I grep intel-fpga.txt.

Sure, will adds some notes here.

Actually the header sub feature means the registers belong to the
feature device (e.g port and FME), not any sub features (e.g PR, 
Power management).

> 
> > Below user interfaces
> > are created by this patch.
> >
> > Sysfs interface:
> > * /sys/class/fpga///id
> >   Read-only. Port ID.
> >
> > Ioctl interface:
> > * FPGA_PORT_RESET
> >   Reset the FPGA AFU Port.
> >
> > Signed-off-by: Tim Whisonant 
> > Signed-off-by: Enno Luebbers 
> > Signed-off-by: Shiva Rao 
> > Signed-off-by: Christopher Rauer 
> > Signed-off-by: Xiao Guangrong 
> > Signed-off-by: Wu Hao 
> > ---
> > v2: add sysfs documentation.
> > ---
> >  .../ABI/testing/sysfs-platform-intel-fpga-afu  |  7 
> >  drivers/fpga/intel-afu-main.c  | 44 
> > +-
> >  include/uapi/linux/intel-fpga.h| 14 +++
> >  3 files changed, 64 insertions(+), 1 deletion(-)
> >  create mode 100644 Documentation/ABI/testing/sysfs-platform-intel-fpga-
> afu
> >
> > diff --git a/Documentation/ABI/testing/sysfs-platform-intel-fpga-afu
> b/Documentation/ABI/testing/sysfs-platform-intel-fpga-afu
> > new file mode 100644
> > index 000..8ad22c9
> > --- /dev/null
> > +++ b/Documentation/ABI/testing/sysfs-platform-intel-fpga-afu
> > @@ -0,0 +1,7 @@
> > +What:  /sys/bus/platform/devices/intel-fpga-port.0/id
> > +Date:  June 2017
> > +KernelVersion:  4.12
> > +Contact:   Wu Hao 
> > +Description:   Read-only. It returns id of this port. One Intel FPGA device
> > +   may have more than one port. Userspace could use this id to
> > +   distinguish different ports under same FPGA device.
> > diff --git a/drivers/fpga/intel-afu-main.c b/drivers/fpga/intel-afu-main.c
> > index 96d0367..2a17cde 100644
> > --- a/drivers/fpga/intel-afu-main.c
> > +++ b/drivers/fpga/intel-afu-main.c
> > @@ -18,25 +18,66 @@
> >
> >  #include 
> >  #include 
> > +#include 
> >
> >  #include "intel-feature-dev.h"
> >
> > +static ssize_t
> > +id_show(struct device *dev, struct device_attribute *attr, char *buf)
> > +{
> > +   int id = fpga_port_id(to_platform_device(dev));
> > +
> > +   return scnprintf(buf, PAGE_SIZE, "%d\n", id);
> > +}
> > +static DEVICE_ATTR_RO(id);
> > +
> > +static const struct attribute *port_hdr_attrs[] = {
> > +   &dev_attr_id.attr,
> > +   NULL,
> > +};
> > +
> >  static int port_hdr_init(struct platform_device *pdev, struct feature 
> > *feature)
> >  {
> > dev_dbg(&pdev->dev, "PORT HDR Init.\n");
> >
> > -   return 0;
> > +   fpga_port_reset(pdev);
> 
> So the port will be reset here, which happens during fme_probe().
> IIUC the PR region is empty then, there is just the static region,
> right?

port_hdr_init is invoked during afu_probe() function. The fpga_port_reset
only resets the AFU's state and not empty the PR region. User doesn't need
to program it again after port reset.

The purpose of this reset in port_hdr_init function, is to make sure that we 
could have a clean start whenever the port driver module is loaded. And
similar as the one added in afu release.

> 
> > +
> > +   return sysfs_create_files(&pdev->dev.kobj, port_hdr_attrs);
> 
> Greg wrote an article that there could be a race condition caused by
> creating sysfs files this late [1] and I see sysfs_create_files() used
> very sparingly in the kernel.  I'm thinking that fpga-bridge should
> provide a place to create sysfs files earlier by adding an
> attribute_group to fpga_bridge_ops (same for fpga-mgr and fpga-region)
> and then fpga_bridge_register could do bridge->dev.groups =
> br_ops->groups.  I'll put a patch for that out soon.
> 

Hm... I understand there could be a race condition if creates sysfs files late.
Actually the reasons I prefer to have each sub feature to create its own sysfs
files are, 1) if any sub feature is not present, then related init function 
won't 
be invoked and related sysfs files won't be created at all. Then end user could
know which sub features are present by checking these sysfs nodes easily. 
2) Another point of view is about extension of each sub feature, for example,
Some new registers introduced when s

RE: [PATCH 0/5] cramfs refresh for embedded usage

2017-08-15 Thread Nicolas Pitre
On Tue, 15 Aug 2017, Chris Brandt wrote:

> On Tuesday, August 15, 2017 1, Nicolas Pitre wrote:
> > I was able to reproduce. The following patch on top should partially fix
> > it.  I'm trying to figure out how to split a vma and link it properly in
> > the case the vma cannot be mapped entirely. In the mean time shared libs
> > won't be XIP.
> > 
> > 
> > diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
> > index 5aedbd224e..4c7f01fcd2 100644
> > --- a/fs/cramfs/inode.c
> > +++ b/fs/cramfs/inode.c
> 
> 
> Yes, now I can boot with my rootfs being a XIP cramfs.
> 
> However, like you said, libc is not XIP.

I think I have it working now. Probably learned more about the memory 
management internals than I ever wanted to know. Please try the patch 
below on top of all the previous ones. If it works for you as well then 
I'll rebase and repost the whole thing.

diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index 4c7f01fcd2..0b651f985c 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -321,6 +321,86 @@ static u32 cramfs_get_block_range(struct inode *inode, u32 
pgoff, u32 *pages)
return blockaddr << 2;
 }
 
+/*
+ * It is possible for cramfs_physmem_mmap() to partially populate the mapping
+ * causing page faults in the unmapped area. When that happens, we need to
+ * split the vma so that the unmapped area gets its own vma that can be backed
+ * with actual memory pages and loaded normally. This is necessary because
+ * remap_pfn_range() overwrites vma->vm_pgoff with the pfn and filemap_fault()
+ * no longer works with it. Furthermore this makes /proc/x/maps right.
+ * Q: is there a way to do split vma at mmap() time?
+ */
+static const struct vm_operations_struct cramfs_vmasplit_ops;
+static int cramfs_vmasplit_fault(struct vm_fault *vmf)
+{
+   struct mm_struct *mm = vmf->vma->vm_mm;
+   struct vm_area_struct *vma, *new_vma;
+   unsigned long split_val, split_addr;
+   unsigned int split_pgoff, split_page;
+   int ret;
+
+   /* Retrieve the vma split address and validate it */
+   vma = vmf->vma;
+   split_val = (unsigned long)vma->vm_private_data;
+   split_pgoff = split_val & 0x;
+   split_page = split_val >> 16;
+   split_addr = vma->vm_start + split_page * PAGE_SIZE;
+   pr_debug("fault: addr=%#lx vma=%#lx-%#lx split=%#lx\n",
+vmf->address, vma->vm_start, vma->vm_end, split_addr);
+   if (!split_val || split_addr >= vma->vm_end || vmf->address < 
split_addr)
+   return VM_FAULT_SIGSEGV;
+
+   /* We have some vma surgery to do and need the write lock. */
+   up_read(&mm->mmap_sem);
+   if (down_write_killable(&mm->mmap_sem))
+   return VM_FAULT_RETRY;
+
+   /* Make sure the vma didn't change between the locks */
+   vma = find_vma(mm, vmf->address);
+   if (vma->vm_ops != &cramfs_vmasplit_ops) {
+   /*
+* Someone else raced with us and could have handled the fault.
+* Let it go back to user space and fault again if necessary.
+*/
+   downgrade_write(&mm->mmap_sem);
+   return VM_FAULT_NOPAGE;
+   }
+
+   /* Split the vma between the directly mapped area and the rest */
+   ret = split_vma(mm, vma, split_addr, 0);
+   if (ret) {
+   downgrade_write(&mm->mmap_sem);
+   return VM_FAULT_OOM;
+   }
+
+   /* The direct vma should no longer ever fault */
+   vma->vm_ops = NULL;
+
+   /* Retrieve the new vma covering the unmapped area */
+   new_vma = find_vma(mm, split_addr);
+   BUG_ON(new_vma == vma);
+   if (!new_vma) {
+   downgrade_write(&mm->mmap_sem);
+   return VM_FAULT_SIGSEGV;
+   }
+
+   /*
+* Readjust the new vma with the actual file based pgoff and
+* process the fault normally on it.
+*/
+   new_vma->vm_pgoff = split_pgoff;
+   new_vma->vm_ops = &generic_file_vm_ops;
+   vmf->vma = new_vma;
+   vmf->pgoff = split_pgoff;
+   vmf->pgoff += (vmf->address - new_vma->vm_start) >> PAGE_SHIFT;
+   downgrade_write(&mm->mmap_sem);
+   return filemap_fault(vmf);
+}
+
+static const struct vm_operations_struct cramfs_vmasplit_ops = {
+   .fault  = cramfs_vmasplit_fault,
+};
+
 static int cramfs_physmem_mmap(struct file *file, struct vm_area_struct *vma)
 {
struct inode *inode = file_inode(file);
@@ -337,6 +417,7 @@ static int cramfs_physmem_mmap(struct file *file, struct 
vm_area_struct *vma)
if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE))
return -EINVAL;
 
+   /* Could COW work here? */
fail_reason = "vma is writable";
if (vma->vm_flags & VM_WRITE)
goto fail;
@@ -364,7 +445,7 @@ static int cramfs_physmem_mmap(struct file *file, struct 
vm_area_struct *vma)
unsigned int partial = offset_in_page(inode->i_size);
if (parti

Re: Possible race in c4.ko

2017-08-15 Thread Carsten Paeth
Hello Anton,

Thanks for reviewing the code.

This would be right, if the c4 could rise an interrupt at this moment ...

After a reset with c4_reset(), the card will not generate an interrupt,
until firmware has been loaded and the SEND_INIT message has been sent.
c4_load_firmware() -> c4_send_init() sets the card number in the card.

Therefor it's not an issue.

best regards,

calle

Tue, Aug 15, 2017 at 04:22:16PM +0300, Anton Volkov schrieb:
> Hello.
> 
> While searching for races in the Linux kernel I've come across
> "drivers/isdn/hardware/avm/c4.ko" module. Here is a question that I came up
> with while analyzing results. Lines are given using the info from Linux
> v4.12.
> 
> Consider the following case:
> 
> Thread 1:  Thread 2:
> c4_probe
> ->c4_add_card
> request_irq()
>c4_interrupt
>->c4_handle_interrupt
>  ->c4_handle_rx
> card->cardnr = ... cidx = f(card->cardnr)
> (c4.c: line 1227)  (c4.c: line 526)
>if (cidx >= card->nlogcontr) cidx = 0;
>ctrl = &card->ctrlinfo[cidx].capi_ctrl
> 
> card->cardnr is 0 until it is initialized in c4_add_card(). If at the moment
> of read access in c4_handle_rx() it is still 0, cidx may then be assigned an
> undesirable value and wrong controller may handle messages. Is this case
> feasible from your point of view?
> 
> Thank you for your time.
> 
> -- Anton Volkov
> Linux Verification Center, ISPRAS
> web: http://linuxtesting.org
> e-mail: avol...@ispras.ru


Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature

2017-08-15 Thread Byungchul Park
On Wed, Aug 16, 2017 at 12:05:31PM +0800, Boqun Feng wrote:
> > I see...
> > 
> > Worker A : acquired of wfc.work -> wait for cpu_hotplug_lock to be released
> > Task   B : acquired of cpu_hotplug_lock -> wait for lock#3 to be released
> > Task   C : acquired of lock#3 -> wait for completion of barr->done
> 
> >From the stack trace below, this barr->done is for flush_work() in
> lru_add_drain_all_cpuslocked(), i.e. for work "per_cpu(lru_add_drain_work)"
> 
> > Worker D : wait for wfc.work to be released -> will complete barr->done
> 
> and this barr->done is for work "wfc.work".
> 
> So those two barr->done could not be the same instance, IIUC. Therefore
> the deadlock case is not possible.
> 
> The problem here is all barr->done instances are initialized at
> insert_wq_barrier() and they belongs to the same lock class, to fix

I'm not sure this caused the lockdep warning but, if they belongs to the
same class even though they couldn't be the same instance as you said, I
also think that is another problem and should be fixed.

> this, we need to differ barr->done with different lock classes based on
> the corresponding works.
> 
> How about the this(only compilation test):
> 
> ->8
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index e86733a8b344..d14067942088 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -2431,6 +2431,27 @@ struct wq_barrier {
>   struct task_struct  *task;  /* purely informational */
>  };
>  
> +#ifdef CONFIG_LOCKDEP_COMPLETE
> +# define INIT_WQ_BARRIER_ONSTACK(barr, func, target) 
> \
> +do { 
> \
> + INIT_WORK_ONSTACK(&(barr)->work, func); 
> \
> + __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&(barr)->work));  
> \
> + lockdep_init_map_crosslock((struct lockdep_map *)&(barr)->done.map, 
> \
> +"(complete)" #barr,  
> \
> +(target)->lockdep_map.key, 1);   
> \
> + __init_completion(&barr->done); 
> \
> + barr->task = current;   
> \
> +} while (0)
> +#else
> +# define INIT_WQ_BARRIER_ONSTACK(barr, func, target) 
> \
> +do { 
> \
> + INIT_WORK_ONSTACK(&(barr)->work, func); 
> \
> + __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&(barr)->work));  
> \
> + init_completion(&barr->done);   
> \
> + barr->task = current;   
> \
> +} while (0)
> +#endif
> +
>  static void wq_barrier_func(struct work_struct *work)
>  {
>   struct wq_barrier *barr = container_of(work, struct wq_barrier, work);
> @@ -2474,10 +2495,7 @@ static void insert_wq_barrier(struct pool_workqueue 
> *pwq,
>* checks and call back into the fixup functions where we
>* might deadlock.
>*/
> - INIT_WORK_ONSTACK(&barr->work, wq_barrier_func);
> - __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&barr->work));
> - init_completion(&barr->done);
> - barr->task = current;
> + INIT_WQ_BARRIER_ONSTACK(barr, wq_barrier_func, target);
>  
>   /*
>* If @target is currently being executed, schedule the


[PATCH] EDAC, altera: Fix an error handling path in 'altr_edac_device_probe()'

2017-08-15 Thread Christophe JAILLET
'res' is known to be 0 at this point.
If 'devm_ioremap()' fails, returns -ENOMEM instead of 0 which means
success.

Signed-off-by: Christophe JAILLET 
---
 drivers/edac/altera_edac.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
index fa2e5db56d24..346c4987b284 100644
--- a/drivers/edac/altera_edac.c
+++ b/drivers/edac/altera_edac.c
@@ -747,8 +747,10 @@ static int altr_edac_device_probe(struct platform_device 
*pdev)
drvdata->edac_dev_name = ecc_name;
 
drvdata->base = devm_ioremap(&pdev->dev, r->start, resource_size(r));
-   if (!drvdata->base)
+   if (!drvdata->base) {
+   res = -ENOMEM;
goto fail1;
+   }
 
/* Get driver specific data for this EDAC device */
drvdata->data = of_match_node(altr_edac_device_of_match, np)->data;
-- 
2.11.0



[PATCH] scsi: aha1542: constify pnp_device_id

2017-08-15 Thread Arvind Yadav
pnp_device_id are not supposed to change at runtime. All functions
working with pnp_device_id provided by  work with
const pnp_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/aha1542.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index a23cc9a..1242179 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -986,7 +986,7 @@ static struct isa_driver aha1542_isa_driver = {
 static int isa_registered;
 
 #ifdef CONFIG_PNP
-static struct pnp_device_id aha1542_pnp_ids[] = {
+static const struct pnp_device_id aha1542_pnp_ids[] = {
{ .id = "ADP1542" },
{ .id = "" }
 };
-- 
2.7.4



[PATCH] scsi: ncr5380: constify pnp_device_id

2017-08-15 Thread Arvind Yadav
pnp_device_id are not supposed to change at runtime. All functions
working with pnp_device_id provided by  work with
const pnp_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/scsi/g_NCR5380.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c
index c34fc91..1968d81 100644
--- a/drivers/scsi/g_NCR5380.c
+++ b/drivers/scsi/g_NCR5380.c
@@ -703,7 +703,7 @@ static struct isa_driver generic_NCR5380_isa_driver = {
 };
 
 #ifdef CONFIG_PNP
-static struct pnp_device_id generic_NCR5380_pnp_ids[] = {
+static const struct pnp_device_id generic_NCR5380_pnp_ids[] = {
{ .id = "DTC436e", .driver_data = BOARD_DTC3181E },
{ .id = "" }
 };
-- 
2.7.4



Re: [PATCH v7 9/9] sparc64: Add support for ADI (Application Data Integrity)

2017-08-15 Thread David Miller
From: Khalid Aziz 
Date: Wed,  9 Aug 2017 15:26:02 -0600

> +void adi_restore_tags(struct mm_struct *mm, struct vm_area_struct *vma,
> +   unsigned long addr, pte_t pte)
> +{
 ...
> + tag = tag_start(addr, tag_desc);
> + paddr = pte_val(pte) & _PAGE_PADDR_4V;
> + for (tmp = paddr; tmp < (paddr+PAGE_SIZE); tmp += adi_blksize()) {
> + version1 = (*tag) >> 4;
> + version2 = (*tag) & 0x0f;
> + *tag++ = 0;
> + asm volatile("stxa %0, [%1] %2\n\t"
> + :
> + : "r" (version1), "r" (tmp),
> +   "i" (ASI_MCD_REAL));
> + tmp += adi_blksize();
> + asm volatile("stxa %0, [%1] %2\n\t"
> + :
> + : "r" (version2), "r" (tmp),
> +   "i" (ASI_MCD_REAL));
> + }
> + asm volatile("membar #Sync\n\t");

You do a membar here.

> + for (i = pfrom; i < (pfrom + PAGE_SIZE); i += adi_blksize()) {
> + asm volatile("ldxa [%1] %2, %0\n\t"
> + : "=r" (adi_tag)
> + :  "r" (i), "i" (ASI_MCD_REAL));
> + asm volatile("stxa %0, [%1] %2\n\t"
> + :
> + : "r" (adi_tag), "r" (pto),
> +   "i" (ASI_MCD_REAL));

But not here.

Is this OK?  I suspect you need to add a membar this this second piece
of MCD tag storing code.


[PATCH] EDAC, thunderx: Fix an error handling path in 'thunderx_lmc_probe()'

2017-08-15 Thread Christophe JAILLET
'ret' is known to be 0 at this point.
If 'ioremap()' fails, returns -ENOMEM instead of 0 which means success.

Signed-off-by: Christophe JAILLET 
---
 drivers/edac/thunderx_edac.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/edac/thunderx_edac.c b/drivers/edac/thunderx_edac.c
index c8e8b9fd4772..00b89f057695 100644
--- a/drivers/edac/thunderx_edac.c
+++ b/drivers/edac/thunderx_edac.c
@@ -779,6 +779,7 @@ static int thunderx_lmc_probe(struct pci_dev *pdev,
 
if (!l2c_ioaddr) {
dev_err(&pdev->dev, "Cannot map L2C_CTL\n");
+   ret = -ENOMEM;
goto err_free;
}
 
-- 
2.11.0



[PATCH] watchdog: sc1200: constify pnp_device_id

2017-08-15 Thread Arvind Yadav
pnp_device_id are not supposed to change at runtime. All functions
working with pnp_device_id provided by  work with
const pnp_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/watchdog/sc1200wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/sc1200wdt.c b/drivers/watchdog/sc1200wdt.c
index b34d3d5..8e4e2fc 100644
--- a/drivers/watchdog/sc1200wdt.c
+++ b/drivers/watchdog/sc1200wdt.c
@@ -342,7 +342,7 @@ static int __init sc1200wdt_probe(void)
 
 #if defined CONFIG_PNP
 
-static struct pnp_device_id scl200wdt_pnp_devices[] = {
+static const struct pnp_device_id scl200wdt_pnp_devices[] = {
/* National Semiconductor PC87307/PC97307 watchdog component */
{.id = "NSC0800", .driver_data = 0},
{.id = ""},
-- 
2.7.4



[PATCH] net: 3c509: constify pnp_device_id

2017-08-15 Thread Arvind Yadav
pnp_device_id are not supposed to change at runtime. All functions
working with pnp_device_id provided by  work with
const pnp_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/net/ethernet/3com/3c509.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/3com/3c509.c 
b/drivers/net/ethernet/3com/3c509.c
index f66c971..077d01d 100644
--- a/drivers/net/ethernet/3com/3c509.c
+++ b/drivers/net/ethernet/3com/3c509.c
@@ -392,7 +392,7 @@ static struct isa_driver el3_isa_driver = {
 static int isa_registered;
 
 #ifdef CONFIG_PNP
-static struct pnp_device_id el3_pnp_ids[] = {
+static const struct pnp_device_id el3_pnp_ids[] = {
{ .id = "TCM5090" }, /* 3Com Etherlink III (TP) */
{ .id = "TCM5091" }, /* 3Com Etherlink III */
{ .id = "TCM5094" }, /* 3Com Etherlink III (combo) */
-- 
2.7.4



Re: [PATCH] ASoC: Medfield: Delete an error message for a failed memory allocation in snd_mfld_mc_probe()

2017-08-15 Thread Vinod Koul
On Fri, Aug 11, 2017 at 11:33:56AM +0200, SF Markus Elfring wrote:
> From: Markus Elfring 
> Date: Fri, 11 Aug 2017 11:25:41 +0200
> 
> Omit an extra message for a memory allocation failure in this function.
> 
> This issue was detected by using the Coccinelle software.

Acked-By: Vinod Koul 

> 
> Link: 
> http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
> Signed-off-by: Markus Elfring 
> ---
>  sound/soc/intel/boards/mfld_machine.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/sound/soc/intel/boards/mfld_machine.c 
> b/sound/soc/intel/boards/mfld_machine.c
> index 4e08885f37aa..6f44acfb4aae 100644
> --- a/sound/soc/intel/boards/mfld_machine.c
> +++ b/sound/soc/intel/boards/mfld_machine.c
> @@ -376,10 +376,8 @@ static int snd_mfld_mc_probe(struct platform_device 
> *pdev)
>   /* audio interrupt base of SRAM location where
>* interrupts are stored by System FW */
>   mc_drv_ctx = devm_kzalloc(&pdev->dev, sizeof(*mc_drv_ctx), GFP_ATOMIC);
> - if (!mc_drv_ctx) {
> - pr_err("allocation failed\n");
> + if (!mc_drv_ctx)
>   return -ENOMEM;
> - }
>  
>   irq_mem = platform_get_resource_byname(
>   pdev, IORESOURCE_MEM, "IRQ_BASE");
> -- 
> 2.14.0
> 

-- 
~Vinod


[PATCH] PNP: ide: constify pnp_device_id

2017-08-15 Thread Arvind Yadav
pnp_device_id are not supposed to change at runtime. All functions
working with pnp_device_id provided by  work with
const pnp_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/ide/ide-pnp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ide/ide-pnp.c b/drivers/ide/ide-pnp.c
index f5f2b62..859ddab 100644
--- a/drivers/ide/ide-pnp.c
+++ b/drivers/ide/ide-pnp.c
@@ -22,7 +22,7 @@
 #define DRV_NAME "ide-pnp"
 
 /* Add your devices here :)) */
-static struct pnp_device_id idepnp_devices[] = {
+static const struct pnp_device_id idepnp_devices[] = {
/* Generic ESDI/IDE/ATA compatible hard disk controller */
{.id = "PNP0600", .driver_data = 0},
{.id = ""}
-- 
2.7.4



Re: [PATCH v7 2/9] mm, swap: Add infrastructure for saving page metadata on swap

2017-08-15 Thread David Miller
From: Khalid Aziz 
Date: Wed,  9 Aug 2017 15:25:55 -0600

> @@ -1399,6 +1399,12 @@ static bool try_to_unmap_one(struct page *page, struct 
> vm_area_struct *vma,
>   (flags & TTU_MIGRATION)) {
>   swp_entry_t entry;
>   pte_t swp_pte;
> +
> + if (arch_unmap_one(mm, vma, address, pteval) < 0) {
> + set_pte_at(mm, address, pvmw.pte, pteval);
> + ret = false;
> + page_vma_mapped_walk_done(&pvmw);
> + break;
>   /*
>* Store the pfn of the page in a special migration
>* pte. do_swap_page() will wait until the migration
> @@ -1410,6 +1416,7 @@ static bool try_to_unmap_one(struct page *page, struct 
> vm_area_struct *vma,
>   if (pte_soft_dirty(pteval))
>   swp_pte = pte_swp_mksoft_dirty(swp_pte);
>   set_pte_at(mm, address, pvmw.pte, swp_pte);
> + }

This basic block doesn't look right.  I think the new closing brace is
intended to be right after the new break; statement.  If not at the
very least the indentation of the existing code in there needs to be
adjusted.



[PATCH v2 0/5] K2G: Add QSPI support

2017-08-15 Thread Vignesh R
This series adds support for Cadence QSPI IP present in TI's 66AK2G SoC.
The patches enhance the existing cadence-quadspi driver to support
loopback clock circuit, pm_runtime support and tweaks for 66AK2G SoC.


Changes in v2:
* Drop DT patches. Will be sent as separate series as requested by
 maintainer.
* Split binding docs into separate patches.
* Address comments by Rob Herring.

Vignesh R (5):
  mtd: spi-nor: cadence-quadspi: Add TI 66AK2G SoC specific compatible
  mtd: spi-nor: cadence-quadspi: add a delay in write sequence
  mtd: spi-nor: cadence-quadspi: Add new binding to enable loop-back
circuit
  mtd: spi-nor: cadence-quadspi: Add support to enable loop-back clock
circuit
  mtd: spi-nor: cadence-quadspi: Add runtime PM support

 .../devicetree/bindings/mtd/cadence-quadspi.txt|  7 +++-
 drivers/mtd/spi-nor/cadence-quadspi.c  | 46 --
 2 files changed, 49 insertions(+), 4 deletions(-)

-- 
2.14.1



[PATCH v2 2/5] mtd: spi-nor: cadence-quadspi: add a delay in write sequence

2017-08-15 Thread Vignesh R
As per 66AK2G02 TRM[1] SPRUHY8F section 11.15.5.3 Indirect Access
Controller programming sequence, a delay equal to couple of QSPI master
clock(~5ns) is required after setting CQSPI_REG_INDIRECTWR_START bit and
writing data to the flash. Introduce a quirk flag CQSPI_NEEDS_WR_DELAY
to handle this and set this flag for TI 66AK2G SoC.

[1]http://www.ti.com/lit/ug/spruhy8f/spruhy8f.pdf

Signed-off-by: Vignesh R 
---
v2:
Split binding doc to separate patch
Use data pointer to indicate write delay.

 drivers/mtd/spi-nor/cadence-quadspi.c | 27 ++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c 
b/drivers/mtd/spi-nor/cadence-quadspi.c
index 53c7d8e0327a..bb0cb02a6938 100644
--- a/drivers/mtd/spi-nor/cadence-quadspi.c
+++ b/drivers/mtd/spi-nor/cadence-quadspi.c
@@ -38,6 +38,9 @@
 #define CQSPI_NAME "cadence-qspi"
 #define CQSPI_MAX_CHIPSELECT   16
 
+/* Quirks */
+#define CQSPI_NEEDS_WR_DELAY   BIT(0)
+
 struct cqspi_st;
 
 struct cqspi_flash_pdata {
@@ -76,6 +79,7 @@ struct cqspi_st {
u32 fifo_depth;
u32 fifo_width;
u32 trigger_address;
+   u32 wr_delay;
struct cqspi_flash_pdata f_pdata[CQSPI_MAX_CHIPSELECT];
 };
 
@@ -608,6 +612,15 @@ static int cqspi_indirect_write_execute(struct spi_nor 
*nor,
reinit_completion(&cqspi->transfer_complete);
writel(CQSPI_REG_INDIRECTWR_START_MASK,
   reg_base + CQSPI_REG_INDIRECTWR);
+   /*
+* As per 66AK2G02 TRM SPRUHY8F section 11.15.5.3 Indirect Access
+* Controller programming sequence, couple of cycles of
+* QSPI_REF_CLK delay is required for the above bit to
+* be internally synchronized by the QSPI module. Provide 5
+* cycles of delay.
+*/
+   if (cqspi->wr_delay)
+   ndelay(cqspi->wr_delay);
 
while (remaining > 0) {
write_bytes = remaining > page_size ? page_size : remaining;
@@ -1156,6 +1169,7 @@ static int cqspi_probe(struct platform_device *pdev)
struct cqspi_st *cqspi;
struct resource *res;
struct resource *res_ahb;
+   u32 data;
int ret;
int irq;
 
@@ -1213,6 +1227,10 @@ static int cqspi_probe(struct platform_device *pdev)
}
 
cqspi->master_ref_clk_hz = clk_get_rate(cqspi->clk);
+   data  = (u32)of_device_get_match_data(&pdev->dev);
+   if (data & CQSPI_NEEDS_WR_DELAY)
+   cqspi->wr_delay = 5 * DIV_ROUND_UP(NSEC_PER_SEC,
+  cqspi->master_ref_clk_hz);
 
ret = devm_request_irq(dev, irq, cqspi_irq_handler, 0,
   pdev->name, cqspi);
@@ -1284,7 +1302,14 @@ static const struct dev_pm_ops cqspi__dev_pm_ops = {
 #endif
 
 static const struct of_device_id cqspi_dt_ids[] = {
-   {.compatible = "cdns,qspi-nor",},
+   {
+   .compatible = "cdns,qspi-nor",
+   .data = (void *)0,
+   },
+   {
+   .compatible = "ti,k2g-qspi",
+   .data = (void *)CQSPI_NEEDS_WR_DELAY,
+   },
{ /* end of table */ }
 };
 
-- 
2.14.1



[PATCH v2 3/5] mtd: spi-nor: cadence-quadspi: Add new binding to enable loop-back circuit

2017-08-15 Thread Vignesh R
Cadence QSPI IP has a adapted loop-back circuit which can be enabled by
setting BYPASS field to 0 in READCAPTURE register. It enables use of
QSPI return clock to latch the data rather than the internal QSPI
reference clock. For high speed operations, adapted loop-back circuit
using QSPI return clock helps to increase data valid window.

Add DT parameter cdns,rclk-en to help enable adapted loop-back circuit
for boards which do have QSPI return clock provided. Update binding
documentation for the same.

Signed-off-by: Vignesh R 
---
 Documentation/devicetree/bindings/mtd/cadence-quadspi.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt 
b/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt
index 7dbe3bd9ac56..bb2075df9b38 100644
--- a/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt
+++ b/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt
@@ -16,6 +16,9 @@ Required properties:
 
 Optional properties:
 - cdns,is-decoded-cs : Flag to indicate whether decoder is used or not.
+- cdns,rclk-en : Flag to indicate that QSPI return clock is used to latch
+  the read data rather than the QSPI clock. Make sure that QSPI return
+  clock is populated on the board before using this property.
 
 Optional subnodes:
 Subnodes of the Cadence Quad SPI controller are spi slave nodes with additional
-- 
2.14.1



[PATCH v2 1/5] mtd: spi-nor: cadence-quadspi: Add TI 66AK2G SoC specific compatible

2017-08-15 Thread Vignesh R
Update binding documentation to add a new compatible for TI 66AK2G SoC,
to handle TI SoC specific quirks in the driver.

Signed-off-by: Vignesh R 
---
 Documentation/devicetree/bindings/mtd/cadence-quadspi.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt 
b/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt
index f248056da24c..7dbe3bd9ac56 100644
--- a/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt
+++ b/Documentation/devicetree/bindings/mtd/cadence-quadspi.txt
@@ -1,7 +1,9 @@
 * Cadence Quad SPI controller
 
 Required properties:
-- compatible : Should be "cdns,qspi-nor".
+- compatible : should be one of the following:
+   Generic default - "cdns,qspi-nor".
+   For TI 66AK2G SoC - "ti,k2g-qspi", "cdns,qspi-nor".
 - reg : Contains two entries, each of which is a tuple consisting of a
physical address and length. The first entry is the address and
length of the controller register set. The second entry is the
-- 
2.14.1



[PATCH][RFC v2] PM / Hibernate: Disable wathdog when creating snapshot

2017-08-15 Thread Chen Yu
There is a problem that when counting the pages for creating
the hibernation snapshot will take significant amount of
time, especially on system with large memory. Since the counting
job is performed with irq disabled, this might lead to NMI lockup.
The following warning were found on a system with 1.5TB DRAM:

[ 1124.758184] Freezing user space processes ... (elapsed 0.002 seconds) done.
[ 1124.768721] OOM killer disabled.
[ 1124.847009] PM: Preallocating image memory...
[ 1139.392042] NMI watchdog: Watchdog detected hard LOCKUP on cpu 27
[ 1139.392076] CPU: 27 PID: 3128 Comm: systemd-sleep Not tainted 
4.13.0-0.rc2.git0.1.fc27.x86_64 #1
[ 1139.392077] task: 9f01971ac000 task.stack: b1a3f325c000
[ 1139.392083] RIP: 0010:memory_bm_find_bit+0xf4/0x100
[ 1139.392084] RSP: 0018:b1a3f325fc20 EFLAGS: 0006
[ 1139.392084] RAX:  RBX: 13b83000 RCX: 9fbe89caf000
[ 1139.392085] RDX: b1a3f325fc30 RSI: 3200 RDI: 9fbeae80
[ 1139.392085] RBP: b1a3f325fc40 R08: 13b8 R09: 9fbe89c54878
[ 1139.392085] R10: b1a3f325fc2c R11: 13b83200 R12: 0400
[ 1139.392086] R13: fd552e0c R14: 9fc1bffd31e0 R15: 0202
[ 1139.392086] FS:  7f3189704180() GS:9fbec8ec() 
knlGS:
[ 1139.392087] CS:  0010 DS:  ES:  CR0: 80050033
[ 1139.392087] CR2: 0085da0f7398 CR3: 01771cf9a000 CR4: 007406e0
[ 1139.392088] DR0:  DR1:  DR2: 
[ 1139.392088] DR3:  DR6: fffe0ff0 DR7: 0400
[ 1139.392088] PKRU: 5554
[ 1139.392089] Call Trace:
[ 1139.392092]  ? memory_bm_set_bit+0x29/0x60
[ 1139.392094]  swsusp_set_page_free+0x2b/0x30
[ 1139.392098]  mark_free_pages+0x147/0x1c0
[ 1139.392099]  count_data_pages+0x41/0xa0
[ 1139.392101]  hibernate_preallocate_memory+0x80/0x450
[ 1139.392102]  hibernation_snapshot+0x58/0x410
[ 1139.392103]  hibernate+0x17c/0x310
[ 1139.392104]  state_store+0xdf/0xf0
[ 1139.392107]  kobj_attr_store+0xf/0x20
[ 1139.392111]  sysfs_kf_write+0x37/0x40
[ 1139.392113]  kernfs_fop_write+0x11c/0x1a0
[ 1139.392117]  __vfs_write+0x37/0x170
[ 1139.392121]  ? handle_mm_fault+0xd8/0x230
[ 1139.392122]  vfs_write+0xb1/0x1a0
[ 1139.392123]  SyS_write+0x55/0xc0
[ 1139.392126]  entry_SYSCALL_64_fastpath+0x1a/0xa5

So avoid the NMI lockup by disabling the watchdog temporarily.

Reported-by: Jan Filipcewicz 
Cc: Andrew Morton 
Cc: Michal Hocko 
Cc: Mel Gorman 
Cc: Vlastimil Babka 
Cc: "Rafael J. Wysocki" 
Cc: Len Brown 
Cc: Dan Williams 
Cc: linux...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Chen Yu 
---
 v2: Change the 'feed' action by touch_nmi_watchdog()
 to 'disable' the watchdog by lockup_detector_suspend().
---
 mm/page_alloc.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 6d00f74..adff934 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -66,6 +66,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -2537,10 +2538,15 @@ void mark_free_pages(struct zone *zone)
unsigned long flags;
unsigned int order, t;
struct page *page;
+   bool wd_suspended;
 
if (zone_is_empty(zone))
return;
 
+   wd_suspended = lockup_detector_suspend() ? false : true;
+   if (!wd_suspended)
+   pr_warn_once("Failed to disable lockup detector during 
hibernation.\n");
+
spin_lock_irqsave(&zone->lock, flags);
 
max_zone_pfn = zone_end_pfn(zone);
@@ -2566,6 +2572,9 @@ void mark_free_pages(struct zone *zone)
}
}
spin_unlock_irqrestore(&zone->lock, flags);
+
+   if (wd_suspended)
+   lockup_detector_resume();
 }
 #endif /* CONFIG_PM */
 
-- 
2.7.4



[PATCH v2 5/5] mtd: spi-nor: cadence-quadspi: Add runtime PM support

2017-08-15 Thread Vignesh R
Add pm_runtime* calls to cadence-quadspi driver. This is required to
switch on QSPI power domain on TI 66AK2G SoC during probe.

Signed-off-by: Vignesh R 
---
 drivers/mtd/spi-nor/cadence-quadspi.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c 
b/drivers/mtd/spi-nor/cadence-quadspi.c
index c11ced529ddd..4fd6fb9c83b3 100644
--- a/drivers/mtd/spi-nor/cadence-quadspi.c
+++ b/drivers/mtd/spi-nor/cadence-quadspi.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1224,6 +1225,13 @@ static int cqspi_probe(struct platform_device *pdev)
return -ENXIO;
}
 
+   pm_runtime_enable(&pdev->dev);
+   ret = pm_runtime_get_sync(&pdev->dev);
+   if (ret < 0) {
+   pm_runtime_put_noidle(&pdev->dev);
+   return ret;
+   }
+
ret = clk_prepare_enable(cqspi->clk);
if (ret) {
dev_err(dev, "Cannot enable QSPI clock.\n");
@@ -1275,6 +1283,9 @@ static int cqspi_remove(struct platform_device *pdev)
 
clk_disable_unprepare(cqspi->clk);
 
+   pm_runtime_put_sync(&pdev->dev);
+   pm_runtime_disable(&pdev->dev);
+
return 0;
 }
 
-- 
2.14.1



Re: [PATCH][RFC] PM / Hibernate: Feed NMI wathdog when creating snapshot

2017-08-15 Thread Chen Yu
On Tue, Aug 15, 2017 at 02:41:19PM +0200, Michal Hocko wrote:
> On Tue 15-08-17 01:19:16, Chen Yu wrote:
> [...]
> > @@ -2561,8 +2562,10 @@ void mark_free_pages(struct zone *zone)
> > unsigned long i;
> >  
> > pfn = page_to_pfn(page);
> > -   for (i = 0; i < (1UL << order); i++)
> > +   for (i = 0; i < (1UL << order); i++) {
> > swsusp_set_page_free(pfn_to_page(pfn + i));
> > +   touch_nmi_watchdog();
> > +   }
> 
> this is rather excessive. Why don't you simply call touch_nmi_watchdog
> once per every 1000 pages? Or once per free_list entry?
> 
> Moreover why don't you need to touch_nmi_watchdog in the loop over all
> pfns in the zone (right above this loop)?
> --
After re-checking the code, I think we can simply disable the watchdog
temporarily, thus to avoid feeding the watchdog in the loop.
I'm sending another version based on this.
Thanks,
Yu
> Michal Hocko
> SUSE Labs


[PATCH v2 4/5] mtd: spi-nor: cadence-quadspi: Add support to enable loop-back clock circuit

2017-08-15 Thread Vignesh R
Cadence QSPI IP has a adapted loop-back circuit which can be enabled by
setting BYPASS field to 0 in READCAPTURE register. It enables use of
QSPI return clock to latch the data rather than the internal QSPI
reference clock. For high speed operations, adapted loop-back circuit
using QSPI return clock helps to increase data valid window.

Based on DT parameter cdns,rclk-en enable adapted loop-back circuit
for boards which do have QSPI return clock provided.
This patch also modifies cqspi_readdata_capture() function's bypass
parameter to bool to match how its used in the function.

Signed-off-by: Vignesh R 
---

v2:
Split doc update to separate patch

 drivers/mtd/spi-nor/cadence-quadspi.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c 
b/drivers/mtd/spi-nor/cadence-quadspi.c
index bb0cb02a6938..c11ced529ddd 100644
--- a/drivers/mtd/spi-nor/cadence-quadspi.c
+++ b/drivers/mtd/spi-nor/cadence-quadspi.c
@@ -78,6 +78,7 @@ struct cqspi_st {
boolis_decoded_cs;
u32 fifo_depth;
u32 fifo_width;
+   boolrclk_en;
u32 trigger_address;
u32 wr_delay;
struct cqspi_flash_pdata f_pdata[CQSPI_MAX_CHIPSELECT];
@@ -788,7 +789,7 @@ static void cqspi_config_baudrate_div(struct cqspi_st 
*cqspi)
 }
 
 static void cqspi_readdata_capture(struct cqspi_st *cqspi,
-  const unsigned int bypass,
+  const bool bypass,
   const unsigned int delay)
 {
void __iomem *reg_base = cqspi->iobase;
@@ -852,7 +853,8 @@ static void cqspi_configure(struct spi_nor *nor)
cqspi->sclk = sclk;
cqspi_config_baudrate_div(cqspi);
cqspi_delay(nor);
-   cqspi_readdata_capture(cqspi, 1, f_pdata->read_delay);
+   cqspi_readdata_capture(cqspi, !cqspi->rclk_en,
+  f_pdata->read_delay);
}
 
if (switch_cs || switch_ck)
@@ -1049,6 +1051,8 @@ static int cqspi_of_get_pdata(struct platform_device 
*pdev)
return -ENXIO;
}
 
+   cqspi->rclk_en = of_property_read_bool(np, "cdns,rclk-en");
+
return 0;
 }
 
-- 
2.14.1



Re: [PATCH v2] zsmalloc: zs_page_migrate: schedule free_work if zspage is ZS_EMPTY

2017-08-15 Thread Minchan Kim
On Wed, Aug 16, 2017 at 10:49:14AM +0800, Hui Zhu wrote:
> Hi Minchan,
> 
> 2017-08-16 10:13 GMT+08:00 Minchan Kim :
> > Hi Hui,
> >
> > On Mon, Aug 14, 2017 at 05:56:30PM +0800, Hui Zhu wrote:
> >> After commit e2846124f9a2 ("zsmalloc: zs_page_migrate: skip unnecessary
> >
> > This patch is not merged yet so the hash is invalid.
> > That means we may fold this patch to [1] in current mmotm.
> >
> > [1] 
> > zsmalloc-zs_page_migrate-skip-unnecessary-loops-but-not-return-ebusy-if-zspage-is-not-inuse-fix.patch
> >
> >> loops but not return -EBUSY if zspage is not inuse") zs_page_migrate
> >> can handle the ZS_EMPTY zspage.
> >>
> >> But I got some false in zs_page_isolate:
> >>   if (get_zspage_inuse(zspage) == 0) {
> >>   spin_unlock(&class->lock);
> >>   return false;
> >>   }
> >
> > I also realized we should make zs_page_isolate succeed on empty zspage
> > because we allow the empty zspage migration from now on.
> > Could you send a patch for that as well?
> 
> OK.  I will make a patch for that later.

Please send the patch so I want to fold it to [1] before Andrew is going
to send [1] to Linus.

Thanks.


Re: [PATCH v4 11/20] mtd: nand: qcom: enable BAM or ADM mode

2017-08-15 Thread Archit Taneja



On 08/11/2017 05:09 PM, Abhishek Sahu wrote:

1. DM_EN is only required for EBI2 NAND controller which uses ADM
2. BAM mode will be disabled after power on reset which needs to
be enabled before starting any BAM transfers.

Signed-off-by: Abhishek Sahu 
---
  drivers/mtd/nand/qcom_nandc.c | 17 ++---
  1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
index 3d9fd7f..ae873d3 100644
--- a/drivers/mtd/nand/qcom_nandc.c
+++ b/drivers/mtd/nand/qcom_nandc.c
@@ -163,6 +163,9 @@
  #define NAND_DEV_CMD_VLD_VAL  (READ_START_VLD | WRITE_START_VLD | \
 ERASE_START_VLD | SEQ_READ_START_VLD)
  
+/* NAND_CTRL bits */

+#defineBAM_MODE_EN BIT(0)
+
  /*
   * the NAND controller performs reads/writes with ECC in 516 byte chunks.
   * the driver calls the chunks 'step' or 'codeword' interchangeably
@@ -1035,7 +1038,8 @@ static int read_id(struct qcom_nand_host *host, int 
column)
nandc_set_reg(nandc, NAND_FLASH_CMD, FETCH_ID);
nandc_set_reg(nandc, NAND_ADDR0, column);
nandc_set_reg(nandc, NAND_ADDR1, 0);
-   nandc_set_reg(nandc, NAND_FLASH_CHIP_SELECT, DM_EN);
+   nandc_set_reg(nandc, NAND_FLASH_CHIP_SELECT,
+ nandc->props->is_bam ? 0 : DM_EN);


I'm not sure why the above register was configured in read_id in the first 
place. Would
it be required later if we want the controller to support multiple NAND chips? 
If not,
then we could consider dropping this. Anyway, that can be posted as a separate 
patch
later.

Reviewed-by: Archit Taneja 

Thanks,
Archit


nandc_set_reg(nandc, NAND_EXEC_CMD, 1);
  
  	write_reg_dma(nandc, NAND_FLASH_CMD, 4, NAND_BAM_NEXT_SGL);

@@ -2408,12 +2412,19 @@ static void qcom_nandc_unalloc(struct 
qcom_nand_controller *nandc)
  /* one time setup of a few nand controller registers */
  static int qcom_nandc_setup(struct qcom_nand_controller *nandc)
  {
+   u32 nand_ctrl;
+
/* kill onenand */
nandc_write(nandc, SFLASHC_BURST_CFG, 0);
nandc_write(nandc, NAND_DEV_CMD_VLD, NAND_DEV_CMD_VLD_VAL);
  
-	/* enable ADM DMA */

-   nandc_write(nandc, NAND_FLASH_CHIP_SELECT, DM_EN);
+   /* enable ADM or BAM DMA */
+   if (nandc->props->is_bam) {
+   nand_ctrl = nandc_read(nandc, NAND_CTRL);
+   nandc_write(nandc, NAND_CTRL, nand_ctrl | BAM_MODE_EN);
+   } else {
+   nandc_write(nandc, NAND_FLASH_CHIP_SELECT, DM_EN);
+   }
  
  	/* save the original values of these registers */

nandc->cmd1 = nandc_read(nandc, NAND_DEV_CMD1);



--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


[PATCH] sg: recheck MMAP_IO request length with lock held

2017-08-15 Thread Todd Poynor
Commit 1bc0eb044615 ("scsi: sg: protect accesses to 'reserved' page
array") adds needed concurrency protection for the "reserve" buffer.
Some checks that are initially made outside the lock are replicated once
the lock is taken to ensure the checks and resulting decisions are made
using consistent state.

The check that a request with flag SG_FLAG_MMAP_IO set fits in the
reserve buffer also needs to be performed again under the lock to
ensure the reserve buffer length compared against matches the value in
effect when the request is linked to the reserve buffer.  An -ENOMEM
should be returned in this case, instead of switching over to an
indirect buffer as for non-MMAP_IO requests.

Signed-off-by: Todd Poynor 
---
 drivers/scsi/sg.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index d7ff71e0c85c..3a44b4bc872b 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1735,9 +1735,12 @@ sg_start_req(Sg_request *srp, unsigned char *cmd)
!sfp->res_in_use) {
sfp->res_in_use = 1;
sg_link_reserve(sfp, srp, dxfer_len);
-   } else if ((hp->flags & SG_FLAG_MMAP_IO) && sfp->res_in_use) {
+   } else if (hp->flags & SG_FLAG_MMAP_IO) {
+   res = -EBUSY; /* sfp->res_in_use == 1 */
+   if (dxfer_len > rsv_schp->bufflen)
+   res = -ENOMEM;
mutex_unlock(&sfp->f_mutex);
-   return -EBUSY;
+   return res;
} else {
res = sg_build_indirect(req_schp, sfp, dxfer_len);
if (res) {
-- 
2.14.1.480.gb18f417b89-goog



Re: [PATCH v1 2/6] fs: use on-stack-bio if backing device has BDI_CAP_SYNC capability

2017-08-15 Thread Minchan Kim
Hi Jens,

On Mon, Aug 14, 2017 at 10:17:09AM -0600, Jens Axboe wrote:
> On 08/14/2017 09:38 AM, Jens Axboe wrote:
> > On 08/14/2017 09:31 AM, Minchan Kim wrote:
> >>> Secondly, generally you don't have slow devices and fast devices
> >>> intermingled when running workloads. That's the rare case.
> >>
> >> Not true. zRam is really popular swap for embedded devices where
> >> one of low cost product has a really poor slow nand compared to
> >> lz4/lzo [de]comression.
> > 
> > I guess that's true for some cases. But as I said earlier, the recycling
> > really doesn't care about this at all. They can happily coexist, and not
> > step on each others toes.
> 
> Dusted it off, result is here against -rc5:
> 
> http://git.kernel.dk/cgit/linux-block/log/?h=cpu-alloc-cache
> 
> I'd like to split the amount of units we cache and the amount of units
> we free, right now they are both CPU_ALLOC_CACHE_SIZE. This means that
> once we hit that count, we free all of the, and then store the one we
> were asked to free. That always keeps 1 local, but maybe it'd make more
> sense to cache just free CPU_ALLOC_CACHE_SIZE/2 (or something like that)
> so that we retain more than 1 per cpu in case and app preempts when
> sleeping for IO and the new task on that CPU then issues IO as well.
> Probably minor.
> 
> Ran a quick test on nullb0 with 32 sync readers. The test was O_DIRECT
> on the block device, so I disabled the __blkdev_direct_IO_simple()
> bypass. With the above branch, we get ~18.0M IOPS, and without we get
> ~14M IOPS. Both ran with iostats disabled, to avoid any interference
> from that.

Looks promising.
If recycling bio works well enough, I think we don't need to introduce
new split in the path for on-stack bio.
I will test your version on zram-swap!

Thanks.


linux-next: build failure after merge of the akpm-current tree

2017-08-15 Thread Stephen Rothwell
Hi all,

After merging the akpm-current tree, today's linux-next build (x86_64
allmodconfig) failed like this:

drivers/gpu/drm/i915/i915_gem_execbuffer.c: In function 'get_fence_array':
drivers/gpu/drm/i915/i915_gem_execbuffer.c:2163:20: error: 'GFP_TEMPORARY' 
undeclared (first use in this function)
 __GFP_NOWARN | GFP_TEMPORARY);
^

Caused by commit

  4d6fc0a48c52 ("mm: treewide: remove GFP_TEMPORARY allocation flag")

interacting with commit

  cf6e7bac6357 ("drm/i915: Add support for drm syncobjs")

from the drm-intel tree.

I applied the following merge fix patch (and I suspect - given the
comments in the former commit message - that this could be applied to
the drm-intel tree right now without any problems):

From: Stephen Rothwell 
Date: Wed, 16 Aug 2017 14:41:24 +1000
Subject: [PATCH] drm/i915: fix up for mm: treewide: remove GFP_TEMPORARY 
allocation flag

Signed-off-by: Stephen Rothwell 
---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c 
b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 8fbdefe0216e..15ab3e6792f9 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -2160,7 +2160,7 @@ get_fence_array(struct drm_i915_gem_execbuffer2 *args,
return ERR_PTR(-EFAULT);
 
fences = kvmalloc_array(args->num_cliprects, sizeof(*fences),
-   __GFP_NOWARN | GFP_TEMPORARY);
+   __GFP_NOWARN | GFP_KERNEL);
if (!fences)
return ERR_PTR(-ENOMEM);
 
-- 
2.13.2

-- 
Cheers,
Stephen Rothwell


Re: [PATCH v4 10/20] mtd: nand: qcom: erased codeword detection configuration

2017-08-15 Thread Archit Taneja



On 08/11/2017 05:09 PM, Abhishek Sahu wrote:

The NAND controller returns ECC failure during read of completely
erased codeword. The NAND controller has hardware functionality
to detect erased codeword in case of BCH ECC algorithm. The
NAND_ERASED_CW_DETECT_CFG register controls the erased
codeword/page detection controller. This register should be reset
before every page read by setting and clearing bit 0 of
NAND_ERASED_CW_DETECT_CFG.


Reviewed-by: Archit Taneja 

Thanks,
Archit



Signed-off-by: Abhishek Sahu 
---
  drivers/mtd/nand/qcom_nandc.c | 21 +
  1 file changed, 21 insertions(+)

diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
index b452cfb..3d9fd7f 100644
--- a/drivers/mtd/nand/qcom_nandc.c
+++ b/drivers/mtd/nand/qcom_nandc.c
@@ -200,6 +200,11 @@
  #define NAND_BAM_NWD  BIT(1)
  /* Finish writing in the current sgl and start writing in another sgl */
  #define NAND_BAM_NEXT_SGL BIT(2)
+/*
+ * Erased codeword status is being used two times in single transfer so this
+ * flag will determine the current value of erased codeword status register
+ */
+#define NAND_ERASED_CW_SET BIT(4)
  
  /*

   * This data type corresponds to the BAM transaction which will be used for 
all
@@ -278,6 +283,8 @@ struct nandc_regs {
__le32 read_location2;
__le32 read_location3;
  
+	__le32 erased_cw_detect_cfg_clr;

+   __le32 erased_cw_detect_cfg_set;
  };
  
  /*

@@ -805,6 +812,13 @@ static int write_reg_dma(struct qcom_nand_controller 
*nandc, int first,
if (first == NAND_FLASH_CMD)
flow_control = true;
  
+	if (first == NAND_ERASED_CW_DETECT_CFG) {

+   if (flags & NAND_ERASED_CW_SET)
+   vaddr = ®s->erased_cw_detect_cfg_set;
+   else
+   vaddr = ®s->erased_cw_detect_cfg_clr;
+   }
+
if (first == NAND_EXEC_CMD)
flags |= NAND_BAM_NWD;
  
@@ -857,6 +871,9 @@ static void config_nand_page_read(struct qcom_nand_controller *nandc)

write_reg_dma(nandc, NAND_ADDR0, 2, 0);
write_reg_dma(nandc, NAND_DEV0_CFG0, 3, 0);
write_reg_dma(nandc, NAND_EBI2_ECC_BUF_CFG, 1, 0);
+   write_reg_dma(nandc, NAND_ERASED_CW_DETECT_CFG, 1, 0);
+   write_reg_dma(nandc, NAND_ERASED_CW_DETECT_CFG, 1,
+ NAND_ERASED_CW_SET | NAND_BAM_NEXT_SGL);
  }
  
  /*

@@ -2258,6 +2275,10 @@ static int qcom_nand_host_setup(struct qcom_nand_host 
*host)
  
  	host->clrflashstatus = FS_READY_BSY_N;

host->clrreadstatus = 0xc0;
+   nandc->regs->erased_cw_detect_cfg_clr =
+   cpu_to_le32(CLR_ERASED_PAGE_DET);
+   nandc->regs->erased_cw_detect_cfg_set =
+   cpu_to_le32(SET_ERASED_PAGE_DET);
  
  	dev_dbg(nandc->dev,

"cfg0 %x cfg1 %x ecc_buf_cfg %x ecc_bch cfg %x cw_size %d cw_data %d 
strength %d parity_bytes %d steps %d\n",



--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


[PATCH v3 14/14] [media] cxd2880 : Update MAINTAINERS file for CXD2880 driver

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

This is MAINTAINERS file update about the driver for
the Sony CXD2880 DVB-T2/T tuner + demodulator.

[Change list]
Changes in V3
   MAINTAINERS
  -no change

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 MAINTAINERS | 9 +
 1 file changed, 9 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 6f7721d1634c..12a80c33c194 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8302,6 +8302,15 @@ T:   git git://linuxtv.org/media_tree.git
 S: Supported
 F: drivers/media/dvb-frontends/cxd2841er*
 
+MEDIA DRIVERS FOR CXD2880
+M: Yasunari Takiguchi 
+L: linux-me...@vger.kernel.org
+W: http://linuxtv.org/
+T: git git://linuxtv.org/media_tree.git
+S: Supported
+F: drivers/media/dvb-frontends/cxd2880/*
+F: drivers/media/spi/cxd2880*
+
 MEDIA DRIVERS FOR FREESCALE IMX
 M: Steve Longerbeam 
 M: Philipp Zabel 
-- 
2.13.0



Re: [PATCH] ioctl_tty.2: add TIOCGPTPEER documentation

2017-08-15 Thread Aleksa Sarai

I've applied this patch, and then tweaked the wording a little. Could
you please check the following text:

TIOCGPTPEERint flags
   (since Linux 4.13) Given  a  file  descriptor  in  fd  that
   refers  to  a  pseudoterminal  master, open (with the given
   open(2)-style flags) and return a new file descriptor  that
   refers to the peer pseudoterminal slave device.  This oper‐
   ation can be performed regardless of whether  the  pathname
   of  the  slave  device  is  accessible  through the calling
   process's mount namespaces.

   Security-conscious programs interacting with namespaces may
   wish  to  use  this  operation rather than open(2) with the
   pathname returned by ptsname(3), and similar library  func‐
   tions that have insecure APIs.


Yup, that sounds good.


I also have a question on the last sentence: what are the "similar library
functions that have insecure APIs"? It's not clear to me what you are
referring to here.


There are a few posix_-style functions provided by glibc that are just 
wrappers around the open+ptsname combo that I mention earlier in the 
sentence (and thus are vulnerable to the same issue). But if you feel 
it's confusing you can feel free to drop it.


Thanks.

--
Aleksa Sarai
Software Engineer (Containers)
SUSE Linux GmbH
https://www.cyphar.com/


[PATCH v3 13/14] [media] cxd2880: Add all Kconfig files for the driver

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

This is the Kconfig files of driver for
the Sony CXD2880 DVB-T2/T tuner + demodulator driver.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/Kconfig
  -no change
   drivers/media/dvb-frontends/cxd2880/Kconfig
  -no change
   drivers/media/spi/Kconfig
  -no change

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 drivers/media/dvb-frontends/Kconfig |  2 ++
 drivers/media/dvb-frontends/cxd2880/Kconfig |  6 ++
 drivers/media/spi/Kconfig   | 14 ++
 3 files changed, 22 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/Kconfig

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index 3a260b82b3e8..6831f4a49c18 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -519,6 +519,8 @@ config DVB_GP8PSK_FE
depends on DVB_CORE
default DVB_USB_GP8PSK
 
+source "drivers/media/dvb-frontends/cxd2880/Kconfig"
+
 comment "DVB-C (cable) frontends"
depends on DVB_CORE
 
diff --git a/drivers/media/dvb-frontends/cxd2880/Kconfig 
b/drivers/media/dvb-frontends/cxd2880/Kconfig
new file mode 100644
index ..36b8b6f7c4f7
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/Kconfig
@@ -0,0 +1,6 @@
+config DVB_CXD2880
+   tristate "Sony CXD2880 DVB-T2/T tuner + demodulator"
+   depends on DVB_CORE && SPI
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+   help
+ Say Y when you want to support this frontend.
\ No newline at end of file
diff --git a/drivers/media/spi/Kconfig b/drivers/media/spi/Kconfig
index a21f5a39a440..b07ac86fc53c 100644
--- a/drivers/media/spi/Kconfig
+++ b/drivers/media/spi/Kconfig
@@ -12,3 +12,17 @@ config VIDEO_GS1662
 endmenu
 
 endif
+
+if SPI
+menu "Media SPI Adapters"
+
+config CXD2880_SPI_DRV
+   tristate "Sony CXD2880 SPI support"
+   depends on DVB_CORE && SPI
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+   help
+ Choose if you would like to have SPI interface support for Sony 
CXD2880.
+
+endmenu
+
+endif
-- 
2.13.0



[PATCH v3 12/14] [media] cxd2880: Add all Makefile files for the driver

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

This is the Makefile files of driver
for the Sony CXD2880 DVB-T2/T tuner + demodulator.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/Makefile
  -no change
   drivers/media/dvb-frontends/cxd2880/Makefile
  -removed cxd2880_math.o \ 
   drivers/media/spi/Makefile
  -no change

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 drivers/media/dvb-frontends/Makefile |  1 +
 drivers/media/dvb-frontends/cxd2880/Makefile | 20 
 drivers/media/spi/Makefile   |  5 +
 3 files changed, 26 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/Makefile

diff --git a/drivers/media/dvb-frontends/Makefile 
b/drivers/media/dvb-frontends/Makefile
index 3fccaf34ef52..d298c7954699 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -126,3 +126,4 @@ obj-$(CONFIG_DVB_HORUS3A) += horus3a.o
 obj-$(CONFIG_DVB_ASCOT2E) += ascot2e.o
 obj-$(CONFIG_DVB_HELENE) += helene.o
 obj-$(CONFIG_DVB_ZD1301_DEMOD) += zd1301_demod.o
+obj-$(CONFIG_DVB_CXD2880) += cxd2880/
diff --git a/drivers/media/dvb-frontends/cxd2880/Makefile 
b/drivers/media/dvb-frontends/cxd2880/Makefile
new file mode 100644
index ..ee7758b28a05
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/Makefile
@@ -0,0 +1,20 @@
+cxd2880-objs := cxd2880_common.o \
+   cxd2880_devio_spi.o \
+   cxd2880_integ.o \
+   cxd2880_integ_dvbt2.o \
+   cxd2880_integ_dvbt.o \
+   cxd2880_io.o \
+   cxd2880_spi_device.o \
+   cxd2880_stopwatch_port.o \
+   cxd2880_tnrdmd.o \
+   cxd2880_tnrdmd_dvbt2.o \
+   cxd2880_tnrdmd_dvbt2_mon.o \
+   cxd2880_tnrdmd_dvbt.o \
+   cxd2880_tnrdmd_dvbt_mon.o\
+   cxd2880_tnrdmd_mon.o\
+   cxd2880_top.o
+
+obj-$(CONFIG_DVB_CXD2880) += cxd2880.o
+
+ccflags-y += -Idrivers/media/dvb-core
+ccflags-y += -Idrivers/media/dvb-frontends
diff --git a/drivers/media/spi/Makefile b/drivers/media/spi/Makefile
index ea64013d16cc..40e0f88d9f6c 100644
--- a/drivers/media/spi/Makefile
+++ b/drivers/media/spi/Makefile
@@ -1 +1,6 @@
 obj-$(CONFIG_VIDEO_GS1662) += gs1662.o
+obj-$(CONFIG_CXD2880_SPI_DRV) += cxd2880-spi.o
+
+ccflags-y += -Idrivers/media/dvb-core
+ccflags-y += -Idrivers/media/dvb-frontends
+ccflags-y += -Idrivers/media/dvb-frontends/cxd2880
\ No newline at end of file
-- 
2.13.0



[PATCH v3 11/14] [media] cxd2880: Add DVB-T2 monitor and integration layer functions

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

Provide monitor and integration layer functions (DVB-T2)
for the Sony CXD2880 DVB-T2/T tuner + demodulator driver.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.c
  -changed CXD2880_SLEEP to usleep_range
  -replaced cxd2880_atomic_set to atomic_set
  -modified return code
  -modified coding style of if()  
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.h
  -modified return code
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2_mon.c
  -removed unnecessary cast
  -changed cxd2880_math_log to intlog10
  -modified return code
  -modified coding style of if() 
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2_mon.h
  -modified return code

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 .../dvb-frontends/cxd2880/cxd2880_integ_dvbt2.c|  312 +++
 .../dvb-frontends/cxd2880/cxd2880_integ_dvbt2.h|   64 +
 .../cxd2880/cxd2880_tnrdmd_dvbt2_mon.c | 2622 
 .../cxd2880/cxd2880_tnrdmd_dvbt2_mon.h |  170 ++
 4 files changed, 3168 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.h
 create mode 100644 
drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2_mon.c
 create mode 100644 
drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2_mon.h

diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.c 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.c
new file mode 100644
index ..ac049820d797
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.c
@@ -0,0 +1,312 @@
+/*
+ * cxd2880_integ_dvbt2.c
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * integration layer functions for DVB-T2
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#include "cxd2880_tnrdmd_dvbt2.h"
+#include "cxd2880_tnrdmd_dvbt2_mon.h"
+#include "cxd2880_integ_dvbt2.h"
+
+static int dvbt2_wait_demod_lock(struct cxd2880_tnrdmd *tnr_dmd,
+enum cxd2880_dvbt2_profile
+profile);
+
+static int dvbt2_wait_l1_post_lock(struct cxd2880_tnrdmd *tnr_dmd);
+
+int cxd2880_integ_dvbt2_tune(struct cxd2880_tnrdmd *tnr_dmd,
+struct cxd2880_dvbt2_tune_param
+*tune_param)
+{
+   int ret = 0;
+
+   if ((!tnr_dmd) || (!tune_param))
+   return -EINVAL;
+
+   if (tnr_dmd->diver_mode == CXD2880_TNRDMD_DIVERMODE_SUB)
+   return -EINVAL;
+
+   if ((tnr_dmd->state != CXD2880_TNRDMD_STATE_SLEEP) &&
+   (tnr_dmd->state != CXD2880_TNRDMD_STATE_ACTIVE))
+   return -EPERM;
+
+   atomic_set(&tnr_dmd->cancel, 0);
+
+   if ((tune_param->bandwidth != CXD2880_DTV_BW_1_7_MHZ) &&
+   (tune_param->bandwidth != CXD2880_DTV_BW_5_MHZ) &&
+   (tune_param->bandwidth != CXD2880_DTV_BW_6_MHZ) &&
+   (tune_param->bandwidth != CXD2880_DTV_BW_7_MHZ) &&
+   (tune_param->bandwidth != CXD2880_DTV_BW_8_MHZ)) {
+   return -EOPNOTSUPP;
+   }
+
+   if ((tune_param->profile != CXD2880_DVBT2_PROFILE_BASE) &&
+   (tune_param->profile != CXD2880_DVBT2_PROFILE_LITE))
+   return -EINVAL;
+
+   ret = cxd2880_tnrdmd_dvbt2_tune1(tnr_dmd, tune_param);
+   if (ret)
+   return ret;
+
+   usleep_range(CXD2880_TNRDMD_WAIT_AGC_STABLE * 1,
+CXD2880_TNRDMD_WAIT_AGC_STABLE * 1 + 1000);
+
+   ret = cxd28

[PATCH v3 10/14] [media] cxd2880: Add DVB-T2 control functions for the driver

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

Provide definitions, interfaces and functions needed for DVB-T2
of the Sony CXD2880 DVB-T2/T tuner + demodulator driver.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt2.h
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2.c
  -modified return code
  -modified coding style of if() 
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2.h
  -modified return code

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 .../media/dvb-frontends/cxd2880/cxd2880_dvbt2.h|  402 ++
 .../dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2.c   | 1359 
 .../dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2.h   |   82 ++
 3 files changed, 1843 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt2.h
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2.h

diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt2.h 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt2.h
new file mode 100644
index ..674ed17deef5
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt2.h
@@ -0,0 +1,402 @@
+/*
+ * cxd2880_dvbt2.h
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * DVB-T2 related definitions
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#ifndef CXD2880_DVBT2_H
+#define CXD2880_DVBT2_H
+
+#include "cxd2880_common.h"
+
+enum cxd2880_dvbt2_profile {
+   CXD2880_DVBT2_PROFILE_BASE,
+   CXD2880_DVBT2_PROFILE_LITE,
+   CXD2880_DVBT2_PROFILE_ANY
+};
+
+enum cxd2880_dvbt2_version {
+   CXD2880_DVBT2_V111,
+   CXD2880_DVBT2_V121,
+   CXD2880_DVBT2_V131
+};
+
+enum cxd2880_dvbt2_s1 {
+   CXD2880_DVBT2_S1_BASE_SISO = 0x00,
+   CXD2880_DVBT2_S1_BASE_MISO = 0x01,
+   CXD2880_DVBT2_S1_NON_DVBT2 = 0x02,
+   CXD2880_DVBT2_S1_LITE_SISO = 0x03,
+   CXD2880_DVBT2_S1_LITE_MISO = 0x04,
+   CXD2880_DVBT2_S1_RSVD3 = 0x05,
+   CXD2880_DVBT2_S1_RSVD4 = 0x06,
+   CXD2880_DVBT2_S1_RSVD5 = 0x07,
+   CXD2880_DVBT2_S1_UNKNOWN = 0xff
+};
+
+enum cxd2880_dvbt2_base_s2 {
+   CXD2880_DVBT2_BASE_S2_M2K_G_ANY = 0x00,
+   CXD2880_DVBT2_BASE_S2_M8K_G_DVBT = 0x01,
+   CXD2880_DVBT2_BASE_S2_M4K_G_ANY = 0x02,
+   CXD2880_DVBT2_BASE_S2_M1K_G_ANY = 0x03,
+   CXD2880_DVBT2_BASE_S2_M16K_G_ANY = 0x04,
+   CXD2880_DVBT2_BASE_S2_M32K_G_DVBT = 0x05,
+   CXD2880_DVBT2_BASE_S2_M8K_G_DVBT2 = 0x06,
+   CXD2880_DVBT2_BASE_S2_M32K_G_DVBT2 = 0x07,
+   CXD2880_DVBT2_BASE_S2_UNKNOWN = 0xff
+};
+
+enum cxd2880_dvbt2_lite_s2 {
+   CXD2880_DVBT2_LITE_S2_M2K_G_ANY = 0x00,
+   CXD2880_DVBT2_LITE_S2_M8K_G_DVBT = 0x01,
+   CXD2880_DVBT2_LITE_S2_M4K_G_ANY = 0x02,
+   CXD2880_DVBT2_LITE_S2_M16K_G_DVBT2 = 0x03,
+   CXD2880_DVBT2_LITE_S2_M16K_G_DVBT = 0x04,
+   CXD2880_DVBT2_LITE_S2_RSVD1 = 0x05,
+   CXD2880_DVBT2_LITE_S2_M8K_G_DVBT2 = 0x06,
+   CXD2880_DVBT2_LITE_S2_RSVD2 = 0x07,
+   CXD2880_DVBT2_LITE_S2_UNKNOWN = 0xff
+};
+
+enum cxd2880_dvbt2_guard {
+   CXD2880_DVBT2_G1_32 = 0x00,
+   CXD2880_DVBT2_G1_16 = 0x01,
+   CXD2880_DVBT2_G1_8 = 0x02,
+   CXD2880_DVBT2_G1_4 = 0x03,
+   CXD2880_DVBT2_G1_128 = 0x04,
+   CXD2880_DVBT2_G19_128 = 0x05,
+   CXD2880_DVBT2_G19_256 = 0x06,
+   CXD2880_DVBT2_G_RSVD1 = 0x07,
+   CXD2880_DVBT2_G_UNKNOWN = 0xff
+};
+
+enum cxd2880_dvbt2_mode {
+   CXD2880_DVBT2_M2K = 0x00,
+   CXD2880_DVBT2_M8K = 0x01,
+   CXD2880_DVBT2_M4K = 0x02,
+   CXD2880_DVBT2_M1K = 0x03,
+   CXD2880

Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature

2017-08-15 Thread Byungchul Park
On Wed, Aug 16, 2017 at 12:05:31PM +0800, Boqun Feng wrote:
> On Wed, Aug 16, 2017 at 09:16:37AM +0900, Byungchul Park wrote:
> > On Tue, Aug 15, 2017 at 10:20:20AM +0200, Ingo Molnar wrote:
> > > 
> > > So with the latest fixes there's a new lockdep warning on one of my 
> > > testboxes:
> > > 
> > > [   11.322487] EXT4-fs (sda2): mounted filesystem with ordered data mode. 
> > > Opts: (null)
> > > 
> > > [   11.495661] ==
> > > [   11.502093] WARNING: possible circular locking dependency detected
> > > [   11.508507] 4.13.0-rc5-00497-g73135c58-dirty #1 Not tainted
> > > [   11.514313] --
> > > [   11.520725] umount/533 is trying to acquire lock:
> > > [   11.525657]  ((complete)&barr->done){+.+.}, at: [] 
> > > flush_work+0x213/0x2f0
> > > [   11.534411] 
> > >but task is already holding lock:
> > > [   11.540661]  (lock#3){+.+.}, at: [] 
> > > lru_add_drain_all_cpuslocked+0x3d/0x190
> > > [   11.549613] 
> > >which lock already depends on the new lock.
> > > 
> > > The full splat is below. The kernel config is nothing fancy - distro 
> > > derived, 
> > > pretty close to defconfig, with lockdep enabled.
> > 
> > I see...
> > 
> > Worker A : acquired of wfc.work -> wait for cpu_hotplug_lock to be released
> > Task   B : acquired of cpu_hotplug_lock -> wait for lock#3 to be released
> > Task   C : acquired of lock#3 -> wait for completion of barr->done
> 
> >From the stack trace below, this barr->done is for flush_work() in
> lru_add_drain_all_cpuslocked(), i.e. for work "per_cpu(lru_add_drain_work)"
> 
> > Worker D : wait for wfc.work to be released -> will complete barr->done
> 
> and this barr->done is for work "wfc.work".

I think it can be the same instance. wait_for_completion() in flush_work()
e.g. at task C in my example, waits for completion which we expect to be
done by a worker e.g. worker D in my example.

I think the problem is caused by a write-acquisition of wfc.work in
process_one_work(). The acquisition of wfc.work should be reenterable,
that is, read-acquisition, shouldn't it?

I might be wrong... Please fix me if so.

Thank you,
Byungchul

> So those two barr->done could not be the same instance, IIUC. Therefore
> the deadlock case is not possible.
> 
> The problem here is all barr->done instances are initialized at
> insert_wq_barrier() and they belongs to the same lock class, to fix
> this, we need to differ barr->done with different lock classes based on
> the corresponding works.
> 
> How about the this(only compilation test):
> 
> ->8
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index e86733a8b344..d14067942088 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -2431,6 +2431,27 @@ struct wq_barrier {
>   struct task_struct  *task;  /* purely informational */
>  };
>  
> +#ifdef CONFIG_LOCKDEP_COMPLETE
> +# define INIT_WQ_BARRIER_ONSTACK(barr, func, target) 
> \
> +do { 
> \
> + INIT_WORK_ONSTACK(&(barr)->work, func); 
> \
> + __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&(barr)->work));  
> \
> + lockdep_init_map_crosslock((struct lockdep_map *)&(barr)->done.map, 
> \
> +"(complete)" #barr,  
> \
> +(target)->lockdep_map.key, 1);   
> \
> + __init_completion(&barr->done); 
> \
> + barr->task = current;   
> \
> +} while (0)
> +#else
> +# define INIT_WQ_BARRIER_ONSTACK(barr, func, target) 
> \
> +do { 
> \
> + INIT_WORK_ONSTACK(&(barr)->work, func); 
> \
> + __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&(barr)->work));  
> \
> + init_completion(&barr->done);   
> \
> + barr->task = current;   
> \
> +} while (0)
> +#endif
> +
>  static void wq_barrier_func(struct work_struct *work)
>  {
>   struct wq_barrier *barr = container_of(work, struct wq_barrier, work);
> @@ -2474,10 +2495,7 @@ static void insert_wq_barrier(struct pool_workqueue 
> *pwq,
>* checks and call back into the fixup functions where we
>* might deadlock.
>*/
> - INIT_WORK_ONSTACK(&barr->work, wq_barrier_func);
> - __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&barr->work));
> - init_completion(&barr->done);
> - barr->task = current;
> + INIT_WQ_BARRIER_ONSTACK(barr, wq_barrier_func, target);
>  
>   /*
>* If @target is currently being executed, schedule the


[PATCH v3 09/14] [media] cxd2880: Add DVB-T monitor and integration layer functions

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

Provide monitor and integration layer functions (DVB-T)
for the Sony CXD2880 DVB-T2/T tuner + demodulator driver.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.c
  -changed CXD2880_SLEEP to usleep_range
  -chnaged cxd2880_atomic_set to atomic_set
  -modified return code
  -modified coding style of if() 
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.h
  -modified return code
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt_mon.c
  -removed unnecessary cast
  -changed cxd2880_math_log to intlog10
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt_mon.h
  -modified return code

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 .../dvb-frontends/cxd2880/cxd2880_integ_dvbt.c |  198 
 .../dvb-frontends/cxd2880/cxd2880_integ_dvbt.h |   58 +
 .../cxd2880/cxd2880_tnrdmd_dvbt_mon.c  | 1227 
 .../cxd2880/cxd2880_tnrdmd_dvbt_mon.h  |  106 ++
 4 files changed, 1589 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.h
 create mode 100644 
drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt_mon.c
 create mode 100644 
drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt_mon.h

diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.c 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.c
new file mode 100644
index ..729cb0939203
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.c
@@ -0,0 +1,198 @@
+/*
+ * cxd2880_integ_dvbt.c
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * integration layer functions for DVB-T
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#include "cxd2880_tnrdmd_dvbt.h"
+#include "cxd2880_integ_dvbt.h"
+
+static int dvbt_wait_demod_lock(struct cxd2880_tnrdmd *tnr_dmd);
+
+int cxd2880_integ_dvbt_tune(struct cxd2880_tnrdmd *tnr_dmd,
+   struct cxd2880_dvbt_tune_param
+   *tune_param)
+{
+   int ret = 0;
+
+   if ((!tnr_dmd) || (!tune_param))
+   return -EINVAL;
+
+   if (tnr_dmd->diver_mode == CXD2880_TNRDMD_DIVERMODE_SUB)
+   return -EINVAL;
+
+   if ((tnr_dmd->state != CXD2880_TNRDMD_STATE_SLEEP) &&
+   (tnr_dmd->state != CXD2880_TNRDMD_STATE_ACTIVE))
+   return -EPERM;
+
+   atomic_set(&tnr_dmd->cancel, 0);
+
+   if ((tune_param->bandwidth != CXD2880_DTV_BW_5_MHZ) &&
+   (tune_param->bandwidth != CXD2880_DTV_BW_6_MHZ) &&
+   (tune_param->bandwidth != CXD2880_DTV_BW_7_MHZ) &&
+   (tune_param->bandwidth != CXD2880_DTV_BW_8_MHZ)) {
+   return -EOPNOTSUPP;
+   }
+
+   ret = cxd2880_tnrdmd_dvbt_tune1(tnr_dmd, tune_param);
+   if (ret)
+   return ret;
+
+   usleep_range(CXD2880_TNRDMD_WAIT_AGC_STABLE * 1,
+CXD2880_TNRDMD_WAIT_AGC_STABLE * 1 + 1000);
+
+   ret = cxd2880_tnrdmd_dvbt_tune2(tnr_dmd, tune_param);
+   if (ret)
+   return ret;
+
+   ret = dvbt_wait_demod_lock(tnr_dmd);
+   if (ret)
+   return ret;
+
+   return ret;
+}
+
+int cxd2880_integ_dvbt_wait_ts_lock(struct cxd2880_tnrdmd *tnr_dmd)
+{
+   int ret = 0;
+   enum cxd2880_tnrdmd_lock_result lock =
+   CXD2880_TNRDMD_LOCK_RESULT_NOTDETECT;
+   struct cxd2880_stopwatch timer;
+   u8 continue_wait = 1;
+   unsigned int elapsed = 0;
+
+   if (!tnr_dmd)
+   return -EINVAL;
+
+   if (tnr_dmd->

[PATCH v3 08/14] [media] cxd2880: Add DVB-T control functions the driver

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

Provide definitions, interfaces and functions needed for DVB-T
of the Sony CXD2880 DVB-T2/T tuner + demodulator driver.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt.h
  -no change
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.c
  -modified return code
  -modified coding style of if() 
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.h
  -modified return code

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt.h |   91 ++
 .../dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.c| 1115 
 .../dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.h|   62 ++
 3 files changed, 1268 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt.h
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.h

diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt.h 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt.h
new file mode 100644
index ..345c094760d2
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt.h
@@ -0,0 +1,91 @@
+/*
+ * cxd2880_dvbt.h
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * DVB-T related definitions
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#ifndef CXD2880_DVBT_H
+#define CXD2880_DVBT_H
+
+#include "cxd2880_common.h"
+
+enum cxd2880_dvbt_constellation {
+   CXD2880_DVBT_CONSTELLATION_QPSK,
+   CXD2880_DVBT_CONSTELLATION_16QAM,
+   CXD2880_DVBT_CONSTELLATION_64QAM,
+   CXD2880_DVBT_CONSTELLATION_RESERVED_3
+};
+
+enum cxd2880_dvbt_hierarchy {
+   CXD2880_DVBT_HIERARCHY_NON,
+   CXD2880_DVBT_HIERARCHY_1,
+   CXD2880_DVBT_HIERARCHY_2,
+   CXD2880_DVBT_HIERARCHY_4
+};
+
+enum cxd2880_dvbt_coderate {
+   CXD2880_DVBT_CODERATE_1_2,
+   CXD2880_DVBT_CODERATE_2_3,
+   CXD2880_DVBT_CODERATE_3_4,
+   CXD2880_DVBT_CODERATE_5_6,
+   CXD2880_DVBT_CODERATE_7_8,
+   CXD2880_DVBT_CODERATE_RESERVED_5,
+   CXD2880_DVBT_CODERATE_RESERVED_6,
+   CXD2880_DVBT_CODERATE_RESERVED_7
+};
+
+enum cxd2880_dvbt_guard {
+   CXD2880_DVBT_GUARD_1_32,
+   CXD2880_DVBT_GUARD_1_16,
+   CXD2880_DVBT_GUARD_1_8,
+   CXD2880_DVBT_GUARD_1_4
+};
+
+enum cxd2880_dvbt_mode {
+   CXD2880_DVBT_MODE_2K,
+   CXD2880_DVBT_MODE_8K,
+   CXD2880_DVBT_MODE_RESERVED_2,
+   CXD2880_DVBT_MODE_RESERVED_3
+};
+
+enum cxd2880_dvbt_profile {
+   CXD2880_DVBT_PROFILE_HP = 0,
+   CXD2880_DVBT_PROFILE_LP
+};
+
+struct cxd2880_dvbt_tpsinfo {
+   enum cxd2880_dvbt_constellation constellation;
+   enum cxd2880_dvbt_hierarchy hierarchy;
+   enum cxd2880_dvbt_coderate rate_hp;
+   enum cxd2880_dvbt_coderate rate_lp;
+   enum cxd2880_dvbt_guard guard;
+   enum cxd2880_dvbt_mode mode;
+   u8 fnum;
+   u8 length_indicator;
+   u16 cell_id;
+   u8 cell_id_ok;
+   u8 reserved_even;
+   u8 reserved_odd;
+};
+
+#endif
diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.c 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.c
new file mode 100644
index ..8a16cb359171
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.c
@@ -0,0 +1,1115 @@
+/*
+ * cxd2880_tnrdmd_dvbt.c
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * control functions for DVB-T
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General

[PATCH v3 07/14] [media] cxd2880: Add top level of the driver

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

This provides the main dvb frontend operation functions
for the Sony CXD2880 DVB-T2/T tuner + demodulator driver.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/cxd2880/cxd2880_top.c
  -adjusted indent spaces
  -modified debugging code
  -removed unnecessary cast
  -modified return code
  -modified coding style of if() 
  -modified about measurement period of PER/BER.
  -changed hexadecimal code to lower case. 

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 drivers/media/dvb-frontends/cxd2880/cxd2880_top.c | 1879 +
 1 file changed, 1879 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_top.c

diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_top.c 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_top.c
new file mode 100644
index ..306966dd186b
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_top.c
@@ -0,0 +1,1879 @@
+/*
+ * cxd2880_top.c
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
+
+#include 
+
+#include "dvb_frontend.h"
+#include "dvb_math.h"
+
+#include "cxd2880.h"
+#include "cxd2880_tnrdmd_mon.h"
+#include "cxd2880_tnrdmd_dvbt2_mon.h"
+#include "cxd2880_tnrdmd_dvbt_mon.h"
+#include "cxd2880_integ_dvbt2.h"
+#include "cxd2880_integ_dvbt.h"
+#include "cxd2880_devio_spi.h"
+#include "cxd2880_spi_device.h"
+#include "cxd2880_tnrdmd_driver_version.h"
+
+struct cxd2880_priv {
+   struct cxd2880_tnrdmd tnrdmd;
+   struct spi_device *spi;
+   struct cxd2880_io regio;
+   struct cxd2880_spi_device spi_device;
+   struct cxd2880_spi cxd2880_spi;
+   struct cxd2880_dvbt_tune_param dvbt_tune_param;
+   struct cxd2880_dvbt2_tune_param dvbt2_tune_param;
+   struct mutex *spi_mutex; /* For SPI access exclusive control */
+   unsigned long pre_ber_update;
+   unsigned long pre_ber_interval;
+   unsigned long post_ber_update;
+   unsigned long post_ber_interval;
+   unsigned long ucblock_update;
+   unsigned long ucblock_interval;
+};
+
+static int cxd2880_pre_bit_err_t(
+   struct cxd2880_tnrdmd *tnrdmd, u32 *pre_bit_err,
+   u32 *pre_bit_count)
+{
+   u8 rdata[2];
+   int ret = 0;
+
+   if ((!tnrdmd) || (!pre_bit_err) || (!pre_bit_count))
+   return -EINVAL;
+
+   if (tnrdmd->diver_mode == CXD2880_TNRDMD_DIVERMODE_SUB)
+   return -EINVAL;
+
+   if (tnrdmd->state != CXD2880_TNRDMD_STATE_ACTIVE)
+   return -EPERM;
+
+   if (tnrdmd->sys != CXD2880_DTV_SYS_DVBT)
+   return -EPERM;
+
+   ret = slvt_freeze_reg(tnrdmd);
+   if (ret)
+   return ret;
+
+   ret = tnrdmd->io->write_reg(tnrdmd->io,
+   CXD2880_IO_TGT_DMD,
+   0x00, 0x10);
+   if (ret) {
+   slvt_unfreeze_reg(tnrdmd);
+   return ret;
+   }
+
+   ret = tnrdmd->io->read_regs(tnrdmd->io,
+   CXD2880_IO_TGT_DMD,
+   0x39, rdata, 1);
+   if (ret) {
+   slvt_unfreeze_reg(tnrdmd);
+   return ret;
+   }
+
+   if ((rdata[0] & 0x01) == 0) {
+   slvt_unfreeze_reg(tnrdmd);
+   return -EBUSY;
+   }
+
+   ret = tnrdmd->io->read_regs(tnrdmd->io,
+   CXD2880_IO_TGT_DMD,
+   0x22, rdata, 2);
+   if (ret) {
+   slvt_unfreeze_reg(tnrdmd);
+   return ret;
+   }
+
+   *pre

[PATCH v3 06/14] [media] cxd2880: Add integration layer for the driver

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

These functions monitor the driver and watch for task completion.
This is part of the Sony CXD2880 DVB-T2/T tuner + demodulator driver.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ.c
  -changed cxd2880_atomic_read to atomic_read
  -changed cxd2880_atomic_set to atomic_set
  -modified return code
  -modified coding style of if() 
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ.h
  -modified return code

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 .../media/dvb-frontends/cxd2880/cxd2880_integ.c| 98 ++
 .../media/dvb-frontends/cxd2880/cxd2880_integ.h| 44 ++
 2 files changed, 142 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_integ.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_integ.h

diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_integ.c 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_integ.c
new file mode 100644
index ..d4516df49210
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_integ.c
@@ -0,0 +1,98 @@
+/*
+ * cxd2880_integ.c
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * integration layer common functions
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#include "cxd2880_tnrdmd.h"
+#include "cxd2880_tnrdmd_mon.h"
+#include "cxd2880_integ.h"
+
+int cxd2880_integ_init(struct cxd2880_tnrdmd *tnr_dmd)
+{
+   int ret = 0;
+   struct cxd2880_stopwatch timer;
+   unsigned int elapsed_time = 0;
+   u8 cpu_task_completed = 0;
+
+   if (!tnr_dmd)
+   return -EINVAL;
+
+   ret = cxd2880_tnrdmd_init1(tnr_dmd);
+   if (ret)
+   return ret;
+
+   ret = cxd2880_stopwatch_start(&timer);
+   if (ret)
+   return ret;
+
+   while (1) {
+   ret = cxd2880_stopwatch_elapsed(&timer, &elapsed_time);
+   if (ret)
+   return ret;
+
+   ret =
+   cxd2880_tnrdmd_check_internal_cpu_status(tnr_dmd,
+&cpu_task_completed);
+   if (ret)
+   return ret;
+
+   if (cpu_task_completed)
+   break;
+
+   if (elapsed_time > CXD2880_TNRDMD_WAIT_INIT_TIMEOUT)
+   return -ETIME;
+   ret =
+   cxd2880_stopwatch_sleep(&timer,
+   CXD2880_TNRDMD_WAIT_INIT_INTVL);
+   if (ret)
+   return ret;
+   }
+
+   ret = cxd2880_tnrdmd_init2(tnr_dmd);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
+int cxd2880_integ_cancel(struct cxd2880_tnrdmd *tnr_dmd)
+{
+   if (!tnr_dmd)
+   return -EINVAL;
+
+   atomic_set(&tnr_dmd->cancel, 1);
+
+   return 0;
+}
+
+int cxd2880_integ_check_cancellation(struct cxd2880_tnrdmd *tnr_dmd)
+{
+   if (!tnr_dmd)
+   return -EINVAL;
+
+   if (atomic_read(&tnr_dmd->cancel) != 0)
+   return -ECANCELED;
+
+   return 0;
+}
diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_integ.h 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_integ.h
new file mode 100644
index ..2b4fe5c3743b
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_integ.h
@@ -0,0 +1,44 @@
+/*
+ * cxd2880_integ.h
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * integration layer common interface
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Gener

Re: [PATCH v4 09/20] mtd: nand: qcom: support for read location registers

2017-08-15 Thread Archit Taneja



On 08/11/2017 05:09 PM, Abhishek Sahu wrote:

In EBI2, all codeword data will be read in FLASH_BUF_ACC buffer
and ADM will copy the data from source (FLASH_BUF_ACC) to
destination (memory for data read).

In QPIC, there is no FLASH_BUF_ACC and all the codeword data will
held in QPIC BAM FIFO buffers. It provides multiple READ_LOCATION
registers which will be used for copying the data from FIFO to
memory. The READ_LOCATION register will be used to read a
specific amount of data from a specific offset within the flash
buffer. It supports sequential offset requests. Each request is
composed of the following fields:

a. Offset within the flash buffer from which data should be
read
b. Amount of data to be read
c. Flag bit specifying the last read request from the flash
buffer. Following the last read request the NANDc refers to the
buffer as empty.

Signed-off-by: Abhishek Sahu 
---
  drivers/mtd/nand/qcom_nandc.c | 64 +++
  1 file changed, 64 insertions(+)

diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
index d9c8a6b..b452cfb 100644
--- a/drivers/mtd/nand/qcom_nandc.c
+++ b/drivers/mtd/nand/qcom_nandc.c
@@ -53,6 +53,8 @@
  #define   NAND_VERSION0xf08
  #define   NAND_READ_LOCATION_00xf20
  #define   NAND_READ_LOCATION_10xf24
+#defineNAND_READ_LOCATION_20xf28
+#defineNAND_READ_LOCATION_30xf2c
  
  /* dummy register offsets, used by write_reg_dma */

  #define   NAND_DEV_CMD1_RESTORE   0xdead
@@ -135,6 +137,11 @@
  #define   ERASED_PAGE (PAGE_ALL_ERASED | PAGE_ERASED)
  #define   ERASED_CW   (CODEWORD_ALL_ERASED | 
CODEWORD_ERASED)
  
+/* NAND_READ_LOCATION_n bits */

+#define READ_LOCATION_OFFSET   0
+#define READ_LOCATION_SIZE 16
+#define READ_LOCATION_LAST 31
+
  /* Version Mask */
  #define   NAND_VERSION_MAJOR_MASK 0xf000
  #define   NAND_VERSION_MAJOR_SHIFT28
@@ -177,6 +184,12 @@
  #define   ECC_BCH_4BITBIT(2)
  #define   ECC_BCH_8BITBIT(3)
  
+#define nandc_set_readl(nandc, reg, offset, size, is_last)	\


Minor nit, readl makes one think it's 'read long'. If it isn't too
much effort, could you s/nandc_set_readl/nandc_set_read_loc ?


+nandc_set_reg(nandc, NAND_READ_LOCATION_##reg, \
+ ((offset) << READ_LOCATION_OFFSET) |\
+ ((size) << READ_LOCATION_SIZE) |\
+ ((is_last) << READ_LOCATION_LAST))
+
  #define QPIC_PER_CW_CMD_SGL   32
  #define QPIC_PER_CW_DATA_SGL  8
  
@@ -260,6 +273,11 @@ struct nandc_regs {

__le32 orig_vld;
  
  	__le32 ecc_buf_cfg;

+   __le32 read_location0;
+   __le32 read_location1;
+   __le32 read_location2;
+   __le32 read_location3;
+
  };
  
  /*

@@ -516,6 +534,14 @@ static __le32 *offset_to_nandc_reg(struct nandc_regs 
*regs, int offset)
return ®s->orig_vld;
case NAND_EBI2_ECC_BUF_CFG:
return ®s->ecc_buf_cfg;
+   case NAND_READ_LOCATION_0:
+   return ®s->read_location0;
+   case NAND_READ_LOCATION_1:
+   return ®s->read_location1;
+   case NAND_READ_LOCATION_2:
+   return ®s->read_location2;
+   case NAND_READ_LOCATION_3:
+   return ®s->read_location3;
default:
return NULL;
}
@@ -590,6 +616,10 @@ static void update_rw_regs(struct qcom_nand_host *host, 
int num_cw, bool read)
nandc_set_reg(nandc, NAND_FLASH_STATUS, host->clrflashstatus);
nandc_set_reg(nandc, NAND_READ_STATUS, host->clrreadstatus);
nandc_set_reg(nandc, NAND_EXEC_CMD, 1);
+
+   if (read)
+   nandc_set_readl(nandc, 0, 0, host->use_ecc ?
+   host->cw_data : host->cw_size, 1);
  }
  
  /*

@@ -835,6 +865,10 @@ static void config_nand_page_read(struct 
qcom_nand_controller *nandc)
   */
  static void config_nand_cw_read(struct qcom_nand_controller *nandc)
  {
+   if (nandc->props->is_bam)
+   write_reg_dma(nandc, NAND_READ_LOCATION_0, 4,
+ NAND_BAM_NEXT_SGL);
+
write_reg_dma(nandc, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL);
write_reg_dma(nandc, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL);
  
@@ -923,6 +957,7 @@ static int nandc_param(struct qcom_nand_host *host)
  
  	nandc_set_reg(nandc, NAND_DEV_CMD1_RESTORE, nandc->cmd1);

nandc_set_reg(nandc, NAND_DEV_CMD_VLD_RESTORE, nandc->vld);
+   nandc_set_readl(nandc, 0, 0, 512, 1);
  
  	write_reg_dma(nandc, NAND_DEV_CMD_VLD, 1, 0);

write_reg_dma(nandc, NAND_DEV_CMD1, 1, NAND_BAM_NEXT_SGL);
@@ -1398,6 +1433,19 @@ static int read_page_ecc(struct qcom_nand_host *host, u8 
*data_buf,
oob_size = host->ecc_bytes_hw + host->spare_bytes;
}

[PATCH v3 05/14] [media] cxd2880: Add tuner part of the driver

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

This part of the driver has the main routines to handle
the tuner and demodulator functionality.  The tnrdmd_mon.* files
have monitor functions for the driver.
This is part of the Sony CXD2880 DVB-T2/T tuner + demodulator driver.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h
  -removed code relevant to ISDB-T
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.c
  -removed unnecessary cast
  -removed code relevant to ISDB-T
  -changed CXD2880_SLEEP to usleep_range
  -changed cxd2880_memset to memset 
  -changed cxd2880_atomic_set to atomic_set
  -modified return code
  -modified coding style of if()
  -changed to use const values at writing a lot of registers 
   with a command. 
  -changed hexadecimal code to lower case. 
  -adjusted of indent spaces
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.h
  -removed code relevant to ISDB-T
  -changed cxd2880_atomic struct to atomic_t
  -modified return code
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_driver_version.h
  -updated version information
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.c
  -changed CXD2880_SLEEP to usleep_range
  -removed unnecessary cast
  -modified return code
  -modified coding style of if() 
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.h
  -modified return code

Changes in V2
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_driver_version.h
  -updated version information

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h  |   46 +
 .../media/dvb-frontends/cxd2880/cxd2880_tnrdmd.c   | 4030 
 .../media/dvb-frontends/cxd2880/cxd2880_tnrdmd.h   |  391 ++
 .../cxd2880/cxd2880_tnrdmd_driver_version.h|   29 +
 .../dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.c |  221 ++
 .../dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.h |   52 +
 6 files changed, 4769 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.h
 create mode 100644 
drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_driver_version.h
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.h

diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h
new file mode 100644
index ..2d35d3990060
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h
@@ -0,0 +1,46 @@
+/*
+ * cxd2880_dtv.h
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * DTV related definitions
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#ifndef CXD2880_DTV_H
+#define CXD2880_DTV_H
+
+enum cxd2880_dtv_sys {
+   CXD2880_DTV_SYS_UNKNOWN,
+   CXD2880_DTV_SYS_DVBT,
+   CXD2880_DTV_SYS_DVBT2,
+   CXD2880_DTV_SYS_ANY
+};
+
+enum cxd2880_dtv_bandwidth {
+   CXD2880_DTV_BW_UNKNOWN = 0,
+   CXD2880_DTV_BW_1_7_MHZ = 1,
+   CXD2880_DTV_BW_5_MHZ = 5,
+   CXD2880_DTV_BW_6_MHZ = 6,
+   CXD2880_DTV_BW_7_MHZ = 7,
+   CXD2880_DTV_BW_8_MHZ = 8
+};
+
+#endif
diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.c 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.c
new file mode 100644
index ..044dc26d2ff3
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.c
@@ -0,0 +1,4030 @@

[PATCH v3 04/14] [media] cxd2880: Add spi device IO routines

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

Add functions for initializing, reading and writing to the SPI
device for the Sony CXD2880 DVB-T2/T tuner + demodulator.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/cxd2880/cxd2880_devio_spi.c
  -removed unnecessary cast
  -changed cxd2880_memcpy to memcpy
  -modified return code
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_devio_spi.h
  -modified return code
   drivers/media/dvb-frontends/cxd2880/cxd2880_spi.h
  -modified return code
   drivers/media/dvb-frontends/cxd2880/cxd2880_spi_device.c
  -removed unnecessary cast
  -modified return code
   drivers/media/dvb-frontends/cxd2880/cxd2880_spi_device.h
  -modified return code

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 .../dvb-frontends/cxd2880/cxd2880_devio_spi.c  | 146 +
 .../dvb-frontends/cxd2880/cxd2880_devio_spi.h  |  40 ++
 drivers/media/dvb-frontends/cxd2880/cxd2880_spi.h  |  51 +++
 .../dvb-frontends/cxd2880/cxd2880_spi_device.c | 130 ++
 .../dvb-frontends/cxd2880/cxd2880_spi_device.h |  43 ++
 5 files changed, 410 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_devio_spi.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_devio_spi.h
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_spi.h
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_spi_device.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_spi_device.h

diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_devio_spi.c 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_devio_spi.c
new file mode 100644
index ..2cf4fb0e4610
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_devio_spi.c
@@ -0,0 +1,146 @@
+/*
+ * cxd2880_devio_spi.c
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * I/O interface via SPI
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#include "cxd2880_devio_spi.h"
+
+#define BURST_WRITE_MAX 128
+
+static int cxd2880_io_spi_read_reg(struct cxd2880_io *io,
+  enum cxd2880_io_tgt tgt,
+  u8 sub_address, u8 *data,
+  u32 size)
+{
+   int ret = 0;
+   struct cxd2880_spi *spi = NULL;
+   u8 send_data[6];
+   u8 *read_data_top = data;
+
+   if ((!io) || (!io->if_object) || (!data))
+   return -EINVAL;
+
+   if (sub_address + size > 0x100)
+   return -ERANGE;
+
+   spi = io->if_object;
+
+   if (tgt == CXD2880_IO_TGT_SYS)
+   send_data[0] = 0x0b;
+   else
+   send_data[0] = 0x0a;
+
+   send_data[3] = 0;
+   send_data[4] = 0;
+   send_data[5] = 0;
+
+   while (size > 0) {
+   send_data[1] = sub_address;
+   if (size > 255)
+   send_data[2] = 255;
+   else
+   send_data[2] = size;
+
+   ret =
+   spi->write_read(spi, send_data, sizeof(send_data),
+   read_data_top, send_data[2]);
+   if (ret)
+   return ret;
+
+   sub_address += send_data[2];
+   read_data_top += send_data[2];
+   size -= send_data[2];
+   }
+
+   return ret;
+}
+
+static int cxd2880_io_spi_write_reg(struct cxd2880_io *io,
+   enum cxd2880_io_tgt tgt,
+   u8 sub_address,
+   const u8 *data, u32 size)
+{
+   int ret = 0;
+   struct cxd2880_spi *spi = NULL;

[PATCH v3 03/14] [media] cxd2880: Add common files for the driver

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

These are common files for the driver for the
Sony CXD2880 DVB-T2/T tuner + demodulator.
These contains helper functions for the driver.

[Change list]
Changes in V3
   drivers/media/dvb-frontends/cxd2880/cxd2880.h
  -no change
   drivers/media/dvb-frontends/cxd2880/cxd2880_common.c
  -changed MASKUPPER/MASKLOWER with GENMASK 
   drivers/media/dvb-frontends/cxd2880/cxd2880_common.h
  -removed definition NULL and SONY_SLEEP
  -changed CXD2880_SLEEP to usleep_range
  -changed cxd2880_atomic_set to atomic_set
  -removed cxd2880_atomic struct and cxd2880_atomic_read
  -changed stop-watch function
  -modified return code
   drivers/media/dvb-frontends/cxd2880/cxd2880_io.c
  -removed unnecessary cast
  -modified return code
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_io.h
  -modified return code 
   drivers/media/dvb-frontends/cxd2880/cxd2880_stopwatch_port.c
  -changed CXD2880_SLEEP to usleep_range
  -changed stop-watch function
  -modified return code
   #drivers/media/dvb-frontends/cxd2880/cxd2880_stdlib.h
  -cxd2880_stdlib.h file was removed from V3.

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 drivers/media/dvb-frontends/cxd2880/cxd2880.h  | 46 +++
 .../media/dvb-frontends/cxd2880/cxd2880_common.c   | 38 
 .../media/dvb-frontends/cxd2880/cxd2880_common.h   | 50 
 drivers/media/dvb-frontends/cxd2880/cxd2880_io.c   | 68 ++
 drivers/media/dvb-frontends/cxd2880/cxd2880_io.h   | 62 
 .../dvb-frontends/cxd2880/cxd2880_stopwatch_port.c | 60 +++
 6 files changed, 324 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880.h
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_common.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_common.h
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_io.c
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_io.h
 create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_stopwatch_port.c

diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880.h 
b/drivers/media/dvb-frontends/cxd2880/cxd2880.h
new file mode 100644
index ..281f9a784eb5
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880.h
@@ -0,0 +1,46 @@
+/*
+ * cxd2880.h
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver public definitions
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#ifndef CXD2880_H
+#define CXD2880_H
+
+struct cxd2880_config {
+   struct spi_device *spi;
+   struct mutex *spi_mutex; /* For SPI access exclusive control */
+};
+
+#if IS_REACHABLE(CONFIG_DVB_CXD2880)
+extern struct dvb_frontend *cxd2880_attach(struct dvb_frontend *fe,
+   struct cxd2880_config *cfg);
+#else
+static inline struct dvb_frontend *cxd2880_attach(struct dvb_frontend *fe,
+   struct cxd2880_config *cfg)
+{
+   pr_warn("%s: driver disabled by Kconfig\n", __func__);
+   return NULL;
+}
+#endif /* CONFIG_DVB_CXD2880 */
+
+#endif /* CXD2880_H */
diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_common.c 
b/drivers/media/dvb-frontends/cxd2880/cxd2880_common.c
new file mode 100644
index ..ffaa140bb8cb
--- /dev/null
+++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_common.c
@@ -0,0 +1,38 @@
+/*
+ * cxd2880_common.c
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * common functions
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify

[PATCH v3 02/14] [media] cxd2880-spi: Add support for CXD2880 SPI interface

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

This is the SPI adapter part of the driver for the
Sony CXD2880 DVB-T2/T tuner + demodulator.

[Change list]
Changes in V3
   drivers/media/spi/cxd2880-spi.c
  -adjusted of indent spaces
  -removed unnecessary cast
  -changed debugging code
  -changed timeout method
  -modified coding style of if()
  -changed hexadecimal code to lower case. 

Changes in V2
   drivers/media/spi/cxd2880-spi.c
  -Modified PID filter setting.

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 drivers/media/spi/cxd2880-spi.c | 697 
 1 file changed, 697 insertions(+)
 create mode 100644 drivers/media/spi/cxd2880-spi.c

diff --git a/drivers/media/spi/cxd2880-spi.c b/drivers/media/spi/cxd2880-spi.c
new file mode 100644
index ..961b94daab38
--- /dev/null
+++ b/drivers/media/spi/cxd2880-spi.c
@@ -0,0 +1,697 @@
+/*
+ * cxd2880-spi.c
+ * Sony CXD2880 DVB-T2/T tuner + demodulator driver
+ * SPI adapter
+ *
+ * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; version 2 of the License.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
+
+#include 
+#include 
+
+#include "dvb_demux.h"
+#include "dmxdev.h"
+#include "dvb_frontend.h"
+#include "cxd2880.h"
+
+#define CXD2880_MAX_FILTER_SIZE 32
+#define BURST_WRITE_MAX 128
+#define MAX_TRANS_PACKET 300
+
+struct cxd2880_ts_buf_info {
+   u8 read_ready;
+   u8 almost_full;
+   u8 almost_empty;
+   u8 overflow;
+   u8 underflow;
+   u16 packet_num;
+};
+
+struct cxd2880_pid_config {
+   u8 is_enable;
+   u16 pid;
+};
+
+struct cxd2880_pid_filter_config {
+   u8 is_negative;
+   struct cxd2880_pid_config pid_config[CXD2880_MAX_FILTER_SIZE];
+};
+
+struct cxd2880_dvb_spi {
+   struct dvb_frontend dvb_fe;
+   struct dvb_adapter adapter;
+   struct dvb_demux demux;
+   struct dmxdev dmxdev;
+   struct dmx_frontend dmx_fe;
+   struct task_struct *cxd2880_ts_read_thread;
+   struct spi_device *spi;
+   struct mutex spi_mutex; /* For SPI access exclusive control */
+   int feed_count;
+   int all_pid_feed_count;
+   u8 *ts_buf;
+   struct cxd2880_pid_filter_config filter_config;
+};
+
+DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
+
+static int cxd2880_write_spi(struct spi_device *spi, u8 *data, u32 size)
+{
+   struct spi_message msg;
+   struct spi_transfer tx;
+   int ret = 0;
+
+   if ((!spi) || (!data)) {
+   pr_err("invalid arg\n");
+   return -EINVAL;
+   }
+
+   memset(&tx, 0, sizeof(tx));
+   tx.tx_buf = data;
+   tx.len = size;
+
+   spi_message_init(&msg);
+   spi_message_add_tail(&tx, &msg);
+   ret = spi_sync(spi, &msg);
+
+   return ret;
+}
+
+static int cxd2880_write_reg(struct spi_device *spi,
+u8 subAddress, const u8 *data, u32 size)
+{
+   u8 send_data[BURST_WRITE_MAX + 4];
+   const u8 *write_data_top = NULL;
+   int ret = 0;
+
+   if ((!spi) || (!data)) {
+   pr_err("invalid arg\n");
+   return -EINVAL;
+   }
+   if (size > BURST_WRITE_MAX) {
+   pr_err("data size > WRITE_MAX\n");
+   return -EINVAL;
+   }
+
+   if (subAddress + size > 0x100) {
+   pr_err("out of range\n");
+   return -EINVAL;
+   }
+
+   send_data[0] = 0x0e;
+   write_data_top = data;
+
+   while (size > 0) {
+   send_data[1] = subAddress;
+   if (size > 255)
+   send_data[2] = 255;
+   else
+   send_data[2] = (u8)size;
+
+   memcpy(&send_data[3], write_data_top, send_data[2]);
+
+   r

[PATCH v3 01/14] [dt-bindings] [media] Add document file for CXD2880 SPI I/F

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

This is the document file for Sony CXD2880 DVB-T2/T tuner + demodulator.
It contains the description of the SPI adapter binding.

No change since version 1. I should have carried the ack forward:
Acked-by: Rob Herring 

Signed-off-by: Yasunari Takiguchi 
Signed-off-by: Masayuki Yamamoto 
Signed-off-by: Hideki Nozawa 
Signed-off-by: Kota Yonezawa 
Signed-off-by: Toshihiko Matsumoto 
Signed-off-by: Satoshi Watanabe 
---
 .../devicetree/bindings/media/spi/sony-cxd2880.txt | 14 ++
 1 file changed, 14 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/spi/sony-cxd2880.txt

diff --git a/Documentation/devicetree/bindings/media/spi/sony-cxd2880.txt 
b/Documentation/devicetree/bindings/media/spi/sony-cxd2880.txt
new file mode 100644
index ..fc5aa263abe5
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/spi/sony-cxd2880.txt
@@ -0,0 +1,14 @@
+Sony CXD2880 DVB-T2/T tuner + demodulator driver SPI adapter
+
+Required properties:
+- compatible: Should be "sony,cxd2880".
+- reg: SPI chip select number for the device.
+- spi-max-frequency: Maximum bus speed, should be set to <5500> (55MHz).
+
+Example:
+
+cxd2880@0 {
+   compatible = "sony,cxd2880";
+   reg = <0>; /* CE0 */
+   spi-max-frequency = <5500>; /* 55MHz */
+};
-- 
2.13.0



Re: [PATCH v4 08/20] mtd: nand: qcom: support for passing flags in transfer functions

2017-08-15 Thread Archit Taneja



On 08/11/2017 05:09 PM, Abhishek Sahu wrote:

The BAM has multiple flags to control the transfer. This patch
adds flags parameter in register and data transfer functions and
modifies all these functions call with appropriate flags using
following rule

1. Read and write can’t go in single command descriptor so
separate SGL should be used.
2. For some of the requests, NWD flag should be set in BAM
DMA descriptor.
3. For Data write, the BAM has internal buffer for each codeword.
All write request will modify the data in internal buffer and
this buffer will be flushed to NAND device once EOT flag is set.
So for all the write requests in single codeword, the EOT should
be cleared for all tx data descriptors except the last one.

Signed-off-by: Abhishek Sahu 
---
  drivers/mtd/nand/qcom_nandc.c | 122 --
  1 file changed, 70 insertions(+), 52 deletions(-)

diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
index f52a692..d9c8a6b 100644
--- a/drivers/mtd/nand/qcom_nandc.c
+++ b/drivers/mtd/nand/qcom_nandc.c
@@ -180,6 +180,14 @@
  #define QPIC_PER_CW_CMD_SGL   32
  #define QPIC_PER_CW_DATA_SGL  8
  
+/* Flags used for BAM DMA desc preparation*/

+/* Don't set the EOT in current tx sgl */
+#define NAND_BAM_NO_EOTBIT(0)
+/* Set the NWD flag in current sgl */
+#define NAND_BAM_NWD   BIT(1)
+/* Finish writing in the current sgl and start writing in another sgl */
+#define NAND_BAM_NEXT_SGL  BIT(2)
+
  /*
   * This data type corresponds to the BAM transaction which will be used for 
all
   * NAND transfers.
@@ -731,7 +739,7 @@ static int prep_adm_dma_desc(struct qcom_nand_controller 
*nandc, bool read,
   * @num_regs: number of registers to read


Minor comment: the read_reg_dma/write_reg/read_data/write_data_dma funcs add a 
new arg, so it
would be nice to update the comment describing the function and its arguments. 
It would also
be nice to mention that the flags are presently used only for controllers using 
BAM.

With that,

Reviewed-by: Archit Taneja 

Thanks,
Archit


   */
  static int read_reg_dma(struct qcom_nand_controller *nandc, int first,
-   int num_regs)
+   int num_regs, unsigned int flags)
  {
bool flow_control = false;
void *vaddr;
@@ -755,7 +763,7 @@ static int read_reg_dma(struct qcom_nand_controller *nandc, 
int first,
   * @num_regs: number of registers to write
   */
  static int write_reg_dma(struct qcom_nand_controller *nandc, int first,
-int num_regs)
+int num_regs, unsigned int flags)
  {
bool flow_control = false;
struct nandc_regs *regs = nandc->regs;
@@ -767,6 +775,9 @@ static int write_reg_dma(struct qcom_nand_controller 
*nandc, int first,
if (first == NAND_FLASH_CMD)
flow_control = true;
  
+	if (first == NAND_EXEC_CMD)

+   flags |= NAND_BAM_NWD;
+
if (first == NAND_DEV_CMD1_RESTORE)
first = NAND_DEV_CMD1;
  
@@ -788,7 +799,7 @@ static int write_reg_dma(struct qcom_nand_controller *nandc, int first,

   * @size: DMA transaction size in bytes
   */
  static int read_data_dma(struct qcom_nand_controller *nandc, int reg_off,
-const u8 *vaddr, int size)
+const u8 *vaddr, int size, unsigned int flags)
  {
return prep_adm_dma_desc(nandc, true, reg_off, vaddr, size, false);
  }
@@ -802,7 +813,7 @@ static int read_data_dma(struct qcom_nand_controller 
*nandc, int reg_off,
   * @size: DMA transaction size in bytes
   */
  static int write_data_dma(struct qcom_nand_controller *nandc, int reg_off,
- const u8 *vaddr, int size)
+ const u8 *vaddr, int size, unsigned int flags)
  {
return prep_adm_dma_desc(nandc, false, reg_off, vaddr, size, false);
  }
@@ -813,9 +824,9 @@ static int write_data_dma(struct qcom_nand_controller 
*nandc, int reg_off,
   */
  static void config_nand_page_read(struct qcom_nand_controller *nandc)
  {
-   write_reg_dma(nandc, NAND_ADDR0, 2);
-   write_reg_dma(nandc, NAND_DEV0_CFG0, 3);
-   write_reg_dma(nandc, NAND_EBI2_ECC_BUF_CFG, 1);
+   write_reg_dma(nandc, NAND_ADDR0, 2, 0);
+   write_reg_dma(nandc, NAND_DEV0_CFG0, 3, 0);
+   write_reg_dma(nandc, NAND_EBI2_ECC_BUF_CFG, 1, 0);
  }
  
  /*

@@ -824,11 +835,12 @@ static void config_nand_page_read(struct 
qcom_nand_controller *nandc)
   */
  static void config_nand_cw_read(struct qcom_nand_controller *nandc)
  {
-   write_reg_dma(nandc, NAND_FLASH_CMD, 1);
-   write_reg_dma(nandc, NAND_EXEC_CMD, 1);
+   write_reg_dma(nandc, NAND_FLASH_CMD, 1, NAND_BAM_NEXT_SGL);
+   write_reg_dma(nandc, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL);
  
-	read_reg_dma(nandc, NAND_FLASH_STATUS, 2);

-   read_reg_dma(nandc, N

Re: linux-next: manual merge of the akpm-current tree with the tip tree

2017-08-15 Thread Minchan Kim
On Mon, Aug 14, 2017 at 09:57:23PM +0200, Peter Zijlstra wrote:
> On Mon, Aug 14, 2017 at 05:38:39PM +0900, Minchan Kim wrote:
> > memory-barrier.txt always scares me. I have read it for a while
> > and IIUC, it seems semantic of spin_unlock(&same_pte) would be
> > enough without some memory-barrier inside mm_tlb_flush_nested.
> 
> Indeed, see the email I just send. Its both spin_lock() and
> spin_unlock() that we care about.
> 
> Aside from the semi permeable barrier of these primitives, RCpc ensures
> these orderings only work against the _same_ lock variable.
> 
> Let me try and explain the ordering for PPC (which is by far the worst
> we have in this regard):
> 
> 
> spin_lock(lock)
> {
>   while (test_and_set(lock))
>   cpu_relax();
>   lwsync();
> }
> 
> 
> spin_unlock(lock)
> {
>   lwsync();
>   clear(lock);
> }
> 
> Now LWSYNC has fairly 'simple' semantics, but with fairly horrible
> ramifications. Consider LWSYNC to provide _local_ TSO ordering, this
> means that it allows 'stores reordered after loads'.
> 
> For the spin_lock() that implies that all load/store's inside the lock
> do indeed stay in, but the ACQUIRE is only on the LOAD of the
> test_and_set(). That is, the actual _set_ can leak in. After all it can
> re-order stores after load (inside the lock).
> 
> For unlock it again means all load/store's prior stay prior, and the
> RELEASE is on the store clearing the lock state (nothing surprising
> here).
> 
> Now the _local_ part, the main take-away is that these orderings are
> strictly CPU local. What makes the spinlock work across CPUs (as we'd
> very much expect it to) is the address dependency on the lock variable.
> 
> In order for the spin_lock() to succeed, it must observe the clear. Its
> this link that crosses between the CPUs and builds the ordering. But
> only the two CPUs agree on this order. A third CPU not involved in
> this transaction can disagree on the order of events.

The detail explanation in your previous reply makes me comfortable
from scary memory-barrier.txt but this reply makes me scared again. ;-)

Thanks for the kind clarification, Peter!



[PATCH v3 00/14] [dt-bindings] [media] Add document file and driver for Sony CXD2880 DVB-T2/T tuner + demodulator

2017-08-15 Thread Yasunari.Takiguchi
From: Yasunari Takiguchi 

Hi,

This is the patch series (version 3) of Sony CXD2880 DVB-T2/T tuner + 
demodulator driver.
The driver supports DVB-API and interfaces through SPI.

We have tested the driver on Raspberry Pi 3 and got picture and sound from a 
media player.

The change history of this patch series is as below.

[Change list]
Changes in V3
(1)Total patch number was changed from 15 to 14,
   due to the all files of [PATCH v2 04/15] were removed.
   drivers/media/dvb-frontends/cxd2880/cxd2880_math.c
  -Removed
   drivers/media/dvb-frontends/cxd2880/cxd2880_math.h
  -Removed

(2)Removed another file.
   drivers/media/dvb-frontends/cxd2880/cxd2880_stdlib.h
  -Removed 

(3)The detail change items of each files are as below.
[PATCH v3 01/14]
   Documentation/devicetree/bindings/media/spi/sony-cxd2880.txt
  -no change
[PATCH v3 02/14]
   drivers/media/spi/cxd2880-spi.c
  -adjusted of indent spaces
  -removed unnecessary cast
  -changed debugging code
  -changed timeout method
  -modified coding style of if()
  -changed hexadecimal code to lower case. 
[PATCH v3 03/14]
   drivers/media/dvb-frontends/cxd2880/cxd2880.h
  -no change
   drivers/media/dvb-frontends/cxd2880/cxd2880_common.c
  -changed MASKUPPER/MASKLOWER with GENMASK 
   drivers/media/dvb-frontends/cxd2880/cxd2880_common.h
  -removed definition NULL and SONY_SLEEP
  -changed CXD2880_SLEEP to usleep_range
  -changed cxd2880_atomic_set to atomic_set
  -removed cxd2880_atomic struct and cxd2880_atomic_read
  -changed stop-watch function
  -modified return code
   drivers/media/dvb-frontends/cxd2880/cxd2880_io.c
  -removed unnecessary cast
  -modified return code
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_io.h
  -modified return code 
   drivers/media/dvb-frontends/cxd2880/cxd2880_stopwatch_port.c
  -changed CXD2880_SLEEP to usleep_range
  -changed stop-watch function
  -modified return code
   #drivers/media/dvb-frontends/cxd2880/cxd2880_stdlib.h
  -cxd2880_stdlib.h file was removed from V3.
[PATCH v3 04/14]
   drivers/media/dvb-frontends/cxd2880/cxd2880_devio_spi.c
  -removed unnecessary cast
  -changed cxd2880_memcpy to memcpy
  -modified return code
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_devio_spi.h
  -modified return code
   drivers/media/dvb-frontends/cxd2880/cxd2880_spi.h
  -modified return code
   drivers/media/dvb-frontends/cxd2880/cxd2880_spi_device.c
  -removed unnecessary cast
  -modified return code
   drivers/media/dvb-frontends/cxd2880/cxd2880_spi_device.h
  -modified return code
[PATCH v3 05/14]
   drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h
  -removed code relevant to ISDB-T
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.c
  -removed unnecessary cast
  -removed code relevant to ISDB-T
  -changed CXD2880_SLEEP to usleep_range
  -changed cxd2880_memset to memset 
  -changed cxd2880_atomic_set to atomic_set
  -modified return code
  -modified coding style of if()
  -changed to use const values at writing a lot of registers 
   with a command. 
  -changed hexadecimal code to lower case. 
  -adjusted of indent spaces
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.h
  -removed code relevant to ISDB-T
  -changed cxd2880_atomic struct to atomic_t
  -modified return code
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_driver_version.h
  -updated version information
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.c
  -changed CXD2880_SLEEP to usleep_range
  -removed unnecessary cast
  -modified return code
  -modified coding style of if() 
  -changed hexadecimal code to lower case. 
   drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.h
  -modified return code
[PATCH v3 06/14]
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ.c
  -changed cxd2880_atomic_read to atomic_read
  -changed cxd2880_atomic_set to atomic_set
  -modified return code
  -modified coding style of if() 
   drivers/media/dvb-frontends/cxd2880/cxd2880_integ.h
  -modified return code
[PATCH v3 07/14]
   drivers/media/dvb-frontends/cxd2880/cxd2880_top.c
  -adjusted indent spaces
  -modified debugging code
  -removed unnecessary cast
  -modified return code
  -modified coding style of if() 
  -modified about measureme

Re: [PATCH net-next V2 1/3] tap: use build_skb() for small packet

2017-08-15 Thread Jason Wang



On 2017年08月16日 11:59, Michael S. Tsirkin wrote:

On Wed, Aug 16, 2017 at 11:57:51AM +0800, Jason Wang wrote:


On 2017年08月16日 11:55, Michael S. Tsirkin wrote:

On Tue, Aug 15, 2017 at 08:45:20PM -0700, Eric Dumazet wrote:

On Fri, 2017-08-11 at 19:41 +0800, Jason Wang wrote:

We use tun_alloc_skb() which calls sock_alloc_send_pskb() to allocate
skb in the past. This socket based method is not suitable for high
speed userspace like virtualization which usually:

- ignore sk_sndbuf (INT_MAX) and expect to receive the packet as fast as
possible
- don't want to be block at sendmsg()

To eliminate the above overheads, this patch tries to use build_skb()
for small packet. We will do this only when the following conditions
are all met:

- TAP instead of TUN
- sk_sndbuf is INT_MAX
- caller don't want to be blocked
- zerocopy is not used
- packet size is smaller enough to use build_skb()

Pktgen from guest to host shows ~11% improvement for rx pps of tap:

Before: ~1.70Mpps
After : ~1.88Mpps

What's more important, this makes it possible to implement XDP for tap
before creating skbs.

Well well well.

You do realize that tun_build_skb() is not thread safe ?

The issue is alloc frag, isn't it?
I guess for now we can limit this to XDP mode only, and
just allocate full pages in that mode.



Limit this to XDP mode only does not prevent user from sending packets to
same queue in parallel I think?

Thanks

Yes but then you can just drop the page frag allocator since
XDP is assumed not to care about truesize for most packets.



Ok, let me do some test to see the numbers between the two methods first.

Thanks


Re: [PATCH v8 00/14] lockdep: Implement crossrelease feature

2017-08-15 Thread Boqun Feng
On Wed, Aug 16, 2017 at 09:16:37AM +0900, Byungchul Park wrote:
> On Tue, Aug 15, 2017 at 10:20:20AM +0200, Ingo Molnar wrote:
> > 
> > So with the latest fixes there's a new lockdep warning on one of my 
> > testboxes:
> > 
> > [   11.322487] EXT4-fs (sda2): mounted filesystem with ordered data mode. 
> > Opts: (null)
> > 
> > [   11.495661] ==
> > [   11.502093] WARNING: possible circular locking dependency detected
> > [   11.508507] 4.13.0-rc5-00497-g73135c58-dirty #1 Not tainted
> > [   11.514313] --
> > [   11.520725] umount/533 is trying to acquire lock:
> > [   11.525657]  ((complete)&barr->done){+.+.}, at: [] 
> > flush_work+0x213/0x2f0
> > [   11.534411] 
> >but task is already holding lock:
> > [   11.540661]  (lock#3){+.+.}, at: [] 
> > lru_add_drain_all_cpuslocked+0x3d/0x190
> > [   11.549613] 
> >which lock already depends on the new lock.
> > 
> > The full splat is below. The kernel config is nothing fancy - distro 
> > derived, 
> > pretty close to defconfig, with lockdep enabled.
> 
> I see...
> 
> Worker A : acquired of wfc.work -> wait for cpu_hotplug_lock to be released
> Task   B : acquired of cpu_hotplug_lock -> wait for lock#3 to be released
> Task   C : acquired of lock#3 -> wait for completion of barr->done

>From the stack trace below, this barr->done is for flush_work() in
lru_add_drain_all_cpuslocked(), i.e. for work "per_cpu(lru_add_drain_work)"

> Worker D : wait for wfc.work to be released -> will complete barr->done

and this barr->done is for work "wfc.work".

So those two barr->done could not be the same instance, IIUC. Therefore
the deadlock case is not possible.

The problem here is all barr->done instances are initialized at
insert_wq_barrier() and they belongs to the same lock class, to fix
this, we need to differ barr->done with different lock classes based on
the corresponding works.

How about the this(only compilation test):

->8
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index e86733a8b344..d14067942088 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2431,6 +2431,27 @@ struct wq_barrier {
struct task_struct  *task;  /* purely informational */
 };
 
+#ifdef CONFIG_LOCKDEP_COMPLETE
+# define INIT_WQ_BARRIER_ONSTACK(barr, func, target)   
\
+do {   
\
+   INIT_WORK_ONSTACK(&(barr)->work, func); 
\
+   __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&(barr)->work));  
\
+   lockdep_init_map_crosslock((struct lockdep_map *)&(barr)->done.map, 
\
+  "(complete)" #barr,  
\
+  (target)->lockdep_map.key, 1);   
\
+   __init_completion(&barr->done); 
\
+   barr->task = current;   
\
+} while (0)
+#else
+# define INIT_WQ_BARRIER_ONSTACK(barr, func, target)   
\
+do {   
\
+   INIT_WORK_ONSTACK(&(barr)->work, func); 
\
+   __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&(barr)->work));  
\
+   init_completion(&barr->done);   
\
+   barr->task = current;   
\
+} while (0)
+#endif
+
 static void wq_barrier_func(struct work_struct *work)
 {
struct wq_barrier *barr = container_of(work, struct wq_barrier, work);
@@ -2474,10 +2495,7 @@ static void insert_wq_barrier(struct pool_workqueue *pwq,
 * checks and call back into the fixup functions where we
 * might deadlock.
 */
-   INIT_WORK_ONSTACK(&barr->work, wq_barrier_func);
-   __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&barr->work));
-   init_completion(&barr->done);
-   barr->task = current;
+   INIT_WQ_BARRIER_ONSTACK(barr, wq_barrier_func, target);
 
/*
 * If @target is currently being executed, schedule the


Re: [PATCH 1/2] x86/idle: add halt poll for halt idle

2017-08-15 Thread Michael S. Tsirkin
On Thu, Jun 22, 2017 at 11:22:13AM +, root wrote:
> From: Yang Zhang 
> 
> This patch introduce a new mechanism to poll for a while before
> entering idle state.
> 
> David has a topic in KVM forum to describe the problem on current KVM VM
> when running some message passing workload in KVM forum. Also, there
> are some work to improve the performance in KVM, like halt polling in KVM.
> But we still has 4 MSR wirtes and HLT vmexit when going into halt idle
> which introduce lot of latency.
> 
> Halt polling in KVM provide the capbility to not schedule out VCPU when
> it is the only task in this pCPU. Unlike it, this patch will let VCPU polls
> for a while if there is no work inside VCPU to elimiate heavy vmexit during
> in/out idle. The potential impact is it will cost more CPU cycle since we
> are doing polling and may impact other task which waiting on the same
> physical CPU in host.

I wonder whether you considered doing this in an idle driver.
I have a prototype patch combining this with mwait within guest -
I can post it if you are interested.


> Here is the data i get when running benchmark contextswitch
> (https://github.com/tsuna/contextswitch)
> 
> before patch:
> 200 process context switches in 4822613801ns (2411.3ns/ctxsw)
> 
> after patch:
> 200 process context switches in 3584098241ns (1792.0ns/ctxsw)
> 
> Signed-off-by: Yang Zhang 
> ---
>  Documentation/sysctl/kernel.txt | 10 ++
>  arch/x86/kernel/process.c   | 21 +
>  include/linux/kernel.h  |  3 +++
>  kernel/sched/idle.c |  3 +++
>  kernel/sysctl.c |  9 +
>  5 files changed, 46 insertions(+)
> 
> diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
> index bac23c1..4e71bfe 100644
> --- a/Documentation/sysctl/kernel.txt
> +++ b/Documentation/sysctl/kernel.txt
> @@ -63,6 +63,7 @@ show up in /proc/sys/kernel:
>  - perf_event_max_stack
>  - perf_event_max_contexts_per_stack
>  - pid_max
> +- poll_threshold_ns[ X86 only ]
>  - powersave-nap   [ PPC only ]
>  - printk
>  - printk_delay
> @@ -702,6 +703,15 @@ kernel tries to allocate a number starting from this one.
>  
>  ==
>  
> +poll_threshold_ns: (X86 only)
> +
> +This parameter used to control the max wait time to poll before going
> +into real idle state. By default, the values is 0 means don't poll.
> +It is recommended to change the value to non-zero if running latency-bound
> +workloads in VM.
> +
> +==
> +
>  powersave-nap: (PPC only)
>  
>  If set, Linux-PPC will use the 'nap' mode of powersaving,
> diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
> index 0bb8842..6361783 100644
> --- a/arch/x86/kernel/process.c
> +++ b/arch/x86/kernel/process.c
> @@ -39,6 +39,10 @@
>  #include 
>  #include 
>  
> +#ifdef CONFIG_HYPERVISOR_GUEST
> +unsigned long poll_threshold_ns;
> +#endif
> +
>  /*
>   * per-CPU TSS segments. Threads are completely 'soft' on Linux,
>   * no more per-task TSS's. The TSS size is kept cacheline-aligned
> @@ -313,6 +317,23 @@ static inline void play_dead(void)
>  }
>  #endif
>  
> +#ifdef CONFIG_HYPERVISOR_GUEST
> +void arch_cpu_idle_poll(void)
> +{
> + ktime_t start, cur, stop;
> +
> + if (poll_threshold_ns) {
> + start = cur = ktime_get();
> + stop = ktime_add_ns(ktime_get(), poll_threshold_ns);
> + do {
> + if (need_resched())
> + break;
> + cur = ktime_get();
> + } while (ktime_before(cur, stop));
> + }
> +}
> +#endif
> +
>  void arch_cpu_idle_enter(void)
>  {
>   tsc_verify_tsc_adjust(false);
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index 13bc08a..04cf774 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -460,6 +460,9 @@ extern __scanf(2, 0)
>  extern int sysctl_panic_on_stackoverflow;
>  
>  extern bool crash_kexec_post_notifiers;
> +#ifdef CONFIG_HYPERVISOR_GUEST
> +extern unsigned long poll_threshold_ns;
> +#endif
>  
>  /*
>   * panic_cpu is used for synchronizing panic() and crash_kexec() execution. 
> It
> diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
> index 2a25a9e..e789f99 100644
> --- a/kernel/sched/idle.c
> +++ b/kernel/sched/idle.c
> @@ -74,6 +74,7 @@ static noinline int __cpuidle cpu_idle_poll(void)
>  }
>  
>  /* Weak implementations for optional arch specific functions */
> +void __weak arch_cpu_idle_poll(void) { }
>  void __weak arch_cpu_idle_prepare(void) { }
>  void __weak arch_cpu_idle_enter(void) { }
>  void __weak arch_cpu_idle_exit(void) { }
> @@ -219,6 +220,8 @@ static void do_idle(void)
>*/
>  
>   __current_set_polling();
> + arch_cpu_idle_poll();
> +
>   tick_nohz_idle_enter();
>  
>   while (!need_resched()) {
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
>

Re: [PATCH v3] zsmalloc: zs_page_migrate: schedule free_work if zspage is ZS_EMPTY

2017-08-15 Thread Minchan Kim
On Wed, Aug 16, 2017 at 11:19:41AM +0800, Hui Zhu wrote:
> After commit [1] zs_page_migrate can handle the ZS_EMPTY zspage.
> 
> But I got some false in zs_page_isolate:
>   if (get_zspage_inuse(zspage) == 0) {
>   spin_unlock(&class->lock);
>   return false;
>   }
> The page of this zspage was migrated in before.
> 
> The reason is commit [1] just handle the "page" but not "newpage"
> then it keep the "newpage" with a empty zspage inside system.
> Root cause is zs_page_isolate remove it from ZS_EMPTY list but not
> call zs_page_putback "schedule_work(&pool->free_work);".  Because
> zs_page_migrate done the job without "schedule_work(&pool->free_work);"
> 
> Make this patch let zs_page_migrate wake up free_work if need.
> 
> [1] 
> zsmalloc-zs_page_migrate-skip-unnecessary-loops-but-not-return-ebusy-if-zspage-is-not-inuse-fix.patch
> 
> Signed-off-by: Hui Zhu 
Acked-by: Minchan Kim 

Thanks!


Re: [PATCH 0/5] Add clk and scpsys support for MT6755

2017-08-15 Thread Mars Cheng
Hi Rob, Stephen, Matthias

gentle ping.

Thanks.

On Tue, 2017-08-08 at 16:13 +0800, Mars Cheng wrote:
> Mars Cheng (3):
>   clk: mediatek: add mt6755 clock ID
>   clk: mediatek: add clk support for MT6755
>   soc: mediatek: add MT6755 scpsys support
> 
> wendell.lin (2):
>   dt-bindings: mediatek: add MT6755 power dt-bindings
>   dt-bindings: arm: mediatek: document clk bindings for MT6755
> 
>  .../bindings/arm/mediatek/mediatek,apmixedsys.txt  |1 +
>  .../bindings/arm/mediatek/mediatek,imgsys.txt  |1 +
>  .../bindings/arm/mediatek/mediatek,infracfg.txt|1 +
>  .../bindings/arm/mediatek/mediatek,mmsys.txt   |1 +
>  .../bindings/arm/mediatek/mediatek,topckgen.txt|1 +
>  .../bindings/arm/mediatek/mediatek,vdecsys.txt |1 +
>  .../bindings/arm/mediatek/mediatek,vencsys.txt |1 +
>  .../devicetree/bindings/soc/mediatek/scpsys.txt|3 +
>  drivers/clk/mediatek/Kconfig   |   32 +
>  drivers/clk/mediatek/Makefile  |5 +
>  drivers/clk/mediatek/clk-mt6755-img.c  |   81 +++
>  drivers/clk/mediatek/clk-mt6755-mm.c   |  148 +
>  drivers/clk/mediatek/clk-mt6755-vdec.c |   91 +++
>  drivers/clk/mediatek/clk-mt6755-venc.c |   78 +++
>  drivers/clk/mediatek/clk-mt6755.c  |  666 
> 
>  drivers/soc/mediatek/mtk-scpsys.c  |  116 
>  include/dt-bindings/clock/mt6755-clk.h |  293 +
>  include/dt-bindings/power/mt6755-power.h   |   26 +
>  18 files changed, 1546 insertions(+)
>  create mode 100644 drivers/clk/mediatek/clk-mt6755-img.c
>  create mode 100644 drivers/clk/mediatek/clk-mt6755-mm.c
>  create mode 100644 drivers/clk/mediatek/clk-mt6755-vdec.c
>  create mode 100644 drivers/clk/mediatek/clk-mt6755-venc.c
>  create mode 100644 drivers/clk/mediatek/clk-mt6755.c
>  create mode 100644 include/dt-bindings/clock/mt6755-clk.h
>  create mode 100644 include/dt-bindings/power/mt6755-power.h
> 
> 




Re: [PATCH net-next V2 1/3] tap: use build_skb() for small packet

2017-08-15 Thread Michael S. Tsirkin
On Wed, Aug 16, 2017 at 11:57:51AM +0800, Jason Wang wrote:
> 
> 
> On 2017年08月16日 11:55, Michael S. Tsirkin wrote:
> > On Tue, Aug 15, 2017 at 08:45:20PM -0700, Eric Dumazet wrote:
> > > On Fri, 2017-08-11 at 19:41 +0800, Jason Wang wrote:
> > > > We use tun_alloc_skb() which calls sock_alloc_send_pskb() to allocate
> > > > skb in the past. This socket based method is not suitable for high
> > > > speed userspace like virtualization which usually:
> > > > 
> > > > - ignore sk_sndbuf (INT_MAX) and expect to receive the packet as fast as
> > > >possible
> > > > - don't want to be block at sendmsg()
> > > > 
> > > > To eliminate the above overheads, this patch tries to use build_skb()
> > > > for small packet. We will do this only when the following conditions
> > > > are all met:
> > > > 
> > > > - TAP instead of TUN
> > > > - sk_sndbuf is INT_MAX
> > > > - caller don't want to be blocked
> > > > - zerocopy is not used
> > > > - packet size is smaller enough to use build_skb()
> > > > 
> > > > Pktgen from guest to host shows ~11% improvement for rx pps of tap:
> > > > 
> > > > Before: ~1.70Mpps
> > > > After : ~1.88Mpps
> > > > 
> > > > What's more important, this makes it possible to implement XDP for tap
> > > > before creating skbs.
> > > Well well well.
> > > 
> > > You do realize that tun_build_skb() is not thread safe ?
> > The issue is alloc frag, isn't it?
> > I guess for now we can limit this to XDP mode only, and
> > just allocate full pages in that mode.
> > 
> > 
> 
> Limit this to XDP mode only does not prevent user from sending packets to
> same queue in parallel I think?
> 
> Thanks

Yes but then you can just drop the page frag allocator since
XDP is assumed not to care about truesize for most packets.

-- 
MST


  1   2   3   4   5   6   7   8   9   >