Re: rtc: isl1208: avoid possible sysfs race

2018-09-24 Thread Denis OSTERLAND
Hi,

just for clarification:
This changes user-space representation from
/sys/class/rtc/rtcN/device/{atrim,dtrim,usr}
to
/sys/class/rtc/rtcN/{atrim,dtrim,usr}
and fixes the "mistake made back in 2006" you mention in
https://patchwork.ozlabs.org/patch/881397/
correct?

Regards Denis

Am Samstag, den 15.09.2018, 13:43 +0200 schrieb Alexandre Belloni:
> Use rtc_add_group to add the common sysfs group to avoid a possible race
> condition.
> 
> Signed-off-by: Alexandre Belloni 
> ---
>  drivers/rtc/rtc-isl1208.c | 11 +--
>  1 file changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
> index ea18a8f4bce0..e1e9434c9972 100644
> --- a/drivers/rtc/rtc-isl1208.c
> +++ b/drivers/rtc/rtc-isl1208.c
> @@ -804,7 +804,7 @@ isl1208_probe(struct i2c_client *client, const struct 
> i2c_device_id *id)
>   evdet_irq = of_irq_get_byname(np, "evdet");
>   }
>  
> - rc = sysfs_create_group(&client->dev.kobj, &isl1208_rtc_sysfs_files);
> + rc = rtc_add_group(rtc, &isl1208_rtc_sysfs_files);
>   if (rc)
>   return rc;
>  
> @@ -821,14 +821,6 @@ isl1208_probe(struct i2c_client *client, const struct 
> i2c_device_id *id)
>   return rtc_register_device(rtc);
>  }
>  
> -static int
> -isl1208_remove(struct i2c_client *client)
> -{
> - sysfs_remove_group(&client->dev.kobj, &isl1208_rtc_sysfs_files);
> -
> - return 0;
> -}
> -
>  static const struct i2c_device_id isl1208_id[] = {
>   { "isl1208", TYPE_ISL1208 },
>   { "isl1218", TYPE_ISL1218 },
> @@ -851,7 +843,6 @@ static struct i2c_driver isl1208_driver = {
>   .of_match_table = of_match_ptr(isl1208_of_match),
>   },
>   .probe = isl1208_probe,
> - .remove = isl1208_remove,
>   .id_table = isl1208_id,
>  };
>  

Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315
___

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail 
enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten 
haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung 
und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail 
contains confidential and/or legally protected information. Please inform us if 
you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, 
disclosure, alteration, distribution and/or publication of this e-mail is 
strictly prohibited. 


Re: [PATCH 1/2] iio: adc: at91: fix acking DRDY irq on simple conversions

2018-09-24 Thread Eugen Hristev




On 24.09.2018 23:27, Jonathan Cameron wrote:

On Mon, 24 Sep 2018 21:00:56 +0100
Jonathan Cameron  wrote:


On Mon, 24 Sep 2018 09:19:43 +0300
Eugen Hristev  wrote:


On 22.09.2018 13:31, Jonathan Cameron wrote:

On Thu, 20 Sep 2018 15:40:37 +0300
Eugen Hristev  wrote:
 

When doing simple conversions, the driver did not acknowledge the DRDY irq.
If this irq is not acked, it will be left pending, and as soon as a trigger
is enabled, the irq handler will be called, it doesn't know why this irq
has occurred because no channel is pending, and then we will have irq loop
and board will hang.

Fixes 0e589d5fb ("ARM: AT91: IIO: Add AT91 ADC driver.")
Cc: Maxime Ripard 
Cc: 
Signed-off-by: Eugen Hristev 
---
   drivers/iio/adc/at91_adc.c | 5 +
   1 file changed, 5 insertions(+)

diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 44b5168..e85f859 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -712,6 +712,11 @@ static int at91_adc_read_raw(struct iio_dev *idev,
at91_adc_writel(st, AT91_ADC_CHDR,
AT91_ADC_CH(chan->channel));
at91_adc_writel(st, AT91_ADC_IDR, BIT(chan->channel));
+   /*
+* we need to ack the DRDY irq, otherwise it will be
+* left pending and irq handler will be confused
+*/
+   at91_adc_readl(st, AT91_ADC_LCDR);


I'm curious as to how things were working before.  Does this only occur
if we do a raw_read whilst the buffer is enabled?


No. The situation is that the read raw does not properly cleans itself
up after it's done.
The DRDY bit is cleared only when LCDR (last converted data ) is being read.
Even if we read the per channel conversion data, the LCDR still needs to
be read to clear this irq status.
The driver does not use the DRDY irq but this irq status is still being
set in the status register.


Hmm. That is somewhat nasty if it results in false interrupts when you
then enable them.


I'm talking rubbish here.  Please ignore!



   


I would have assumed when it's not enabled, the irq would be masked and
never generated in the first place...

It may be that what we actually need to do is to prevent read_raw accesses
when the buffer is enabled (like lots of other drivers do precisely to
avoid this sort of condition). The problem there comes if we have
existing applications doing this combination as we are then breaking
userspace. If that's the case we'll need to be a bit more clever.

Hammering down an irq state in a non irq handling path isn't a good
solution.


Ok, I will move the clearing of the DRDY (LCDR read) in the irq path
then, and send a v2.


If that can be done cleanly, let us go with that approach. If not
what you have here with the addition of a comments saying that the
interrupt status is not masked, merely the interrupt and as a result needs
clearing for when you later enabled the interrupt, is fine.

This definitely sounds like one of those bits of hardware that
you can write software to use safely but they certainly didn't make
it easy to do so!


For what it's worth a small explanation:

The status in the ISR (interrupt status) is updated regardless of 
whether the IRQ is enabled in the IER (interrupt enable) or not. 
Actually "enabling DRDY" makes the hardware start raising the interrupt 
line on DRDY event if it's the case. but DRDY bit is still being 
asserted in the ISR. It works like this because someone might want to 
write some simple driver without IRQ, just poll the ISR for the status.


One other thing, in my driver, at91-sama5d2_adc, I had the same issue, 
and I am reading the DRDY in the EOC part after waking up from the wait. 
This makes the IRQ handler shorter by a few hundred cycles : read LCDR 
in the userspace-called read_raw.
Do you want me to have a patch at some point to move the LCDR read in 
the IRQ handler for at91-sama5d2_adc as well ?


Eugen



Jonathan


   


Jonathan
 
   
   		st->last_value = 0;

st->done = false;
 







Re: [PATCH] remoteproc: qcom: q6v5: Propagate EPROBE_DEFER

2018-09-24 Thread Sibi Sankar

On 2018-09-20 07:21, Bjorn Andersson wrote:

In the case that the interrupts fail to result because of the
interrupt-controller not yet being registered the
platform_get_irq_byname() call will fail with -EPROBE_DEFER, but 
passing

this into devm_request_threaded_irq() will result in -EINVAL being
returned, the driver is therefor not reprobed later.



The patch looks fine.
Reviewed-by: Sibi Sankar 

Fixes: 3b415c8fb263 ("remoteproc: q6v5: Extract common resource 
handling")

Cc: sta...@vger.kernel.org
Signed-off-by: Bjorn Andersson 
---
 drivers/remoteproc/qcom_q6v5.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/remoteproc/qcom_q6v5.c 
b/drivers/remoteproc/qcom_q6v5.c

index 61a760ee4aac..e9ab90c19304 100644
--- a/drivers/remoteproc/qcom_q6v5.c
+++ b/drivers/remoteproc/qcom_q6v5.c
@@ -198,6 +198,9 @@ int qcom_q6v5_init(struct qcom_q6v5 *q6v5, struct
platform_device *pdev,
}

q6v5->fatal_irq = platform_get_irq_byname(pdev, "fatal");
+   if (q6v5->fatal_irq == -EPROBE_DEFER)
+   return -EPROBE_DEFER;
+
ret = devm_request_threaded_irq(&pdev->dev, q6v5->fatal_irq,
NULL, q6v5_fatal_interrupt,
IRQF_TRIGGER_RISING | IRQF_ONESHOT,
@@ -208,6 +211,9 @@ int qcom_q6v5_init(struct qcom_q6v5 *q6v5, struct
platform_device *pdev,
}

q6v5->ready_irq = platform_get_irq_byname(pdev, "ready");
+   if (q6v5->ready_irq == -EPROBE_DEFER)
+   return -EPROBE_DEFER;
+
ret = devm_request_threaded_irq(&pdev->dev, q6v5->ready_irq,
NULL, q6v5_ready_interrupt,
IRQF_TRIGGER_RISING | IRQF_ONESHOT,
@@ -218,6 +224,9 @@ int qcom_q6v5_init(struct qcom_q6v5 *q6v5, struct
platform_device *pdev,
}

q6v5->handover_irq = platform_get_irq_byname(pdev, "handover");
+   if (q6v5->handover_irq == -EPROBE_DEFER)
+   return -EPROBE_DEFER;
+
ret = devm_request_threaded_irq(&pdev->dev, q6v5->handover_irq,
NULL, q6v5_handover_interrupt,
IRQF_TRIGGER_RISING | IRQF_ONESHOT,
@@ -229,6 +238,9 @@ int qcom_q6v5_init(struct qcom_q6v5 *q6v5, struct
platform_device *pdev,
disable_irq(q6v5->handover_irq);

q6v5->stop_irq = platform_get_irq_byname(pdev, "stop-ack");
+   if (q6v5->stop_irq == -EPROBE_DEFER)
+   return -EPROBE_DEFER;
+
ret = devm_request_threaded_irq(&pdev->dev, q6v5->stop_irq,
NULL, q6v5_stop_interrupt,
IRQF_TRIGGER_RISING | IRQF_ONESHOT,


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


Re: [0-Day CI notification] 0-Day CI test service will be unavailable from Sep 30 to Oct 8

2018-09-24 Thread Kalle Valo
Philip Li  writes:

> Hi all, this is Philip who maintains the 0-Day CI test service. Thanks for
> subscribing to the service. We will have site level power down during China
> national holiday, so the service will be unavailable from Asia Pacific Time
> Sep 30 5PM to Oct 8 5PM. We will recover it as soon as we can. Sorry for any
> inconvenience caused during this period.

I so much rely on the 0-day reports that being without it for a week
sounds horrible :) I hope you get it up quickly after the power down.

-- 
Kalle Valo

Re: [PATCH TRIVIAL] Punctuation fixes

2018-09-24 Thread Richard Weinberger
Am Dienstag, 25. September 2018, 02:09:20 CEST schrieb Diego Viola:
> > Diego, I know you can do better. :-)
> > How about running linux-next and hunting down regressions?
> > I think we suggested this already on IRC.
> 
> OK. I'll do that after I'm done with the documentation.

By the definition of done. ;-)
If you want to help,
Documentation/virtual/uml/UserModeLinux-HOWTO.txt
needs an update.

Thanks,
//richard




[PATCH v6 4/7] mm, devm_memremap_pages: Add MEMORY_DEVICE_PRIVATE support

2018-09-24 Thread Dan Williams
In preparation for consolidating all ZONE_DEVICE enabling via
devm_memremap_pages(), teach it how to handle the constraints of
MEMORY_DEVICE_PRIVATE ranges.

Reviewed-by: Jérôme Glisse 
[jglisse: call move_pfn_range_to_zone for MEMORY_DEVICE_PRIVATE]
Acked-by: Christoph Hellwig 
Reported-by: Logan Gunthorpe 
Reviewed-by: Logan Gunthorpe 
Signed-off-by: Dan Williams 
---
 kernel/memremap.c |   53 +
 1 file changed, 41 insertions(+), 12 deletions(-)

diff --git a/kernel/memremap.c b/kernel/memremap.c
index fe2a9cd0b9c1..6e32fe36b460 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -132,9 +132,15 @@ static void devm_memremap_pages_release(void *data)
- align_start;
 
mem_hotplug_begin();
-   arch_remove_memory(align_start, align_size, pgmap->altmap_valid ?
-   &pgmap->altmap : NULL);
-   kasan_remove_zero_shadow(__va(align_start), align_size);
+   if (pgmap->type == MEMORY_DEVICE_PRIVATE) {
+   pfn = align_start >> PAGE_SHIFT;
+   __remove_pages(page_zone(pfn_to_page(pfn)), pfn,
+   align_size >> PAGE_SHIFT, NULL);
+   } else {
+   arch_remove_memory(align_start, align_size,
+   pgmap->altmap_valid ? &pgmap->altmap : NULL);
+   kasan_remove_zero_shadow(__va(align_start), align_size);
+   }
mem_hotplug_done();
 
untrack_pfn(NULL, PHYS_PFN(align_start), align_size);
@@ -232,17 +238,40 @@ void *devm_memremap_pages(struct device *dev, struct 
dev_pagemap *pgmap)
goto err_pfn_remap;
 
mem_hotplug_begin();
-   error = kasan_add_zero_shadow(__va(align_start), align_size);
-   if (error) {
-   mem_hotplug_done();
-   goto err_kasan;
+
+   /*
+* For device private memory we call add_pages() as we only need to
+* allocate and initialize struct page for the device memory. More-
+* over the device memory is un-accessible thus we do not want to
+* create a linear mapping for the memory like arch_add_memory()
+* would do.
+*
+* For all other device memory types, which are accessible by
+* the CPU, we do want the linear mapping and thus use
+* arch_add_memory().
+*/
+   if (pgmap->type == MEMORY_DEVICE_PRIVATE) {
+   error = add_pages(nid, align_start >> PAGE_SHIFT,
+   align_size >> PAGE_SHIFT, NULL, false);
+   } else {
+   error = kasan_add_zero_shadow(__va(align_start), align_size);
+   if (error) {
+   mem_hotplug_done();
+   goto err_kasan;
+   }
+
+   error = arch_add_memory(nid, align_start, align_size, altmap,
+   false);
+   }
+
+   if (!error) {
+   struct zone *zone;
+
+   zone = &NODE_DATA(nid)->node_zones[ZONE_DEVICE];
+   move_pfn_range_to_zone(zone, align_start >> PAGE_SHIFT,
+   align_size >> PAGE_SHIFT, altmap);
}
 
-   error = arch_add_memory(nid, align_start, align_size, altmap, false);
-   if (!error)
-   move_pfn_range_to_zone(&NODE_DATA(nid)->node_zones[ZONE_DEVICE],
-   align_start >> PAGE_SHIFT,
-   align_size >> PAGE_SHIFT, altmap);
mem_hotplug_done();
if (error)
goto err_add_memory;



[PATCH v6 3/7] mm, devm_memremap_pages: Fix shutdown handling

2018-09-24 Thread Dan Williams
The last step before devm_memremap_pages() returns success is to
allocate a release action, devm_memremap_pages_release(), to tear the
entire setup down. However, the result from devm_add_action() is not
checked.

Checking the error from devm_add_action() is not enough. The api
currently relies on the fact that the percpu_ref it is using is killed
by the time the devm_memremap_pages_release() is run. Rather than
continue this awkward situation, offload the responsibility of killing
the percpu_ref to devm_memremap_pages_release() directly. This allows
devm_memremap_pages() to do the right thing  relative to init failures
and shutdown.

Without this change we could fail to register the teardown of
devm_memremap_pages(). The likelihood of hitting this failure is tiny as
small memory allocations almost always succeed. However, the impact of
the failure is large given any future reconfiguration, or
disable/enable, of an nvdimm namespace will fail forever as subsequent
calls to devm_memremap_pages() will fail to setup the pgmap_radix since
there will be stale entries for the physical address range.

An argument could be made to require that the ->kill() operation be set
in the @pgmap arg rather than passed in separately. However, it helps
code readability, tracking the lifetime of a given instance, to be able
to grep the kill routine directly at the devm_memremap_pages() call
site.

Cc: 
Fixes: e8d513483300 ("memremap: change devm_memremap_pages interface...")
Reviewed-by: "Jérôme Glisse" 
Reported-by: Logan Gunthorpe 
Reviewed-by: Logan Gunthorpe 
Reviewed-by: Christoph Hellwig 
Signed-off-by: Dan Williams 
---
 drivers/dax/pmem.c|   14 +++---
 drivers/nvdimm/pmem.c |   13 +
 include/linux/memremap.h  |2 ++
 kernel/memremap.c |   31 +++
 tools/testing/nvdimm/test/iomap.c |   15 ++-
 5 files changed, 39 insertions(+), 36 deletions(-)

diff --git a/drivers/dax/pmem.c b/drivers/dax/pmem.c
index 99e2aace8078..2c1f459c0c63 100644
--- a/drivers/dax/pmem.c
+++ b/drivers/dax/pmem.c
@@ -48,9 +48,8 @@ static void dax_pmem_percpu_exit(void *data)
percpu_ref_exit(ref);
 }
 
-static void dax_pmem_percpu_kill(void *data)
+static void dax_pmem_percpu_kill(struct percpu_ref *ref)
 {
-   struct percpu_ref *ref = data;
struct dax_pmem *dax_pmem = to_dax_pmem(ref);
 
dev_dbg(dax_pmem->dev, "trace\n");
@@ -112,17 +111,10 @@ static int dax_pmem_probe(struct device *dev)
}
 
dax_pmem->pgmap.ref = &dax_pmem->ref;
+   dax_pmem->pgmap.kill = dax_pmem_percpu_kill;
addr = devm_memremap_pages(dev, &dax_pmem->pgmap);
-   if (IS_ERR(addr)) {
-   devm_remove_action(dev, dax_pmem_percpu_exit, &dax_pmem->ref);
-   percpu_ref_exit(&dax_pmem->ref);
+   if (IS_ERR(addr))
return PTR_ERR(addr);
-   }
-
-   rc = devm_add_action_or_reset(dev, dax_pmem_percpu_kill,
-   &dax_pmem->ref);
-   if (rc)
-   return rc;
 
/* adjust the dax_region resource to the start of data */
memcpy(&res, &dax_pmem->pgmap.res, sizeof(res));
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 6071e2942053..52f72ad8fe1e 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -309,8 +309,11 @@ static void pmem_release_queue(void *q)
blk_cleanup_queue(q);
 }
 
-static void pmem_freeze_queue(void *q)
+static void pmem_freeze_queue(struct percpu_ref *ref)
 {
+   struct request_queue *q;
+
+   q = container_of(ref, typeof(*q), q_usage_counter);
blk_freeze_queue_start(q);
 }
 
@@ -402,6 +405,7 @@ static int pmem_attach_disk(struct device *dev,
 
pmem->pfn_flags = PFN_DEV;
pmem->pgmap.ref = &q->q_usage_counter;
+   pmem->pgmap.kill = pmem_freeze_queue;
if (is_nd_pfn(dev)) {
if (setup_pagemap_fsdax(dev, &pmem->pgmap))
return -ENOMEM;
@@ -425,13 +429,6 @@ static int pmem_attach_disk(struct device *dev,
addr = devm_memremap(dev, pmem->phys_addr,
pmem->size, ARCH_MEMREMAP_PMEM);
 
-   /*
-* At release time the queue must be frozen before
-* devm_memremap_pages is unwound
-*/
-   if (devm_add_action_or_reset(dev, pmem_freeze_queue, q))
-   return -ENOMEM;
-
if (IS_ERR(addr))
return PTR_ERR(addr);
pmem->virt_addr = addr;
diff --git a/include/linux/memremap.h b/include/linux/memremap.h
index f91f9e763557..a84572cdc438 100644
--- a/include/linux/memremap.h
+++ b/include/linux/memremap.h
@@ -106,6 +106,7 @@ typedef void (*dev_page_free_t)(struct page *page, void 
*data);
  * @altmap: pre-allocated/reserved memory for vmemmap allocations
  * @res: physical address range covered by @ref
  * @ref: reference count that pins the devm_memremap_pages() mapp

[PATCH v6 7/7] mm, hmm: Mark hmm_devmem_{add, add_resource} EXPORT_SYMBOL_GPL

2018-09-24 Thread Dan Williams
The routines hmm_devmem_add(), and hmm_devmem_add_resource() duplicated
devm_memremap_pages() and are now simple now wrappers around the core
facility to inject a dev_pagemap instance into the global pgmap_radix
and hook page-idle events. The devm_memremap_pages() interface is base
infrastructure for HMM. HMM has more and deeper ties into the kernel
memory management implementation than base ZONE_DEVICE which is itself a
EXPORT_SYMBOL_GPL facility.

Originally, the HMM page structure creation routines copied the
devm_memremap_pages() code and reused ZONE_DEVICE. A cleanup to unify
the implementations was discussed during the initial review:
http://lkml.iu.edu/hypermail/linux/kernel/1701.2/00812.html
Recent work to extend devm_memremap_pages() for the peer-to-peer-DMA
facility enabled this cleanup to move forward.

In addition to the integration with devm_memremap_pages() HMM depends on
other GPL-only symbols:

mmu_notifier_unregister_no_release
percpu_ref
region_intersects
__class_create

It goes further to consume / indirectly expose functionality that is not
exported to any other driver:

alloc_pages_vma
walk_page_range

HMM is derived from devm_memremap_pages(), and extends deep core-kernel
fundamentals. Similar to devm_memremap_pages(), mark its entry points
EXPORT_SYMBOL_GPL().

Cc: "Jérôme Glisse" 
Cc: Logan Gunthorpe 
Reviewed-by: Christoph Hellwig 
Signed-off-by: Dan Williams 
---
 mm/hmm.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/hmm.c b/mm/hmm.c
index 2e72cb4188ca..90d1383c7e24 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -1062,7 +1062,7 @@ struct hmm_devmem *hmm_devmem_add(const struct 
hmm_devmem_ops *ops,
return result;
return devmem;
 }
-EXPORT_SYMBOL(hmm_devmem_add);
+EXPORT_SYMBOL_GPL(hmm_devmem_add);
 
 struct hmm_devmem *hmm_devmem_add_resource(const struct hmm_devmem_ops *ops,
   struct device *device,
@@ -1116,7 +1116,7 @@ struct hmm_devmem *hmm_devmem_add_resource(const struct 
hmm_devmem_ops *ops,
return result;
return devmem;
 }
-EXPORT_SYMBOL(hmm_devmem_add_resource);
+EXPORT_SYMBOL_GPL(hmm_devmem_add_resource);
 
 /*
  * A device driver that wants to handle multiple devices memory through a



Re: [PATCH RESEND] trace_uprobe: support reference counter in fd-based uprobe

2018-09-24 Thread kbuild test robot
Hi Song,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on tip/perf/core]
[also build test ERROR on v4.19-rc5 next-20180925]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Song-Liu/trace_uprobe-support-reference-counter-in-fd-based-uprobe/20180925-135454
config: i386-randconfig-x005-201838 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   kernel/trace/trace_uprobe.c: In function 'create_local_trace_uprobe':
>> kernel/trace/trace_uprobe.c:1376:4: error: 'struct trace_uprobe' has no 
>> member named 'ref_ctr_offset'
 tu->ref_ctr_offset = ref_ctr_offset;
   ^~

vim +1376 kernel/trace/trace_uprobe.c

  1340  
  1341  #ifdef CONFIG_PERF_EVENTS
  1342  struct trace_event_call *
  1343  create_local_trace_uprobe(char *name, unsigned long offs,
  1344unsigned long ref_ctr_offset, bool is_return)
  1345  {
  1346  struct trace_uprobe *tu;
  1347  struct path path;
  1348  int ret;
  1349  
  1350  ret = kern_path(name, LOOKUP_FOLLOW, &path);
  1351  if (ret)
  1352  return ERR_PTR(ret);
  1353  
  1354  if (!d_is_reg(path.dentry)) {
  1355  path_put(&path);
  1356  return ERR_PTR(-EINVAL);
  1357  }
  1358  
  1359  /*
  1360   * local trace_kprobes are not added to probe_list, so they are 
never
  1361   * searched in find_trace_kprobe(). Therefore, there is no 
concern of
  1362   * duplicated name "DUMMY_EVENT" here.
  1363   */
  1364  tu = alloc_trace_uprobe(UPROBE_EVENT_SYSTEM, "DUMMY_EVENT", 0,
  1365  is_return);
  1366  
  1367  if (IS_ERR(tu)) {
  1368  pr_info("Failed to allocate trace_uprobe.(%d)\n",
  1369  (int)PTR_ERR(tu));
  1370  path_put(&path);
  1371  return ERR_CAST(tu);
  1372  }
  1373  
  1374  tu->offset = offs;
  1375  tu->path = path;
> 1376  tu->ref_ctr_offset = ref_ctr_offset;
  1377  tu->filename = kstrdup(name, GFP_KERNEL);
  1378  init_trace_event_call(tu, &tu->tp.call);
  1379  
  1380  if (set_print_fmt(&tu->tp, is_ret_probe(tu)) < 0) {
  1381  ret = -ENOMEM;
  1382  goto error;
  1383  }
  1384  
  1385  return &tu->tp.call;
  1386  error:
  1387  free_trace_uprobe(tu);
  1388  return ERR_PTR(ret);
  1389  }
  1390  

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


.config.gz
Description: application/gzip


[PATCH v6 6/7] mm, hmm: Replace hmm_devmem_pages_create() with devm_memremap_pages()

2018-09-24 Thread Dan Williams
Commit e8d513483300 "memremap: change devm_memremap_pages interface to
use struct dev_pagemap" refactored devm_memremap_pages() to allow a
dev_pagemap instance to be supplied. Passing in a dev_pagemap interface
simplifies the design of pgmap type drivers in that they can rely on
container_of() to lookup any private data associated with the given
dev_pagemap instance.

In addition to the cleanups this also gives hmm users multi-order-radix
improvements that arrived with commit ab1b597ee0e4 "mm,
devm_memremap_pages: use multi-order radix for ZONE_DEVICE lookups"

As part of the conversion to the devm_memremap_pages() method of
handling the percpu_ref relative to when pages are put, the percpu_ref
completion needs to move to hmm_devmem_ref_exit(). See commit
71389703839e ("mm, zone_device: Replace {get, put}_zone_device_page...")
for details.

Reviewed-by: Christoph Hellwig 
Reviewed-by: Jérôme Glisse 
Acked-by: Balbir Singh 
Cc: Logan Gunthorpe 
Signed-off-by: Dan Williams 
---
 mm/hmm.c |  194 --
 1 file changed, 26 insertions(+), 168 deletions(-)

diff --git a/mm/hmm.c b/mm/hmm.c
index ec1d9eccf176..2e72cb4188ca 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -938,17 +938,16 @@ static void hmm_devmem_ref_exit(void *data)
struct hmm_devmem *devmem;
 
devmem = container_of(ref, struct hmm_devmem, ref);
+   wait_for_completion(&devmem->completion);
percpu_ref_exit(ref);
 }
 
-static void hmm_devmem_ref_kill(void *data)
+static void hmm_devmem_ref_kill(struct percpu_ref *ref)
 {
-   struct percpu_ref *ref = data;
struct hmm_devmem *devmem;
 
devmem = container_of(ref, struct hmm_devmem, ref);
percpu_ref_kill(ref);
-   wait_for_completion(&devmem->completion);
 }
 
 static int hmm_devmem_fault(struct vm_area_struct *vma,
@@ -971,152 +970,6 @@ static void hmm_devmem_free(struct page *page, void *data)
devmem->ops->free(devmem, page);
 }
 
-static DEFINE_MUTEX(hmm_devmem_lock);
-static RADIX_TREE(hmm_devmem_radix, GFP_KERNEL);
-
-static void hmm_devmem_radix_release(struct resource *resource)
-{
-   resource_size_t key;
-
-   mutex_lock(&hmm_devmem_lock);
-   for (key = resource->start;
-key <= resource->end;
-key += PA_SECTION_SIZE)
-   radix_tree_delete(&hmm_devmem_radix, key >> PA_SECTION_SHIFT);
-   mutex_unlock(&hmm_devmem_lock);
-}
-
-static void hmm_devmem_release(void *data)
-{
-   struct hmm_devmem *devmem = data;
-   struct resource *resource = devmem->resource;
-   unsigned long start_pfn, npages;
-   struct zone *zone;
-   struct page *page;
-
-   /* pages are dead and unused, undo the arch mapping */
-   start_pfn = (resource->start & ~(PA_SECTION_SIZE - 1)) >> PAGE_SHIFT;
-   npages = ALIGN(resource_size(resource), PA_SECTION_SIZE) >> PAGE_SHIFT;
-
-   page = pfn_to_page(start_pfn);
-   zone = page_zone(page);
-
-   mem_hotplug_begin();
-   if (resource->desc == IORES_DESC_DEVICE_PRIVATE_MEMORY)
-   __remove_pages(zone, start_pfn, npages, NULL);
-   else
-   arch_remove_memory(start_pfn << PAGE_SHIFT,
-  npages << PAGE_SHIFT, NULL);
-   mem_hotplug_done();
-
-   hmm_devmem_radix_release(resource);
-}
-
-static int hmm_devmem_pages_create(struct hmm_devmem *devmem)
-{
-   resource_size_t key, align_start, align_size, align_end;
-   struct device *device = devmem->device;
-   int ret, nid, is_ram;
-   unsigned long pfn;
-
-   align_start = devmem->resource->start & ~(PA_SECTION_SIZE - 1);
-   align_size = ALIGN(devmem->resource->start +
-  resource_size(devmem->resource),
-  PA_SECTION_SIZE) - align_start;
-
-   is_ram = region_intersects(align_start, align_size,
-  IORESOURCE_SYSTEM_RAM,
-  IORES_DESC_NONE);
-   if (is_ram == REGION_MIXED) {
-   WARN_ONCE(1, "%s attempted on mixed region %pr\n",
-   __func__, devmem->resource);
-   return -ENXIO;
-   }
-   if (is_ram == REGION_INTERSECTS)
-   return -ENXIO;
-
-   if (devmem->resource->desc == IORES_DESC_DEVICE_PUBLIC_MEMORY)
-   devmem->pagemap.type = MEMORY_DEVICE_PUBLIC;
-   else
-   devmem->pagemap.type = MEMORY_DEVICE_PRIVATE;
-
-   devmem->pagemap.res = *devmem->resource;
-   devmem->pagemap.page_fault = hmm_devmem_fault;
-   devmem->pagemap.page_free = hmm_devmem_free;
-   devmem->pagemap.dev = devmem->device;
-   devmem->pagemap.ref = &devmem->ref;
-   devmem->pagemap.data = devmem;
-
-   mutex_lock(&hmm_devmem_lock);
-   align_end = align_start + align_size - 1;
-   for (key = align_start; key <= align_end; key += PA_SECTION_SIZE) {
-   struct hmm_devmem *dup;
-
-  

[PATCH v6 0/7] mm: Merge hmm into devm_memremap_pages, mark GPL-only

2018-09-24 Thread Dan Williams
Changes since v5 [1]:
* Move the percpu-ref kill function to be passed in via @pgmap (Christoph)
* Added Christoph's ack for patches 2 and 4
* Added Jérôme's Reviewed-by for patches 2-6
* Fix MEMORY_DEVICE_PRIVATE support (Jérôme)

[1]: https://lkml.org/lkml/2018/9/13/104

---

Hi Andrew,

Jérôme has reviewed the cleanups, thanks Jérôme. We still disagree on
the EXPORT_SYMBOL_GPL status of the core HMM implementation, but Logan,
Christoph and I continue to support marking all devm_memremap_pages()
derivatives EXPORT_SYMBOL_GPL.

HMM has been upstream for over a year, with no in-tree users it is clear
it was designed first and foremost for out of tree drivers. It takes
advantage of a facility Christoph and I spearheaded to support
persistent memory. It continues to see expanding use cases with no clear
end date when it will stop attracting features / revisions. It is not
suitable to export devm_memremap_pages() as a stable 3rd party driver
api.

devm_memremap_pages() is a facility that can create struct page entries
for any arbitrary range and give out-of-tree drivers the ability to
subvert core aspects of page management. It, and anything derived from
it (e.g. hmm, pcip2p, etc...), is a deep integration point into the core
kernel, and an EXPORT_SYMBOL_GPL() interface. 

Commit 31c5bda3a656 "mm: fix exports that inadvertently make put_page()
EXPORT_SYMBOL_GPL" was merged ahead of this series to relieve some of
the pressure from innocent consumers of put_page(), but now we need this
series to address *producers* of device pages.

More details and justification in the changelogs. The 0day
infrastructure has reported success across 152 configs and this survives
the libnvdimm unit test suite. Aside from the controversial bits the
diffstat is compelling at:

7 files changed, 127 insertions(+), 321 deletions(-)

Note that the series has some minor collisions with Alex's recent series
to improve devm_memremap_pages() scalability [2]. So, whichever you take
first the other will need a minor rebase.

[2]: https://www.lkml.org/lkml/2018/9/11/10

---

Dan Williams (7):
  mm, devm_memremap_pages: Mark devm_memremap_pages() EXPORT_SYMBOL_GPL
  mm, devm_memremap_pages: Kill mapping "System RAM" support
  mm, devm_memremap_pages: Fix shutdown handling
  mm, devm_memremap_pages: Add MEMORY_DEVICE_PRIVATE support
  mm, hmm: Use devm semantics for hmm_devmem_{add,remove}
  mm, hmm: Replace hmm_devmem_pages_create() with devm_memremap_pages()
  mm, hmm: Mark hmm_devmem_{add,add_resource} EXPORT_SYMBOL_GPL


 drivers/dax/pmem.c|   14 --
 drivers/nvdimm/pmem.c |   13 +-
 include/linux/hmm.h   |4 
 include/linux/memremap.h  |2 
 kernel/memremap.c |   95 +++-
 mm/hmm.c  |  303 +
 tools/testing/nvdimm/test/iomap.c |   17 ++
 7 files changed, 127 insertions(+), 321 deletions(-)


[PATCH v6 5/7] mm, hmm: Use devm semantics for hmm_devmem_{add, remove}

2018-09-24 Thread Dan Williams
devm semantics arrange for resources to be torn down when
device-driver-probe fails or when device-driver-release completes.
Similar to devm_memremap_pages() there is no need to support an explicit
remove operation when the users properly adhere to devm semantics.

Note that devm_kzalloc() automatically handles allocating node-local
memory.

Reviewed-by: Christoph Hellwig 
Reviewed-by: Jérôme Glisse 
Cc: "Jérôme Glisse" 
Cc: Logan Gunthorpe 
Signed-off-by: Dan Williams 
---
 include/linux/hmm.h |4 --
 mm/hmm.c|  127 ++-
 2 files changed, 25 insertions(+), 106 deletions(-)

diff --git a/include/linux/hmm.h b/include/linux/hmm.h
index 4c92e3ba3e16..5ec8635f602c 100644
--- a/include/linux/hmm.h
+++ b/include/linux/hmm.h
@@ -499,8 +499,7 @@ struct hmm_devmem {
  * enough and allocate struct page for it.
  *
  * The device driver can wrap the hmm_devmem struct inside a private device
- * driver struct. The device driver must call hmm_devmem_remove() before the
- * device goes away and before freeing the hmm_devmem struct memory.
+ * driver struct.
  */
 struct hmm_devmem *hmm_devmem_add(const struct hmm_devmem_ops *ops,
  struct device *device,
@@ -508,7 +507,6 @@ struct hmm_devmem *hmm_devmem_add(const struct 
hmm_devmem_ops *ops,
 struct hmm_devmem *hmm_devmem_add_resource(const struct hmm_devmem_ops *ops,
   struct device *device,
   struct resource *res);
-void hmm_devmem_remove(struct hmm_devmem *devmem);
 
 /*
  * hmm_devmem_page_set_drvdata - set per-page driver data field
diff --git a/mm/hmm.c b/mm/hmm.c
index c968e49f7a0c..ec1d9eccf176 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -939,7 +939,6 @@ static void hmm_devmem_ref_exit(void *data)
 
devmem = container_of(ref, struct hmm_devmem, ref);
percpu_ref_exit(ref);
-   devm_remove_action(devmem->device, &hmm_devmem_ref_exit, data);
 }
 
 static void hmm_devmem_ref_kill(void *data)
@@ -950,7 +949,6 @@ static void hmm_devmem_ref_kill(void *data)
devmem = container_of(ref, struct hmm_devmem, ref);
percpu_ref_kill(ref);
wait_for_completion(&devmem->completion);
-   devm_remove_action(devmem->device, &hmm_devmem_ref_kill, data);
 }
 
 static int hmm_devmem_fault(struct vm_area_struct *vma,
@@ -988,7 +986,7 @@ static void hmm_devmem_radix_release(struct resource 
*resource)
mutex_unlock(&hmm_devmem_lock);
 }
 
-static void hmm_devmem_release(struct device *dev, void *data)
+static void hmm_devmem_release(void *data)
 {
struct hmm_devmem *devmem = data;
struct resource *resource = devmem->resource;
@@ -996,11 +994,6 @@ static void hmm_devmem_release(struct device *dev, void 
*data)
struct zone *zone;
struct page *page;
 
-   if (percpu_ref_tryget_live(&devmem->ref)) {
-   dev_WARN(dev, "%s: page mapping is still live!\n", __func__);
-   percpu_ref_put(&devmem->ref);
-   }
-
/* pages are dead and unused, undo the arch mapping */
start_pfn = (resource->start & ~(PA_SECTION_SIZE - 1)) >> PAGE_SHIFT;
npages = ALIGN(resource_size(resource), PA_SECTION_SIZE) >> PAGE_SHIFT;
@@ -1124,19 +1117,6 @@ static int hmm_devmem_pages_create(struct hmm_devmem 
*devmem)
return ret;
 }
 
-static int hmm_devmem_match(struct device *dev, void *data, void *match_data)
-{
-   struct hmm_devmem *devmem = data;
-
-   return devmem->resource == match_data;
-}
-
-static void hmm_devmem_pages_remove(struct hmm_devmem *devmem)
-{
-   devres_release(devmem->device, &hmm_devmem_release,
-  &hmm_devmem_match, devmem->resource);
-}
-
 /*
  * hmm_devmem_add() - hotplug ZONE_DEVICE memory for device memory
  *
@@ -1164,8 +1144,7 @@ struct hmm_devmem *hmm_devmem_add(const struct 
hmm_devmem_ops *ops,
 
dev_pagemap_get_ops();
 
-   devmem = devres_alloc_node(&hmm_devmem_release, sizeof(*devmem),
-  GFP_KERNEL, dev_to_node(device));
+   devmem = devm_kzalloc(device, sizeof(*devmem), GFP_KERNEL);
if (!devmem)
return ERR_PTR(-ENOMEM);
 
@@ -1179,11 +1158,11 @@ struct hmm_devmem *hmm_devmem_add(const struct 
hmm_devmem_ops *ops,
ret = percpu_ref_init(&devmem->ref, &hmm_devmem_ref_release,
  0, GFP_KERNEL);
if (ret)
-   goto error_percpu_ref;
+   return ERR_PTR(ret);
 
-   ret = devm_add_action(device, hmm_devmem_ref_exit, &devmem->ref);
+   ret = devm_add_action_or_reset(device, hmm_devmem_ref_exit, 
&devmem->ref);
if (ret)
-   goto error_devm_add_action;
+   return ERR_PTR(ret);
 
size = ALIGN(size, PA_SECTION_SIZE);
addr = min((unsigned long)iomem_resource.end,
@@ -1203,16 +1182,12 @@ struct hmm_devmem *hmm_devmem_add(const struct 
hmm_devmem_ops *ops,
 

[PATCH v6 1/7] mm, devm_memremap_pages: Mark devm_memremap_pages() EXPORT_SYMBOL_GPL

2018-09-24 Thread Dan Williams
devm_memremap_pages() is a facility that can create struct page entries
for any arbitrary range and give drivers the ability to subvert core
aspects of page management.

Specifically the facility is tightly integrated with the kernel's memory
hotplug functionality. It injects an altmap argument deep into the
architecture specific vmemmap implementation to allow allocating from
specific reserved pages, and it has Linux specific assumptions about
page structure reference counting relative to get_user_pages() and
get_user_pages_fast(). It was an oversight and a mistake that this was
not marked EXPORT_SYMBOL_GPL from the outset.

Again, devm_memremap_pagex() exposes and relies upon core kernel
internal assumptions and will continue to evolve along with 'struct
page', memory hotplug, and support for new memory types / topologies.
Only an in-kernel GPL-only driver is expected to keep up with this
ongoing evolution. This interface, and functionality derived from this
interface, is not suitable for kernel-external drivers.

Cc: Michal Hocko 
Cc: "Jérôme Glisse" 
Reviewed-by: Christoph Hellwig 
Signed-off-by: Dan Williams 
---
 kernel/memremap.c |2 +-
 tools/testing/nvdimm/test/iomap.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/memremap.c b/kernel/memremap.c
index 5b8600d39931..f95c7833db6d 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -283,7 +283,7 @@ void *devm_memremap_pages(struct device *dev, struct 
dev_pagemap *pgmap)
pgmap_radix_release(res, pgoff);
return ERR_PTR(error);
 }
-EXPORT_SYMBOL(devm_memremap_pages);
+EXPORT_SYMBOL_GPL(devm_memremap_pages);
 
 unsigned long vmem_altmap_offset(struct vmem_altmap *altmap)
 {
diff --git a/tools/testing/nvdimm/test/iomap.c 
b/tools/testing/nvdimm/test/iomap.c
index ff9d3a5825e1..ed18a0cbc0c8 100644
--- a/tools/testing/nvdimm/test/iomap.c
+++ b/tools/testing/nvdimm/test/iomap.c
@@ -113,7 +113,7 @@ void *__wrap_devm_memremap_pages(struct device *dev, struct 
dev_pagemap *pgmap)
return nfit_res->buf + offset - nfit_res->res.start;
return devm_memremap_pages(dev, pgmap);
 }
-EXPORT_SYMBOL(__wrap_devm_memremap_pages);
+EXPORT_SYMBOL_GPL(__wrap_devm_memremap_pages);
 
 pfn_t __wrap_phys_to_pfn_t(phys_addr_t addr, unsigned long flags)
 {



[PATCH v6 2/7] mm, devm_memremap_pages: Kill mapping "System RAM" support

2018-09-24 Thread Dan Williams
Given the fact that devm_memremap_pages() requires a percpu_ref that is
torn down by devm_memremap_pages_release() the current support for
mapping RAM is broken.

Support for remapping "System RAM" has been broken since the beginning
and there is no existing user of this this code path, so just kill the
support and make it an explicit error.

This cleanup also simplifies a follow-on patch to fix the error path
when setting a devm release action for devm_memremap_pages_release()
fails.

Reviewed-by: "Jérôme Glisse" 
Reviewed-by: Christoph Hellwig 
Reviewed-by: Logan Gunthorpe 
Signed-off-by: Dan Williams 
---
 kernel/memremap.c |9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/kernel/memremap.c b/kernel/memremap.c
index f95c7833db6d..92e838127767 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -202,15 +202,12 @@ void *devm_memremap_pages(struct device *dev, struct 
dev_pagemap *pgmap)
is_ram = region_intersects(align_start, align_size,
IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE);
 
-   if (is_ram == REGION_MIXED) {
-   WARN_ONCE(1, "%s attempted on mixed region %pr\n",
-   __func__, res);
+   if (is_ram != REGION_DISJOINT) {
+   WARN_ONCE(1, "%s attempted on %s region %pr\n", __func__,
+   is_ram == REGION_MIXED ? "mixed" : "ram", res);
return ERR_PTR(-ENXIO);
}
 
-   if (is_ram == REGION_INTERSECTS)
-   return __va(res->start);
-
if (!pgmap->ref)
return ERR_PTR(-EINVAL);
 



Re: [PATCH] PCI: remove unnecessary check of device_type == pci

2018-09-24 Thread Michal Simek
Hi Lorenzo,

On 21.9.2018 11:29, Lorenzo Pieralisi wrote:
> On Wed, Aug 29, 2018 at 01:34:40PM -0500, Rob Herring wrote:
>> PCI host drivers have already matched on compatible strings, so checking
>> device_type is redundant. Also, device_type is considered deprecated for
>> FDT though we've still been requiring it for PCI hosts as it is useful
>> for finding PCI buses.
>>
>> Cc: Will Deacon 
>> Cc: Lorenzo Pieralisi 
>> Cc: Bjorn Helgaas 
>> Cc: Alan Douglas 
>> Cc: Subrahmanya Lingappa 
>> Cc: Michal Simek 
>> Cc: linux-...@vger.kernel.org
>> Cc: linux-arm-ker...@lists.infradead.org
>> Signed-off-by: Rob Herring 
>> ---
>>  drivers/pci/controller/pci-host-common.c   | 8 
>>  drivers/pci/controller/pcie-cadence-host.c | 7 ---
>>  drivers/pci/controller/pcie-mobiveil.c | 7 ---
>>  drivers/pci/controller/pcie-xilinx-nwl.c   | 9 -
>>  drivers/pci/controller/pcie-xilinx.c   | 7 ---
>>  5 files changed, 38 deletions(-)
> 
> Hi Michal,
> 
> are you OK with these changes ?


This change is fine.
Acked-by: Michal Simek 

Thanks,
Michal


Re: [PATCH 0/9] AHCI and SATA PHY support for BCM63138

2018-09-24 Thread Kishon Vijay Abraham I



On Friday 21 September 2018 12:49 AM, Florian Fainelli wrote:
> On 09/20/2018 12:16 PM, Florian Fainelli wrote:
>> Hi Kishon, Tejun,
>>
>> This patch series adds support for the SATA AHCI and PHY found on the
>> ARM-basd BCM63138 DSL SoCs.
>>
>> It would probably make sense for patches 1-3 to go through Kishon's
>> tree, patches 4-7 through Tejun's tree, and I would be merging the last
>> two patches through the Broadcom ARM-SoC tree.
>>
>> Let me know if this is not a workable plan, thank you very much!
> 
> Looks like I had left patches with the incorrect subject, please
> disregard the following patches:
> 
> [PATCH 2/9] phy: broadcom: allow PHY_BRCM_SATA driver to be built for
> DSL SoCs
> [PATCH 5/9] ata: sata_brcmstb: Allow optional reset controller to be used
> [PATCH 6/9] ata: ahci_brcmstb: Match 63138 compatible strings
> 
> since they have incorrect/inconsistent titles, the other patches are
> fine though. Sorry about that.

merged the first 3 patches to linux-phy tree.

Thanks
Kishon


[PATCH] pinctrl: generic: Avoid several implicit enum conversions

2018-09-24 Thread Nathan Chancellor
Clang warns when one enumerated type is implicitly converted to another,
which happens several times in the pinctrl drivers for a few reasons:

* The PCONFDUMP macro, which sets the param member in pin_config_item.
* The pinconf_generic_params structure, which is used by drivers to
  configure their bindings, which has a param member like pin_config_item.
* The pinconf_to_config_packed, which takes either the generic enum
  pin_config_param or a specialized one.

Drivers are allowed to extend this enumerated type because of the gap
betweem PIN_CONFIG_END and PIN_CONFIG_MAX. Make it clear to Clang that
this is allowed by changing param's type in all of these instances to
int so no conversion needs to happen.

Link: https://github.com/ClangBuiltLinux/linux/issues/138
Signed-off-by: Nathan Chancellor 
---
 include/linux/pinctrl/pinconf-generic.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/pinctrl/pinconf-generic.h 
b/include/linux/pinctrl/pinconf-generic.h
index 6c0680641108..13076ae7acfb 100644
--- a/include/linux/pinctrl/pinconf-generic.h
+++ b/include/linux/pinctrl/pinconf-generic.h
@@ -150,7 +150,7 @@ static inline u32 pinconf_to_config_argument(unsigned long 
config)
return (u32) ((config >> 8) & 0xffUL);
 }
 
-static inline unsigned long pinconf_to_config_packed(enum pin_config_param 
param,
+static inline unsigned long pinconf_to_config_packed(int param,
 u32 argument)
 {
return PIN_CONF_PACKED(param, argument);
@@ -164,7 +164,7 @@ static inline unsigned long pinconf_to_config_packed(enum 
pin_config_param param
}
 
 struct pin_config_item {
-   const enum pin_config_param param;
+   const int param;
const char * const display;
const char * const format;
bool has_arg;
@@ -180,7 +180,7 @@ struct pinctrl_map;
 
 struct pinconf_generic_params {
const char * const property;
-   enum pin_config_param param;
+   int param;
u32 default_value;
 };
 
-- 
2.19.0



[PATCH 2/2] panic fix for making cache device

2018-09-24 Thread Dongbo Cao
when the nbuckets of cache device is smaller than 1024, making cache device 
will trigger BUG_ON in kernel, add a condition to avoid this.

Signed-off-by: Dongbo Cao 
---
 drivers/md/bcache/super.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 0c0f6d8f..47d122ed 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -2036,7 +2036,12 @@ static int cache_alloc(struct cache *ca)
 */
btree_buckets = ca->sb.njournal_buckets ?: 8;
free = roundup_pow_of_two(ca->sb.nbuckets) >> 10;
-   
+   if (!free) {
+   ret = -EPERM;
+   err = "ca->sb.nbuckets is too small";
+   goto err_free;
+   }
+
if (!init_fifo(&ca->free[RESERVE_BTREE], btree_buckets,
GFP_KERNEL)) {
err = "ca->free[RESERVE_BTREE] alloc failed";
@@ -2102,6 +2107,7 @@ static int cache_alloc(struct cache *ca)
 err_prio_alloc:
free_fifo(&ca->free[RESERVE_BTREE]);
 err_btree_alloc:
+err_free:
module_put(THIS_MODULE);
if (err)
pr_notice("error %s: %s", ca->cache_dev_name, err);
@@ -2131,6 +2137,8 @@ static int register_cache(struct cache_sb *sb, struct 
page *sb_page,
blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
if (ret == -ENOMEM)
err = "cache_alloc(): -ENOMEM";
+   else if (ret == -EPERM)
+   err = "cache_alloc(): cache device is too small";
else
err = "cache_alloc(): unknown error";
goto err;
-- 
2.17.1




[PATCH 1/2] split original if-condition code into separate ones

2018-09-24 Thread Dongbo Cao
to make it clearly to debug.

Signed-off-by: Dongbo Cao 
---
 drivers/md/bcache/super.c | 81 +++
 1 file changed, 66 insertions(+), 15 deletions(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index fa4058e4..0c0f6d8f 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -2017,6 +2017,8 @@ static int cache_alloc(struct cache *ca)
size_t free;
size_t btree_buckets;
struct bucket *b;
+   int ret = -ENOMEM;
+   const char *err = NULL;
 
__module_get(THIS_MODULE);
kobject_init(&ca->kobj, &bch_cache_ktype);
@@ -2034,27 +2036,76 @@ static int cache_alloc(struct cache *ca)
 */
btree_buckets = ca->sb.njournal_buckets ?: 8;
free = roundup_pow_of_two(ca->sb.nbuckets) >> 10;
-
-   if (!init_fifo(&ca->free[RESERVE_BTREE], btree_buckets, GFP_KERNEL) ||
-   !init_fifo_exact(&ca->free[RESERVE_PRIO], prio_buckets(ca), 
GFP_KERNEL) ||
-   !init_fifo(&ca->free[RESERVE_MOVINGGC], free, GFP_KERNEL) ||
-   !init_fifo(&ca->free[RESERVE_NONE], free, GFP_KERNEL) ||
-   !init_fifo(&ca->free_inc,   free << 2, GFP_KERNEL) ||
-   !init_heap(&ca->heap,   free << 3, GFP_KERNEL) ||
-   !(ca->buckets   = vzalloc(array_size(sizeof(struct bucket),
-ca->sb.nbuckets))) ||
-   !(ca->prio_buckets  = kzalloc(array3_size(sizeof(uint64_t),
- prio_buckets(ca), 2),
- GFP_KERNEL)) ||
-   !(ca->disk_buckets  = alloc_bucket_pages(GFP_KERNEL, ca)))
-   return -ENOMEM;
+   
+   if (!init_fifo(&ca->free[RESERVE_BTREE], btree_buckets,
+   GFP_KERNEL)) {
+   err = "ca->free[RESERVE_BTREE] alloc failed";
+   goto err_btree_alloc;
+   }
+   if (!init_fifo_exact(&ca->free[RESERVE_PRIO], prio_buckets(ca),
+   GFP_KERNEL)) {
+   err = "ca->free[RESERVE_PRIO] alloc failed";
+   goto err_prio_alloc;
+   }
+   if (!init_fifo(&ca->free[RESERVE_MOVINGGC], free, GFP_KERNEL)) {
+   err = "ca->free[RESERVE_MOVINGGC] alloc failed";
+   goto err_movinggc_alloc;
+   }
+   if (!init_fifo(&ca->free[RESERVE_NONE], free, GFP_KERNEL)) {
+   err = "ca->free[RESERVE_NONE] alloc failed";
+   goto err_none_alloc;
+   }
+   if (!init_fifo(&ca->free_inc, free << 2, GFP_KERNEL)) {
+   err = "ca->free_inc alloc failed";
+   goto err_free_inc_alloc;
+   }
+   if (!init_heap(&ca->heap, free << 3, GFP_KERNEL)) {
+   err = "ca->heap alloc failed";
+   goto err_heap_alloc;
+   }
+   if (!(ca->buckets = vzalloc(array_size(sizeof(struct bucket),
+   ca->sb.nbuckets {
+   err = "ca->buckets alloc failed";
+   goto err_buckets_alloc;
+   }
+   if (!(ca->prio_buckets = kzalloc(array3_size(sizeof(uint64_t),
+   prio_buckets(ca), 2),
+   GFP_KERNEL))) {
+   err = "ca->prio_buckets alloc failed";
+   goto err_prio_buckets_alloc;
+   }
+   if (!(ca->disk_buckets = alloc_bucket_pages(GFP_KERNEL, ca))) {
+   err = "ca->disk_buckets alloc failed";
+   goto err_disk_buckets_alloc;
+   }
 
ca->prio_last_buckets = ca->prio_buckets + prio_buckets(ca);
 
for_each_bucket(b, ca)
atomic_set(&b->pin, 0);
-
return 0;
+
+err_disk_buckets_alloc:
+   kfree(ca->prio_buckets);
+err_prio_buckets_alloc:
+   vfree(ca->buckets);
+err_buckets_alloc:
+   free_heap(&ca->heap);
+err_heap_alloc:
+   free_fifo(&ca->free_inc);
+err_free_inc_alloc:
+   free_fifo(&ca->free[RESERVE_NONE]);
+err_none_alloc:
+   free_fifo(&ca->free[RESERVE_MOVINGGC]);
+err_movinggc_alloc:
+   free_fifo(&ca->free[RESERVE_PRIO]);
+err_prio_alloc:
+   free_fifo(&ca->free[RESERVE_BTREE]);
+err_btree_alloc:
+   module_put(THIS_MODULE);
+   if (err)
+   pr_notice("error %s: %s", ca->cache_dev_name, err);
+   return ret;
 }
 
 static int register_cache(struct cache_sb *sb, struct page *sb_page,
-- 
2.17.1




Re: [LKP] [mm, oom] 6209f6fc62: general_protection_fault:#[##]

2018-09-24 Thread Michal Hocko
On Tue 25-09-18 13:48:20, kernel test robot wrote:
> FYI, we noticed the following commit (built with gcc-7):
> 
> commit: 6209f6fc62835d84c2a92d237588a114e39436ce ("mm, oom: rework mmap_exit 
> vs. oom_reaper synchronization")
> https://github.com/0day-ci/linux 
> UPDATE-20180911-024633/Tetsuo-Handa/mm-oom-Fix-unnecessary-killing-of-additional-processes/20180910-163452

Do you have a msg-id to the patch that has been tested?
-- 
Michal Hocko
SUSE Labs


Re: [PATCH] ARM: dts: da850-lego-ev3: slow down A/DC as much as possible

2018-09-24 Thread Sekhar Nori
Hi David,

On Monday 24 September 2018 07:01 AM, David Lechner wrote:
> Due to the electrical design of the A/DC circuits on LEGO MINDSTORMS EV3,
> if we are reading analog values as fast as possible (i.e. using DMA to
> service the SPI) the A/DC chip will read incorrect values - as much as
> 0.1V off when the SPI is running at 10MHz. (This has to do with the
> capacitor charge time when channels are muxed in the A/DC.)

So you believe this is an issue with the board design rather than the
limitation of the ADC chip itself? Because if its the later, the fix
should be in the driver instead.

> 
> This patch slows down the SPI as much as possible (if CPU is at 456MHz,
> SPI runs at 1/2 of that, so 228MHz and has a max prescalar of 256, so
> we could get ~891kHz, but we're just rounding it to 1MHz). We also use
> the max allowable value for WDELAY to slow things down even more.
> 
> These changes reduce the error of the analog values to about 5mV, which
> is tolerable.
> 
> Commits a3762b13a596 ("spi: spi-davinci: Add support for SPI_CS_WORD")
> and e2540da86ef8 ("iio: adc: ti-ads7950: use SPI_CS_WORD to reduce
> CPU usage") introduce changes that allow DMA transfers to be used, so
> this slow down is needed now.
> 
> Signed-off-by: David Lechner 
> ---
> 
> FYI, this patch doesn't strictly depend on the other two mentioned. In fact, 
> it
> would better if it got merged before them, but the consequences are minimal, 
> so
> it doesn't seem worth it to me to try coordinating merges here.
> 
> Both of these patches mentioned have been picked up in the respective
> subsystems.

Is this needed for the -rc cycle or can wait for v4.20?

Thanks,
Sekhar

> 
>  arch/arm/boot/dts/da850-lego-ev3.dts | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/da850-lego-ev3.dts 
> b/arch/arm/boot/dts/da850-lego-ev3.dts
> index c4729d0e6c19..66fcadf0ba91 100644
> --- a/arch/arm/boot/dts/da850-lego-ev3.dts
> +++ b/arch/arm/boot/dts/da850-lego-ev3.dts
> @@ -352,7 +352,8 @@
>   compatible = "ti,ads7957";
>   reg = <3>;
>   #io-channel-cells = <1>;
> - spi-max-frequency = <1000>;
> + spi-max-frequency = <100>;
> + ti,spi-wdelay = <63>;
>   vref-supply = <&adc_ref>;
>   };
>  };
> -- 
> 2.17.1
> 



Re: [PATCH bpf-next 2/9] bpf: rework cgroup storage pointer passing

2018-09-24 Thread Song Liu
On Fri, Sep 21, 2018 at 10:16 AM Roman Gushchin  wrote:
>
> To simplify the following introduction of per-cpu cgroup storage,
> let's rework a bit a mechanism of passing a pointer to a cgroup
> storage into the bpf_get_local_storage(). Let's save a pointer
> to the corresponding bpf_cgroup_storage structure, instead of
> a pointer to the actual buffer.
>
> It will help us to handle per-cpu storage later, which has
> a different way of accessing to the actual data.
>
> Signed-off-by: Roman Gushchin 
> Cc: Daniel Borkmann 
> Cc: Alexei Starovoitov 

Acked-by: Song Liu 

> ---
>  include/linux/bpf-cgroup.h | 13 -
>  kernel/bpf/helpers.c   |  8 ++--
>  kernel/bpf/local_storage.c |  3 ++-
>  3 files changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h
> index e9871b012dac..7e0c9a1d48b7 100644
> --- a/include/linux/bpf-cgroup.h
> +++ b/include/linux/bpf-cgroup.h
> @@ -23,7 +23,8 @@ struct bpf_cgroup_storage;
>  extern struct static_key_false cgroup_bpf_enabled_key;
>  #define cgroup_bpf_enabled static_branch_unlikely(&cgroup_bpf_enabled_key)
>
> -DECLARE_PER_CPU(void*, bpf_cgroup_storage[MAX_BPF_CGROUP_STORAGE_TYPE]);
> +DECLARE_PER_CPU(struct bpf_cgroup_storage*,
> +   bpf_cgroup_storage[MAX_BPF_CGROUP_STORAGE_TYPE]);
>
>  #define for_each_cgroup_storage_type(stype) \
> for (stype = 0; stype < MAX_BPF_CGROUP_STORAGE_TYPE; stype++)
> @@ -115,15 +116,9 @@ static inline void bpf_cgroup_storage_set(struct 
> bpf_cgroup_storage
>   
> *storage[MAX_BPF_CGROUP_STORAGE_TYPE])
>  {
> enum bpf_cgroup_storage_type stype;
> -   struct bpf_storage_buffer *buf;
> -
> -   for_each_cgroup_storage_type(stype) {
> -   if (!storage[stype])
> -   continue;
>
> -   buf = READ_ONCE(storage[stype]->buf);
> -   this_cpu_write(bpf_cgroup_storage[stype], &buf->data[0]);
> -   }
> +   for_each_cgroup_storage_type(stype)
> +   this_cpu_write(bpf_cgroup_storage[stype], storage[stype]);
>  }
>
>  struct bpf_cgroup_storage *bpf_cgroup_storage_alloc(struct bpf_prog *prog,
> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> index 9070b2ace6aa..e42f8789b7ea 100644
> --- a/kernel/bpf/helpers.c
> +++ b/kernel/bpf/helpers.c
> @@ -195,7 +195,8 @@ const struct bpf_func_proto 
> bpf_get_current_cgroup_id_proto = {
>  };
>
>  #ifdef CONFIG_CGROUP_BPF
> -DECLARE_PER_CPU(void*, bpf_cgroup_storage[MAX_BPF_CGROUP_STORAGE_TYPE]);
> +DECLARE_PER_CPU(struct bpf_cgroup_storage*,
> +   bpf_cgroup_storage[MAX_BPF_CGROUP_STORAGE_TYPE]);
>
>  BPF_CALL_2(bpf_get_local_storage, struct bpf_map *, map, u64, flags)
>  {
> @@ -204,8 +205,11 @@ BPF_CALL_2(bpf_get_local_storage, struct bpf_map *, map, 
> u64, flags)
>  * verifier checks that its value is correct.
>  */
> enum bpf_cgroup_storage_type stype = cgroup_storage_type(map);
> +   struct bpf_cgroup_storage *storage;
>
> -   return (unsigned long) this_cpu_read(bpf_cgroup_storage[stype]);
> +   storage = this_cpu_read(bpf_cgroup_storage[stype]);
> +
> +   return (unsigned long)&READ_ONCE(storage->buf)->data[0];
>  }
>
>  const struct bpf_func_proto bpf_get_local_storage_proto = {
> diff --git a/kernel/bpf/local_storage.c b/kernel/bpf/local_storage.c
> index 0bd9f19fc557..6742292fb39e 100644
> --- a/kernel/bpf/local_storage.c
> +++ b/kernel/bpf/local_storage.c
> @@ -7,7 +7,8 @@
>  #include 
>  #include 
>
> -DEFINE_PER_CPU(void*, bpf_cgroup_storage[MAX_BPF_CGROUP_STORAGE_TYPE]);
> +DEFINE_PER_CPU(struct bpf_cgroup_storage*,
> +  bpf_cgroup_storage[MAX_BPF_CGROUP_STORAGE_TYPE]);
>
>  #ifdef CONFIG_CGROUP_BPF
>
> --
> 2.17.1
>


[PATCH] ARM: dts: add omap3-gta04a5one to Makefile

2018-09-24 Thread H. Nikolaus Schaller
We have defined a new DTS and it should be compiled.

Signed-off-by: H. Nikolaus Schaller 
---
 arch/arm/boot/dts/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index b5bd3de87c33..8cb78264adee 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -649,6 +649,7 @@ dtb-$(CONFIG_ARCH_OMAP3) += \
omap3-gta04a3.dtb \
omap3-gta04a4.dtb \
omap3-gta04a5.dtb \
+   omap3-gta04a5one.dtb \
omap3-ha.dtb \
omap3-ha-lcd.dtb \
omap3-igep0020.dtb \
-- 
2.12.2



Re: [PATCH v2 1/2] mm/page_alloc: Fix panic caused by passing debug_guardpage_minorder or kernelcore to command line

2018-09-24 Thread Michal Hocko
On Mon 24-09-18 14:42:17, Andrew Morton wrote:
> On Mon, 24 Sep 2018 16:24:08 +0200 Michal Hocko  wrote:
> 
> > On Sat 22-09-18 22:53:32, zhe...@windriver.com wrote:
> > > From: He Zhe 
> > > 
> > > debug_guardpage_minorder_setup and cmdline_parse_kernelcore do not check
> > > input argument before using it. The argument would be a NULL pointer if
> > > "debug_guardpage_minorder" or "kernelcore", without its value, is set in
> > > command line and thus causes the following panic.
> > > 
> > > PANIC: early exception 0xe3 IP 10:a08146f1 error 0 cr2 0x0
> > > [0.00] CPU: 0 PID: 0 Comm: swapper Not tainted 
> > > 4.19.0-rc4-yocto-standard+ #11
> > > [0.00] RIP: 0010:parse_option_str+0x11/0x90
> > > ...
> > > [0.00] Call Trace:
> > > [0.00]  cmdline_parse_kernelcore+0x19/0x41
> > > [0.00]  do_early_param+0x57/0x8e
> > > [0.00]  parse_args+0x208/0x320
> > > [0.00]  ? rdinit_setup+0x30/0x30
> > > [0.00]  parse_early_options+0x29/0x2d
> > > [0.00]  ? rdinit_setup+0x30/0x30
> > > [0.00]  parse_early_param+0x36/0x4d
> > > [0.00]  setup_arch+0x336/0x99e
> > > [0.00]  start_kernel+0x6f/0x4ee
> > > [0.00]  x86_64_start_reservations+0x24/0x26
> > > [0.00]  x86_64_start_kernel+0x6f/0x72
> > > [0.00]  secondary_startup_64+0xa4/0xb0
> > > 
> > > This patch adds a check to prevent the panic
> > 
> > Is this something we deeply care about? The kernel command line
> > interface is to be used by admins who know what they are doing.  Using
> > random or wrong values for these parameters can have detrimental effects
> > on the system. This particular case would blow up early, good. At least
> > it is visible immediately. This and many other parameters could have a
> > seemingly valid input (e.g. not a missing value) and subtle runtime
> > effect. You won't blow up immediately but the system is hardly usable
> > and the early checking cannot possible catch all those cases. Take a
> > mem=$N copied from one machine to another with a different memory
> > layout. While 2G can be perfectly fine on one a different machine might
> > result on a completely unusable system because the available RAM is
> > place higher.
> > 
> > So I am really wondering. Do we really want a lot of code to catch
> > kernel command line incorrect inputs? Does it really lead to better
> > quality overall? IMHO, we do have a proper documentation and we should
> > trust those starting the kernel.
> 
> No, it's not very important.  It might help some people understand why
> their kernel went splat in rare circumstances.  And it's __init code so
> the runtime impact is nil.
> 
> It bothers me that there are many other kernel parameters which have
> the same undesirable behaviour.  I'd much prefer a general fixup which
> gave all of them this treatment, but it's unclear how to do this.

If early_param took an additional argument to tell "this really requires
a parameter" then we could do it in the common code.

$ git grep "early_param(\"" | wc -l
251

quite a lot of work for something that hasn't been a problem for years I
guess. But maybe this would allow to remove ad-hoc checks in handlers
and reduce the overal code size (in LOC) in the end.
-- 
Michal Hocko
SUSE Labs


Re: [PATCH v2] remoteproc: q6v5: Add support to vote for rpmh power domains

2018-09-24 Thread Rajendra Nayak

Hi Ulf,

On 9/11/2018 5:00 PM, Ulf Hansson wrote:

+Viresh

On 4 September 2018 at 09:10, Rajendra Nayak  wrote:

With rpmh ARC resources being modelled as power domains with performance
state,
we need to proxy vote on these for SDM845.
Add support to vote on multiple of them, now that genpd supports
associating
mutliple power domains to a device.


thanks for the review, looks like I missed responding to this one somehow :(



I guess it's fair to mention that the votes are, at this point, done
for maximum performance!?

Is that really needed in the long run? I mean, I guess you should walk
through the OPP library to find the needed performance level? No?


well, yes the votes are for max perf, but these are just sort of *proxy*
votes from the remoteproc driver on behalf of the firmware, up until the
time the firmware itself is up and running and can put its own requests.
So this is general practice to just vote for max clocks/regulator/perf states
because we don't really know what meets the firmware requirements.





Signed-off-by: Rajendra Nayak 
---
Changes in v2:
* Drop the perf vote along with disabling the powerdomain
* pm_suspend_ignore_children() to not mess with runtime PM of children
* Detach powerdomains as part of .remove and in error path during probe,
issue reported by Brian Norris 
* Use dev_pm_domain_attach_by_name() api

  drivers/remoteproc/qcom_q6v5_pil.c | 111 -
  1 file changed, 109 insertions(+), 2 deletions(-)

diff --git a/drivers/remoteproc/qcom_q6v5_pil.c 
b/drivers/remoteproc/qcom_q6v5_pil.c
index d7a4b9eca5d2..f4b3a9b09a5d 100644
--- a/drivers/remoteproc/qcom_q6v5_pil.c
+++ b/drivers/remoteproc/qcom_q6v5_pil.c
@@ -25,6 +25,8 @@
  #include 
  #include 
  #include 
+#include 
+#include 
  #include 
  #include 
  #include 
@@ -131,6 +133,7 @@ struct rproc_hexagon_res {
 char **proxy_clk_names;
 char **reset_clk_names;
 char **active_clk_names;
+   char **pd_names;
 int version;
 bool need_mem_protection;
 bool has_alt_reset;
@@ -155,9 +158,11 @@ struct q6v5 {
 struct clk *active_clks[8];
 struct clk *reset_clks[4];
 struct clk *proxy_clks[4];
+   struct device *pd_devs[3];
 int active_clk_count;
 int reset_clk_count;
 int proxy_clk_count;
+   int pd_count;

 struct reg_info active_regs[1];
 struct reg_info proxy_regs[3];
@@ -316,6 +321,40 @@ static void q6v5_clk_disable(struct device *dev,
 clk_disable_unprepare(clks[i]);
  }

+static int q6v5_powerdomain_enable(struct device *dev, struct device **devs,
+  int count)


Looks like passing the qproc struct, rather than a couple of its
member could simplify the code a bit. No strong opinion though.


sure, I will try to simplify this one.




+{
+   int i;
+
+   if (!count)
+   return 0;
+
+   if (count > 1)
+   for (i = 0; i < count; i++)
+   dev_pm_genpd_set_performance_state(devs[i], INT_MAX);
+   else
+   dev_pm_genpd_set_performance_state(dev, INT_MAX);
+
+   return pm_runtime_get_sync(dev);
+}
+
+static int q6v5_powerdomain_disable(struct device *dev, struct device **devs,
+   int count)


Ditto.


+{
+   int i;
+
+   if (!count)
+   return 0;
+
+   if (count > 1)
+   for (i = 0; i < count; i++)
+   dev_pm_genpd_set_performance_state(devs[i], 0);
+   else
+   dev_pm_genpd_set_performance_state(dev, 0);
+
+   return pm_runtime_put(dev);
+}
+
  static int q6v5_xfer_mem_ownership(struct q6v5 *qproc, int *current_perm,
bool remote_owner, phys_addr_t addr,
size_t size)
@@ -792,11 +831,18 @@ static int q6v5_start(struct rproc *rproc)

 qcom_q6v5_prepare(&qproc->q6v5);

+   ret = q6v5_powerdomain_enable(qproc->dev, qproc->pd_devs,
+ qproc->pd_count);
+   if (ret < 0) {
+   dev_err(qproc->dev, "failed to enable power domains\n");
+   goto disable_irqs;
+   }
+
 ret = q6v5_regulator_enable(qproc, qproc->proxy_regs,
 qproc->proxy_reg_count);
 if (ret) {
 dev_err(qproc->dev, "failed to enable proxy supplies\n");
-   goto disable_irqs;
+   goto disable_powerdomains;
 }

 ret = q6v5_clk_enable(qproc->dev, qproc->proxy_clks,
@@ -920,6 +966,8 @@ static int q6v5_start(struct rproc *rproc)
 q6v5_regulator_disable(qproc, qproc->proxy_regs,
qproc->proxy_reg_count);

+disable_powerdomains:
+   q6v5_powerdomain_disable(qproc->dev, qproc->pd_devs, qproc->pd_count);
  disable_irqs:
 qcom_q6v5_unprepare(&qproc->q6v5);

@@ -972,7 +1020,7 @@ static int q6v5_stop(struct

Re: [patch v2] mm, thp: always specify ineligible vmas as nh in smaps

2018-09-24 Thread Michal Hocko
On Mon 24-09-18 22:43:49, Vlastimil Babka wrote:
> On 9/24/18 10:02 PM, Michal Hocko wrote:
> > On Mon 24-09-18 21:56:03, Michal Hocko wrote:
[...]
> >> That being said, I do not object to the patch, I am just trying to
> >> understand what is the intended usage for the flag that does try to say
> >> more than the madvise status.
> > 
> > And moreover, how is the PR_SET_THP_DISABLE any different from the
> > global THP disabled case. Do we want to set all vmas to nh as well?
> 
> Probably not. It's easy to check the global status, but is it possible
> to query for the prctl flags of a process?

Dunno but I suspect there is no way to check for this.

> We are looking at process or
> even vma-specific flags here. If the prctl was historically implemented
> via VM_NOHUGEPAGE and thus reported as such in smaps, it makes sense to
> do so even with the MMF_ flag IMHO?

Yes if this breaks some userspace which relied on the previous behavior.
But if nothing really broke then I guess it would be better to have the
semantic as clear as possible. Go and check the global status to make
the whole picture doesn't look very sound to me. On the other hand this
VMA has a madvise flag on it sounds quite clear and you know what to
expect at least. Sure the hint might be ignored in the end but well,
these are hints they do not guarantee anything after all.
-- 
Michal Hocko
SUSE Labs


[LKP] [mm, oom] 6209f6fc62: general_protection_fault:#[##]

2018-09-24 Thread kernel test robot
FYI, we noticed the following commit (built with gcc-7):

commit: 6209f6fc62835d84c2a92d237588a114e39436ce ("mm, oom: rework mmap_exit 
vs. oom_reaper synchronization")
https://github.com/0day-ci/linux 
UPDATE-20180911-024633/Tetsuo-Handa/mm-oom-Fix-unnecessary-killing-of-additional-processes/20180910-163452

in testcase: trinity
with following parameters:

runtime: 300s

test-description: Trinity is a linux system call fuzz tester.
test-url: http://codemonkey.org.uk/projects/trinity/


on test machine: qemu-system-x86_64 -enable-kvm -cpu Haswell,+smep,+smap -smp 2 
-m 512M

caused below changes (please refer to attached dmesg/kmsg for entire 
log/backtrace):


+--+++
|  | a49a9dcce8 | 6209f6fc62 |
+--+++
| boot_successes   | 4  | 0  |
| boot_failures| 11 | 9  |
| invoked_oom-killer:gfp_mask=0x   | 10 | 9  |
| Mem-Info | 11 | 9  |
| Out_of_memory:Kill_process   | 11 | 9  |
| general_protection_fault:#[##]   | 0  | 7  |
| RIP:__oom_reap_task_mm   | 0  | 8  |
| Kernel_panic-not_syncing:Fatal_exception | 0  | 8  |
+--+++




[   75.095365] [431] 0   431 4460 1839696320
 -1000 sed
[   75.116040] [439] 0   439 4469  729737280
 -1000 rc.local
[   75.137487] [440] 0   440 1078  313532480
 0 sleep
[   75.158428] [441] 0   441 4990  178614400
 -1000 lkp-setup-rootf
[   75.181175] [442] 0   442   85   49409600
 -1000 run-parts
[   75.202754] Out of memory: Kill process 397 (rc) score 7 or sacrifice child
[   75.219642] Killed process 427 (S99rc.local) total-vm:18036kB, 
anon-rss:420kB, file-rss:2704kB, shmem-rss:0kB
/etc/init.d/rc: line 149:   427 Killed  $debug "$script" $action
[   75.270407] general protection fault:  [#1] DEBUG_PAGEALLOC PTI
[   75.289553] CPU: 0 PID: 11 Comm: oom_reaper Not tainted 
4.19.0-rc2-00206-g6209f6f #1
[   75.309358] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.10.2-1 04/01/2014
[   75.330813] RIP: 0010:__oom_reap_task_mm+0x40/0x180
[   75.343290] Code: 8b 04 25 28 00 00 00 48 89 45 d0 31 c0 80 8f b2 04 00 00 
40 48 8b 1f 48 85 db 0f 84 0b 01 00 00 49 89 fc c6 85 47 ff ff ff 01 <48> 8b 43 
50 a9 00 24 40 00 0f 85 e3 00 00 00 48 83 bb 90 00 00 00
[   75.386036] RSP: 0018:88001d087db8 EFLAGS: 00010202
[   75.399221] RAX: 6b6b6b6b6b6b6b6b RBX: 6b6b6b6b6b05036b RCX: 01ab
[   75.416364] RDX: 88001d0828e0 RSI: a0ac31fe RDI: 88000d103a80
[   75.433182] RBP: 88001d087e78 R08: 4ab0396a R09: a0ac31fe
[   75.449774] R10: 88000d103b78 R11: 88001d0822c0 R12: 88000d103a80
[   75.466591] R13: 88000d103a80 R14: 88000d103b28 R15: 840b6574
[   75.483286] FS:  () GS:8308c000() 
knlGS:
[   75.503824] CS:  0010 DS:  ES:  CR0: 80050033
[   75.518117] CR2: 7f7171c3b1f4 CR3: 03062003 CR4: 000206b0
[   75.533929] Call Trace:
[   75.541424]  ? oom_reaper+0x1aa/0x4c0
[   75.550332]  oom_reaper+0x36b/0x4c0
[   75.559503]  ? __wake_up_common_lock+0xc0/0xc0
[   75.569710]  kthread+0x151/0x160
[   75.578584]  ? __oom_reap_task_mm+0x180/0x180
[   75.589480]  ? __kthread_create_on_node+0x1e0/0x1e0
[   75.601818]  ret_from_fork+0x24/0x30
[   75.637304] ---[ end trace 084a6c5aff200732 ]---
[   75.661129] RIP: 0010:__oom_reap_task_mm+0x40/0x180
[   75.672375] Code: 8b 04 25 28 00 00 00 48 89 45 d0 31 c0 80 8f b2 04 00 00 
40 48 8b 1f 48 85 db 0f 84 0b 01 00 00 49 89 fc c6 85 47 ff ff ff 01 <48> 8b 43 
50 a9 00 24 40 00 0f 85 e3 00 00 00 48 83 bb 90 00 00 00
[   75.717670] RSP: 0018:88001d087db8 EFLAGS: 00010202
[   75.733410] RAX: 6b6b6b6b6b6b6b6b RBX: 6b6b6b6b6b05036b RCX: 01ab
[   75.751142] RDX: 88001d0828e0 RSI: a0ac31fe RDI: 88000d103a80
[   75.769090] RBP: 88001d087e78 R08: 4ab0396a R09: a0ac31fe
[   75.786955] R10: 88000d103b78 R11: 88001d0822c0 R12: 88000d103a80
[   75.805100] R13: 88000d103a80 R14: 88000d103b28 R15: 840b6574
[   75.823112] FS:  () GS:8308c000() 
knlGS:
[   75.845084] CS:  0010 DS:  ES:  CR0: 80050033
[   75.860290] CR2: 7f7171c3b1f4 CR3: 03062003 CR4: 000206b0
[   75.878136] Kernel panic - not syncing: Fatal exception
[   75.891719] Kernel Offset: disabled

Elapsed time

Re: [PATCH 3.18 104/105] IB/nes: Fix a compiler warning

2018-09-24 Thread Joe Perches
On Mon, 2018-09-24 at 22:39 +, Sasha Levin wrote:
> The reasoning behind it was similar to the "no warnings" reasoning of
> upstream: there might be real issues hiding in the sea of "harmless"
> warnings, so we want to get rid of all of them to catch real issues.

I believe this to be a poor idea for -stable acceptance.

It's impossible to know when gcc or any other compiler
would decide to add any new warning.




Re: [RFC PATCH] selinux: add a fallback to defcontext for native labeling

2018-09-24 Thread Taras Kondratiuk
Quoting Paul Moore (2018-09-24 20:46:57)
> On Fri, Sep 21, 2018 at 10:39 AM Stephen Smalley  wrote:
> > On 09/20/2018 06:59 PM, Taras Kondratiuk wrote:
> > > Quoting Stephen Smalley (2018-09-20 07:49:12)
> > >> On 09/19/2018 10:41 PM, Taras Kondratiuk wrote:
> > >>> Quoting Stephen Smalley (2018-09-19 12:00:33)
> >  On 09/19/2018 12:52 PM, Taras Kondratiuk wrote:
> 
> ...
> 
> > > IMO it would be more consistent if defcontext cover all "unlabeled"
> > > groups. It seems unlikely to me that somebody who currently uses
> > > defcontext can somehow rely on mapping invalid labels to unlabeled
> > > instead of default context.
> >
> > Yes, and that seems more consistent with the current documentation in
> > the mount man page for defcontext=.
> >
> > I'd be inclined to change selinux_inode_notifysecctx() to call
> > security_context_to_sid_default() directly instead of using
> > selinux_inode_setsecurity() and change security_context_to_sid_core()
> > and sidtab_search_core() as suggested above to save and use the def_sid
> > instead of SECINITSID_UNLABELED always (initializing the context def_sid
> > to SECINITSID_UNLABELED as the default).  selinux_inode_setsecurity() we
> > should leave unchanged, or if we change it at all, it should be more
> > like the handling in selinux_inode_setxattr().  The notifysecctx hook is
> > invoked by the filesystem to notify the security module of the file's
> > existing security context, so in that case we always want the _default
> > behavior, whereas the setsecurity hook is invoked by the vfs or the
> > filesystem to set the security context of a file to a new value, so in
> > that case we would only use the _force interface if the caller had
> > CAP_MAC_ADMIN.
> >
> > Paul, what say you?  NB This would be a user-visible behavior change for
> > mounts specifying defcontext= on xattr filesystems; files with invalid
> > contexts will then show up with the defcontext value instead of the
> > unlabeled context.  If that's too risky, then we'd need a flag or
> > something to security_context_to_sid_default() to distinguish the
> > behaviors and only set it when called from selinux_inode_notifysecctx().
> 
> Visible changes like this are always worrisome, even though I think it
> is safe to assume that the defcontext option is not widely used.  I'd
> feel much better if this change was opt-in.
> 
> Which brings about it's own problems.  We have the policy capability
> functionality, but that is likely a poor fit for this as the policy
> capabilities are usually controlled by the Linux distribution while
> the mount options are set by the system's administrator when the
> filesystem is mounted.  We could add a toggle somewhere in selinuxfs,
> but I really dislike that idea, and would prefer to find a different
> solution if possible.  I'm not sure how much flak we would get for
> introducing a new mount option, but perhaps that is the best way to
> handle this: defcontext would continue to behave as it does now, but
> new option X would behave as mentioned in this thread.
> 
> Thoughts?

The new option X will also mean "default context", so it will be pretty
hard to come up with a different but a sensible name. I'm afraid that
having two options with hardly distinguishable semantics will be very
confusing.

What about a kernel config option that modifies the behavior of
defcontext?


linux-next: Tree for Sep 25

2018-09-24 Thread Stephen Rothwell
Hi all,

Changes since 20180924:

Dropped trees: xarray, ida (temporarily)

Non-merge commits (relative to Linus' tree): 5626
 6053 files changed, 275592 insertions(+), 120719 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, an allmodconfig 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 (with and without kvm enabled).

Below is a summary of the state of the merge.

I am currently merging 288 trees (counting Linus' and 66 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 (02214bfc89c7 Merge tag 'media/v4.19-2' of 
git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media)
Merging fixes/master (72358c0b59b7 linux-next: build warnings from the build of 
Linus' tree)
Merging kbuild-current/fixes (ef8c4ed9db80 kbuild: allow to use GCC toolchain 
not in Clang search path)
Merging arc-current/for-curr (40660f1fcee8 ARC: build: Don't set CROSS_COMPILE 
in arch's Makefile)
Merging arm-current/fixes (afc9f65e01cd ARM: 8781/1: Fix Thumb-2 syscall return 
for binutils 2.29+)
Merging arm64-fixes/for-next/fixes (031e6e6b4e12 arm64: hugetlb: Avoid 
unnecessary clearing in huge_ptep_set_access_flags)
Merging m68k-current/for-linus (0986b16ab49b m68k/mac: Use correct PMU response 
format)
Merging powerpc-fixes/fixes (c716a25b9b70 powerpc/pkeys: Fix reading of ibm, 
processor-storage-keys property)
Merging sparc/master (df2def49c57b Merge tag 'acpi-4.19-rc1-2' of 
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm)
Merging fscrypt-current/for-stable (ae64f9bd1d36 Linux 4.15-rc2)
Merging net/master (f4a518797b40 net: mvneta: fix the remaining Rx descriptor 
unmapping issues)
Merging bpf/master (fad0c40fab14 Merge branch 'bpf-sockmap-estab-fixes')
Merging ipsec/master (32bf94fb5c2e xfrm: validate template mode)
Merging netfilter/master (346fa83d1093 netfilter: conntrack: get rid of double 
sizeof)
Merging ipvs/master (feb9f55c33e5 netfilter: nft_dynset: allow dynamic updates 
of non-anonymous set)
Merging wireless-drivers/master (2823c8716c68 b43: fix DMA error related 
regression with proprietary firmware)
Merging mac80211/master (c42055105785 mac80211: fix TX status reporting for 
ieee80211s)
Merging rdma-fixes/for-rc (b4a4957d3d1c IB/hfi1: Fix destroy_qp hang after a 
link down)
Merging sound-current/for-linus (b3a5402cbceb ALSA: hda: Fix the 
audio-component completion timeout)
Merging sound-asoc-fixes/for-linus (85adbf9815ab Merge branch 'asoc-4.19' into 
asoc-linus)
Merging regmap-fixes/for-linus (7876320f8880 Linux 4.19-rc4)
Merging regulator-fixes/for-linus (69a3f680261f Merge branch 'regulator-4.19' 
into regulator-linus)
Merging spi-fixes/for-linus (1f6b3b2c1ff4 Merge branch 'spi-4.19' into 
spi-linus)
Merging pci-current/for-linus (9024143e700f PCI: dwc: Fix scheduling while 
atomic issues)
Merging driver-core.current/driver-core-linus (7876320f8880 Linux 4.19-rc4)
Merging tty.current/tty-linus (7e620984b625 serial: imx: restore handshaking 
irq for imx1)
Merging usb.current/usb-linus (3e3b81965cbf usb: typec: mux: Take care of 
driver module reference counting)
Merging usb-gadget-fixes/fixes (d9707490077b usb: dwc2: Fix call location of 
dwc2_check_core_endianness)
Merging usb-serial-fixes/usb-linus (f5fad711c06e USB: serial: simple: add 
Motorola Tetra MTP6550 id)
Merging usb-chipidea-fixes/ci-for-usb-stable (a930d8bd94d8 usb: chipidea: 
Always build 

Re: [PATCH 1/2] phy: zynqmp: Add phy driver for xilinx zynqmp phy core

2018-09-24 Thread Kishon Vijay Abraham I
Hi,

On Wednesday 29 August 2018 07:37 PM, Anurag Kumar Vulisha wrote:
> ZynqMP SoC has a Gigabit Transceiver with four lanes. All the high speed
> peripherals such as USB, SATA, PCIE, Display Port and Ethernet SGMII can
> rely on any of the four GT lanes for PHY layer. This patch adds driver
> for that ZynqMP GT core.
> 
> Signed-off-by: Anurag Kumar Vulisha 
> ---
>  drivers/phy/Kconfig|8 +
>  drivers/phy/Makefile   |1 +
>  drivers/phy/phy-zynqmp.c   | 1579 
> 
>  include/dt-bindings/phy/phy.h  |2 +
>  include/linux/phy/phy-zynqmp.h |   52 ++
>  5 files changed, 1642 insertions(+)
>  create mode 100644 drivers/phy/phy-zynqmp.c
>  create mode 100644 include/linux/phy/phy-zynqmp.h
> 
> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> index 5c8d452..14cf3330 100644
> --- a/drivers/phy/Kconfig
> +++ b/drivers/phy/Kconfig
> @@ -40,6 +40,14 @@ config PHY_XGENE
>   help
> This option enables support for APM X-Gene SoC multi-purpose PHY.
>  
> +config PHY_XILINX_ZYNQMP
> + tristate "Xilinx ZynqMP PHY driver"
> + depends on ARCH_ZYNQMP
> + select GENERIC_PHY
> + help
> +   Enable this to support ZynqMP High Speed Gigabit Transceiver
> +   that is part of ZynqMP SoC.
> +
>  source "drivers/phy/allwinner/Kconfig"
>  source "drivers/phy/amlogic/Kconfig"
>  source "drivers/phy/broadcom/Kconfig"
> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
> index 84e3bd9..f2a8d27 100644
> --- a/drivers/phy/Makefile
> +++ b/drivers/phy/Makefile
> @@ -7,6 +7,7 @@ obj-$(CONFIG_GENERIC_PHY) += phy-core.o
>  obj-$(CONFIG_PHY_LPC18XX_USB_OTG)+= phy-lpc18xx-usb-otg.o
>  obj-$(CONFIG_PHY_XGENE)  += phy-xgene.o
>  obj-$(CONFIG_PHY_PISTACHIO_USB)  += phy-pistachio-usb.o
> +obj-$(CONFIG_PHY_XILINX_ZYNQMP)  += phy-zynqmp.o
>  obj-$(CONFIG_ARCH_SUNXI) += allwinner/
>  obj-$(CONFIG_ARCH_MESON) += amlogic/
>  obj-$(CONFIG_LANTIQ) += lantiq/
> diff --git a/drivers/phy/phy-zynqmp.c b/drivers/phy/phy-zynqmp.c
> new file mode 100644
> index 000..306cedd
> --- /dev/null
> +++ b/drivers/phy/phy-zynqmp.c
> @@ -0,0 +1,1579 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * phy-zynqmp.c - PHY driver for Xilinx ZynqMP GT.
> + *
> + * Copyright (C) 2018 Xilinx Inc.
> + *
> + * Author: Anurag Kumar Vulisha 
> + *
> + * This driver is tested for USB, SATA and Display Port currently.
> + * Other controllers PCIe and SGMII should also work but that is
> + * experimental as of now.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/* Inter Connect Matrix parameters */
> +#define ICM_CFG0 0x10010
> +#define ICM_CFG1 0x10014
> +#define ICM_CFG0_L0_MASK 0x07
> +#define ICM_CFG0_L1_MASK 0x70
> +#define ICM_CFG1_L2_MASK 0x07
> +#define ICM_CFG2_L3_MASK 0x70
> +#define ICM_CFG_SHIFT4
> +
> +/* Inter Connect Matrix allowed protocols */
> +#define ICM_PROTOCOL_PD  0x0
> +#define ICM_PROTOCOL_PCIE0x1
> +#define ICM_PROTOCOL_SATA0x2
> +#define ICM_PROTOCOL_USB 0x3
> +#define ICM_PROTOCOL_DP  0x4
> +#define ICM_PROTOCOL_SGMII   0x5
> +
> +/* Test Mode common reset control  parameters */
> +#define TM_CMN_RST   0x10018
> +#define TM_CMN_RST_EN0x1
> +#define TM_CMN_RST_SET   0x2
> +#define TM_CMN_RST_MASK  0x3
> +
> +/* Refclk selection parameters */
> +#define PLL_REF_SEL0 0x1
> +#define PLL_REF_OFFSET   0x4
> +#define PLL_FREQ_MASK0x1F
> +#define PLL_STATUS_READ_OFFSET   0x4000
> +#define PLL_STATUS_LOCKED0x10
> +
> +/* PLL SSC step size offsets */
> +#define L0_L0_REF_CLK_SEL0x2860
> +#define L0_PLL_SS_STEPS_0_LSB0x2368
> +#define L0_PLL_SS_STEPS_1_MSB0x236C
> +#define L0_PLL_SS_STEP_SIZE_0_LSB0x2370
> +#define L0_PLL_SS_STEP_SIZE_10x2374
> +#define L0_PLL_SS_STEP_SIZE_20x2378
> +#define L0_PLL_SS_STEP_SIZE_3_MSB0x237C
> +#define L0_PLL_STATUS_READ_1 0x23E4
> +
> +/* SSC step size parameters */
> +#define STEP_SIZE_OFFSET 0x4000
> +#define STEP_SIZE_0_MASK 0xFF
> +#define STEP_SIZE_1_MASK 0xFF
> +#define STEP_SIZE_2_MASK 0xFF
> +#define STEP_SIZE_3_MASK 0x3
> +#define STEP_SIZE_SHIFT  8
> +#define FORCE_STEP_SIZE  0x10
> +#define FORCE_STEPS  0x20
> +#define STEPS_OFFSET 0x4000
> +#define

[PATCH v2 2/2] treewide: use bus_find_device_by_fwnode

2018-09-24 Thread Silesh C V
Use bus_find_device_by_fwnode helper to find the device having a
specific firmware node on a bus.
---
 drivers/hwtracing/coresight/of_coresight.c | 14 --
 drivers/i2c/i2c-core-of.c  |  9 ++---
 drivers/infiniband/hw/hns/hns_roce_hw_v1.c |  8 +---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c |  8 +---
 drivers/nvmem/core.c   |  7 +--
 drivers/of/of_mdio.c   |  8 +---
 drivers/of/platform.c  |  7 +--
 drivers/spi/spi.c  | 10 +++---
 8 files changed, 14 insertions(+), 57 deletions(-)

diff --git a/drivers/hwtracing/coresight/of_coresight.c 
b/drivers/hwtracing/coresight/of_coresight.c
index 6880bee..8193b50 100644
--- a/drivers/hwtracing/coresight/of_coresight.c
+++ b/drivers/hwtracing/coresight/of_coresight.c
@@ -17,12 +17,6 @@
 #include 
 #include 
 
-
-static int of_dev_node_match(struct device *dev, void *data)
-{
-   return dev->of_node == data;
-}
-
 static struct device *
 of_coresight_get_endpoint_device(struct device_node *endpoint)
 {
@@ -32,8 +26,8 @@ static int of_dev_node_match(struct device *dev, void *data)
 * If we have a non-configurable replicator, it will be found on the
 * platform bus.
 */
-   dev = bus_find_device(&platform_bus_type, NULL,
- endpoint, of_dev_node_match);
+   dev = bus_find_device_by_fwnode(&platform_bus_type, NULL,
+   &endpoint->fwnode);
if (dev)
return dev;
 
@@ -41,8 +35,8 @@ static int of_dev_node_match(struct device *dev, void *data)
 * We have a configurable component - circle through the AMBA bus
 * looking for the device that matches the endpoint node.
 */
-   return bus_find_device(&amba_bustype, NULL,
-  endpoint, of_dev_node_match);
+   return bus_find_device_by_fwnode(&amba_bustype, NULL,
+   &endpoint->fwnode);
 }
 
 static void of_coresight_get_ports(const struct device_node *node,
diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c
index 6cb7ad6..2b8ef8d 100644
--- a/drivers/i2c/i2c-core-of.c
+++ b/drivers/i2c/i2c-core-of.c
@@ -116,18 +116,13 @@ void of_i2c_register_devices(struct i2c_adapter *adap)
of_node_put(bus);
 }
 
-static int of_dev_node_match(struct device *dev, void *data)
-{
-   return dev->of_node == data;
-}
-
 /* must call put_device() when done with returned i2c_client device */
 struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
 {
struct device *dev;
struct i2c_client *client;
 
-   dev = bus_find_device(&i2c_bus_type, NULL, node, of_dev_node_match);
+   dev = bus_find_device_by_fwnode(&i2c_bus_type, NULL, &node->fwnode);
if (!dev)
return NULL;
 
@@ -145,7 +140,7 @@ struct i2c_adapter *of_find_i2c_adapter_by_node(struct 
device_node *node)
struct device *dev;
struct i2c_adapter *adapter;
 
-   dev = bus_find_device(&i2c_bus_type, NULL, node, of_dev_node_match);
+   dev = bus_find_device_by_fwnode(&i2c_bus_type, NULL, &node->fwnode);
if (!dev)
return NULL;
 
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c 
b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
index 081aa91..b0d418e 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
@@ -4832,19 +4832,13 @@ static void hns_roce_v1_cleanup_eq_table(struct 
hns_roce_dev *hr_dev)
 };
 MODULE_DEVICE_TABLE(acpi, hns_roce_acpi_match);
 
-static int hns_roce_node_match(struct device *dev, void *fwnode)
-{
-   return dev->fwnode == fwnode;
-}
-
 static struct
 platform_device *hns_roce_find_pdev(struct fwnode_handle *fwnode)
 {
struct device *dev;
 
/* get the 'device' corresponding to the matching 'fwnode' */
-   dev = bus_find_device(&platform_bus_type, NULL,
- fwnode, hns_roce_node_match);
+   dev = bus_find_device_by_fwnode(&platform_bus_type, NULL, fwnode);
/* get the platform device */
return dev ? to_platform_device(dev) : NULL;
 }
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
index 16294cd..d5d7c88 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
@@ -758,17 +758,11 @@ struct dsaf_misc_op *hns_misc_op_get(struct dsaf_device 
*dsaf_dev)
return (void *)misc_op;
 }
 
-static int hns_dsaf_dev_match(struct device *dev, void *fwnode)
-{
-   return dev->fwnode == fwnode;
-}
-
 struct
 platform_device *hns_dsaf_find_platform_device(struct fwnode_handle *fwnode)
 {
struct device *dev;
 
-   dev = bus_find_device(&platform_bus_type, NULL,
-

[PATCH v2 1/2] Driver core: add bus_find_device_by_fwnode

2018-09-24 Thread Silesh C V
Some drivers need to find the device on a bus having a specific firmware
node. Currently, such drivers have their own implementations to do this.
Provide a helper similar to bus_find_device_by_name so that each driver
does not have to reinvent this.

Signed-off-by: Silesh C V 
---
 drivers/base/bus.c | 26 ++
 include/linux/device.h |  3 +++
 2 files changed, 29 insertions(+)

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 8bfd27e..148b198 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "base.h"
 #include "power/power.h"
 
@@ -373,6 +374,31 @@ struct device *bus_find_device_by_name(struct bus_type 
*bus,
 }
 EXPORT_SYMBOL_GPL(bus_find_device_by_name);
 
+static int match_fwnode(struct device *dev, void *data)
+{
+   struct fwnode_handle *fwnode = data;
+   struct device_node *of_node = to_of_node(fwnode);
+
+   if (of_node)
+   return dev->of_node == of_node;
+   else
+   return dev->fwnode == fwnode;
+}
+
+/**
+ * bus_find_device_by_fwnode - device iterator for locating a particular device
+ * having a specific firmware node
+ * @bus: bus type
+ * @start: Device to begin with
+ * @fwnode: firmware node of the device to match
+ */
+struct device *bus_find_device_by_fwnode(struct bus_type *bus, struct device 
*start,
+   struct fwnode_handle *fwnode)
+{
+   return bus_find_device(bus, start, (void *)fwnode, match_fwnode);
+}
+EXPORT_SYMBOL_GPL(bus_find_device_by_fwnode);
+
 /**
  * subsys_find_device_by_id - find a device with a specific enumeration number
  * @subsys: subsystem
diff --git a/include/linux/device.h b/include/linux/device.h
index 8f88254..09384f6 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -171,6 +171,9 @@ struct device *bus_find_device(struct bus_type *bus, struct 
device *start,
 struct device *bus_find_device_by_name(struct bus_type *bus,
   struct device *start,
   const char *name);
+struct device *bus_find_device_by_fwnode(struct bus_type *bus,
+  struct device *start,
+  struct fwnode_handle *fwnode);
 struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id,
struct device *hint);
 int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
-- 
1.9.1



Re: [PATCH] ARM: dts: gta04: add serial console wakeup irq

2018-09-24 Thread Andreas Kemnade
Hi Tony,

On Mon, 24 Sep 2018 15:03:45 -0700
Tony Lindgren  wrote:

> * Andreas Kemnade  [180923 08:12]:
> > This enables the possibility to have more aggressive runtime pm
> > by providing proper wakeup irq for the serial console.  
> 
> Thanks applying to omap-for-v4.20/dt.
> 
> FYI, you can now grep wake /proc/interrupts and see the
> wakeirq counts increase when they trigger. Might be handy
> for debugging PM stuff.
> 
thanks for that information, you also had a patch for checking
pm which was explicitely marked as not-to-merge. Is there
any up-to-date version of it?

Well, for debugging I check first average currents via bq27000
attached to omap_hdq. omap_hdq gets stuck after first transaction
after idling uarts which does not happen when CM_AUTOIDLE1_CORE.AUTO_HDQ
is cleared. Reloading the omap_hdq module to try to fix things
makes w1 really freak out (patch already sent for that).
Well, will do some rtfm and hopefully come back with a patch.
afaicr there was something special...
The result are power management problem in /dev/brain ;-)

Regards,
Andreas


pgpzzP9fixB_3.pgp
Description: OpenPGP digital signature


[PATCH v4] ARM: dts: dra7: Fix up unaligned access setting for PCIe EP

2018-09-24 Thread Vignesh R
Bit positions of PCIE_SS1_AXI2OCP_LEGACY_MODE_ENABLE and
PCIE_SS1_AXI2OCP_LEGACY_MODE_ENABLE in CTRL_CORE_SMA_SW_7 are
incorrectly documented in the TRM. In fact, the bit positions are
swapped. Update the DT bindings for PCIe EP to reflect the same.

Fixes: d23f3839fe97 ("ARM: dts: DRA7: Add pcie1 dt node for EP mode")
Cc: sta...@vger.kernel.org
Signed-off-by: Vignesh R 
---

This patch is split from v3 here:
https://lore.kernel.org/patchwork/cover/967020/
Patch can be applied standalone and has no dependencies on other patches
in v3.

 arch/arm/boot/dts/dra7.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index 1050da6c6d35..fc50d6a8e51a 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -355,7 +355,7 @@
ti,hwmods = "pcie1";
phys = <&pcie1_phy>;
phy-names = "pcie-phy0";
-   ti,syscon-unaligned-access = <&scm_conf1 0x14 
2>;
+   ti,syscon-unaligned-access = <&scm_conf1 0x14 
1>;
status = "disabled";
};
};
-- 
2.19.0



RE: [PATCH] sdhci: arasan: Add runtime PM support

2018-09-24 Thread Manish Narani
Ping!

> -Original Message-
> From: Manish Narani [mailto:manish.nar...@xilinx.com]
> Sent: Tuesday, September 18, 2018 8:34 PM
> To: adrian.hun...@intel.com; Michal Simek ;
> ulf.hans...@linaro.org
> Cc: linux-...@vger.kernel.org; linux-arm-ker...@lists.infradead.org; linux-
> ker...@vger.kernel.org; Manish Narani 
> Subject: [PATCH] sdhci: arasan: Add runtime PM support
> 
> Add runtime PM support in Arasan SDHCI driver.
> 
> Signed-off-by: Manish Narani 
> ---
>  drivers/mmc/host/sdhci-of-arasan.c | 80
> +-
>  1 file changed, 78 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-
> arasan.c
> index a40bcc2..370ada5 100644
> --- a/drivers/mmc/host/sdhci-of-arasan.c
> +++ b/drivers/mmc/host/sdhci-of-arasan.c
> @@ -23,6 +23,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -30,6 +31,7 @@
>  #include "cqhci.h"
>  #include "sdhci-pltfm.h"
> 
> +#define SDHCI_ARASAN_AUTOSUSPEND_DELAY   2000 /* ms */
>  #define SDHCI_ARASAN_VENDOR_REGISTER 0x78
>  #define SDHCI_ARASAN_CQE_BASE_ADDR   0x200
>  #define VENDOR_ENHANCED_STROBE   BIT(0)
> @@ -363,6 +365,70 @@ static const struct sdhci_pltfm_data
> sdhci_arasan_cqe_pdata = {
>   SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN,
>  };
> 
> +#ifdef CONFIG_PM
> +static int sdhci_arasan_runtime_suspend(struct device *dev) {
> + struct platform_device *pdev = to_platform_device(dev);
> + struct sdhci_host *host = platform_get_drvdata(pdev);
> + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
> + struct sdhci_arasan_data *sdhci_arasan =
> sdhci_pltfm_priv(pltfm_host);
> + int ret;
> +
> + if (sdhci_arasan->has_cqe) {
> + ret = cqhci_suspend(host->mmc);
> + if (ret)
> + return ret;
> + }
> +
> + ret = sdhci_runtime_suspend_host(host);
> + if (ret)
> + return ret;
> +
> + if (host->tuning_mode != SDHCI_TUNING_MODE_3)
> + mmc_retune_needed(host->mmc);
> +
> + clk_disable(pltfm_host->clk);
> + clk_disable(sdhci_arasan->clk_ahb);
> +
> + return 0;
> +}
> +
> +static int sdhci_arasan_runtime_resume(struct device *dev) {
> + struct platform_device *pdev = to_platform_device(dev);
> + struct sdhci_host *host = platform_get_drvdata(pdev);
> + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
> + struct sdhci_arasan_data *sdhci_arasan =
> sdhci_pltfm_priv(pltfm_host);
> + int ret;
> +
> + ret = clk_enable(sdhci_arasan->clk_ahb);
> + if (ret) {
> + dev_err(dev, "Cannot enable AHB clock.\n");
> + return ret;
> + }
> +
> + ret = clk_enable(pltfm_host->clk);
> + if (ret) {
> + dev_err(dev, "Cannot enable SD clock.\n");
> + return ret;
> + }
> +
> + ret = sdhci_runtime_resume_host(host);
> + if (ret)
> + goto out;
> +
> + if (sdhci_arasan->has_cqe)
> + return cqhci_resume(host->mmc);
> +
> + return 0;
> +out:
> + clk_disable(pltfm_host->clk);
> + clk_disable(sdhci_arasan->clk_ahb);
> +
> + return ret;
> +}
> +#endif /* ! CONFIG_PM */
> +
>  #ifdef CONFIG_PM_SLEEP
>  /**
>   * sdhci_arasan_suspend - Suspend method for the driver @@ -455,8 +521,10
> @@ static int sdhci_arasan_resume(struct device *dev)  }  #endif /* !
> CONFIG_PM_SLEEP */
> 
> -static SIMPLE_DEV_PM_OPS(sdhci_arasan_dev_pm_ops,
> sdhci_arasan_suspend,
> -  sdhci_arasan_resume);
> +static const struct dev_pm_ops sdhci_arasan_dev_pm_ops = {
> + SET_SYSTEM_SLEEP_PM_OPS(sdhci_arasan_suspend,
> sdhci_arasan_resume)
> + SET_RUNTIME_PM_OPS(sdhci_arasan_runtime_suspend,
> +sdhci_arasan_runtime_resume, NULL) };
> 
>  static const struct of_device_id sdhci_arasan_of_match[] = {
>   /* SoC-specific compatible strings w/ soc_ctl_map */ @@ -821,6
> +889,14 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
>   if (ret)
>   goto err_add_host;
> 
> + pm_runtime_set_active(&pdev->dev);
> + pm_runtime_enable(&pdev->dev);
> + pm_runtime_set_autosuspend_delay(&pdev->dev,
> +
> SDHCI_ARASAN_AUTOSUSPEND_DELAY);
> + pm_runtime_mark_last_busy(&pdev->dev);
> + pm_runtime_use_autosuspend(&pdev->dev);
> + pm_runtime_forbid(&pdev->dev);
> +
>   return 0;
> 
>  err_add_host:
> --
> 2.1.1



Re: [PATCH] of: unittest: Don't dereference args.np after test errors

2018-09-24 Thread Guenter Roeck

Hi Frank,

On 09/24/2018 09:19 PM, Frank Rowand wrote:

Hi Guenter,

On 09/23/18 09:33, Guenter Roeck wrote:

If a devicetree parse function fails, it is quite likely that args.np
is invalid. Trying to dereference it will then cause the system to crash.

This was seen when trying to run devicetree unittests on a g3beige
qemu system. This system has the OF_IMAP_OLDWORLD_MAC flag set in
of_irq_workarounds and expects an 'old style' structure of irq
nodes. Trying to parse the test nodes fails and results in the
following crash.

OF: /testcase-data/phandle-tests/consumer-b: arguments longer than property
Unable to handle kernel paging request for data at address 0x00bc616e
Faulting instruction address: 0xc092437c
Oops: Kernel access of bad area, sig: 11 [#1]
BE PREEMPT PowerMac
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Not tainted 4.19.0-rc4-yocto-standard+ #1
NIP:  c092437c LR: c0925098 CTR: c0925088
REGS: cf8dfb40 TRAP: 0300   Not tainted  (4.19.0-rc4-yocto-standard+)
MSR:  1032   CR: 82004044  XER: 
DAR: 00bc616e DSISR: 4000
GPR00: c0925098 cf8dfbf0 cf8e c14098c7 c14098c7 c1409c50 0066 0002
GPR08: 0063 00bc614e c0b483e9 000a 82004048  0008 c0b36d80
GPR16: c0ac c0b4233c c14098c7 c0b13c14 05ff 000a c0b483e4 c0b00a30
GPR24: cecfe324 cecfe324 c0acc434 c0ac8420 c1409c50 05ff c1409c50 c14098c7
NIP [c092437c] device_node_gen_full_name+0x30/0x15c
LR [c0925098] device_node_string+0x190/0x3c8
Call Trace:
[cf8dfbf0] [c0733704] of_find_property+0x5c/0x74 (unreliable)
[cf8dfc30] [c0925098] device_node_string+0x190/0x3c8
[cf8dfca0] [c092690c] pointer+0x274/0x4d4
[cf8dfcd0] [c0926e20] vsnprintf+0x2b4/0x5ec
[cf8dfd30] [c0927170] vscnprintf+0x18/0x48
[cf8dfd40] [c008eb70] vprintk_store+0x4c/0x22c
[cf8dfd70] [c008f1c4] vprintk_emit+0x94/0x270
[cf8dfda0] [c008fb60] printk+0x5c/0x6c
[cf8dfde0] [c0bd1ec0] of_unittest+0x2670/0x2b48
[cf8dfe80] [c0004ba8] do_one_initcall+0xac/0x320
[cf8dfee0] [c0b8975c] kernel_init_freeable+0x328/0x3f0
[cf8dff30] [c00050c4] kernel_init+0x24/0x118
[cf8dff40] [c0014278] ret_from_kernel_thread+0x14/0x1c

To avoid this and similar problems, don't try to dereference args.np
after devicetree parse failures, and display the name of the parsed node
instead. With this, we get error messages such as

dt-test ### FAIL of_unittest_parse_interrupts():791 index 0 -
data error on node /testcase-data/interrupts/interrupts0 rc=-22

This may not display the intended node name, but it is better than a crash.


Thanks for finding and debugging the root cause of the problem.

As the patch comment notes, the changes do not fix the root cause, but
instead avoid the crash.  I'd like to deal with the root cause instead.

I've never encountered OF_IMAP_OLDWORLD_MAC and need to dig deeper to
understand exactly how having it set leads to the error returns from
of_parse_phandle_with_args().  Thus my off-the-top-of-my-head first
observation is likely to be incorrect.  But I'd like to point out
what I suspect is likely to be a more useful direction for the fix.

I'll use a bit of artful logic to claim that the root cause is that
of_parse_phandle_with_args() does not behave as unittests expect when
OF_IMAP_OLDWORLD_MAC is set.

If the of_parse_phandle_with_args() calls are not going to perform the
test that unittest expects to be performing, then it is pointless to
do the tests.  The fix then is to not do those tests.  For example,
at the top of of_unittest_parse_phandle_with_args(), simply do:

 if (of_irq_workarounds & OF_IMAP_OLDWORLD_MAC)
 return;



I thought about submitting that as second patch, but wanted to wait
for feedback before doing that. I'll be more than happy to drop this
patch and replace it with the above.


I did not look to see whether the other test areas you found can be
as easily avoided, without avoiding tests that are still valid when
OF_IMAP_OLDWORLD_MAC is set, but I am hoping so.

While looking at the patch, I noticed that the current
of_unittest_parse_phandle_with_args() also does not call of_node_put()
in the cases where of_count_phandle_with_args() does not return an
error.  I'll add fixing that to my todo list.

And as you pointed out, of_unittest_parse_phandle_with_args() should
not be blindly using the contents of args when an error occurred.  I'll
also put fixing that on my todo list.



That was the intent of this patch, but I'll be happy to leave it up to you
to find a better solution. I did not check if there are situations where
args.np is still usable, or if it makes a difference if args.np is
preinitialized with NULL, so it might well be that a better fix is
possible.

Thanks,
Guenter


-Frank





Fixes: 53a42093d96ef ("of: Add device tree selftests")
Signed-off-by: Guenter Roeck 
---
  drivers/of/unittest.c | 12 ++--
  1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 722537e14848..5942ddce1b9f 100644
--- a/drivers

Re: [PATCH] of: unittest: Don't dereference args.np after test errors

2018-09-24 Thread Frank Rowand
On 09/24/18 21:19, Frank Rowand wrote:
> Hi Guenter,
> 
> On 09/23/18 09:33, Guenter Roeck wrote:
>> If a devicetree parse function fails, it is quite likely that args.np
>> is invalid. Trying to dereference it will then cause the system to crash.
>>
>> This was seen when trying to run devicetree unittests on a g3beige
>> qemu system. This system has the OF_IMAP_OLDWORLD_MAC flag set in
>> of_irq_workarounds and expects an 'old style' structure of irq
>> nodes. Trying to parse the test nodes fails and results in the
>> following crash.
>>
>> OF: /testcase-data/phandle-tests/consumer-b: arguments longer than property
>> Unable to handle kernel paging request for data at address 0x00bc616e
>> Faulting instruction address: 0xc092437c
>> Oops: Kernel access of bad area, sig: 11 [#1]
>> BE PREEMPT PowerMac
>> Modules linked in:
>> CPU: 0 PID: 1 Comm: swapper Not tainted 4.19.0-rc4-yocto-standard+ #1
>> NIP:  c092437c LR: c0925098 CTR: c0925088
>> REGS: cf8dfb40 TRAP: 0300   Not tainted  (4.19.0-rc4-yocto-standard+)
>> MSR:  1032   CR: 82004044  XER: 
>> DAR: 00bc616e DSISR: 4000
>> GPR00: c0925098 cf8dfbf0 cf8e c14098c7 c14098c7 c1409c50 0066 
>> 0002
>> GPR08: 0063 00bc614e c0b483e9 000a 82004048  0008 
>> c0b36d80
>> GPR16: c0ac c0b4233c c14098c7 c0b13c14 05ff 000a c0b483e4 
>> c0b00a30
>> GPR24: cecfe324 cecfe324 c0acc434 c0ac8420 c1409c50 05ff c1409c50 
>> c14098c7
>> NIP [c092437c] device_node_gen_full_name+0x30/0x15c
>> LR [c0925098] device_node_string+0x190/0x3c8
>> Call Trace:
>> [cf8dfbf0] [c0733704] of_find_property+0x5c/0x74 (unreliable)
>> [cf8dfc30] [c0925098] device_node_string+0x190/0x3c8
>> [cf8dfca0] [c092690c] pointer+0x274/0x4d4
>> [cf8dfcd0] [c0926e20] vsnprintf+0x2b4/0x5ec
>> [cf8dfd30] [c0927170] vscnprintf+0x18/0x48
>> [cf8dfd40] [c008eb70] vprintk_store+0x4c/0x22c
>> [cf8dfd70] [c008f1c4] vprintk_emit+0x94/0x270
>> [cf8dfda0] [c008fb60] printk+0x5c/0x6c
>> [cf8dfde0] [c0bd1ec0] of_unittest+0x2670/0x2b48
>> [cf8dfe80] [c0004ba8] do_one_initcall+0xac/0x320
>> [cf8dfee0] [c0b8975c] kernel_init_freeable+0x328/0x3f0
>> [cf8dff30] [c00050c4] kernel_init+0x24/0x118
>> [cf8dff40] [c0014278] ret_from_kernel_thread+0x14/0x1c
>>
>> To avoid this and similar problems, don't try to dereference args.np
>> after devicetree parse failures, and display the name of the parsed node
>> instead. With this, we get error messages such as
>>
>> dt-test ### FAIL of_unittest_parse_interrupts():791 index 0 -
>>  data error on node /testcase-data/interrupts/interrupts0 rc=-22
>>
>> This may not display the intended node name, but it is better than a crash.
> 
> Thanks for finding and debugging the root cause of the problem.
> 
> As the patch comment notes, the changes do not fix the root cause, but
> instead avoid the crash.  I'd like to deal with the root cause instead.
> 
> I've never encountered OF_IMAP_OLDWORLD_MAC and need to dig deeper to
> understand exactly how having it set leads to the error returns from
> of_parse_phandle_with_args().  Thus my off-the-top-of-my-head first
> observation is likely to be incorrect.  But I'd like to point out
> what I suspect is likely to be a more useful direction for the fix.
> 
> I'll use a bit of artful logic to claim that the root cause is that
> of_parse_phandle_with_args() does not behave as unittests expect when
> OF_IMAP_OLDWORLD_MAC is set.
> 
> If the of_parse_phandle_with_args() calls are not going to perform the
> test that unittest expects to be performing, then it is pointless to
> do the tests.  The fix then is to not do those tests.  For example,
> at the top of of_unittest_parse_phandle_with_args(), simply do:
> 
> if (of_irq_workarounds & OF_IMAP_OLDWORLD_MAC)
> return;

I forgot to mention another rationale for this approach.  This will result
in the number of failed tests to remain at zero.

-Frank


> I did not look to see whether the other test areas you found can be
> as easily avoided, without avoiding tests that are still valid when
> OF_IMAP_OLDWORLD_MAC is set, but I am hoping so.
> 
> While looking at the patch, I noticed that the current
> of_unittest_parse_phandle_with_args() also does not call of_node_put()
> in the cases where of_count_phandle_with_args() does not return an
> error.  I'll add fixing that to my todo list.
> 
> And as you pointed out, of_unittest_parse_phandle_with_args() should
> not be blindly using the contents of args when an error occurred.  I'll
> also put fixing that on my todo list.
> 
> -Frank
> 
> 
> 
>>
>> Fixes: 53a42093d96ef ("of: Add device tree selftests")
>> Signed-off-by: Guenter Roeck 
>> ---
>>  drivers/of/unittest.c | 12 ++--
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
>> index 722537e14848..5942ddce1b9f 100644
>> --- a/drivers/of/unittest.c
>> +++ b/drivers/of/unittest.c
>> @@ -424,7 +424,7 @@ static void __init 
>> of_unittest_parse_pha

[0-Day CI notification] 0-Day CI test service will be unavailable from Sep 30 to Oct 8

2018-09-24 Thread Philip Li
Hi all, this is Philip who maintains the 0-Day CI test service. Thanks for
subscribing to the service. We will have site level power down during China
national holiday, so the service will be unavailable from Asia Pacific Time
Sep 30 5PM to Oct 8 5PM. We will recover it as soon as we can. Sorry for any
inconvenience caused during this period.

Thanks


Re: [PATCH] of: unittest: Don't dereference args.np after test errors

2018-09-24 Thread Frank Rowand
Hi Guenter,

On 09/23/18 09:33, Guenter Roeck wrote:
> If a devicetree parse function fails, it is quite likely that args.np
> is invalid. Trying to dereference it will then cause the system to crash.
> 
> This was seen when trying to run devicetree unittests on a g3beige
> qemu system. This system has the OF_IMAP_OLDWORLD_MAC flag set in
> of_irq_workarounds and expects an 'old style' structure of irq
> nodes. Trying to parse the test nodes fails and results in the
> following crash.
> 
> OF: /testcase-data/phandle-tests/consumer-b: arguments longer than property
> Unable to handle kernel paging request for data at address 0x00bc616e
> Faulting instruction address: 0xc092437c
> Oops: Kernel access of bad area, sig: 11 [#1]
> BE PREEMPT PowerMac
> Modules linked in:
> CPU: 0 PID: 1 Comm: swapper Not tainted 4.19.0-rc4-yocto-standard+ #1
> NIP:  c092437c LR: c0925098 CTR: c0925088
> REGS: cf8dfb40 TRAP: 0300   Not tainted  (4.19.0-rc4-yocto-standard+)
> MSR:  1032   CR: 82004044  XER: 
> DAR: 00bc616e DSISR: 4000
> GPR00: c0925098 cf8dfbf0 cf8e c14098c7 c14098c7 c1409c50 0066 0002
> GPR08: 0063 00bc614e c0b483e9 000a 82004048  0008 c0b36d80
> GPR16: c0ac c0b4233c c14098c7 c0b13c14 05ff 000a c0b483e4 c0b00a30
> GPR24: cecfe324 cecfe324 c0acc434 c0ac8420 c1409c50 05ff c1409c50 c14098c7
> NIP [c092437c] device_node_gen_full_name+0x30/0x15c
> LR [c0925098] device_node_string+0x190/0x3c8
> Call Trace:
> [cf8dfbf0] [c0733704] of_find_property+0x5c/0x74 (unreliable)
> [cf8dfc30] [c0925098] device_node_string+0x190/0x3c8
> [cf8dfca0] [c092690c] pointer+0x274/0x4d4
> [cf8dfcd0] [c0926e20] vsnprintf+0x2b4/0x5ec
> [cf8dfd30] [c0927170] vscnprintf+0x18/0x48
> [cf8dfd40] [c008eb70] vprintk_store+0x4c/0x22c
> [cf8dfd70] [c008f1c4] vprintk_emit+0x94/0x270
> [cf8dfda0] [c008fb60] printk+0x5c/0x6c
> [cf8dfde0] [c0bd1ec0] of_unittest+0x2670/0x2b48
> [cf8dfe80] [c0004ba8] do_one_initcall+0xac/0x320
> [cf8dfee0] [c0b8975c] kernel_init_freeable+0x328/0x3f0
> [cf8dff30] [c00050c4] kernel_init+0x24/0x118
> [cf8dff40] [c0014278] ret_from_kernel_thread+0x14/0x1c
> 
> To avoid this and similar problems, don't try to dereference args.np
> after devicetree parse failures, and display the name of the parsed node
> instead. With this, we get error messages such as
> 
> dt-test ### FAIL of_unittest_parse_interrupts():791 index 0 -
>   data error on node /testcase-data/interrupts/interrupts0 rc=-22
> 
> This may not display the intended node name, but it is better than a crash.

Thanks for finding and debugging the root cause of the problem.

As the patch comment notes, the changes do not fix the root cause, but
instead avoid the crash.  I'd like to deal with the root cause instead.

I've never encountered OF_IMAP_OLDWORLD_MAC and need to dig deeper to
understand exactly how having it set leads to the error returns from
of_parse_phandle_with_args().  Thus my off-the-top-of-my-head first
observation is likely to be incorrect.  But I'd like to point out
what I suspect is likely to be a more useful direction for the fix.

I'll use a bit of artful logic to claim that the root cause is that
of_parse_phandle_with_args() does not behave as unittests expect when
OF_IMAP_OLDWORLD_MAC is set.

If the of_parse_phandle_with_args() calls are not going to perform the
test that unittest expects to be performing, then it is pointless to
do the tests.  The fix then is to not do those tests.  For example,
at the top of of_unittest_parse_phandle_with_args(), simply do:

if (of_irq_workarounds & OF_IMAP_OLDWORLD_MAC)
return;

I did not look to see whether the other test areas you found can be
as easily avoided, without avoiding tests that are still valid when
OF_IMAP_OLDWORLD_MAC is set, but I am hoping so.

While looking at the patch, I noticed that the current
of_unittest_parse_phandle_with_args() also does not call of_node_put()
in the cases where of_count_phandle_with_args() does not return an
error.  I'll add fixing that to my todo list.

And as you pointed out, of_unittest_parse_phandle_with_args() should
not be blindly using the contents of args when an error occurred.  I'll
also put fixing that on my todo list.

-Frank



> 
> Fixes: 53a42093d96ef ("of: Add device tree selftests")
> Signed-off-by: Guenter Roeck 
> ---
>  drivers/of/unittest.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
> index 722537e14848..5942ddce1b9f 100644
> --- a/drivers/of/unittest.c
> +++ b/drivers/of/unittest.c
> @@ -424,7 +424,7 @@ static void __init 
> of_unittest_parse_phandle_with_args(void)
>   }
>  
>   unittest(passed, "index %i - data error on node %pOF rc=%i\n",
> -  i, args.np, rc);
> +  i, np, rc);
>   }
>  
>   /* Check for missing list property */
> @@ -554,8 +554,8 @@ static void __init 
> of_unittest_parse_phandl

Re: Portable DT Connectors with regard to FPGAs

2018-09-24 Thread David Gibson
On Mon, Sep 24, 2018 at 03:32:44PM -0500, Alan Tull wrote:
> My interest here was in having some discussion on whether connectors
> are a good match for handling FPGAs.
> 
> The relevant use model is where a user applies a DT overlay targeting
> an FPGA region after the kernel has booted.  That overlay initiates
> FPGA programming and then adds nodes for the new FPGA hardware. This
> is discussed more completely in the FPGA manager DT binding document
> [1].  The main deal here is that I'd like to be able to add nodes
> in/below a FPGA region node to support devices in the FPGA (and be
> able also to remove them if we are going to reconfigure the FPGA.)
> 
> Previous discussions about DT connectors focused on the types of
> things likely to be on a physical connector. GPIO and SPI got named as
> good examples for discussion while MMIO specifically was dismissed
> [2].  That's problematic for embedded FPGAs for example since the FPGA
> is on a mmio bus and hardware that is programmed into the FPGA lives
> on that mmio bus similar to any embedded peripherals.  So there's a
> question - are mmio busses intended to be left un-connectorizable?

I don't see any particular reason that a connector couldn't be used
for mmio devices.  I think you'd want to treat the connection point as
a bridge on the mmio bus - that can have a 'ranges' property mapping
the connected device into the parent bus's address space (as an
identity mapping or otherwise).

> 
> Alan
> 
> [1] 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/fpga/fpga-region.txt
> 
> [2] https://lkml.org/lkml/2016/7/20/560
> 

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: PGP signature


Re: [PATCH 4.9 111/111] MIPS: VDSO: Drop gic_get_usm_range() usage

2018-09-24 Thread 林上智
Hi,

Guenter Roeck  於 2018年9月25日 週二 上午9:36寫道:
>
> On Mon, Sep 24, 2018 at 01:53:18PM +0200, Greg Kroah-Hartman wrote:
> > 4.9-stable review patch.  If anyone has any objections, please let me know.
> >
>
> This patch breaks v4.4.y and v4.9.y builds.
> It includes asm/mips-cps.h which doesn't exist in those releases.

I am sorry for my fault, thanks for your report.

Since the patch b025d51873d5fe6 "MIPS: CM: Specify register size when
generating accessors" which created asm/mips-cps.h is not a bug-fixed
patch, hence I will not backport this header.

Hi Greg,

Could you please help to revert this commit? This commit was intended
to fix dependency of 70d7783 "MIPS: VDSO: Match data page cache
colouring when D$ aliases", but I saw 70d7783 was merged before this
commit; therefore, I don't think it is necessary to keep this commit.

I apology for any inconvenience caused, and I will be more careful next time.

SZ Lin (林上智)

>
> Building mips:malta_defconfig:smp:initrd ... failed
> 
> Error log:
> arch/mips/kernel/vdso.c:23:26: fatal error: asm/mips-cps.h: No such file or 
> directory
>
> Guenter
>
> > --
> >
> > From: Paul Burton 
> >
> > commit 00578cd864d45ae4b8fa3f684f8d6f783dd8d15d upstream.
> >
> > We don't really need gic_get_usm_range() to abstract discovery of the
> > address of the GIC user-visible section now that we have access to its
> > base address globally.
> >
> > Switch to calculating it ourselves, which will allow us to stop
> > requiring the irqchip driver to care about a counter exposed to userland
> > for use via the VDSO.
> >
> > Signed-off-by: Paul Burton 
> > Cc: Jason Cooper 
> > Cc: Marc Zyngier 
> > Cc: Thomas Gleixner 
> > Cc: linux-m...@linux-mips.org
> > Patchwork: https://patchwork.linux-mips.org/patch/17040/
> > Signed-off-by: Ralf Baechle 
> > Signed-off-by: SZ Lin (林上智) 
> > Signed-off-by: Greg Kroah-Hartman 
> > ---
> >  arch/mips/kernel/vdso.c |   15 +--
> >  1 file changed, 5 insertions(+), 10 deletions(-)
> >
> > --- a/arch/mips/kernel/vdso.c
> > +++ b/arch/mips/kernel/vdso.c
> > @@ -13,7 +13,6 @@
> >  #include 
> >  #include 
> >  #include 
> > -#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -21,6 +20,7 @@
> >  #include 
> >
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >
> > @@ -101,9 +101,8 @@ int arch_setup_additional_pages(struct l
> >  {
> >   struct mips_vdso_image *image = current->thread.abi->vdso;
> >   struct mm_struct *mm = current->mm;
> > - unsigned long gic_size, vvar_size, size, base, data_addr, vdso_addr;
> > + unsigned long gic_size, vvar_size, size, base, data_addr, vdso_addr, 
> > gic_pfn;
> >   struct vm_area_struct *vma;
> > - struct resource gic_res;
> >   int ret;
> >
> >   if (down_write_killable(&mm->mmap_sem))
> > @@ -127,7 +126,7 @@ int arch_setup_additional_pages(struct l
> >* only map a page even though the total area is 64K, as we only need
> >* the counter registers at the start.
> >*/
> > - gic_size = gic_present ? PAGE_SIZE : 0;
> > + gic_size = mips_gic_present() ? PAGE_SIZE : 0;
> >   vvar_size = gic_size + PAGE_SIZE;
> >   size = vvar_size + image->size;
> >
> > @@ -168,13 +167,9 @@ int arch_setup_additional_pages(struct l
> >
> >   /* Map GIC user page. */
> >   if (gic_size) {
> > - ret = gic_get_usm_range(&gic_res);
> > - if (ret)
> > - goto out;
> > + gic_pfn = virt_to_phys(mips_gic_base + MIPS_GIC_USER_OFS) >> 
> > PAGE_SHIFT;
> >
> > - ret = io_remap_pfn_range(vma, base,
> > -  gic_res.start >> PAGE_SHIFT,
> > -  gic_size,
> > + ret = io_remap_pfn_range(vma, base, gic_pfn, gic_size,
> >pgprot_noncached(PAGE_READONLY));
> >   if (ret)
> >   goto out;
> >
> >


Re: [PATCH] sparc64: viohs: Remove VLA usage

2018-09-24 Thread David Miller
From: Kees Cook 
Date: Mon, 24 Sep 2018 20:17:55 -0700

> On Wed, Sep 5, 2018 at 3:03 PM, Kees Cook  wrote:
>> In the quest to remove all stack VLA usage from the kernel[1], this
>> allocates a fixed size array for the maximum number of cookies and
>> adds a runtime sanity check.
>>
>> [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1
>> rq...@mail.gmail.com
>>
>> Signed-off-by: Kees Cook 
> 
> Friendly ping. Dave, can you take this?

I'll try to get to this soon, kinda backlogged at the moment.

Sorry.


Re: [PATCH] sparc64: viohs: Remove VLA usage

2018-09-24 Thread Kees Cook
On Wed, Sep 5, 2018 at 3:03 PM, Kees Cook  wrote:
> In the quest to remove all stack VLA usage from the kernel[1], this
> allocates a fixed size array for the maximum number of cookies and
> adds a runtime sanity check.
>
> [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1
> rq...@mail.gmail.com
>
> Signed-off-by: Kees Cook 

Friendly ping. Dave, can you take this?

Thanks!

-Kees

> ---
>  arch/sparc/kernel/viohs.c | 12 +---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/arch/sparc/kernel/viohs.c b/arch/sparc/kernel/viohs.c
> index 635d67ffc9a3..7db5aabe9708 100644
> --- a/arch/sparc/kernel/viohs.c
> +++ b/arch/sparc/kernel/viohs.c
> @@ -180,11 +180,17 @@ static int send_dreg(struct vio_driver_state *vio)
> struct vio_dring_register pkt;
> char all[sizeof(struct vio_dring_register) +
>  (sizeof(struct ldc_trans_cookie) *
> - dr->ncookies)];
> + VIO_MAX_RING_COOKIES)];
> } u;
> +   size_t bytes = sizeof(struct vio_dring_register) +
> +  (sizeof(struct ldc_trans_cookie) *
> +   dr->ncookies);
> int i;
>
> -   memset(&u, 0, sizeof(u));
> +   if (WARN_ON(bytes > sizeof(u)))
> +   return -EINVAL;
> +
> +   memset(&u, 0, bytes);
> init_tag(&u.pkt.tag, VIO_TYPE_CTRL, VIO_SUBTYPE_INFO, VIO_DRING_REG);
> u.pkt.dring_ident = 0;
> u.pkt.num_descr = dr->num_entries;
> @@ -206,7 +212,7 @@ static int send_dreg(struct vio_driver_state *vio)
>(unsigned long long) u.pkt.cookies[i].cookie_size);
> }
>
> -   return send_ctrl(vio, &u.pkt.tag, sizeof(u));
> +   return send_ctrl(vio, &u.pkt.tag, bytes);
>  }
>
>  static int send_rdx(struct vio_driver_state *vio)
> --
> 2.17.1
>
>
> --
> Kees Cook
> Pixel Security



-- 
Kees Cook
Pixel Security


[PATCH 1/2] iio: magnetometer: Add DT support for PNI RM3100

2018-09-24 Thread Song Qiang
PNI RM3100 is a high resolution, large signal immunity magnetometer,
composed of 3 single sensors and a processing chip with MagI2C Interface.
PNI is not in the vendors' list, so this patch is also adding it.

Signed-off-by: Song Qiang 
---
Changes in v2:
- Remove bus specific part in compatible string.

 .../bindings/iio/magnetometer/pni,rm3100.txt  | 20 +++
 .../devicetree/bindings/vendor-prefixes.txt   |  1 +
 2 files changed, 21 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/iio/magnetometer/pni,rm3100.txt

diff --git a/Documentation/devicetree/bindings/iio/magnetometer/pni,rm3100.txt 
b/Documentation/devicetree/bindings/iio/magnetometer/pni,rm3100.txt
new file mode 100644
index ..4677690fc5d0
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/magnetometer/pni,rm3100.txt
@@ -0,0 +1,20 @@
+* PNI RM3100 3-axis magnetometer sensor
+
+Required properties:
+
+- compatible : should be "pni,rm3100"
+- reg : the I2C address or SPI chip select number of the sensor.
+
+Optional properties:
+
+- interrupts: data ready (DRDY) from the chip.
+  The interrupts can be triggered on rising edges.
+
+Example:
+
+rm3100: rm3100@20 {
+   compatible = "pni,rm3100";
+   reg = <0x20>;
+   interrupt-parent = <&gpio0>;
+   interrupts = <4 IRQ_TYPE_EDGE_RISING>;
+};
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 41f0b97eb933..5bf3395fe9ae 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -288,6 +288,7 @@ pine64  Pine64
 pixcir  PIXCIR MICROELECTRONICS Co., Ltd
 plathome   Plat'Home Co., Ltd.
 plda   PLDA
+pni PNI
 portwell   Portwell Inc.
 poslab Poslab Technology Co., Ltd.
 powervrPowerVR (deprecated, use img)
-- 
2.17.1



[PATCH 2/2] iio: magnetometer: Add driver support for PNI RM3100

2018-09-24 Thread Song Qiang
PNI RM3100 is a high resolution, large signal immunity magnetometer,
composed of 3 single sensors and a processing chip with MagI2C Interface.

Following functions are available:
- Single-shot measurement from
  /sys/bus/iio/devices/iio:deviceX/in_magn_{axis}_raw
- Triggerd buffer measurement.
- Both i2c and spi interface are supported.
- Both interrupt and polling measurement is supported, depands on if
  the 'interrupts' in DT is declared.

Signed-off-by: Song Qiang 
---
Changes in v2:
- Add scale channel.
- Add EXPORT_SYMBOL_GPL() to export regmap confuguration
  structures.
- Add sampling frequency available attribute.
- Clean up headers and License declarations.
- Change axis number to 3.
- Remove bus specific part in compatible string.
- Remove le32_to_cpu().
- Check cycle count registers at *_probe().
- Format comments.
- Spell check.
- Change prefix from RM_* to RM3100_*.
- Check all error return paths.
- Add devm_add_action() to avoid race condition when remove.

 MAINTAINERS|   7 +
 drivers/iio/magnetometer/Kconfig   |  29 ++
 drivers/iio/magnetometer/Makefile  |   4 +
 drivers/iio/magnetometer/rm3100-core.c | 470 +
 drivers/iio/magnetometer/rm3100-i2c.c  |  58 +++
 drivers/iio/magnetometer/rm3100-spi.c  |  64 
 drivers/iio/magnetometer/rm3100.h  |  73 
 7 files changed, 705 insertions(+)
 create mode 100644 drivers/iio/magnetometer/rm3100-core.c
 create mode 100644 drivers/iio/magnetometer/rm3100-i2c.c
 create mode 100644 drivers/iio/magnetometer/rm3100-spi.c
 create mode 100644 drivers/iio/magnetometer/rm3100.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 967ce8cdd1cc..14eeeb072403 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11393,6 +11393,13 @@ M: "Rafael J. Wysocki" 
 S: Maintained
 F: drivers/pnp/
 
+PNI RM3100 IIO DRIVER
+M: Song Qiang 
+L: linux-...@vger.kernel.org
+S: Maintained
+F: drivers/iio/magnetometer/rm3100*
+F: Documentation/devicetree/bindings/iio/magnetometer/pni,rm3100.txt
+
 POSIX CLOCKS and TIMERS
 M: Thomas Gleixner 
 L: linux-kernel@vger.kernel.org
diff --git a/drivers/iio/magnetometer/Kconfig b/drivers/iio/magnetometer/Kconfig
index ed9d776d01af..f130b866a4fc 100644
--- a/drivers/iio/magnetometer/Kconfig
+++ b/drivers/iio/magnetometer/Kconfig
@@ -175,4 +175,33 @@ config SENSORS_HMC5843_SPI
  - hmc5843_core (core functions)
  - hmc5843_spi (support for HMC5983)
 
+config SENSORS_RM3100
+   tristate
+   select IIO_BUFFER
+   select IIO_TRIGGERED_BUFFER
+
+config SENSORS_RM3100_I2C
+   tristate "PNI RM3100 9-Axis Magnetometer (I2C)"
+   depends on I2C
+   select SENSORS_RM3100
+   select REGMAP_I2C
+   help
+ Say Y here to add support for the PNI RM3100 9-Axis Magnetometer.
+
+ This driver can also be compiled as a module.
+ To compile this driver as a module, choose M here: the module
+ will be called rm3100-i2c.
+
+config SENSORS_RM3100_SPI
+   tristate "PNI RM3100 9-Axis Magnetometer (SPI)"
+   depends on SPI_MASTER
+   select SENSORS_RM3100
+   select REGMAP_SPI
+   help
+ Say Y here to add support for the PNI RM3100 9-Axis Magnetometer.
+
+ This driver can also be compiled as a module.
+ To compile this driver as a module, choose M here: the module
+ will be called rm3100-spi.
+
 endmenu
diff --git a/drivers/iio/magnetometer/Makefile 
b/drivers/iio/magnetometer/Makefile
index 664b2f866472..ba1bc34b82fa 100644
--- a/drivers/iio/magnetometer/Makefile
+++ b/drivers/iio/magnetometer/Makefile
@@ -24,3 +24,7 @@ obj-$(CONFIG_IIO_ST_MAGN_SPI_3AXIS) += st_magn_spi.o
 obj-$(CONFIG_SENSORS_HMC5843)  += hmc5843_core.o
 obj-$(CONFIG_SENSORS_HMC5843_I2C)  += hmc5843_i2c.o
 obj-$(CONFIG_SENSORS_HMC5843_SPI)  += hmc5843_spi.o
+
+obj-$(CONFIG_SENSORS_RM3100)   += rm3100-core.o
+obj-$(CONFIG_SENSORS_RM3100_I2C)   += rm3100-i2c.o
+obj-$(CONFIG_SENSORS_RM3100_SPI)   += rm3100-spi.o
diff --git a/drivers/iio/magnetometer/rm3100-core.c 
b/drivers/iio/magnetometer/rm3100-core.c
new file mode 100644
index ..5d28b53b7a04
--- /dev/null
+++ b/drivers/iio/magnetometer/rm3100-core.c
@@ -0,0 +1,470 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * PNI RM3100 3-axis geomagnetic sensor driver core.
+ *
+ * Copyright (C) 2018 Song Qiang 
+ *
+ * User Manual available at
+ * 
+ *
+ * TODO: event generaton, pm.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "rm3100.h"
+
+static const struct regmap_range rm3100_readable_ranges[] = {
+   regmap_reg_range(RM3100_W_REG_START, RM3100_W_REG_END),
+};
+
+const struct regmap_access_table rm3100_readable_table = {
+   .yes_rang

Re: [PATCH 4.18 164/235] pinctrl: pinmux: Return selector to the pinctrl driver

2018-09-24 Thread Dan Rue
On Mon, Sep 24, 2018 at 06:07:10PM -0500, Dan Rue wrote:
> On Mon, Sep 24, 2018 at 01:52:30PM +0200, Greg Kroah-Hartman wrote:
> > 4.18-stable review patch.  If anyone has any objections, please let me know.
> 
> I bisected a boot failure on an x15 (arm) board to this commit on
> 4.18.10-rc1. I'm also seeing issues on 4.14 and 4.18 with arm64 boards
> hikey and dragonboard 410c, but I have not investigated them yet (they
> could be unrelated).
> 
> I see there are fixes to this commit that have not been backported.
> Namely:
> 
> 823dd71f58eb ("pinctrl: ingenic: Fix group & function error checking")
> a203728ac6bb ("pinctrl: core: Return selector to the pinctrl driver")
> 
> However, I tried adding those two in but I still see the boot failure on
> x15.

Dropping 9c5cd7b6ca4e ("pinctrl: pinmux: Return selector to the pinctrl
driver") does appear to fix the boot issues I'm seeing on x15 and hikey.

Dan

> 
> Dan
> 
> > 
> > --
> > 
> > From: Tony Lindgren 
> > 
> > [ Upstream commit f913cfce4ee49a3382a9ff95696f49a46e56e974 ]
> > 
> > We must return the selector from pinmux_generic_add_function() so
> > pin controller device drivers can remove the right group if needed
> > for deferred probe for example. And we now must make sure that a
> > proper name is passed so we can use it to check if the entry already
> > exists.
> > 
> > Note that fixes are also needed for the pin controller drivers to
> > use the selector value.
> > 
> > Fixes: a76edc89b100 ("pinctrl: core: Add generic pinctrl functions for
> > managing groups")
> > Reported-by: H. Nikolaus Schaller 
> > Cc: Christ van Willegen 
> > Cc: Haojian Zhuang 
> > Cc: Jacopo Mondi 
> > Cc: Paul Cercueil 
> > Cc: Sean Wang 
> > Signed-off-by: Tony Lindgren 
> > Tested-By: H. Nikolaus Schaller 
> > Reviewed-by: Andy Shevchenko 
> > Signed-off-by: Linus Walleij 
> > Signed-off-by: Sasha Levin 
> > Signed-off-by: Greg Kroah-Hartman 
> > ---
> >  drivers/pinctrl/pinmux.c |   16 
> >  1 file changed, 12 insertions(+), 4 deletions(-)
> > 
> > --- a/drivers/pinctrl/pinmux.c
> > +++ b/drivers/pinctrl/pinmux.c
> > @@ -308,7 +308,6 @@ static int pinmux_func_name_to_selector(
> > selector++;
> > }
> >  
> > -   dev_err(pctldev->dev, "function '%s' not supported\n", function);
> > return -EINVAL;
> >  }
> >  
> > @@ -775,6 +774,16 @@ int pinmux_generic_add_function(struct p
> > void *data)
> >  {
> > struct function_desc *function;
> > +   int selector;
> > +
> > +   if (!name)
> > +   return -EINVAL;
> > +
> > +   selector = pinmux_func_name_to_selector(pctldev, name);
> > +   if (selector >= 0)
> > +   return selector;
> > +
> > +   selector = pctldev->num_functions;
> >  
> > function = devm_kzalloc(pctldev->dev, sizeof(*function), GFP_KERNEL);
> > if (!function)
> > @@ -785,12 +794,11 @@ int pinmux_generic_add_function(struct p
> > function->num_group_names = num_groups;
> > function->data = data;
> >  
> > -   radix_tree_insert(&pctldev->pin_function_tree, pctldev->num_functions,
> > - function);
> > +   radix_tree_insert(&pctldev->pin_function_tree, selector, function);
> >  
> > pctldev->num_functions++;
> >  
> > -   return 0;
> > +   return selector;
> >  }
> >  EXPORT_SYMBOL_GPL(pinmux_generic_add_function);
> >  
> > 
> > 


Re: [PATCH] IB/mlx4: Avoid implicit enumerated type conversion

2018-09-24 Thread Jason Gunthorpe
On Mon, Sep 24, 2018 at 03:29:38PM -0700, Nick Desaulniers wrote:
> On Mon, Sep 24, 2018 at 3:27 PM Nathan Chancellor
>  wrote:
> >
> > On Mon, Sep 24, 2018 at 03:24:36PM -0700, Nick Desaulniers wrote:
> > > On Mon, Sep 24, 2018 at 12:57 PM Nathan Chancellor
> > >  wrote:
> > > >
> > > > Clang warns when one enumerated type is implicitly converted to another.
> > > >
> > > > drivers/infiniband/hw/mlx4/mad.c:1811:41: warning: implicit conversion
> > > > from enumeration type 'enum mlx4_ib_qp_flags' to different enumeration
> > > > type 'enum ib_qp_create_flags' [-Wenum-conversion]
> > > > qp_init_attr.init_attr.create_flags = 
> > > > MLX4_IB_SRIOV_TUNNEL_QP;
> > > > ~ 
> > > > ^~~
> > > >
> > > > drivers/infiniband/hw/mlx4/mad.c:1819:41: warning: implicit conversion
> > > > from enumeration type 'enum mlx4_ib_qp_flags' to different enumeration
> > > > type 'enum ib_qp_create_flags' [-Wenum-conversion]
> > > > qp_init_attr.init_attr.create_flags = MLX4_IB_SRIOV_SQP;
> > > > ~ ^
> > > >
> > > > The type mlx4_ib_qp_flags explicitly provides supplemental values to the
> > > > type ib_qp_create_flags. Make that clear to Clang by changing the
> > > > create_flags type to u32.
> > > >
> > > > Reported-by: Nick Desaulniers 
> > > > Signed-off-by: Nathan Chancellor 
> > > >  include/rdma/ib_verbs.h | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> > > > index e463d3007a35..f6f4d9e3c8ed 100644
> > > > +++ b/include/rdma/ib_verbs.h
> > > > @@ -1149,7 +1149,7 @@ struct ib_qp_init_attr {
> > > > struct ib_qp_capcap;
> > > > enum ib_sig_typesq_sig_type;
> > > > enum ib_qp_type qp_type;
> > > > -   enum ib_qp_create_flags create_flags;
> > > > +   u32 create_flags;
> > >
> > > I think it might be better to just have explicit casts at the
> > > assignment.  What do the maintainers think?
> > >
> >
> > That's fine with me, I tend to explicitly cast if it is only one
> > location but it certainly makes sense in this case as well. I'll
> > wait for the maintainers to weigh in before sending a v2.
> 
> Yeah, I mean my opinion on this might seem arbitrary, but based on the
> pattern and the comment in ib_qp_create_flags, those enum values are
> reserved to be "subclassed" in a sense, so they should always be in
> sync or this code will have bigger problems.

One should not use an 'enum' type name for bitfield storage, as once
you start or'ing things together the values no longer fall on the
enum. Some compilers and tools even give warnings in this case, ie

   enum x foo = X_A | X_B;

Is an assignment from 'int' to an 'enum x' with an implicit cast.

For this reason, usually bitfield enum declarations should be
anonymous.

Jason


Re: [RFC PATCH 0/9] Improve zone lock scalability using Daniel Jordan's list work

2018-09-24 Thread Aaron Lu
On Fri, Sep 21, 2018 at 10:45:36AM -0700, Daniel Jordan wrote:
> On Tue, Sep 11, 2018 at 01:36:07PM +0800, Aaron Lu wrote:
> > Daniel Jordan and others proposed an innovative technique to make
> > multiple threads concurrently use list_del() at any position of the
> > list and list_add() at head position of the list without taking a lock
> > in this year's MM summit[0].
> > 
> > People think this technique may be useful to improve zone lock
> > scalability so here is my try.
> 
> Nice, this uses the smp_list_* functions well in spite of the limitations you
> encountered with them here.
> 
> > Performance wise on 56 cores/112 threads Intel Skylake 2 sockets server
> > using will-it-scale/page_fault1 process mode(higher is better):
> > 
> > kernelperformance  zone lock contention
> > patch1 9219349 76.99%
> > patch7 2461133 -73.3%  54.46%(another 34.66% on smp_list_add())
> > patch811712766 +27.0%  68.14%
> > patch911386980 +23.5%  67.18%
> 
> Is "zone lock contention" the percentage that readers and writers combined
> spent waiting?  I'm curious to see read and write wait time broken out, since
> it seems there are writers (very likely on the allocation side) spoiling the
> parallelism we get with the read lock.

lock contention is combined, read side consumes about 31% while write
side consumes 35%. Write side definitely is blocking read side.

I also tried not taking lock in read mode on free path to avoid free
path blocking on allocation path, but that caused other unplesant
consequences for allocation path, namely the free_list head->next can
be NULL when allocating pages due to free path can be adding pages to
the list using smp_list_add/splice so I had to use free_list head->prev
instead to fetch pages on allocation path. Also, the fetched page can be
merged in the mean time on free path so need to confirm if it is really
usable, etc. This complicated allocation path and didn't deliver good
results so I gave up this idea.

> If the contention is from allocation, I wonder whether it's feasible to make
> that path use SMP list functions.  Something like smp_list_cut_position
> combined with using page clusters from [*] to cut off a chunk of list.  Many
> details to keep in mind there, though, like having to unset PageBuddy in that
> list chunk when other tasks can be concurrently merging pages that are part of
> it.

As you put here, the PageBuddy flag is a problem. If I cut off a batch
of pages from free_list and then dropping the lock, these pages will
have PageBuddy flag set and free path can attempt a merge with any of
these pages and cause problems.

PageBuddy flag can not be cleared with lock held since that would
require accessing 'struct page's for these pages and it is the most time
consuming part among all operations that happened on allocation path
under zone lock.

This is doable in your referenced no_merge+cluster_alloc approach because
we skipped merge most of the time. And when merge really needs to
happen like in compaction, cluser_alloc will be disabled.

> Or maybe what's needed is a more scalable data structure than an array of
> lists, since contention on the heads seems to be the limiting factor.  A 
> simple
> list that keeps the pages in most-recently-used order (except when adding to
> the list tail) is good for cache warmth, but I wonder how helpful that is when
> all CPUs can allocate from the front.  Having multiple places to put pages of 
> a
> given order/mt would ease the contention.

Agree.

> > Though lock contention reduced a lot for patch7, the performance dropped
> > considerably due to severe cache bouncing on free list head among
> > multiple threads doing page free at the same time, because every page free
> > will need to add the page to the free list head.
> 
> Could be beneficial to take an MCS-style approach in smp_list_splice/add so
> that multiple waiters aren't bouncing the same cacheline around.  This is
> something I'm planning to try on lru_lock.

That's a good idea.
If that is done, we can at least parallelise free path and gain
something by not paying the penalty of cache bouncing on list head.

> 
> Daniel
> 
> [*] https://lkml.kernel.org/r/20180509085450.3524-1-aaron...@intel.com

And thanks a lot for the comments!


Re: [PATCH 1/5] RISC-V: Build tishift only on 64-bit

2018-09-24 Thread Zong Li
Christoph Hellwig  於 2018年9月21日 週五 下午2:58寫道:
>
> On Tue, Sep 18, 2018 at 05:19:13PM +0800, Zong Li wrote:
> > Only RV64 supports 128 integer size.
> >
> > Signed-off-by: Zong Li 
>
> This looks fine.  Just curious, what do we even need 128-bit integers
> for on riscv64?  Did you see any issues if you drop it entirely?

You can refer to this issue, but I didn't try it.
https://github.com/riscv/riscv-linux/issues/136


Re: Code of Conduct: Let's revamp it.

2018-09-24 Thread gratuitouslicensesarerevocable
In your employment contract there exists a provision where you sign over 
your rights to any and all intellectual property, patents, copyrights 
developed during your term of employment.


Said clause makes it clear that what you've furnished is a work-for-hire 
and owned by the company or the entity you have contracted with.


It should be clear why that is not the case with regards to kernel 
contributions by third parties.
Unlike the FSF etc, Linus never required nor sought copyright 
assignments: thus you still own your code.


You were not paid valuable consideration by the licensees for the code.
There exists no interest to bind your hand.

You never even suggested to said licensees that you would forfeit your 
right to revoke.
Furthermore, they were incapable of relying on said in-existent 
utterances.


You may revoke at your pleasure.
And they shall be bound by the will of your countenance.

On 2018-09-24 19:45, Bernd Petrovitsch wrote:

BTW you cannot do that at your workplace either because in all sane
software development companies you cease all (transferable) rights of
your written to the company paying you (and the rest is usually not
enough to get anything revoked).

I don't see why that should be any different with GPLv2 patches for the
Kernel sent to public mailinglists with the intent of inclusion.

Please get back to the issue and circumstances at hand and do not try 
to
divert people with "not intended for the public" or "semi-public" or 
any

other off-topic stuff which is clearly not the case here.
Or - even better - shut up, unsubscribe and go away, thank you.

MfG,
Bernd, NAL but I talked to a lot of them;-)

PS: Sorry for troll feeding:-(


[PATCH v4 2/3] spi: mediatek: add spi slave for Mediatek MT2712

2018-09-24 Thread Leilk Liu
This patch adds basic spi slave for MT2712.

Signed-off-by: Leilk Liu 
---
 drivers/spi/Kconfig|   10 +
 drivers/spi/Makefile   |1 +
 drivers/spi/spi-slave-mt27xx.c |  554 
 3 files changed, 565 insertions(+)
 create mode 100644 drivers/spi/spi-slave-mt27xx.c

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 671d078..60b13c6 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -596,6 +596,16 @@ config SPI_SIRF
help
  SPI driver for CSR SiRFprimaII SoCs
 
+config SPI_SLAVE_MT27XX
+   tristate "MediaTek SPI slave device"
+   depends on ARCH_MEDIATEK || COMPILE_TEST
+   depends on SPI_SLAVE
+   help
+ This selects the MediaTek(R) SPI slave device driver.
+ If you want to use MediaTek(R) SPI slave interface,
+ say Y or M here.If you are not sure, say N.
+ SPI slave drivers for Mediatek MT27XX series ARM SoCs.
+
 config SPI_SPRD_ADI
tristate "Spreadtrum ADI controller"
depends on ARCH_SPRD || COMPILE_TEST
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index a90d559..3b469fa 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -88,6 +88,7 @@ obj-$(CONFIG_SPI_SH_HSPI) += spi-sh-hspi.o
 obj-$(CONFIG_SPI_SH_MSIOF) += spi-sh-msiof.o
 obj-$(CONFIG_SPI_SH_SCI)   += spi-sh-sci.o
 obj-$(CONFIG_SPI_SIRF) += spi-sirf.o
+obj-$(CONFIG_SPI_SLAVE_MT27XX)  += spi-slave-mt27xx.o
 obj-$(CONFIG_SPI_SPRD_ADI) += spi-sprd-adi.o
 obj-$(CONFIG_SPI_STM32)+= spi-stm32.o
 obj-$(CONFIG_SPI_ST_SSC4)  += spi-st-ssc4.o
diff --git a/drivers/spi/spi-slave-mt27xx.c b/drivers/spi/spi-slave-mt27xx.c
new file mode 100644
index 000..d1075433
--- /dev/null
+++ b/drivers/spi/spi-slave-mt27xx.c
@@ -0,0 +1,554 @@
+// SPDX-License-Identifier: GPL-2.0+
+// Copyright (c) 2018 MediaTek Inc.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define SPIS_IRQ_EN_REG0x0
+#define SPIS_IRQ_CLR_REG   0x4
+#define SPIS_IRQ_ST_REG0x8
+#define SPIS_IRQ_MASK_REG  0xc
+#define SPIS_CFG_REG   0x10
+#define SPIS_RX_DATA_REG   0x14
+#define SPIS_TX_DATA_REG   0x18
+#define SPIS_RX_DST_REG0x1c
+#define SPIS_TX_SRC_REG0x20
+#define SPIS_DMA_CFG_REG   0x30
+#define SPIS_SOFT_RST_REG  0x40
+
+/* SPIS_IRQ_EN_REG */
+#define DMA_DONE_ENBIT(7)
+#define DATA_DONE_EN   BIT(2)
+#define RSTA_DONE_EN   BIT(1)
+#define CMD_INVALID_EN BIT(0)
+
+/* SPIS_IRQ_ST_REG */
+#define DMA_DONE_STBIT(7)
+#define DATA_DONE_ST   BIT(2)
+#define RSTA_DONE_ST   BIT(1)
+#define CMD_INVALID_ST BIT(0)
+
+/* SPIS_IRQ_MASK_REG */
+#define DMA_DONE_MASK  BIT(7)
+#define DATA_DONE_MASK BIT(2)
+#define RSTA_DONE_MASK BIT(1)
+#define CMD_INVALID_MASK   BIT(0)
+
+/* SPIS_CFG_REG */
+#define SPIS_TX_ENDIAN BIT(7)
+#define SPIS_RX_ENDIAN BIT(6)
+#define SPIS_TXMSBFBIT(5)
+#define SPIS_RXMSBFBIT(4)
+#define SPIS_CPHA  BIT(3)
+#define SPIS_CPOL  BIT(2)
+#define SPIS_TX_EN BIT(1)
+#define SPIS_RX_EN BIT(0)
+
+/* SPIS_DMA_CFG_REG */
+#define TX_DMA_TRIG_EN BIT(31)
+#define TX_DMA_EN  BIT(30)
+#define RX_DMA_EN  BIT(29)
+#define TX_DMA_LEN 0xf
+
+/* SPIS_SOFT_RST_REG */
+#define SPIS_DMA_ADDR_EN   BIT(1)
+#define SPIS_SOFT_RST  BIT(0)
+
+#define MTK_SPI_SLAVE_MAX_FIFO_SIZE 512U
+
+struct mtk_spi_slave {
+   struct device *dev;
+   void __iomem *base;
+   struct clk *spi_clk;
+   struct completion xfer_done;
+   struct spi_transfer *cur_transfer;
+   bool slave_aborted;
+};
+
+static const struct of_device_id mtk_spi_slave_of_match[] = {
+   { .compatible = "mediatek,mt2712-spi-slave", },
+   {}
+};
+MODULE_DEVICE_TABLE(of, mtk_spi_slave_of_match);
+
+static void mtk_spi_slave_disable_dma(struct mtk_spi_slave *mdata)
+{
+   u32 reg_val;
+
+   reg_val = readl(mdata->base + SPIS_DMA_CFG_REG);
+   reg_val &= ~RX_DMA_EN;
+   reg_val &= ~TX_DMA_EN;
+   writel(reg_val, mdata->base + SPIS_DMA_CFG_REG);
+}
+
+static void mtk_spi_slave_disable_xfer(struct mtk_spi_slave *mdata)
+{
+   u32 reg_val;
+
+   reg_val = readl(mdata->base + SPIS_CFG_REG);
+   reg_val &= ~SPIS_TX_EN;
+   reg_val &= ~SPIS_RX_EN;
+   writel(reg_val, mdata->base + SPIS_CFG_REG);
+}
+
+static int mtk_spi_slave_wait_for_completion(struct mtk_spi_slave *mdata)
+{
+   if (wait_for_completion_interruptible(&mdata->xfer_done) ||
+   mdata->slave_aborted) {
+   dev_err(mdata->dev, "interrupted\n");
+   return -EINTR;
+   }
+
+   return 0;
+}
+
+static int mtk_spi_slave_prepare_mes

[PATCH v4 0/3] Add Mediatek SPI slave driver

2018-09-24 Thread Leilk Liu
>From 7f2423debd91771a1d3a5ca02cd3990f1417bcb8 Mon Sep 17 00:00:00 2001
From: Leilk Liu 
Date: Tue, 25 Sep 2018 10:11:44 +0800
Subject: Subject: [PATCH v4 0/3] Add Mediatek SPI slave driver

v4:
1. Fix Mark Brown review comment about kconfig & driver.

v3:
1. Fix Rob Herring review comment about bindings.
2. remove unused variables in driver.

v2:
1. Fix Sean Wang review comment.
2. remove unused register and offset define.
3. update bindings file with assigned-clocks and assigned-clocks-parents.

v1:
This series are based on 4.19-rc1 and provide three patches to add mediatek spi 
slave driver.


Leilk Liu (3):
  spi: mediatek: add bindings for Mediatek MT2712 soc platform
  spi: mediatek: add spi slave for Mediatek MT2712
  arm64: dts: Add spi slave dts

 .../devicetree/bindings/spi/spi-slave-mt27xx.txt   |  32 ++
 arch/arm64/boot/dts/mediatek/mt2712e.dtsi  |  11 +
 drivers/spi/Kconfig|  10 +
 drivers/spi/Makefile   |   1 +
 drivers/spi/spi-slave-mt27xx.c | 554 +
 5 files changed, 608 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/spi-slave-mt27xx.txt
 create mode 100644 drivers/spi/spi-slave-mt27xx.c

-- 
1.9.1




[PATCH v4 1/3] spi: mediatek: add bindings for Mediatek MT2712 soc platform

2018-09-24 Thread Leilk Liu
This patch adds a DT binding documentation for the MT2712 soc.

Signed-off-by: Leilk Liu 
---
 .../devicetree/bindings/spi/spi-slave-mt27xx.txt   |   32 
 1 file changed, 32 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/spi-slave-mt27xx.txt

diff --git a/Documentation/devicetree/bindings/spi/spi-slave-mt27xx.txt 
b/Documentation/devicetree/bindings/spi/spi-slave-mt27xx.txt
new file mode 100644
index 000..09cb2c4
--- /dev/null
+++ b/Documentation/devicetree/bindings/spi/spi-slave-mt27xx.txt
@@ -0,0 +1,32 @@
+Binding for MTK SPI Slave controller
+
+Required properties:
+- compatible: should be one of the following.
+- mediatek,mt2712-spi-slave: for mt2712 platforms
+- reg: Address and length of the register set for the device.
+- interrupts: Should contain spi interrupt.
+- clocks: phandles to input clocks.
+  It's clock gate, and should be <&infracfg CLK_INFRA_AO_SPI1>.
+- clock-names: should be "spi" for the clock gate.
+
+Optional properties:
+- assigned-clocks: it's mux clock, should be <&topckgen CLK_TOP_SPISLV_SEL>.
+- assigned-clock-parents: parent of mux clock.
+  It's PLL, and should be on of the following.
+   -  <&topckgen CLK_TOP_UNIVPLL1_D2>: specify parent clock 312MHZ.
+  It's the default one.
+   -  <&topckgen CLK_TOP_UNIVPLL1_D4>: specify parent clock 156MHZ.
+   -  <&topckgen CLK_TOP_UNIVPLL2_D4>: specify parent clock 104MHZ.
+   -  <&topckgen CLK_TOP_UNIVPLL1_D8>: specify parent clock 78MHZ.
+
+Example:
+- SoC Specific Portion:
+spis1: spi@10013000 {
+   compatible = "mediatek,mt2712-spi-slave";
+   reg = <0 0x10013000 0 0x100>;
+   interrupts = ;
+   clocks = <&infracfg CLK_INFRA_AO_SPI1>;
+   clock-names = "spi";
+   assigned-clocks = <&topckgen CLK_TOP_SPISLV_SEL>;
+   assigned-clock-parents = <&topckgen CLK_TOP_UNIVPLL1_D2>;
+};
-- 
1.7.9.5



[PATCH v4 3/3] arm64: dts: Add spi slave dts

2018-09-24 Thread Leilk Liu
This patch adds MT2712 spi slave into device tree.

Signed-off-by: Leilk Liu 
---
 arch/arm64/boot/dts/mediatek/mt2712e.dtsi |   11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi 
b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi
index 75cc0f7..ee627a7 100644
--- a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi
@@ -301,6 +301,17 @@
status = "disabled";
};
 
+   spis1: spi@10013000 {
+   compatible = "mediatek,mt2712-spi-slave";
+   reg = <0 0x10013000 0 0x100>;
+   interrupts = ;
+   clocks = <&infracfg CLK_INFRA_AO_SPI1>;
+   clock-names = "spi";
+   assigned-clocks = <&topckgen CLK_TOP_SPISLV_SEL>;
+   assigned-clock-parents = <&topckgen CLK_TOP_UNIVPLL1_D2>;
+   status = "disabled";
+   };
+
apmixedsys: syscon@10209000 {
compatible = "mediatek,mt2712-apmixedsys", "syscon";
reg = <0 0x10209000 0 0x1000>;
-- 
1.7.9.5



Re: [PATCH 3/5] lib: Add umoddi3 and udivmoddi4 of GCC library routines

2018-09-24 Thread Zong Li
Christoph Hellwig  於 2018年9月21日 週五 下午3:00寫道:
>
> On Tue, Sep 18, 2018 at 05:19:15PM +0800, Zong Li wrote:
> > Add umoddi3 and udivmoddi4 support for 32-bit.
>
> This probably wants a better explanation of why you need them.
>
> > index 000..69f2d36
> > --- /dev/null
> > +++ b/lib/udivmoddi4.c
> > @@ -0,0 +1,291 @@
> > +// SPDX-License-Identifier: GPL-2.0
>
> Who wrote this code, where does it come from?

The RV32 need the umoddi3 to do modulo when the operands are long long
type, like other libraries implementation such as ucmpdi2, lshrdi3 and
so on. I encounter the undefined reference 'umoddi3' when I use the in
house dma driver, although it is in house driver, but I think that
umoddi3 is a common function for RV32. The udivmoddi4 and umoddi3 are
copies from libgcc in gcc. There are other functions use the
udivmoddi4 in libgcc, so I separate the umoddi3 and udivmoddi4 for
flexible extension in the future.


[PATCH V2] mm/hugetlb: Add mmap() encodings for 32MB and 512MB page sizes

2018-09-24 Thread Anshuman Khandual
ARM64 architecture also supports 32MB and 512MB HugeTLB page sizes.
This just adds mmap() system call argument encoding for them.

Signed-off-by: Anshuman Khandual 
---

Changes in V2:
- Updated SHM and MFD definitions per Mike

 include/uapi/asm-generic/hugetlb_encode.h | 2 ++
 include/uapi/linux/memfd.h| 2 ++
 include/uapi/linux/mman.h | 2 ++
 include/uapi/linux/shm.h  | 2 ++
 4 files changed, 8 insertions(+)

diff --git a/include/uapi/asm-generic/hugetlb_encode.h 
b/include/uapi/asm-generic/hugetlb_encode.h
index e4732d3..b0f8e87 100644
--- a/include/uapi/asm-generic/hugetlb_encode.h
+++ b/include/uapi/asm-generic/hugetlb_encode.h
@@ -26,7 +26,9 @@
 #define HUGETLB_FLAG_ENCODE_2MB(21 << 
HUGETLB_FLAG_ENCODE_SHIFT)
 #define HUGETLB_FLAG_ENCODE_8MB(23 << 
HUGETLB_FLAG_ENCODE_SHIFT)
 #define HUGETLB_FLAG_ENCODE_16MB   (24 << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_32MB   (25 << HUGETLB_FLAG_ENCODE_SHIFT)
 #define HUGETLB_FLAG_ENCODE_256MB  (28 << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_512MB  (29 << HUGETLB_FLAG_ENCODE_SHIFT)
 #define HUGETLB_FLAG_ENCODE_1GB(30 << 
HUGETLB_FLAG_ENCODE_SHIFT)
 #define HUGETLB_FLAG_ENCODE_2GB(31 << 
HUGETLB_FLAG_ENCODE_SHIFT)
 #define HUGETLB_FLAG_ENCODE_16GB   (34 << HUGETLB_FLAG_ENCODE_SHIFT)
diff --git a/include/uapi/linux/memfd.h b/include/uapi/linux/memfd.h
index 015a4c0..7a8a267 100644
--- a/include/uapi/linux/memfd.h
+++ b/include/uapi/linux/memfd.h
@@ -25,7 +25,9 @@
 #define MFD_HUGE_2MB   HUGETLB_FLAG_ENCODE_2MB
 #define MFD_HUGE_8MB   HUGETLB_FLAG_ENCODE_8MB
 #define MFD_HUGE_16MB  HUGETLB_FLAG_ENCODE_16MB
+#define MFD_HUGE_32MB  HUGETLB_FLAG_ENCODE_32MB
 #define MFD_HUGE_256MB HUGETLB_FLAG_ENCODE_256MB
+#define MFD_HUGE_512MB HUGETLB_FLAG_ENCODE_512MB
 #define MFD_HUGE_1GB   HUGETLB_FLAG_ENCODE_1GB
 #define MFD_HUGE_2GB   HUGETLB_FLAG_ENCODE_2GB
 #define MFD_HUGE_16GB  HUGETLB_FLAG_ENCODE_16GB
diff --git a/include/uapi/linux/mman.h b/include/uapi/linux/mman.h
index bfd5938..d0f515d 100644
--- a/include/uapi/linux/mman.h
+++ b/include/uapi/linux/mman.h
@@ -28,7 +28,9 @@
 #define MAP_HUGE_2MB   HUGETLB_FLAG_ENCODE_2MB
 #define MAP_HUGE_8MB   HUGETLB_FLAG_ENCODE_8MB
 #define MAP_HUGE_16MB  HUGETLB_FLAG_ENCODE_16MB
+#define MAP_HUGE_32MB  HUGETLB_FLAG_ENCODE_32MB
 #define MAP_HUGE_256MB HUGETLB_FLAG_ENCODE_256MB
+#define MAP_HUGE_512MB HUGETLB_FLAG_ENCODE_512MB
 #define MAP_HUGE_1GB   HUGETLB_FLAG_ENCODE_1GB
 #define MAP_HUGE_2GB   HUGETLB_FLAG_ENCODE_2GB
 #define MAP_HUGE_16GB  HUGETLB_FLAG_ENCODE_16GB
diff --git a/include/uapi/linux/shm.h b/include/uapi/linux/shm.h
index dde1344..6507ad0 100644
--- a/include/uapi/linux/shm.h
+++ b/include/uapi/linux/shm.h
@@ -65,7 +65,9 @@ struct shmid_ds {
 #define SHM_HUGE_2MB   HUGETLB_FLAG_ENCODE_2MB
 #define SHM_HUGE_8MB   HUGETLB_FLAG_ENCODE_8MB
 #define SHM_HUGE_16MB  HUGETLB_FLAG_ENCODE_16MB
+#define SHM_HUGE_32MB  HUGETLB_FLAG_ENCODE_32MB
 #define SHM_HUGE_256MB HUGETLB_FLAG_ENCODE_256MB
+#define SHM_HUGE_512MB HUGETLB_FLAG_ENCODE_512MB
 #define SHM_HUGE_1GB   HUGETLB_FLAG_ENCODE_1GB
 #define SHM_HUGE_2GB   HUGETLB_FLAG_ENCODE_2GB
 #define SHM_HUGE_16GB  HUGETLB_FLAG_ENCODE_16GB
-- 
2.7.4



Re: [RFC 00/20] ns: Introduce Time Namespace

2018-09-24 Thread Andrey Vagin
On Tue, Sep 25, 2018 at 12:02:32AM +0200, Eric W. Biederman wrote:
> Andrey Vagin  writes:
> 
> > On Fri, Sep 21, 2018 at 02:27:29PM +0200, Eric W. Biederman wrote:
> >> Dmitry Safonov  writes:
> >> 
> >> > Discussions around time virtualization are there for a long time.
> >> > The first attempt to implement time namespace was in 2006 by Jeff Dike.
> >> > From that time, the topic appears on and off in various discussions.
> >> >
> >> > There are two main use cases for time namespaces:
> >> > 1. change date and time inside a container;
> >> > 2. adjust clocks for a container restored from a checkpoint.
> >> >
> >> > “It seems like this might be one of the last major obstacles keeping
> >> > migration from being used in production systems, given that not all
> >> > containers and connections can be migrated as long as a time dependency
> >> > is capable of messing it up.” (by github.com/dav-ell)
> >> >
> >> > The kernel provides access to several clocks: CLOCK_REALTIME,
> >> > CLOCK_MONOTONIC, CLOCK_BOOTTIME. Last two clocks are monotonous, but the
> >> > start points for them are not defined and are different for each running
> >> > system. When a container is migrated from one node to another, all
> >> > clocks have to be restored into consistent states; in other words, they
> >> > have to continue running from the same points where they have been
> >> > dumped.
> >> >
> >> > The main idea behind this patch set is adding per-namespace offsets for
> >> > system clocks. When a process in a non-root time namespace requests
> >> > time of a clock, a namespace offset is added to the current value of
> >> > this clock on a host and the sum is returned.
> >> >
> >> > All offsets are placed on a separate page, this allows up to map it as 
> >> > part of vvar into user processes and use offsets from vdso calls.
> >> >
> >> > Now offsets are implemented for CLOCK_MONOTONIC and CLOCK_BOOTTIME
> >> > clocks.
> >> >
> >> > Questions to discuss:
> >> >
> >> > * Clone flags exhaustion. Currently there is only one unused clone flag
> >> > bit left, and it may be worth to use it to extend arguments of the clone
> >> > system call.
> >> >
> >> > * Realtime clock implementation details:
> >> >   Is having a simple offset enough?
> >> >   What to do when date and time is changed on the host?
> >> >   Is there a need to adjust vfs modification and creation times? 
> >> >   Implementation for adjtime() syscall.
> >> 
> >> Overall I support this effort.  In my quick skim this code looked good.
> >
> > Hi Eric,
> >
> > Thank you for the feedback.
> >
> >> 
> >> My feeling is that we need to be able to support running ntpd and
> >> support one namespace doing googles smoothing of leap seconds while
> >> another namespace takes the leap second.
> >> 
> >> What I was imagining when I was last thinking about this was one
> >> instance of struct timekeeper aka tk_core per time namespace.  That
> >> structure already keeps offsets for all of the various clocks from
> >> the kerne internal time sources.  What would be needed would be to
> >> pass in an appropriate time namespace pointer.
> >> 
> >> I could be completely wrong as I have not take the time to completely
> >> trace through the code.  Have you looked at pushing the time namespace
> >> down as far as tk_core?
> >> 
> >> What I think would be the big advantage (besides ntp working) is that
> >> the bulk of the code could be reused.  Allowing testing of the kernel's
> >> time code by setting up a new time namespace.  So a person in production
> >> could setup a time namespace with the time set ahead a little  bit and
> >> be able to verify that the kernel handles the upcoming leap second
> >> properly.
> >>
> >
> > It is an interesting idea, but I have a few questions:
> >
> > 1. Does it mean that timekeeping_update() will be called for each
> > namespace? This functions is called periodically, it updates times on the
> > timekeeper structure, updates vsyscall_gtod_data, etc. What will be an
> > overhead of this?
> 
> I don't know if periodically is a proper characterization.  There may be
> a code path that does that.  But from what I can see timekeeping_update
> is the guts of settimeofday (and a few related functions).
> 
> So it appears to make sense for timekeeping_update to be per namespace.
> 
> Hmm.  Looking at what is updated in the vsyscall_gtod_data it does
> look like you would have to periodically update things, but I don't know
> big that period would be.  As long as the period is reasonably large,
> or the time namespaces were sufficiently deschronized it should not
> be a problem.  But that is the class of problem that could make
> my ideal impractical if there is measuarable overhead.
> 
> Where were you seeing timekeeping_update being called periodically?

timekeeping_update() is called HZ times per-second:

[   67.912858]  timekeeping_update.cold.26+0x5/0xa
[   67.913332]  timekeeping_advance+0x361/0x5c0
[   67.913857]  ? tick_sched_do_timer+0x55/0x70
[   6

Re: [PATCH 4.9 111/111] MIPS: VDSO: Drop gic_get_usm_range() usage

2018-09-24 Thread Guenter Roeck
On Mon, Sep 24, 2018 at 01:53:18PM +0200, Greg Kroah-Hartman wrote:
> 4.9-stable review patch.  If anyone has any objections, please let me know.
> 

This patch breaks v4.4.y and v4.9.y builds.
It includes asm/mips-cps.h which doesn't exist in those releases.

Building mips:malta_defconfig:smp:initrd ... failed

Error log:
arch/mips/kernel/vdso.c:23:26: fatal error: asm/mips-cps.h: No such file or 
directory

Guenter

> --
> 
> From: Paul Burton 
> 
> commit 00578cd864d45ae4b8fa3f684f8d6f783dd8d15d upstream.
> 
> We don't really need gic_get_usm_range() to abstract discovery of the
> address of the GIC user-visible section now that we have access to its
> base address globally.
> 
> Switch to calculating it ourselves, which will allow us to stop
> requiring the irqchip driver to care about a counter exposed to userland
> for use via the VDSO.
> 
> Signed-off-by: Paul Burton 
> Cc: Jason Cooper 
> Cc: Marc Zyngier 
> Cc: Thomas Gleixner 
> Cc: linux-m...@linux-mips.org
> Patchwork: https://patchwork.linux-mips.org/patch/17040/
> Signed-off-by: Ralf Baechle 
> Signed-off-by: SZ Lin (林上智) 
> Signed-off-by: Greg Kroah-Hartman 
> ---
>  arch/mips/kernel/vdso.c |   15 +--
>  1 file changed, 5 insertions(+), 10 deletions(-)
> 
> --- a/arch/mips/kernel/vdso.c
> +++ b/arch/mips/kernel/vdso.c
> @@ -13,7 +13,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> @@ -21,6 +20,7 @@
>  #include 
>  
>  #include 
> +#include 
>  #include 
>  #include 
>  
> @@ -101,9 +101,8 @@ int arch_setup_additional_pages(struct l
>  {
>   struct mips_vdso_image *image = current->thread.abi->vdso;
>   struct mm_struct *mm = current->mm;
> - unsigned long gic_size, vvar_size, size, base, data_addr, vdso_addr;
> + unsigned long gic_size, vvar_size, size, base, data_addr, vdso_addr, 
> gic_pfn;
>   struct vm_area_struct *vma;
> - struct resource gic_res;
>   int ret;
>  
>   if (down_write_killable(&mm->mmap_sem))
> @@ -127,7 +126,7 @@ int arch_setup_additional_pages(struct l
>* only map a page even though the total area is 64K, as we only need
>* the counter registers at the start.
>*/
> - gic_size = gic_present ? PAGE_SIZE : 0;
> + gic_size = mips_gic_present() ? PAGE_SIZE : 0;
>   vvar_size = gic_size + PAGE_SIZE;
>   size = vvar_size + image->size;
>  
> @@ -168,13 +167,9 @@ int arch_setup_additional_pages(struct l
>  
>   /* Map GIC user page. */
>   if (gic_size) {
> - ret = gic_get_usm_range(&gic_res);
> - if (ret)
> - goto out;
> + gic_pfn = virt_to_phys(mips_gic_base + MIPS_GIC_USER_OFS) >> 
> PAGE_SHIFT;
>  
> - ret = io_remap_pfn_range(vma, base,
> -  gic_res.start >> PAGE_SHIFT,
> -  gic_size,
> + ret = io_remap_pfn_range(vma, base, gic_pfn, gic_size,
>pgprot_noncached(PAGE_READONLY));
>   if (ret)
>   goto out;
> 
> 


[PATCH] ASoC: soc-utils: Rename dummy_dma_ops to snd_dummy_ops

2018-09-24 Thread Matthias Kaehlcke
The symbols 'dummy_dma_ops' is declared with different data types by
sound/soc/soc-utils.c and arch/arm64/include/asm/dma-mapping.h. This
leads to conflicts when soc-utils.c (indirectly) includes dma-mapping.h:

sound/soc/soc-utils.c:282:33: error: conflicting types for 'dummy_dma_ops'
  static const struct snd_pcm_ops dummy_dma_ops = {
  ^
...
arch/arm64/include/asm/dma-mapping.h:27:33: note: previous declaration of 
'dummy_dma_ops' was here
  extern const struct dma_map_ops dummy_dma_ops;
  ^

Rename the symbol in soc-utils.c to 'snd_dummy_ops' to avoid the conflict.

Signed-off-by: Matthias Kaehlcke 
---
 sound/soc/soc-utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c
index e0c93496c0cd..ab44133bc0bf 100644
--- a/sound/soc/soc-utils.c
+++ b/sound/soc/soc-utils.c
@@ -273,13 +273,13 @@ static int dummy_dma_open(struct snd_pcm_substream 
*substream)
return 0;
 }
 
-static const struct snd_pcm_ops dummy_dma_ops = {
+static const struct snd_pcm_ops snd_dummy_ops = {
.open   = dummy_dma_open,
.ioctl  = snd_pcm_lib_ioctl,
 };
 
 static const struct snd_soc_component_driver dummy_platform = {
-   .ops = &dummy_dma_ops,
+   .ops = &snd_dummy_ops,
 };
 
 static const struct snd_soc_component_driver dummy_codec = {
-- 
2.19.0.605.g01d371f741-goog



Re: [PATCH] clocksource/drivers/fttmr010: fix set_next_event handler

2018-09-24 Thread Tao Ren
On 9/24/18, 4:20 PM, "Joel Stanley"  wrote:

> Whatever method is easiest for you. A patch file or a tarball is fine.
> I will then add it to the set of tests I run when testing aspeed
> kernels.

No problem, Joel. I will share the test code with you offline.


Thanks,
Tao Ren




Re: [PATCH] rpmsg: core: add support to power domains for devices

2018-09-24 Thread Suman Anna
Hi Srinivas,

On 06/15/2018 04:59 AM, Srinivas Kandagatla wrote:
> Some of the rpmsg devices need to switch on power domains to communicate
> with remote processor. For example on Qualcomm DB820c platform LPASS
> power domain needs to switched on for any kind of audio services.
> This patch adds the missing power domain support in rpmsg core.
> 
> Without this patch attempting to play audio via QDSP on DB820c would
> reboot the system.
> 
> Signed-off-by: Srinivas Kandagatla 
> ---
>  drivers/rpmsg/rpmsg_core.c | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c
> index b714a543a91d..8122807db380 100644
> --- a/drivers/rpmsg/rpmsg_core.c
> +++ b/drivers/rpmsg/rpmsg_core.c
> @@ -15,6 +15,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #include "rpmsg_internal.h"
> @@ -449,6 +450,10 @@ static int rpmsg_dev_probe(struct device *dev)
>   struct rpmsg_endpoint *ept = NULL;
>   int err;
>  
> + err = dev_pm_domain_attach(dev, true);
> + if (err)
> + goto out;

This patch has broken the virtio-rpmsg stack based rpmsg devices. These
devices are non-DT and the rpmsg_dev_probe() is now failing with -19
(-ENODEV) error code.

Loic, Arnaud,
Can one of you double-confirm this behavior on ST platforms as well?
The patch came through 4.14.71 stable release and broke our downstream
kernels.

regards
Suman

> +
>   if (rpdrv->callback) {
>   strncpy(chinfo.name, rpdev->id.name, RPMSG_NAME_SIZE);
>   chinfo.src = rpdev->src;
> @@ -490,6 +495,8 @@ static int rpmsg_dev_remove(struct device *dev)
>  
>   rpdrv->remove(rpdev);
>  
> + dev_pm_domain_detach(dev, true);
> +
>   if (rpdev->ept)
>   rpmsg_destroy_ept(rpdev->ept);
>  
> 



Re: [PATCH TRIVIAL] Punctuation fixes

2018-09-24 Thread Diego Viola
On Sun, Sep 23, 2018 at 5:59 AM Richard Weinberger
 wrote:
>
> On Sun, Sep 23, 2018 at 3:00 AM Miguel Ojeda
>  wrote:
> >
> > Hi Diego,
> >
> > A few things, since it looks like this is your first patch.
>
> git log...
>
> > On Sat, Sep 22, 2018 at 5:56 PM, Diego Viola  wrote:
> > > On Wed, Sep 12, 2018 at 12:54 AM Diego Viola  
> > > wrote:
> > >>
> > >> Signed-off-by: Diego Viola 
> > >> ---
> > >>  CREDITS | 2 +-
> > >>  MAINTAINERS | 2 +-
> > >>  Makefile| 2 +-
> > >>  3 files changed, 3 insertions(+), 3 deletions(-)
> > >>
> > >> diff --git a/CREDITS b/CREDITS
> > >> index 5befd2d71..b82efb36d 100644
> > >> --- a/CREDITS
> > >> +++ b/CREDITS
> > >> @@ -1473,7 +1473,7 @@ W: http://www.linux-ide.org/
> > >>  W: http://www.linuxdiskcert.org/
> > >>  D: Random SMP kernel hacker...
> > >>  D: Uniform Multi-Platform E-IDE driver
> > >> -D: Active-ATA-Chipset maddness..
> > >> +D: Active-ATA-Chipset maddness...
> >
> > I think the extra dots is what was intended here :)
>
> Diego, I know you can do better. :-)
> How about running linux-next and hunting down regressions?
> I think we suggested this already on IRC.

OK. I'll do that after I'm done with the documentation.

>
> --
> Thanks,
> //richard

Thanks,
Diego


[PATCH v2] dt-bindings: pinctrl: qcom-pmic-gpio: Add pms405 support

2018-09-24 Thread Bjorn Andersson
From: Vinod Koul 

Add support for the PMS405 GPIO support to the Qualcomm PMIC GPIO
binding.

Signed-off-by: Vinod Koul 
Signed-off-by: Bjorn Andersson 
---

Changes since v1:
- Dropped unnecessary driver update
- Updated subject

 Documentation/devicetree/bindings/pinctrl/qcom,pmic-gpio.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/pinctrl/qcom,pmic-gpio.txt 
b/Documentation/devicetree/bindings/pinctrl/qcom,pmic-gpio.txt
index ffd4345415f3..ab4000eab07d 100644
--- a/Documentation/devicetree/bindings/pinctrl/qcom,pmic-gpio.txt
+++ b/Documentation/devicetree/bindings/pinctrl/qcom,pmic-gpio.txt
@@ -19,6 +19,7 @@ PMIC's from Qualcomm.
"qcom,pm8998-gpio"
"qcom,pma8084-gpio"
"qcom,pmi8994-gpio"
+   "qcom,pms405-gpio"
 
And must contain either "qcom,spmi-gpio" or "qcom,ssbi-gpio"
if the device is on an spmi bus or an ssbi bus respectively
@@ -91,6 +92,7 @@ to specify in a pin configuration subnode:
gpio1-gpio26 for pm8998
gpio1-gpio22 for pma8084
gpio1-gpio10 for pmi8994
+   gpio1-gpio11 for pms405
 
 - function:
Usage: required
-- 
2.18.0



Re: [PATCH v12 1/2] leds: core: Introduce LED pattern trigger

2018-09-24 Thread Bjorn Andersson
On Mon 10 Sep 19:47 PDT 2018, Baolin Wang wrote:
[..]
> diff --git a/Documentation/ABI/testing/sysfs-class-led-trigger-pattern 
> b/Documentation/ABI/testing/sysfs-class-led-trigger-pattern
[..]
> +What:/sys/class/leds//hw_pattern
> +Date:September 2018
> +KernelVersion:   4.20
> +Description:
> + Specify a hardware pattern for the LED, for LED hardware that
> + supports autonomously controlling brightness over time, 
> according
> + to some preprogrammed hardware patterns.
> +
> + Since different LED hardware can have different semantics of
> + hardware patterns, each driver is expected to provide its own
> + description for the hardware patterns in their ABI documentation
> + file.
> +
> +What:/sys/class/leds//repeat
> +Date:September 2018
> +KernelVersion:   4.20
> +Description:
> + Specify a pattern repeat number. -1 means repeat indefinitely,
> + other negative numbers and number 0 are invalid.
> +
> + This file will always return the originally written repeat
> + number.

This captures the infinite case much better, thanks!

Given that 0 is described as invalid, does this imply that setting a new
pattern the repeat will be disabled? And hence if my hardware supports
only infinite or no-repeat setting a new pattern is the way to disable
further repeats (rather than just setting repeat = 0)?


Regardless, I believe the semantics of these two files will work fine
for my Qualcomm LPG driver.

Regards,
Bjorn


[PATCH v3 0/3] Fix qcom geni i2c DMA handling

2018-09-24 Thread Stephen Boyd
(Numbering is weird because I dropped patch 1 but left numbering
the same)

The qcom GENI I2C driver fails DMA sometimes when things
from request firmware are passed in as the message buffer.
This patch series fixes that problem in the first patch
and the second patch cleans up the code a little to reduce
lines and simplify lines.

Cc: Karthikeyan Ramasubramanian 
Cc: Sagar Dharia 
Cc: Girish Mahadevan 
Cc: Doug Anderson 

Changes from v2:
 * Dropped first patch because it's applied
 * New patch 3 to simplify irq handler
 * Updated patch 2 to hoist out common code and remove 'mode'
   local variable

Changes from v1:
 * Use i2c helpers to map buffers
 * New patch 2 to clean up seriously indented code

Stephen Boyd (2):
  i2c: i2c-qcom-geni: Simplify tx/rx functions
  i2c: i2c-qcom-geni: Simplify irq handler

 drivers/i2c/busses/i2c-qcom-geni.c | 149 +
 1 file changed, 65 insertions(+), 84 deletions(-)

-- 
Sent by a computer through tubes



[PATCH v3 2/3] i2c: i2c-qcom-geni: Simplify tx/rx functions

2018-09-24 Thread Stephen Boyd
We never really look at the 'ret' local variable in these functions, so
let's remove it to make way for shorter and simpler code. Furthermore,
we can shorten some lines by adding two local variables for the SE and
the message length so that everything fits in 80 columns and testing the
'dma_buf' local variable in lieu of the 'mode' local variable.  And
kernel style is to leave the return statement by itself, detached from
the rest of the function.

Cc: Karthikeyan Ramasubramanian 
Cc: Sagar Dharia 
Cc: Girish Mahadevan 
Cc: Doug Anderson 
Signed-off-by: Stephen Boyd 
---
 drivers/i2c/busses/i2c-qcom-geni.c | 79 ++
 1 file changed, 36 insertions(+), 43 deletions(-)

diff --git a/drivers/i2c/busses/i2c-qcom-geni.c 
b/drivers/i2c/busses/i2c-qcom-geni.c
index 9f2eb02481d3..0b466835cf40 100644
--- a/drivers/i2c/busses/i2c-qcom-geni.c
+++ b/drivers/i2c/busses/i2c-qcom-geni.c
@@ -365,29 +365,24 @@ static int geni_i2c_rx_one_msg(struct geni_i2c_dev *gi2c, 
struct i2c_msg *msg,
u32 m_param)
 {
dma_addr_t rx_dma;
-   enum geni_se_xfer_mode mode;
-   unsigned long time_left = XFER_TIMEOUT;
+   unsigned long time_left;
void *dma_buf;
+   struct geni_se *se = &gi2c->se;
+   size_t len = msg->len;
 
-   gi2c->cur = msg;
-   mode = GENI_SE_FIFO;
dma_buf = i2c_get_dma_safe_msg_buf(msg, 32);
if (dma_buf)
-   mode = GENI_SE_DMA;
-
-   geni_se_select_mode(&gi2c->se, mode);
-   writel_relaxed(msg->len, gi2c->se.base + SE_I2C_RX_TRANS_LEN);
-   geni_se_setup_m_cmd(&gi2c->se, I2C_READ, m_param);
-   if (mode == GENI_SE_DMA) {
-   int ret;
-
-   ret = geni_se_rx_dma_prep(&gi2c->se, dma_buf, msg->len,
-   &rx_dma);
-   if (ret) {
-   mode = GENI_SE_FIFO;
-   geni_se_select_mode(&gi2c->se, mode);
-   i2c_put_dma_safe_msg_buf(dma_buf, msg, false);
-   }
+   geni_se_select_mode(se, GENI_SE_DMA);
+   else
+   geni_se_select_mode(se, GENI_SE_FIFO);
+
+   writel_relaxed(len, se->base + SE_I2C_RX_TRANS_LEN);
+   geni_se_setup_m_cmd(se, I2C_READ, m_param);
+
+   if (dma_buf && geni_se_rx_dma_prep(se, dma_buf, len, &rx_dma)) {
+   geni_se_select_mode(se, GENI_SE_FIFO);
+   i2c_put_dma_safe_msg_buf(dma_buf, msg, false);
+   dma_buf = NULL;
}
 
time_left = wait_for_completion_timeout(&gi2c->done, XFER_TIMEOUT);
@@ -395,12 +390,13 @@ static int geni_i2c_rx_one_msg(struct geni_i2c_dev *gi2c, 
struct i2c_msg *msg,
geni_i2c_abort_xfer(gi2c);
 
gi2c->cur_rd = 0;
-   if (mode == GENI_SE_DMA) {
+   if (dma_buf) {
if (gi2c->err)
geni_i2c_rx_fsm_rst(gi2c);
-   geni_se_rx_dma_unprep(&gi2c->se, rx_dma, msg->len);
+   geni_se_rx_dma_unprep(se, rx_dma, len);
i2c_put_dma_safe_msg_buf(dma_buf, msg, !gi2c->err);
}
+
return gi2c->err;
 }
 
@@ -408,45 +404,41 @@ static int geni_i2c_tx_one_msg(struct geni_i2c_dev *gi2c, 
struct i2c_msg *msg,
u32 m_param)
 {
dma_addr_t tx_dma;
-   enum geni_se_xfer_mode mode;
unsigned long time_left;
void *dma_buf;
+   struct geni_se *se = &gi2c->se;
+   size_t len = msg->len;
 
-   gi2c->cur = msg;
-   mode = GENI_SE_FIFO;
dma_buf = i2c_get_dma_safe_msg_buf(msg, 32);
if (dma_buf)
-   mode = GENI_SE_DMA;
-
-   geni_se_select_mode(&gi2c->se, mode);
-   writel_relaxed(msg->len, gi2c->se.base + SE_I2C_TX_TRANS_LEN);
-   geni_se_setup_m_cmd(&gi2c->se, I2C_WRITE, m_param);
-   if (mode == GENI_SE_DMA) {
-   int ret;
-
-   ret = geni_se_tx_dma_prep(&gi2c->se, dma_buf, msg->len,
-   &tx_dma);
-   if (ret) {
-   mode = GENI_SE_FIFO;
-   geni_se_select_mode(&gi2c->se, mode);
-   i2c_put_dma_safe_msg_buf(dma_buf, msg, false);
-   }
+   geni_se_select_mode(se, GENI_SE_DMA);
+   else
+   geni_se_select_mode(se, GENI_SE_FIFO);
+
+   writel_relaxed(len, se->base + SE_I2C_TX_TRANS_LEN);
+   geni_se_setup_m_cmd(se, I2C_WRITE, m_param);
+
+   if (dma_buf && geni_se_tx_dma_prep(se, dma_buf, len, &tx_dma)) {
+   geni_se_select_mode(se, GENI_SE_FIFO);
+   i2c_put_dma_safe_msg_buf(dma_buf, msg, false);
+   dma_buf = NULL;
}
 
-   if (mode == GENI_SE_FIFO) /* Get FIFO IRQ */
-   writel_relaxed(1, gi2c->se.base + SE_GENI_TX_WATERMARK_REG);
+   if (!dma_buf) /* Get FIFO IRQ */
+   writel_relaxed(1, se->base + SE_GENI_TX_WATERMAR

[PATCH v3 3/3] i2c: i2c-qcom-geni: Simplify irq handler

2018-09-24 Thread Stephen Boyd
We don't need to use goto here, we can just collapse the if statement
and goto chain into multiple branches and then combine some duplicate
completion calls into one big if statement. Let's do it to clean up code
some more.

Cc: Karthikeyan Ramasubramanian 
Cc: Sagar Dharia 
Cc: Girish Mahadevan 
Cc: Doug Anderson 
Signed-off-by: Stephen Boyd 
---
 drivers/i2c/busses/i2c-qcom-geni.c | 70 +-
 1 file changed, 29 insertions(+), 41 deletions(-)

diff --git a/drivers/i2c/busses/i2c-qcom-geni.c 
b/drivers/i2c/busses/i2c-qcom-geni.c
index 0b466835cf40..527f55c8c4c7 100644
--- a/drivers/i2c/busses/i2c-qcom-geni.c
+++ b/drivers/i2c/busses/i2c-qcom-geni.c
@@ -201,21 +201,23 @@ static void geni_i2c_err(struct geni_i2c_dev *gi2c, int 
err)
 static irqreturn_t geni_i2c_irq(int irq, void *dev)
 {
struct geni_i2c_dev *gi2c = dev;
-   int j;
+   void __iomem *base = gi2c->se.base;
+   int j, p;
u32 m_stat;
u32 rx_st;
u32 dm_tx_st;
u32 dm_rx_st;
u32 dma;
+   u32 val;
struct i2c_msg *cur;
unsigned long flags;
 
spin_lock_irqsave(&gi2c->lock, flags);
-   m_stat = readl_relaxed(gi2c->se.base + SE_GENI_M_IRQ_STATUS);
-   rx_st = readl_relaxed(gi2c->se.base + SE_GENI_RX_FIFO_STATUS);
-   dm_tx_st = readl_relaxed(gi2c->se.base + SE_DMA_TX_IRQ_STAT);
-   dm_rx_st = readl_relaxed(gi2c->se.base + SE_DMA_RX_IRQ_STAT);
-   dma = readl_relaxed(gi2c->se.base + SE_GENI_DMA_MODE_EN);
+   m_stat = readl_relaxed(base + SE_GENI_M_IRQ_STATUS);
+   rx_st = readl_relaxed(base + SE_GENI_RX_FIFO_STATUS);
+   dm_tx_st = readl_relaxed(base + SE_DMA_TX_IRQ_STAT);
+   dm_rx_st = readl_relaxed(base + SE_DMA_RX_IRQ_STAT);
+   dma = readl_relaxed(base + SE_GENI_DMA_MODE_EN);
cur = gi2c->cur;
 
if (!cur ||
@@ -238,26 +240,17 @@ static irqreturn_t geni_i2c_irq(int irq, void *dev)
 
/* Disable the TX Watermark interrupt to stop TX */
if (!dma)
-   writel_relaxed(0, gi2c->se.base +
-  SE_GENI_TX_WATERMARK_REG);
-   goto irqret;
-   }
-
-   if (dma) {
+   writel_relaxed(0, base + SE_GENI_TX_WATERMARK_REG);
+   } else if (dma) {
dev_dbg(gi2c->se.dev, "i2c dma tx:0x%x, dma rx:0x%x\n",
dm_tx_st, dm_rx_st);
-   goto irqret;
-   }
-
-   if (cur->flags & I2C_M_RD &&
-   m_stat & (M_RX_FIFO_WATERMARK_EN | M_RX_FIFO_LAST_EN)) {
+   } else if (cur->flags & I2C_M_RD &&
+  m_stat & (M_RX_FIFO_WATERMARK_EN | M_RX_FIFO_LAST_EN)) {
u32 rxcnt = rx_st & RX_FIFO_WC_MSK;
 
for (j = 0; j < rxcnt; j++) {
-   u32 val;
-   int p = 0;
-
-   val = readl_relaxed(gi2c->se.base + SE_GENI_RX_FIFOn);
+   p = 0;
+   val = readl_relaxed(base + SE_GENI_RX_FIFOn);
while (gi2c->cur_rd < cur->len && p < sizeof(val)) {
cur->buf[gi2c->cur_rd++] = val & 0xff;
val >>= 8;
@@ -270,44 +263,39 @@ static irqreturn_t geni_i2c_irq(int irq, void *dev)
   m_stat & M_TX_FIFO_WATERMARK_EN) {
for (j = 0; j < gi2c->tx_wm; j++) {
u32 temp;
-   u32 val = 0;
-   int p = 0;
 
+   val = 0;
+   p = 0;
while (gi2c->cur_wr < cur->len && p < sizeof(val)) {
temp = cur->buf[gi2c->cur_wr++];
val |= temp << (p * 8);
p++;
}
-   writel_relaxed(val, gi2c->se.base + SE_GENI_TX_FIFOn);
+   writel_relaxed(val, base + SE_GENI_TX_FIFOn);
/* TX Complete, Disable the TX Watermark interrupt */
if (gi2c->cur_wr == cur->len) {
-   writel_relaxed(0, gi2c->se.base +
-   SE_GENI_TX_WATERMARK_REG);
+   writel_relaxed(0, base + 
SE_GENI_TX_WATERMARK_REG);
break;
}
}
}
-irqret:
+
if (m_stat)
-   writel_relaxed(m_stat, gi2c->se.base + SE_GENI_M_IRQ_CLEAR);
+   writel_relaxed(m_stat, base + SE_GENI_M_IRQ_CLEAR);
+
+   if (dma && dm_tx_st)
+   writel_relaxed(dm_tx_st, base + SE_DMA_TX_IRQ_CLR);
+   if (dma && dm_rx_st)
+   writel_relaxed(dm_rx_st, base + SE_DMA_RX_IRQ_CLR);
 
-   if (dma) {
-   if (dm_tx_st)
-   writel_relaxed(dm_tx_st, gi2c->se.base +
-   SE_

Re: [PATCH] mm: fix COW faults after mlock()

2018-09-24 Thread Yury Norov
On Tue, Sep 25, 2018 at 12:22:47AM +0300, Kirill A. Shutemov wrote:
> External Email
> 
> On Mon, Sep 24, 2018 at 04:08:52PM +0300, Yury Norov wrote:
> > After mlock() on newly mmap()ed shared memory I observe page faults.
> >
> > The problem is that populate_vma_page_range() doesn't set FOLL_WRITE
> > flag for writable shared memory in mlock() path, arguing that like:
> > /*
> >  * We want to touch writable mappings with a write fault in order
> >  * to break COW, except for shared mappings because these don't COW
> >  * and we would not want to dirty them for nothing.
> >  */
> >
> > But they are actually COWed. The most straightforward way to avoid it
> > is to set FOLL_WRITE flag for shared mappings as well as for private ones.
> 
> Huh? How do shared mapping get CoWed?
> 
> In this context CoW means to create a private copy of the  page for the
> process. It only makes sense for private mappings as all pages in shared
> mappings do not belong to the process.
> 
> Shared mappings will still get faults, but a bit later -- after the page
> is written back to disc, the page get clear and write protected to catch
> the next write access.
> 
> Noticeable exception is tmpfs/shmem. These pages do not belong to normal
> write back process. But the code path is used for other filesystems as
> well.
> 
> Therefore, NAK. You only create unneeded write back traffic.

Hi Kirill,

(My first reaction was exactly like yours indeed, but) on my real
system (Cavium OcteonTX2), and on my qemu simulation I can reproduce
the same behavior: just mlock()ed memory causes faults. That faults
happen because page is mapped to the process as read-only, while
underlying VMA is read-write. So faults get resolved well by just
setting write access to the page.

Maybe I use term COW wrongly here, but this is how faultin_page()
works, and it sets FOLL_COW bit before return (which is ignored 
on upper level).

I realize that proper fix may be more complex, and if so I'll
thankfully take it and drop this patch from my tree, but this is
all that I have so far to address the problem.

The user code below is reproducer. 

Thanks,
Yury

int i, ret, len = getpagesize() * 1000;
char tmpfile[] = "/tmp/my_tmp-XX";
int fd = mkstemp(tmpfile);

ret = ftruncate(fd, len);
if (ret) {
printf("Failed to ftruncate: %d\n", errno);
goto out;
}

ptr = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (ptr == MAP_FAILED) {
printf("Failed to mmap memory: %d\n", errno);
goto out;
}

ret = mlock(ptr, len);
if (ret) {
printf("Failed to mlock: %d\n", errno);
goto out;
}

printf("Touch...\n");

for (i = 0; i < len; i++)
ptr[i] = (char) i; /* Faults here. */

printf("\t... done\n");
out:
close(fd);
unlink(tmpfile);


[PATCH V5 29/30] dt-bindings: timer: gx6605s SOC timer

2018-09-24 Thread Guo Ren
 - Dt-bindings doc for gx6605s SOC's system timer.

Signed-off-by: Guo Ren 
Reviewed-by: Rob Herring 
---
 .../bindings/timer/csky,gx6605s-timer.txt  | 42 ++
 1 file changed, 42 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/timer/csky,gx6605s-timer.txt

diff --git a/Documentation/devicetree/bindings/timer/csky,gx6605s-timer.txt 
b/Documentation/devicetree/bindings/timer/csky,gx6605s-timer.txt
new file mode 100644
index 000..6b04344
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/csky,gx6605s-timer.txt
@@ -0,0 +1,42 @@
+=
+gx6605s SOC Timer
+=
+
+The timer is used in gx6605s soc as system timer and the driver
+contain clk event and clk source.
+
+==
+timer node bindings definition
+==
+
+   Description: Describes gx6605s SOC timer
+
+   PROPERTIES
+
+   - compatible
+   Usage: required
+   Value type: 
+   Definition: must be "csky,gx6605s-timer"
+   - reg
+   Usage: required
+   Value type: 
+   Definition:  in soc from cpu view
+   - clocks
+   Usage: required
+   Value type: phandle + clock specifier cells
+   Definition: must be input clk node
+   - interrupt
+   Usage: required
+   Value type: 
+   Definition: must be timer irq num defined by soc
+
+Examples:
+-
+
+   timer0: timer@20a000 {
+   compatible = "csky,gx6605s-timer";
+   reg = <0x0020a000 0x400>;
+   clocks = <&dummy_apb_clk>;
+   interrupts = <10>;
+   interrupt-parent = <&intc>;
+   };
-- 
2.7.4



[PATCH V5 30/30] clocksource: add gx6605s SOC system timer

2018-09-24 Thread Guo Ren
Changelog:
 - Add COMPILE_TEST in Kconfig
 - Add License and Copyright
 - Use timer-of framework
 - Change name with upstream feedback
 - Use clksource_mmio framework

Signed-off-by: Guo Ren 
---
 drivers/clocksource/Kconfig |   8 ++
 drivers/clocksource/Makefile|   1 +
 drivers/clocksource/timer-gx6605s.c | 150 
 3 files changed, 159 insertions(+)
 create mode 100644 drivers/clocksource/timer-gx6605s.c

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index a28043f..3dc24ca 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -628,4 +628,12 @@ config CSKY_MPTIMER
  Say yes here to enable C-SKY SMP timer driver used for C-SKY SMP
  system.
 
+config GX6605S_TIMER
+   bool "Gx6605s SOC system timer driver" if COMPILE_TEST
+   depends on CSKY
+   select CLKSRC_MMIO
+   select TIMER_OF
+   help
+ This option enables support for gx6605s SOC's timer.
+
 endmenu
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 848c676..7a1b0f4 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -80,3 +80,4 @@ obj-$(CONFIG_X86_NUMACHIP)+= numachip.o
 obj-$(CONFIG_ATCPIT100_TIMER)  += timer-atcpit100.o
 obj-$(CONFIG_RISCV_TIMER)  += riscv_timer.o
 obj-$(CONFIG_CSKY_MPTIMER) += csky_mptimer.o
+obj-$(CONFIG_GX6605S_TIMER)+= timer-gx6605s.o
diff --git a/drivers/clocksource/timer-gx6605s.c 
b/drivers/clocksource/timer-gx6605s.c
new file mode 100644
index 000..3974ede
--- /dev/null
+++ b/drivers/clocksource/timer-gx6605s.c
@@ -0,0 +1,150 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+
+#include 
+#include 
+#include 
+
+#include "timer-of.h"
+
+#define CLKSRC_OFFSET  0x40
+
+#define TIMER_STATUS   0x00
+#define TIMER_VALUE0x04
+#define TIMER_CONTRL   0x10
+#define TIMER_CONFIG   0x20
+#define TIMER_DIV  0x24
+#define TIMER_INI  0x28
+
+#define GX6605S_STATUS_CLR BIT(0)
+#define GX6605S_CONTRL_RST BIT(0)
+#define GX6605S_CONTRL_START   BIT(1)
+#define GX6605S_CONFIG_EN  BIT(0)
+#define GX6605S_CONFIG_IRQ_EN  BIT(1)
+
+static irqreturn_t gx6605s_timer_interrupt(int irq, void *dev)
+{
+   struct clock_event_device *ce = dev;
+   void __iomem *base = timer_of_base(to_timer_of(ce));
+
+   writel_relaxed(GX6605S_STATUS_CLR, base + TIMER_STATUS);
+
+   ce->event_handler(ce);
+
+   return IRQ_HANDLED;
+}
+
+static int gx6605s_timer_set_oneshot(struct clock_event_device *ce)
+{
+   void __iomem *base = timer_of_base(to_timer_of(ce));
+
+   /* reset and stop counter */
+   writel_relaxed(GX6605S_CONTRL_RST, base + TIMER_CONTRL);
+
+   /* enable with irq and start */
+   writel_relaxed(GX6605S_CONFIG_EN | GX6605S_CONFIG_IRQ_EN, base + 
TIMER_CONFIG);
+
+   return 0;
+}
+
+static int gx6605s_timer_set_next_event(unsigned long delta, struct 
clock_event_device *ce)
+{
+   void __iomem *base = timer_of_base(to_timer_of(ce));
+
+   /* use reset to pause timer */
+   writel_relaxed(GX6605S_CONTRL_RST, base + TIMER_CONTRL);
+
+   /* config next timeout value */
+   writel_relaxed(ULONG_MAX - delta, base + TIMER_INI);
+   writel_relaxed(GX6605S_CONTRL_START, base + TIMER_CONTRL);
+
+   return 0;
+}
+
+static int gx6605s_timer_shutdown(struct clock_event_device *ce)
+{
+   void __iomem *base = timer_of_base(to_timer_of(ce));
+
+   writel_relaxed(0, base + TIMER_CONTRL);
+   writel_relaxed(0, base + TIMER_CONFIG);
+
+   return 0;
+}
+
+static struct timer_of to = {
+   .flags = TIMER_OF_IRQ | TIMER_OF_BASE | TIMER_OF_CLOCK,
+   .clkevt = {
+   .rating = 300,
+   .features   = CLOCK_EVT_FEAT_DYNIRQ |
+ CLOCK_EVT_FEAT_ONESHOT,
+   .set_state_shutdown = gx6605s_timer_shutdown,
+   .set_state_oneshot  = gx6605s_timer_set_oneshot,
+   .set_next_event = gx6605s_timer_set_next_event,
+   .cpumask= cpu_possible_mask,
+   },
+   .of_irq = {
+   .handler= gx6605s_timer_interrupt,
+   .flags  = IRQF_TIMER | IRQF_IRQPOLL,
+   },
+};
+
+static u64 notrace gx6605s_sched_clock_read(void)
+{
+   void __iomem *base;
+
+   base = timer_of_base(&to) + CLKSRC_OFFSET;
+
+   return (u64)readl_relaxed(base + TIMER_VALUE);
+}
+
+static void gx6605s_clkevt_init(void __iomem *base)
+{
+   writel_relaxed(0, base + TIMER_DIV);
+   writel_relaxed(0, base + TIMER_CONFIG);
+
+   clockevents_config_and_register(&to.clkevt, timer_of_rate(&to), 2, 
ULONG_MAX);
+}
+
+static int gx6605s_clksrc_init(void __iomem *base)
+{
+   writel_relaxed(0, base + TIMER_DIV);
+   writel_relaxed(0, base + TIMER_I

[PATCH V5 27/30] dt-bindings: interrupt-controller: C-SKY APB intc

2018-09-24 Thread Guo Ren
 - Dt-bindings doc about C-SKY apb bus interrupt controller.

Signed-off-by: Guo Ren 
---
 .../interrupt-controller/csky,apb-intc.txt | 62 ++
 1 file changed, 62 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/interrupt-controller/csky,apb-intc.txt

diff --git 
a/Documentation/devicetree/bindings/interrupt-controller/csky,apb-intc.txt 
b/Documentation/devicetree/bindings/interrupt-controller/csky,apb-intc.txt
new file mode 100644
index 000..44286dc
--- /dev/null
+++ b/Documentation/devicetree/bindings/interrupt-controller/csky,apb-intc.txt
@@ -0,0 +1,62 @@
+==
+C-SKY APB Interrupt Controller
+==
+
+C-SKY APB Interrupt Controller is a simple soc interrupt controller
+on the apb bus and we only use it as root irq controller.
+
+ - csky,apb-intc is used in a lot of csky fpgas and socs, it support 64 irq 
nums.
+ - csky,dual-apb-intc consists of 2 apb-intc and 128 irq nums supported.
+ - csky,gx6605s-intc is gx6605s soc internal irq interrupt controller, 64 irq 
nums.
+
+=
+intc node bindings definition
+=
+
+   Description: Describes APB interrupt controller
+
+   PROPERTIES
+
+   - compatible
+   Usage: required
+   Value type: 
+   Definition: must be "csky,apb-intc"
+   "csky,dual-apb-intc"
+   "csky,gx6605s-intc"
+   - #interrupt-cells
+   Usage: required
+   Value type: 
+   Definition: must be <1>
+   - reg
+   Usage: required
+   Value type: 
+   Definition:  in soc from cpu view
+   - interrupt-controller:
+   Usage: required
+   - csky,support-pulse-signal:
+   Usage: select
+   Description: to support pulse signal flag
+
+Examples:
+-
+
+   intc: interrupt-controller@50 {
+   compatible = "csky,apb-intc";
+   #interrupt-cells = <1>;
+   reg = <0x0050 0x400>;
+   interrupt-controller;
+   };
+
+   intc: interrupt-controller@50 {
+   compatible = "csky,dual-apb-intc";
+   #interrupt-cells = <1>;
+   reg = <0x0050 0x400>;
+   interrupt-controller;
+   };
+
+   intc: interrupt-controller@50 {
+   compatible = "csky,gx6605s-intc";
+   #interrupt-cells = <1>;
+   reg = <0x0050 0x400>;
+   interrupt-controller;
+   };
-- 
2.7.4



[PATCH V5 26/30] MAINTAINERS: Add csky

2018-09-24 Thread Guo Ren
Add a maintainer information for the csky(C-SKY) architecture.

Signed-off-by: Guo Ren 
---
 MAINTAINERS | 16 
 1 file changed, 16 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index d870cb5..6b7c1be 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3211,6 +3211,22 @@ T:   git git://git.alsa-project.org/alsa-kernel.git
 S: Maintained
 F: sound/pci/oxygen/
 
+C-SKY ARCHITECTURE
+M: Guo Ren 
+T: git https://github.com/c-sky/csky-linux.git
+S: Supported
+F: arch/csky/
+F: Documentation/devicetree/bindings/interrupt-controller/csky,mpintc.txt
+F: drivers/irqchip/irq-csky-mpintc.c
+F: Documentation/devicetree/bindings/interrupt-controller/csky,apb-intc.txt
+F: drivers/irqchip/irq-csky-apb-intc.c
+F: Documentation/devicetree/bindings/timer/csky,mptimer.txt
+F: drivers/clocksource/csky_mptimer.c
+F: Documentation/devicetree/bindings/timer/csky,gx6605s-timer.txt
+F: drivers/clocksource/timer-gx6605s.c
+K: csky
+N: csky
+
 C6X ARCHITECTURE
 M: Mark Salter 
 M: Aurelien Jacquiot 
-- 
2.7.4



[PATCH V5 28/30] irqchip: add C-SKY APB bus interrupt controller

2018-09-24 Thread Guo Ren
 - irq-csky-apb-intc is a simple SOC interrupt controller which is
   used in a lot of C-SKY CPU SOC products.

Changelog:
 - use "bool ret" instead of "int ret"
 - add support-pulse-signal in irq-csky-apb-intc.c
 - change name with upstream feed-back
 - add INTC_IFR to clear irq-pending
 - remove CSKY_VECIRQ_LEGENCY
 - change to generic irq chip framework
 - add License and Copyright
 - use irq_domain_add_linear instead of leagcy

Signed-off-by: Guo Ren 
---
 drivers/irqchip/Kconfig |   8 ++
 drivers/irqchip/Makefile|   1 +
 drivers/irqchip/irq-csky-apb-intc.c | 260 
 3 files changed, 269 insertions(+)
 create mode 100644 drivers/irqchip/irq-csky-apb-intc.c

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 92e1c20..bf12549 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -379,6 +379,14 @@ config CSKY_MPINTC
  for C-SKY SMP system. In fact it's not mmio map and it use ld/st
  to visit the controller's register inside CPU.
 
+config CSKY_APB_INTC
+   bool "C-SKY APB Interrupt Controller"
+   depends on CSKY
+   help
+ Say yes here to enable C-SKY APB interrupt controller driver used
+ by C-SKY single core SOC system. It use mmio map apb-bus to visit
+ the controller's register.
+
 endmenu
 
 config SIFIVE_PLIC
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index 6b739ea..72eaf53 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -88,4 +88,5 @@ obj-$(CONFIG_GOLDFISH_PIC)+= irq-goldfish-pic.o
 obj-$(CONFIG_NDS32)+= irq-ativic32.o
 obj-$(CONFIG_QCOM_PDC) += qcom-pdc.o
 obj-$(CONFIG_CSKY_MPINTC)  += irq-csky-mpintc.o
+obj-$(CONFIG_CSKY_APB_INTC)+= irq-csky-apb-intc.o
 obj-$(CONFIG_SIFIVE_PLIC)  += irq-sifive-plic.o
diff --git a/drivers/irqchip/irq-csky-apb-intc.c 
b/drivers/irqchip/irq-csky-apb-intc.c
new file mode 100644
index 000..cfe32a7
--- /dev/null
+++ b/drivers/irqchip/irq-csky-apb-intc.c
@@ -0,0 +1,260 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define INTC_IRQS  64
+
+#define CK_INTC_ICR0x00
+#define CK_INTC_PEN31_00   0x14
+#define CK_INTC_PEN63_32   0x2c
+#define CK_INTC_NEN31_00   0x10
+#define CK_INTC_NEN63_32   0x28
+#define CK_INTC_SOURCE 0x40
+#define CK_INTC_DUAL_BASE  0x100
+
+#define GX_INTC_PEN31_00   0x00
+#define GX_INTC_PEN63_32   0x04
+#define GX_INTC_NEN31_00   0x40
+#define GX_INTC_NEN63_32   0x44
+#define GX_INTC_NMASK31_00 0x50
+#define GX_INTC_NMASK63_32 0x54
+#define GX_INTC_SOURCE 0x60
+
+static void __iomem *reg_base;
+static struct irq_domain *root_domain;
+
+static int nr_irq = INTC_IRQS;
+
+/*
+ * When controller support pulse signal, the PEN_reg will hold on signal
+ * without software trigger.
+ *
+ * So, to support pulse signal we need to clear IFR_reg and the address of
+ * IFR_offset is NEN_offset - 8.
+ */
+static void irq_ck_mask_set_bit(struct irq_data *d)
+{
+   struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
+   struct irq_chip_type *ct = irq_data_get_chip_type(d);
+   unsigned long ifr = ct->regs.mask - 8;
+   u32 mask = d->mask;
+
+   irq_gc_lock(gc);
+   *ct->mask_cache |= mask;
+   irq_reg_writel(gc, *ct->mask_cache, ct->regs.mask);
+   irq_reg_writel(gc, irq_reg_readl(gc, ifr) & ~mask, ifr);
+   irq_gc_unlock(gc);
+}
+
+static void __init ck_set_gc(struct device_node *node, void __iomem *reg_base,
+u32 mask_reg, u32 irq_base)
+{
+   struct irq_chip_generic *gc;
+
+   gc = irq_get_domain_generic_chip(root_domain, irq_base);
+   gc->reg_base = reg_base;
+   gc->chip_types[0].regs.mask = mask_reg;
+   gc->chip_types[0].chip.irq_mask = irq_gc_mask_clr_bit;
+   gc->chip_types[0].chip.irq_unmask = irq_gc_mask_set_bit;
+
+   if (of_find_property(node, "csky,support-pulse-signal", NULL))
+   gc->chip_types[0].chip.irq_unmask = irq_ck_mask_set_bit;
+}
+
+static inline u32 build_channel_val(u32 idx, u32 magic)
+{
+   u32 res;
+
+   /*
+* Set the same index for each channel
+*/
+   res = idx | (idx << 8) | (idx << 16) | (idx << 24);
+
+   /*
+* Set the channel magic number in descending order.
+* The magic is 0x00010203 for ck-intc
+* The magic is 0x03020100 for gx6605s-intc
+*/
+   return res | magic;
+}
+
+static inline void setup_irq_channel(u32 magic, void __iomem *reg_addr)
+{
+   u32 i;
+
+   /* Setup 64 channel slots */
+   for (i = 0; i < INTC_IRQS; i += 4) {
+   writel_relaxed(build_channel_val(i, magic), reg_addr + i);
+ 

[PATCH V5 25/30] dt-bindings: timer: C-SKY Multi-processor timer

2018-09-24 Thread Guo Ren
 - Dt-bingdings doc for C-SKY SMP system setting.

Signed-off-by: Guo Ren 
---
 .../devicetree/bindings/timer/csky,mptimer.txt | 46 ++
 1 file changed, 46 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/csky,mptimer.txt

diff --git a/Documentation/devicetree/bindings/timer/csky,mptimer.txt 
b/Documentation/devicetree/bindings/timer/csky,mptimer.txt
new file mode 100644
index 000..1e7e31d
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/csky,mptimer.txt
@@ -0,0 +1,46 @@
+
+C-SKY Multi-processors Timer
+
+
+C-SKY multi-processors timer is designed for C-SKY SMP system and the
+regs is accessed by cpu co-processor 4 registers with mtcr/mfcr.
+
+ - PTIM_CTLR "cr<0, 14>" Control reg to start reset timer.
+ - PTIM_TSR  "cr<1, 14>" Interrupt cleanup status reg.
+ - PTIM_CCVR "cr<3, 14>" Current counter value reg.
+ - PTIM_LVR  "cr<6, 14>" Window value reg to triger next event.
+
+==
+timer node bindings definition
+==
+
+   Description: Describes SMP timer
+
+   PROPERTIES
+
+   - compatible
+   Usage: required
+   Value type: 
+   Definition: must be "csky,mptimer"
+   - clocks
+   Usage: required
+   Value type: 
+   Definition: must be input clk node
+   - interrupts
+   Usage: required
+   Value type: 
+   Definition: must be timer irq num defined by soc
+   - interrupt-parent:
+   Usage: required
+   Value type: 
+   Definition: must be interrupt controller node
+
+Examples:
+-
+
+   timer: timer {
+   compatible = "csky,mptimer";
+   clocks = <&dummy_apb_clk>;
+   interrupts = <16>;
+   interrupt-parent = <&intc>;
+   };
-- 
2.7.4



[PATCH V5 24/30] clocksource: add C-SKY SMP timer

2018-09-24 Thread Guo Ren
This timer is used by SMP system and use mfcr/mtcr instruction
to access the regs.

Changelog:
 - Remove #define CPUHP_AP_CSKY_TIMER_STARTING
 - Add CPUHP_AP_CSKY_TIMER_STARTING in cpuhotplug.h
 - Support csky mp timer alpha version.
 - Just use low-counter with 32bit width as clocksource.
 - Coding convention with upstream feed-back.

Signed-off-by: Guo Ren 
---
 drivers/clocksource/Kconfig|   8 ++
 drivers/clocksource/Makefile   |   1 +
 drivers/clocksource/csky_mptimer.c | 176 +
 include/linux/cpuhotplug.h |   1 +
 4 files changed, 186 insertions(+)
 create mode 100644 drivers/clocksource/csky_mptimer.c

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index a11f4ba..a28043f 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -620,4 +620,12 @@ config RISCV_TIMER
  is accessed via both the SBI and the rdcycle instruction.  This is
  required for all RISC-V systems.
 
+config CSKY_MPTIMER
+   bool "C-SKY Multi Processor Timer"
+   depends on CSKY
+   select TIMER_OF
+   help
+ Say yes here to enable C-SKY SMP timer driver used for C-SKY SMP
+ system.
+
 endmenu
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index db51b24..848c676 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -79,3 +79,4 @@ obj-$(CONFIG_CLKSRC_ST_LPC)   += clksrc_st_lpc.o
 obj-$(CONFIG_X86_NUMACHIP) += numachip.o
 obj-$(CONFIG_ATCPIT100_TIMER)  += timer-atcpit100.o
 obj-$(CONFIG_RISCV_TIMER)  += riscv_timer.o
+obj-$(CONFIG_CSKY_MPTIMER) += csky_mptimer.o
diff --git a/drivers/clocksource/csky_mptimer.c 
b/drivers/clocksource/csky_mptimer.c
new file mode 100644
index 000..9dc3cfb
--- /dev/null
+++ b/drivers/clocksource/csky_mptimer.c
@@ -0,0 +1,176 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "timer-of.h"
+
+#define PTIM_CCVR  "cr<3, 14>"
+#define PTIM_CTLR  "cr<0, 14>"
+#define PTIM_LVR   "cr<6, 14>"
+#define PTIM_TSR   "cr<1, 14>"
+
+static int csky_mptimer_set_next_event(unsigned long delta, struct 
clock_event_device *ce)
+{
+   mtcr(PTIM_LVR, delta);
+
+   return 0;
+}
+
+static int csky_mptimer_shutdown(struct clock_event_device *ce)
+{
+   mtcr(PTIM_CTLR, 0);
+
+   return 0;
+}
+
+static int csky_mptimer_oneshot(struct clock_event_device *ce)
+{
+   mtcr(PTIM_CTLR, 1);
+
+   return 0;
+}
+
+static int csky_mptimer_oneshot_stopped(struct clock_event_device *ce)
+{
+   mtcr(PTIM_CTLR, 0);
+
+   return 0;
+}
+
+static DEFINE_PER_CPU(struct timer_of, csky_to) = {
+   .flags  = TIMER_OF_CLOCK,
+   .clkevt = {
+   .rating = 300,
+   .features   = CLOCK_EVT_FEAT_PERCPU |
+ CLOCK_EVT_FEAT_ONESHOT,
+   .set_state_shutdown = csky_mptimer_shutdown,
+   .set_state_oneshot  = csky_mptimer_oneshot,
+   .set_state_oneshot_stopped  = csky_mptimer_oneshot_stopped,
+   .set_next_event = csky_mptimer_set_next_event,
+   },
+   .of_irq = {
+   .flags  = IRQF_TIMER,
+   .percpu = 1,
+   },
+};
+
+static irqreturn_t timer_interrupt(int irq, void *dev)
+{
+   struct timer_of *to = this_cpu_ptr(&csky_to);
+
+   mtcr(PTIM_TSR, 0);
+
+   to->clkevt.event_handler(&to->clkevt);
+
+   return IRQ_HANDLED;
+}
+
+/*
+ * clock event for percpu
+ */
+static int csky_mptimer_starting_cpu(unsigned int cpu)
+{
+   struct timer_of *to = per_cpu_ptr(&csky_to, cpu);
+
+   to->clkevt.cpumask = cpumask_of(cpu);
+
+   clockevents_config_and_register(&to->clkevt, timer_of_rate(to), 2, 
ULONG_MAX);
+
+   enable_percpu_irq(timer_of_irq(to), 0);
+
+   return 0;
+}
+
+static int csky_mptimer_dying_cpu(unsigned int cpu)
+{
+   struct timer_of *to = per_cpu_ptr(&csky_to, cpu);
+
+   disable_percpu_irq(timer_of_irq(to));
+
+   return 0;
+}
+
+/*
+ * clock source
+ */
+static u64 sched_clock_read(void)
+{
+   return (u64) mfcr(PTIM_CCVR);
+}
+
+static u64 clksrc_read(struct clocksource *c)
+{
+   return (u64) mfcr(PTIM_CCVR);
+}
+
+struct clocksource csky_clocksource = {
+   .name   = "csky",
+   .rating = 400,
+   .mask   = CLOCKSOURCE_MASK(32),
+   .flags  = CLOCK_SOURCE_IS_CONTINUOUS,
+   .read   = clksrc_read,
+};
+
+static int __init csky_mptimer_init(struct device_node *np)
+{
+   int ret, cpu;
+   struct timer_of *to;
+   int rate = 0;
+   int irq  = 0;
+
+   /*
+* Csky_mptimer is designed for C-SKY SMP multi-processors

[PATCH v3 1/2] remoteproc: qcom: Rename Hexagon v5 PAS driver

2018-09-24 Thread Bjorn Andersson
The Hexagon v5 ADSP driver is used for more than only the ADSP and
there's an upcoming non-PAS ADSP PIL for SDM845, so rename the driver to
qcom_q6v5_pas in order to better suite this.

Cc: Rohit kumar 
Signed-off-by: Bjorn Andersson 
---

Changes since v2:
- Move the rename of qcom_q6v5_pil to the 2nd patch, where it belongs.

 drivers/remoteproc/Kconfig| 27 ++-
 drivers/remoteproc/Makefile   |  2 +-
 .../{qcom_adsp_pil.c => qcom_q6v5_pas.c}  |  4 +--
 3 files changed, 17 insertions(+), 16 deletions(-)
 rename drivers/remoteproc/{qcom_adsp_pil.c => qcom_q6v5_pas.c} (98%)

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 052d4dd347f9..425e502c6471 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -84,8 +84,16 @@ config KEYSTONE_REMOTEPROC
  It's safe to say N here if you're not interested in the Keystone
  DSPs or just want to use a bare minimum kernel.
 
-config QCOM_ADSP_PIL
-   tristate "Qualcomm ADSP Peripheral Image Loader"
+config QCOM_RPROC_COMMON
+   tristate
+
+config QCOM_Q6V5_COMMON
+   tristate
+   depends on ARCH_QCOM
+   depends on QCOM_SMEM
+
+config QCOM_Q6V5_PAS
+   tristate "Qualcomm Hexagon v5 Peripheral Authentication Service support"
depends on OF && ARCH_QCOM
depends on QCOM_SMEM
depends on RPMSG_QCOM_SMD || (COMPILE_TEST && RPMSG_QCOM_SMD=n)
@@ -98,15 +106,7 @@ config QCOM_ADSP_PIL
select QCOM_SCM
help
  Say y here to support the TrustZone based Peripherial Image Loader
- for the Qualcomm ADSP remote processors.
-
-config QCOM_RPROC_COMMON
-   tristate
-
-config QCOM_Q6V5_COMMON
-   tristate
-   depends on ARCH_QCOM
-   depends on QCOM_SMEM
+ for the Qualcomm Hexagon v5 based remote processors.
 
 config QCOM_Q6V5_PIL
tristate "Qualcomm Hexagon V5 Peripherial Image Loader"
@@ -120,8 +120,9 @@ config QCOM_Q6V5_PIL
select QCOM_RPROC_COMMON
select QCOM_SCM
help
- Say y here to support the Qualcomm Peripherial Image Loader for the
- Hexagon V5 based remote processors.
+ Say y here to support the TrustZone based Peripherial Image Loader
+ for the Qualcomm Hexagon v5 based remote processors. This is commonly
+ used to control subsystems such as ADSP, Compute and Sensor.
 
 config QCOM_Q6V5_WCSS
tristate "Qualcomm Hexagon based WCSS Peripheral Image Loader"
diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
index 03332fa7e2ee..eb86c8ba5a87 100644
--- a/drivers/remoteproc/Makefile
+++ b/drivers/remoteproc/Makefile
@@ -14,9 +14,9 @@ obj-$(CONFIG_OMAP_REMOTEPROC) += omap_remoteproc.o
 obj-$(CONFIG_WKUP_M3_RPROC)+= wkup_m3_rproc.o
 obj-$(CONFIG_DA8XX_REMOTEPROC) += da8xx_remoteproc.o
 obj-$(CONFIG_KEYSTONE_REMOTEPROC)  += keystone_remoteproc.o
-obj-$(CONFIG_QCOM_ADSP_PIL)+= qcom_adsp_pil.o
 obj-$(CONFIG_QCOM_RPROC_COMMON)+= qcom_common.o
 obj-$(CONFIG_QCOM_Q6V5_COMMON) += qcom_q6v5.o
+obj-$(CONFIG_QCOM_Q6V5_PAS)+= qcom_q6v5_pas.o
 obj-$(CONFIG_QCOM_Q6V5_PIL)+= qcom_q6v5_pil.o
 obj-$(CONFIG_QCOM_Q6V5_WCSS)   += qcom_q6v5_wcss.o
 obj-$(CONFIG_QCOM_SYSMON)  += qcom_sysmon.o
diff --git a/drivers/remoteproc/qcom_adsp_pil.c 
b/drivers/remoteproc/qcom_q6v5_pas.c
similarity index 98%
rename from drivers/remoteproc/qcom_adsp_pil.c
rename to drivers/remoteproc/qcom_q6v5_pas.c
index d4339a6da616..2478ef3cd519 100644
--- a/drivers/remoteproc/qcom_adsp_pil.c
+++ b/drivers/remoteproc/qcom_q6v5_pas.c
@@ -364,11 +364,11 @@ static struct platform_driver adsp_driver = {
.probe = adsp_probe,
.remove = adsp_remove,
.driver = {
-   .name = "qcom_adsp_pil",
+   .name = "qcom_q6v5_pas",
.of_match_table = adsp_of_match,
},
 };
 
 module_platform_driver(adsp_driver);
-MODULE_DESCRIPTION("Qualcomm MSM8974/MSM8996 ADSP Peripherial Image Loader");
+MODULE_DESCRIPTION("Qualcomm Hexagon v5 Peripheral Authentication Service 
driver");
 MODULE_LICENSE("GPL v2");
-- 
2.18.0



[PATCH v3 2/2] remoteproc: qcom: Rename Hexagon v5 modem driver

2018-09-24 Thread Bjorn Andersson
The qcom_q6v5_pil implements support for the self-authenticating modem
subsystem. With the introduction of other q6v5 based non-TZ based
remoteproc driver the current name is cause for confusion, so rename it
to be more specific.

No functional change.

Signed-off-by: Bjorn Andersson 
---

Chances since v2:
- Updated module description, driver name and header comment

 drivers/remoteproc/Kconfig | 14 +++---
 drivers/remoteproc/Makefile|  2 +-
 .../{qcom_q6v5_pil.c => qcom_q6v5_mss.c}   |  6 +++---
 3 files changed, 11 insertions(+), 11 deletions(-)
 rename drivers/remoteproc/{qcom_q6v5_pil.c => qcom_q6v5_mss.c} (99%)

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 425e502c6471..8894935583e2 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -92,30 +92,30 @@ config QCOM_Q6V5_COMMON
depends on ARCH_QCOM
depends on QCOM_SMEM
 
-config QCOM_Q6V5_PAS
-   tristate "Qualcomm Hexagon v5 Peripheral Authentication Service support"
+config QCOM_Q6V5_MSS
+   tristate "Qualcomm Hexagon V5 self-authenticating modem subsystem 
support"
depends on OF && ARCH_QCOM
depends on QCOM_SMEM
depends on RPMSG_QCOM_SMD || (COMPILE_TEST && RPMSG_QCOM_SMD=n)
depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n
depends on QCOM_SYSMON || QCOM_SYSMON=n
select MFD_SYSCON
-   select QCOM_MDT_LOADER
select QCOM_Q6V5_COMMON
select QCOM_RPROC_COMMON
select QCOM_SCM
help
- Say y here to support the TrustZone based Peripherial Image Loader
- for the Qualcomm Hexagon v5 based remote processors.
+ Say y here to support the Qualcomm self-authenticating modem
+ subsystem based on Hexagon V5.
 
-config QCOM_Q6V5_PIL
-   tristate "Qualcomm Hexagon V5 Peripherial Image Loader"
+config QCOM_Q6V5_PAS
+   tristate "Qualcomm Hexagon v5 Peripheral Authentication Service support"
depends on OF && ARCH_QCOM
depends on QCOM_SMEM
depends on RPMSG_QCOM_SMD || (COMPILE_TEST && RPMSG_QCOM_SMD=n)
depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n
depends on QCOM_SYSMON || QCOM_SYSMON=n
select MFD_SYSCON
+   select QCOM_MDT_LOADER
select QCOM_Q6V5_COMMON
select QCOM_RPROC_COMMON
select QCOM_SCM
diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
index eb86c8ba5a87..050f41ac93b0 100644
--- a/drivers/remoteproc/Makefile
+++ b/drivers/remoteproc/Makefile
@@ -16,8 +16,8 @@ obj-$(CONFIG_DA8XX_REMOTEPROC)+= 
da8xx_remoteproc.o
 obj-$(CONFIG_KEYSTONE_REMOTEPROC)  += keystone_remoteproc.o
 obj-$(CONFIG_QCOM_RPROC_COMMON)+= qcom_common.o
 obj-$(CONFIG_QCOM_Q6V5_COMMON) += qcom_q6v5.o
+obj-$(CONFIG_QCOM_Q6V5_MSS)+= qcom_q6v5_mss.o
 obj-$(CONFIG_QCOM_Q6V5_PAS)+= qcom_q6v5_pas.o
-obj-$(CONFIG_QCOM_Q6V5_PIL)+= qcom_q6v5_pil.o
 obj-$(CONFIG_QCOM_Q6V5_WCSS)   += qcom_q6v5_wcss.o
 obj-$(CONFIG_QCOM_SYSMON)  += qcom_sysmon.o
 obj-$(CONFIG_QCOM_WCNSS_PIL)   += qcom_wcnss_pil.o
diff --git a/drivers/remoteproc/qcom_q6v5_pil.c 
b/drivers/remoteproc/qcom_q6v5_mss.c
similarity index 99%
rename from drivers/remoteproc/qcom_q6v5_pil.c
rename to drivers/remoteproc/qcom_q6v5_mss.c
index d7a4b9eca5d2..9ebbb9339295 100644
--- a/drivers/remoteproc/qcom_q6v5_pil.c
+++ b/drivers/remoteproc/qcom_q6v5_mss.c
@@ -1,5 +1,5 @@
 /*
- * Qualcomm Peripheral Image Loader
+ * Qualcomm self-authenticating modem subsystem remoteproc driver
  *
  * Copyright (C) 2016 Linaro Ltd.
  * Copyright (C) 2014 Sony Mobile Communications AB
@@ -1368,11 +1368,11 @@ static struct platform_driver q6v5_driver = {
.probe = q6v5_probe,
.remove = q6v5_remove,
.driver = {
-   .name = "qcom-q6v5-pil",
+   .name = "qcom-q6v5-mss",
.of_match_table = q6v5_of_match,
},
 };
 module_platform_driver(q6v5_driver);
 
-MODULE_DESCRIPTION("Peripheral Image Loader for Hexagon");
+MODULE_DESCRIPTION("Qualcomm Self-authenticating modem remoteproc driver");
 MODULE_LICENSE("GPL v2");
-- 
2.18.0



[PATCH v3 0/2] remoteproc: qcom: Rename adsp and mss drivers

2018-09-24 Thread Bjorn Andersson
As we're introducing a non-TZ based remoteproc driver for the ADSP in SDM845
the current naming scheme becomes cumbersome. Rename the existing drivers in
order to allow for the following:

qcom_q6v5_adsp - handle the non-TZ adsp subsystem
qcom_q6v5_mss - handles the self-authenticated modem
qcom_q6v5_pas - handles all TZ based "standard" subsystems
qcom_q6v5_wcss - handles the non-TZ wireless subsystem

Bjorn Andersson (2):
  remoteproc: qcom: Rename Hexagon v5 PAS driver
  remoteproc: qcom: Rename Hexagon v5 modem driver

 drivers/remoteproc/Kconfig| 35 ++-
 drivers/remoteproc/Makefile   |  4 +--
 .../{qcom_q6v5_pil.c => qcom_q6v5_mss.c}  |  6 ++--
 .../{qcom_adsp_pil.c => qcom_q6v5_pas.c}  |  4 +--
 4 files changed, 25 insertions(+), 24 deletions(-)
 rename drivers/remoteproc/{qcom_q6v5_pil.c => qcom_q6v5_mss.c} (99%)
 rename drivers/remoteproc/{qcom_adsp_pil.c => qcom_q6v5_pas.c} (98%)

-- 
2.18.0



[PATCH V5 22/30] irqchip: add C-SKY SMP interrupt controller

2018-09-24 Thread Guo Ren
 - Irq-csky-mpintc is C-SKY smp system interrupt controller and it
   could support 16 soft irqs, 16 private irqs, and 992 max common
   irqs.

Changelog:
 - Move IPI_IRQ into the driver
 - Remove irq_set_default_host() and use set_ipi_irq_mapping()
 - Change name with upstream feed-back
 - Change irq map, reserve soft_irq & private_irq space
 - Add License and Copyright
 - Support set_affinity for irq balance in SMP

Signed-off-by: Guo Ren 
---
 drivers/irqchip/Kconfig   |   8 ++
 drivers/irqchip/Makefile  |   1 +
 drivers/irqchip/irq-csky-mpintc.c | 195 ++
 3 files changed, 204 insertions(+)
 create mode 100644 drivers/irqchip/irq-csky-mpintc.c

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 383e7b7..92e1c20 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -371,6 +371,14 @@ config QCOM_PDC
  Power Domain Controller driver to manage and configure wakeup
  IRQs for Qualcomm Technologies Inc (QTI) mobile chips.
 
+config CSKY_MPINTC
+   bool "C-SKY Multi Processor Interrupt Controller"
+   depends on CSKY
+   help
+ Say yes here to enable C-SKY SMP interrupt controller driver used
+ for C-SKY SMP system. In fact it's not mmio map and it use ld/st
+ to visit the controller's register inside CPU.
+
 endmenu
 
 config SIFIVE_PLIC
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index fbd1ec8..6b739ea 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -87,4 +87,5 @@ obj-$(CONFIG_MESON_IRQ_GPIO)  += irq-meson-gpio.o
 obj-$(CONFIG_GOLDFISH_PIC) += irq-goldfish-pic.o
 obj-$(CONFIG_NDS32)+= irq-ativic32.o
 obj-$(CONFIG_QCOM_PDC) += qcom-pdc.o
+obj-$(CONFIG_CSKY_MPINTC)  += irq-csky-mpintc.o
 obj-$(CONFIG_SIFIVE_PLIC)  += irq-sifive-plic.o
diff --git a/drivers/irqchip/irq-csky-mpintc.c 
b/drivers/irqchip/irq-csky-mpintc.c
new file mode 100644
index 000..2b424d27
--- /dev/null
+++ b/drivers/irqchip/irq-csky-mpintc.c
@@ -0,0 +1,195 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static struct irq_domain *root_domain;
+static void __iomem *INTCG_base;
+static void __iomem *INTCL_base;
+
+#define IPI_IRQ15
+#define INTC_IRQS  256
+#define COMM_IRQ_BASE  32
+
+#define INTCG_SIZE 0x8000
+#define INTCL_SIZE 0x1000
+#define INTC_SIZE  INTCL_SIZE*nr_cpu_ids + INTCG_SIZE
+
+#define INTCG_ICTLR0x0
+#define INTCG_CICFGR   0x100
+#define INTCG_CIDSTR   0x1000
+
+#define INTCL_PICTLR   0x0
+#define INTCL_SIGR 0x60
+#define INTCL_HPPIR0x68
+#define INTCL_RDYIR0x6c
+#define INTCL_SENR 0xa0
+#define INTCL_CENR 0xa4
+#define INTCL_CACR 0xb4
+
+static DEFINE_PER_CPU(void __iomem *, intcl_reg);
+
+static void csky_mpintc_handler(struct pt_regs *regs)
+{
+   void __iomem *reg_base = this_cpu_read(intcl_reg);
+
+   do {
+   handle_domain_irq(root_domain,
+ readl_relaxed(reg_base + INTCL_RDYIR),
+ regs);
+   } while (readl_relaxed(reg_base + INTCL_HPPIR) & BIT(31));
+}
+
+static void csky_mpintc_enable(struct irq_data *d)
+{
+   void __iomem *reg_base = this_cpu_read(intcl_reg);
+
+   writel_relaxed(d->hwirq, reg_base + INTCL_SENR);
+}
+
+static void csky_mpintc_disable(struct irq_data *d)
+{
+   void __iomem *reg_base = this_cpu_read(intcl_reg);
+
+   writel_relaxed(d->hwirq, reg_base + INTCL_CENR);
+}
+
+static void csky_mpintc_eoi(struct irq_data *d)
+{
+   void __iomem *reg_base = this_cpu_read(intcl_reg);
+
+   writel_relaxed(d->hwirq, reg_base + INTCL_CACR);
+}
+
+#ifdef CONFIG_SMP
+static int csky_irq_set_affinity(struct irq_data *d,
+const struct cpumask *mask_val,
+bool force)
+{
+   unsigned int cpu;
+   unsigned int offset = 4 * (d->hwirq - COMM_IRQ_BASE);
+
+   if (!force)
+   cpu = cpumask_any_and(mask_val, cpu_online_mask);
+   else
+   cpu = cpumask_first(mask_val);
+
+   if (cpu >= nr_cpu_ids)
+   return -EINVAL;
+
+   /* Enable interrupt destination */
+   cpu |= BIT(31);
+
+   writel_relaxed(cpu, INTCG_base + INTCG_CIDSTR + offset);
+
+   irq_data_update_effective_affinity(d, cpumask_of(cpu));
+
+   return IRQ_SET_MASK_OK_DONE;
+}
+#endif
+
+static struct irq_chip csky_irq_chip = {
+   .name   = "C-SKY SMP Intc",
+   .irq_eoi= csky_mpintc_eoi,
+   .irq_enable = csky_mpintc_enable,
+   .irq_disable= csky_mpintc_disable,
+#ifdef CONFIG_SMP
+   .irq_set_affinity = csky_irq_set_affinity,
+#endif
+};
+
+sta

Re: [PATCH] crypto: ccp: Remove forward declaration

2018-09-24 Thread Gary R Hook
On 09/24/2018 04:44 PM, Nick Desaulniers wrote:
> On Mon, Sep 24, 2018 at 2:27 PM Gary R Hook  wrote:
>>
>> On 09/24/2018 03:24 PM, Nick Desaulniers wrote:
>>> On Mon, Sep 24, 2018 at 12:18 PM Gary R Hook  wrote:

 On 09/24/2018 12:26 PM, Nathan Chancellor wrote:
> Clang emits a warning about this construct:
>
> drivers/crypto/ccp/sp-platform.c:36:36: warning: tentative array
> definition assumed to have one element
> static const struct acpi_device_id sp_acpi_match[];
>   ^
> 1 warning generated.
>
> Just remove the forward declarations and move the initializations up
> so that they can be used in sp_get_of_version and sp_get_acpi_version.

 I'm not going to out and out object to this just yet.
>>>
>>> Tentative array definitions need to have the correct length specified;
>>> it should either be forward declared as the correct length, or as this
>>> patch does, skip the forward declare and move up the definition.
>>> Thanks for this patch Nathan.
>>> Reviewed-by: Nick Desaulniers 
>>
>>
>> Checked my C99, and using both static and [] to create a declaration
> 
> Note that the kernel uses gnu89, which is ISO C90 + gnu extensions (IIUC).

I understand that (and appreciate that ubiquitousness of the dialect) 
but in this case it sounds like we are interested in the widest possible 
compatibility. Which makes the original patch problematic, and the fix 
suggested herein suitable.

> 
>> (because it's really a definition) apparently isn't valid. I should have
>> known that. Since I'm old school...
>>
>> Acked-by: Gary R Hook 
>>
>>
>>>

 I am not a clang expert. Can you please provide a make command that
 would explain how you precipitated this complaint?


> Reported-by: Nick Desaulniers 
> Signed-off-by: Nathan Chancellor 
> ---
> drivers/crypto/ccp/sp-platform.c | 53 +++-
> 1 file changed, 25 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/crypto/ccp/sp-platform.c 
> b/drivers/crypto/ccp/sp-platform.c
> index 71734f254fd1..b75dc7db2d4a 100644
> --- a/drivers/crypto/ccp/sp-platform.c
> +++ b/drivers/crypto/ccp/sp-platform.c
> @@ -33,8 +33,31 @@ struct sp_platform {
> unsigned int irq_count;
> };
>
> -static const struct acpi_device_id sp_acpi_match[];
> -static const struct of_device_id sp_of_match[];
> +static const struct sp_dev_vdata dev_vdata[] = {
> + {
> + .bar = 0,
> +#ifdef CONFIG_CRYPTO_DEV_SP_CCP
> + .ccp_vdata = &ccpv3_platform,
> +#endif
> + },
> +};
> +
> +#ifdef CONFIG_ACPI
> +static const struct acpi_device_id sp_acpi_match[] = {
> + { "AMDI0C00", (kernel_ulong_t)&dev_vdata[0] },
> + { },
> +};
> +MODULE_DEVICE_TABLE(acpi, sp_acpi_match);
> +#endif
> +
> +#ifdef CONFIG_OF
> +static const struct of_device_id sp_of_match[] = {
> + { .compatible = "amd,ccp-seattle-v1a",
> +   .data = (const void *)&dev_vdata[0] },
> + { },
> +};
> +MODULE_DEVICE_TABLE(of, sp_of_match);
> +#endif
>
> static struct sp_dev_vdata *sp_get_of_version(struct platform_device 
> *pdev)
> {
> @@ -201,32 +224,6 @@ static int sp_platform_resume(struct platform_device 
> *pdev)
> }
> #endif
>
> -static const struct sp_dev_vdata dev_vdata[] = {
> - {
> - .bar = 0,
> -#ifdef CONFIG_CRYPTO_DEV_SP_CCP
> - .ccp_vdata = &ccpv3_platform,
> -#endif
> - },
> -};
> -
> -#ifdef CONFIG_ACPI
> -static const struct acpi_device_id sp_acpi_match[] = {
> - { "AMDI0C00", (kernel_ulong_t)&dev_vdata[0] },
> - { },
> -};
> -MODULE_DEVICE_TABLE(acpi, sp_acpi_match);
> -#endif
> -
> -#ifdef CONFIG_OF
> -static const struct of_device_id sp_of_match[] = {
> - { .compatible = "amd,ccp-seattle-v1a",
> -   .data = (const void *)&dev_vdata[0] },
> - { },
> -};
> -MODULE_DEVICE_TABLE(of, sp_of_match);
> -#endif
> -
> static struct platform_driver sp_platform_driver = {
> .driver = {
> .name = "ccp",
>

>>>
>>>
>>
> 
> 



[PATCH V5 23/30] dt-bindings: interrupt-controller: C-SKY SMP intc

2018-09-24 Thread Guo Ren
 - Dt-bindings doc about C-SKY Multi-processors interrupt controller.

Signed-off-by: Guo Ren 
---
 .../bindings/interrupt-controller/csky,mpintc.txt  | 40 ++
 1 file changed, 40 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/interrupt-controller/csky,mpintc.txt

diff --git 
a/Documentation/devicetree/bindings/interrupt-controller/csky,mpintc.txt 
b/Documentation/devicetree/bindings/interrupt-controller/csky,mpintc.txt
new file mode 100644
index 000..9cdad74
--- /dev/null
+++ b/Documentation/devicetree/bindings/interrupt-controller/csky,mpintc.txt
@@ -0,0 +1,40 @@
+===
+C-SKY Multi-processors Interrupt Controller
+===
+
+C-SKY Multi-processors Interrupt Controller is designed for ck807/ck810/ck860
+SMP soc, and it also could be used in non-SMP system.
+
+Interrupt number definition:
+
+  0-15  : software irq, and we use 15 as our IPI_IRQ.
+ 16-31  : private  irq, and we use 16 as the co-processor timer.
+ 31-1024: common irq for soc ip.
+
+=
+intc node bindings definition
+=
+
+   Description: Describes SMP interrupt controller
+
+   PROPERTIES
+
+   - compatible
+   Usage: required
+   Value type: 
+   Definition: must be "csky,mpintc"
+   - interrupt-cells
+   Usage: required
+   Value type: 
+   Definition: must be <1>
+   - interrupt-controller:
+   Usage: required
+
+Examples:
+-
+
+   intc: interrupt-controller {
+   compatible = "csky,mpintc";
+   #interrupt-cells = <1>;
+   interrupt-controller;
+   };
-- 
2.7.4



[PATCH V5 20/30] csky/dma: bugfix dma_sync_for_cpu/device

2018-09-24 Thread Guo Ren
ref: https://lkml.org/lkml/2018/5/18/1068

map for_cpu for_device  unmap
TO_DEV  writeback   nonewriteback   none
TO_CPU  invalidate  invalidate* invalidate  invalidate*
BIDIR   writeback   invalidate  writeback   invalidate

Signed-off-by: Guo Ren 
---
 arch/csky/mm/dma-mapping.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/csky/mm/dma-mapping.c b/arch/csky/mm/dma-mapping.c
index 16c2087..30a2041 100644
--- a/arch/csky/mm/dma-mapping.c
+++ b/arch/csky/mm/dma-mapping.c
@@ -217,7 +217,8 @@ void arch_sync_dma_for_device(struct device *dev, 
phys_addr_t paddr,
break;
case DMA_FROM_DEVICE:
case DMA_BIDIRECTIONAL:
-   BUG();
+   dma_wbinv_range(vaddr + offset, vaddr + offset + size);
+   break;
default:
BUG();
}
@@ -240,7 +241,7 @@ void arch_sync_dma_for_cpu(struct device *dev, phys_addr_t 
paddr,
 
switch (dir) {
case DMA_TO_DEVICE:
-   BUG();
+   break;
case DMA_FROM_DEVICE:
case DMA_BIDIRECTIONAL:
dma_wbinv_range(vaddr + offset, vaddr + offset + size);
-- 
2.7.4



[PATCH V5 21/30] csky: remove irq_mapping from smp.c

2018-09-24 Thread Guo Ren
 - Add irq_mapping return check
 - Move IPI_IRQ into irq-driver
 - remove irq_mapping from smp.c to irq-driver
 - Add set_ipi_irq_mapping api to irq-driver
 - update asm/smp.h

Signed-off-by: Guo Ren 
---
 arch/csky/include/asm/smp.h |  4 +++-
 arch/csky/kernel/smp.c  | 27 +++
 2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/arch/csky/include/asm/smp.h b/arch/csky/include/asm/smp.h
index 9a53abf..f3e4f24 100644
--- a/arch/csky/include/asm/smp.h
+++ b/arch/csky/include/asm/smp.h
@@ -17,7 +17,9 @@ void arch_send_call_function_ipi_mask(struct cpumask *mask);
 
 void arch_send_call_function_single_ipi(int cpu);
 
-void __init set_send_ipi(void (*func)(const unsigned long *, unsigned long));
+void __init set_send_ipi(void (*func)(const unsigned long *));
+
+void __init set_ipi_irq_mapping(int (*func)(void));
 
 #define raw_smp_processor_id() (current_thread_info()->cpu)
 
diff --git a/arch/csky/kernel/smp.c b/arch/csky/kernel/smp.c
index 522c73f..14877e2 100644
--- a/arch/csky/kernel/smp.c
+++ b/arch/csky/kernel/smp.c
@@ -20,8 +20,6 @@
 #include 
 #include 
 
-#define IPI_IRQ15
-
 static struct {
unsigned long bits cacheline_aligned;
 } ipi_data[NR_CPUS] __cacheline_aligned;
@@ -56,9 +54,9 @@ static irqreturn_t handle_ipi(int irq, void *dev)
return IRQ_HANDLED;
 }
 
-static void (*send_arch_ipi)(const unsigned long *mask, unsigned long irq) = 
NULL;
+static void (*send_arch_ipi)(const unsigned long *mask) = NULL;
 
-void __init set_send_ipi(void (*func)(const unsigned long *, unsigned long))
+void __init set_send_ipi(void (*func)(const unsigned long *))
 {
if (send_arch_ipi)
return;
@@ -75,7 +73,7 @@ send_ipi_message(const struct cpumask *to_whom, enum 
ipi_message_type operation)
set_bit(operation, &ipi_data[i].bits);
 
smp_mb();
-   send_arch_ipi(cpumask_bits(to_whom), IPI_IRQ);
+   send_arch_ipi(cpumask_bits(to_whom));
 }
 
 void arch_send_call_function_ipi_mask(struct cpumask *mask)
@@ -115,19 +113,32 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 }
 
 static int ipi_dummy_dev;
+static int ipi_irq;
 
 void __init enable_smp_ipi(void)
 {
-   enable_percpu_irq(IPI_IRQ, 0);
+   enable_percpu_irq(ipi_irq, 0);
+}
+
+static int (*arch_ipi_irq_mapping)(void) = NULL;
+
+void __init set_ipi_irq_mapping(int (*func)(void))
+{
+   if (arch_ipi_irq_mapping)
+   return;
+
+   arch_ipi_irq_mapping = func;
 }
 
 void __init setup_smp_ipi(void)
 {
int rc;
 
-   irq_create_mapping(NULL, IPI_IRQ);
+   ipi_irq = arch_ipi_irq_mapping();
+   if (ipi_irq == 0)
+   panic("%s IRQ mapping failed\n", __func__);
 
-   rc = request_percpu_irq(IPI_IRQ, handle_ipi, "IPI Interrupt", 
&ipi_dummy_dev);
+   rc = request_percpu_irq(ipi_irq, handle_ipi, "IPI Interrupt", 
&ipi_dummy_dev);
if (rc)
panic("%s IRQ request failed\n", __func__);
 
-- 
2.7.4



[PATCH V5 19/30] dt-bindings: Add vendor prefix for csky

2018-09-24 Thread Guo Ren
Add csky vendor definition.

Signed-off-by: Guo Ren 
---
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 2c3fc51..a728ee3 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -84,6 +84,7 @@ cosmicCosmic Circuits
 crane  Crane Connectivity Solutions
 creative   Creative Technology Ltd
 crystalfontz   Crystalfontz America, Inc.
+csky   Hangzhou C-SKY Microsystems Co., Ltd
 cubietech  Cubietech, Ltd.
 cypressCypress Semiconductor Corporation
 cznic  CZ.NIC, z.s.p.o.
-- 
2.7.4



[PATCH V5 18/30] dt-bindings: csky CPU Bindings

2018-09-24 Thread Guo Ren
This patch adds the documentation to describe that how to add cpu nodes in
dts for SMP.

Signed-off-by: Guo Ren 
---
 Documentation/devicetree/bindings/csky/cpus.txt | 70 +
 1 file changed, 70 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/csky/cpus.txt

diff --git a/Documentation/devicetree/bindings/csky/cpus.txt 
b/Documentation/devicetree/bindings/csky/cpus.txt
new file mode 100644
index 000..ee3901d
--- /dev/null
+++ b/Documentation/devicetree/bindings/csky/cpus.txt
@@ -0,0 +1,70 @@
+==
+C-SKY CPU Bindings
+==
+
+The device tree allows to describe the layout of CPUs in a system through
+the "cpus" node, which in turn contains a number of subnodes (ie "cpu")
+defining properties for every cpu.
+
+Only SMP system need to care about the cpus node and single processor
+needn't define cpus node at all.
+
+=
+cpus and cpu node bindings definition
+=
+
+- cpus node
+
+Description: Container of cpu nodes
+
+The node name must be "cpus".
+
+A cpus node must define the following properties:
+
+- #address-cells
+Usage: required
+Value type: 
+Definition: must be set to 1
+- #size-cells
+Usage: required
+Value type: 
+Definition: must be set to 0
+
+- cpu node
+
+Description: Describes one of SMP cores
+
+PROPERTIES
+
+- device_type
+Usage: required
+Value type: 
+Definition: must be "cpu"
+- reg
+Usage: required
+Value type: 
+Definition: CPU index
+- status:
+Usage: required
+Value type: 
+Definition: "ok"   means enable  the cpu-core
+"disabled" means disable the cpu-core
+
+Example:
+
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   cpu@0 {
+   device_type = "cpu";
+   reg = <0>;
+   status = "ok";
+   };
+
+   cpu@1 {
+   device_type = "cpu";
+   reg = <1>;
+   status = "ok";
+   };
+   };
-- 
2.7.4



[PATCH V5 17/30] csky: Misc headers

2018-09-24 Thread Guo Ren
This patch adds csky register definition, byteorder, asm-offsets codes.

Signed-off-by: Guo Ren 
---
 arch/csky/abiv1/inc/abi/reg_ops.h  |  27 
 arch/csky/abiv1/inc/abi/regdef.h   |  26 +++
 arch/csky/abiv2/inc/abi/reg_ops.h  |  17 ++
 arch/csky/abiv2/inc/abi/regdef.h   |  26 +++
 arch/csky/include/asm/bitops.h | 282 +
 arch/csky/include/asm/checksum.h   |  55 +++
 arch/csky/include/asm/compat.h |  11 ++
 arch/csky/include/asm/reg_ops.h|  22 +++
 arch/csky/include/uapi/asm/byteorder.h |   9 ++
 arch/csky/kernel/asm-offsets.c |  86 ++
 10 files changed, 561 insertions(+)
 create mode 100644 arch/csky/abiv1/inc/abi/reg_ops.h
 create mode 100644 arch/csky/abiv1/inc/abi/regdef.h
 create mode 100644 arch/csky/abiv2/inc/abi/reg_ops.h
 create mode 100644 arch/csky/abiv2/inc/abi/regdef.h
 create mode 100644 arch/csky/include/asm/bitops.h
 create mode 100644 arch/csky/include/asm/checksum.h
 create mode 100644 arch/csky/include/asm/compat.h
 create mode 100644 arch/csky/include/asm/reg_ops.h
 create mode 100644 arch/csky/include/uapi/asm/byteorder.h
 create mode 100644 arch/csky/kernel/asm-offsets.c

diff --git a/arch/csky/abiv1/inc/abi/reg_ops.h 
b/arch/csky/abiv1/inc/abi/reg_ops.h
new file mode 100644
index 000..6091788
--- /dev/null
+++ b/arch/csky/abiv1/inc/abi/reg_ops.h
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+
+#ifndef __ABI_REG_OPS_H
+#define __ABI_REG_OPS_H
+#include 
+
+#define cprcr(reg) \
+({ \
+   unsigned int tmp;   \
+   asm volatile("cprcr %0, "reg"\n":"=b"(tmp));\
+   tmp;\
+})
+
+#define cpwcr(reg, val)\
+({ \
+   asm volatile("cpwcr %0, "reg"\n"::"b"(val));\
+})
+
+static inline unsigned int mfcr_hint(void)
+{
+   return mfcr("cr30");
+}
+
+static inline unsigned int mfcr_ccr2(void){return 0;}
+
+#endif /* __ABI_REG_OPS_H */
diff --git a/arch/csky/abiv1/inc/abi/regdef.h b/arch/csky/abiv1/inc/abi/regdef.h
new file mode 100644
index 000..68cf10f
--- /dev/null
+++ b/arch/csky/abiv1/inc/abi/regdef.h
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+
+#ifndef  __ASM_CSKY_REGDEF_H
+#define  __ASM_CSKY_REGDEF_H
+
+#define syscallid  r1
+#define r11_sigr11
+
+#define regs_syscallid(regs) regs->regs[9]
+
+/*
+ * PSR format:
+ * | 31 | 30-24 | 23-16 | 15 14 | 13-0 |
+ *   S CPID VEC TM
+ *
+ *S: Super Mode
+ * CPID: Coprocessor id, only 15 for MMU
+ *  VEC: Exception Number
+ *   TM: Trace Mode
+ */
+#define DEFAULT_PSR_VALUE  0x8f00
+
+#define SYSTRACE_SAVENUM   2
+
+#endif /* __ASM_CSKY_REGDEF_H */
diff --git a/arch/csky/abiv2/inc/abi/reg_ops.h 
b/arch/csky/abiv2/inc/abi/reg_ops.h
new file mode 100644
index 000..ffe4fc9
--- /dev/null
+++ b/arch/csky/abiv2/inc/abi/reg_ops.h
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+
+#ifndef __ABI_REG_OPS_H
+#define __ABI_REG_OPS_H
+#include 
+
+static inline unsigned int mfcr_hint(void)
+{
+   return mfcr("cr31");
+}
+
+static inline unsigned int mfcr_ccr2(void)
+{
+   return mfcr("cr23");
+}
+#endif /* __ABI_REG_OPS_H */
diff --git a/arch/csky/abiv2/inc/abi/regdef.h b/arch/csky/abiv2/inc/abi/regdef.h
new file mode 100644
index 000..676e74a
--- /dev/null
+++ b/arch/csky/abiv2/inc/abi/regdef.h
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+
+#ifndef  __ASM_CSKY_REGDEF_H
+#define  __ASM_CSKY_REGDEF_H
+
+#define syscallid  r7
+#define r11_sigr11
+
+#define regs_syscallid(regs) regs->regs[3]
+
+/*
+ * PSR format:
+ * | 31 | 30-24 | 23-16 | 15 14 | 13-10 | 9 | 8-0 |
+ *   S  VEC TMMM
+ *
+ *   S: Super Mode
+ * VEC: Exception Number
+ *  TM: Trace Mode
+ *  MM: Memory unaligned addr access
+ */
+#define DEFAULT_PSR_VALUE  0x8200
+
+#define SYSTRACE_SAVENUM   5
+
+#endif /* __ASM_CSKY_REGDEF_H */
diff --git a/arch/csky/include/asm/bitops.h b/arch/csky/include/asm/bitops.h
new file mode 100644
index 000..c9834f1
--- /dev/null
+++ b/arch/csky/include/asm/bitops.h
@@ -0,0 +1,282 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+
+#ifndef __ASM_CSKY_BITOPS_H
+#define __ASM_CSKY_BITOPS_H
+
+#include 
+#include 
+
+/*
+ * asm-generic/bitops/ffs.h
+ */
+static inline int ffs(int x)
+{
+   if(!x) return 0;
+
+   asm volatile (
+   "brev %0\n"
+   "ff1  %0\n"
+   "addi %0, 1\n"
+   :"=&r"(x)
+

[PATCH V5 16/30] csky: SMP support

2018-09-24 Thread Guo Ren
This patch adds boot, ipi, hotplug code for SMP.

Signed-off-by: Guo Ren 
---
 arch/csky/include/asm/smp.h |  26 +
 arch/csky/kernel/smp.c  | 234 
 2 files changed, 260 insertions(+)
 create mode 100644 arch/csky/include/asm/smp.h
 create mode 100644 arch/csky/kernel/smp.c

diff --git a/arch/csky/include/asm/smp.h b/arch/csky/include/asm/smp.h
new file mode 100644
index 000..9a53abf
--- /dev/null
+++ b/arch/csky/include/asm/smp.h
@@ -0,0 +1,26 @@
+#ifndef __ASM_CSKY_SMP_H
+#define __ASM_CSKY_SMP_H
+
+#include 
+#include 
+#include 
+
+#ifdef CONFIG_SMP
+
+void __init setup_smp(void);
+
+void __init setup_smp_ipi(void);
+
+void __init enable_smp_ipi(void);
+
+void arch_send_call_function_ipi_mask(struct cpumask *mask);
+
+void arch_send_call_function_single_ipi(int cpu);
+
+void __init set_send_ipi(void (*func)(const unsigned long *, unsigned long));
+
+#define raw_smp_processor_id() (current_thread_info()->cpu)
+
+#endif /* CONFIG_SMP */
+
+#endif /* __ASM_CSKY_SMP_H */
diff --git a/arch/csky/kernel/smp.c b/arch/csky/kernel/smp.c
new file mode 100644
index 000..522c73f
--- /dev/null
+++ b/arch/csky/kernel/smp.c
@@ -0,0 +1,234 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define IPI_IRQ15
+
+static struct {
+   unsigned long bits cacheline_aligned;
+} ipi_data[NR_CPUS] __cacheline_aligned;
+
+enum ipi_message_type {
+   IPI_EMPTY,
+   IPI_RESCHEDULE,
+   IPI_CALL_FUNC,
+   IPI_MAX
+};
+
+static irqreturn_t handle_ipi(int irq, void *dev)
+{
+   unsigned long *pending_ipis = &ipi_data[smp_processor_id()].bits;
+
+   while (true) {
+   unsigned long ops;
+
+   ops = xchg(pending_ipis, 0);
+   if (ops == 0)
+   return IRQ_HANDLED;
+
+   if (ops & (1 << IPI_RESCHEDULE))
+   scheduler_ipi();
+
+   if (ops & (1 << IPI_CALL_FUNC))
+   generic_smp_call_function_interrupt();
+
+   BUG_ON((ops >> IPI_MAX) != 0);
+   }
+
+   return IRQ_HANDLED;
+}
+
+static void (*send_arch_ipi)(const unsigned long *mask, unsigned long irq) = 
NULL;
+
+void __init set_send_ipi(void (*func)(const unsigned long *, unsigned long))
+{
+   if (send_arch_ipi)
+   return;
+
+   send_arch_ipi = func;
+}
+
+static void
+send_ipi_message(const struct cpumask *to_whom, enum ipi_message_type 
operation)
+{
+   int i;
+
+   for_each_cpu(i, to_whom)
+   set_bit(operation, &ipi_data[i].bits);
+
+   smp_mb();
+   send_arch_ipi(cpumask_bits(to_whom), IPI_IRQ);
+}
+
+void arch_send_call_function_ipi_mask(struct cpumask *mask)
+{
+   send_ipi_message(mask, IPI_CALL_FUNC);
+}
+
+void arch_send_call_function_single_ipi(int cpu)
+{
+   send_ipi_message(cpumask_of(cpu), IPI_CALL_FUNC);
+}
+
+static void ipi_stop(void *unused)
+{
+   while (1);
+}
+
+void smp_send_stop(void)
+{
+   on_each_cpu(ipi_stop, NULL, 1);
+}
+
+void smp_send_reschedule(int cpu)
+{
+   send_ipi_message(cpumask_of(cpu), IPI_RESCHEDULE);
+}
+
+void *__cpu_up_stack_pointer[NR_CPUS];
+void *__cpu_up_task_pointer[NR_CPUS];
+
+void __init smp_prepare_boot_cpu(void)
+{
+}
+
+void __init smp_prepare_cpus(unsigned int max_cpus)
+{
+}
+
+static int ipi_dummy_dev;
+
+void __init enable_smp_ipi(void)
+{
+   enable_percpu_irq(IPI_IRQ, 0);
+}
+
+void __init setup_smp_ipi(void)
+{
+   int rc;
+
+   irq_create_mapping(NULL, IPI_IRQ);
+
+   rc = request_percpu_irq(IPI_IRQ, handle_ipi, "IPI Interrupt", 
&ipi_dummy_dev);
+   if (rc)
+   panic("%s IRQ request failed\n", __func__);
+
+   enable_smp_ipi();
+}
+
+void __init setup_smp(void)
+{
+   struct device_node *node = NULL;
+   int cpu;
+
+   while ((node = of_find_node_by_type(node, "cpu"))) {
+   if (!of_device_is_available(node))
+   continue;
+
+   if (of_property_read_u32(node, "reg", &cpu))
+   continue;
+
+   if (cpu >= NR_CPUS)
+   continue;
+
+   set_cpu_possible(cpu, true);
+   set_cpu_present(cpu, true);
+   }
+}
+
+extern void _start_smp_secondary(void);
+
+volatile unsigned int secondary_hint;
+volatile unsigned int secondary_ccr;
+volatile unsigned int secondary_stack;
+
+int __cpu_up(unsigned int cpu, struct task_struct *tidle)
+{
+   unsigned int tmp;
+
+   secondary_stack = (unsigned int)tidle->stack + THREAD_SIZE;
+
+   secondary_hint = mfcr("cr31");
+
+   secondary_ccr  = mfcr("cr18");
+
+   /* Flush dcache */
+   mtcr("cr17", 0x22);
+
+   /* Enable cpu in SMP reset ctrl reg */
+   tmp = mfcr("cr<29, 0>");
+   tmp |= 1 << cpu;
+   mtcr

[PATCH V5 15/30] csky: Debug and Ptrace GDB

2018-09-24 Thread Guo Ren
This patch adds arch ptrace implementation, stack dump and bug.h.

Signed-off-by: Guo Ren 
---
 arch/csky/include/asm/bug.h |  26 +++
 arch/csky/include/uapi/asm/ptrace.h | 104 
 arch/csky/kernel/dumpstack.c|  65 
 arch/csky/kernel/ptrace.c   | 318 
 4 files changed, 513 insertions(+)
 create mode 100644 arch/csky/include/asm/bug.h
 create mode 100644 arch/csky/include/uapi/asm/ptrace.h
 create mode 100644 arch/csky/kernel/dumpstack.c
 create mode 100644 arch/csky/kernel/ptrace.c

diff --git a/arch/csky/include/asm/bug.h b/arch/csky/include/asm/bug.h
new file mode 100644
index 000..10b9028
--- /dev/null
+++ b/arch/csky/include/asm/bug.h
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+
+#ifndef __ASM_CSKY_BUG_H
+#define __ASM_CSKY_BUG_H
+
+#include 
+#include 
+#include 
+
+#define BUG()  \
+do {   \
+   asm volatile ("bkpt\n");\
+   unreachable();  \
+} while (0)
+
+#define HAVE_ARCH_BUG
+
+#include 
+
+struct pt_regs;
+
+void die_if_kernel (char *str, struct pt_regs *regs, int nr);
+void show_regs(struct pt_regs *);
+
+#endif /* __ASM_CSKY_BUG_H */
diff --git a/arch/csky/include/uapi/asm/ptrace.h 
b/arch/csky/include/uapi/asm/ptrace.h
new file mode 100644
index 000..688c6fd
--- /dev/null
+++ b/arch/csky/include/uapi/asm/ptrace.h
@@ -0,0 +1,104 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+
+#ifndef _CSKY_PTRACE_H
+#define _CSKY_PTRACE_H
+
+#ifndef __ASSEMBLY__
+
+struct pt_regs {
+   unsigned long   tls;
+   unsigned long   lr;
+   unsigned long   pc;
+   unsigned long   sr;
+   unsigned long   usp;
+
+   /*
+* a0, a1, a2, a3:
+* abiv1: r2, r3, r4, r5
+* abiv2: r0, r1, r2, r3
+*/
+   unsigned long   orig_a0;
+   unsigned long   a0;
+   unsigned long   a1;
+   unsigned long   a2;
+   unsigned long   a3;
+
+   /*
+* ABIV2: r4 ~ r13
+* ABIV1: r6 ~ r14, r1
+*/
+   unsigned long   regs[10];
+
+#if defined(__CSKYABIV2__)
+   /* r16 ~ r30 */
+   unsigned long   exregs[15];
+
+   unsigned long   rhi;
+   unsigned long   rlo;
+   unsigned long   pad; /* reserved */
+#endif
+};
+
+struct user_fp {
+   unsigned long   vr[96];
+   unsigned long   fcr;
+   unsigned long   fesr;
+   unsigned long   fid;
+   unsigned long   reserved;
+};
+
+/*
+ * Switch stack for switch_to after push pt_regs.
+ *
+ * ABI_CSKYV2: r4 ~ r11, r15 ~ r17, r26 ~ r30;
+ * ABI_CSKYV1: r8 ~ r14, r15;
+ */
+struct  switch_stack {
+#if defined(__CSKYABIV2__)
+   unsigned long   r4;
+unsigned long   r5;
+unsigned long   r6;
+unsigned long   r7;
+   unsigned long   r8;
+unsigned long   r9;
+unsigned long   r10;
+unsigned long   r11;
+#else
+   unsigned long   r8;
+unsigned long   r9;
+unsigned long   r10;
+unsigned long   r11;
+unsigned long   r12;
+unsigned long   r13;
+unsigned long   r14;
+#endif
+unsigned long   r15;
+#if defined(__CSKYABIV2__)
+unsigned long   r16;
+unsigned long   r17;
+unsigned long   r26;
+unsigned long   r27;
+unsigned long   r28;
+unsigned long   r29;
+unsigned long   r30;
+#endif
+};
+
+#ifdef __KERNEL__
+
+#define PS_S0x8000  /* Supervisor Mode */
+
+#define arch_has_single_step() (1)
+#define current_pt_regs() \
+   (struct pt_regs *)((char *)current_thread_info() + THREAD_SIZE) - 1
+
+#define user_stack_pointer(regs) ((regs)->usp)
+
+#define user_mode(regs) (!((regs)->sr & PS_S))
+#define instruction_pointer(regs) ((regs)->pc)
+#define profile_pc(regs) instruction_pointer(regs)
+
+#endif /* __KERNEL__ */
+#endif /* __ASSEMBLY__ */
+#endif /* _CSKY_PTRACE_H */
diff --git a/arch/csky/kernel/dumpstack.c b/arch/csky/kernel/dumpstack.c
new file mode 100644
index 000..c7e46d8
--- /dev/null
+++ b/arch/csky/kernel/dumpstack.c
@@ -0,0 +1,65 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+
+#include 
+
+int kstack_depth_to_print = 48;
+
+void show_trace(unsigned long *stack)
+{
+   unsigned long *endstack;
+   unsigned long addr;
+   int i;
+
+   pr_info("Call Trace:\n");
+   addr = (unsigned long)stack + THREAD_SIZE - 1;
+   endstack = (unsigned long *)(addr & -THREAD_SIZE);
+   i = 0;
+   while (stack + 1 <= endstack) {
+   addr = *stack++;
+   /*
+* If the address is either in the text segment of the
+* kernel, or in the region which contains vmalloc'e

[PATCH v2] staging: vc04_services: Update TODO re: arm64

2018-09-24 Thread Aymen Qader
Remove the TODO item to remove manual cache flushing from bulk_receive.
This was previously done in this commit:

(7e8dbdea) staging: bcm2835-camera: Remove explicit cache flush
operations

Also remove the unnecessary asm/cacheflush.h header.

Signed-off-by: Aymen Qader 
---
v2: Make commit message clearer

 drivers/staging/vc04_services/bcm2835-camera/TODO | 6 --
 drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 1 -
 2 files changed, 7 deletions(-)

diff --git a/drivers/staging/vc04_services/bcm2835-camera/TODO 
b/drivers/staging/vc04_services/bcm2835-camera/TODO
index cefce72d814f..6c2b4ffe4996 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/TODO
+++ b/drivers/staging/vc04_services/bcm2835-camera/TODO
@@ -15,9 +15,3 @@ padding in the V4L2 spec, but that padding doesn't match what 
the
 hardware can do.  If we exposed the native padding requirements
 through the V4L2 "multiplanar" formats, the firmware would have one
 less copy it needed to do.
-
-3) Port to ARM64
-
-The bulk_receive() does some manual cache flushing that are 32-bit ARM
-only, which we should convert to proper cross-platform APIs.
-
diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c 
b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
index 51e5b04ff0f5..6e5c1d4ee122 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
@@ -21,7 +21,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "mmal-common.h"
-- 
2.17.1



Re: [PATCH TRIVIAL] Punctuation fixes

2018-09-24 Thread Diego Viola
Hi Miguel,

On Sat, Sep 22, 2018 at 9:59 PM Miguel Ojeda
 wrote:
>
> Hi Diego,
>
> A few things, since it looks like this is your first patch.
>
> On Sat, Sep 22, 2018 at 5:56 PM, Diego Viola  wrote:
> > On Wed, Sep 12, 2018 at 12:54 AM Diego Viola  wrote:
> >>
> >> Signed-off-by: Diego Viola 
> >> ---
> >>  CREDITS | 2 +-
> >>  MAINTAINERS | 2 +-
> >>  Makefile| 2 +-
> >>  3 files changed, 3 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/CREDITS b/CREDITS
> >> index 5befd2d71..b82efb36d 100644
> >> --- a/CREDITS
> >> +++ b/CREDITS
> >> @@ -1473,7 +1473,7 @@ W: http://www.linux-ide.org/
> >>  W: http://www.linuxdiskcert.org/
> >>  D: Random SMP kernel hacker...
> >>  D: Uniform Multi-Platform E-IDE driver
> >> -D: Active-ATA-Chipset maddness..
> >> +D: Active-ATA-Chipset maddness...
>
> I think the extra dots is what was intended here :)

OK.

>
> >>  D: Ultra DMA 133/100/66/33 w/48-bit Addressing
> >>  D: ATA-Disconnect, ATA-TCQ
> >>  D: ATA-Smart Kernel Daemon
> >> diff --git a/MAINTAINERS b/MAINTAINERS
> >> index d870cb57c..6567bf245 100644
> >> --- a/MAINTAINERS
> >> +++ b/MAINTAINERS
> >> @@ -93,7 +93,7 @@ Descriptions of section entries:
> >>Supported:   Someone is actually paid to look after this.
> >>Maintained:  Someone actually looks after it.
> >>Odd Fixes:   It has a maintainer but they don't have time to do
> >> -   much other than throw the odd patch in. See below..
> >> +   much other than throw the odd patch in. See below.
> >>Orphan:  No current maintainer [but maybe you could take the
> >> role as you write your new code].
> >>Obsolete:Old code. Something tagged obsolete generally means
> >> diff --git a/Makefile b/Makefile
> >> index 4d5c883a9..7b5c5d634 100644
> >> --- a/Makefile
> >> +++ b/Makefile
> >> @@ -1109,7 +1109,7 @@ archprepare: archheaders archscripts prepare1 
> >> scripts_basic
> >>  prepare0: archprepare gcc-plugins
> >> $(Q)$(MAKE) $(build)=.
> >>
> >> -# All the preparing..
> >> +# All the preparing...
> >>  prepare: prepare0 prepare-objtool
> >>
> >>  # Support for using generic headers in asm-generic
> >> --
> >> 2.19.0
> >>
> >
> > Jonathan,
> >
> > can you please merge my patch? After you merge this one, I'll go
> > through the rest of the documentation to make it more consistent.
>
> Jonathan is not responsible for these files. Jiri Kosina is the
> maintainer of the trivial tree.

OK, I'm CCing him with this email.

>
> There are 1700+ instances of a "two-stops ellipsis" in the kernel. I
> am not sure they were mistakes, given their prevalence, even if they are
> not formal/common English. Also, I am not sure a commit for each 3 is
> really appropriate! :) Maybe do the full sweep of the Documentation
> ones in a single patch?

Good idea, do you know what approach I can use for the full sweep? sed
perhaps? Doing this manually would be very tedious and using sed might
be error prone.

>
> Also, typically you would note in the subject that this is a "v2" of
> your previous patch (if I am not wrong, you sent a first version
> fixing only one of the 3 mistakes).

Correct, this is my V2 of the first patch. Sorry for not specifying that.

>
> Thanks for your first patch!
>
> Cheers,
> Miguel

Thanks,
Diego


Re: POSIX violation by writeback error

2018-09-24 Thread Alan Cox
> write()
> kernel attempts to write back page and fails
> page is marked clean and evicted from the cache
> read()
> 
> Now your write is gone and there were no calls between the write and
> read.
> 
> The question we still need to answer is this:
> 
> When we attempt to write back some data from the cache and that fails,
> what should happen to the dirty pages?

Why do you care about the content of the pages at that point. The only
options are to use the data (todays model), or to report that you are on
fire.

If you are going to error you don't need to use the data so you could in
fact compress dramatically the amount of stuff you need to save
somewhere. You need the page information so you can realize what page
this is, but you can point the data into oblivion somewhere because you
are no longer going to give it to anyone (assuming you can successfully
force unmap it from everyone once it's not locked by a DMA or similar).

In the real world though it's fairly unusual to just lose a bit of I/O.
Flash devices in particular have a nasty tendancy to simply go *poof* and
the first you know about an I/O error is the last data the drive ever
gives you short of jtag. NFS is an exception and NFS soft timeouts are
nasty.

Alan


Re: POSIX violation by writeback error

2018-09-24 Thread Alan Cox
> The other thing which you seem to be assuming is that applications
> which care about precious data won't use fsync(2).  And in general,
> it's been fairly well known for decades that if you care about your
> data, you have to use fsync(2) or O_DIRECT writes; and you *must*
> check the error return of both the fsync(2) and the close(2) system
> calls.  Emacs got that right in the mid-1980's --- over 30 years ago.
> We mocked GNOME and KDE's toy notepad applications for getting this
> wrong a decade ago, and they've since fixed it.

That's also because our fsync no longer sucks rocks. It used to be
possible for a box under heavy disk I/O to take minutes to fsync a file
because our disk scheduling was so awful (hours if doing a backup to USB
stick).

The problem I think actually is a bit different. There isn't an

int fbarrier(int fd, ...);

call with more relaxed semantics so that you can say 'what I have done so
far must not be consumed by a reader until we are sure it is stable, but
I don't actually need it to hit disk right now'. That's just a flag on
buffers saying 'if we try to read this, make sure we write it out first',
and the flag is cleared as the buffer hits media in writeback.

All of this is still probabilities. I can do all the fsync's I like,
consume the stable data, cause actions over the network like sending
people goods, and then the server is destroyed by a power surge.
Transactions are a higher level concept and the kernel can't fix that.

Alan


Re: [PATCH] clocksource/drivers/fttmr010: fix set_next_event handler

2018-09-24 Thread Joel Stanley
On Sat, 22 Sep 2018 at 03:41, Tao Ren  wrote:
>
> On 9/20/18, 8:33 PM, "Joel Stanley"  wrote:
>
> > I gave this a spin on the ast2400. It looked okay, but I was wondering
> > if you could share you test case so I can run the same test?
>
> Thank you Joel for the testing.
> Sure I can share the test (a small c program which measures delay introduced 
> by nanosleep()), but what would be the preferred way to share it? Like a 
> format-patch? Or maybe I should refine the test and send to openbmc for 
> review?

Whatever method is easiest for you. A patch file or a tarball is fine.
I will then add it to the set of tests I run when testing aspeed
kernels.

Cheers,

Joel


Re: POSIX violation by writeback error

2018-09-24 Thread Alan Cox
On Thu, 6 Sep 2018 11:17:18 +0200
Rogier Wolff  wrote:

> On Thu, Sep 06, 2018 at 12:57:09PM +1000, Dave Chinner wrote:
> > On Wed, Sep 05, 2018 at 02:07:46PM +0200, Rogier Wolff wrote:  
> 
> > > And this has worked for years because
> > > the kernel caches stuff from inodes and data-blocks. If you suddenly
> > > write stuff to harddisk at 10ms for each seek between inode area and
> > > data-area..  
> > 
> > You're assuming an awful lot about filesystem implementation here.
> > Neither ext4, btrfs or XFS issue physical IO like this when flushing
> > data.  
> 
> My thinking is: When fsync (implicit or explicit)  needs to know 
> the result of the underlying IO, it needs to wait for it to have
> happened.

Worse than that. In many cases it needs to wait for the I/O command to
have been accepted and confirmed by the drive, then tell the disk to do a
commit to physical media, then see if that blows up. A confirmation the
disk got the data is not a confirmation that it's stable. Your disk can
also reply from its internal cache with data that will fail to hit the
media a few seconds later.

Given a cache flush on an ATA disk can take 7 seconds I'm not fond of it
8) Fortunately spinning rust is on the way out.

It's even uglier in truth. Spinning rust rewrites sectors under you
by magic without your knowledge and in freaky cases you can have data
turn error that you've not even touched this month. Flash has some
similar behaviour although it can at least use a supercap to do real work.

You can also issue things like a single 16K write and have only the last
8K succeed and the drive report an error, which freaks out some supposedly
robust techniques.

Alan


Re: [PATCH 4.18 164/235] pinctrl: pinmux: Return selector to the pinctrl driver

2018-09-24 Thread Dan Rue
On Mon, Sep 24, 2018 at 01:52:30PM +0200, Greg Kroah-Hartman wrote:
> 4.18-stable review patch.  If anyone has any objections, please let me know.

I bisected a boot failure on an x15 (arm) board to this commit on
4.18.10-rc1. I'm also seeing issues on 4.14 and 4.18 with arm64 boards
hikey and dragonboard 410c, but I have not investigated them yet (they
could be unrelated).

I see there are fixes to this commit that have not been backported.
Namely:

823dd71f58eb ("pinctrl: ingenic: Fix group & function error checking")
a203728ac6bb ("pinctrl: core: Return selector to the pinctrl driver")

However, I tried adding those two in but I still see the boot failure on
x15.

Dan

> 
> --
> 
> From: Tony Lindgren 
> 
> [ Upstream commit f913cfce4ee49a3382a9ff95696f49a46e56e974 ]
> 
> We must return the selector from pinmux_generic_add_function() so
> pin controller device drivers can remove the right group if needed
> for deferred probe for example. And we now must make sure that a
> proper name is passed so we can use it to check if the entry already
> exists.
> 
> Note that fixes are also needed for the pin controller drivers to
> use the selector value.
> 
> Fixes: a76edc89b100 ("pinctrl: core: Add generic pinctrl functions for
> managing groups")
> Reported-by: H. Nikolaus Schaller 
> Cc: Christ van Willegen 
> Cc: Haojian Zhuang 
> Cc: Jacopo Mondi 
> Cc: Paul Cercueil 
> Cc: Sean Wang 
> Signed-off-by: Tony Lindgren 
> Tested-By: H. Nikolaus Schaller 
> Reviewed-by: Andy Shevchenko 
> Signed-off-by: Linus Walleij 
> Signed-off-by: Sasha Levin 
> Signed-off-by: Greg Kroah-Hartman 
> ---
>  drivers/pinctrl/pinmux.c |   16 
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> --- a/drivers/pinctrl/pinmux.c
> +++ b/drivers/pinctrl/pinmux.c
> @@ -308,7 +308,6 @@ static int pinmux_func_name_to_selector(
>   selector++;
>   }
>  
> - dev_err(pctldev->dev, "function '%s' not supported\n", function);
>   return -EINVAL;
>  }
>  
> @@ -775,6 +774,16 @@ int pinmux_generic_add_function(struct p
>   void *data)
>  {
>   struct function_desc *function;
> + int selector;
> +
> + if (!name)
> + return -EINVAL;
> +
> + selector = pinmux_func_name_to_selector(pctldev, name);
> + if (selector >= 0)
> + return selector;
> +
> + selector = pctldev->num_functions;
>  
>   function = devm_kzalloc(pctldev->dev, sizeof(*function), GFP_KERNEL);
>   if (!function)
> @@ -785,12 +794,11 @@ int pinmux_generic_add_function(struct p
>   function->num_group_names = num_groups;
>   function->data = data;
>  
> - radix_tree_insert(&pctldev->pin_function_tree, pctldev->num_functions,
> -   function);
> + radix_tree_insert(&pctldev->pin_function_tree, selector, function);
>  
>   pctldev->num_functions++;
>  
> - return 0;
> + return selector;
>  }
>  EXPORT_SYMBOL_GPL(pinmux_generic_add_function);
>  
> 
> 


[PATCH i2c-next v2 1/2] dt-bindings: i2c: aspeed: Add 'idle-wait-timeout-ms' property

2018-09-24 Thread Jae Hyun Yoo
This commit adds 'idle-wait-timeout-ms' property which can be used
for bus idle waiting logic in multi-master environment.

Signed-off-by: Jae Hyun Yoo 
---
 Documentation/devicetree/bindings/i2c/i2c-aspeed.txt | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/i2c/i2c-aspeed.txt 
b/Documentation/devicetree/bindings/i2c/i2c-aspeed.txt
index 8fbd8633a387..42ecaaf67172 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-aspeed.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-aspeed.txt
@@ -13,9 +13,13 @@ Required Properties:
 - interrupts   : interrupt number
 
 Optional Properties:
-- bus-frequency: frequency of the bus clock in Hz defaults to 100 kHz 
when not
- specified
-- multi-master : states that there is another master active on this bus.
+- bus-frequency: frequency of the bus clock in Hz defaults to 
100 kHz
+ when not specified
+- multi-master : states that there is another master active on this
+ bus.
+- idle-wait-timeout-ms : bus idle waiting timeout in milliseconds when
+ multi-master is set, defaults to 100 ms when not
+ specified.
 
 Example:
 
-- 
2.18.0



[PATCH i2c-next v2 2/2] i2c: aspeed: Add bus idle waiting logic for multi-master use cases

2018-09-24 Thread Jae Hyun Yoo
In multi-master environment, this driver's master cannot know
exactly when peer master sends data to this driver's slave so a
case can be happened that this master tries to send data through
the master_xfer function but slave data from peer master is still
being processed by this driver.

To prevent state corruption in the case, this patch adds checking
if any slave operation is ongoing and it waits up to the timeout
duration before starting a master_xfer operation.

Signed-off-by: Jae Hyun Yoo 
---
 drivers/i2c/busses/i2c-aspeed.c | 70 ++---
 1 file changed, 55 insertions(+), 15 deletions(-)

diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
index 8dc9161ced38..acc26e2a8866 100644
--- a/drivers/i2c/busses/i2c-aspeed.c
+++ b/drivers/i2c/busses/i2c-aspeed.c
@@ -12,6 +12,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -99,6 +100,7 @@
 ASPEED_I2CD_INTR_TX_ACK)
 
 /* 0x14 : I2CD Command/Status Register   */
+#define ASPEED_I2CD_XFER_MODE_STS_MASK GENMASK(22, 19)
 #define ASPEED_I2CD_SCL_LINE_STS   BIT(18)
 #define ASPEED_I2CD_SDA_LINE_STS   BIT(17)
 #define ASPEED_I2CD_BUS_BUSY_STS   BIT(16)
@@ -115,6 +117,10 @@
 /* 0x18 : I2CD Slave Device Address Register   */
 #define ASPEED_I2CD_DEV_ADDR_MASK  GENMASK(6, 0)
 
+/* Bus busy checking */
+#define ASPEED_I2C_IDLE_WAIT_TIMEOUT_MS_DEFAULT100   /* 100 ms 
*/
+#define ASPEED_I2C_BUS_BUSY_CHECK_INTERVAL_US  1 /* 10 ms */
+
 enum aspeed_i2c_master_state {
ASPEED_I2C_MASTER_INACTIVE,
ASPEED_I2C_MASTER_START,
@@ -156,6 +162,9 @@ struct aspeed_i2c_bus {
int cmd_err;
/* Protected only by i2c_lock_bus */
int master_xfer_result;
+   /* Multi-master */
+   boolmulti_master;
+   u32 idle_wait_timeout_ms;
 #if IS_ENABLED(CONFIG_I2C_SLAVE)
struct i2c_client   *slave;
enum aspeed_i2c_slave_state slave_state;
@@ -596,27 +605,49 @@ static irqreturn_t aspeed_i2c_bus_irq(int irq, void 
*dev_id)
return irq_remaining ? IRQ_NONE : IRQ_HANDLED;
 }
 
+static int aspeed_i2c_check_bus_busy(struct aspeed_i2c_bus *bus)
+{
+   u32 status_check_mask = ASPEED_I2CD_BUS_BUSY_STS;
+   ktime_t timeout;
+
+   if (bus->multi_master) {
+   might_sleep();
+   timeout = ktime_add_ms(ktime_get(), bus->idle_wait_timeout_ms);
+   /*
+* ASPEED_I2CD_XFER_MODE_STS_MASK is marked as
+* 'for debugging purpose only' in datasheet but ASPEED
+* confirmed that this reflects real information and good to be
+* used in practical code. It will be used only in multi-master
+* use cases.
+*/
+   status_check_mask |= ASPEED_I2CD_XFER_MODE_STS_MASK;
+   }
+
+   for (;;) {
+   if (!(readl(bus->base + ASPEED_I2C_CMD_REG) &
+ status_check_mask))
+   return 0;
+   if (!bus->multi_master)
+   break;
+   if (ktime_compare(ktime_get(), timeout) > 0)
+   break;
+   usleep_range((ASPEED_I2C_BUS_BUSY_CHECK_INTERVAL_US >> 2) + 1,
+ASPEED_I2C_BUS_BUSY_CHECK_INTERVAL_US);
+   }
+
+   return aspeed_i2c_recover_bus(bus);
+}
+
 static int aspeed_i2c_master_xfer(struct i2c_adapter *adap,
  struct i2c_msg *msgs, int num)
 {
struct aspeed_i2c_bus *bus = i2c_get_adapdata(adap);
unsigned long time_left, flags;
-   int ret = 0;
-
-   spin_lock_irqsave(&bus->lock, flags);
-   bus->cmd_err = 0;
 
-   /* If bus is busy, attempt recovery. We assume a single master
-* environment.
-*/
-   if (readl(bus->base + ASPEED_I2C_CMD_REG) & ASPEED_I2CD_BUS_BUSY_STS) {
-   spin_unlock_irqrestore(&bus->lock, flags);
-   ret = aspeed_i2c_recover_bus(bus);
-   if (ret)
-   return ret;
-   spin_lock_irqsave(&bus->lock, flags);
-   }
+   if (aspeed_i2c_check_bus_busy(bus))
+   return -EAGAIN;
 
+   spin_lock_irqsave(&bus->lock, flags);
bus->cmd_err = 0;
bus->msgs = msgs;
bus->msgs_index = 0;
@@ -827,8 +858,17 @@ static int aspeed_i2c_init(struct aspeed_i2c_bus *bus,
if (ret < 0)
return ret;
 
-   if (!of_property_read_bool(pdev->dev.of_node, "multi-master"))
+   if (of_property_read_bool(pdev->dev.of_node, "multi-master")) {
+   bus->multi_master = true;
+   ret = of_property_read_u32(pdev->dev.of_node,
+  "idle-wait-timeout-ms",

[PATCH i2c-next v2 0/2] i2c: aspeed: Add bus idle waiting logic for multi-master use cases

2018-09-24 Thread Jae Hyun Yoo
In multi-master environment, this driver's master cannot know
exactly when peer master sends data to this driver's slave so a
case can be happened that this master tries to send data through
the master_xfer function but slave data from peer master is still
being processed by this driver.

To prevent state corruption in the case, this patch adds checking
if any slave operation is ongoing and it waits up to the timeout
duration before starting a master_xfer operation.

Please review this patch set.

Thanks,

-Jae

Changes since v1:
- Changed define names of timeout related.

Jae Hyun Yoo (2):
  dt-bindings: i2c: aspeed: Add 'idle-wait-timeout-ms' setting
  i2c: aspeed: Add bus idle waiting logic for multi-master use cases

 .../devicetree/bindings/i2c/i2c-aspeed.txt| 10 ++-
 drivers/i2c/busses/i2c-aspeed.c   | 70 +++
 2 files changed, 62 insertions(+), 18 deletions(-)

-- 
2.18.0



Re: [PATCH] staging: vc04_services: Update TODO re: arm64

2018-09-24 Thread Scott Branden

Hi Aymen


On 18-09-24 03:48 PM, Aymen Qader wrote:

This patch removes the TODO item to remove manual cache flushing from b

Remove the use of "This patch".
Please read 
https://www.kernel.org/doc/html/latest/process/submitting-patches.html

"Describe your changes in imperative mood"

Also, it looks like you broke "bulk_receive" across 2 lines.
Please correct and fix receive typo.

ulk_receieve - this was done in 7e8dbea. Also remove the unnecessary

also read in the guidelines:
If you want to refer to a specific commit, don't just refer to the SHA-1 
ID of the commit.
Please also include the oneline summary of the commit, to make it easier 
for reviewers to know what it is about.

asm/cacheflush.h header.

Signed-off-by: Aymen Qader 
---
  drivers/staging/vc04_services/bcm2835-camera/TODO | 6 --
  drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 1 -
  2 files changed, 7 deletions(-)

diff --git a/drivers/staging/vc04_services/bcm2835-camera/TODO 
b/drivers/staging/vc04_services/bcm2835-camera/TODO
index cefce72d814f..6c2b4ffe4996 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/TODO
+++ b/drivers/staging/vc04_services/bcm2835-camera/TODO
@@ -15,9 +15,3 @@ padding in the V4L2 spec, but that padding doesn't match what 
the
  hardware can do.  If we exposed the native padding requirements
  through the V4L2 "multiplanar" formats, the firmware would have one
  less copy it needed to do.
-
-3) Port to ARM64
-
-The bulk_receive() does some manual cache flushing that are 32-bit ARM
-only, which we should convert to proper cross-platform APIs.
-
diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c 
b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
index 51e5b04ff0f5..6e5c1d4ee122 100644
--- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
+++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
@@ -21,7 +21,6 @@
  #include 
  #include 
  #include 
-#include 
  #include 
  
  #include "mmal-common.h"




  1   2   3   4   5   6   7   8   9   10   >