Re: [PATCH v2 1/1] userfaultfd/sysctl: add vm.unprivileged_userfaultfd

2020-05-26 Thread Xiaoming Ni



On Tue, Mar 19, 2019 at 11:07:22AM +0800, Peter Xu wrote:
> Add a global sysctl knob "vm.unprivileged_userfaultfd" to control
> whether userfaultfd is allowed by unprivileged users.  When this is
> set to zero, only privileged users (root user, or users with the
> CAP_SYS_PTRACE capability) will be able to use the userfaultfd
> syscalls.

Hello
I am a bit confused about this patch, can you help to answer it.

Why the sysctl interface of fs/userfaultfd.c belongs to vm_table instead 
of fs_table ?


https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cefdca0a86be517bc390fc4541e3674b8e7803b0

Thanks
Xiaoming Ni





Re: [PATCH v3 03/16] mfd: mfd-core: match device tree node against reg property

2020-05-26 Thread Lee Jones
On Tue, 26 May 2020, Andy Shevchenko wrote:

> On Tue, May 26, 2020 at 05:54:38PM +0200, Michael Walle wrote:
> > Am 2020-05-26 09:24, schrieb Lee Jones:
> 
> ...
> 
> > Like I said, in the long term I would like to have support for
> > different versions of the board management controller
> 
> > without having to change the device tree and have device tree bindings for 
> > the
> > subdevices at the same time.
> 
> But isn't device tree to describe *very specific platform* rather than *class
> of platforms*?

Yes.  Device Tree describes the hardware.

If the hardware changes, so must the Device Tree.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


Re: [PATCH v2 15/91] clk: bcm: rpi: Pass the clocks data to the firmware function

2020-05-26 Thread Stephen Boyd
Quoting Maxime Ripard (2020-04-24 08:33:56)
> The raspberry_clock_property only takes the clock ID as an argument, but
> now that we have a clock data structure it makes more sense to just pass
> that structure instead.
> 
> Cc: Michael Turquette 
> Cc: Stephen Boyd 
> Cc: linux-...@vger.kernel.org
> Acked-by: Nicolas Saenz Julienne 
> Signed-off-by: Maxime Ripard 
> ---

Reviewed-by: Stephen Boyd 


Re: [PATCH v2 08/91] clk: bcm: rpi: Remove global pllb_arm clock pointer

2020-05-26 Thread Stephen Boyd
Quoting Maxime Ripard (2020-04-24 08:33:49)
> The pllb_arm clk_hw pointer in the raspberry_clk structure isn't used
> anywhere but in the raspberrypi_register_pllb_arm.
> 
> Let's remove it, this will make our lives easier in future patches.
> 
> Cc: Michael Turquette 
> Cc: Stephen Boyd 
> Cc: linux-...@vger.kernel.org
> Acked-by: Nicolas Saenz Julienne 
> Signed-off-by: Maxime Ripard 
> ---

Reviewed-by: Stephen Boyd 


Re: [PATCH v2 09/91] clk: bcm: rpi: Make sure pllb_arm is removed

2020-05-26 Thread Stephen Boyd
Quoting Maxime Ripard (2020-04-24 08:33:50)
> The pllb_arm clock was created at probe time, but was never removed if
> something went wrong later in probe, or if the driver was ever removed from
> the system.
> 
> Now that we are using clk_hw_register, we can just use its managed variant

clk_hw_register()

> to take care of that for us.
> 
> Cc: Michael Turquette 
> Cc: linux-...@vger.kernel.org
> Acked-by: Nicolas Saenz Julienne 
> Reviewed-by: Stephen Boyd 
> Signed-off-by: Maxime Ripard 
> ---

Reviewed-by: Stephen Boyd 


Re: [PATCH RFCv2 9/9] arm64: Support async page fault

2020-05-26 Thread Paolo Bonzini
Hi Gavin,

I definitely appreciate the work, but this is repeating most of the
mistakes done in the x86 implementation.  In particular:

- the page ready signal can be done as an interrupt, rather than an
exception.  This is because "page ready" can be handled asynchronously,
in contrast to "page not present" which must be done on the same
instruction that triggers it.  You can refer to the recent series from
Vitaly Kuznetsov that switched "page ready" to an interrupt.

- the page not present is reusing the memory abort exception, and
there's really no reason to do so.  I think it would be best if ARM
could reserve one ESR exception code for the hypervisor.  Mark, any
ideas how to proceed here?

- for x86 we're also thinking of initiating the page fault from the
exception handler, rather than doing so from the hypervisor before
injecting the exception.  If ARM leads the way here, we would do our
best to share code when x86 does the same.

- do not bother with using KVM_ASYNC_PF_SEND_ALWAYS, it's a fringe case
that adds a lot of complexity.

Also, please include me on further iterations of the series.

Thanks!

Paolo

On 08/05/20 05:29, Gavin Shan wrote:
> This supports asynchronous page fault for the guest. The design is
> similar to what x86 has: on receiving a PAGE_NOT_PRESENT signal from
> the host, the current task is either rescheduled or put into power
> saving mode. The task will be waken up when PAGE_READY signal is
> received. The PAGE_READY signal might be received in the context
> of the suspended process, to be waken up. That means the suspended
> process has to wake up itself, but it's not safe and prone to cause
> dead-lock on CPU runqueue lock. So the wakeup is delayed on returning
> from kernel space to user space or idle process is picked for running.
> 
> The signals are conveyed through the async page fault control block,
> which was passed to host on enabling the functionality. On each page
> fault, the control block is checked and switch to the async page fault
> handling flow if any signals exist.
> 
> The feature is put into the CONFIG_KVM_GUEST umbrella, which is added
> by this patch. So we have inline functions implemented in kvm_para.h,
> like other architectures do, to check if async page fault (one of the
> KVM para-virtualized features) is available. Also, the kernel boot
> parameter "no-kvmapf" can be specified to disable the feature.
> 
> Signed-off-by: Gavin Shan 
> ---
>  arch/arm64/Kconfig |  11 +
>  arch/arm64/include/asm/exception.h |   3 +
>  arch/arm64/include/asm/kvm_para.h  |  27 +-
>  arch/arm64/kernel/entry.S  |  33 +++
>  arch/arm64/kernel/process.c|   4 +
>  arch/arm64/mm/fault.c  | 434 +
>  6 files changed, 505 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 40fb05d96c60..2d5e5ee62d6d 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -1045,6 +1045,17 @@ config PARAVIRT
> under a hypervisor, potentially improving performance significantly
> over full virtualization.
>  
> +config KVM_GUEST
> + bool "KVM Guest Support"
> + depends on PARAVIRT
> + default y
> + help
> +   This option enables various optimizations for running under the KVM
> +   hypervisor. Overhead for the kernel when not running inside KVM should
> +   be minimal.
> +
> +   In case of doubt, say Y
> +
>  config PARAVIRT_TIME_ACCOUNTING
>   bool "Paravirtual steal time accounting"
>   select PARAVIRT
> diff --git a/arch/arm64/include/asm/exception.h 
> b/arch/arm64/include/asm/exception.h
> index 7a6e81ca23a8..d878afa42746 100644
> --- a/arch/arm64/include/asm/exception.h
> +++ b/arch/arm64/include/asm/exception.h
> @@ -46,4 +46,7 @@ void bad_el0_sync(struct pt_regs *regs, int reason, 
> unsigned int esr);
>  void do_cp15instr(unsigned int esr, struct pt_regs *regs);
>  void do_el0_svc(struct pt_regs *regs);
>  void do_el0_svc_compat(struct pt_regs *regs);
> +#ifdef CONFIG_KVM_GUEST
> +void kvm_async_pf_delayed_wake(void);
> +#endif
>  #endif   /* __ASM_EXCEPTION_H */
> diff --git a/arch/arm64/include/asm/kvm_para.h 
> b/arch/arm64/include/asm/kvm_para.h
> index 0ea481dd1c7a..b2f8ef243df7 100644
> --- a/arch/arm64/include/asm/kvm_para.h
> +++ b/arch/arm64/include/asm/kvm_para.h
> @@ -3,6 +3,20 @@
>  #define _ASM_ARM_KVM_PARA_H
>  
>  #include 
> +#include 
> +#include 
> +
> +#ifdef CONFIG_KVM_GUEST
> +static inline int kvm_para_available(void)
> +{
> + return 1;
> +}
> +#else
> +static inline int kvm_para_available(void)
> +{
> + return 0;
> +}
> +#endif /* CONFIG_KVM_GUEST */
>  
>  static inline bool kvm_check_and_clear_guest_paused(void)
>  {
> @@ -11,17 +25,16 @@ static inline bool kvm_check_and_clear_guest_paused(void)
>  
>  static inline unsigned int kvm_arch_para_features(void)
>  {
> - return 0;
> + unsigned int features = 0;
> +
> + if (kvm_arm_hyp_service_available(ARM_SMCC

Re: [PATCH v9] mfd: mt6360: add pmic mt6360 driver

2020-05-26 Thread Lee Jones
On Thu, 23 Apr 2020, Gene Chen wrote:

> Add mfd driver for mt6360 pmic chip include
> Battery Charger/USB_PD/Flash LED/RGB LED/LDO/Buck

I changed the subject line and commit log a bit.

> Signed-off-by: Gene Chen 
> Acked-for-MFD-by: Lee Jones 
> ---
>  drivers/mfd/Kconfig|  12 ++
>  drivers/mfd/Makefile   |   1 +
>  drivers/mfd/mt6360-core.c  | 425 
> +
>  include/linux/mfd/mt6360.h | 240 +
>  4 files changed, 678 insertions(+)
>  create mode 100644 drivers/mfd/mt6360-core.c
>  create mode 100644 include/linux/mfd/mt6360.h

Applied, thanks.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


Re: [v3,1/1] hwmon:(nct7904) Set default timeout

2020-05-26 Thread Guenter Roeck
On Wed, May 27, 2020 at 06:16:59AM +, yuechao.z...@advantech.com.cn wrote:
> From: Yuechao Zhao 
> 
> The timeout module parameter should not be used for setting the default
> timeout. Because, if you set the timeout = 0, the default timeout will
> be meaningless. And the timeout module parameter of 0 means "no timeout
> module paraameter specified".
> 
> Signed-off-by: Yuechao Zhao 

Applied.

Thanks,
Guenter

> ---
> Change in v3:
> - replace 'static int timeout = WATCHDOG_TIMEOUT;' with 'static int timeout;'
> - fixed typo
> 
> Change in v2:
> - modify subject to 'hwmon:(nct7904) Set default timeout'
> ---
>  drivers/hwmon/nct7904.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/hwmon/nct7904.c b/drivers/hwmon/nct7904.c
> index 18c95be..b042569 100644
> --- a/drivers/hwmon/nct7904.c
> +++ b/drivers/hwmon/nct7904.c
> @@ -111,14 +111,14 @@
>  #define MIN_TIMEOUT  (1 * 60)
>  #define MAX_TIMEOUT  (255 * 60)
>  
> -static int timeout = WATCHDOG_TIMEOUT;
> +static int timeout;
>  module_param(timeout, int, 0);
>  MODULE_PARM_DESC(timeout, "Watchdog timeout in minutes. 1 <= timeout <= 255, 
> default="
> - __MODULE_STRING(WATCHODOG_TIMEOUT) ".");
> + __MODULE_STRING(WATCHDOG_TIMEOUT) ".");
>  
>  static bool nowayout = WATCHDOG_NOWAYOUT;
>  module_param(nowayout, bool, 0);
> -MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started once 
> started (default="
> +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started 
> (default="
>   __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
>  
>  static const unsigned short normal_i2c[] = {
> @@ -1147,7 +1147,7 @@ static int nct7904_probe(struct i2c_client *client,
>   data->wdt.ops = &nct7904_wdt_ops;
>   data->wdt.info = &nct7904_wdt_info;
>  
> - data->wdt.timeout = timeout * 60; /* in seconds */
> + data->wdt.timeout = WATCHDOG_TIMEOUT * 60; /* Set default timeout */
>   data->wdt.min_timeout = MIN_TIMEOUT;
>   data->wdt.max_timeout = MAX_TIMEOUT;
>   data->wdt.parent = &client->dev;


Re: [PATCH v2 06/91] clk: bcm: rpi: Statically init clk_init_data

2020-05-26 Thread Stephen Boyd
Quoting Maxime Ripard (2020-04-24 08:33:47)
> Instead of declaring the clk_init_data and then calling memset on it, just
> initialise properly.
> 
> Cc: Michael Turquette 
> Cc: Stephen Boyd 
> Cc: linux-...@vger.kernel.org
> Acked-by: Nicolas Saenz Julienne 
> Signed-off-by: Maxime Ripard 
> ---

Reviewed-by: Stephen Boyd 


[PATCH v2 12/12] mm/page_alloc: use standard migration target allocation function directly

2020-05-26 Thread js1304
From: Joonsoo Kim 

There is no need to make a function in order to call standard migration
target allocation function. Use standard one directly.

Signed-off-by: Joonsoo Kim 
---
 include/linux/page-isolation.h |  2 --
 mm/page_alloc.c|  9 +++--
 mm/page_isolation.c| 11 ---
 3 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h
index 35e3bdb..20a4b63 100644
--- a/include/linux/page-isolation.h
+++ b/include/linux/page-isolation.h
@@ -62,6 +62,4 @@ undo_isolate_page_range(unsigned long start_pfn, unsigned 
long end_pfn,
 int test_pages_isolated(unsigned long start_pfn, unsigned long end_pfn,
int isol_flags);
 
-struct page *alloc_migrate_target(struct page *page, struct alloc_control *ac);
-
 #endif
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 9803158..3f5cfab 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -8359,6 +8359,11 @@ static int __alloc_contig_migrate_range(struct 
compact_control *cc,
unsigned long pfn = start;
unsigned int tries = 0;
int ret = 0;
+   struct alloc_control ac = {
+   .nid = zone_to_nid(cc->zone),
+   .nmask = &node_states[N_MEMORY],
+   .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL,
+   };
 
migrate_prep();
 
@@ -8385,8 +8390,8 @@ static int __alloc_contig_migrate_range(struct 
compact_control *cc,
&cc->migratepages);
cc->nr_migratepages -= nr_reclaimed;
 
-   ret = migrate_pages(&cc->migratepages, alloc_migrate_target,
-   NULL, NULL, cc->mode, MR_CONTIG_RANGE);
+   ret = migrate_pages(&cc->migratepages, alloc_migration_target,
+   NULL, &ac, cc->mode, MR_CONTIG_RANGE);
}
if (ret < 0) {
putback_movable_pages(&cc->migratepages);
diff --git a/mm/page_isolation.c b/mm/page_isolation.c
index aba799d..03d6cad 100644
--- a/mm/page_isolation.c
+++ b/mm/page_isolation.c
@@ -297,14 +297,3 @@ int test_pages_isolated(unsigned long start_pfn, unsigned 
long end_pfn,
 
return pfn < end_pfn ? -EBUSY : 0;
 }
-
-struct page *alloc_migrate_target(struct page *page, struct alloc_control 
*__ac)
-{
-   struct alloc_control ac = {
-   .nid = page_to_nid(page),
-   .nmask = &node_states[N_MEMORY],
-   .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL,
-   };
-
-   return alloc_migration_target(page, &ac);
-}
-- 
2.7.4



[PATCH v2 07/12] mm/hugetlb: do not modify user provided gfp_mask

2020-05-26 Thread js1304
From: Joonsoo Kim 

It's not good practice to modify user input. Instead of using it to
build correct gfp_mask for APIs, this patch introduces another gfp_mask
field, __gfp_mask, for internal usage.

Signed-off-by: Joonsoo Kim 
---
 mm/hugetlb.c  | 19 ++-
 mm/internal.h |  2 ++
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index e465582..4757e72 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1068,15 +1068,15 @@ static struct page *dequeue_huge_page_nodemask(struct 
hstate *h,
struct zoneref *z;
int node = NUMA_NO_NODE;
 
-   zonelist = node_zonelist(ac->nid, ac->gfp_mask);
+   zonelist = node_zonelist(ac->nid, ac->__gfp_mask);
 
 retry_cpuset:
cpuset_mems_cookie = read_mems_allowed_begin();
for_each_zone_zonelist_nodemask(zone, z, zonelist,
-   gfp_zone(ac->gfp_mask), ac->nmask) {
+   gfp_zone(ac->__gfp_mask), ac->nmask) {
struct page *page;
 
-   if (!cpuset_zone_allowed(zone, ac->gfp_mask))
+   if (!cpuset_zone_allowed(zone, ac->__gfp_mask))
continue;
/*
 * no need to ask again on the same node. Pool is node rather 
than
@@ -1127,8 +1127,8 @@ static struct page *dequeue_huge_page_vma(struct hstate 
*h,
if (avoid_reserve && h->free_huge_pages - h->resv_huge_pages == 0)
goto err;
 
-   ac.gfp_mask = htlb_alloc_mask(h);
-   ac.nid = huge_node(vma, address, ac.gfp_mask, &mpol, &ac.nmask);
+   ac.__gfp_mask = htlb_alloc_mask(h);
+   ac.nid = huge_node(vma, address, ac.__gfp_mask, &mpol, &ac.nmask);
 
page = dequeue_huge_page_nodemask(h, &ac);
if (page && !avoid_reserve && vma_has_reserves(vma, chg)) {
@@ -1951,7 +1951,7 @@ static struct page *alloc_migrate_huge_page(struct hstate 
*h,
if (hstate_is_gigantic(h))
return NULL;
 
-   page = alloc_fresh_huge_page(h, ac->gfp_mask,
+   page = alloc_fresh_huge_page(h, ac->__gfp_mask,
ac->nid, ac->nmask, NULL);
if (!page)
return NULL;
@@ -1989,9 +1989,10 @@ struct page *alloc_buddy_huge_page_with_mpol(struct 
hstate *h,
 struct page *alloc_huge_page_nodemask(struct hstate *h,
struct alloc_control *ac)
 {
-   ac->gfp_mask |= htlb_alloc_mask(h);
+   ac->__gfp_mask = htlb_alloc_mask(h);
+   ac->__gfp_mask |= ac->gfp_mask;
if (ac->nid == NUMA_NO_NODE)
-   ac->gfp_mask &= ~__GFP_THISNODE;
+   ac->__gfp_mask &= ~__GFP_THISNODE;
 
spin_lock(&hugetlb_lock);
if (h->free_huge_pages - h->resv_huge_pages > 0) {
@@ -2010,7 +2011,7 @@ struct page *alloc_huge_page_nodemask(struct hstate *h,
 * will not come from CMA area
 */
if (ac->skip_cma)
-   ac->gfp_mask &= ~__GFP_MOVABLE;
+   ac->__gfp_mask &= ~__GFP_MOVABLE;
 
return alloc_migrate_huge_page(h, ac);
 }
diff --git a/mm/internal.h b/mm/internal.h
index 159cfd6..2dc0268 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -619,6 +619,8 @@ struct alloc_control {
nodemask_t *nmask;
gfp_t gfp_mask;
bool skip_cma;
+
+   gfp_t __gfp_mask;   /* Used internally in API implementation */
 };
 
 #endif /* __MM_INTERNAL_H */
-- 
2.7.4



[PATCH v2 10/12] mm/gup: use standard migration target allocation function

2020-05-26 Thread js1304
From: Joonsoo Kim 

There is no reason to implement it's own function for migration
target allocation. Use standard one.

Signed-off-by: Joonsoo Kim 
---
 mm/gup.c | 61 ++---
 1 file changed, 10 insertions(+), 51 deletions(-)

diff --git a/mm/gup.c b/mm/gup.c
index a49d7ea..0e4214d 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1593,58 +1593,16 @@ static bool check_dax_vmas(struct vm_area_struct 
**vmas, long nr_pages)
 }
 
 #ifdef CONFIG_CMA
-static struct page *new_non_cma_page(struct page *page,
+static struct page *alloc_migration_target_non_cma(struct page *page,
struct alloc_control *ac)
 {
-   /*
-* We want to make sure we allocate the new page from the same node
-* as the source page.
-*/
-   int nid = page_to_nid(page);
-   /*
-* Trying to allocate a page for migration. Ignore allocation
-* failure warnings. We don't force __GFP_THISNODE here because
-* this node here is the node where we have CMA reservation and
-* in some case these nodes will have really less non movable
-* allocation memory.
-*/
-   gfp_t gfp_mask = GFP_USER | __GFP_NOWARN;
-
-   if (PageHighMem(page))
-   gfp_mask |= __GFP_HIGHMEM;
-
-   if (PageHuge(page)) {
-   struct hstate *h = page_hstate(page);
-   struct alloc_control ac = {
-   .nid = nid,
-   .nmask = NULL,
-   .gfp_mask = __GFP_NOWARN,
-   .skip_cma = true,
-   };
-
-   return alloc_huge_page_nodemask(h, &ac);
-   }
-
-   if (PageTransHuge(page)) {
-   struct page *thp;
-   /*
-* ignore allocation failure warnings
-*/
-   gfp_t thp_gfpmask = GFP_TRANSHUGE | __GFP_NOWARN;
-
-   /*
-* Remove the movable mask so that we don't allocate from
-* CMA area again.
-*/
-   thp_gfpmask &= ~__GFP_MOVABLE;
-   thp = __alloc_pages_node(nid, thp_gfpmask, HPAGE_PMD_ORDER);
-   if (!thp)
-   return NULL;
-   prep_transhuge_page(thp);
-   return thp;
-   }
+   struct alloc_control __ac = {
+   .nid = page_to_nid(page),
+   .gfp_mask = GFP_USER | __GFP_NOWARN,
+   .skip_cma = true,
+   };
 
-   return __alloc_pages_node(nid, gfp_mask, 0);
+   return alloc_migration_target(page, &__ac);
 }
 
 static long check_and_migrate_cma_pages(struct task_struct *tsk,
@@ -1706,8 +1664,9 @@ static long check_and_migrate_cma_pages(struct 
task_struct *tsk,
for (i = 0; i < nr_pages; i++)
put_page(pages[i]);
 
-   if (migrate_pages(&cma_page_list, new_non_cma_page,
- NULL, NULL, MIGRATE_SYNC, MR_CONTIG_RANGE)) {
+   if (migrate_pages(&cma_page_list,
+   alloc_migration_target_non_cma, NULL, NULL,
+   MIGRATE_SYNC, MR_CONTIG_RANGE)) {
/*
 * some of the pages failed migration. Do get_user_pages
 * without migration.
-- 
2.7.4



[PATCH v2 11/12] mm/mempolicy: use standard migration target allocation function

2020-05-26 Thread js1304
From: Joonsoo Kim 

There is no reason to implement it's own function for migration
target allocation. Use standard one.

Signed-off-by: Joonsoo Kim 
---
 mm/internal.h  |  3 ---
 mm/mempolicy.c | 32 +++-
 mm/migrate.c   |  3 ++-
 3 files changed, 5 insertions(+), 33 deletions(-)

diff --git a/mm/internal.h b/mm/internal.h
index 6f5d810..82495ee 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -612,9 +612,6 @@ static inline bool is_migrate_highatomic_page(struct page 
*page)
 }
 
 void setup_zone_pageset(struct zone *zone);
-struct alloc_control;
-extern struct page *alloc_new_node_page(struct page *page,
-   struct alloc_control *ac);
 
 struct alloc_control {
int nid;/* preferred node id */
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index e50c3eb..27329bdf 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1065,33 +1065,6 @@ static int migrate_page_add(struct page *page, struct 
list_head *pagelist,
return 0;
 }
 
-/* page allocation callback for NUMA node migration */
-struct page *alloc_new_node_page(struct page *page, struct alloc_control *__ac)
-{
-   if (PageHuge(page)) {
-   struct hstate *h = page_hstate(compound_head(page));
-   struct alloc_control ac = {
-   .nid = __ac->nid,
-   .nmask = NULL,
-   .gfp_mask = __GFP_THISNODE,
-   };
-
-   return alloc_huge_page_nodemask(h, &ac);
-   } else if (PageTransHuge(page)) {
-   struct page *thp;
-
-   thp = alloc_pages_node(__ac->nid,
-   (GFP_TRANSHUGE | __GFP_THISNODE),
-   HPAGE_PMD_ORDER);
-   if (!thp)
-   return NULL;
-   prep_transhuge_page(thp);
-   return thp;
-   } else
-   return __alloc_pages_node(__ac->nid, GFP_HIGHUSER_MOVABLE |
-   __GFP_THISNODE, 0);
-}
-
 /*
  * Migrate pages from one node to a target node.
  * Returns error or the number of pages not migrated.
@@ -1104,6 +1077,7 @@ static int migrate_to_node(struct mm_struct *mm, int 
source, int dest,
int err = 0;
struct alloc_control ac = {
.nid = dest,
+   .gfp_mask = GFP_HIGHUSER_MOVABLE | __GFP_THISNODE,
};
 
nodes_clear(nmask);
@@ -1119,8 +1093,8 @@ static int migrate_to_node(struct mm_struct *mm, int 
source, int dest,
flags | MPOL_MF_DISCONTIG_OK, &pagelist);
 
if (!list_empty(&pagelist)) {
-   err = migrate_pages(&pagelist, alloc_new_node_page, NULL, &ac,
-   MIGRATE_SYNC, MR_SYSCALL);
+   err = migrate_pages(&pagelist, alloc_migration_target, NULL,
+   &ac, MIGRATE_SYNC, MR_SYSCALL);
if (err)
putback_movable_pages(&pagelist);
}
diff --git a/mm/migrate.c b/mm/migrate.c
index 780135a..393f592 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1590,9 +1590,10 @@ static int do_move_pages_to_node(struct mm_struct *mm,
int err;
struct alloc_control ac = {
.nid = node,
+   .gfp_mask = GFP_HIGHUSER_MOVABLE | __GFP_THISNODE,
};
 
-   err = migrate_pages(pagelist, alloc_new_node_page, NULL, &ac,
+   err = migrate_pages(pagelist, alloc_migration_target, NULL, &ac,
MIGRATE_SYNC, MR_SYSCALL);
if (err)
putback_movable_pages(pagelist);
-- 
2.7.4



[PATCH v2 08/12] mm/migrate: change the interface of the migration target alloc/free functions

2020-05-26 Thread js1304
From: Joonsoo Kim 

To prepare unifying duplicated functions in following patches, this patch
changes the interface of the migration target alloc/free functions.
Functions now use struct alloc_control as an argument.

There is no functional change.

Signed-off-by: Joonsoo Kim 
---
 include/linux/migrate.h| 15 +++--
 include/linux/page-isolation.h |  4 +++-
 mm/compaction.c| 15 -
 mm/gup.c   |  5 +++--
 mm/internal.h  |  5 -
 mm/memory-failure.c| 13 ++-
 mm/memory_hotplug.c|  9 +---
 mm/mempolicy.c | 22 +++---
 mm/migrate.c   | 51 ++
 mm/page_alloc.c|  2 +-
 mm/page_isolation.c|  9 +---
 11 files changed, 89 insertions(+), 61 deletions(-)

diff --git a/include/linux/migrate.h b/include/linux/migrate.h
index 1d70b4a..923c4f3 100644
--- a/include/linux/migrate.h
+++ b/include/linux/migrate.h
@@ -7,8 +7,9 @@
 #include 
 #include 
 
-typedef struct page *new_page_t(struct page *page, unsigned long private);
-typedef void free_page_t(struct page *page, unsigned long private);
+struct alloc_control;
+typedef struct page *new_page_t(struct page *page, struct alloc_control *ac);
+typedef void free_page_t(struct page *page, struct alloc_control *ac);
 
 /*
  * Return values from addresss_space_operations.migratepage():
@@ -38,9 +39,9 @@ extern int migrate_page(struct address_space *mapping,
struct page *newpage, struct page *page,
enum migrate_mode mode);
 extern int migrate_pages(struct list_head *l, new_page_t new, free_page_t free,
-   unsigned long private, enum migrate_mode mode, int reason);
+   struct alloc_control *ac, enum migrate_mode mode, int reason);
 extern struct page *new_page_nodemask(struct page *page,
-   int preferred_nid, nodemask_t *nodemask);
+   struct alloc_control *ac);
 extern int isolate_movable_page(struct page *page, isolate_mode_t mode);
 extern void putback_movable_page(struct page *page);
 
@@ -56,11 +57,11 @@ extern int migrate_page_move_mapping(struct address_space 
*mapping,
 
 static inline void putback_movable_pages(struct list_head *l) {}
 static inline int migrate_pages(struct list_head *l, new_page_t new,
-   free_page_t free, unsigned long private, enum migrate_mode mode,
-   int reason)
+   free_page_t free, struct alloc_control *ac,
+   enum migrate_mode mode, int reason)
{ return -ENOSYS; }
 static inline struct page *new_page_nodemask(struct page *page,
-   int preferred_nid, nodemask_t *nodemask)
+   struct alloc_control *ac)
{ return NULL; }
 static inline int isolate_movable_page(struct page *page, isolate_mode_t mode)
{ return -EBUSY; }
diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h
index 5724580..35e3bdb 100644
--- a/include/linux/page-isolation.h
+++ b/include/linux/page-isolation.h
@@ -2,6 +2,8 @@
 #ifndef __LINUX_PAGEISOLATION_H
 #define __LINUX_PAGEISOLATION_H
 
+struct alloc_control;
+
 #ifdef CONFIG_MEMORY_ISOLATION
 static inline bool has_isolate_pageblock(struct zone *zone)
 {
@@ -60,6 +62,6 @@ undo_isolate_page_range(unsigned long start_pfn, unsigned 
long end_pfn,
 int test_pages_isolated(unsigned long start_pfn, unsigned long end_pfn,
int isol_flags);
 
-struct page *alloc_migrate_target(struct page *page, unsigned long private);
+struct page *alloc_migrate_target(struct page *page, struct alloc_control *ac);
 
 #endif
diff --git a/mm/compaction.c b/mm/compaction.c
index 9ce4cff..538ed7b 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -1563,9 +1563,9 @@ static void isolate_freepages(struct compact_control *cc)
  * from the isolated freelists in the block we are migrating to.
  */
 static struct page *compaction_alloc(struct page *migratepage,
-   unsigned long data)
+   struct alloc_control *ac)
 {
-   struct compact_control *cc = (struct compact_control *)data;
+   struct compact_control *cc = (struct compact_control *)ac->private;
struct page *freepage;
 
if (list_empty(&cc->freepages)) {
@@ -1587,9 +1587,9 @@ static struct page *compaction_alloc(struct page 
*migratepage,
  * freelist.  All pages on the freelist are from the same zone, so there is no
  * special handling needed for NUMA.
  */
-static void compaction_free(struct page *page, unsigned long data)
+static void compaction_free(struct page *page, struct alloc_control *ac)
 {
-   struct compact_control *cc = (struct compact_control *)data;
+   struct compact_control *cc = (struct compact_control *)ac->private;
 
list_add(&page->lru, &cc->freepages);
cc->nr_freepages++;
@@ -2097,6 +

[PATCH v2 02/12] mm/migrate: move migration helper from .h to .c

2020-05-26 Thread js1304
From: Joonsoo Kim 

It's not performance sensitive function. Move it to .c.
This is a preparation step for future change.

Acked-by: Mike Kravetz 
Signed-off-by: Joonsoo Kim 
---
 include/linux/migrate.h | 33 +
 mm/migrate.c| 29 +
 2 files changed, 34 insertions(+), 28 deletions(-)

diff --git a/include/linux/migrate.h b/include/linux/migrate.h
index 3e546cb..1d70b4a 100644
--- a/include/linux/migrate.h
+++ b/include/linux/migrate.h
@@ -31,34 +31,6 @@ enum migrate_reason {
 /* In mm/debug.c; also keep sync with include/trace/events/migrate.h */
 extern const char *migrate_reason_names[MR_TYPES];
 
-static inline struct page *new_page_nodemask(struct page *page,
-   int preferred_nid, nodemask_t *nodemask)
-{
-   gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL;
-   unsigned int order = 0;
-   struct page *new_page = NULL;
-
-   if (PageHuge(page))
-   return 
alloc_huge_page_nodemask(page_hstate(compound_head(page)),
-   preferred_nid, nodemask);
-
-   if (PageTransHuge(page)) {
-   gfp_mask |= GFP_TRANSHUGE;
-   order = HPAGE_PMD_ORDER;
-   }
-
-   if (PageHighMem(page) || (zone_idx(page_zone(page)) == ZONE_MOVABLE))
-   gfp_mask |= __GFP_HIGHMEM;
-
-   new_page = __alloc_pages_nodemask(gfp_mask, order,
-   preferred_nid, nodemask);
-
-   if (new_page && PageTransHuge(new_page))
-   prep_transhuge_page(new_page);
-
-   return new_page;
-}
-
 #ifdef CONFIG_MIGRATION
 
 extern void putback_movable_pages(struct list_head *l);
@@ -67,6 +39,8 @@ extern int migrate_page(struct address_space *mapping,
enum migrate_mode mode);
 extern int migrate_pages(struct list_head *l, new_page_t new, free_page_t free,
unsigned long private, enum migrate_mode mode, int reason);
+extern struct page *new_page_nodemask(struct page *page,
+   int preferred_nid, nodemask_t *nodemask);
 extern int isolate_movable_page(struct page *page, isolate_mode_t mode);
 extern void putback_movable_page(struct page *page);
 
@@ -85,6 +59,9 @@ static inline int migrate_pages(struct list_head *l, 
new_page_t new,
free_page_t free, unsigned long private, enum migrate_mode mode,
int reason)
{ return -ENOSYS; }
+static inline struct page *new_page_nodemask(struct page *page,
+   int preferred_nid, nodemask_t *nodemask)
+   { return NULL; }
 static inline int isolate_movable_page(struct page *page, isolate_mode_t mode)
{ return -EBUSY; }
 
diff --git a/mm/migrate.c b/mm/migrate.c
index 22a26a5..824c22e 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1537,6 +1537,35 @@ int migrate_pages(struct list_head *from, new_page_t 
get_new_page,
return rc;
 }
 
+struct page *new_page_nodemask(struct page *page,
+   int preferred_nid, nodemask_t *nodemask)
+{
+   gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL;
+   unsigned int order = 0;
+   struct page *new_page = NULL;
+
+   if (PageHuge(page))
+   return alloc_huge_page_nodemask(
+   page_hstate(compound_head(page)),
+   preferred_nid, nodemask);
+
+   if (PageTransHuge(page)) {
+   gfp_mask |= GFP_TRANSHUGE;
+   order = HPAGE_PMD_ORDER;
+   }
+
+   if (PageHighMem(page) || (zone_idx(page_zone(page)) == ZONE_MOVABLE))
+   gfp_mask |= __GFP_HIGHMEM;
+
+   new_page = __alloc_pages_nodemask(gfp_mask, order,
+   preferred_nid, nodemask);
+
+   if (new_page && PageTransHuge(new_page))
+   prep_transhuge_page(new_page);
+
+   return new_page;
+}
+
 #ifdef CONFIG_NUMA
 
 static int store_status(int __user *status, int start, int value, int nr)
-- 
2.7.4



[PATCH v2 09/12] mm/migrate: make standard migration target allocation functions

2020-05-26 Thread js1304
From: Joonsoo Kim 

There are some similar functions for migration target allocation. Since
there is no fundamental difference, it's better to keep just one rather
than keeping all variants. This patch implements base migration target
allocation function. In the following patches, variants will be converted
to use this function.

Note that PageHighmem() call in previous function is changed to open-code
"is_highmem_idx()" since it provides more readability.

Signed-off-by: Joonsoo Kim 
---
 include/linux/migrate.h |  6 +++---
 mm/memory-failure.c |  3 ++-
 mm/memory_hotplug.c |  3 ++-
 mm/migrate.c| 24 +---
 mm/page_isolation.c |  3 ++-
 5 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/include/linux/migrate.h b/include/linux/migrate.h
index 923c4f3..abf09b3 100644
--- a/include/linux/migrate.h
+++ b/include/linux/migrate.h
@@ -40,8 +40,8 @@ extern int migrate_page(struct address_space *mapping,
enum migrate_mode mode);
 extern int migrate_pages(struct list_head *l, new_page_t new, free_page_t free,
struct alloc_control *ac, enum migrate_mode mode, int reason);
-extern struct page *new_page_nodemask(struct page *page,
-   struct alloc_control *ac);
+extern struct page *alloc_migration_target(struct page *page,
+   struct alloc_control *ac);
 extern int isolate_movable_page(struct page *page, isolate_mode_t mode);
 extern void putback_movable_page(struct page *page);
 
@@ -60,7 +60,7 @@ static inline int migrate_pages(struct list_head *l, 
new_page_t new,
free_page_t free, struct alloc_control *ac,
enum migrate_mode mode, int reason)
{ return -ENOSYS; }
-static inline struct page *new_page_nodemask(struct page *page,
+static inline struct page *alloc_migration_target(struct page *page,
struct alloc_control *ac)
{ return NULL; }
 static inline int isolate_movable_page(struct page *page, isolate_mode_t mode)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 0d5d59b..a75de67 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1639,9 +1639,10 @@ static struct page *new_page(struct page *p, struct 
alloc_control *__ac)
struct alloc_control ac = {
.nid = page_to_nid(p),
.nmask = &node_states[N_MEMORY],
+   .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL,
};
 
-   return new_page_nodemask(p, &ac);
+   return alloc_migration_target(p, &ac);
 }
 
 /*
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 89642f9..185f4c9 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1249,7 +1249,8 @@ static struct page *new_node_page(struct page *page, 
struct alloc_control *__ac)
 
ac.nid = nid;
ac.nmask = &nmask;
-   return new_page_nodemask(page, &ac);
+   ac.gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL;
+   return alloc_migration_target(page, &ac);
 }
 
 static int
diff --git a/mm/migrate.c b/mm/migrate.c
index 9d6ed94..780135a 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1537,31 +1537,33 @@ int migrate_pages(struct list_head *from, new_page_t 
get_new_page,
return rc;
 }
 
-struct page *new_page_nodemask(struct page *page, struct alloc_control *ac)
+struct page *alloc_migration_target(struct page *page, struct alloc_control 
*ac)
 {
-   gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL;
unsigned int order = 0;
struct page *new_page = NULL;
+   int zidx;
 
+   /* hugetlb has it's own gfp handling logic */
if (PageHuge(page)) {
struct hstate *h = page_hstate(compound_head(page));
-   struct alloc_control __ac = {
-   .nid = ac->nid,
-   .nmask = ac->nmask,
-   };
 
-   return alloc_huge_page_nodemask(h, &__ac);
+   return alloc_huge_page_nodemask(h, ac);
}
 
+   ac->__gfp_mask = ac->gfp_mask;
if (PageTransHuge(page)) {
-   gfp_mask |= GFP_TRANSHUGE;
+   ac->__gfp_mask |= GFP_TRANSHUGE;
order = HPAGE_PMD_ORDER;
}
+   zidx = zone_idx(page_zone(page));
+   if (is_highmem_idx(zidx) || zidx == ZONE_MOVABLE)
+   ac->__gfp_mask |= __GFP_HIGHMEM;
 
-   if (PageHighMem(page) || (zone_idx(page_zone(page)) == ZONE_MOVABLE))
-   gfp_mask |= __GFP_HIGHMEM;
+   if (ac->skip_cma)
+   ac->__gfp_mask &= ~__GFP_MOVABLE;
 
-   new_page = __alloc_pages_nodemask(gfp_mask, order, ac->nid, ac->nmask);
+   new_page = __alloc_pages_nodemask(ac->__gfp_mask, order,
+   ac->nid, ac->nmask);
 
if (new_page && PageTransHuge(new_page))
prep_transhuge_page(new_page);
diff --git a/mm/page_isolation.c b/mm/page_isolation.c
index 1e1

[PATCH v2 00/12] clean-up the migration target allocation functions

2020-05-26 Thread js1304
From: Joonsoo Kim 

This patchset clean-up the migration target allocation functions.

* Changes on v2
- add acked-by tags
- fix missing compound_head() call for the patch #3
- remove thisnode field on alloc_control and use __GFP_THISNODE directly
- fix missing __gfp_mask setup for the patch
"mm/hugetlb: do not modify user provided gfp_mask"

* Cover-letter

Contributions of this patchset are:
1. unify two hugetlb alloc functions. As a result, one is remained.
2. make one external hugetlb alloc function to internal one.
3. unify three functions for migration target allocation.

The patchset is based on next-20200526.
The patchset is available on:

https://github.com/JoonsooKim/linux/tree/cleanup-migration-target-allocation-v2.00-next-20200526

Thanks.

Joonsoo Kim (12):
  mm/page_isolation: prefer the node of the source page
  mm/migrate: move migration helper from .h to .c
  mm/hugetlb: introduce alloc_control structure to simplify migration
target allocation APIs
  mm/hugetlb: use provided ac->gfp_mask for allocation
  mm/hugetlb: unify hugetlb migration callback function
  mm/hugetlb: make hugetlb migration target allocation APIs CMA aware
  mm/hugetlb: do not modify user provided gfp_mask
  mm/migrate: change the interface of the migration target alloc/free
functions
  mm/migrate: make standard migration target allocation functions
  mm/gup: use standard migration target allocation function
  mm/mempolicy: use standard migration target allocation function
  mm/page_alloc: use standard migration target allocation function
directly

 include/linux/hugetlb.h| 33 ++-
 include/linux/migrate.h| 44 +---
 include/linux/page-isolation.h |  4 +-
 mm/compaction.c| 15 ---
 mm/gup.c   | 60 +---
 mm/hugetlb.c   | 91 --
 mm/internal.h  | 12 +-
 mm/memory-failure.c| 14 ---
 mm/memory_hotplug.c| 10 +++--
 mm/mempolicy.c | 38 ++
 mm/migrate.c   | 72 +
 mm/page_alloc.c|  9 -
 mm/page_isolation.c|  5 ---
 13 files changed, 191 insertions(+), 216 deletions(-)

-- 
2.7.4



[PATCH v2 03/12] mm/hugetlb: introduce alloc_control structure to simplify migration target allocation APIs

2020-05-26 Thread js1304
From: Joonsoo Kim 

Currently, page allocation functions for migration requires some arguments.
More worse, in the following patch, more argument will be needed to unify
the similar functions. To simplify them, in this patch, unified data
structure that controls allocation behaviour is introduced.

For clean-up, function declarations are re-ordered.

Signed-off-by: Joonsoo Kim 
---
 include/linux/hugetlb.h | 35 +++-
 mm/gup.c| 11 ++---
 mm/hugetlb.c| 62 -
 mm/internal.h   |  7 ++
 mm/mempolicy.c  | 13 +++
 mm/migrate.c| 13 +++
 6 files changed, 83 insertions(+), 58 deletions(-)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 50650d0..15c8fb8 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -14,6 +14,7 @@
 struct ctl_table;
 struct user_struct;
 struct mmu_gather;
+struct alloc_control;
 
 #ifndef is_hugepd
 typedef struct { unsigned long pd; } hugepd_t;
@@ -502,15 +503,16 @@ struct huge_bootmem_page {
struct hstate *hstate;
 };
 
-struct page *alloc_huge_page(struct vm_area_struct *vma,
-   unsigned long addr, int avoid_reserve);
-struct page *alloc_huge_page_node(struct hstate *h, int nid);
-struct page *alloc_huge_page_nodemask(struct hstate *h, int preferred_nid,
-   nodemask_t *nmask);
+struct page *alloc_migrate_huge_page(struct hstate *h,
+   struct alloc_control *ac);
+struct page *alloc_huge_page_node(struct hstate *h,
+   struct alloc_control *ac);
+struct page *alloc_huge_page_nodemask(struct hstate *h,
+   struct alloc_control *ac);
 struct page *alloc_huge_page_vma(struct hstate *h, struct vm_area_struct *vma,
unsigned long address);
-struct page *alloc_migrate_huge_page(struct hstate *h, gfp_t gfp_mask,
-int nid, nodemask_t *nmask);
+struct page *alloc_huge_page(struct vm_area_struct *vma,
+   unsigned long addr, int avoid_reserve);
 int huge_add_to_page_cache(struct page *page, struct address_space *mapping,
pgoff_t idx);
 
@@ -752,20 +754,14 @@ static inline void huge_ptep_modify_prot_commit(struct 
vm_area_struct *vma,
 #else  /* CONFIG_HUGETLB_PAGE */
 struct hstate {};
 
-static inline struct page *alloc_huge_page(struct vm_area_struct *vma,
-  unsigned long addr,
-  int avoid_reserve)
-{
-   return NULL;
-}
-
-static inline struct page *alloc_huge_page_node(struct hstate *h, int nid)
+static inline struct page *
+alloc_huge_page_node(struct hstate *h, struct alloc_control *ac)
 {
return NULL;
 }
 
 static inline struct page *
-alloc_huge_page_nodemask(struct hstate *h, int preferred_nid, nodemask_t 
*nmask)
+alloc_huge_page_nodemask(struct hstate *h, struct alloc_control *ac)
 {
return NULL;
 }
@@ -777,6 +773,13 @@ static inline struct page *alloc_huge_page_vma(struct 
hstate *h,
return NULL;
 }
 
+static inline struct page *alloc_huge_page(struct vm_area_struct *vma,
+  unsigned long addr,
+  int avoid_reserve)
+{
+   return NULL;
+}
+
 static inline int __alloc_bootmem_huge_page(struct hstate *h)
 {
return 0;
diff --git a/mm/gup.c b/mm/gup.c
index ee039d4..6b78f11 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1612,16 +1612,21 @@ static struct page *new_non_cma_page(struct page *page, 
unsigned long private)
if (PageHighMem(page))
gfp_mask |= __GFP_HIGHMEM;
 
-#ifdef CONFIG_HUGETLB_PAGE
if (PageHuge(page)) {
struct hstate *h = page_hstate(page);
+   struct alloc_control ac = {
+   .nid = nid,
+   .nmask = NULL,
+   .gfp_mask = gfp_mask,
+   };
+
/*
 * We don't want to dequeue from the pool because pool pages 
will
 * mostly be from the CMA region.
 */
-   return alloc_migrate_huge_page(h, gfp_mask, nid, NULL);
+   return alloc_migrate_huge_page(h, &ac);
}
-#endif
+
if (PageTransHuge(page)) {
struct page *thp;
/*
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 57ece74..453ba94 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1053,8 +1053,8 @@ static struct page *dequeue_huge_page_node_exact(struct 
hstate *h, int nid)
return page;
 }
 
-static struct page *dequeue_huge_page_nodemask(struct hstate *h, gfp_t 
gfp_mask, int nid,
-   nodemask_t *nmask)
+static struct page *dequeue_huge_page_nodemask(struct hstate *h,
+   struct alloc_con

[PATCH v2 04/12] mm/hugetlb: use provided ac->gfp_mask for allocation

2020-05-26 Thread js1304
From: Joonsoo Kim 

gfp_mask handling on alloc_huge_page_(node|nodemask) is
slightly changed, from ASSIGN to OR. It's safe since caller of these
functions doesn't pass extra gfp_mask except htlb_alloc_mask().

This is a preparation step for following patches.

Signed-off-by: Joonsoo Kim 
---
 mm/hugetlb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 453ba94..dabe460 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1985,7 +1985,7 @@ struct page *alloc_huge_page_node(struct hstate *h,
 {
struct page *page = NULL;
 
-   ac->gfp_mask = htlb_alloc_mask(h);
+   ac->gfp_mask |= htlb_alloc_mask(h);
if (ac->nid != NUMA_NO_NODE)
ac->gfp_mask |= __GFP_THISNODE;
 
@@ -2004,7 +2004,7 @@ struct page *alloc_huge_page_node(struct hstate *h,
 struct page *alloc_huge_page_nodemask(struct hstate *h,
struct alloc_control *ac)
 {
-   ac->gfp_mask = htlb_alloc_mask(h);
+   ac->gfp_mask |= htlb_alloc_mask(h);
 
spin_lock(&hugetlb_lock);
if (h->free_huge_pages - h->resv_huge_pages > 0) {
-- 
2.7.4



[PATCH v2 01/12] mm/page_isolation: prefer the node of the source page

2020-05-26 Thread js1304
From: Joonsoo Kim 

For locality, it's better to migrate the page to the same node
rather than the node of the current caller's cpu.

Acked-by: Roman Gushchin 
Signed-off-by: Joonsoo Kim 
---
 mm/page_isolation.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/page_isolation.c b/mm/page_isolation.c
index 2c11a38..7df89bd 100644
--- a/mm/page_isolation.c
+++ b/mm/page_isolation.c
@@ -300,5 +300,7 @@ int test_pages_isolated(unsigned long start_pfn, unsigned 
long end_pfn,
 
 struct page *alloc_migrate_target(struct page *page, unsigned long private)
 {
-   return new_page_nodemask(page, numa_node_id(), &node_states[N_MEMORY]);
+   int nid = page_to_nid(page);
+
+   return new_page_nodemask(page, nid, &node_states[N_MEMORY]);
 }
-- 
2.7.4



[PATCH v2 06/12] mm/hugetlb: make hugetlb migration target allocation APIs CMA aware

2020-05-26 Thread js1304
From: Joonsoo Kim 

There is a user who do not want to use CMA memory for migration. Until
now, it is implemented by caller side but it's not optimal since there
is limited information on caller. This patch implements it on callee side
to get better result.

Acked-by: Mike Kravetz 
Signed-off-by: Joonsoo Kim 
---
 include/linux/hugetlb.h |  2 --
 mm/gup.c|  9 +++--
 mm/hugetlb.c| 21 +
 mm/internal.h   |  1 +
 4 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index f482563..3d05f7d 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -503,8 +503,6 @@ struct huge_bootmem_page {
struct hstate *hstate;
 };
 
-struct page *alloc_migrate_huge_page(struct hstate *h,
-   struct alloc_control *ac);
 struct page *alloc_huge_page_nodemask(struct hstate *h,
struct alloc_control *ac);
 struct page *alloc_huge_page_vma(struct hstate *h, struct vm_area_struct *vma,
diff --git a/mm/gup.c b/mm/gup.c
index 6b78f11..87eca79 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1617,14 +1617,11 @@ static struct page *new_non_cma_page(struct page *page, 
unsigned long private)
struct alloc_control ac = {
.nid = nid,
.nmask = NULL,
-   .gfp_mask = gfp_mask,
+   .gfp_mask = __GFP_NOWARN,
+   .skip_cma = true,
};
 
-   /*
-* We don't want to dequeue from the pool because pool pages 
will
-* mostly be from the CMA region.
-*/
-   return alloc_migrate_huge_page(h, &ac);
+   return alloc_huge_page_nodemask(h, &ac);
}
 
if (PageTransHuge(page)) {
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 8132985..e465582 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1033,13 +1033,19 @@ static void enqueue_huge_page(struct hstate *h, struct 
page *page)
h->free_huge_pages_node[nid]++;
 }
 
-static struct page *dequeue_huge_page_node_exact(struct hstate *h, int nid)
+static struct page *dequeue_huge_page_node_exact(struct hstate *h,
+   int nid, bool skip_cma)
 {
struct page *page;
 
-   list_for_each_entry(page, &h->hugepage_freelists[nid], lru)
+   list_for_each_entry(page, &h->hugepage_freelists[nid], lru) {
+   if (skip_cma && is_migrate_cma_page(page))
+   continue;
+
if (!PageHWPoison(page))
break;
+   }
+
/*
 * if 'non-isolated free hugepage' not found on the list,
 * the allocation fails.
@@ -1080,7 +1086,7 @@ static struct page *dequeue_huge_page_nodemask(struct 
hstate *h,
continue;
node = zone_to_nid(zone);
 
-   page = dequeue_huge_page_node_exact(h, node);
+   page = dequeue_huge_page_node_exact(h, node, ac->skip_cma);
if (page)
return page;
}
@@ -1937,7 +1943,7 @@ static struct page *alloc_surplus_huge_page(struct hstate 
*h, gfp_t gfp_mask,
return page;
 }
 
-struct page *alloc_migrate_huge_page(struct hstate *h,
+static struct page *alloc_migrate_huge_page(struct hstate *h,
struct alloc_control *ac)
 {
struct page *page;
@@ -1999,6 +2005,13 @@ struct page *alloc_huge_page_nodemask(struct hstate *h,
}
spin_unlock(&hugetlb_lock);
 
+   /*
+* clearing __GFP_MOVABLE flag ensure that allocated page
+* will not come from CMA area
+*/
+   if (ac->skip_cma)
+   ac->gfp_mask &= ~__GFP_MOVABLE;
+
return alloc_migrate_huge_page(h, ac);
 }
 
diff --git a/mm/internal.h b/mm/internal.h
index 6e613ce..159cfd6 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -618,6 +618,7 @@ struct alloc_control {
int nid;/* preferred node id */
nodemask_t *nmask;
gfp_t gfp_mask;
+   bool skip_cma;
 };
 
 #endif /* __MM_INTERNAL_H */
-- 
2.7.4



[PATCH v2 05/12] mm/hugetlb: unify hugetlb migration callback function

2020-05-26 Thread js1304
From: Joonsoo Kim 

There is no difference between two migration callback functions,
alloc_huge_page_node() and alloc_huge_page_nodemask(), except
__GFP_THISNODE handling. This patch moves this handling to
alloc_huge_page_nodemask() and function caller. Then, remove
alloc_huge_page_node().

Signed-off-by: Joonsoo Kim 
---
 include/linux/hugetlb.h |  8 
 mm/hugetlb.c| 23 ++-
 mm/mempolicy.c  |  3 ++-
 3 files changed, 4 insertions(+), 30 deletions(-)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 15c8fb8..f482563 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -505,8 +505,6 @@ struct huge_bootmem_page {
 
 struct page *alloc_migrate_huge_page(struct hstate *h,
struct alloc_control *ac);
-struct page *alloc_huge_page_node(struct hstate *h,
-   struct alloc_control *ac);
 struct page *alloc_huge_page_nodemask(struct hstate *h,
struct alloc_control *ac);
 struct page *alloc_huge_page_vma(struct hstate *h, struct vm_area_struct *vma,
@@ -755,12 +753,6 @@ static inline void huge_ptep_modify_prot_commit(struct 
vm_area_struct *vma,
 struct hstate {};
 
 static inline struct page *
-alloc_huge_page_node(struct hstate *h, struct alloc_control *ac)
-{
-   return NULL;
-}
-
-static inline struct page *
 alloc_huge_page_nodemask(struct hstate *h, struct alloc_control *ac)
 {
return NULL;
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index dabe460..8132985 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1980,31 +1980,12 @@ struct page *alloc_buddy_huge_page_with_mpol(struct 
hstate *h,
 }
 
 /* page migration callback function */
-struct page *alloc_huge_page_node(struct hstate *h,
-   struct alloc_control *ac)
-{
-   struct page *page = NULL;
-
-   ac->gfp_mask |= htlb_alloc_mask(h);
-   if (ac->nid != NUMA_NO_NODE)
-   ac->gfp_mask |= __GFP_THISNODE;
-
-   spin_lock(&hugetlb_lock);
-   if (h->free_huge_pages - h->resv_huge_pages > 0)
-   page = dequeue_huge_page_nodemask(h, ac);
-   spin_unlock(&hugetlb_lock);
-
-   if (!page)
-   page = alloc_migrate_huge_page(h, ac);
-
-   return page;
-}
-
-/* page migration callback function */
 struct page *alloc_huge_page_nodemask(struct hstate *h,
struct alloc_control *ac)
 {
ac->gfp_mask |= htlb_alloc_mask(h);
+   if (ac->nid == NUMA_NO_NODE)
+   ac->gfp_mask &= ~__GFP_THISNODE;
 
spin_lock(&hugetlb_lock);
if (h->free_huge_pages - h->resv_huge_pages > 0) {
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 3b6b551..e705efd 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1073,9 +1073,10 @@ struct page *alloc_new_node_page(struct page *page, 
unsigned long node)
struct alloc_control ac = {
.nid = node,
.nmask = NULL,
+   .gfp_mask = __GFP_THISNODE,
};
 
-   return alloc_huge_page_node(h, &ac);
+   return alloc_huge_page_nodemask(h, &ac);
} else if (PageTransHuge(page)) {
struct page *thp;
 
-- 
2.7.4



Re: [PATCH 01/11] mm/page_isolation: prefer the node of the source page

2020-05-26 Thread Joonsoo Kim
> > >  mm/page_isolation.c | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/mm/page_isolation.c b/mm/page_isolation.c
> > > index 2c11a38..7df89bd 100644
> > > --- a/mm/page_isolation.c
> > > +++ b/mm/page_isolation.c
> > > @@ -300,5 +300,7 @@ int test_pages_isolated(unsigned long start_pfn, 
> > > unsigned long end_pfn,
> > >
> > >  struct page *alloc_migrate_target(struct page *page, unsigned long 
> > > private)
> > >  {
> > > - return new_page_nodemask(page, numa_node_id(), 
> > > &node_states[N_MEMORY]);
> > > + int nid = page_to_nid(page);
> > > +
> > > + return new_page_nodemask(page, nid, &node_states[N_MEMORY]);
> >
> > Why not new_page_nodemask(page, page_to_nid(page), &node_states[N_MEMORY]) ?
> > Still fits into 80 characters.
>
> It's just my preference not directly using function call in argument
> as much as possible.
> If you don't like it, I will change it as you suggested. However,
> since alloc_migrate_target()
> will be removed in following patch, there will be no difference in the end.

Oops... I found that your suggestion exceed 80 character.
I will leave the patch as it is.

Thanks.


Re: [PATCH v11 00/56] atmel_mxt_ts misc

2020-05-26 Thread Dmitry Torokhov
Hi Jiada,

On Thu, May 07, 2020 at 10:56:00PM -0700, Jiada Wang wrote:
> This patch-set forward ports Nick Dyer's work in ndyer/linux github
> repository as long as some other features and fixes

Sorry for ignoring the series for quite a while. I guess my biggest
issue with the series is that quite a bit of patches are trying to
handle the fallout from a very unfortunate design decision in the
driver: the fact that it attempts to automatically upload firmware and
config on every boot/probe. This design was done at my urging because I
did not have access to the technical documentation and did not realize
that the controller has non-volatile memory for both firmware and
configuration. We should only attempt to automatically load firmware
where device does not have non-volatile memory and is unable function
otherwise, in all other cases we better leave it to userspace to decide
whether to execute firmware update and when. The kernel should only
provide facilities so that userspace can initiate firmware update. This
design has worked well for Chrome OS for many years (it used Atmel
controllers in several products), and I would like to bring it to the
mainline.

Thanks.

-- 
Dmitry


Re: [RESEND PATCH v2 2/4] dt-bindings: clk: sprd: add mipi_csi_xx clocks for SC9863A

2020-05-26 Thread Stephen Boyd
Quoting Chunyan Zhang (2020-05-26 22:36:36)
> From: Chunyan Zhang 
> 
> mipi_csi_xx clocks are used by camera sensors.
> 
> Signed-off-by: Chunyan Zhang 
> Acked-by: Rob Herring 
> ---

Applied to clk-next


Re: [RESEND PATCH v2 1/4] clk: sprd: check its parent status before reading gate clock

2020-05-26 Thread Stephen Boyd
Quoting Chunyan Zhang (2020-05-26 22:36:35)
> From: Chunyan Zhang 
> 
> Some clocks only can be accessed if their parent is enabled. mipi_csi_xx
> clocks on SC9863A are an examples. We have to ensure the parent clock is
> enabled when reading those clocks.
> 
> Signed-off-by: Chunyan Zhang 
> ---

Applied to clk-next


Re: [RESEND PATCH v2 3/4] clk: sprd: add dt-bindings include for mipi_csi_xx clocks

2020-05-26 Thread Stephen Boyd
Quoting Chunyan Zhang (2020-05-26 22:36:37)
> From: Chunyan Zhang 
> 
> mipi_csi_xx clocks are used by camera sensors.
> 
> Signed-off-by: Chunyan Zhang 
> Acked-by: Rob Herring 
> ---

Applied to clk-next


Re: [RESEND PATCH v2 4/4] clk: sprd: add mipi_csi_xx gate clocks

2020-05-26 Thread Stephen Boyd
Quoting Chunyan Zhang (2020-05-26 22:36:38)
> From: Chunyan Zhang 
> 
> mipi_csi_xx clocks are used by camera sensors.
> 
> Signed-off-by: Chunyan Zhang 
> ---

Applied to clk-next


Re: [PATCH v1 1/1] PCI/ERR: Handle fatal error recovery for non-hotplug capable devices

2020-05-26 Thread Yicong Yang


On 2020/5/27 12:04, Kuppuswamy, Sathyanarayanan wrote:
>
>
> On 5/26/20 8:50 PM, Yicong Yang wrote:
>> Hi,
>>
>>
>> On 2020/5/27 9:31, Kuppuswamy, Sathyanarayanan wrote:
>>> Hi,
>>>
>>> On 5/21/20 7:56 PM, Yicong Yang wrote:


 On 2020/5/22 3:31, Kuppuswamy, Sathyanarayanan wrote:
>
>
> On 5/21/20 3:58 AM, Yicong Yang wrote:
>> On 2020/5/21 1:04, Kuppuswamy, Sathyanarayanan wrote:
>>>
>>>
>>> On 5/20/20 1:28 AM, Yicong Yang wrote:
 On 2020/5/7 11:32, sathyanarayanan.kuppusw...@linux.intel.com wrote:
> From: Kuppuswamy Sathyanarayanan 
> 
>
> If there are non-hotplug capable devices connected to a given
> port, then during the fatal error recovery(triggered by DPC or
> AER), after calling reset_link() function, we cannot rely on
> hotplug handler to detach and re-enumerate the device drivers
> in the affected bus. Instead, we will have to let the error
> recovery handler call report_slot_reset() for all devices in
> the bus to notify about the reset operation. Although this is
> only required for non hot-plug capable devices, doing it for
> hotplug capable devices should not affect the functionality.
>
> Along with above issue, this fix also applicable to following
> issue.
>
> Commit 6d2c89441571 ("PCI/ERR: Update error status after
> reset_link()") added support to store status of reset_link()
> call. Although this fixed the error recovery issue observed if
> the initial value of error status is PCI_ERS_RESULT_DISCONNECT
> or PCI_ERS_RESULT_NO_AER_DRIVER, it also discarded the status
> result from report_frozen_detected. This can cause a failure to
> recover if _NEED_RESET is returned by report_frozen_detected and
> report_slot_reset is not invoked.
>
> Such an event can be induced for testing purposes by reducing the
> Max_Payload_Size of a PCIe bridge to less than that of a device
> downstream from the bridge, and then initiating I/O through the
> device, resulting in oversize transactions.  In the presence of DPC,
> this results in a containment event and attempted reset and recovery
> via pcie_do_recovery.  After 6d2c89441571 report_slot_reset is not
> invoked, and the device does not recover.
>
> [original patch is from jay.vosbu...@canonical.com]
> [original patch link 
> https://lore.kernel.org/linux-pci/18609.1588812972@famine/]
> Fixes: 6d2c89441571 ("PCI/ERR: Update error status after 
> reset_link()")
> Signed-off-by: Jay Vosburgh 
> Signed-off-by: Kuppuswamy Sathyanarayanan 
> 
> ---
>  drivers/pci/pcie/err.c | 19 +++
>  1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
> index 14bb8f54723e..db80e1ecb2dc 100644
> --- a/drivers/pci/pcie/err.c
> +++ b/drivers/pci/pcie/err.c
> @@ -165,13 +165,24 @@ pci_ers_result_t pcie_do_recovery(struct 
> pci_dev *dev,
>  pci_dbg(dev, "broadcast error_detected message\n");
>  if (state == pci_channel_io_frozen) {
>  pci_walk_bus(bus, report_frozen_detected, &status);
> -status = reset_link(dev);
> -if (status != PCI_ERS_RESULT_RECOVERED) {
> +status = PCI_ERS_RESULT_NEED_RESET;
> +} else {
> +pci_walk_bus(bus, report_normal_detected, &status);
> +}
> +
> +if (status == PCI_ERS_RESULT_NEED_RESET) {
> +if (reset_link) {
> +if (reset_link(dev) != PCI_ERS_RESULT_RECOVERED)

 we'll call reset_link() only if link is frozen. so it may have problem 
 here.
>>> you mean before this change right?
>>> After this change, reset_link() will be called as long as status is
>>> PCI_ERS_RESULT_NEED_RESET.
>>
>> Yes. I think we should reset the link only if the io is blocked as 
>> before. There's
>> no reason to reset a normal link.
> Currently, only AER and DPC driver uses pcie_do_recovery() call. So the
> possible reset_link options are dpc_reset_link() and aer_root_reset().
>
> In dpc_reset_link() case, the link is already disabled and hence we
> don't need to do another reset. In case of aer_root_reset() it
> uses pci_bus_error_reset() to reset the slot.

 Not exactly. In pci_bus_error_reset(), we call pci_slot_reset() only if 
 it's
 hotpluggable. But we always call pci_bus_reset() to perform a secondary bus
 reset for the bridge. That's what I think is unnecessary for a normal link,
 and that's what reset link indicates us to do. The slot reset i

Re: [PATCH v4] workqueue: Remove unnecessary kfree() call in rcu_free_wq()

2020-05-26 Thread Markus Elfring
> The callback function "rcu_free_wq" could be called after memory
> was released for "wq->rescuer" already and assignment is empty. so
> remove unnecessary kfree(NULL).

I have got the impression that also this wording approach contains weaknesses.
How do you think about a wording variant like the following?

   The data structure member “wq->rescuer” was reset to a null pointer
   in one if branch. It was passed to a call of the function “kfree”
   in the callback function “rcu_free_wq” (which was eventually executed).
   The function “kfree” does not perform more meaningful data processing
   for a passed null pointer (besides immediately returning from such a call).
   Thus delete this function call which became unnecessary with the referenced
   software update.


> Fixes: def98c84b6cd ("workqueue: Fix spurious sanity check failures in 
> destroy_workqueue()")

This change triggered another collateral evolution finally.
Would you like to detect similarly questionable function calls
by advanced source code analysis?


> Fixes: 8efe1223d73c ("workqueue: Fix missing kfree(rescuer) in 
> destroy_workqueue()")

Please delete this tag from the change description
(because I find that it is not so relevant here.)


>  v1->v2->v3->v4:
>  Modify wrong submission information.

Will it be nicer to mention the adjustment of the commit message?

Regards,
Markus


Re: [PATCH] clk: versatile: remove redundant assignment to pointer clk

2020-05-26 Thread Stephen Boyd
Quoting Colin King (2020-05-26 15:41:16)
> From: Colin Ian King 
> 
> The pointer clk is being initialized with a value that is never read
> and is being updated with a new value later on. The initialization
> is redundant and can be removed.
> 
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King 
> ---

Applied to clk-next


[PATCH v2 0/3] Buggy bootloader workaround v2

2020-05-26 Thread Jiaxun Yang
v2: Fixed typo due to keyboard failure.

Jiaxun Yang (3):
  MIPS: head.S: Always jump to kernel_entry at head of text
  MIPS: Move kernel head into a standalone section
  MIPS: Loongson64: select NO_EXCEPT_FILL

 arch/mips/Kconfig  | 1 +
 arch/mips/kernel/head.S| 6 ++
 arch/mips/kernel/vmlinux.lds.S | 8 ++--
 3 files changed, 9 insertions(+), 6 deletions(-)

-- 
2.27.0.rc0



[PATCH v2 3/3] MIPS: Loongson64: select NO_EXCEPT_FILL

2020-05-26 Thread Jiaxun Yang
Loongson64 load kernel at 0x8200 and allocate exception vectors
by ebase. So we don't need to reserve space for exception vectors
at head of kernel.

Signed-off-by: Jiaxun Yang 
---
 arch/mips/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 3ca59b610a67..0e385f7b7691 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -462,6 +462,7 @@ config MACH_LOONGSON64
select IRQ_MIPS_CPU
select NR_CPUS_DEFAULT_64
select USE_GENERIC_EARLY_PRINTK_8250
+   select NO_EXCEPT_FILL
select SYS_HAS_CPU_LOONGSON64
select SYS_HAS_EARLY_PRINTK
select SYS_SUPPORTS_SMP
-- 
2.27.0.rc0



[PATCH v2 2/3] MIPS: Move kernel head into a standalone section

2020-05-26 Thread Jiaxun Yang
That's what already done by Arm64 and other architectures.
That would allow us put more things like PE headers safely into
the header.

Signed-off-by: Jiaxun Yang 
---
 arch/mips/kernel/head.S| 4 ++--
 arch/mips/kernel/vmlinux.lds.S | 8 ++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
index c7c2795837e7..8081a905a71c 100644
--- a/arch/mips/kernel/head.S
+++ b/arch/mips/kernel/head.S
@@ -59,6 +59,8 @@
 #endif
.endm
 
+   __HEAD
+_head:
 #ifndef CONFIG_NO_EXCEPT_FILL
/*
 * Reserved space for exception handlers.
@@ -67,8 +69,6 @@
.fill   0x400
 #endif
 
-EXPORT(_stext)
-
/*
 * Give us a fighting chance of running if execution beings at the
 * kernel load address.  This is needed because this platform does
diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
index f185a85a27c1..b9ace667b82b 100644
--- a/arch/mips/kernel/vmlinux.lds.S
+++ b/arch/mips/kernel/vmlinux.lds.S
@@ -57,8 +57,12 @@ SECTIONS
 #endif
. = LINKER_LOAD_ADDRESS;
/* read-only */
-   _text = .;  /* Text and read-only data */
-   .text : {
+   .head.text : {
+   _text = .;
+   HEAD_TEXT
+   }
+   .text : {   /* Real text segment*/
+   _stext = .; /* Text and read-only data  */
TEXT_TEXT
SCHED_TEXT
CPUIDLE_TEXT
-- 
2.27.0.rc0



[PATCH v2 1/3] MIPS: head.S: Always jump to kernel_entry at head of text

2020-05-26 Thread Jiaxun Yang
Buggy loaders like early version of PMON2000 sometimes ignore
elf_entry and goto start of text directly.

That would help with dealing with these loaders.

Signed-off-by: Jiaxun Yang 
---
 arch/mips/kernel/head.S | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
index 3b02ffe46304..c7c2795837e7 100644
--- a/arch/mips/kernel/head.S
+++ b/arch/mips/kernel/head.S
@@ -69,7 +69,6 @@
 
 EXPORT(_stext)
 
-#ifdef CONFIG_BOOT_RAW
/*
 * Give us a fighting chance of running if execution beings at the
 * kernel load address.  This is needed because this platform does
@@ -77,7 +76,6 @@ EXPORT(_stext)
 */
 FEXPORT(__kernel_entry)
j   kernel_entry
-#endif /* CONFIG_BOOT_RAW */
 
__REF
 
-- 
2.27.0.rc0



Re: [RFC PATCH v4 01/13] ptrace: Use regset_size() for dynamic regset size.

2020-05-26 Thread Greentime Hu
Oleg Nesterov  於 2020年5月26日 週二 下午10:00寫道:
>
> On 05/26, Greentime Hu wrote:
> >
> > @@ -882,13 +882,18 @@ static int ptrace_regset(struct task_struct *task, 
> > int req, unsigned int type,
> >   const struct user_regset_view *view = task_user_regset_view(task);
> >   const struct user_regset *regset = find_regset(view, type);
> >   int regset_no;
> > + unsigned int size;
> >
> > - if (!regset || (kiov->iov_len % regset->size) != 0)
> > + if (!regset)
> >   return -EINVAL;
> >
> >   regset_no = regset - view->regsets;
> > - kiov->iov_len = min(kiov->iov_len,
> > - (__kernel_size_t) (regset->n * regset->size));
> > + size = regset_size(task, regset);
> > +
> > + if ((kiov->iov_len % size) != 0)
> > + return -EINVAL;
>
> Hmm. this doesn't look right.
>
> Before this patch we check "iov_len % regset->size", this is not the same
> as "iov_len % regset_size()".
>
> IOW, currently you can read/write, say, only the 1st register, you patch
> breaks this?
>

Hi Oleg,

Thank you. I misunderstood the meaning of regset->size
It seems I only needs to update this line, right?
- kiov->iov_len = min(kiov->iov_len,  (__kernel_size_t) (regset->n *
regset->size));
+ kiov->iov_len = min(kiov->iov_len,  (__kernel_size_t)
regset_size(task, regset));


Re: KMSAN: uninit-value in bpf_skb_load_helper_32

2020-05-26 Thread syzbot
syzbot has found a reproducer for the following crash on:

HEAD commit:94bc4cd0 net: bpf: kmsan: disable CONFIG_BPF_JIT under KMSAN
git tree:   https://github.com/google/kmsan.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=149b3d4a10
kernel config:  https://syzkaller.appspot.com/x/.config?x=86e4f8af239686c6
dashboard link: https://syzkaller.appspot.com/bug?extid=ae94def68efda6a4be52
compiler:   clang version 10.0.0 (https://github.com/llvm/llvm-project/ 
c2443155a0fb245c8f17f2c1c72b6ea391e86e81)
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=12fc37aa10
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=14fce3a110

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+ae94def68efda6a4b...@syzkaller.appspotmail.com

=
BUG: KMSAN: uninit-value in bpf_skb_load_helper_32 net/core/filter.c:238 
[inline]
BUG: KMSAN: uninit-value in bpf_skb_load_helper_32+0xee/0x2d0 
net/core/filter.c:232
CPU: 1 PID: 8814 Comm: sshd Not tainted 5.7.0-rc4-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1c9/0x220 lib/dump_stack.c:118
 kmsan_report+0xf7/0x1e0 mm/kmsan/kmsan_report.c:121
 __msan_warning+0x58/0xa0 mm/kmsan/kmsan_instr.c:215
 bpf_skb_load_helper_32 net/core/filter.c:238 [inline]
 bpf_skb_load_helper_32+0xee/0x2d0 net/core/filter.c:232
 ___bpf_prog_run+0x214d/0x97a0 kernel/bpf/core.c:1516
 __bpf_prog_run32+0x101/0x170 kernel/bpf/core.c:1681
 bpf_dispatcher_nop_func include/linux/bpf.h:545 [inline]
 bpf_prog_run_pin_on_cpu include/linux/filter.h:599 [inline]
 bpf_prog_run_clear_cb include/linux/filter.h:721 [inline]
 run_filter net/packet/af_packet.c:2012 [inline]
 packet_rcv+0x70f/0x2160 net/packet/af_packet.c:2085
 deliver_skb net/core/dev.c:2168 [inline]
 dev_queue_xmit_nit+0x862/0x1270 net/core/dev.c:2238
 xmit_one net/core/dev.c:3473 [inline]
 dev_hard_start_xmit+0x20f/0xab0 net/core/dev.c:3493
 sch_direct_xmit+0x512/0x18b0 net/sched/sch_generic.c:314
 qdisc_restart net/sched/sch_generic.c:377 [inline]
 __qdisc_run+0x15ec/0x3350 net/sched/sch_generic.c:385
 qdisc_run include/net/pkt_sched.h:134 [inline]
 __dev_xmit_skb net/core/dev.c:3668 [inline]
 __dev_queue_xmit+0x23b7/0x3b20 net/core/dev.c:4021
 dev_queue_xmit+0x4b/0x60 net/core/dev.c:4085
 neigh_hh_output include/net/neighbour.h:499 [inline]
 neigh_output include/net/neighbour.h:508 [inline]
 ip_finish_output2+0x20fd/0x2610 net/ipv4/ip_output.c:228
 __ip_finish_output+0xaa7/0xd80 net/ipv4/ip_output.c:306
 ip_finish_output+0x166/0x410 net/ipv4/ip_output.c:316
 NF_HOOK_COND include/linux/netfilter.h:296 [inline]
 ip_output+0x593/0x680 net/ipv4/ip_output.c:430
 dst_output include/net/dst.h:435 [inline]
 ip_local_out net/ipv4/ip_output.c:125 [inline]
 __ip_queue_xmit+0x1b5c/0x21a0 net/ipv4/ip_output.c:530
 ip_queue_xmit+0xcc/0xf0 include/net/ip.h:237
 __tcp_transmit_skb+0x4221/0x6090 net/ipv4/tcp_output.c:1238
 tcp_transmit_skb net/ipv4/tcp_output.c:1254 [inline]
 tcp_write_xmit+0x30e1/0xb470 net/ipv4/tcp_output.c:2517
 __tcp_push_pending_frames+0x124/0x4e0 net/ipv4/tcp_output.c:2693
 tcp_push+0x6fa/0x8a0 net/ipv4/tcp.c:725
 tcp_sendmsg_locked+0x5d89/0x6d00 net/ipv4/tcp.c:1403
 tcp_sendmsg+0xb2/0x100 net/ipv4/tcp.c:1433
 inet_sendmsg+0x178/0x2e0 net/ipv4/af_inet.c:807
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg net/socket.c:672 [inline]
 sock_write_iter+0x606/0x6d0 net/socket.c:1004
 call_write_iter include/linux/fs.h:1907 [inline]
 new_sync_write fs/read_write.c:484 [inline]
 __vfs_write+0xa5a/0xca0 fs/read_write.c:497
 vfs_write+0x444/0x8e0 fs/read_write.c:559
 ksys_write+0x267/0x450 fs/read_write.c:612
 __do_sys_write fs/read_write.c:624 [inline]
 __se_sys_write+0x92/0xb0 fs/read_write.c:621
 __x64_sys_write+0x4a/0x70 fs/read_write.c:621
 do_syscall_64+0xb8/0x160 arch/x86/entry/common.c:297
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7f155876b970
Code: 73 01 c3 48 8b 0d 28 d5 2b 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 
00 00 83 3d 99 2d 2c 00 00 75 10 b8 01 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 31 
c3 48 83 ec 08 e8 7e 9b 01 00 48 89 04 24
RSP: 002b:7ffc12f70e38 EFLAGS: 0246 ORIG_RAX: 0001
RAX: ffda RBX: 0034 RCX: 7f155876b970
RDX: 0034 RSI: 55fc293bc0a4 RDI: 0003
RBP: 55fc293ad0b0 R08: 7ffc12fb4080 R09: 0070
R10: 006f R11: 0246 R12: 0001
R13: 7ffc12f70ecf R14: 55fc27f2fbe7 R15: 0003

Uninit was stored to memory at:
 kmsan_save_stack_with_flags mm/kmsan/kmsan.c:144 [inline]
 kmsan_internal_chain_origin+0xad/0x130 mm/kmsan/kmsan.c:310
 __msan_chain_origin+0x50/0x90 mm/kmsan/kmsan_instr.c:165
 ___bpf_prog_run+0x6c80/0x97a0 kernel/bpf/core.c:1391
 __bpf_prog_run32+0x101/0x170 kernel/bpf/core.c:1681
 

Re: [PATCH v6 3/5] remoteproc: qcom: Update PIL relocation info on load

2020-05-26 Thread Stephen Boyd
Quoting Bjorn Andersson (2020-05-26 22:48:47)
> Update the PIL relocation information in IMEM with information about
> where the firmware for various remoteprocs are loaded.
> 
> Reviewed-by: Vinod Koul 
> Signed-off-by: Bjorn Andersson 
> ---

Reviewed-by: Stephen Boyd 


Re: [PATCH v2 1/2] perf evlist: Ensure grouped events with same cpu map

2020-05-26 Thread Jin, Yao

Hi Jiri,

On 5/27/2020 11:20 AM, Jin, Yao wrote:

Hi Jiri,

On 5/26/2020 7:51 PM, Jiri Olsa wrote:

On Mon, May 25, 2020 at 02:55:58PM +0800, Jin Yao wrote:

SNIP


diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 2a9de6491700..1161cffc0688 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1704,3 +1704,52 @@ struct evsel *perf_evlist__reset_weak_group(struct 
evlist *evsel_list,
  }
  return leader;
  }
+
+static bool cpus_map_matched(struct evsel *prev, struct evsel *evsel)
+{
+    if (evsel->core.cpus->nr != prev->core.cpus->nr)
+    return false;
+
+    for (int i = 0; i < evsel->core.cpus->nr; i++) {
+    if (evsel->core.cpus->map[i] != prev->core.cpus->map[i])
+    return false;
+    }
+
+    return true;
+}
+
+bool evlist__cpus_map_matched(struct evlist *evlist)
+{
+    struct evsel *prev = evlist__first(evlist), *evsel = prev;
+    int nr_members = prev->core.nr_members;
+
+    evlist__for_each_entry_continue(evlist, evsel) {
+    if (nr_members <= 1) {
+    prev = evsel;
+    nr_members = evsel->core.nr_members;
+    continue;
+    }
+
+    nr_members--;
+
+    if (!cpus_map_matched(prev, evsel))
+    return false;
+
+    prev = evsel;
+    }
+
+    return true;
+}
+
+void evlist__force_disable_group(struct evlist *evlist)
+{
+    struct evsel *evsel;
+
+    pr_warning("WARNING: event cpu maps are not fully matched, "
+   "stop event grouping\n");
+
+    evlist__for_each_entry(evlist, evsel) {
+    evsel->leader = evsel;
+    evsel->core.nr_members = 0;
+    }
+}


I think this is too much, we need to disable only groups with not
matching cpus, not all of them, how about something like this



Yes, that's too much.



 struct evsel *pos;

 evlist__for_each_entry(evlist, evsel) {
 if (evsel->leader == evsel)
 continue;
 if (!cpus_map_matched(evsel->leader, evsel))
 continue;
 pr_warn("Disabling group...

 for_each_group_member(pos, evsel->leader) {
 pos->leader = pos;
 evsel->core.nr_members = 0;
 }
 }

jirka



Hmm, change "!cpus_map_matched()" to "cpus_map_matched()"? and use for_each_group_evsel() to replace 
for_each_group_member()?


How about something like following?

void evlist__check_cpu_maps(struct evlist *evlist)
{
 struct evsel *evsel, *pos;

 evlist__for_each_entry(evlist, evsel) {
     if (evsel->leader == evsel)
     continue;

     if (cpu_maps_matched(evsel->leader, evsel))
     continue;

     pr_warning("WARNING: event cpu maps are not fully matched, "
    "disable group\n");

     for_each_group_evsel(pos, evsel->leader) {
     pos->leader = pos;
     pos->core.nr_members = 0;
     }

     /*
  * For core & uncore mixed event group, for example,
  * '{cycles,unc_cbo_cache_lookup.any_i}',
  * In evlist:
  * cycles,
  * unc_cbo_cache_lookup.any_i,
  * unc_cbo_cache_lookup.any_i,
  * unc_cbo_cache_lookup.any_i,
  * unc_cbo_cache_lookup.any_i,
  *
  * cycles is leader and all unc_cbo_cache_lookup.any_i
  * point to this leader. But for_each_group_evsel can't
  * iterate all members from cycles. It only iterates
  * cycles and one unc_cbo_cache_lookup.any_i. So we
  * set extra evsel here.
  */
     evsel->leader = evsel;
     evsel->core.nr_members = 0;
 }
}

Thanks
Jin Yao


Issue is found!

It looks we can't set "pos->leader = pos" in either for_each_group_member() or in 
for_each_group_evsel() because it may exit the iteration immediately.


evlist__for_each_entry(evlist, evsel) {
if (evsel->leader == evsel)
continue;

if (cpu_maps_matched(evsel->leader, evsel))
continue;

pr_warning("WARNING: event cpu maps are not fully matched, "
   "disable group\n");

for_each_group_member(pos, evsel->leader) {
pos->leader = pos;
pos->core.nr_members = 0;
}

Let me use the example of '{cycles,unc_cbo_cache_lookup.any_i}' again.

In evlist:
cycles,
unc_cbo_cache_lookup.any_i,
unc_cbo_cache_lookup.any_i,
unc_cbo_cache_lookup.any_i,
unc_cbo_cache_lookup.any_i,

When we reach the for_each_group_member at first time, evsel is the first unc_cbo_cache_lookup.any_i 
and evsel->leader is cycles. pos is same as the evsel (the first unc_cbo_cache_lookup.any_i).


Once we execute "pos->leader = pos;", it's actually "evsel->leader = evsel". So now evsel->leader is 
changed to the first unc_cbo_cache_lookup.any_i.


In next iteration, pos is the second unc_cbo_cache

Re: [PATCH v6 2/5] remoteproc: qcom: Introduce helper to store pil info in IMEM

2020-05-26 Thread Stephen Boyd
Quoting Bjorn Andersson (2020-05-26 22:48:46)
> diff --git a/drivers/remoteproc/qcom_pil_info.c 
> b/drivers/remoteproc/qcom_pil_info.c
> new file mode 100644
> index ..0785c7cde2d3
> --- /dev/null
> +++ b/drivers/remoteproc/qcom_pil_info.c
> @@ -0,0 +1,124 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (c) 2019-2020 Linaro Ltd.
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define PIL_RELOC_NAME_LEN 8
> +
> +struct pil_reloc_entry {
> +   char name[PIL_RELOC_NAME_LEN];
> +   __le64 base;
> +   __le32 size;
> +} __packed;
> +
> +struct pil_reloc {
> +   struct device *dev;

This isn't assigned. Remove it?

> +   void __iomem *base;
> +   size_t num_entries;
> +};
> +
> +static struct pil_reloc _reloc __read_mostly;
> +static DEFINE_MUTEX(reloc_mutex);

reloc_mutex is a little generic. Maybe pil_reloc_lock or
qcom_pil_reloc_lock?

> +
> +static int qcom_pil_info_init(void)
> +{
> +   struct device_node *np;
> +   struct resource imem;
> +   void __iomem *base;
> +   int ret;
> +
> +   /* Already initialized? */
> +   if (_reloc.base)
> +   return 0;
> +
> +   np = of_find_compatible_node(NULL, NULL, "qcom,pil-reloc-info");
> +   if (!np)
> +   return -ENOENT;
> +
> +   ret = of_address_to_resource(np, 0, &imem);
> +   of_node_put(np);
> +   if (ret < 0)
> +   return ret;
> +
> +   base = ioremap(imem.start, resource_size(&imem));
> +   if (!base) {
> +   pr_err("failed to map PIL relocation info region\n");
> +   return -ENOMEM;
> +   }
> +
> +   memset_io(base, 0, resource_size(&imem));
> +
> +   _reloc.base = base;
> +   _reloc.num_entries = resource_size(&imem) / sizeof(struct 
> pil_reloc_entry);
> +
> +   return 0;
> +}
> +
> +/**
> + * qcom_pil_info_store() - store PIL information of image in IMEM
> + * @image: name of the image
> + * @base:  base address of the loaded image
> + * @size:  size of the loaded image
> + *
> + * Return: 0 on success, negative errno on failure
> + */
> +int qcom_pil_info_store(const char *image, phys_addr_t base, size_t size)
> +{
> +   char buf[PIL_RELOC_NAME_LEN];
> +   void __iomem *entry;
> +   int ret;
> +   int i;
> +
> +   mutex_lock(&reloc_mutex);
> +   ret = qcom_pil_info_init();
> +   if (ret < 0) {
> +   mutex_unlock(&reloc_mutex);
> +   return ret;
> +   }
> +
> +   for (i = 0; i < _reloc.num_entries; i++) {
> +   entry = _reloc.base + i * sizeof(struct pil_reloc_entry);
> +
> +   memcpy_fromio(buf, entry, PIL_RELOC_NAME_LEN);
> +
> +   /*
> +* An empty record means we didn't find it, given that the
> +* records are packed.
> +*/
> +   if (!buf[0])
> +   goto found_unused;
> +
> +   if (!strncmp(buf, image, PIL_RELOC_NAME_LEN))
> +   goto found_existing;
> +   }
> +
> +   pr_warn("insufficient PIL info slots\n");
> +   mutex_unlock(&reloc_mutex);
> +   return -ENOMEM;
> +
> +found_unused:
> +   memcpy_toio(entry, image, PIL_RELOC_NAME_LEN);
> +found_existing:
> +   writel(base, entry + offsetof(struct pil_reloc_entry, base));
> +   writel(size, entry + offsetof(struct pil_reloc_entry, size));

It makes me nervous to see offsetof() used in the same line as writel()
because who knows what the compiler does, even with __packed and stuff.
I guess I tried and failed to convince you earlier to change this code
to use fixed offsets instead of structs to describe the memory layout
but that must have failed!

> +   mutex_unlock(&reloc_mutex);
> +
> +   return 0;
> +}
> +EXPORT_SYMBOL_GPL(qcom_pil_info_store);
> +
> +static void __exit pil_reloc_exit(void)
> +{
> +   mutex_lock(&reloc_mutex);
> +   iounmap(_reloc.base);
> +   _reloc.base = NULL;
> +   mutex_unlock(&reloc_mutex);
> +}
> +module_exit(pil_reloc_exit);
> +
> +MODULE_DESCRIPTION("Qualcomm PIL relocation info");
> +MODULE_LICENSE("GPL v2");
> diff --git a/drivers/remoteproc/qcom_pil_info.h 
> b/drivers/remoteproc/qcom_pil_info.h
> new file mode 100644
> index ..1b89a63ba82f
> --- /dev/null
> +++ b/drivers/remoteproc/qcom_pil_info.h
> @@ -0,0 +1,7 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef __QCOM_PIL_INFO_H__
> +#define __QCOM_PIL_INFO_H__

Probably need  here for phys_addr_t definition to make
this header self-contained.

> +
> +int qcom_pil_info_store(const char *image, phys_addr_t base, size_t size);
> +
> +#endif


[PATCH V7 1/3] dt-bindings: geni-se: Convert QUP geni-se bindings to YAML

2020-05-26 Thread Akash Asthana
Convert QUP geni-se bindings to DT schema format using json-schema.

Signed-off-by: Akash Asthana 
Reviewed-by: Rob Herring 
Reviewed-by: Stephen Boyd 
---
Changes in V2:
 - As per Stephen's comment corrected defintion of interrupts for UART node.
   Any valid UART node must contain atleast 1 interrupts.

Changes in V3:
 - As per Rob's comment, added number of reg entries for reg property.
 - As per Rob's comment, corrected unit address to hex.
 - As per Rob's comment, created a pattern which matches everything common
   to geni based I2C, SPI and UART controller and then one pattern  for each.
 - As per Rob's comment, restored original example.

Changes in V4:
 - Resolve below compilation error reported from bot.

/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/soc/qcom/
qcom,geni-se.yaml: properties:clocks:minItems: False schema does not allow 2
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/soc/qcom/
qcom,geni-se.yaml: properties:clocks:maxItems: False schema does not allow 2
Documentation/devicetree/bindings/Makefile:12: recipe for target
'Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.example.dts' failed
make[1]: *** [Documentation/devicetree/bindings/soc/qcom/
qcom,geni-se.example.dts] Error 1
Makefile:1263: recipe for target 'dt_binding_check' failed
make: *** [dt_binding_check] Error 2

Changes in V6:
 - Added reg entry for soc@0 example node to address below warning.

Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.example.dts:22.20-60.11
: Warning (unit_address_vs_reg): /example-0/soc@0: node has a unit name,
but no reg or ranges property

Changes in V7:
 - No change.

 .../devicetree/bindings/soc/qcom/qcom,geni-se.txt  |  94 -
 .../devicetree/bindings/soc/qcom/qcom,geni-se.yaml | 210 +
 2 files changed, 210 insertions(+), 94 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.txt
 create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.yaml

diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.txt 
b/Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.txt
deleted file mode 100644
index dab7ca9..000
--- a/Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.txt
+++ /dev/null
@@ -1,94 +0,0 @@
-Qualcomm Technologies, Inc. GENI Serial Engine QUP Wrapper Controller
-
-Generic Interface (GENI) based Qualcomm Universal Peripheral (QUP) wrapper
-is a programmable module for supporting a wide range of serial interfaces
-like UART, SPI, I2C, I3C, etc. A single QUP module can provide upto 8 Serial
-Interfaces, using its internal Serial Engines. The GENI Serial Engine QUP
-Wrapper controller is modeled as a node with zero or more child nodes each
-representing a serial engine.
-
-Required properties:
-- compatible:  Must be "qcom,geni-se-qup".
-- reg: Must contain QUP register address and length.
-- clock-names: Must contain "m-ahb" and "s-ahb".
-- clocks:  AHB clocks needed by the device.
-
-Required properties if child node exists:
-- #address-cells:  Must be <1> for Serial Engine Address
-- #size-cells: Must be <1> for Serial Engine Address Size
-- ranges:  Must be present
-
-Properties for children:
-
-A GENI based QUP wrapper controller node can contain 0 or more child nodes
-representing serial devices.  These serial devices can be a QCOM UART, I2C
-controller, SPI controller, or some combination of aforementioned devices.
-Please refer below the child node definitions for the supported serial
-interface protocols.
-
-Qualcomm Technologies Inc. GENI Serial Engine based I2C Controller
-
-Required properties:
-- compatible:  Must be "qcom,geni-i2c".
-- reg: Must contain QUP register address and length.
-- interrupts:  Must contain I2C interrupt.
-- clock-names: Must contain "se".
-- clocks:  Serial engine core clock needed by the device.
-- #address-cells:  Must be <1> for I2C device address.
-- #size-cells: Must be <0> as I2C addresses have no size component.
-
-Optional property:
-- clock-frequency: Desired I2C bus clock frequency in Hz.
-   When missing default to 10Hz.
-
-Child nodes should conform to I2C bus binding as described in i2c.txt.
-
-Qualcomm Technologies Inc. GENI Serial Engine based UART Controller
-
-Required properties:
-- compatible:  Must be "qcom,geni-debug-uart" or "qcom,geni-uart".
-- reg: Must contain UART register location and length.
-- interrupts:  Must contain UART core interrupts.
-- clock-names: Must contain "se".
-- clocks:  Serial engine core clock needed by the device.
-
-Qualcomm Technologies Inc. GENI Serial Engine based SPI Controller
-node binding is described in
-Documentation/devicetree/bindings/spi/qcom,spi-geni-qcom.txt.
-
-Example:
-   geniqup@8c

[PATCH V7 3/3] dt-bindings: serial: Add binding for UART pin swap

2020-05-26 Thread Akash Asthana
Add documentation to support RX-TX & CTS-RTS GPIO pin swap in HW.

Signed-off-by: Akash Asthana 
Reviewed-by: Stephen Boyd 
---
Changes in V7:
 - As per Rob's comment, added type: boolean to properties.

 Documentation/devicetree/bindings/serial/serial.yaml | 8 
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/serial/serial.yaml 
b/Documentation/devicetree/bindings/serial/serial.yaml
index 53204d9..8645d0e 100644
--- a/Documentation/devicetree/bindings/serial/serial.yaml
+++ b/Documentation/devicetree/bindings/serial/serial.yaml
@@ -67,6 +67,14 @@ properties:
   (wired and enabled by pinmux configuration).  This depends on both the
   UART hardware and the board wiring.
 
+  rx-tx-swap:
+type: boolean
+description: RX and TX pins are swapped.
+
+  cts-rts-swap:
+type: boolean
+description: CTS and RTS pins are swapped.
+
 if:
   required:
 - uart-has-rtscts
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,\na 
Linux Foundation Collaborative Project



Re: [PATCH v1 2/2] Add PWM driver for LGM

2020-05-26 Thread Tanwar, Rahul


Hi Uwe,

Thanks for review.

On 22/5/2020 4:56 pm, Uwe Kleine-König wrote:
> Hello,
>
> On Fri, May 22, 2020 at 03:41:59PM +0800, Rahul Tanwar wrote:
>> Add PWM controller driver for Intel's Lightning Mountain(LGM) SoC.
>>
>> Signed-off-by: Rahul Tanwar 
>> ---
>>  drivers/pwm/Kconfig |   9 ++
>>  drivers/pwm/Makefile|   1 +
>>  drivers/pwm/pwm-intel-lgm.c | 356 
>> 
>>  3 files changed, 366 insertions(+)
>>  create mode 100644 drivers/pwm/pwm-intel-lgm.c
>>
>> diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
>> index eebbc917ac97..a582214f50b2 100644
>> --- a/drivers/pwm/Kconfig
>> +++ b/drivers/pwm/Kconfig
>> @@ -232,6 +232,15 @@ config PWM_IMX_TPM
>>To compile this driver as a module, choose M here: the module
>>will be called pwm-imx-tpm.
>>  
>> +config PWM_INTEL_LGM
>> +tristate "Intel LGM PWM support"
>> +depends on X86 || COMPILE_TEST
>> +help
>> +  Generic PWM framework driver for LGM SoC.
[...]
>> +};
>> +
>> +static void tach_work(struct work_struct *work)
>> +{
>> +struct intel_pwm_chip *pc = container_of(work, struct intel_pwm_chip,
>> + work.work);
>> +struct regmap *regmap = pc->regmap;
>> +u32 fan_tach, fan_dc, val;
>> +s32 diff;
>> +static u32 fanspeed_err_cnt, time_window, delta_dc;
>> +
>> +/*
>> + * Fan speed is tracked by reading the active duty cycle of PWM output
>> + * from the active duty cycle register. Some variance in the duty cycle
>> + * register value is expected. So we set a time window of 30 seconds and
>> + * if we detect inaccurate fan speed 6 times within 30 seconds then we
>> + * mark it as fan speed problem and fix it by readjusting the duty 
>> cycle.
>> + */
> I'm a unhappy to have this in the PWM driver. The PWM driver is supposed
> to be generic and I think this belongs into a dedicated driver.

Well noted about all other review concerns. I will rework the driver in v2.
However, i am not very sure about the above point - of having a separate
dedicated driver for tach_work because its logic is tightly coupled with
this driver.

Regards,
Rahul


[PATCH V7 2/3] dt-bindings: geni-se: Add interconnect binding for GENI QUP

2020-05-26 Thread Akash Asthana
Add documentation for the interconnect and interconnect-names properties
for the GENI QUP.

Signed-off-by: Akash Asthana 
Reviewed-by: Stephen Boyd 
---
Changes in V5:
 - Add interconnect property for QUP wrapper (parent node).
 - Add minItems = 2 for interconnect property in child nodes

Changes in V6:
 - As per Rob's comment added minItems = 2 for interconnect-names.

Changes in V7:
 - No change.

 .../devicetree/bindings/soc/qcom/qcom,geni-se.yaml  | 17 +
 1 file changed, 17 insertions(+)

diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.yaml 
b/Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.yaml
index 885966f..b19505b 100644
--- a/Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.yaml
+++ b/Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.yaml
@@ -46,6 +46,12 @@ properties:
 
   ranges: true
 
+  interconnects:
+maxItems: 1
+
+  interconnect-names:
+const: qup-core
+
 required:
   - compatible
   - reg
@@ -73,6 +79,17 @@ patternProperties:
 description: Serial engine core clock needed by the device.
 maxItems: 1
 
+  interconnects:
+ minItems: 2
+ maxItems: 3
+
+  interconnect-names:
+ minItems: 2
+ items:
+   - const: qup-core
+   - const: qup-config
+   - const: qup-memory
+
 required:
   - reg
   - clock-names
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,\na 
Linux Foundation Collaborative Project



[PATCH V7 0/3] Convert QUP bindings to YAML and add ICC, pin swap doc

2020-05-26 Thread Akash Asthana
Changes in V6:
 - As per Rob's suggestion moved pin swap documentation from QUP to
   serial.yaml file[PATCH V6 3/3].

Changes in V4:
 - Add interconnect binding patch.
 - Add UART pin swap binding patch.

Akash Asthana (3):
  dt-bindings: geni-se: Convert QUP geni-se bindings to YAML
  dt-bindings: geni-se: Add interconnect binding for GENI QUP
  dt-bindings: serial: Add binding for UART pin swap

 .../devicetree/bindings/serial/serial.yaml |   6 +
 .../devicetree/bindings/soc/qcom/qcom,geni-se.txt  |  94 -
 .../devicetree/bindings/soc/qcom/qcom,geni-se.yaml | 227 +
 3 files changed, 233 insertions(+), 94 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.txt
 create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.yaml

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



Re: [PATCH] power: reset: vexpress: fix build issue

2020-05-26 Thread Anders Roxell
On Tue, 26 May 2020 at 17:41, Rob Herring  wrote:
>
> " On Mon, May 25, 2020 at 11:38 PM Nathan Chancellor
>  wrote:
> >
> > On Mon, May 25, 2020 at 07:37:45PM -0400, Valdis Klētnieks wrote:
> > > On Sun, 24 May 2020 15:20:25 -0700, Nathan Chancellor said:
> > >
> > > > arm-linux-gnueabi-ld: drivers/power/reset/vexpress-poweroff.o: in 
> > > > function `vexpress_reset_probe':
> > > > vexpress-poweroff.c:(.text+0x36c): undefined reference to 
> > > > `devm_regmap_init_vexpress_config'
> > >
> > > The part I can't figure out is that git blame tells me there's already an
> > > export:
> > >
> > > 3b9334ac835bb (Pawel Moll  2014-04-30 16:46:29 +0100 154)   return 
> > > regmap;
> > > 3b9334ac835bb (Pawel Moll  2014-04-30 16:46:29 +0100 155) }
> > > b33cdd283bd91 (Arnd Bergmann   2014-05-26 17:25:22 +0200 156) 
> > > EXPORT_SYMBOL_GPL(devm_regmap_init_vexpress_config);
> > > 3b9334ac835bb (Pawel Moll  2014-04-30 16:46:29 +0100 157)
> > >
> > > but I can't figure out where or if 
> > > drivers/power/reset/vexpress-poweroff.c gets
> > > a MODULE_LICENSE from...
> >
> > Correct, it is exported but that file is being built as a module whereas
> > the file requiring it is beign builtin. As far as I understand, that
> > will not work, hence the error.
> >
> > The issue with this patch is that ARCH_VEXPRESS still just selects
> > POWER_RESET_VEXPRESS, which ignores "depends on", hence the Kconfig
> > warning and not fixing the error.
> >
> > I am not that much of a Kconfig guru to come up with a solution. I am
> > just reporting it because arm allmodconfig is broken on -next due to
> > this.
>
> Commit "ARM: vexpress: Don't select VEXPRESS_CONFIG" needs to be
> reverted. I've asked Arnd to revert it.

Reverting that patch with my patch will make allmodconfig work for arm too.

>
> Anders patch is still needed for arm64.

Yes, it is still needed for arm64.

Cheers,
Anders


Re: [PATCH v2 0/4] x86/boot: Remove runtime relocations from compressed kernel

2020-05-26 Thread Sedat Dilek
On Tue, May 26, 2020 at 5:36 PM Arvind Sankar  wrote:
>
> On Tue, May 26, 2020 at 04:50:38PM +0200, Sedat Dilek wrote:
> > On Tue, May 26, 2020 at 4:47 PM Arvind Sankar  wrote:
> > >
> > > On Tue, May 26, 2020 at 02:44:29PM +0200, Sedat Dilek wrote:
> > > >
> > > > Are those diffs correct when using "x86/boot: Correct relocation
> > > > destination on old linkers"?
> > > >
> > >
> > > It looks ok, but that patch (and even marking the other symbols .hidden)
> > > should be unnecessary after this series.
> >
> > You mean _bss, _ebss and _end?
> >
> > - Sedat -
>
> Yes. Those .hidden markings are there to ensure that when relocations
> are generated (as they are currently), they're generated as
> R_386_RELATIVE (which uses B+A calculation, with A being the link-time
> virtual address of the symbol, and stored in the relocation field)
> rather than R_386_32 (which uses S+A calculation, and so doesn't work
> without runtime processing). After this patchset there aren't any
> relocations, so while the .hidden markings won't hurt, they won't be
> necessary either.
>

Do you plan a change on this?

- Sedat -


[PATCH v3 4/4] kdb: Switch kdb_msg_write() to use safer polling I/O

2020-05-26 Thread Sumit Garg
In kgdb NMI context, calling console handlers isn't safe due to locks
used in those handlers which could lead to a deadlock. Although, using
oops_in_progress increases the chance to bypass locks in most console
handlers but it might not be sufficient enough in case a console uses
more locks (VT/TTY is good example).

Currently when a driver provides both polling I/O and a console then kdb
will output using the console. We can increase robustness by using the
currently active polling I/O driver (which should be lockless) instead
of the corresponding console. For several common cases (e.g. an
embedded system with a single serial port that is used both for console
output and debugger I/O) this will result in no console handler being
used.

Suggested-by: Daniel Thompson 
Signed-off-by: Sumit Garg 
---
 drivers/tty/serial/kgdboc.c | 17 -
 include/linux/kgdb.h|  2 ++
 kernel/debug/kdb/kdb_io.c   | 46 +++--
 3 files changed, 42 insertions(+), 23 deletions(-)

diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
index c9f94fa..6199fe1 100644
--- a/drivers/tty/serial/kgdboc.c
+++ b/drivers/tty/serial/kgdboc.c
@@ -35,7 +35,6 @@ static struct kparam_string kps = {
 };
 
 static int kgdboc_use_kms;  /* 1 if we use kernel mode switching */
-static struct tty_driver   *kgdb_tty_driver;
 static int kgdb_tty_line;
 
 #ifdef CONFIG_KDB_KEYBOARD
@@ -154,7 +153,7 @@ static int configure_kgdboc(void)
}
 
kgdboc_io_ops.is_console = 0;
-   kgdb_tty_driver = NULL;
+   kgdboc_io_ops.tty_drv = NULL;
 
kgdboc_use_kms = 0;
if (strncmp(cptr, "kms,", 4) == 0) {
@@ -178,7 +177,7 @@ static int configure_kgdboc(void)
}
}
 
-   kgdb_tty_driver = p;
+   kgdboc_io_ops.tty_drv = p;
kgdb_tty_line = tty_line;
 
 do_register:
@@ -216,18 +215,18 @@ static int __init init_kgdboc(void)
 
 static int kgdboc_get_char(void)
 {
-   if (!kgdb_tty_driver)
+   if (!kgdboc_io_ops.tty_drv)
return -1;
-   return kgdb_tty_driver->ops->poll_get_char(kgdb_tty_driver,
-   kgdb_tty_line);
+   return kgdboc_io_ops.tty_drv->ops->poll_get_char(kgdboc_io_ops.tty_drv,
+kgdb_tty_line);
 }
 
 static void kgdboc_put_char(u8 chr)
 {
-   if (!kgdb_tty_driver)
+   if (!kgdboc_io_ops.tty_drv)
return;
-   kgdb_tty_driver->ops->poll_put_char(kgdb_tty_driver,
-   kgdb_tty_line, chr);
+   kgdboc_io_ops.tty_drv->ops->poll_put_char(kgdboc_io_ops.tty_drv,
+ kgdb_tty_line, chr);
 }
 
 static int param_set_kgdboc_var(const char *kmessage,
diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
index b072aeb..05d165d 100644
--- a/include/linux/kgdb.h
+++ b/include/linux/kgdb.h
@@ -275,6 +275,7 @@ struct kgdb_arch {
  * for the I/O driver.
  * @is_console: 1 if the end device is a console 0 if the I/O device is
  * not a console
+ * @tty_drv: Pointer to polling tty driver.
  */
 struct kgdb_io {
const char  *name;
@@ -285,6 +286,7 @@ struct kgdb_io {
void(*pre_exception) (void);
void(*post_exception) (void);
int is_console;
+   struct tty_driver   *tty_drv;
 };
 
 extern const struct kgdb_arch  arch_kgdb_ops;
diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index f848482..c2efa52 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "kdb_private.h"
 
 #define CMD_BUFLEN 256
@@ -542,13 +543,18 @@ static int kdb_search_string(char *searched, char 
*searchfor)
return 0;
 }
 
-static void kdb_io_write(char *cp, int len, void (*io_put_char)(u8 ch))
+static void kdb_io_write(char *cp, int len, void (*io_put_char)(u8),
+struct tty_driver *p, int line,
+void (*poll_put_char)(struct tty_driver *, int, char))
 {
if (len <= 0)
return;
 
while (len--) {
-   io_put_char(*cp);
+   if (io_put_char)
+   io_put_char(*cp);
+   if (poll_put_char)
+   poll_put_char(p, line, *cp);
cp++;
}
 }
@@ -561,22 +567,34 @@ static void kdb_msg_write(char *msg, int msg_len)
return;
 
if (dbg_io_ops && !dbg_io_ops->is_console)
-   kdb_io_write(msg, msg_len, dbg_io_ops->write_char);
+   kdb_io_write(msg, msg_len, dbg_io_ops->write_char,
+NULL, 0, NULL);
 
for_each_console(c) {
+   int line;
+   struct tty_driver *p;
+
if (!(c->flags & CON_ENABLED))
   

Re: [PATCH v2] net: phy: at803x: add cable diagnostics support for ATH9331 and ATH8032

2020-05-26 Thread David Miller
From: Oleksij Rempel 
Date: Wed, 27 May 2020 07:08:43 +0200

> Add support for Atheros 100Base-T PHYs. The only difference seems to be
> the ability to test 2 pairs instead of 4 and the lack of 1000Base-T
> specific register.
> 
> Only the ATH9331 was tested with this patch.
> 
> Signed-off-by: Oleksij Rempel 
> Reviewed-by: Andrew Lunn 
> Reviewed-by: Florian Fainelli 

Applied to net-next, thank you.


[PATCH v3 1/4] kdb: Re-factor kdb_printf() message write code

2020-05-26 Thread Sumit Garg
Re-factor kdb_printf() message write code in order to avoid duplication
of code and thereby increase readability.

Signed-off-by: Sumit Garg 
---
 kernel/debug/kdb/kdb_io.c | 61 +--
 1 file changed, 32 insertions(+), 29 deletions(-)

diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index 924bc92..f6b4d47 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -542,6 +542,33 @@ static int kdb_search_string(char *searched, char 
*searchfor)
return 0;
 }
 
+static void kdb_io_write(char *cp, int len, void (*io_put_char)(u8 ch))
+{
+   if (len <= 0)
+   return;
+
+   while (len--) {
+   io_put_char(*cp);
+   cp++;
+   }
+}
+
+static void kdb_msg_write(char *msg, int msg_len)
+{
+   struct console *c;
+
+   if (msg_len <= 0)
+   return;
+
+   if (dbg_io_ops && !dbg_io_ops->is_console)
+   kdb_io_write(msg, msg_len, dbg_io_ops->write_char);
+
+   for_each_console(c) {
+   c->write(c, msg, msg_len);
+   touch_nmi_watchdog();
+   }
+}
+
 int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap)
 {
int diag;
@@ -553,7 +580,6 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, 
va_list ap)
int this_cpu, old_cpu;
char *cp, *cp2, *cphold = NULL, replaced_byte = ' ';
char *moreprompt = "more> ";
-   struct console *c;
unsigned long uninitialized_var(flags);
 
/* Serialize kdb_printf if multiple cpus try to write at once.
@@ -687,22 +713,11 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, 
va_list ap)
 */
retlen = strlen(kdb_buffer);
cp = (char *) printk_skip_headers(kdb_buffer);
-   if (!dbg_kdb_mode && kgdb_connected) {
+   if (!dbg_kdb_mode && kgdb_connected)
gdbstub_msg_write(cp, retlen - (cp - kdb_buffer));
-   } else {
-   if (dbg_io_ops && !dbg_io_ops->is_console) {
-   len = retlen - (cp - kdb_buffer);
-   cp2 = cp;
-   while (len--) {
-   dbg_io_ops->write_char(*cp2);
-   cp2++;
-   }
-   }
-   for_each_console(c) {
-   c->write(c, cp, retlen - (cp - kdb_buffer));
-   touch_nmi_watchdog();
-   }
-   }
+   else
+   kdb_msg_write(cp, retlen - (cp - kdb_buffer));
+
if (logging) {
saved_loglevel = console_loglevel;
console_loglevel = CONSOLE_LOGLEVEL_SILENT;
@@ -751,19 +766,7 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, 
va_list ap)
moreprompt = "more> ";
 
kdb_input_flush();
-
-   if (dbg_io_ops && !dbg_io_ops->is_console) {
-   len = strlen(moreprompt);
-   cp = moreprompt;
-   while (len--) {
-   dbg_io_ops->write_char(*cp);
-   cp++;
-   }
-   }
-   for_each_console(c) {
-   c->write(c, moreprompt, strlen(moreprompt));
-   touch_nmi_watchdog();
-   }
+   kdb_msg_write(moreprompt, strlen(moreprompt));
 
if (logging)
printk("%s", moreprompt);
-- 
2.7.4



[PATCH v3 0/4] kdb: Improve console handling

2020-05-26 Thread Sumit Garg
This patch-set is aimed to improve console handling especially when kdb
operates in NMI context.

Brief description of enhancements:
- Add status check for console prior to invoking corresponding handler.
- Fixup to avoid possible deadlock in NMI context due to usage of locks
  in the console handlers.
- Prefer usage of polling I/O driver mode (lockless APIs) over invocation
  of console handlers.

Changes in v3:
- Split patch to have separate patch for console status check.
- New patch to re-factor kdb message emit code.
- New patch to prefer polling I/O over console mode.
- Add code comments to describe usage of oops_in_progress.

Changes in v2:
- Use oops_in_progress directly instead of bust_spinlocks().

Sumit Garg (4):
  kdb: Re-factor kdb_printf() message write code
  kdb: Check status of console prior to invoking handlers
  kdb: Make kdb_printf robust to run in NMI context
  kdb: Switch kdb_msg_write() to use safer polling I/O

 drivers/tty/serial/kgdboc.c | 17 -
 include/linux/kgdb.h|  2 +
 kernel/debug/kdb/kdb_io.c   | 91 ++---
 3 files changed, 72 insertions(+), 38 deletions(-)

-- 
2.7.4



[PATCH v3 3/4] kdb: Make kdb_printf robust to run in NMI context

2020-05-26 Thread Sumit Garg
While rounding up CPUs via NMIs, its possible that a rounded up CPU
maybe holding a console port lock leading to kgdb master CPU stuck in
a deadlock during invocation of console write operations. So in order
to avoid such a deadlock, enable oops_in_progress prior to invocation
of console handlers.

Suggested-by: Petr Mladek 
Signed-off-by: Sumit Garg 
---
 kernel/debug/kdb/kdb_io.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index 349dfcc..f848482 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -566,7 +566,17 @@ static void kdb_msg_write(char *msg, int msg_len)
for_each_console(c) {
if (!(c->flags & CON_ENABLED))
continue;
+   /*
+* While rounding up CPUs via NMIs, its possible that
+* a rounded up CPU maybe holding a console port lock
+* leading to kgdb master CPU stuck in a deadlock during
+* invocation of console write operations. So in order
+* to avoid such a deadlock, enable oops_in_progress
+* prior to invocation of console handlers.
+*/
+   ++oops_in_progress;
c->write(c, msg, msg_len);
+   --oops_in_progress;
touch_nmi_watchdog();
}
 }
-- 
2.7.4



[PATCH v3 2/4] kdb: Check status of console prior to invoking handlers

2020-05-26 Thread Sumit Garg
Check if a console is enabled prior to invoking corresponding write
handler.

Suggested-by: Sergey Senozhatsky 
Signed-off-by: Sumit Garg 
---
 kernel/debug/kdb/kdb_io.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index f6b4d47..349dfcc 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -564,6 +564,8 @@ static void kdb_msg_write(char *msg, int msg_len)
kdb_io_write(msg, msg_len, dbg_io_ops->write_char);
 
for_each_console(c) {
+   if (!(c->flags & CON_ENABLED))
+   continue;
c->write(c, msg, msg_len);
touch_nmi_watchdog();
}
-- 
2.7.4



[PATCH] iommu/iova: Free global iova rcache on iova alloc failure

2020-05-26 Thread vjitta
From: Vijayanand Jitta 

When ever an iova alloc request fails we free the iova
ranges present in the percpu iova rcaches and then retry
but the global iova rcache is not freed as a result we
could still see iova alloc failure even after retry as
global rcache is still holding the iova's which can cause
fragmentation. So, free the global iova rcache as well
and then go for the retry.

Signed-off-by: Vijayanand Jitta 
---
 drivers/iommu/iova.c | 22 ++
 include/linux/iova.h |  6 ++
 2 files changed, 28 insertions(+)

diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
index 0e6a953..5ae0328 100644
--- a/drivers/iommu/iova.c
+++ b/drivers/iommu/iova.c
@@ -431,6 +431,7 @@ struct iova *find_iova(struct iova_domain *iovad, unsigned 
long pfn)
flush_rcache = false;
for_each_online_cpu(cpu)
free_cpu_cached_iovas(cpu, iovad);
+   free_global_cached_iovas(iovad);
goto retry;
}
 
@@ -1044,5 +1045,26 @@ void free_cpu_cached_iovas(unsigned int cpu, struct 
iova_domain *iovad)
}
 }
 
+/*
+ * free all the IOVA ranges of global cache
+ */
+void free_global_cached_iovas(struct iova_domain *iovad)
+{
+   struct iova_rcache *rcache;
+   int i, j;
+
+   for (i = 0; i < IOVA_RANGE_CACHE_MAX_SIZE; ++i) {
+   rcache = &iovad->rcaches[i];
+   spin_lock(&rcache->lock);
+   for (j = 0; j < rcache->depot_size; ++j) {
+   iova_magazine_free_pfns(rcache->depot[j], iovad);
+   iova_magazine_free(rcache->depot[j]);
+   rcache->depot[j] = NULL;
+   }
+   rcache->depot_size = 0;
+   spin_unlock(&rcache->lock);
+   }
+}
+
 MODULE_AUTHOR("Anil S Keshavamurthy ");
 MODULE_LICENSE("GPL");
diff --git a/include/linux/iova.h b/include/linux/iova.h
index a0637ab..a905726 100644
--- a/include/linux/iova.h
+++ b/include/linux/iova.h
@@ -163,6 +163,7 @@ int init_iova_flush_queue(struct iova_domain *iovad,
 struct iova *split_and_remove_iova(struct iova_domain *iovad,
struct iova *iova, unsigned long pfn_lo, unsigned long pfn_hi);
 void free_cpu_cached_iovas(unsigned int cpu, struct iova_domain *iovad);
+void free_global_cached_iovas(struct iova_domain *iovad);
 #else
 static inline int iova_cache_get(void)
 {
@@ -270,6 +271,11 @@ static inline void free_cpu_cached_iovas(unsigned int cpu,
 struct iova_domain *iovad)
 {
 }
+
+static inline void free_global_cached_iovas(struct iova_domain *iovad)
+{
+}
+
 #endif
 
 #endif
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation


[PATCH v2] clk: mediatek: assign the initial value to clk_init_data of mtk_mux

2020-05-26 Thread Weiyi Lu
When some new clock supports are introduced, e.g. [1]
it might lead to an error although it should be NULL because
clk_init_data is on the stack and it might have random values
if using without initialization.
Add the missing initial value to clk_init_data.

[1] https://android-review.googlesource.com/c/kernel/common/+/1278046

Fixes: a3ae549917f1 ("clk: mediatek: Add new clkmux register API")
Cc: 
Signed-off-by: Weiyi Lu 
Reviewed-by: Matthias Brugger 
---
 drivers/clk/mediatek/clk-mux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/mediatek/clk-mux.c b/drivers/clk/mediatek/clk-mux.c
index 76f9cd0..14e127e 100644
--- a/drivers/clk/mediatek/clk-mux.c
+++ b/drivers/clk/mediatek/clk-mux.c
@@ -160,7 +160,7 @@ struct clk *mtk_clk_register_mux(const struct mtk_mux *mux,
 spinlock_t *lock)
 {
struct mtk_clk_mux *clk_mux;
-   struct clk_init_data init;
+   struct clk_init_data init = {};
struct clk *clk;
 
clk_mux = kzalloc(sizeof(*clk_mux), GFP_KERNEL);
-- 
1.8.1.1.dirty


Re: [PATCH v2 0/4] x86/boot: Remove runtime relocations from compressed kernel

2020-05-26 Thread Sedat Dilek
On Tue, May 26, 2020 at 5:31 PM Arvind Sankar  wrote:
>
> On Tue, May 26, 2020 at 05:07:24PM +0200, Sedat Dilek wrote:
> > > >
> > >
> > > Maybe this should be:
> > >
> > > [ arch/x86/boot/compressed/Makefile ]
> > >
> > > -KBUILD_CFLAGS += -include hidden.h
> > > +KBUILD_CFLAGS += -include ./hidden.h
> > >
> >
> > NOPE.
> >
> > This works:
> >
> > [ arch/x86/boot/compressed/Makefile ]
> >
> > -KBUILD_CFLAGS += -include hidden.h
> > +KBUILD_CFLAGS += -include ./arch/x86/boot/compressed/hidden.h
> >
> > $ ll arch/x86/boot/bzImage arch/x86/boot/compressed/vmlinux
> > -rw-r--r-- 1 dileks dileks 6,5M Mai 26 17:05 arch/x86/boot/bzImage
> > -rwxr-xr-x 1 dileks dileks 6,5M Mai 26 17:05 
> > arch/x86/boot/compressed/vmlinux
> >
> > - Sedat -
>
> It needs to either be $(srctree)/$(src)/hidden.h, or we should add
> -I $(srctree)/$(src) to the KBUILD_CFLAGS. The latter option is added
> automatically when building in a separate builddir with O=${KOBJ} (which
> is how I, and I assume Ard, was testing), but for some reason is not
> added when building in-tree. The -include option doesn't automatically
> search the directory of the source file.
>
> -include file Process file as if "#include "file"" appeared as the first
> line of the primary source file.  However, the first directory searched
> for file is the preprocessor's working directory instead of the
> directory containing the main source file.  If not found there, it is
> searched for in the remainder of the "#include "..."" search chain as
> normal.

Will you send a follow-up or a v3 for this?

- Sedat -


Re: [PATCH v4 6/7] KVM: MIPS: clean up redundant 'kvm_run' parameters

2020-05-26 Thread Tianjia Zhang




On 2020/4/27 13:40, Huacai Chen wrote:

Reviewed-by: Huacai Chen 

On Mon, Apr 27, 2020 at 12:35 PM Tianjia Zhang
 wrote:


In the current kvm version, 'kvm_run' has been included in the 'kvm_vcpu'
structure. For historical reasons, many kvm-related function parameters
retain the 'kvm_run' and 'kvm_vcpu' parameters at the same time. This
patch does a unified cleanup of these remaining redundant parameters.

Signed-off-by: Tianjia Zhang 
---
  arch/mips/include/asm/kvm_host.h |  28 +---
  arch/mips/kvm/emulate.c  |  59 ++--
  arch/mips/kvm/mips.c |  11 ++-
  arch/mips/kvm/trap_emul.c| 114 ++-
  arch/mips/kvm/vz.c   |  26 +++
  5 files changed, 87 insertions(+), 151 deletions(-)



Hi Huacai,

These two patches(6/7 and 7/7) should be merged into the tree of the 
mips architecture separately. At present, there seems to be no good way 
to merge the whole architecture patchs.


For this series of patches, some architectures have been merged, some 
need to update the patch.


Thanks and best,
Tianjia


[PATCH V2] mfd: sprd: Add wakeup capability for PMIC irq

2020-05-26 Thread Chunyan Zhang
From: Baolin Wang 

When changing to use suspend-to-idle to save power, the PMIC irq can not
wakeup the system due to lack of wakeup capability, which will cause
the sub-irqs (such as power key) of the PMIC can not wake up the system.
Thus we can add the wakeup capability for PMIC irq to solve this issue,
as well as removing the IRQF_NO_SUSPEND flag to allow PMIC irq to be
a wakeup source.

Reported-by: Chunyan Zhang 
Signed-off-by: Baolin Wang 
Tested-by: Chunyan Zhang 
---
Changes from v1:
* addressed comments from Lee;
* added tested-by from Chunyan.
(This patch is rebased on branch for-mfd-next)
---
 drivers/mfd/sprd-sc27xx-spi.c | 28 +++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/sprd-sc27xx-spi.c b/drivers/mfd/sprd-sc27xx-spi.c
index 6cde4724..adb4a1b13332 100644
--- a/drivers/mfd/sprd-sc27xx-spi.c
+++ b/drivers/mfd/sprd-sc27xx-spi.c
@@ -256,7 +256,7 @@ static int sprd_pmic_probe(struct spi_device *spi)
}
 
ret = devm_regmap_add_irq_chip(&spi->dev, ddata->regmap, ddata->irq,
-  IRQF_ONESHOT | IRQF_NO_SUSPEND, 0,
+  IRQF_ONESHOT, 0,
   &ddata->irq_chip, &ddata->irq_data);
if (ret) {
dev_err(&spi->dev, "Failed to add PMIC irq chip %d\n", ret);
@@ -272,9 +272,34 @@ static int sprd_pmic_probe(struct spi_device *spi)
return ret;
}
 
+   device_init_wakeup(&spi->dev, true);
return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int sprd_pmic_suspend(struct device *dev)
+{
+   struct sprd_pmic *ddata = dev_get_drvdata(dev);
+
+   if (device_may_wakeup(dev))
+   enable_irq_wake(ddata->irq);
+
+   return 0;
+}
+
+static int sprd_pmic_resume(struct device *dev)
+{
+   struct sprd_pmic *ddata = dev_get_drvdata(dev);
+
+   if (device_may_wakeup(dev))
+   disable_irq_wake(ddata->irq);
+
+   return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(sprd_pmic_pm_ops, sprd_pmic_suspend, 
sprd_pmic_resume);
+
 static const struct of_device_id sprd_pmic_match[] = {
{ .compatible = "sprd,sc2731", .data = &sc2731_data },
{},
@@ -285,6 +310,7 @@ static struct spi_driver sprd_pmic_driver = {
.driver = {
.name = "sc27xx-pmic",
.of_match_table = sprd_pmic_match,
+   .pm = &sprd_pmic_pm_ops,
},
.probe = sprd_pmic_probe,
 };
-- 
2.20.1



Re: [PATCH] HID: multitouch: Remove MT_CLS_WIN_8_DUAL

2020-05-26 Thread Kai-Heng Feng



> On May 26, 2020, at 16:43, Benjamin Tissoires  
> wrote:
> 
> On Tue, May 26, 2020 at 10:24 AM Jiri Kosina  wrote:
>> 
>> On Tue, 14 Apr 2020, Kai-Heng Feng wrote:
>> 
>>> After commit c23e2043d5f7 ("HID: multitouch: do not filter mice nodes"),
>>> MT_CLS_WIN_8 also supports mouse nodes, hence make MT_CLS_WIN_8_DUAL
>>> redundant.
>>> 
>>> Remove MT_CLS_WIN_8_DUAL accordingly.
>> 
>> Benjamin, can I get your Ack on this one please?
> 
> Heh, funny enough I was trying to fix
> https://bugzilla.kernel.org/show_bug.cgi?id=207235 and was pondering
> this one too.
> 
> To fix #207235, I'll likely need to add a new class and quirk in
> hid-multitouch. I can't really find a generic solution for now, and we
> better have a local quirk for the 2 devices we currently have and
> backport those to stable. However, this patch will likely conflict
> (trivially), with the new quirks, so I was thinking:
> - submitting my quick and dirty quirk and mark it to stable
> - apply this one on top of it (this one really doesn't need to go to stable)
> 
> How does that sound?

Sounds good. I'll resend this patch once your patch lands in the tree.

Kai-Heng

> 
> Cheers,
> Benjamin
> 
>> 
>> Thanks,
>> 
>> --
>> Jiri Kosina
>> SUSE Labs
>> 
> 



Re: [PATCH] macvlan: Skip loopback packets in RX handler

2020-05-26 Thread David Miller
From: Alexander A Sverdlin 
Date: Tue, 26 May 2020 14:27:51 +0200

> From: Alexander Sverdlin 
> 
> Ignore loopback-originatig packets soon enough and don't try to process L2
> header where it doesn't exist. The very similar br_handle_frame() in bridge
> code performs exactly the same check.
> 
> This is an example of such ICMPv6 packet:
 ...
> Call Trace, how it happens exactly:
>  ...
>  macvlan_handle_frame+0x321/0x425 [macvlan]
>  ? macvlan_forward_source+0x110/0x110 [macvlan]
>  __netif_receive_skb_core+0x545/0xda0
 ...
> Signed-off-by: Alexander Sverdlin 

Applied to net-next, thanks.


不況に強い社会福祉事業 新規参入オンラインセミナー

2020-05-26 Thread 社会福祉プロジェクト
代表者様

社会福祉事業を応援するメディアを運営しております
社会福祉プロジェクトと申します。

今、新規事業をお考えの経営者様を対象に
社会福祉事業が大変注目されているのを
ご存知でしょうか?


今月複数回にわたって開催された
社会福祉プロジェクトオンラインセミナーも
大変な盛会のうちに終える事となりました。

社会福祉プロジェクトセミナーを少しのぞいてみる。
https://fukushi-service.work/seminar/


実際にセミナーに参加された方からも

「福祉総合企業というビジネスモデルが
印象的でした。」

「リピート率が高い、高収益、貢献ビジネス。
青山先生の熱意に感銘を受けました。」

「国を相手にする手堅いビジネスであること。
実は同様の事を目立たずにやっている人達が
いることが知れた。」

「労働時間に対して売り上げが高いことに
驚きました。」


などなど

ここでは全部紹介しきれませんが
参加後のアンケートでも93.6%の方から
大変満足の声をいただきました。

社会福祉プロジェクトセミナーを少しのぞいてみる。
https://fukushi-service.work/seminar/

今月24日が最後のセミナー開催でしたが
大変好評の声をいただいており

もう一度この優れたビジネスモデルについて
知っていただく機会を特別に設ける事にしました。

この特別開催のお知らせを告知して早速申し込みの
数も殺到しており、残り枠数も大変少なくなってきて
おります。

「やっぱりあの時話だけでも聞いておくべきだった。」
と後から後悔するまえに

まずは参加枠の確保をしていただく事を
強くオススメ致します。


社会福祉プロジェクトセミナーの残り席数と日程を確認する。
https://fukushi-service.work/seminar/


大切なお子様をお預かりする福祉事業
を、ビジネスと呼ぶのは少し抵抗がありますが

収益面でも充実しなければ、質の高い
サービスを提供する事も困難になります。

このセミナーでお伝えするのは

福祉事業を通じた高い社会貢献の実現と、
資産形成含め、効果実証済みのビジネスモデルを
活用した安定した収益の確保。

この2つを両立させ、物心両面を満たす
再現性ある経営ノウハウについてです。

社会福祉プロジェクトセミナーの残り席数と日程を確認する。
https://fukushi-service.work/seminar/


特に人一倍働いているのに、利益が
なかなか伸びない。上がらない。

自分が働けなくなったら、事業として
成り立たない。

人財がなかなか定着しない。育たない。


そのような事でお悩みの経営者の方や
事業主の方に、知っていただきたい内容です。

次回セミナー開催の予定はございません。

今回がラストチャンスとなるかもしれませんので
少しでも興味がある方は

この機を逃さず物心両面を満たすノウハウを
手に入れて下さい。

社会福祉プロジェクト最終セミナーの残り席数と日程を確認する。
https://fukushi-service.work/seminar/


それでは、当日お会いできる事を
楽しみにしております。


主催:社会福祉プロジェクト

-
社会福祉プロジェクト

i...@fukushi-service.work
https://fukushi-service.work/seminar/

〒531-0072
大阪府大阪市北区豊崎2丁目7−9いずみビル4F
TEL : 06--4030
-


Re: [PATCH] HID: multitouch: enable multi-input as a quirk for some devices

2020-05-26 Thread Kai-Heng Feng



> On May 26, 2020, at 23:07, Benjamin Tissoires  
> wrote:
> 
> Two touchpad/trackstick combos are currently not behaving properly.
> They define a mouse emulation collection, as per Win8 requirements,
> but also define a separate mouse collection for the trackstick.
> 
> The way the kernel currently treat the collections is that it
> merges both in one device. However, given that the first mouse
> collection already defines X,Y and left, right buttons, when
> mapping the events from the second mouse collection, hid-multitouch
> sees that these events are already mapped, and simply ignores them.
> 
> To be able to report events from the tracktick, add a new quirked
> class for it, and manually add the 2 devices we know about.
> 
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=207235
> Cc: sta...@vger.kernel.org
> Signed-off-by: Benjamin Tissoires 

Tested-by: Kai-Heng Feng 

> ---
> drivers/hid/hid-multitouch.c | 26 ++
> 1 file changed, 26 insertions(+)
> 
> diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
> index 03c720b47306..39e4da7468e1 100644
> --- a/drivers/hid/hid-multitouch.c
> +++ b/drivers/hid/hid-multitouch.c
> @@ -69,6 +69,7 @@ MODULE_LICENSE("GPL");
> #define MT_QUIRK_ASUS_CUSTOM_UP   BIT(17)
> #define MT_QUIRK_WIN8_PTP_BUTTONS BIT(18)
> #define MT_QUIRK_SEPARATE_APP_REPORT  BIT(19)
> +#define MT_QUIRK_FORCE_MULTI_INPUT   BIT(20)
> 
> #define MT_INPUTMODE_TOUCHSCREEN  0x02
> #define MT_INPUTMODE_TOUCHPAD 0x03
> @@ -189,6 +190,7 @@ static void mt_post_parse(struct mt_device *td, struct 
> mt_application *app);
> #define MT_CLS_WIN_8  0x0012
> #define MT_CLS_EXPORT_ALL_INPUTS  0x0013
> #define MT_CLS_WIN_8_DUAL 0x0014
> +#define MT_CLS_WIN_8_FORCE_MULTI_INPUT   0x0015
> 
> /* vendor specific classes */
> #define MT_CLS_3M 0x0101
> @@ -279,6 +281,15 @@ static const struct mt_class mt_classes[] = {
>   MT_QUIRK_CONTACT_CNT_ACCURATE |
>   MT_QUIRK_WIN8_PTP_BUTTONS,
>   .export_all_inputs = true },
> + { .name = MT_CLS_WIN_8_FORCE_MULTI_INPUT,
> + .quirks = MT_QUIRK_ALWAYS_VALID |
> + MT_QUIRK_IGNORE_DUPLICATES |
> + MT_QUIRK_HOVERING |
> + MT_QUIRK_CONTACT_CNT_ACCURATE |
> + MT_QUIRK_STICKY_FINGERS |
> + MT_QUIRK_WIN8_PTP_BUTTONS |
> + MT_QUIRK_FORCE_MULTI_INPUT,
> + .export_all_inputs = true },
> 
>   /*
>* vendor specific classes
> @@ -1714,6 +1725,11 @@ static int mt_probe(struct hid_device *hdev, const 
> struct hid_device_id *id)
>   if (id->group != HID_GROUP_MULTITOUCH_WIN_8)
>   hdev->quirks |= HID_QUIRK_MULTI_INPUT;
> 
> + if (mtclass->quirks & MT_QUIRK_FORCE_MULTI_INPUT) {
> + hdev->quirks &= ~HID_QUIRK_INPUT_PER_APP;
> + hdev->quirks |= HID_QUIRK_MULTI_INPUT;
> + }
> +
>   timer_setup(&td->release_timer, mt_expired_timeout, 0);
> 
>   ret = hid_parse(hdev);
> @@ -1926,6 +1942,11 @@ static const struct hid_device_id mt_devices[] = {
>   MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
>   USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_C002) },
> 
> + /* Elan devices */
> + { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT,
> + HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8,
> + USB_VENDOR_ID_ELAN, 0x313a) },
> +
>   /* Elitegroup panel */
>   { .driver_data = MT_CLS_SERIAL,
>   MT_USB_DEVICE(USB_VENDOR_ID_ELITEGROUP,
> @@ -2056,6 +2077,11 @@ static const struct hid_device_id mt_devices[] = {
>   MT_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM,
>   USB_DEVICE_ID_MTP_STM)},
> 
> + /* Synaptics devices */
> + { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT,
> + HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8,
> + USB_VENDOR_ID_SYNAPTICS, 0xce08) },
> +
>   /* TopSeed panels */
>   { .driver_data = MT_CLS_TOPSEED,
>   MT_USB_DEVICE(USB_VENDOR_ID_TOPSEED2,
> -- 
> 2.25.1
> 



[v3,1/1] hwmon:(nct7904) Set default timeout

2020-05-26 Thread yuechao.zhao
From: Yuechao Zhao 

The timeout module parameter should not be used for setting the default
timeout. Because, if you set the timeout = 0, the default timeout will
be meaningless. And the timeout module parameter of 0 means "no timeout
module paraameter specified".

Signed-off-by: Yuechao Zhao 
---
Change in v3:
- replace 'static int timeout = WATCHDOG_TIMEOUT;' with 'static int timeout;'
- fixed typo

Change in v2:
- modify subject to 'hwmon:(nct7904) Set default timeout'
---
 drivers/hwmon/nct7904.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/hwmon/nct7904.c b/drivers/hwmon/nct7904.c
index 18c95be..b042569 100644
--- a/drivers/hwmon/nct7904.c
+++ b/drivers/hwmon/nct7904.c
@@ -111,14 +111,14 @@
 #define MIN_TIMEOUT(1 * 60)
 #define MAX_TIMEOUT(255 * 60)
 
-static int timeout = WATCHDOG_TIMEOUT;
+static int timeout;
 module_param(timeout, int, 0);
 MODULE_PARM_DESC(timeout, "Watchdog timeout in minutes. 1 <= timeout <= 255, 
default="
-   __MODULE_STRING(WATCHODOG_TIMEOUT) ".");
+   __MODULE_STRING(WATCHDOG_TIMEOUT) ".");
 
 static bool nowayout = WATCHDOG_NOWAYOUT;
 module_param(nowayout, bool, 0);
-MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started once 
started (default="
+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
 
 static const unsigned short normal_i2c[] = {
@@ -1147,7 +1147,7 @@ static int nct7904_probe(struct i2c_client *client,
data->wdt.ops = &nct7904_wdt_ops;
data->wdt.info = &nct7904_wdt_info;
 
-   data->wdt.timeout = timeout * 60; /* in seconds */
+   data->wdt.timeout = WATCHDOG_TIMEOUT * 60; /* Set default timeout */
data->wdt.min_timeout = MIN_TIMEOUT;
data->wdt.max_timeout = MAX_TIMEOUT;
data->wdt.parent = &client->dev;
-- 
1.8.3.1



[PATCH] MIPS: Fix IRQ tracing when call handle_fpe() and handle_msa_fpe()

2020-05-26 Thread YuanJunQing
 Register "a1" is unsaved in this function,
 when CONFIG_TRACE_IRQFLAGS is enabled,
 the TRACE_IRQS_OFF macro will call trace_hardirqs_off(),
 and this may change register "a1".
 The changed register "a1" as argument will be send
 to do_fpe() and do_msa_fpe().

Signed-off-by: YuanJunQing 
---
 arch/mips/kernel/genex.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/mips/kernel/genex.S b/arch/mips/kernel/genex.S
index 8236fb291e3f..a1b966f3578e 100644
--- a/arch/mips/kernel/genex.S
+++ b/arch/mips/kernel/genex.S
@@ -476,20 +476,20 @@ NESTED(nmi_handler, PT_SIZE, sp)
.endm
 
.macro  __build_clear_fpe
+   CLI
+   TRACE_IRQS_OFF
.setpush
/* gas fails to assemble cfc1 for some archs (octeon).*/ \
.setmips1
SET_HARDFLOAT
cfc1a1, fcr31
.setpop
-   CLI
-   TRACE_IRQS_OFF
.endm
 
.macro  __build_clear_msa_fpe
-   _cfcmsa a1, MSA_CSR
CLI
TRACE_IRQS_OFF
+   _cfcmsa a1, MSA_CSR
.endm
 
.macro  __build_clear_ade
-- 
2.17.1



Re: [PATCH 1/1] dt-bindings: MIPS: Document Ingenic SoCs binding.

2020-05-26 Thread Zhou Yanjie

Hi Paul,

在 2020/5/27 上午3:10, Paul Cercueil 写道:

Hi Zhou,

Le mer. 27 mai 2020 à 1:07, 周琰杰 (Zhou Yanjie) 
 a écrit :

Document the available properties for the SoC root node and the
CPU nodes of the devicetree for the Ingenic XBurst SoCs.

Tested-by: H. Nikolaus Schaller 
Tested-by: Paul Boddie 
Signed-off-by: 周琰杰 (Zhou Yanjie) 
---
 .../bindings/mips/ingenic/ingenic,cpu.yaml | 57 
++

 1 file changed, 57 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/mips/ingenic/ingenic,cpu.yaml


diff --git 
a/Documentation/devicetree/bindings/mips/ingenic/ingenic,cpu.yaml 
b/Documentation/devicetree/bindings/mips/ingenic/ingenic,cpu.yaml

new file mode 100644
index ..afb02071a756
--- /dev/null
+++ b/Documentation/devicetree/bindings/mips/ingenic/ingenic,cpu.yaml
@@ -0,0 +1,57 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mips/ingenic/ingenic,cpu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Bindings for Ingenic XBurst family CPUs
+
+maintainers:
+  - 周琰杰 (Zhou Yanjie) 
+
+description:
+  Ingenic XBurst family CPUs shall have the following properties.
+
+properties:
+  compatible:
+    oneOf:
+
+  - description: Ingenic XBurst®1 CPU Cores
+    items:


Strip the 'items', put the enum directly.



Sure, I'll drop it in the next version.



+  enum:
+    - ingenic,xburst-mxu1.0
+    - ingenic,xburst-fpu1.0-mxu1.1
+    - ingenic,xburst-fpu2.0-mxu2.0
+
+  - description: Ingenic XBurst®2 CPU Cores
+    items:


Same here.



Sure.



+  enum:
+    - ingenic,xburst2-fpu2.1-mxu2.1-smt
+
+  reg:
+    maxItems: 1
+
+required:
+  - device_type
+  - compatible
+  - reg


device_type is not in the list of your properties.

Also, I think you need a clock in there.



Sure, I will add it.


Thanks and best regards!



-Paul


+
+examples:
+  - |
+    cpus {
+    #address-cells = <1>;
+    #size-cells = <0>;
+
+    cpu0: cpu@0 {
+    device_type = "cpu";
+    compatible = "ingenic,xburst-fpu1.0-mxu1.1";
+    reg = <0>;
+    };
+
+    cpu1: cpu@1 {
+    device_type = "cpu";
+    compatible = "ingenic,xburst-fpu1.0-mxu1.1";
+    reg = <1>;
+    };
+    };
+...
--
2.11.0





RE: [RFC PATCH v12 07/11] psci: Add hypercall service for kvm ptp.

2020-05-26 Thread Jianyong Wu
Hi Steven,

> -Original Message-
> From: Steven Price 
> Sent: Tuesday, May 26, 2020 7:02 PM
> To: Jianyong Wu ; net...@vger.kernel.org;
> yangbo...@nxp.com; john.stu...@linaro.org; t...@linutronix.de;
> pbonz...@redhat.com; sean.j.christopher...@intel.com; m...@kernel.org;
> richardcoch...@gmail.com; Mark Rutland ;
> w...@kernel.org; Suzuki Poulose 
> Cc: linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org;
> kvm...@lists.cs.columbia.edu; k...@vger.kernel.org; Steve Capper
> ; Kaly Xin ; Justin He
> ; Wei Chen ; nd 
> Subject: Re: [RFC PATCH v12 07/11] psci: Add hypercall service for kvm ptp.
> 
> On 25/05/2020 03:11, Jianyong Wu wrote:
> > Hi Steven,
> 
> Hi Jianyong,
> 
> [...]>>> diff --git a/virt/kvm/arm/hypercalls.c b/virt/kvm/arm/hypercalls.c
> >>> index db6dce3d0e23..c964122f8dae 100644
> >>> --- a/virt/kvm/arm/hypercalls.c
> >>> +++ b/virt/kvm/arm/hypercalls.c
> >>> @@ -3,6 +3,7 @@
> >>>
> >>>#include 
> >>>#include 
> >>> +#include 
> >>>
> >>>#include 
> >>>
> >>> @@ -11,6 +12,10 @@
> >>>
> >>>int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)
> >>>{
> >>> +#ifdef CONFIG_ARM64_KVM_PTP_HOST
> >>> + struct system_time_snapshot systime_snapshot;
> >>> + u64 cycles;
> >>> +#endif
> >>>   u32 func_id = smccc_get_function(vcpu);
> >>>   u32 val[4] = {SMCCC_RET_NOT_SUPPORTED};
> >>>   u32 feature;
> >>> @@ -70,7 +75,49 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)
> >>>   break;
> >>>   case ARM_SMCCC_VENDOR_HYP_KVM_FEATURES_FUNC_ID:
> >>>   val[0] = BIT(ARM_SMCCC_KVM_FUNC_FEATURES);
> >>> +
> >>> +#ifdef CONFIG_ARM64_KVM_PTP_HOST
> >>> + val[0] |= BIT(ARM_SMCCC_KVM_FUNC_KVM_PTP); #endif
> >>>   break;
> >>> +
> >>> +#ifdef CONFIG_ARM64_KVM_PTP_HOST
> >>> + /*
> >>> +  * This serves virtual kvm_ptp.
> >>> +  * Four values will be passed back.
> >>> +  * reg0 stores high 32-bit host ktime;
> >>> +  * reg1 stores low 32-bit host ktime;
> >>> +  * reg2 stores high 32-bit difference of host cycles and cntvoff;
> >>> +  * reg3 stores low 32-bit difference of host cycles and cntvoff.
> >>> +  */
> >>> + case ARM_SMCCC_VENDOR_HYP_KVM_PTP_FUNC_ID:
> >>> + /*
> >>> +  * system time and counter value must captured in the same
> >>> +  * time to keep consistency and precision.
> >>> +  */
> >>> + ktime_get_snapshot(&systime_snapshot);
> >>> + if (systime_snapshot.cs_id != CSID_ARM_ARCH_COUNTER)
> >>> + break;
> >>> + val[0] = upper_32_bits(systime_snapshot.real);
> >>> + val[1] = lower_32_bits(systime_snapshot.real);
> >>> + /*
> >>> +  * which of virtual counter or physical counter being
> >>> +  * asked for is decided by the first argument.
> >>> +  */
> >>> + feature = smccc_get_arg1(vcpu);
> >>> + switch (feature) {
> >>> + case ARM_SMCCC_VENDOR_HYP_KVM_PTP_PHY_FUNC_ID:
> >>> + cycles = systime_snapshot.cycles;
> >>> + break;
> >>> + default:
> >>
> >> There's something a bit odd here.
> >>
> >> ARM_SMCCC_VENDOR_HYP_KVM_PTP_FUNC_ID and
> >> ARM_SMCCC_VENDOR_HYP_KVM_PTP_PHY_FUNC_ID look like they
> should be
> >> names of separate (top-level) functions, but actually the _PHY_ one
> >> is a parameter for the first. If the intention is to have a parameter
> >> then it would be better to pick a better name for the _PHY_ define
> >> and not define it using ARM_SMCCC_CALL_VAL.
> >>
> > Yeah, _PHY_ is not the same meaning with _PTP_FUNC_ID,  so I think it
> should be a different name.
> > What about ARM_SMCCC_VENDOR_HYP_KVM_PTP_PHY_COUNTER?
> 
> Personally I'd go with something much shorter, e.g.
> ARM_PTP_PHY_COUNTER.
> This is just an argument to an SMCCC call so there's no need for most of the
> prefix, indeed if (for whatever reason) there was a non-SMCCC mechanism
> added to do the same thing it would be reasonable to reuse the same values.
> 
Ok ,  this shorter name is better.

> >> Second the use of "default:" means that there's no possibility to
> >> later extend this interface for more clocks if needed in the future.
> >>
> > I think we can add more clocks by adding more cases, this "default" means
> we can use no first arg to determine the default clock.
> 
> The problem with the 'default' is it means it's not possible to probe whether
> the kernel supports any more clocks. If we used a different value (that the
> kernel doesn't support) then we end up in the default case and have no idea
> whether the clock value is the one we requested or not.
> 
Yeah,  it's more meaningful. Should return the exact value back to user.

> It's generally better when defining an ABI to explicitly return an error for
> unknown parameters, that way a future user of the ABI can discover
> whether the call did what was expected or not.
> 

ok. I will fix it.

> >> Alternatively you could indeed implement as two top-level fun

Re: [PATCH v3 1/3] riscv: Move kernel mapping to vmalloc zone

2020-05-26 Thread Zong Li
On Wed, May 27, 2020 at 1:06 AM Alex Ghiti  wrote:
>
> Hi Zong,
>
> Le 5/26/20 à 5:43 AM, Zong Li a écrit :
> > On Sun, May 24, 2020 at 4:54 PM Alexandre Ghiti  wrote:
> >> This is a preparatory patch for relocatable kernel.
> >>
> >> The kernel used to be linked at PAGE_OFFSET address and used to be loaded
> >> physically at the beginning of the main memory. Therefore, we could use
> >> the linear mapping for the kernel mapping.
> >>
> >> But the relocated kernel base address will be different from PAGE_OFFSET
> >> and since in the linear mapping, two different virtual addresses cannot
> >> point to the same physical address, the kernel mapping needs to lie outside
> >> the linear mapping.
> >>
> >> In addition, because modules and BPF must be close to the kernel (inside
> >> +-2GB window), the kernel is placed at the end of the vmalloc zone minus
> >> 2GB, which leaves room for modules and BPF. The kernel could not be
> >> placed at the beginning of the vmalloc zone since other vmalloc
> >> allocations from the kernel could get all the +-2GB window around the
> >> kernel which would prevent new modules and BPF programs to be loaded.
> >>
> >> Signed-off-by: Alexandre Ghiti 
> >> ---
> >>   arch/riscv/boot/loader.lds.S |  3 +-
> >>   arch/riscv/include/asm/page.h| 10 +-
> >>   arch/riscv/include/asm/pgtable.h | 37 +---
> >>   arch/riscv/kernel/head.S |  3 +-
> >>   arch/riscv/kernel/module.c   |  4 +--
> >>   arch/riscv/kernel/vmlinux.lds.S  |  3 +-
> >>   arch/riscv/mm/init.c | 58 +---
> >>   arch/riscv/mm/physaddr.c |  2 +-
> >>   8 files changed, 87 insertions(+), 33 deletions(-)
> >>
> >> diff --git a/arch/riscv/boot/loader.lds.S b/arch/riscv/boot/loader.lds.S
> >> index 47a5003c2e28..62d94696a19c 100644
> >> --- a/arch/riscv/boot/loader.lds.S
> >> +++ b/arch/riscv/boot/loader.lds.S
> >> @@ -1,13 +1,14 @@
> >>   /* SPDX-License-Identifier: GPL-2.0 */
> >>
> >>   #include 
> >> +#include 
> >>
> >>   OUTPUT_ARCH(riscv)
> >>   ENTRY(_start)
> >>
> >>   SECTIONS
> >>   {
> >> -   . = PAGE_OFFSET;
> >> +   . = KERNEL_LINK_ADDR;
> >>
> >>  .payload : {
> >>  *(.payload)
> >> diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h
> >> index 2d50f76efe48..48bb09b6a9b7 100644
> >> --- a/arch/riscv/include/asm/page.h
> >> +++ b/arch/riscv/include/asm/page.h
> >> @@ -90,18 +90,26 @@ typedef struct page *pgtable_t;
> >>
> >>   #ifdef CONFIG_MMU
> >>   extern unsigned long va_pa_offset;
> >> +extern unsigned long va_kernel_pa_offset;
> >>   extern unsigned long pfn_base;
> >>   #define ARCH_PFN_OFFSET(pfn_base)
> >>   #else
> >>   #define va_pa_offset   0
> >> +#define va_kernel_pa_offset0
> >>   #define ARCH_PFN_OFFSET(PAGE_OFFSET >> PAGE_SHIFT)
> >>   #endif /* CONFIG_MMU */
> >>
> >>   extern unsigned long max_low_pfn;
> >>   extern unsigned long min_low_pfn;
> >> +extern unsigned long kernel_virt_addr;
> >>
> >>   #define __pa_to_va_nodebug(x)  ((void *)((unsigned long) (x) + 
> >> va_pa_offset))
> >> -#define __va_to_pa_nodebug(x)  ((unsigned long)(x) - va_pa_offset)
> >> +#define linear_mapping_va_to_pa(x) ((unsigned long)(x) - va_pa_offset)
> >> +#define kernel_mapping_va_to_pa(x) \
> >> +   ((unsigned long)(x) - va_kernel_pa_offset)
> >> +#define __va_to_pa_nodebug(x)  \
> >> +   (((x) >= PAGE_OFFSET) ? \
> >> +   linear_mapping_va_to_pa(x) : kernel_mapping_va_to_pa(x))
> >>
> >>   #ifdef CONFIG_DEBUG_VIRTUAL
> >>   extern phys_addr_t __virt_to_phys(unsigned long x);
> >> diff --git a/arch/riscv/include/asm/pgtable.h 
> >> b/arch/riscv/include/asm/pgtable.h
> >> index 35b60035b6b0..25213cfaf680 100644
> >> --- a/arch/riscv/include/asm/pgtable.h
> >> +++ b/arch/riscv/include/asm/pgtable.h
> >> @@ -11,23 +11,29 @@
> >>
> >>   #include 
> >>
> >> -#ifndef __ASSEMBLY__
> >> -
> >> -/* Page Upper Directory not used in RISC-V */
> >> -#include 
> >> -#include 
> >> -#include 
> >> -#include 
> >> -
> >> -#ifdef CONFIG_MMU
> >> +#ifndef CONFIG_MMU
> >> +#define KERNEL_VIRT_ADDR   PAGE_OFFSET
> >> +#define KERNEL_LINK_ADDR   PAGE_OFFSET
> >> +#else
> >> +/*
> >> + * Leave 2GB for modules and BPF that must lie within a 2GB range around
> >> + * the kernel.
> >> + */
> >> +#define KERNEL_VIRT_ADDR   (VMALLOC_END - SZ_2G + 1)
> >> +#define KERNEL_LINK_ADDR   KERNEL_VIRT_ADDR
> >>
> >>   #define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1)
> >>   #define VMALLOC_END  (PAGE_OFFSET - 1)
> >>   #define VMALLOC_START(PAGE_OFFSET - VMALLOC_SIZE)
> >>
> >>   #define BPF_JIT_REGION_SIZE(SZ_128M)
> >> -#define BPF_JIT_REGION_START   (PAGE_OFFSET - BPF_JIT_REGION_SIZE)
> >> -#define BPF_JIT_REGION_END (VMALLOC_END)
> >> +#define BPF_JIT_REGION_START   (kernel_virt_addr)
> >> +#define BPF_JIT_REGION_END (kernel_virt_addr + BPF_JIT_REGION_SIZE)
> > It seems to have a potenti

[PATCH] vdpa: fix typos in the comments for __vdpa_alloc_device()

2020-05-26 Thread Jason Wang
Fix two typos in the comments for __vdpa_alloc_device().

Signed-off-by: Jason Wang 
---
 drivers/vdpa/vdpa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
index ff6562f602e0..de211ef3738c 100644
--- a/drivers/vdpa/vdpa.c
+++ b/drivers/vdpa/vdpa.c
@@ -63,7 +63,7 @@ static void vdpa_release_dev(struct device *d)
  * @config: the bus operations that is supported by this device
  * @size: size of the parent structure that contains private data
  *
- * Drvier should use vdap_alloc_device() wrapper macro instead of
+ * Driver should use vdpa_alloc_device() wrapper macro instead of
  * using this directly.
  *
  * Returns an error when parent/config/dma_dev is not set or fail to get
-- 
2.20.1



Re: [PATCH] ipc/msg.c: wake up senders until there is a queue empty capacity

2020-05-26 Thread Manfred Spraul

Hello Artur,

On 5/26/20 9:56 AM, Artur Barsegyan wrote:

Hello, Manfred!

Thank you, for your review. I've reviewed your patch.

I forgot about the case with different message types. At now with your patch,
a sender will force message consuming if that doesn't hold own capacity.

I have measured queue throughput and have pushed the results to:
https://github.com/artur-barsegyan/systemv_queue_research

But I'm confused about the next thought: in general loop in the do_msgsnd()
function, we doesn't check pipeline sending availability. Your case will be
optimized if we check the pipeline sending inside the loop.


I don't get your concern, or perhaps this is a feature that I had always 
assumed as "normal":


"msg_fits_inqueue(msq, msgsz)" is in the loop, this ensures progress.

The rational is a design decision:

The check for pipeline sending is only done if there would be space to 
store the message in the queue.


I was afraid that performing the pipeline send immediately, without 
checking queue availability, could break apps:


Some messages would arrive immediately (if there is a waiting receiver), 
other messages are stuck forever (since the queue is full).


Initial patch: https://lkml.org/lkml/1999/10/3/5 (without any remarks 
about the design decision)


The risk that I had seen was theoretical, I do not have any real bug 
reports. So we could change it.


Perhaps: Go in the same direction as it was done for POSIX mqueue: 
implement pipelined receive.



On Sun, May 24, 2020 at 03:21:31PM +0200, Manfred Spraul wrote:

Hello Artur,

On 5/23/20 10:34 PM, Artur Barsegyan wrote:

Take into account the total size of the already enqueued messages of
previously handled senders before another one.

Otherwise, we have serious degradation of receiver throughput for
case with multiple senders because another sender wakes up,
checks the queue capacity and falls into sleep again.

Each round-trip wastes CPU time a lot and leads to perceptible
throughput degradation.

Source code of:
- sender/receiver
- benchmark script
- ready graphics of before/after results

is located here: https://github.com/artur-barsegyan/systemv_queue_research

Thanks for analyzing the issue!


Signed-off-by: Artur Barsegyan 
---
   ipc/msg.c | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ipc/msg.c b/ipc/msg.c
index caca67368cb5..52d634b0a65a 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -214,6 +214,7 @@ static void ss_wakeup(struct msg_queue *msq,
struct msg_sender *mss, *t;
struct task_struct *stop_tsk = NULL;
struct list_head *h = &msq->q_senders;
+   size_t msq_quota_used = 0;
list_for_each_entry_safe(mss, t, h, list) {
if (kill)
@@ -233,7 +234,7 @@ static void ss_wakeup(struct msg_queue *msq,
 * move the sender to the tail on behalf of the
 * blocked task.
 */
-   else if (!msg_fits_inqueue(msq, mss->msgsz)) {
+   else if (!msg_fits_inqueue(msq, msq_quota_used + mss->msgsz)) {
if (!stop_tsk)
stop_tsk = mss->tsk;
@@ -241,6 +242,7 @@ static void ss_wakeup(struct msg_queue *msq,
continue;
}
+   msq_quota_used += mss->msgsz;
wake_q_add(wake_q, mss->tsk);

You have missed the case of a do_msgsnd() that doesn't enqueue the message:

Situation:

- 2 messages of type 1 in the queue (2x8192 bytes, queue full)

- 6 senders waiting to send messages of type 2

- 6 receivers waiting to get messages of type 2.

If now a receiver reads one message of type 1, then all 6 senders can send.

WIth your patch applied, only one sender sends the message to one receiver,
and the remaining 10 tasks continue to sleep.


Could you please check and (assuming that you agree) run your benchmarks
with the patch applied?

--

     Manfred



 From fe2f257b1950a19bf5c6f67e71aa25c2f13bcdc3 Mon Sep 17 00:00:00 2001
From: Manfred Spraul 
Date: Sun, 24 May 2020 14:47:31 +0200
Subject: [PATCH 2/2] ipc/msg.c: Handle case of senders not enqueuing the
  message

The patch "ipc/msg.c: wake up senders until there is a queue empty
capacity" avoids the thundering herd problem by wakeing up
only as many potential senders as there is free space in the queue.

This patch is a fix: If one of the senders doesn't enqueue its message,
then a search for further potential senders must be performed.

Signed-off-by: Manfred Spraul 
---
  ipc/msg.c | 21 +
  1 file changed, 21 insertions(+)

diff --git a/ipc/msg.c b/ipc/msg.c
index 52d634b0a65a..f6d5188db38a 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -208,6 +208,12 @@ static inline void ss_del(struct msg_sender *mss)
list_del(&mss->list);
  }
  
+/*

+ * ss_wakeup() assumes that the stored senders will enqueue the pending 
message.
+ * Thus: If a woken up task doesn't send the enqueued message for whatever
+ * reas

Re: [PATCH v8 4/6] dt-bindings: MIPS: Document Ingenic SoCs binding.

2020-05-26 Thread Zhou Yanjie



在 2020/5/27 上午3:29, Rob Herring 写道:

On Tue, May 19, 2020 at 10:35:21PM +0800, 周琰杰 (Zhou Yanjie) wrote:

Document the available properties for the SoC root node and the
CPU nodes of the devicetree for the Ingenic XBurst SoCs.

Tested-by: H. Nikolaus Schaller 
Tested-by: Paul Boddie 
Signed-off-by: 周琰杰 (Zhou Yanjie) 
---

Notes:
 v1->v2:
 Change the two Document from txt to yaml.
 
 v2->v3:

 Fix formatting errors.
 
 v3->v4:

 Fix bugs in the two yaml files.
 
 v4->v5:

 No change.
 
 v5->v6:

 Rewrite the two yaml files.
 
 v6->v7:

 1.Update compatible strings in "ingenic,cpu.yaml".
 2.Fix formatting errors, and enum for compatible strings.
 3.Remove unnecessary "ingenic,soc.yaml".
 
 v7->v8:

 No change.

  .../bindings/mips/ingenic/ingenic,cpu.yaml | 57 ++
  1 file changed, 57 insertions(+)
  create mode 100644 
Documentation/devicetree/bindings/mips/ingenic/ingenic,cpu.yaml

diff --git a/Documentation/devicetree/bindings/mips/ingenic/ingenic,cpu.yaml 
b/Documentation/devicetree/bindings/mips/ingenic/ingenic,cpu.yaml
new file mode 100644
index ..afb0207
--- /dev/null
+++ b/Documentation/devicetree/bindings/mips/ingenic/ingenic,cpu.yaml
@@ -0,0 +1,57 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mips/ingenic/ingenic,cpu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Bindings for Ingenic XBurst family CPUs
+
+maintainers:
+  - 周琰杰 (Zhou Yanjie) 
+
+description:
+  Ingenic XBurst family CPUs shall have the following properties.
+
+properties:
+  compatible:
+oneOf:
+
+  - description: Ingenic XBurst®1 CPU Cores
+items:

This is a single compatible string, right? If so, drop items.



Sure, I'll drop it. And because the SMP driver has some other work that 
can't be completed in a short time, so I will send this patch separately.




+  enum:
+- ingenic,xburst-mxu1.0
+- ingenic,xburst-fpu1.0-mxu1.1
+- ingenic,xburst-fpu2.0-mxu2.0
+
+  - description: Ingenic XBurst®2 CPU Cores
+items:
+  enum:
+- ingenic,xburst2-fpu2.1-mxu2.1-smt

Just: const: ingenic,xburst2-fpu2.1-mxu2.1-smt

Continuing to append CPU features isn't going to scale well. Does
'xburst2' imply certain features? If so, not really any need to have
them be explicit.



XBurst (XBurst1) is the first generation CPU core of Ingenic, its basic 
property is single-issue in-order execution, XBurst2 is the second 
generation CPU core of Ingenic, its basic property is daul-issue limited 
out-of-order execution, and both CPU cores can cooperate with some 
extended propeties,  such as different versions of FPU, different 
versions of MXU instruction set, with or without simultaneous 
multi-threading.


Currently there is only one processor entity based on XBurst2 is 
produced, so there is  only one string for now.



Thanks and best regards!



+
+  reg:
+maxItems: 1
+
+required:
+  - device_type
+  - compatible
+  - reg
+
+examples:
+  - |
+cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   cpu0: cpu@0 {
+   device_type = "cpu";
+   compatible = "ingenic,xburst-fpu1.0-mxu1.1";
+   reg = <0>;
+   };
+
+   cpu1: cpu@1 {
+   device_type = "cpu";
+   compatible = "ingenic,xburst-fpu1.0-mxu1.1";
+   reg = <1>;
+   };
+};
+...
--
2.7.4



Re: [PATCH] sparc32: register memory occupied by kernel as memblock.memory

2020-05-26 Thread David Miller
From: Mike Rapoport 
Date: Wed, 27 May 2020 07:52:19 +0300

> Andrew, David,
> 
> Any comments on this?

No objections from me:

Acked-by: David S. Miller 


Re: [PATCH 0/2] Bugy bootloader woraround

2020-05-26 Thread Jiaxun Yang
On Wed, 27 May 2020 13:27:17 +0800
Jiaxun Yang  wrote:

> Jiaxun Yang (2):
>   MIPS: head.S: Always jump to kernel_entry at head of text
>   MIPS: Loongso64: select NO_EXCEPT_FILL

Please ignore the noise.
Something went wrong with my keyboard...

> 
>  arch/mips/Kconfig   | 1 +
>  arch/mips/kernel/head.S | 2 --
>  2 files changed, 1 insertion(+), 2 deletions(-)
> 



Re: [RFC PATCH] gpio: uapi: v2 proposal

2020-05-26 Thread Linus Walleij
On Mon, May 25, 2020 at 4:19 PM Kent Gibson  wrote:

> > > +struct gpioline_config {
> > > +   __u8 default_values[GPIOLINES_MAX];
> >
> > So 32 bytes
> >
>
> Actually that one is 64 bytes, which is the same as v1, i.e. GPIOLINES_MAX
> is the same as GPIOHANDLES_MAX - just renamed.
>
> On the subject of values, is there any reason to use a byte for each line
> rather value than a bit?

Not really, other than making things simple for userspace.

> when adding future fields, the idea was to have a bit
> in the flags that indicates that the corresponding field is now valid.
> If the flag is not set then whatever value is there is irrelevant.

You would need to document that idea, say in the kerneldoc,
else when someone else comes along to do this they will
get it wrong.

> But definitely better to play it safe - will check the padding is
> zeroed as well, as well as any field for which the flag bit is clear.

Yeah better like that. You can write a comment in the code too,
such like "when adding new parameters, update this validation code
to accept it".

> Back on retired ioctls, I notice that 5, 6, and 7 are missing from gpio.
> Have those been retired, or just skipped over by accident?

Just thought it was nice to use jump to 8 for line info.
They should be used when adding generic chip information ioctls().

Yours,
Linus Walleij


Re: [PATCH v1 2/5] clk: Introduce clk_round_rate_unboundly()

2020-05-26 Thread Stephen Boyd
Quoting Dmitry Osipenko (2020-03-30 16:16:14)
> In same cases it may be desired to round clock's rate without taking into
> account current min/max requests made by the clock's users. One example is
> building up OPP table based on a possible clock rates.
> 
> Signed-off-by: Dmitry Osipenko 
> ---
>  drivers/clk/clk.c   | 49 +++--
>  include/linux/clk.h | 18 +

BTW, please run get_maintainers.pl patches. Russell maintains
include/linux/clk.h (the clk API). CCF implements it.


Re: [PATCH V4 6/8] fs/ext4: Make DAX mount option a tri-state

2020-05-26 Thread Xiao Yang
On 2020/5/22 3:13, ira.we...@intel.com wrote:
> From: Ira Weiny
> 
> We add 'always', 'never', and 'inode' (default).  '-o dax' continues to
> operate the same which is equivalent to 'always'.  This new
> functionality is limited to ext4 only.
> 
> Specifically we introduce a 2nd DAX mount flag EXT4_MOUNT2_DAX_NEVER and set
> it and EXT4_MOUNT_DAX_ALWAYS appropriately for the mode.
> 
> We also force EXT4_MOUNT2_DAX_NEVER if !CONFIG_FS_DAX.
> 
> Finally, EXT4_MOUNT2_DAX_INODE is used solely to detect if the user
> specified that option for printing.
Hi Ira,

I have two questions when reviewing this patch:
1) After doing mount with the same dax=inode option, ext4/xfs shows
differnt output(i.e. xfs doesn't print 'dax=inode'):
---
# mount -o dax=inode /dev/pmem0 /mnt/xfstests/test/
# mount | grep pmem0
/dev/pmem0 on /mnt/xfstests/test type ext4 (rw,relatime,seclabel,dax=inode)

# mount -odax=inode /dev/pmem1 /mnt/xfstests/scratch/
# mount | grep pmem1
/dev/pmem1 on /mnt/xfstests/scratch type xfs
(rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota)

Is this expected output? why don't unify the output?

2) Do mount without dax and mount with -odax=inode have the same behavior?
---
# mount /dev/pmem0 /mnt/xfstests/test/
# mount | grep pmem0
/dev/pmem0 on /mnt/xfstests/test type ext4 (rw,relatime,seclabel)
# umount /mnt/xfstests/test
# mount -odax=inode /dev/pmem0 /mnt/xfstests/test/
# mount | grep pmem0
/dev/pmem0 on /mnt/xfstests/test type ext4 (rw,relatime,seclabel,dax=inode
---

BTW: I focus on the support of per-file/directory DAX operations recently.

> 
> Reviewed-by: Jan Kara
> Signed-off-by: Ira Weiny
> 
> ---
> Changes from V1:
>   Fix up mounting options to only show an option if specified
>   Fix remount to prevent dax changes
>   Isolate behavior to ext4 only
> 
> Changes from RFC:
>   Combine remount check for DAX_NEVER with DAX_ALWAYS
>   Update ext4_should_enable_dax()
> ---
>   fs/ext4/ext4.h  |  2 ++
>   fs/ext4/inode.c |  2 ++
>   fs/ext4/super.c | 67 +
>   3 files changed, 61 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index f5291693ce6e..65ffb831b2b9 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -1168,6 +1168,8 @@ struct ext4_inode_info {
> blocks */
>   #define EXT4_MOUNT2_HURD_COMPAT 0x0004 /* Support 
> HURD-castrated
> file systems */
> +#define EXT4_MOUNT2_DAX_NEVER0x0008 /* Do not allow 
> Direct Access */
> +#define EXT4_MOUNT2_DAX_INODE0x0010 /* For printing 
> options only */
> 
>   #define EXT4_MOUNT2_EXPLICIT_JOURNAL_CHECKSUM   0x0008 /* User 
> explicitly
>   specified journal checksum */
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 01636cf5f322..68fac9289109 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -4402,6 +4402,8 @@ static bool ext4_should_enable_dax(struct inode *inode)
>   {
>   struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
> 
> + if (test_opt2(inode->i_sb, DAX_NEVER))
> + return false;
>   if (!S_ISREG(inode->i_mode))
>   return false;
>   if (ext4_should_journal_data(inode))
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 80eb814c47eb..5e056aa20ce9 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -1512,7 +1512,8 @@ enum {
>   Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
>   Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
>   Opt_noquota, Opt_barrier, Opt_nobarrier, Opt_err,
> - Opt_usrquota, Opt_grpquota, Opt_prjquota, Opt_i_version, Opt_dax,
> + Opt_usrquota, Opt_grpquota, Opt_prjquota, Opt_i_version,
> + Opt_dax, Opt_dax_always, Opt_dax_inode, Opt_dax_never,
>   Opt_stripe, Opt_delalloc, Opt_nodelalloc, Opt_warn_on_error,
>   Opt_nowarn_on_error, Opt_mblk_io_submit,
>   Opt_lazytime, Opt_nolazytime, Opt_debug_want_extra_isize,
> @@ -1579,6 +1580,9 @@ static const match_table_t tokens = {
>   {Opt_nobarrier, "nobarrier"},
>   {Opt_i_version, "i_version"},
>   {Opt_dax, "dax"},
> + {Opt_dax_always, "dax=always"},
> + {Opt_dax_inode, "dax=inode"},
> + {Opt_dax_never, "dax=never"},
>   {Opt_stripe, "stripe=%u"},
>   {Opt_delalloc, "delalloc"},
>   {Opt_warn_on_error, "warn_on_error"},
> @@ -1726,6 +1730,7 @@ static int clear_qf_name(struct super_block *sb, int 
> qtype)
>   #define MOPT_NO_EXT30x0200
>   #define MOPT_EXT4_ONLY  (MOPT_NO_EXT2 | MOPT_NO_EXT3)
>   #define MOPT_STRING 0x0400
> +#define MOPT_SKIP0x0800
> 
>   static con

Re: [PATCH v1 2/5] clk: Introduce clk_round_rate_unboundly()

2020-05-26 Thread Stephen Boyd
Quoting Dmitry Osipenko (2020-03-30 16:16:14)
> In same cases it may be desired to round clock's rate without taking into
> account current min/max requests made by the clock's users. One example is
> building up OPP table based on a possible clock rates.

Shouldn't the OPP table come from firmware/DT? I don't quite understand
why we're generating OPP tables on top of the rate rounding API.
clk_round_rate() is supposed to tell us what rate we'll get if we call
clk_set_rate() with the same arguments. An unboundly version of that
doesn't make sense. 

I wonder if perhaps the clk provider should be populating OPP tables in
this case? Or basically anything besides adding another clk consumer API
to solve this problem. Who is the caller? Something later in this
series?


[PATCH v6 2/5] remoteproc: qcom: Introduce helper to store pil info in IMEM

2020-05-26 Thread Bjorn Andersson
A region in IMEM is used to communicate load addresses of remoteproc to
post mortem debug tools. Implement a helper function that can be used to
store this information in order to enable these tools to process
collected ramdumps.

Reviewed-by: Mathieu Poirier 
Reviewed-by: Vinod Koul 
Signed-off-by: Bjorn Andersson 
---

Changes since v5:
- Picked up reviewed-bys

 drivers/remoteproc/Kconfig |   3 +
 drivers/remoteproc/Makefile|   1 +
 drivers/remoteproc/qcom_pil_info.c | 124 +
 drivers/remoteproc/qcom_pil_info.h |   7 ++
 4 files changed, 135 insertions(+)
 create mode 100644 drivers/remoteproc/qcom_pil_info.c
 create mode 100644 drivers/remoteproc/qcom_pil_info.h

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index c4d1731295eb..f4bd96d1a1a3 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -116,6 +116,9 @@ 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_PIL_INFO
+   tristate
+
 config QCOM_RPROC_COMMON
tristate
 
diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
index e8b886e511f0..fe398f82d550 100644
--- a/drivers/remoteproc/Makefile
+++ b/drivers/remoteproc/Makefile
@@ -16,6 +16,7 @@ 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_PIL_INFO)+= qcom_pil_info.o
 obj-$(CONFIG_QCOM_RPROC_COMMON)+= qcom_common.o
 obj-$(CONFIG_QCOM_Q6V5_COMMON) += qcom_q6v5.o
 obj-$(CONFIG_QCOM_Q6V5_ADSP)   += qcom_q6v5_adsp.o
diff --git a/drivers/remoteproc/qcom_pil_info.c 
b/drivers/remoteproc/qcom_pil_info.c
new file mode 100644
index ..0785c7cde2d3
--- /dev/null
+++ b/drivers/remoteproc/qcom_pil_info.c
@@ -0,0 +1,124 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2019-2020 Linaro Ltd.
+ */
+#include 
+#include 
+#include 
+#include 
+
+#define PIL_RELOC_NAME_LEN 8
+
+struct pil_reloc_entry {
+   char name[PIL_RELOC_NAME_LEN];
+   __le64 base;
+   __le32 size;
+} __packed;
+
+struct pil_reloc {
+   struct device *dev;
+   void __iomem *base;
+   size_t num_entries;
+};
+
+static struct pil_reloc _reloc __read_mostly;
+static DEFINE_MUTEX(reloc_mutex);
+
+static int qcom_pil_info_init(void)
+{
+   struct device_node *np;
+   struct resource imem;
+   void __iomem *base;
+   int ret;
+
+   /* Already initialized? */
+   if (_reloc.base)
+   return 0;
+
+   np = of_find_compatible_node(NULL, NULL, "qcom,pil-reloc-info");
+   if (!np)
+   return -ENOENT;
+
+   ret = of_address_to_resource(np, 0, &imem);
+   of_node_put(np);
+   if (ret < 0)
+   return ret;
+
+   base = ioremap(imem.start, resource_size(&imem));
+   if (!base) {
+   pr_err("failed to map PIL relocation info region\n");
+   return -ENOMEM;
+   }
+
+   memset_io(base, 0, resource_size(&imem));
+
+   _reloc.base = base;
+   _reloc.num_entries = resource_size(&imem) / sizeof(struct 
pil_reloc_entry);
+
+   return 0;
+}
+
+/**
+ * qcom_pil_info_store() - store PIL information of image in IMEM
+ * @image: name of the image
+ * @base:  base address of the loaded image
+ * @size:  size of the loaded image
+ *
+ * Return: 0 on success, negative errno on failure
+ */
+int qcom_pil_info_store(const char *image, phys_addr_t base, size_t size)
+{
+   char buf[PIL_RELOC_NAME_LEN];
+   void __iomem *entry;
+   int ret;
+   int i;
+
+   mutex_lock(&reloc_mutex);
+   ret = qcom_pil_info_init();
+   if (ret < 0) {
+   mutex_unlock(&reloc_mutex);
+   return ret;
+   }
+
+   for (i = 0; i < _reloc.num_entries; i++) {
+   entry = _reloc.base + i * sizeof(struct pil_reloc_entry);
+
+   memcpy_fromio(buf, entry, PIL_RELOC_NAME_LEN);
+
+   /*
+* An empty record means we didn't find it, given that the
+* records are packed.
+*/
+   if (!buf[0])
+   goto found_unused;
+
+   if (!strncmp(buf, image, PIL_RELOC_NAME_LEN))
+   goto found_existing;
+   }
+
+   pr_warn("insufficient PIL info slots\n");
+   mutex_unlock(&reloc_mutex);
+   return -ENOMEM;
+
+found_unused:
+   memcpy_toio(entry, image, PIL_RELOC_NAME_LEN);
+found_existing:
+   writel(base, entry + offsetof(struct pil_reloc_entry, base));
+   writel(size, entry + offsetof(struct pil_reloc_entry, size));
+   mutex_unlock(&reloc_mutex);
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(qcom_pil_info_

[PATCH v6 5/5] arm64: dts: qcom: sdm845: Add IMEM and PIL info region

2020-05-26 Thread Bjorn Andersson
Add a simple-mfd representing IMEM on SDM845 and define the PIL
relocation info region, so that post mortem tools will be able to locate
the loaded remoteprocs.

Reviewed-by: Stephen Boyd 
Reviewed-by: Vinod Koul 
Signed-off-by: Bjorn Andersson 
---

Changes since v5:
- Picked up reviewed-bys

 arch/arm64/boot/dts/qcom/sdm845.dtsi | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi 
b/arch/arm64/boot/dts/qcom/sdm845.dtsi
index 8eb5a31346d2..fee50d979dc3 100644
--- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
@@ -3724,6 +3724,21 @@ spmi_bus: spmi@c44 {
cell-index = <0>;
};
 
+   imem@146bf000 {
+   compatible = "simple-mfd";
+   reg = <0 0x146bf000 0 0x1000>;
+
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   ranges = <0 0 0x146bf000 0x1000>;
+
+   pil-reloc@94c {
+   compatible = "qcom,pil-reloc-info";
+   reg = <0x94c 0xc8>;
+   };
+   };
+
apps_smmu: iommu@1500 {
compatible = "qcom,sdm845-smmu-500", "arm,mmu-500";
reg = <0 0x1500 0 0x8>;
-- 
2.26.2



[PATCH v6 4/5] arm64: dts: qcom: qcs404: Add IMEM and PIL info region

2020-05-26 Thread Bjorn Andersson
Add a simple-mfd representing IMEM on QCS404 and define the PIL
relocation info region, so that post mortem tools will be able to locate
the loaded remoteprocs.

Reviewed-by: Stephen Boyd 
Reviewed-by: Vinod Koul 
Signed-off-by: Bjorn Andersson 
---

Changes since v5:
- Picked up reviewed-bys

 arch/arm64/boot/dts/qcom/qcs404.dtsi | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/qcs404.dtsi 
b/arch/arm64/boot/dts/qcom/qcs404.dtsi
index c685a1664810..b654b802e95c 100644
--- a/arch/arm64/boot/dts/qcom/qcs404.dtsi
+++ b/arch/arm64/boot/dts/qcom/qcs404.dtsi
@@ -1097,6 +1097,21 @@ blsp2_spi0: spi@7af5000 {
status = "disabled";
};
 
+   imem@860 {
+   compatible = "simple-mfd";
+   reg = <0x0860 0x1000>;
+
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   ranges = <0 0x0860 0x1000>;
+
+   pil-reloc@94c {
+   compatible = "qcom,pil-reloc-info";
+   reg = <0x94c 0xc8>;
+   };
+   };
+
intc: interrupt-controller@b00 {
compatible = "qcom,msm-qgic2";
interrupt-controller;
-- 
2.26.2



[PATCH v6 3/5] remoteproc: qcom: Update PIL relocation info on load

2020-05-26 Thread Bjorn Andersson
Update the PIL relocation information in IMEM with information about
where the firmware for various remoteprocs are loaded.

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

Changes since v5:
- Added select QCOM_PIL_INFO to all relevant Kconfig options
- Replaced mem_reloc with mem_phys, to get the start of the memory region,
  rather than the bottom address prior to relocation.
- Include qcom_pil_info.h in qcom_q6v5_wcss.c

 drivers/remoteproc/Kconfig  |  5 +
 drivers/remoteproc/qcom_q6v5_adsp.c | 16 +---
 drivers/remoteproc/qcom_q6v5_mss.c  |  3 +++
 drivers/remoteproc/qcom_q6v5_pas.c  | 15 ---
 drivers/remoteproc/qcom_q6v5_wcss.c | 14 +++---
 drivers/remoteproc/qcom_wcnss.c | 14 +++---
 6 files changed, 55 insertions(+), 12 deletions(-)

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index f4bd96d1a1a3..3e8d5d1a2b9e 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -135,6 +135,7 @@ config QCOM_Q6V5_ADSP
depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n
depends on QCOM_SYSMON || QCOM_SYSMON=n
select MFD_SYSCON
+   select QCOM_PIL_INFO
select QCOM_MDT_LOADER
select QCOM_Q6V5_COMMON
select QCOM_RPROC_COMMON
@@ -151,6 +152,7 @@ config QCOM_Q6V5_MSS
depends on QCOM_SYSMON || QCOM_SYSMON=n
select MFD_SYSCON
select QCOM_MDT_LOADER
+   select QCOM_PIL_INFO
select QCOM_Q6V5_COMMON
select QCOM_Q6V5_IPA_NOTIFY
select QCOM_RPROC_COMMON
@@ -167,6 +169,7 @@ config QCOM_Q6V5_PAS
depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n
depends on QCOM_SYSMON || QCOM_SYSMON=n
select MFD_SYSCON
+   select QCOM_PIL_INFO
select QCOM_MDT_LOADER
select QCOM_Q6V5_COMMON
select QCOM_RPROC_COMMON
@@ -185,6 +188,7 @@ config QCOM_Q6V5_WCSS
depends on QCOM_SYSMON || QCOM_SYSMON=n
select MFD_SYSCON
select QCOM_MDT_LOADER
+   select QCOM_PIL_INFO
select QCOM_Q6V5_COMMON
select QCOM_RPROC_COMMON
select QCOM_SCM
@@ -218,6 +222,7 @@ config QCOM_WCNSS_PIL
depends on QCOM_SMEM
depends on QCOM_SYSMON || QCOM_SYSMON=n
select QCOM_MDT_LOADER
+   select QCOM_PIL_INFO
select QCOM_RPROC_COMMON
select QCOM_SCM
help
diff --git a/drivers/remoteproc/qcom_q6v5_adsp.c 
b/drivers/remoteproc/qcom_q6v5_adsp.c
index d2a2574dcf35..efb2c1aa80a3 100644
--- a/drivers/remoteproc/qcom_q6v5_adsp.c
+++ b/drivers/remoteproc/qcom_q6v5_adsp.c
@@ -26,6 +26,7 @@
 #include 
 
 #include "qcom_common.h"
+#include "qcom_pil_info.h"
 #include "qcom_q6v5.h"
 #include "remoteproc_internal.h"
 
@@ -82,6 +83,7 @@ struct qcom_adsp {
unsigned int halt_lpass;
 
int crash_reason_smem;
+   const char *info_name;
 
struct completion start_done;
struct completion stop_done;
@@ -164,10 +166,17 @@ static int qcom_adsp_shutdown(struct qcom_adsp *adsp)
 static int adsp_load(struct rproc *rproc, const struct firmware *fw)
 {
struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv;
+   int ret;
+
+   ret = qcom_mdt_load_no_init(adsp->dev, fw, rproc->firmware, 0,
+   adsp->mem_region, adsp->mem_phys,
+   adsp->mem_size, &adsp->mem_reloc);
+   if (ret)
+   return ret;
+
+   qcom_pil_info_store(adsp->info_name, adsp->mem_phys, adsp->mem_size);
 
-   return qcom_mdt_load_no_init(adsp->dev, fw, rproc->firmware, 0,
-adsp->mem_region, adsp->mem_phys, adsp->mem_size,
-&adsp->mem_reloc);
+   return 0;
 }
 
 static int adsp_start(struct rproc *rproc)
@@ -436,6 +445,7 @@ static int adsp_probe(struct platform_device *pdev)
adsp = (struct qcom_adsp *)rproc->priv;
adsp->dev = &pdev->dev;
adsp->rproc = rproc;
+   adsp->info_name = desc->sysmon_name;
platform_set_drvdata(pdev, adsp);
 
ret = adsp_alloc_memory_region(adsp);
diff --git a/drivers/remoteproc/qcom_q6v5_mss.c 
b/drivers/remoteproc/qcom_q6v5_mss.c
index feb70283b6a2..dd37e462ed61 100644
--- a/drivers/remoteproc/qcom_q6v5_mss.c
+++ b/drivers/remoteproc/qcom_q6v5_mss.c
@@ -29,6 +29,7 @@
 
 #include "remoteproc_internal.h"
 #include "qcom_common.h"
+#include "qcom_pil_info.h"
 #include "qcom_q6v5.h"
 
 #include 
@@ -1189,6 +1190,8 @@ static int q6v5_mpss_load(struct q6v5 *qproc)
else if (ret < 0)
dev_err(qproc->dev, "MPSS authentication failed: %d\n", ret);
 
+   qcom_pil_info_store("modem", qproc->mpss_phys, qproc->mpss_size);
+
 release_firmware:
release_firmware(fw);
 out:
diff --git a/drivers/remoteproc/qcom_q6v5_pas.c 
b/drivers/remoteproc/qcom_q6v5_pas.c
index 61791a03f648..3837f23995e0 100644
--- a/drivers/remoteproc/qcom_q6v5_pas.c
+++ b/drivers/remoteproc/qcom_q6v5_pas.c
@@ -25,6

[PATCH v6 1/5] dt-bindings: remoteproc: Add Qualcomm PIL info binding

2020-05-26 Thread Bjorn Andersson
Add a devicetree binding for the Qualcomm peripheral image loader
relocation information region found in the IMEM.

Reviewed-by: Mathieu Poirier 
Reviewed-by: Rob Herring 
Reviewed-by: Stephen Boyd 
Reviewed-by: Vinod Koul 
Signed-off-by: Bjorn Andersson 
---

Changes since v5:
- Picked up reviewed-bys

 .../bindings/remoteproc/qcom,pil-info.yaml| 44 +++
 1 file changed, 44 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/remoteproc/qcom,pil-info.yaml

diff --git a/Documentation/devicetree/bindings/remoteproc/qcom,pil-info.yaml 
b/Documentation/devicetree/bindings/remoteproc/qcom,pil-info.yaml
new file mode 100644
index ..87c52316ddbd
--- /dev/null
+++ b/Documentation/devicetree/bindings/remoteproc/qcom,pil-info.yaml
@@ -0,0 +1,44 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/remoteproc/qcom,pil-info.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm peripheral image loader relocation info binding
+
+maintainers:
+  - Bjorn Andersson 
+
+description:
+  The Qualcomm peripheral image loader relocation memory region, in IMEM, is
+  used for communicating remoteproc relocation information to post mortem
+  debugging tools.
+
+properties:
+  compatible:
+const: qcom,pil-reloc-info
+
+  reg:
+maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+imem@146bf000 {
+  compatible = "syscon", "simple-mfd";
+  reg = <0x146bf000 0x1000>;
+
+  #address-cells = <1>;
+  #size-cells = <1>;
+
+  ranges = <0 0x146bf000 0x1000>;
+
+  pil-reloc@94c {
+compatible = "qcom,pil-reloc-info";
+reg = <0x94c 0xc8>;
+  };
+};
+...
-- 
2.26.2



[PATCH v6 0/5] remoteproc: qcom: PIL info support

2020-05-26 Thread Bjorn Andersson
Introduce support for filling out the relocation information in IMEM, to aid
post mortem debug tools to locate the various remoteprocs.

Bjorn Andersson (5):
  dt-bindings: remoteproc: Add Qualcomm PIL info binding
  remoteproc: qcom: Introduce helper to store pil info in IMEM
  remoteproc: qcom: Update PIL relocation info on load
  arm64: dts: qcom: qcs404: Add IMEM and PIL info region
  arm64: dts: qcom: sdm845: Add IMEM and PIL info region

 .../bindings/remoteproc/qcom,pil-info.yaml|  44 +++
 arch/arm64/boot/dts/qcom/qcs404.dtsi  |  15 +++
 arch/arm64/boot/dts/qcom/sdm845.dtsi  |  15 +++
 drivers/remoteproc/Kconfig|   8 ++
 drivers/remoteproc/Makefile   |   1 +
 drivers/remoteproc/qcom_pil_info.c| 124 ++
 drivers/remoteproc/qcom_pil_info.h|   7 +
 drivers/remoteproc/qcom_q6v5_adsp.c   |  16 ++-
 drivers/remoteproc/qcom_q6v5_mss.c|   3 +
 drivers/remoteproc/qcom_q6v5_pas.c|  15 ++-
 drivers/remoteproc/qcom_q6v5_wcss.c   |  14 +-
 drivers/remoteproc/qcom_wcnss.c   |  14 +-
 12 files changed, 264 insertions(+), 12 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/remoteproc/qcom,pil-info.yaml
 create mode 100644 drivers/remoteproc/qcom_pil_info.c
 create mode 100644 drivers/remoteproc/qcom_pil_info.h

-- 
2.26.2



Re: [PATCH] clk: versatile: remove redundant assignment to pointer clk

2020-05-26 Thread Linus Walleij
On Wed, May 27, 2020 at 12:41 AM Colin King  wrote:

> From: Colin Ian King 
>
> The pointer clk is being initialized with a value that is never read
> and is being updated with a new value later on. The initialization
> is redundant and can be removed.
>
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King 

Reviewed-by: Linus Walleij 

Yours,
Linus Walleij


general protection fault in start_creating

2020-05-26 Thread syzbot
Hello,

syzbot found the following crash on:

HEAD commit:c11d28ab Add linux-next specific files for 20200522
git tree:   linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=1135d53c10
kernel config:  https://syzkaller.appspot.com/x/.config?x=3f6dbdea4159fb66
dashboard link: https://syzkaller.appspot.com/bug?extid=705f4401d5a93a59b87d
compiler:   gcc (GCC) 9.0.0 20181231 (experimental)
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=110448d210

The bug was bisected to:

commit 63d04348371b7ea4a134bcf47c79763d969e9168
Author: Paolo Bonzini 
Date:   Tue Mar 31 22:42:22 2020 +

KVM: x86: move kvm_create_vcpu_debugfs after last failure point

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=1366069a10
final crash:https://syzkaller.appspot.com/x/report.txt?x=10e6069a10
console output: https://syzkaller.appspot.com/x/log.txt?x=1766069a10

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+705f4401d5a93a59b...@syzkaller.appspotmail.com
Fixes: 63d04348371b ("KVM: x86: move kvm_create_vcpu_debugfs after last failure 
point")

general protection fault, probably for non-canonical address 
0xdc2a:  [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0150-0x0157]
CPU: 0 PID: 8143 Comm: syz-executor.0 Not tainted 
5.7.0-rc6-next-20200522-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
01/01/2011
RIP: 0010:__lock_acquire+0xe1b/0x48a0 kernel/locking/lockdep.c:4250
Code: b6 0a 41 be 01 00 00 00 0f 86 ce 0b 00 00 89 05 ab 87 b6 0a e9 c3 0b 00 
00 48 b8 00 00 00 00 00 fc ff df 4c 89 d2 48 c1 ea 03 <80> 3c 02 00 0f 85 e5 2c 
00 00 49 81 3a 40 75 e5 8b 0f 84 b0 f2 ff
RSP: 0018:c900043cf7b8 EFLAGS: 00010002
RAX: dc00 RBX: 0001 RCX: 
RDX: 002a RSI:  RDI: 0150
RBP: 0001 R08: 0001 R09: 
R10: 0150 R11: 0001 R12: 
R13: 8880966f8240 R14:  R15: 
FS:  7f6300c10700() GS:8880ae60() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 7f6300bcbdb8 CR3: 92f4d000 CR4: 001426f0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
 lock_acquire+0x1f2/0x8f0 kernel/locking/lockdep.c:4959
 down_write+0x8d/0x150 kernel/locking/rwsem.c:1531
 inode_lock include/linux/fs.h:801 [inline]
 start_creating+0xa8/0x250 fs/debugfs/inode.c:334
 __debugfs_create_file+0x62/0x400 fs/debugfs/inode.c:383
 kvm_arch_create_vcpu_debugfs+0x9f/0x200 arch/x86/kvm/debugfs.c:52
 kvm_create_vcpu_debugfs arch/x86/kvm/../../../virt/kvm/kvm_main.c:2998 [inline]
 kvm_vm_ioctl_create_vcpu arch/x86/kvm/../../../virt/kvm/kvm_main.c:3075 
[inline]
 kvm_vm_ioctl+0x1c28/0x2460 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3603
 vfs_ioctl fs/ioctl.c:48 [inline]
 ksys_ioctl+0x11a/0x180 fs/ioctl.c:753
 __do_sys_ioctl fs/ioctl.c:762 [inline]
 __se_sys_ioctl fs/ioctl.c:760 [inline]
 __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:760
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3
RIP: 0033:0x45ca29
Code: 0d b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 
89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 
db b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:7f6300c0fc78 EFLAGS: 0246 ORIG_RAX: 0010
RAX: ffda RBX: 004e73c0 RCX: 0045ca29
RDX:  RSI: ae41 RDI: 0005
RBP: 0078bf00 R08:  R09: 
R10:  R11: 0246 R12: 
R13: 0396 R14: 004c62c6 R15: 7f6300c106d4
Modules linked in:
---[ end trace b2ea4e12631736e7 ]---
RIP: 0010:__lock_acquire+0xe1b/0x48a0 kernel/locking/lockdep.c:4250
Code: b6 0a 41 be 01 00 00 00 0f 86 ce 0b 00 00 89 05 ab 87 b6 0a e9 c3 0b 00 
00 48 b8 00 00 00 00 00 fc ff df 4c 89 d2 48 c1 ea 03 <80> 3c 02 00 0f 85 e5 2c 
00 00 49 81 3a 40 75 e5 8b 0f 84 b0 f2 ff
RSP: 0018:c900043cf7b8 EFLAGS: 00010002
RAX: dc00 RBX: 0001 RCX: 
RDX: 002a RSI:  RDI: 0150
RBP: 0001 R08: 0001 R09: 
R10: 0150 R11: 0001 R12: 
R13: 8880966f8240 R14:  R15: 
FS:  7f6300c10700() GS:8880ae60() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 7f6300bcbdb8 CR3: 92f4d000 CR4: 001426f0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 000

Re: [RFC] perf/core: allow ftrace for functions in kernel/event/core.c

2020-05-26 Thread Masami Hiramatsu
On Tue, 26 May 2020 21:46:29 +
Song Liu  wrote:

> 
> 
> > On May 26, 2020, at 2:39 PM, Peter Zijlstra  wrote:
> > 
> > On Tue, May 26, 2020 at 02:28:26PM -0700, Song Liu wrote:
> >> It is useful to trace functions in kernel/event/core.c. Allow ftrace for
> >> them by removing $(CC_FLAGS_FTRACE) from Makefile.
> > 
> > Did you try using the ftrace event with perf with this on?
> 
> I have tried a few things, like 
> 
>   perf stat -e probe:perf_read -I 1000
>   perf record -e probe:__x64_sys_perf_event_open -aR
> 
> They all work fine. 

Did you try using perf with function-tracer or function-graph tracer?
If you just want to trace those functions with kprobes, you can 
build your kernel with CONFIG_KPROBE_EVENTS_ON_NOTRACE=y, which allows
you to probe perf_read etc.

Thank you,


-- 
Masami Hiramatsu 


Re: [PATCH] perf jvmti: remove redundant jitdump line table entries

2020-05-26 Thread Nick Gasson
On 05/27/20 13:03 PM, Ian Rogers wrote:
>
> Great result, thanks! I note there is a lack of symbolization when
> benchmarking a few Java applications. I'll try to see if there's a
> sensible resolution for those.
>

I noticed it loses information when the Hotspot code cache is
resized. I've been working around that by setting
-XX:InitialCodeCacheSize and -XX:ReservedCodeCacheSize to large
values. Does this help in your case?

>
> It'd be better to make this into two patches. Also on acme's perf/core
> branch if possible:
> https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/log/?h=perf/core

OK sure, I'll do that.

--
Nick


Re: [PATCH V2] PCI: qcom: Improve exception handling in qcom_pcie_probe()

2020-05-26 Thread Markus Elfring
> 1. pm_runtime_put() …
…
> 2. pm_runtime_disable() …

How do you think about to add blank lines for such enumeration items
and to indent the text below the numbers?


> Co-developed-by: Markus Elfring 

Will our collaboration evolve in more ways besides patch review?

Regards,
Markus


[RESEND PATCH v2 1/4] clk: sprd: check its parent status before reading gate clock

2020-05-26 Thread Chunyan Zhang
From: Chunyan Zhang 

Some clocks only can be accessed if their parent is enabled. mipi_csi_xx
clocks on SC9863A are an examples. We have to ensure the parent clock is
enabled when reading those clocks.

Signed-off-by: Chunyan Zhang 
---
 drivers/clk/sprd/gate.c | 7 +++
 drivers/clk/sprd/gate.h | 9 +
 2 files changed, 16 insertions(+)

diff --git a/drivers/clk/sprd/gate.c b/drivers/clk/sprd/gate.c
index 574cfc116bbc..56e1714b541e 100644
--- a/drivers/clk/sprd/gate.c
+++ b/drivers/clk/sprd/gate.c
@@ -94,8 +94,15 @@ static int sprd_gate_is_enabled(struct clk_hw *hw)
 {
struct sprd_gate *sg = hw_to_sprd_gate(hw);
struct sprd_clk_common *common = &sg->common;
+   struct clk_hw *parent;
unsigned int reg;
 
+   if (sg->flags & SPRD_GATE_NON_AON) {
+   parent = clk_hw_get_parent(hw);
+   if (!parent || !clk_hw_is_enabled(parent))
+   return 0;
+   }
+
regmap_read(common->regmap, common->reg, ®);
 
if (sg->flags & CLK_GATE_SET_TO_DISABLE)
diff --git a/drivers/clk/sprd/gate.h b/drivers/clk/sprd/gate.h
index b55817869367..e738dafa4fe9 100644
--- a/drivers/clk/sprd/gate.h
+++ b/drivers/clk/sprd/gate.h
@@ -19,6 +19,15 @@ struct sprd_gate {
struct sprd_clk_common  common;
 };
 
+/*
+ * sprd_gate->flags is used for:
+ * CLK_GATE_SET_TO_DISABLE BIT(0)
+ * CLK_GATE_HIWORD_MASKBIT(1)
+ * CLK_GATE_BIG_ENDIAN BIT(2)
+ * so we define new flags from BIT(3)
+ */
+#define SPRD_GATE_NON_AON BIT(3) /* not alway powered on, check before read */
+
 #define SPRD_SC_GATE_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, \
_sc_offset, _enable_mask, _flags,   \
_gate_flags, _udelay, _ops, _fn)\
-- 
2.20.1



[RESEND PATCH v2 4/4] clk: sprd: add mipi_csi_xx gate clocks

2020-05-26 Thread Chunyan Zhang
From: Chunyan Zhang 

mipi_csi_xx clocks are used by camera sensors.

Signed-off-by: Chunyan Zhang 
---
 drivers/clk/sprd/sc9863a-clk.c | 32 
 1 file changed, 32 insertions(+)

diff --git a/drivers/clk/sprd/sc9863a-clk.c b/drivers/clk/sprd/sc9863a-clk.c
index a0631f7756cf..f67bd08f225c 100644
--- a/drivers/clk/sprd/sc9863a-clk.c
+++ b/drivers/clk/sprd/sc9863a-clk.c
@@ -1615,6 +1615,36 @@ static const struct sprd_clk_desc sc9863a_mm_gate_desc = 
{
.hw_clks= &sc9863a_mm_gate_hws,
 };
 
+/* camera sensor clocks */
+static SPRD_GATE_CLK_HW(mipi_csi_clk, "mipi-csi-clk", &mahb_ckg_eb.common.hw,
+   0x20, BIT(16), 0, SPRD_GATE_NON_AON);
+static SPRD_GATE_CLK_HW(mipi_csi_s_clk, "mipi-csi-s-clk", 
&mahb_ckg_eb.common.hw,
+   0x24, BIT(16), 0, SPRD_GATE_NON_AON);
+static SPRD_GATE_CLK_HW(mipi_csi_m_clk, "mipi-csi-m-clk", 
&mahb_ckg_eb.common.hw,
+   0x28, BIT(16), 0, SPRD_GATE_NON_AON);
+
+static struct sprd_clk_common *sc9863a_mm_clk_clks[] = {
+   /* address base is 0x6090 */
+   &mipi_csi_clk.common,
+   &mipi_csi_s_clk.common,
+   &mipi_csi_m_clk.common,
+};
+
+static struct clk_hw_onecell_data sc9863a_mm_clk_hws = {
+   .hws= {
+   [CLK_MIPI_CSI]  = &mipi_csi_clk.common.hw,
+   [CLK_MIPI_CSI_S]= &mipi_csi_s_clk.common.hw,
+   [CLK_MIPI_CSI_M]= &mipi_csi_m_clk.common.hw,
+   },
+   .num= CLK_MM_CLK_NUM,
+};
+
+static const struct sprd_clk_desc sc9863a_mm_clk_desc = {
+   .clk_clks   = sc9863a_mm_clk_clks,
+   .num_clk_clks   = ARRAY_SIZE(sc9863a_mm_clk_clks),
+   .hw_clks= &sc9863a_mm_clk_hws,
+};
+
 static SPRD_SC_GATE_CLK_FW_NAME(sim0_eb,   "sim0-eb",  "ext-26m", 0x0,
0x1000, BIT(0), 0, 0);
 static SPRD_SC_GATE_CLK_FW_NAME(iis0_eb,   "iis0-eb",  "ext-26m", 0x0,
@@ -1737,6 +1767,8 @@ static const struct of_device_id sprd_sc9863a_clk_ids[] = 
{
  .data = &sc9863a_aonapb_gate_desc },
{ .compatible = "sprd,sc9863a-mm-gate", /* 0x6080 */
  .data = &sc9863a_mm_gate_desc },
+   { .compatible = "sprd,sc9863a-mm-clk",  /* 0x6090 */
+ .data = &sc9863a_mm_clk_desc },
{ .compatible = "sprd,sc9863a-apapb-gate",  /* 0x7130 */
  .data = &sc9863a_apapb_gate_desc },
{ }
-- 
2.20.1



[RESEND PATCH v2 0/4] add mipi_csi_xx gate clocks for SC9863A

2020-05-26 Thread Chunyan Zhang
From: Chunyan Zhang 

mipi_csi_xx clocks are used by camera sensors. These clocks cannot be
accessed (even read) if their parent gate clock is disabled. So this
patchset also add a check to parent clocks when reading these gate
clocks which marked with the specific flag (SPRD_GATE_NON_AON).

changes from v1:
* added Rob's acked-by;

Chunyan Zhang (4):
  clk: sprd: check its parent status before reading gate clock
  dt-bindings: clk: sprd: add mipi_csi_xx clocks for SC9863A
  clk: sprd: add dt-bindings include for mipi_csi_xx clocks
  clk: sprd: add mipi_csi_xx gate clocks

 .../bindings/clock/sprd,sc9863a-clk.yaml  |  1 +
 drivers/clk/sprd/gate.c   |  7 
 drivers/clk/sprd/gate.h   |  9 ++
 drivers/clk/sprd/sc9863a-clk.c| 32 +++
 include/dt-bindings/clock/sprd,sc9863a-clk.h  |  5 +++
 5 files changed, 54 insertions(+)

-- 
2.20.1



[RESEND PATCH v2 2/4] dt-bindings: clk: sprd: add mipi_csi_xx clocks for SC9863A

2020-05-26 Thread Chunyan Zhang
From: Chunyan Zhang 

mipi_csi_xx clocks are used by camera sensors.

Signed-off-by: Chunyan Zhang 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml 
b/Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml
index bb3a78d8105e..87e8349a539a 100644
--- a/Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml
+++ b/Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml
@@ -28,6 +28,7 @@ properties:
   - sprd,sc9863a-rpll
   - sprd,sc9863a-dpll
   - sprd,sc9863a-mm-gate
+  - sprd,sc9863a-mm-clk
   - sprd,sc9863a-apapb-gate
 
   clocks:
-- 
2.20.1



[RESEND PATCH v2 3/4] clk: sprd: add dt-bindings include for mipi_csi_xx clocks

2020-05-26 Thread Chunyan Zhang
From: Chunyan Zhang 

mipi_csi_xx clocks are used by camera sensors.

Signed-off-by: Chunyan Zhang 
Acked-by: Rob Herring 
---
 include/dt-bindings/clock/sprd,sc9863a-clk.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/dt-bindings/clock/sprd,sc9863a-clk.h 
b/include/dt-bindings/clock/sprd,sc9863a-clk.h
index 901ba59676c2..4e030421641f 100644
--- a/include/dt-bindings/clock/sprd,sc9863a-clk.h
+++ b/include/dt-bindings/clock/sprd,sc9863a-clk.h
@@ -308,6 +308,11 @@
 #define CLK_MCPHY_CFG_EB   14
 #define CLK_MM_GATE_NUM(CLK_MCPHY_CFG_EB + 1)
 
+#define CLK_MIPI_CSI   0
+#define CLK_MIPI_CSI_S 1
+#define CLK_MIPI_CSI_M 2
+#define CLK_MM_CLK_NUM (CLK_MIPI_CSI_M + 1)
+
 #define CLK_SIM0_EB0
 #define CLK_IIS0_EB1
 #define CLK_IIS1_EB2
-- 
2.20.1



Re: [PATCH] gpiolib: add GPIO_SET_DEBOUNCE_IOCTL

2020-05-26 Thread Linus Walleij
On Mon, May 25, 2020 at 5:17 PM Kent Gibson  wrote:

> > I suppose gpiolib would have to steal or intercept the interrupt
> > by using e.g. IRQF_SHARED and then just return IRQ_HANDLED
> > on the first IRQ so the underlying irq handler does not get called.
>
> And how would gpiolib ensure that it was first in the chain?

I don't know.

> Totally agree with the concept - just trying to work out how to
> implement it seemlessly given the existing API and usage, and given my
> limited knowledge of the kernel internals.

The irqchip maintainers certainly know the answer for the question
of shared interrupts at least.

> > Failure is an option! Sorry if I push too complex ideas.
>
> I'm not as concerned about complexity as I am about fragility.
>
> I don't see any problem adding debounce for gpiolib-cdev.
> Adding a more complete solution to gpiolib itself is certainly
> non-trivial, if it is possible at all.

I agree. It's just that I perceive it as more elegant if we can do that.

> The path I'll probably be taking is adding a debouncer to gpiolib-cdev,
> so at least we have a solution for userspace, then take a longer look at
> the more general solution.

That's fine! Thanks for looking into this.

Linus Walleij


Re: [PATCH] perf jvmti: remove redundant jitdump line table entries

2020-05-26 Thread Nick Gasson
On 05/26/20 19:55 PM, Jiri Olsa wrote:
> On Fri, May 22, 2020 at 02:53:30PM +0800, Nick Gasson wrote:
>> For each PC/BCI pair in the JVMTI compiler inlining record table, the
>> jitdump plugin emits debug line table entries for every source line in
>> the method preceding that BCI. Instead only emit one source line per
>> PC/BCI pair. Reported by Ian Rogers. This reduces the .dump size for
>> SPECjbb from ~230MB to ~40MB.
>> 
>> Also fix an error in the DWARF line table state machine where addresses
>> are incorrectly offset by -0x40 (GEN_ELF_TEXT_OFFSET). This can be seen
>> with `objdump -S` on the ELF files after perf inject.
>
> hi,
> I can't apply this on latest Arnaldo's perf/core:
>
> patching file jvmti/libjvmti.c
> Hunk #1 FAILED at 32.
> Hunk #2 succeeded at 67 (offset -4 lines).
> Hunk #3 FAILED at 85.
> Hunk #4 succeeded at 114 (offset -7 lines).
>

Sorry I based this on my earlier patch series below but I didn't realise
that wasn't merged to perf/core yet. Could those patches be applied
first? I believe Ian added a Reviewed-by for all three.

https://lore.kernel.org/lkml/20200427061520.24905-3-nick.gas...@arm.com/T/


>
>> 
>> Signed-off-by: Nick Gasson 
>> ---
>>  tools/perf/jvmti/libjvmti.c| 73 +-
>>  tools/perf/util/genelf_debug.c |  4 +-
>>  2 files changed, 30 insertions(+), 47 deletions(-)
>> 
>> diff --git a/tools/perf/jvmti/libjvmti.c b/tools/perf/jvmti/libjvmti.c
>> index a9a056d68416..398e4ba6498d 100644
>> --- a/tools/perf/jvmti/libjvmti.c
>> +++ b/tools/perf/jvmti/libjvmti.c
>> @@ -32,38 +32,41 @@ static void print_error(jvmtiEnv *jvmti, const char 
>> *msg, jvmtiError ret)
>>  
>>  #ifdef HAVE_JVMTI_CMLR
>>  static jvmtiError
>> -do_get_line_numbers(jvmtiEnv *jvmti, void *pc, jmethodID m, jint bci,
>> -jvmti_line_info_t *tab, jint *nr)
>> +do_get_line_number(jvmtiEnv *jvmti, void *pc, jmethodID m, jint bci,
>> +   jvmti_line_info_t *tab)
>>  {
>> -jint i, lines = 0;
>> -jint nr_lines = 0;
>> +jint i, nr_lines = 0;
>>  jvmtiLineNumberEntry *loc_tab = NULL;
>>  jvmtiError ret;
>> +jint src_line = -1;
>>  
>>  ret = (*jvmti)->GetLineNumberTable(jvmti, m, &nr_lines, &loc_tab);
>>  if (ret == JVMTI_ERROR_ABSENT_INFORMATION || ret == 
>> JVMTI_ERROR_NATIVE_METHOD) {
>>  /* No debug information for this method */
>> -*nr = 0;
>> -return JVMTI_ERROR_NONE;
>> +return ret;
>>  } else if (ret != JVMTI_ERROR_NONE) {
>>  print_error(jvmti, "GetLineNumberTable", ret);
>>  return ret;
>>  }
>>  
>> -for (i = 0; i < nr_lines; i++) {
>> -if (loc_tab[i].start_location < bci) {
>> -tab[lines].pc = (unsigned long)pc;
>> -tab[lines].line_number = loc_tab[i].line_number;
>> -tab[lines].discrim = 0; /* not yet used */
>> -tab[lines].methodID = m;
>> -lines++;
>> -} else {
>> -break;
>> -}
>> +for (i = 0; i < nr_lines && loc_tab[i].start_location <= bci; i++) {
>> +src_line = i;
>> +}
>> +
>> +if (src_line != -1) {
>> +tab->pc = (unsigned long)pc;
>> +tab->line_number = loc_tab[src_line].line_number;
>> +tab->discrim = 0; /* not yet used */
>> +tab->methodID = m;
>> +
>> +ret = JVMTI_ERROR_NONE;
>> +} else {
>> +ret = JVMTI_ERROR_ABSENT_INFORMATION;
>>  }
>> +
>>  (*jvmti)->Deallocate(jvmti, (unsigned char *)loc_tab);
>> -*nr = lines;
>> -return JVMTI_ERROR_NONE;
>> +
>> +return ret;
>>  }
>>  
>>  static jvmtiError
>> @@ -71,9 +74,8 @@ get_line_numbers(jvmtiEnv *jvmti, const void 
>> *compile_info, jvmti_line_info_t **
>>  {
>>  const jvmtiCompiledMethodLoadRecordHeader *hdr;
>>  jvmtiCompiledMethodLoadInlineRecord *rec;
>> -jvmtiLineNumberEntry *lne = NULL;
>>  PCStackInfo *c;
>> -jint nr, ret;
>> +jint ret;
>>  int nr_total = 0;
>>  int i, lines_total = 0;
>>  
>> @@ -86,24 +88,7 @@ get_line_numbers(jvmtiEnv *jvmti, const void 
>> *compile_info, jvmti_line_info_t **
>>  for (hdr = compile_info; hdr != NULL; hdr = hdr->next) {
>>  if (hdr->kind == JVMTI_CMLR_INLINE_INFO) {
>>  rec = (jvmtiCompiledMethodLoadInlineRecord *)hdr;
>> -for (i = 0; i < rec->numpcs; i++) {
>> -c = rec->pcinfo + i;
>> -nr = 0;
>> -/*
>> - * unfortunately, need a tab to get the number 
>> of lines!
>> - */
>> -ret = (*jvmti)->GetLineNumberTable(jvmti, 
>> c->methods[0], &nr, &lne);
>> -if (ret == JVMTI_ERROR_NONE) {
>> -/* free what was allocated for nothing 
>> */
>>

[PATCH 0/2] Bugy bootloader woraround

2020-05-26 Thread Jiaxun Yang
Jiaxun Yang (2):
  MIPS: head.S: Always jump to kernel_entry at head of text
  MIPS: Loongso64: select NO_EXCEPT_FILL

 arch/mips/Kconfig   | 1 +
 arch/mips/kernel/head.S | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)

-- 
2.27.0.rc0



[PATCH 1/2] MIPS: head.S: Always jump to kernel_entry at head of text

2020-05-26 Thread Jiaxun Yang
Buggy loaders like early version of PMON2000 sometimes ignore
elf_entry and goto start of text directly.

That would help with dealing with these loaders.

Signed-off-by: Jiaxun Yang 
---
 arch/mips/kernel/head.S | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
index 3b02ffe46304..c7c2795837e7 100644
--- a/arch/mips/kernel/head.S
+++ b/arch/mips/kernel/head.S
@@ -69,7 +69,6 @@
 
 EXPORT(_stext)
 
-#ifdef CONFIG_BOOT_RAW
/*
 * Give us a fighting chance of running if execution beings at the
 * kernel load address.  This is needed because this platform does
@@ -77,7 +76,6 @@ EXPORT(_stext)
 */
 FEXPORT(__kernel_entry)
j   kernel_entry
-#endif /* CONFIG_BOOT_RAW */
 
__REF
 
-- 
2.27.0.rc0



[PATCH 2/2] MIPS: Loongso64: select NO_EXCEPT_FILL

2020-05-26 Thread Jiaxun Yang
Loongson64 load kernel at 0x8200 and allocate exception vectors
by ebase. So we don't need to reserve space for exception vectors
at head of kernel.

Signed-off-by: Jiaxun Yang 
---
 arch/mips/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 3ca59b610a67..0e385f7b7691 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -462,6 +462,7 @@ config MACH_LOONGSON64
select IRQ_MIPS_CPU
select NR_CPUS_DEFAULT_64
select USE_GENERIC_EARLY_PRINTK_8250
+   select NO_EXCEPT_FILL
select SYS_HAS_CPU_LOONGSON64
select SYS_HAS_EARLY_PRINTK
select SYS_SUPPORTS_SMP
-- 
2.27.0.rc0



[PATCH 14/16] block: remove rcu_read_lock() from part_stat_lock()

2020-05-26 Thread Christoph Hellwig
From: Konstantin Khlebnikov 

The RCU lock is required only in disk_map_sector_rcu() to lookup the
partition.  After that request holds reference to related hd_struct.

Replace get_cpu() with preempt_disable() - returned cpu index is unused.

Signed-off-by: Konstantin Khlebnikov 
[hch: rebased]
Signed-off-by: Christoph Hellwig 
---
 block/genhd.c | 11 ---
 include/linux/part_stat.h |  4 ++--
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/block/genhd.c b/block/genhd.c
index 3e7df0a3e6bb0..1a76593276644 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -321,11 +321,12 @@ struct hd_struct *disk_map_sector_rcu(struct gendisk 
*disk, sector_t sector)
struct hd_struct *part;
int i;
 
+   rcu_read_lock();
ptbl = rcu_dereference(disk->part_tbl);
 
part = rcu_dereference(ptbl->last_lookup);
if (part && sector_in_part(part, sector) && hd_struct_try_get(part))
-   return part;
+   goto out_unlock;
 
for (i = 1; i < ptbl->len; i++) {
part = rcu_dereference(ptbl->part[i]);
@@ -339,10 +340,14 @@ struct hd_struct *disk_map_sector_rcu(struct gendisk 
*disk, sector_t sector)
if (!hd_struct_try_get(part))
break;
rcu_assign_pointer(ptbl->last_lookup, part);
-   return part;
+   goto out_unlock;
}
}
-   return &disk->part0;
+
+   part = &disk->part0;
+out_unlock:
+   rcu_read_unlock();
+   return part;
 }
 
 /**
diff --git a/include/linux/part_stat.h b/include/linux/part_stat.h
index 6644197980b92..a6b0938ce82e9 100644
--- a/include/linux/part_stat.h
+++ b/include/linux/part_stat.h
@@ -21,8 +21,8 @@ struct disk_stats {
  *
  * part_stat_read() can be called at any time.
  */
-#define part_stat_lock()   ({ rcu_read_lock(); get_cpu(); })
-#define part_stat_unlock() do { put_cpu(); rcu_read_unlock(); } while (0)
+#define part_stat_lock()   preempt_disable()
+#define part_stat_unlock() preempt_enable()
 
 #define part_stat_get_cpu(part, field, cpu)\
(per_cpu_ptr((part)->dkstats, (cpu))->field)
-- 
2.26.2



block I/O accounting improvements v2

2020-05-26 Thread Christoph Hellwig
Hi Jens,

they series contains various improvement for block I/O accounting.  The
first bunch of patches switch the bio based drivers to better accounting
helpers compared to the current mess.  The end contains a fix and various
performanc improvements.  Most of this comes from a series Konstantin
sent a few weeks ago, rebased on changes that landed in your tree since
and my change to always use the percpu version of the disk stats.


Changes since v1:
 - add an ifdef CONFIG_BLOCK to work around the sad state of our headers
 - add reviewed-by tags to all patches


[PATCH 12/16] block: account merge of two requests

2020-05-26 Thread Christoph Hellwig
From: Konstantin Khlebnikov 

Also rename blk_account_io_merge() into blk_account_io_merge_request() to
distinguish it from merging request and bio.

Signed-off-by: Konstantin Khlebnikov 
[hch: rebased]
Signed-off-by: Christoph Hellwig 
---
 block/blk-merge.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/block/blk-merge.c b/block/blk-merge.c
index 6a4538d39efd2..c3beae5c1be71 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -669,18 +669,16 @@ void blk_rq_set_mixed_merge(struct request *rq)
rq->rq_flags |= RQF_MIXED_MERGE;
 }
 
-static void blk_account_io_merge(struct request *req)
+static void blk_account_io_merge_request(struct request *req)
 {
if (blk_do_io_stat(req)) {
-   struct hd_struct *part;
-
part_stat_lock();
-   part = req->part;
-
-   hd_struct_put(part);
+   part_stat_inc(req->part, merges[op_stat_group(req_op(req))]);
+   hd_struct_put(req->part);
part_stat_unlock();
}
 }
+
 /*
  * Two cases of handling DISCARD merge:
  * If max_discard_segments > 1, the driver takes every bio
@@ -792,7 +790,7 @@ static struct request *attempt_merge(struct request_queue 
*q,
/*
 * 'next' is going away, so update stats accordingly
 */
-   blk_account_io_merge(next);
+   blk_account_io_merge_request(next);
 
/*
 * ownership of bio passed from next to req, return 'next' for
-- 
2.26.2



  1   2   3   4   5   6   7   8   9   10   >