[PATCH v3 3/3] mmc: host: sdhci-sprd: Add software queue support

2019-09-18 Thread Baolin Wang
Add software queue support to improve the performance.

Signed-off-by: Baolin Wang 
---
 drivers/mmc/host/Kconfig  |1 +
 drivers/mmc/host/sdhci-sprd.c |   26 ++
 2 files changed, 27 insertions(+)

diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index d117f18..862e8e9 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -619,6 +619,7 @@ config MMC_SDHCI_SPRD
depends on ARCH_SPRD
depends on MMC_SDHCI_PLTFM
select MMC_SDHCI_IO_ACCESSORS
+   select MMC_SQHCI
help
  This selects the SDIO Host Controller in Spreadtrum
  SoCs, this driver supports R11(IP version: R11P0).
diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
index d07b979..4dec0b3 100644
--- a/drivers/mmc/host/sdhci-sprd.c
+++ b/drivers/mmc/host/sdhci-sprd.c
@@ -19,6 +19,7 @@
 #include 
 
 #include "sdhci-pltfm.h"
+#include "sqhci.h"
 
 /* SDHCI_ARGUMENT2 register high 16bit */
 #define SDHCI_SPRD_ARG2_STUFF  GENMASK(31, 16)
@@ -379,6 +380,16 @@ static unsigned int sdhci_sprd_get_ro(struct sdhci_host 
*host)
return 0;
 }
 
+static void sdhci_sprd_request_done(struct sdhci_host *host,
+   struct mmc_request *mrq)
+{
+   /* Validate if the request was from software queue firstly. */
+   if (sqhci_finalize_request(host->mmc, mrq))
+   return;
+
+mmc_request_done(host->mmc, mrq);
+}
+
 static struct sdhci_ops sdhci_sprd_ops = {
.read_l = sdhci_sprd_readl,
.write_l = sdhci_sprd_writel,
@@ -392,6 +403,7 @@ static unsigned int sdhci_sprd_get_ro(struct sdhci_host 
*host)
.hw_reset = sdhci_sprd_hw_reset,
.get_max_timeout_count = sdhci_sprd_get_max_timeout_count,
.get_ro = sdhci_sprd_get_ro,
+   .request_done = sdhci_sprd_request_done,
 };
 
 static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq)
@@ -521,6 +533,7 @@ static int sdhci_sprd_probe(struct platform_device *pdev)
 {
struct sdhci_host *host;
struct sdhci_sprd_host *sprd_host;
+   struct sqhci_host *sq_host;
struct clk *clk;
int ret = 0;
 
@@ -631,6 +644,16 @@ static int sdhci_sprd_probe(struct platform_device *pdev)
 
sprd_host->flags = host->flags;
 
+   sq_host = devm_kzalloc(>dev, sizeof(*sq_host), GFP_KERNEL);
+   if (!sq_host) {
+   ret = -ENOMEM;
+   goto err_cleanup_host;
+   }
+
+   ret = sqhci_init(sq_host, host->mmc);
+   if (ret)
+   goto err_cleanup_host;
+
ret = __sdhci_add_host(host);
if (ret)
goto err_cleanup_host;
@@ -689,6 +712,7 @@ static int sdhci_sprd_runtime_suspend(struct device *dev)
struct sdhci_host *host = dev_get_drvdata(dev);
struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host);
 
+   sqhci_suspend(host->mmc);
sdhci_runtime_suspend_host(host);
 
clk_disable_unprepare(sprd_host->clk_sdio);
@@ -717,6 +741,8 @@ static int sdhci_sprd_runtime_resume(struct device *dev)
goto clk_disable;
 
sdhci_runtime_resume_host(host, 1);
+   sqhci_resume(host->mmc);
+
return 0;
 
 clk_disable:
-- 
1.7.9.5



[PATCH v3 2/3] mmc: host: sdhci: Add request_done ops for struct sdhci_ops

2019-09-18 Thread Baolin Wang
Add request_done ops for struct sdhci_ops as a preparation in case some
host controllers have different method to complete one request, such as
supporting request completion of MMC software queue.

Signed-off-by: Baolin Wang 
---
 drivers/mmc/host/sdhci.c |   12 ++--
 drivers/mmc/host/sdhci.h |2 ++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index a5dc5aa..b2c8695 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2710,7 +2710,10 @@ static bool sdhci_request_done(struct sdhci_host *host)
 
spin_unlock_irqrestore(>lock, flags);
 
-   mmc_request_done(host->mmc, mrq);
+   if (host->ops->request_done)
+   host->ops->request_done(host, mrq);
+   else
+   mmc_request_done(host->mmc, mrq);
 
return false;
 }
@@ -3133,7 +3136,12 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
 
/* Process mrqs ready for immediate completion */
for (i = 0; i < SDHCI_MAX_MRQS; i++) {
-   if (mrqs_done[i])
+   if (!mrqs_done[i])
+   continue;
+
+   if (host->ops->request_done)
+   host->ops->request_done(host, mrqs_done[i]);
+   else
mmc_request_done(host->mmc, mrqs_done[i]);
}
 
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 902f855..e9a476f 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -643,6 +643,8 @@ struct sdhci_ops {
void(*voltage_switch)(struct sdhci_host *host);
void(*adma_write_desc)(struct sdhci_host *host, void **desc,
   dma_addr_t addr, int len, unsigned int cmd);
+   void(*request_done)(struct sdhci_host *host,
+   struct mmc_request *mrq);
 };
 
 #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
-- 
1.7.9.5



[PATCH v3 0/3] Add MMC software queue support

2019-09-18 Thread Baolin Wang
Hi All,

Now the MMC read/write stack will always wait for previous request is
completed by mmc_blk_rw_wait(), before sending a new request to hardware,
or queue a work to complete request, that will bring context switching
overhead, especially for high I/O per second rates, to affect the IO
performance.

Thus this patch set will introduce the MMC software command queue support
based on command queue engine's interfaces, and set the queue depth as 2,
that means we do not need wait for previous request is completed and can
queue 2 requests in flight. It is enough to let the irq handler always
trigger the next request without a context switch and then ask the blk_mq
layer for the next one to get queued, as well as avoiding a long latency.

Moreover we can expand the MMC software queue interface to support
MMC packed request or packed command instead of adding new interfaces,
according to previosus discussion.

Below are some comparison data with fio tool. The fio command I used
is like below with changing the '--rw' parameter and enabling the direct
IO flag to measure the actual hardware transfer speed in 4K block size.

./fio --filename=/dev/mmcblk0p30 --direct=1 --iodepth=20 --rw=read --bs=4K 
--size=512M --group_reporting --numjobs=20 --name=test_read

My eMMC card working at HS400 Enhanced strobe mode:
[2.229856] mmc0: new HS400 Enhanced strobe MMC card at address 0001
[2.237566] mmcblk0: mmc0:0001 HBG4a2 29.1 GiB 
[2.242621] mmcblk0boot0: mmc0:0001 HBG4a2 partition 1 4.00 MiB
[2.249110] mmcblk0boot1: mmc0:0001 HBG4a2 partition 2 4.00 MiB
[2.255307] mmcblk0rpmb: mmc0:0001 HBG4a2 partition 3 4.00 MiB, chardev 
(248:0)

1. Without MMC software queue
I tested 3 times for each case and output a average speed.

1) Sequential read:
Speed: 28.9MiB/s, 26.4MiB/s, 30.9MiB/s
Average speed: 28.7MiB/s

2) Random read:
Speed: 18.2MiB/s, 8.9MiB/s, 15.8MiB/s
Average speed: 14.3MiB/s

3) Sequential write:
Speed: 21.1MiB/s, 27.9MiB/s, 25MiB/s
Average speed: 24.7MiB/s

4) Random write:
Speed: 21.5MiB/s, 18.1MiB/s, 18.1MiB/s
Average speed: 19.2MiB/s

2. With MMC software queue
I tested 3 times for each case and output a average speed.

1) Sequential read:
Speed: 44.1MiB/s, 42.3MiB/s, 44.4MiB/s
Average speed: 43.6MiB/s

2) Random read:
Speed: 30.6MiB/s, 30.9MiB/s, 30.5MiB/s
Average speed: 30.6MiB/s

3) Sequential write:
Speed: 44.1MiB/s, 45.9MiB/s, 44.2MiB/s
Average speed: 44.7MiB/s

4) Random write:
Speed: 45.1MiB/s, 43.3MiB/s, 42.4MiB/s
Average speed: 43.6MiB/s

Form above data, we can see the MMC software queue can help to improve the
performance obviously.

Any comments are welcome. Thanks a lot.

Changes from v2:
 - Remove reference to 'struct cqhci_host' and 'struct cqhci_slot',
 instead adding 'struct sqhci_host', which is only used by software queue.

Changes from v1:
 - Add request_done ops for sdhci_ops.
 - Replace virtual command queue with software queue for functions and
 variables.
 - Rename the software queue file and add sqhci.h header file.

Baolin Wang (3):
  mmc: Add MMC software queue support
  mmc: host: sdhci: Add request_done ops for struct sdhci_ops
  mmc: host: sdhci-sprd: Add software queue support

 drivers/mmc/core/block.c  |   61 
 drivers/mmc/core/mmc.c|   13 +-
 drivers/mmc/core/queue.c  |   25 ++-
 drivers/mmc/host/Kconfig  |9 ++
 drivers/mmc/host/Makefile |1 +
 drivers/mmc/host/sdhci-sprd.c |   26 
 drivers/mmc/host/sdhci.c  |   12 +-
 drivers/mmc/host/sdhci.h  |2 +
 drivers/mmc/host/sqhci.c  |  344 +
 drivers/mmc/host/sqhci.h  |   53 +++
 include/linux/mmc/host.h  |3 +
 11 files changed, 537 insertions(+), 12 deletions(-)
 create mode 100644 drivers/mmc/host/sqhci.c
 create mode 100644 drivers/mmc/host/sqhci.h

-- 
1.7.9.5



[PATCH] x86/mm/pti: Handle unaligned addr to PMD-mapped page in pti_clone_pgtable

2019-09-18 Thread Song Liu
To clone page table of PMD-mapped pages, pti_clone_pgtable() requires PMD
aligned start address. [1] adds warning for unaligned addresses. However,
there is still no warning for unaligned address to valid huge pmd [2].

Add alignment check in valid pmd_large() case. If the address is
unaligned, round it down to the nearest PMD aligned address and show
warning.

[1] commit 825d0b73cd75 ("x86/mm/pti: Handle unaligned address gracefully
  in pti_clone_pagetable()")
[2] 
https://lore.kernel.org/lkml/156864062019.3407.14798418565580024723.t...@nanos.tec.linutronix.de/

Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: Peter Zijlstra (Intel) 
Cc: Linus Torvalds 
Signed-off-by: Song Liu 
---
 arch/x86/mm/pti.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index 7f2140414440..d224115c350d 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -343,6 +343,10 @@ pti_clone_pgtable(unsigned long start, unsigned long end,
}
 
if (pmd_large(*pmd) || level == PTI_CLONE_PMD) {
+   /* warn and round_down() unaligned addr */
+   if (WARN_ON_ONCE(addr & ~PMD_MASK))
+   addr &= PMD_MASK;
+
target_pmd = pti_user_pagetable_walk_pmd(addr);
if (WARN_ON(!target_pmd))
return;
-- 
2.17.1



Re: [PATCH trivial] KVM: PPC: Remove superfluous check for non-zero return value

2019-09-18 Thread Thomas Huth
On 18/09/2019 22.54, Greg Kurz wrote:
> On Wed, 18 Sep 2019 18:44:36 +0200
> Greg Kurz  wrote:
> 
>> On Wed, 11 Sep 2019 21:52:35 +0200
>> Thomas Huth  wrote:
>>
>>> After the kfree()s haven been removed in the previous
>>> commit 9798f4ea71ea ("fix rollback when kvmppc_xive_create fails"),
>>> the code can be simplified even more to simply always "return ret"
>>> now.
>>>
>>> Signed-off-by: Thomas Huth 
>>> ---
>>
>> This looks like a good candidate for trivial, hence Cc'ing Jiri
>> and adding trivial keyword in subject.
>>
>> Reviewed-by: Greg Kurz 
>>
> 
> Oops, the patch is correct but there are some fixes that require
> the return 0 to stay around...
> 
> https://patchwork.ozlabs.org/project/kvm-ppc/list/?series=129957

:-)

Ok, then please simply ignore my patch.

 Thomas


Re: [PATCH v1 2/2] spi: cadence-qspi: Add QSPI support for Intel LGM SoC

2019-09-18 Thread Ramuthevar, Vadivel MuruganX

Hi Mark,

   Thank you for the comments and queries.

On 18/9/2019 8:08 PM, Mark Brown wrote:

On Wed, Sep 18, 2019 at 01:59:06PM +0800, Ramuthevar, Vadivel MuruganX wrote:

On 17/9/2019 11:36 PM, Mark Brown wrote:

On Tue, Sep 17, 2019 at 10:11:28AM +0800, Ramuthevar, Vadivel MuruganX wrote:

*    spi-cadence.c* in *drivers/spi/*, which supports very old legacy
cadence-spi based devices(normal)
*    cadence-quadspi.c(drivers/mtd/spi-nor/)* : specific support to SPI-NOR
flash with new spi-nor layer.
      all the API's in this driver purely on spi-nor specific, so couldn't
proceed to adapt.

Are these completely separate IPs or are they just different versions of
the same IP?

These are same IPs , but different features Enabled/Disabled depends upon
the SoC vendors.
for e.g: Intel LGM SoC uses the same IP, but without DMA and Direct access
controller.
also dedicated support to flash devices.

If it's different versions of the same IP then everything should be in
one driver with the optional features enabled depending on what's in a
given system.
Agreed!, I am trying to adapt the driver/mtd/spi-nor/cadence-quadspi.c 
and newly sent patches

in a single driver file, also trying to use spi_mem_ops framework.

With Best Regards
Vadivel


Re: [PATCH] mm/pgtable/debug: Fix test validating architecture page table helpers

2019-09-18 Thread Christophe Leroy




Le 18/09/2019 à 09:32, Anshuman Khandual a écrit :



On 09/13/2019 11:53 AM, Christophe Leroy wrote:

Fix build failure on powerpc.

Fix preemption imbalance.

Signed-off-by: Christophe Leroy 
---
  mm/arch_pgtable_test.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/mm/arch_pgtable_test.c b/mm/arch_pgtable_test.c
index 8b4a92756ad8..f2b3c9ec35fa 100644
--- a/mm/arch_pgtable_test.c
+++ b/mm/arch_pgtable_test.c
@@ -24,6 +24,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  
@@ -400,6 +401,8 @@ static int __init arch_pgtable_tests_init(void)

p4d_clear_tests(p4dp);
pgd_clear_tests(mm, pgdp);
  
+	pte_unmap(ptep);

+
pmd_populate_tests(mm, pmdp, saved_ptep);
pud_populate_tests(mm, pudp, saved_pmdp);
p4d_populate_tests(mm, p4dp, saved_pudp);



Hello Christophe,

I am planning to fold this fix into the current patch and retain your
Signed-off-by. Are you okay with it ?



No problem, do whatever is convenient for you. You can keep the 
signed-off-by, or use tested-by: as I tested it on PPC32.


Christophe


Re: [PATCH V2 2/2] mm/pgtable/debug: Add test validating architecture page table helpers

2019-09-18 Thread Christophe Leroy




Le 19/09/2019 à 06:56, Anshuman Khandual a écrit :



On 09/18/2019 09:56 PM, Christophe Leroy wrote:



Le 18/09/2019 à 07:04, Anshuman Khandual a écrit :



On 09/13/2019 03:31 PM, Christophe Leroy wrote:



Le 13/09/2019 à 11:02, Anshuman Khandual a écrit :



+#if !defined(__PAGETABLE_PMD_FOLDED) && !defined(__ARCH_HAS_4LEVEL_HACK)


#ifdefs have to be avoided as much as possible, see below


Yeah but it has been bit difficult to avoid all these $ifdef because of the
availability (or lack of it) for all these pgtable helpers in various config
combinations on all platforms.


As far as I can see these pgtable helpers should exist everywhere at least via 
asm-generic/ files.


But they might not actually do the right thing.



Can you spot a particular config which fails ?


Lets consider the following example (after removing the $ifdefs around it)
which though builds successfully but fails to pass the intended test. This
is with arm64 config 4K pages sizes with 39 bits VA space which ends up
with a 3 level page table arrangement.

static void __init p4d_clear_tests(p4d_t *p4dp)
{
  p4d_t p4d = READ_ONCE(*p4dp);


My suggestion was not to completely drop the #ifdef but to do like you did in 
pgd_clear_tests() for instance, ie to add the following test on top of the 
function:

 if (mm_pud_folded(mm) || is_defined(__ARCH_HAS_5LEVEL_HACK))
     return;



Sometimes this does not really work. On some platforms, combination of
__PAGETABLE_PUD_FOLDED and __ARCH_HAS_5LEVEL_HACK decide whether the
helpers such as __pud() or __pgd() is even available for that platform.
Ideally it should have been through generic falls backs in include/*/
but I guess there might be bugs on the platform or it has not been
changed to adopt 5 level page table framework with required folding
macros etc.


Yes. As I suggested below, most likely that's better to retain the 
#ifdef __ARCH_HAS_5LEVEL_HACK but change the #ifdef 
__PAGETABLE_PUD_FOLDED by a runtime test of mm_pud_folded(mm)


As pointed by Gerald, some arches don't have __PAGETABLE_PUD_FOLDED 
because they are deciding dynamically if they fold the level on not, but 
have mm_pud_folded(mm)






  p4d = __p4d(p4d_val(p4d) | RANDOM_ORVALUE);
  WRITE_ONCE(*p4dp, p4d);
  p4d_clear(p4dp);
  p4d = READ_ONCE(*p4dp);
  WARN_ON(!p4d_none(p4d));
}

The following test hits an error at WARN_ON(!p4d_none(p4d))

[   16.757333] [ cut here ]
[   16.758019] WARNING: CPU: 11 PID: 1 at mm/arch_pgtable_test.c:187 
arch_pgtable_tests_init+0x24c/0x474


[...]


[   16.781282] ---[ end trace 042e6c40c0a3b038 ]---

On arm64 (4K page size|39 bits VA|3 level page table)

#elif CONFIG_PGTABLE_LEVELS == 3    /* Applicable here */
#define __ARCH_USE_5LEVEL_HACK
#include 

Which pulls in

#include 

which pulls in

#include 

which defines

static inline int p4d_none(p4d_t p4d)
{
  return 0;
}

which will invariably trigger WARN_ON(!p4d_none(p4d)).

Similarly for next test p4d_populate_tests() which will always be
successful because p4d_bad() invariably returns negative.

static inline int p4d_bad(p4d_t p4d)
{
  return 0;
}

static void __init p4d_populate_tests(struct mm_struct *mm, p4d_t *p4dp,
    pud_t *pudp)
{
  p4d_t p4d;

  /*
   * This entry points to next level page table page.
   * Hence this must not qualify as p4d_bad().
   */
  pud_clear(pudp);
  p4d_clear(p4dp);
  p4d_populate(mm, p4dp, pudp);
  p4d = READ_ONCE(*p4dp);
  WARN_ON(p4d_bad(p4d));
}

We should not run these tests for the above config because they are
not applicable and will invariably produce same result.



[...]



So it shouldn't be an issue. Maybe if a couple of arches miss them, the best 
would be to fix the arches, since that's the purpose of your testsuite isn't it 
?


The run time failures as explained previously is because of the folding which
needs to be protected as they are not even applicable. The compile time
failures are because pxx_populate() signatures are platform specific depending
on how many page table levels they really support.



So IIUC, the compiletime problem is around __ARCH_HAS_5LEVEL_HACK. For all #if 
!defined(__PAGETABLE_PXX_FOLDED), something equivalent to the following should 
make the trick.

 if (mm_pxx_folded())
     return;


For the __ARCH_HAS_5LEVEL_HACK stuff, I think we should be able to regroup all 
impacted functions inside a single #ifdef __ARCH_HAS_5LEVEL_HACK


I was wondering if it will be better to

1) Minimize all #ifdefs in the code which might fail on some platforms
2) Restrict proposed test module to platforms where it builds and runs
3) Enable other platforms afterwards after fixing their build problems or other 
requirements


I understand that __ARCH_HAS_5LEVEL_HACK is an HACK as its name 
suggests, so you can't expect all platforms to go for an 

RE: [PATCH V6 2/2] mailbox: introduce ARM SMC based mailbox

2019-09-18 Thread Peng Fan
Hi Jassi,

> Subject: Re: [PATCH V6 2/2] mailbox: introduce ARM SMC based mailbox
> 
> On Wed, Sep 18, 2019 at 5:00 AM Andre Przywara
>  wrote:
> 
> > >
> > > >
> > > > > + };
> > > > > +};
> > > >
> > > > If this is the data structure that this mailbox controller uses, I
> > > > would expect this to be documented somewhere, or even exported.
> > >
> > > Export this structure in include/linux/mailbox/smc-mailbox.h?
> >
> > For instance, even though I am not sure this is really desired or helpful, 
> > since
> we expect a generic mailbox client (the SCPI or SCMI driver) to deal with that
> mailbox.
> >
> > But at least the expected format should be documented, which could just be
> in writing, not necessarily in code.
> >
> Yes, the packet format is specified by the controller and defined in some
> header for clients to include. Other platforms do that already.

So you prefer add the structure in include/linux/mailbox/smc-mailbox.h?

Thanks,
Peng.

> 
> 
> 
> > > > > +
> > > > > +typedef unsigned long (smc_mbox_fn)(unsigned int, unsigned long,
> > > > > + unsigned long, unsigned long,
> > > > > + unsigned long, unsigned long,
> > > > > + unsigned long); static
> smc_mbox_fn
> > > > > +*invoke_smc_mbox_fn;
> > > > > +
> > > > > +static int arm_smc_send_data(struct mbox_chan *link, void
> > > > > +*data) {  struct arm_smc_chan_data *chan_data = link->con_priv;
> > > > > +struct arm_smccc_mbox_cmd *cmd = data;  unsigned long ret;
> > > > > + u32 function_id;
> > > > > +
> > > > > + function_id = chan_data->function_id; if (!function_id)
> > > > > + function_id = cmd->function_id;
> > > > > +
> > > > > + if (function_id & BIT(30)) {
> > > >
> > > > if (ARM_SMCCC_IS_64(function_id)) {
> > >
> > > ok
> > >
> > > >
> > > > > + ret = invoke_smc_mbox_fn(function_id,
> cmd->args_smccc64[0],
> > > > > +  cmd->args_smccc64[1],
> > > > > +  cmd->args_smccc64[2],
> > > > > +  cmd->args_smccc64[3],
> > > > > +  cmd->args_smccc64[4],
> > > > > +  cmd->args_smccc64[5]); }
> else
> > > > > + {
> > > > > + ret = invoke_smc_mbox_fn(function_id,
> cmd->args_smccc32[0],
> > > > > +  cmd->args_smccc32[1],
> > > > > +  cmd->args_smccc32[2],
> > > > > +  cmd->args_smccc32[3],
> > > > > +  cmd->args_smccc32[4],
> > > > > +  cmd->args_smccc32[5]); }
> > > > > +
> > > > > + mbox_chan_received_data(link, (void *)ret);
> > > > > +
> > > > > + return 0;
> > > > > +}
> > > > > +
> > > > > +static unsigned long __invoke_fn_hvc(unsigned int function_id,
> > > > > +  unsigned long arg0, unsigned
> long arg1,
> > > > > +  unsigned long arg2, unsigned
> long arg3,
> > > > > +  unsigned long arg4, unsigned
> long
> > > > > +arg5) {  struct arm_smccc_res res;
> > > > > +
> > > > > + arm_smccc_hvc(function_id, arg0, arg1, arg2, arg3, arg4,
> > > > > +   arg5, 0, );
> > > > > + return res.a0;
> > > > > +}
> > > > > +
> > > > > +static unsigned long __invoke_fn_smc(unsigned int function_id,
> > > > > +  unsigned long arg0, unsigned
> long arg1,
> > > > > +  unsigned long arg2, unsigned
> long arg3,
> > > > > +  unsigned long arg4, unsigned
> long
> > > > > +arg5) {  struct arm_smccc_res res;
> > > > > +
> > > > > + arm_smccc_smc(function_id, arg0, arg1, arg2, arg3, arg4,
> > > > > +   arg5, 0, );
> > > > > + return res.a0;
> > > > > +}
> > > > > +
> > > > > +static const struct mbox_chan_ops arm_smc_mbox_chan_ops = {
> > > > > + .send_data  = arm_smc_send_data,
> > > > > +};
> > > > > +
> > > > > +static int arm_smc_mbox_probe(struct platform_device *pdev) {
> > > > > +struct device *dev = >dev;  struct mbox_controller *mbox;
> > > > > +struct arm_smc_chan_data *chan_data;  int ret;
> > > > > + u32 function_id = 0;
> > > > > +
> > > > > + if (of_device_is_compatible(dev->of_node, "arm,smc-mbox"))
> > > > > + invoke_smc_mbox_fn = __invoke_fn_smc; else
> > > > > + invoke_smc_mbox_fn = __invoke_fn_hvc;
> > > > > +
> > > > > + mbox = devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL); if
> > > > > + (!mbox)
> > > > > + return -ENOMEM;
> > > > > +
> > > > > + mbox->num_chans = 1;
> > > > > + mbox->chans = devm_kzalloc(dev, sizeof(*mbox->chans),
> > > > > + mbox->GFP_KERNEL);
> > > > > + if (!mbox->chans)
> > > > > + return -ENOMEM;
> > > > > +
> > > > > + chan_data = devm_kzalloc(dev, sizeof(*chan_data), GFP_KERNEL);
> > > > > + if (!chan_data)
> > > > > + return -ENOMEM;
> > > > > +
> > > > > + 

remoteproc: don't allow modular build

2019-09-18 Thread Keerthy

Hi Christoph/Bjorn,

There are a bunch of defconfigs that rely on modular build of remoteproc.

If i do a git grep CONFIG_REMOTEPROC on linux-next:

arch/arm/configs/davinci_all_defconfig:CONFIG_REMOTEPROC=m
arch/arm/configs/multi_v7_defconfig:CONFIG_REMOTEPROC=m
arch/arm/configs/omap2plus_defconfig:CONFIG_REMOTEPROC=m
arch/arm/configs/qcom_defconfig:CONFIG_REMOTEPROC=y
arch/arm64/configs/defconfig:CONFIG_REMOTEPROC=m

All of them now stop building the remoteproc as a module and all the 
dependent modules consequently do not get built. Do you recommend all of 
them to get converted to built in?


That will be some magnitude of change.

Best Regards,
Keerthy


[PATCH 5/6] arm64: dts: rockchip: Rename vcc12v_sys into dc_12v for roc-rk3399-pc

2019-09-18 Thread Jagan Teki
It is always better practice to follow regulator naming conventions
as per the schematics for future references.

This would indeed helpful to review and check the naming convention
directly on schematics, both for the code reviewers and the developers.

So, rename vcc12v_sys into dc_12v as per rk3399 power tree as per
roc-rk3399-pc schematics.

Signed-off-by: Jagan Teki 
---
 .../boot/dts/rockchip/rk3399-libretech-roc-rk3399-pc.dts  | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399-libretech-roc-rk3399-pc.dts 
b/arch/arm64/boot/dts/rockchip/rk3399-libretech-roc-rk3399-pc.dts
index e09bcbdd92f5..51242ea5447d 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399-libretech-roc-rk3399-pc.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3399-libretech-roc-rk3399-pc.dts
@@ -57,9 +57,9 @@
 * should be placed inside mp8859, but not until mp8859 has
 * its own dt-binding.
 */
-   vcc12v_sys: mp8859-dcdc1 {
+   dc_12v: mp8859-dcdc1 {
compatible = "regulator-fixed";
-   regulator-name = "vcc12v_sys";
+   regulator-name = "dc_12v";
regulator-always-on;
regulator-boot-on;
regulator-min-microvolt = <1200>;
@@ -85,7 +85,7 @@
regulator-boot-on;
regulator-min-microvolt = <330>;
regulator-max-microvolt = <330>;
-   vin-supply = <_sys>;
+   vin-supply = <_12v>;
};
 
/* Actually 3 regulators (host0, 1, 2) controlled by the same gpio */
@@ -118,7 +118,7 @@
regulator-boot-on;
regulator-min-microvolt = <500>;
regulator-max-microvolt = <500>;
-   vin-supply = <_sys>;
+   vin-supply = <_12v>;
};
 
vdd_log: vdd-log {
-- 
2.18.0.321.gffc6fa0e3



[PATCH 6/6] arm64: dts: rockchip: Fix roc-rk3399-pc regulator input rails

2019-09-18 Thread Jagan Teki
Few, know rk808 pmic regulators VCC[1-4], VCC[6-7], VCC[9-11],
VDD_LOG, VDD_GPU, VDD_CPU_B, VCC3V3_SYS are inputting with vcc_sys
which is 5V power rail from dc_12v.

So, replace the vin-supply of above mentioned regulators
with vcc_sys as per the PMIC-RK808-D page of roc-rk3399-pc
schematics.

Signed-off-by: Jagan Teki 
---
 .../rk3399-libretech-roc-rk3399-pc.dts| 26 +--
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399-libretech-roc-rk3399-pc.dts 
b/arch/arm64/boot/dts/rockchip/rk3399-libretech-roc-rk3399-pc.dts
index 51242ea5447d..1eddb2e00809 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399-libretech-roc-rk3399-pc.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3399-libretech-roc-rk3399-pc.dts
@@ -85,7 +85,7 @@
regulator-boot-on;
regulator-min-microvolt = <330>;
regulator-max-microvolt = <330>;
-   vin-supply = <_12v>;
+   vin-supply = <_sys>;
};
 
/* Actually 3 regulators (host0, 1, 2) controlled by the same gpio */
@@ -129,7 +129,7 @@
regulator-boot-on;
regulator-min-microvolt = <80>;
regulator-max-microvolt = <140>;
-   vin-supply = <_sys>;
+   vin-supply = <_sys>;
};
 };
 
@@ -202,16 +202,16 @@
rockchip,system-power-controller;
wakeup-source;
 
-   vcc1-supply = <_sys>;
-   vcc2-supply = <_sys>;
-   vcc3-supply = <_sys>;
-   vcc4-supply = <_sys>;
-   vcc6-supply = <_sys>;
-   vcc7-supply = <_sys>;
+   vcc1-supply = <_sys>;
+   vcc2-supply = <_sys>;
+   vcc3-supply = <_sys>;
+   vcc4-supply = <_sys>;
+   vcc6-supply = <_sys>;
+   vcc7-supply = <_sys>;
vcc8-supply = <_sys>;
-   vcc9-supply = <_sys>;
-   vcc10-supply = <_sys>;
-   vcc11-supply = <_sys>;
+   vcc9-supply = <_sys>;
+   vcc10-supply = <_sys>;
+   vcc11-supply = <_sys>;
vcc12-supply = <_sys>;
vddio-supply = <_pmu>;
 
@@ -385,7 +385,7 @@
regulator-ramp-delay = <1000>;
regulator-always-on;
regulator-boot-on;
-   vin-supply = <_sys>;
+   vin-supply = <_sys>;
 
regulator-state-mem {
regulator-off-in-suspend;
@@ -404,7 +404,7 @@
regulator-ramp-delay = <1000>;
regulator-always-on;
regulator-boot-on;
-   vin-supply = <_sys>;
+   vin-supply = <_sys>;
 
regulator-state-mem {
regulator-off-in-suspend;
-- 
2.18.0.321.gffc6fa0e3



[PATCH 3/6] arm64: dts: rockchip: Use libretech model, compatible for ROC-PC

2019-09-18 Thread Jagan Teki
Though the ROC-PC is manufactured by firefly, it is co-designed
by libretch like other Libretech computer boards from allwinner,
amlogic does.

So, it is always meaningful to keep maintain those vendors who
are part of design participation so-that the linux mainline
code will expose outside world who are the makers of such
hardware prototypes.

So,
- append the compatible to "libretech,roc-rk3399-pc" and
- update the model to "Libre Computer Board ROC-RK3399-PC"
  like other libretech computer boards does.

Signed-off-by: Jagan Teki 
---
 arch/arm64/boot/dts/rockchip/rk3399-roc-pc.dts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399-roc-pc.dts 
b/arch/arm64/boot/dts/rockchip/rk3399-roc-pc.dts
index c53f3d571620..e09bcbdd92f5 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399-roc-pc.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3399-roc-pc.dts
@@ -9,8 +9,8 @@
 #include "rk3399-opp.dtsi"
 
 / {
-   model = "Firefly ROC-RK3399-PC Board";
-   compatible = "firefly,roc-rk3399-pc", "rockchip,rk3399";
+   model = "Libre Computer Board ROC-RK3399-PC";
+   compatible = "libretech,roc-rk3399-pc", "firefly,roc-rk3399-pc", 
"rockchip,rk3399";
 
chosen {
stdout-path = "serial2:150n8";
-- 
2.18.0.321.gffc6fa0e3



[PATCH 4/6] arm64: dts: rockchip: Rename roc-pc with libretech notation

2019-09-18 Thread Jagan Teki
Though the ROC-PC is manufactured by firefly, it is co-designed
by libretch like other Libretech computer boards from allwinner,
amlogic does.

So, it is always meaningful to keep maintain those vendors who
are part of design participation so-that the linux mainline
code will expose outside world who are the makers of such
hardware prototypes.

So, rename the existing rk3399-roc-pc.dts with libretch notation,
rk3399-libretech-roc-rk3399-pc.dts

Signed-off-by: Jagan Teki 
---
 arch/arm64/boot/dts/rockchip/Makefile   | 2 +-
 .../{rk3399-roc-pc.dts => rk3399-libretech-roc-rk3399-pc.dts}   | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename arch/arm64/boot/dts/rockchip/{rk3399-roc-pc.dts => 
rk3399-libretech-roc-rk3399-pc.dts} (100%)

diff --git a/arch/arm64/boot/dts/rockchip/Makefile 
b/arch/arm64/boot/dts/rockchip/Makefile
index 1f18a9392d15..73c10ddb4300 100644
--- a/arch/arm64/boot/dts/rockchip/Makefile
+++ b/arch/arm64/boot/dts/rockchip/Makefile
@@ -21,12 +21,12 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-khadas-edge.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-khadas-edge-captain.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-khadas-edge-v.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-leez-p710.dtb
+dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-libretech-roc-rk3399-pc.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-nanopc-t4.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-nanopi-m4.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-nanopi-neo4.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-orangepi.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-puma-haikou.dtb
-dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-roc-pc.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-rock-pi-4.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-rock960.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-rockpro64.dtb
diff --git a/arch/arm64/boot/dts/rockchip/rk3399-roc-pc.dts 
b/arch/arm64/boot/dts/rockchip/rk3399-libretech-roc-rk3399-pc.dts
similarity index 100%
rename from arch/arm64/boot/dts/rockchip/rk3399-roc-pc.dts
rename to arch/arm64/boot/dts/rockchip/rk3399-libretech-roc-rk3399-pc.dts
-- 
2.18.0.321.gffc6fa0e3



[PATCH 1/6] arm64: dts: rockchip: Fix rk3399-roc-pc pwm2 pin

2019-09-18 Thread Jagan Teki
ROC-PC is not able to boot linux console if PWM2_d is
unattached to any pinctrl logic.

To be precise the linux boot hang with last logs as,
...
.
[0.003367] Console: colour dummy device 80x25
[0.003788] printk: console [tty0] enabled
[0.004178] printk: bootconsole [uart8250] disabled

In ROC-PC the PWM2_d pin is connected to LOG_DVS_PWM of
VDD_LOG. So, for normal working operations this needs to
active and pull-down.

This patch fix, by attaching pinctrl active and pull-down
the pwm2.

Signed-off-by: Jagan Teki 
---
 arch/arm64/boot/dts/rockchip/rk3399-roc-pc.dts | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399-roc-pc.dts 
b/arch/arm64/boot/dts/rockchip/rk3399-roc-pc.dts
index 19f7732d728c..c53f3d571620 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399-roc-pc.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3399-roc-pc.dts
@@ -548,6 +548,8 @@
 };
 
  {
+   pinctrl-names = "active";
+   pinctrl-0 = <_pin_pull_down>;
status = "okay";
 };
 
-- 
2.18.0.321.gffc6fa0e3



[PATCH 2/6] dt-bindings: arm: rockchip: Use libretech for roc-pc binding

2019-09-18 Thread Jagan Teki
Though the ROC-PC is manufactured by firefly, it is co-designed
by libretch like other Libretech computer boards from allwinner,
amlogic does.

So, it is always meaningful to keep maintain those vendors who
are part of design participation so-that the linux mainline
code will expose outside world who are the makers of such
hardware prototypes.

So, update the dt-bindings of ROC-PC with libretch notation
like other libretech computer boards does.

Signed-off-by: Jagan Teki 
---
 Documentation/devicetree/bindings/arm/rockchip.yaml | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/arm/rockchip.yaml 
b/Documentation/devicetree/bindings/arm/rockchip.yaml
index 110fcca1a94e..bb65a10e85ce 100644
--- a/Documentation/devicetree/bindings/arm/rockchip.yaml
+++ b/Documentation/devicetree/bindings/arm/rockchip.yaml
@@ -87,11 +87,6 @@ properties:
   - const: firefly,roc-rk3328-cc
   - const: rockchip,rk3328
 
-  - description: Firefly ROC-RK3399-PC
-items:
-  - const: firefly,roc-rk3399-pc
-  - const: rockchip,rk3399
-
   - description: FriendlyElec NanoPi4 series boards
 items:
   - enum:
@@ -364,6 +359,12 @@ properties:
   - const: leez,p710
   - const: rockchip,rk3399
 
+  - description: Libre Computer Board ROC-RK3399-PC
+items:
+  - const: libretech,roc-rk3399-pc
+  - const: firefly,roc-rk3399-pc
+  - const: rockchip,rk3399
+
   - description: Mecer Xtreme Mini S6
 items:
   - const: mecer,xms6
-- 
2.18.0.321.gffc6fa0e3



[PATCH 0/6] arm64: dts: rockchip: ROC-PC fixes

2019-09-18 Thread Jagan Teki
This series is trying to fix the Linux boot and other
regulators stuff for ROC-RK3399-PC board.

patch 1: attach pinctrl to pwm2 pin

patch 2-4: libretech naming conventions

patch 5-6: regulator renaming, input rails fixes

Any inputs?
Jagan.

Jagan Teki (6):
  arm64: dts: rockchip: Fix rk3399-roc-pc pwm2 pin
  dt-bindings: arm: rockchip: Use libretech for roc-pc binding
  arm64: dts: rockchip: Use libretech model, compatible for ROC-PC
  arm64: dts: rockchip: Rename roc-pc with libretech notation
  arm64: dts: rockchip: Rename vcc12v_sys into dc_12v for roc-rk3399-pc
  arm64: dts: rockchip: Fix roc-rk3399-pc regulator input rails

 .../devicetree/bindings/arm/rockchip.yaml | 11 +++---
 arch/arm64/boot/dts/rockchip/Makefile |  2 +-
 ...dts => rk3399-libretech-roc-rk3399-pc.dts} | 38 ++-
 3 files changed, 27 insertions(+), 24 deletions(-)
 rename arch/arm64/boot/dts/rockchip/{rk3399-roc-pc.dts => 
rk3399-libretech-roc-rk3399-pc.dts} (95%)

-- 
2.18.0.321.gffc6fa0e3



Re: [PATCH v3 2/2] powerpc/irq: inline call_do_irq() and call_do_softirq()

2019-09-18 Thread Christophe Leroy




Le 18/09/2019 à 18:39, Segher Boessenkool a écrit :

Hi Christophe,

On Wed, Sep 18, 2019 at 03:48:20PM +, Christophe Leroy wrote:

call_do_irq() and call_do_softirq() are quite similar on PPC32 and
PPC64 and are simple enough to be worth inlining.

Inlining them avoids an mflr/mtlr pair plus a save/reload on stack.


But you hardcode the calling sequence in inline asm, which for various
reasons is not a great idea.


+static inline void call_do_irq(struct pt_regs *regs, void *sp)
+{
+   register unsigned long r3 asm("r3") = (unsigned long)regs;
+
+   asm volatile(
+   "  "PPC_STLU"1, %2(%1);\n"
+   "  mr  1, %1;\n"
+   "  bl  %3;\n"
+   "  "PPC_LL"  1, 0(1);\n" : "+r"(r3) :
+   "b"(sp), "i"(THREAD_SIZE - STACK_FRAME_OVERHEAD), "i"(__do_irq) 
:
+   "lr", "xer", "ctr", "memory", "cr0", "cr1", "cr5", "cr6", "cr7",
+   "r0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12");
+}


I realise the original code had this...  Loading the old stack pointer
value back from the stack creates a bottleneck (via the store->load
forwarding it requires).  It could just use
   addi 1,1,-(%2)
here, which can also be written as
   addi 1,1,%n2
(that is portable to all architectures btw).


No, we switched stack before the bl call, we replaced r1 by r3 after 
saving r1 into r3 stack. Now we have to restore the original r1.





Please write the  "+r"(r3)  on the next line?  Not on the same line as
the multi-line template.  This make things more readable.


I don't know if using functions as an "i" works properly...  It probably
does, it's just not something that you see often :-)


What about r2?  Various ABIs handle that differently.  This might make
it impossible to share implementation between 32-bit and 64-bit for this.
But we could add it to the clobber list worst case, that will always work.


Isn't r2 non-volatile on all ABIs ?




So anyway, it looks to me like it will work.  Nice cleanup.  Would be
better if you could do the call to __do_irq from C code, but maybe we
cannot have everything ;-)


sparc do it the following way, is there no risk that GCC adds unwanted 
code inbetween that is not aware there the stack pointer has changed ?


void do_softirq_own_stack(void)
{
void *orig_sp, *sp = softirq_stack[smp_processor_id()];

sp += THREAD_SIZE - 192 - STACK_BIAS;

__asm__ __volatile__("mov %%sp, %0\n\t"
 "mov %1, %%sp"
 : "=" (orig_sp)
 : "r" (sp));
__do_softirq();
__asm__ __volatile__("mov %0, %%sp"
 : : "r" (orig_sp));
}

If the above is no risk, then can we do the same on powerpc ?



Reviewed-by: Segher Boessenkool 


Thanks for the review.

Christophe


[PATCH v6] perf: Sharing PMU counters across compatible events

2019-09-18 Thread Song Liu
This patch tries to enable PMU sharing. To make perf event scheduling
fast, we use special data structures.

An array of "struct perf_event_dup" is added to the perf_event_context,
to remember all the duplicated events under this ctx. All the events
under this ctx has a "dup_id" pointing to its perf_event_dup. Compatible
events under the same ctx share the same perf_event_dup. The following
figure shows a simplified version of the data structure.

  ctx ->  perf_event_dup -> master
 ^
 |
 perf_event /|
 |
 perf_event /

Connection among perf_event and perf_event_dup are built when events are
added or removed from the ctx. So these are not on the critical path of
schedule or perf_rotate_context().

On the critical paths (add, del read), sharing PMU counters doesn't
increase the complexity. Helper functions event_pmu_[add|del|read]() are
introduced to cover these cases. All these functions have O(1) time
complexity.

We allocate a separate perf_event for perf_event_dup->master. This needs
extra attention, because perf_event_alloc() may sleep. To allocate the
master event properly, a new pointer, tmp_master, is added to perf_event.
tmp_master carries a separate perf_event into list_[add|del]_event().
The master event has valid ->ctx and holds ctx->refcount.

Details about the handling of the master event is added to
include/linux/perf_event.h, before struct perf_event_dup.

Cc: Peter Zijlstra 
Cc: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Alexey Budankov 
Cc: Namhyung Kim 
Cc: Tejun Heo 
Signed-off-by: Song Liu 
---
 include/linux/perf_event.h |  61 
 kernel/events/core.c   | 294 ++---
 2 files changed, 332 insertions(+), 23 deletions(-)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 61448c19a132..a694e5eee80a 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -722,6 +722,12 @@ struct perf_event {
 #endif
 
struct list_headsb_list;
+
+   /* for PMU sharing */
+   struct perf_event   *tmp_master;
+   int dup_id;
+   u64 dup_base_count;
+   u64 dup_base_child_count;
 #endif /* CONFIG_PERF_EVENTS */
 };
 
@@ -731,6 +737,58 @@ struct perf_event_groups {
u64 index;
 };
 
+/*
+ * Sharing PMU across compatible events
+ *
+ * If two perf_events in the same perf_event_context are counting same
+ * hardware events (instructions, cycles, etc.), they could share the
+ * hardware PMU counter.
+ *
+ * When a perf_event is added to the ctx (list_add_event), it is compared
+ * against other events in the ctx. If they can share the PMU counter,
+ * a perf_event_dup is allocated to represent the sharing.
+ *
+ * Each perf_event_dup has a virtual master event, which is called by
+ * pmu->add() and pmu->del(). We cannot call perf_event_alloc() in
+ * list_add_event(), so it is allocated and carried by event->tmp_master
+ * into list_add_event().
+ *
+ * Virtual master in different cases/paths:
+ *
+ * < I > perf_event_open() -> close() path:
+ *
+ * 1. Allocated by perf_event_alloc() in sys_perf_event_open();
+ * 2. event->tmp_master->ctx assigned in perf_install_in_context();
+ * 3.a. if used by ctx->dup_events, freed in perf_event_release_kernel();
+ * 3.b. if not used by ctx->dup_events, freed in perf_event_open().
+ *
+ * < II > inherit_event() path:
+ *
+ * 1. Allocated by perf_event_alloc() in inherit_event();
+ * 2. tmp_master->ctx assigned in inherit_event();
+ * 3.a. if used by ctx->dup_events, freed in perf_event_release_kernel();
+ * 3.b. if not used by ctx->dup_events, freed in inherit_event().
+ *
+ * < III > perf_pmu_migrate_context() path:
+ * all dup_events removed during migration (no sharing after the move).
+ *
+ * < IV > perf_event_create_kernel_counter() path:
+ * not supported yet.
+ */
+struct perf_event_dup {
+   /*
+* master event being called by pmu->add() and pmu->del().
+* This event is allocated with perf_event_alloc(). When
+* attached to a ctx, this event should hold ctx->refcount.
+*/
+   struct perf_event   *master;
+   /* number of events in the ctx that shares the master */
+   int total_event_count;
+   /* number of active events of the master */
+   int active_event_count;
+};
+
+#define MAX_PERF_EVENT_DUP_PER_CTX 4
 /**
  * struct perf_event_context - event context structure
  *
@@ -791,6 +849,9 @@ struct perf_event_context {
 #endif
void*task_ctx_data; /* pmu specific data */
struct rcu_head rcu_head;
+
+   /* for PMU sharing. array is needed for O(1) access */
+   struct perf_event_dup   dup_events[MAX_PERF_EVENT_DUP_PER_CTX];
 };
 
 /*
diff --git a/kernel/events/core.c 

[PATCH] Drivers: hv: vmbus: Fix harmless building warnings without CONFIG_PM

2019-09-18 Thread Dexuan Cui
If CONFIG_PM is not set, we can comment out these functions to avoid the
below warnings:

drivers/hv/vmbus_drv.c:2208:12: warning: ‘vmbus_bus_resume’ defined but not 
used [-Wunused-function]
drivers/hv/vmbus_drv.c:2128:12: warning: ‘vmbus_bus_suspend’ defined but not 
used [-Wunused-function]
drivers/hv/vmbus_drv.c:937:12: warning: ‘vmbus_resume’ defined but not used 
[-Wunused-function]
drivers/hv/vmbus_drv.c:918:12: warning: ‘vmbus_suspend’ defined but not used 
[-Wunused-function]

Fixes: 271b2224d42f ("Drivers: hv: vmbus: Implement suspend/resume for VSC 
drivers for hibernation")
Fixes: f53335e3289f ("Drivers: hv: vmbus: Suspend/resume the vmbus itself for 
hibernation")
Reported-by: Arnd Bergmann 
Signed-off-by: Dexuan Cui 
---
 drivers/hv/vmbus_drv.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 391f0b225c9a..8bfb36695413 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -912,6 +912,7 @@ static void vmbus_shutdown(struct device *child_device)
drv->shutdown(dev);
 }
 
+#ifdef CONFIG_PM
 /*
  * vmbus_suspend - Suspend a vmbus device
  */
@@ -949,6 +950,7 @@ static int vmbus_resume(struct device *child_device)
 
return drv->resume(dev);
 }
+#endif /* CONFIG_PM */
 
 /*
  * vmbus_device_release - Final callback release of the vmbus child device
@@ -1070,6 +1072,7 @@ void vmbus_on_msg_dpc(unsigned long data)
vmbus_signal_eom(msg, message_type);
 }
 
+#ifdef CONFIG_PM
 /*
  * Fake RESCIND_CHANNEL messages to clean up hv_sock channels by force for
  * hibernation, because hv_sock connections can not persist across hibernation.
@@ -1105,6 +1108,7 @@ static void vmbus_force_channel_rescinded(struct 
vmbus_channel *channel)
  vmbus_connection.work_queue,
  >work);
 }
+#endif /* CONFIG_PM */
 
 /*
  * Direct callback for channels using other deferred processing
@@ -2125,6 +2129,7 @@ static int vmbus_acpi_add(struct acpi_device *device)
return ret_val;
 }
 
+#ifdef CONFIG_PM
 static int vmbus_bus_suspend(struct device *dev)
 {
struct vmbus_channel *channel, *sc;
@@ -2247,6 +2252,7 @@ static int vmbus_bus_resume(struct device *dev)
 
return 0;
 }
+#endif /* CONFIG_PM */
 
 static const struct acpi_device_id vmbus_acpi_device_ids[] = {
{"VMBUS", 0},
-- 
2.19.1



RE: [PATCH] hv: vmbus: mark PM functions as __maybe_unused

2019-09-18 Thread Dexuan Cui
> From: Arnd Bergmann 
> Sent: Wednesday, September 18, 2019 1:01 PM
> 
> When CONFIG_PM is disabled, we get a couple of harmless warnings:
> 
> drivers/hv/vmbus_drv.c:918:12: error: unused function 'vmbus_suspend'
> [-Werror,-Wunused-function]
> drivers/hv/vmbus_drv.c:937:12: error: unused function 'vmbus_resume'
> [-Werror,-Wunused-function]
> drivers/hv/vmbus_drv.c:2128:12: error: unused function 'vmbus_bus_suspend'
> [-Werror,-Wunused-function]
> drivers/hv/vmbus_drv.c:2208:12: error: unused function 'vmbus_bus_resume'
> [-Werror,-Wunused-function]
> 
> Mark these functions __maybe_unused to let gcc drop them silently.

Hi Arnd,
Thanks for reporting the issue!

If CONFIG_PM is not set, IMO it's better to comment out these functions. :-)

I'll post a patch for this with you Cc'd.

Thanks,
-- Dexuan


[PATCH 1/3] arm64: dts: imx8mq: Use correct clock for usdhc's ipg clk

2019-09-18 Thread Anson Huang
On i.MX8MQ, usdhc's ipg clock is from IMX8MQ_CLK_IPG_ROOT,
assign it explicitly instead of using IMX8MQ_CLK_DUMMY.

Signed-off-by: Anson Huang 
---
 arch/arm64/boot/dts/freescale/imx8mq.dtsi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
index fd42bee..e2c95ad 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
@@ -850,7 +850,7 @@
 "fsl,imx7d-usdhc";
reg = <0x30b4 0x1>;
interrupts = ;
-   clocks = < IMX8MQ_CLK_DUMMY>,
+   clocks = < IMX8MQ_CLK_IPG_ROOT>,
 < IMX8MQ_CLK_NAND_USDHC_BUS>,
 < IMX8MQ_CLK_USDHC1_ROOT>;
clock-names = "ipg", "ahb", "per";
@@ -867,7 +867,7 @@
 "fsl,imx7d-usdhc";
reg = <0x30b5 0x1>;
interrupts = ;
-   clocks = < IMX8MQ_CLK_DUMMY>,
+   clocks = < IMX8MQ_CLK_IPG_ROOT>,
 < IMX8MQ_CLK_NAND_USDHC_BUS>,
 < IMX8MQ_CLK_USDHC2_ROOT>;
clock-names = "ipg", "ahb", "per";
-- 
2.7.4



[PATCH 3/3] arm64: dts: imx8mn: Use correct clock for usdhc's ipg clk

2019-09-18 Thread Anson Huang
On i.MX8MN, usdhc's ipg clock is from IMX8MN_CLK_IPG_ROOT,
assign it explicitly instead of using IMX8MN_CLK_DUMMY.

Signed-off-by: Anson Huang 
---
 arch/arm64/boot/dts/freescale/imx8mn.dtsi | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mn.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mn.dtsi
index 6cb6c9c..725a3a3 100644
--- a/arch/arm64/boot/dts/freescale/imx8mn.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mn.dtsi
@@ -594,7 +594,7 @@
compatible = "fsl,imx8mn-usdhc", 
"fsl,imx7d-usdhc";
reg = <0x30b4 0x1>;
interrupts = ;
-   clocks = < IMX8MN_CLK_DUMMY>,
+   clocks = < IMX8MN_CLK_IPG_ROOT>,
 < IMX8MN_CLK_NAND_USDHC_BUS>,
 < IMX8MN_CLK_USDHC1_ROOT>;
clock-names = "ipg", "ahb", "per";
@@ -610,7 +610,7 @@
compatible = "fsl,imx8mn-usdhc", 
"fsl,imx7d-usdhc";
reg = <0x30b5 0x1>;
interrupts = ;
-   clocks = < IMX8MN_CLK_DUMMY>,
+   clocks = < IMX8MN_CLK_IPG_ROOT>,
 < IMX8MN_CLK_NAND_USDHC_BUS>,
 < IMX8MN_CLK_USDHC2_ROOT>;
clock-names = "ipg", "ahb", "per";
@@ -624,7 +624,7 @@
compatible = "fsl,imx8mn-usdhc", 
"fsl,imx7d-usdhc";
reg = <0x30b6 0x1>;
interrupts = ;
-   clocks = < IMX8MN_CLK_DUMMY>,
+   clocks = < IMX8MN_CLK_IPG_ROOT>,
 < IMX8MN_CLK_NAND_USDHC_BUS>,
 < IMX8MN_CLK_USDHC3_ROOT>;
clock-names = "ipg", "ahb", "per";
-- 
2.7.4



[PATCH 2/3] arm64: dts: imx8mm: Use correct clock for usdhc's ipg clk

2019-09-18 Thread Anson Huang
On i.MX8MM, usdhc's ipg clock is from IMX8MM_CLK_IPG_ROOT,
assign it explicitly instead of using IMX8MM_CLK_DUMMY.

Signed-off-by: Anson Huang 
---
 arch/arm64/boot/dts/freescale/imx8mm.dtsi | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mm.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mm.dtsi
index 7c4dcce..8aafad2 100644
--- a/arch/arm64/boot/dts/freescale/imx8mm.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mm.dtsi
@@ -694,7 +694,7 @@
compatible = "fsl,imx8mm-usdhc", 
"fsl,imx7d-usdhc";
reg = <0x30b4 0x1>;
interrupts = ;
-   clocks = < IMX8MM_CLK_DUMMY>,
+   clocks = < IMX8MM_CLK_IPG_ROOT>,
 < IMX8MM_CLK_NAND_USDHC_BUS>,
 < IMX8MM_CLK_USDHC1_ROOT>;
clock-names = "ipg", "ahb", "per";
@@ -710,7 +710,7 @@
compatible = "fsl,imx8mm-usdhc", 
"fsl,imx7d-usdhc";
reg = <0x30b5 0x1>;
interrupts = ;
-   clocks = < IMX8MM_CLK_DUMMY>,
+   clocks = < IMX8MM_CLK_IPG_ROOT>,
 < IMX8MM_CLK_NAND_USDHC_BUS>,
 < IMX8MM_CLK_USDHC2_ROOT>;
clock-names = "ipg", "ahb", "per";
@@ -724,7 +724,7 @@
compatible = "fsl,imx8mm-usdhc", 
"fsl,imx7d-usdhc";
reg = <0x30b6 0x1>;
interrupts = ;
-   clocks = < IMX8MM_CLK_DUMMY>,
+   clocks = < IMX8MM_CLK_IPG_ROOT>,
 < IMX8MM_CLK_NAND_USDHC_BUS>,
 < IMX8MM_CLK_USDHC3_ROOT>;
clock-names = "ipg", "ahb", "per";
-- 
2.7.4



Re: [PATCH 3/5] ocxl: Tally up the LPC memory on a link & allow it to be mapped

2019-09-18 Thread Alastair D'Silva
On Wed, 2019-09-18 at 16:02 +0200, Frederic Barrat wrote:
> 
> Le 17/09/2019 à 03:42, Alastair D'Silva a écrit :
> > From: Alastair D'Silva 
> > 
> > Tally up the LPC memory on an OpenCAPI link & allow it to be mapped
> > 
> > Signed-off-by: Alastair D'Silva 
> > ---
> >   drivers/misc/ocxl/core.c  |  9 +
> >   drivers/misc/ocxl/link.c  | 61
> > +++
> >   drivers/misc/ocxl/ocxl_internal.h | 42 +
> >   3 files changed, 112 insertions(+)
> > 
> > diff --git a/drivers/misc/ocxl/core.c b/drivers/misc/ocxl/core.c
> > index b7a09b21ab36..fdfe4e0a34e1 100644
> > --- a/drivers/misc/ocxl/core.c
> > +++ b/drivers/misc/ocxl/core.c
> > @@ -230,8 +230,17 @@ static int configure_afu(struct ocxl_afu *afu,
> > u8 afu_idx, struct pci_dev *dev)
> > if (rc)
> > goto err_free_pasid;
> >   
> > +   if (afu->config.lpc_mem_size || afu-
> > >config.special_purpose_mem_size) {
> > +   rc = ocxl_link_add_lpc_mem(afu->fn->link,
> > +   afu->config.lpc_mem_size + afu-
> > >config.special_purpose_mem_size);
> 
> I don't think we should count the special purpose memory, as it's
> not 
> meant to be accessed through the GPU mem BAR, but I'll check.

At least for OpenCAPI 3.0, there is no other in-spec way to access the
memory if it is not mapped by the NPU.

> 
> What happens when unconfiguring the AFU? We should reduce the range
> (see 
> also below). Partial reconfig doesn't seem so far off, so we should
> take 
> it into account.
> 

The mapping is left until the last AFU on the link offlines it's
memory, at which point we clear the mapping from the NPU.

> 
> > +   if (rc)
> > +   goto err_free_mmio;
> > +   }
> > +
> > return 0;
> >   
> > +err_free_mmio:
> > +   unmap_mmio_areas(afu);
> >   err_free_pasid:
> > reclaim_afu_pasid(afu);
> >   err_free_actag:
> > diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c
> > index 58d111afd9f6..2874811a4398 100644
> > --- a/drivers/misc/ocxl/link.c
> > +++ b/drivers/misc/ocxl/link.c
> > @@ -84,6 +84,11 @@ struct ocxl_link {
> > int dev;
> > atomic_t irq_available;
> > struct spa *spa;
> > +   struct mutex lpc_mem_lock;
> > +   u64 lpc_mem_sz; /* Total amount of LPC memory presented on the
> > link */
> > +   u64 lpc_mem;
> > +   int lpc_consumers;
> > +
> > void *platform_data;
> >   };
> >   static struct list_head links_list = LIST_HEAD_INIT(links_list);
> > @@ -396,6 +401,8 @@ static int alloc_link(struct pci_dev *dev, int
> > PE_mask, struct ocxl_link **out_l
> > if (rc)
> > goto err_spa;
> >   
> > +   mutex_init(>lpc_mem_lock);
> > +
> > /* platform specific hook */
> > rc = pnv_ocxl_spa_setup(dev, link->spa->spa_mem, PE_mask,
> > >platform_data);
> > @@ -711,3 +718,57 @@ void ocxl_link_free_irq(void *link_handle, int
> > hw_irq)
> > atomic_inc(>irq_available);
> >   }
> >   EXPORT_SYMBOL_GPL(ocxl_link_free_irq);
> > +
> > +int ocxl_link_add_lpc_mem(void *link_handle, u64 size)
> > +{
> > +   struct ocxl_link *link = (struct ocxl_link *) link_handle;
> > +
> > +   u64 orig_size;
> > +   bool good = false;
> > +
> > +   mutex_lock(>lpc_mem_lock);
> > +   orig_size = link->lpc_mem_sz;
> > +   link->lpc_mem_sz += size;
> 
> 
> We have a choice to make here:
> 1. either we only support one LPC memory-carrying AFU (and the above
> is 
> overkill)
> 2. or we support multiple AFUs with LPC memory (on the same
> function), 
> but then I think the above is too simple.
> 
>  From the opencapi spec, each AFU can define a chunk of memory with
> a 
> starting address and a size. There's no rule which says they have to
> be 
> contiguous. There's no rule which says it must start at 0. So to
> support 
> multiple AFUs with LPC memory, we should record the current maximum 
> range instead of just the global size. Ultimately, we need to tell
> the 
> NPU the range of permissible addresses. It starts at 0, so we need
> to 
> take into account any intial offset and holes.
> 
> I would go for option 2, to at least be consistent within ocxl and 
> support multiple AFUs. Even though I don't think we'll see FPGA
> images 
> with multiple AFUs with LPC memory any time soon.
> 

Ill rework this to take an offset & size, the NPU will map from the
base address up to the largest offset + size provided across all AFUs
on the link.

> 
> > +   good = orig_size < link->lpc_mem_sz;
> > +   mutex_unlock(>lpc_mem_lock);
> > +
> > +   // Check for overflow
> > +   return (good) ? 0 : -EINVAL;
> > +}
> > +EXPORT_SYMBOL_GPL(ocxl_link_add_lpc_mem);
> 
> Do the symbol really need to be exported? IIUC, the next patch
> defines a 
> higher level ocxl_afu_map_lpc_mem() which is meant to be called by a 
> calling driver.
> 

No, I'll remove it.

> 
> > +
> > +u64 ocxl_link_lpc_map(void *link_handle, struct pci_dev *pdev)
> > +{
> > +   struct ocxl_link *link = (struct ocxl_link *) link_handle;
> > +
> > + 

Re: [PATCH V2 2/2] mm/pgtable/debug: Add test validating architecture page table helpers

2019-09-18 Thread Anshuman Khandual



On 09/18/2019 09:56 PM, Christophe Leroy wrote:
> 
> 
> Le 18/09/2019 à 07:04, Anshuman Khandual a écrit :
>>
>>
>> On 09/13/2019 03:31 PM, Christophe Leroy wrote:
>>>
>>>
>>> Le 13/09/2019 à 11:02, Anshuman Khandual a écrit :

>> +#if !defined(__PAGETABLE_PMD_FOLDED) && !defined(__ARCH_HAS_4LEVEL_HACK)
>
> #ifdefs have to be avoided as much as possible, see below

 Yeah but it has been bit difficult to avoid all these $ifdef because of the
 availability (or lack of it) for all these pgtable helpers in various 
 config
 combinations on all platforms.
>>>
>>> As far as I can see these pgtable helpers should exist everywhere at least 
>>> via asm-generic/ files.
>>
>> But they might not actually do the right thing.
>>
>>>
>>> Can you spot a particular config which fails ?
>>
>> Lets consider the following example (after removing the $ifdefs around it)
>> which though builds successfully but fails to pass the intended test. This
>> is with arm64 config 4K pages sizes with 39 bits VA space which ends up
>> with a 3 level page table arrangement.
>>
>> static void __init p4d_clear_tests(p4d_t *p4dp)
>> {
>>  p4d_t p4d = READ_ONCE(*p4dp);
> 
> My suggestion was not to completely drop the #ifdef but to do like you did in 
> pgd_clear_tests() for instance, ie to add the following test on top of the 
> function:
> 
> if (mm_pud_folded(mm) || is_defined(__ARCH_HAS_5LEVEL_HACK))
>     return;
> 

Sometimes this does not really work. On some platforms, combination of
__PAGETABLE_PUD_FOLDED and __ARCH_HAS_5LEVEL_HACK decide whether the
helpers such as __pud() or __pgd() is even available for that platform.
Ideally it should have been through generic falls backs in include/*/
but I guess there might be bugs on the platform or it has not been
changed to adopt 5 level page table framework with required folding
macros etc.

>>
>>  p4d = __p4d(p4d_val(p4d) | RANDOM_ORVALUE);
>>  WRITE_ONCE(*p4dp, p4d);
>>  p4d_clear(p4dp);
>>  p4d = READ_ONCE(*p4dp);
>>  WARN_ON(!p4d_none(p4d));
>> }
>>
>> The following test hits an error at WARN_ON(!p4d_none(p4d))
>>
>> [   16.757333] [ cut here ]
>> [   16.758019] WARNING: CPU: 11 PID: 1 at mm/arch_pgtable_test.c:187 
>> arch_pgtable_tests_init+0x24c/0x474
>> [   16.759455] Modules linked in:
>> [   16.759952] CPU: 11 PID: 1 Comm: swapper/0 Not tainted 
>> 5.3.0-next-20190916-5-g61c218153bb8-dirty #222
>> [   16.761449] Hardware name: linux,dummy-virt (DT)
>> [   16.762185] pstate: 0045 (nzcv daif +PAN -UAO)
>> [   16.762964] pc : arch_pgtable_tests_init+0x24c/0x474
>> [   16.763750] lr : arch_pgtable_tests_init+0x174/0x474
>> [   16.764534] sp : ffc011d7bd50
>> [   16.765065] x29: ffc011d7bd50 x28: 1756bac0
>> [   16.765908] x27: ff85ddaf3000 x26: 02e8
>> [   16.766767] x25: ffc0111ce000 x24: ff85ddaf32e8
>> [   16.767606] x23: ff85ddaef278 x22: 0045cc844000
>> [   16.768445] x21: 00065daef003 x20: 1754
>> [   16.769283] x19: ff85ddb6 x18: 0014
>> [   16.770122] x17: 980426bb x16: 698594c6
>> [   16.770976] x15: 66e25a88 x14: 
>> [   16.771813] x13: 1754 x12: 000a
>> [   16.772651] x11: ff85fcfd0a40 x10: 0001
>> [   16.773488] x9 : 0008 x8 : ffc01143ab26
>> [   16.774336] x7 :  x6 : 
>> [   16.775180] x5 :  x4 : 
>> [   16.776018] x3 : 1756bbe8 x2 : 00065daeb003
>> [   16.776856] x1 : 0065daeb x0 : f000
>> [   16.777693] Call trace:
>> [   16.778092]  arch_pgtable_tests_init+0x24c/0x474
>> [   16.778843]  do_one_initcall+0x74/0x1b0
>> [   16.779458]  kernel_init_freeable+0x1cc/0x290
>> [   16.780151]  kernel_init+0x10/0x100
>> [   16.780710]  ret_from_fork+0x10/0x18
>> [   16.781282] ---[ end trace 042e6c40c0a3b038 ]---
>>
>> On arm64 (4K page size|39 bits VA|3 level page table)
>>
>> #elif CONFIG_PGTABLE_LEVELS == 3    /* Applicable here */
>> #define __ARCH_USE_5LEVEL_HACK
>> #include 
>>
>> Which pulls in
>>
>> #include 
>>
>> which pulls in
>>
>> #include 
>>
>> which defines
>>
>> static inline int p4d_none(p4d_t p4d)
>> {
>>  return 0;
>> }
>>
>> which will invariably trigger WARN_ON(!p4d_none(p4d)).
>>
>> Similarly for next test p4d_populate_tests() which will always be
>> successful because p4d_bad() invariably returns negative.
>>
>> static inline int p4d_bad(p4d_t p4d)
>> {
>>  return 0;
>> }
>>
>> static void __init p4d_populate_tests(struct mm_struct *mm, p4d_t *p4dp,
>>    pud_t *pudp)
>> {
>>  p4d_t p4d;
>>
>>  /*
>>   * This entry points to next level page table page.
>>   * Hence this must not qualify as p4d_bad().
>>   */
>>  pud_clear(pudp);
>>  p4d_clear(p4dp);
>> 

RE: [PATCH] devfreq: Make log message more explicit when devfreq device already exists

2019-09-18 Thread MyungJoo Ham
>Before creating a new devfreq device devfreq_add_device() checks
>if there is already a devfreq dev associated with the requesting
>device (parent). If that's the case the function rejects to create
>another devfreq dev for that parent and logs an error. The error
>message is very unspecific, make it a bit more explicit.
>
>Signed-off-by: Matthias Kaehlcke 
>---
> drivers/devfreq/devfreq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>index ab22bf8a12d6..0e2dd734ab58 100644
>--- a/drivers/devfreq/devfreq.c
>+++ b/drivers/devfreq/devfreq.c
>@@ -625,7 +625,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
>   devfreq = find_device_devfreq(dev);
>   mutex_unlock(_list_lock);
>   if (!IS_ERR(devfreq)) {
>-  dev_err(dev, "%s: Unable to create devfreq for the device.\n",
>+  dev_err(dev, "%s: devfreq device already exists!\n",

Yes, this is more helpful! Thanks!

Acked-by: MyungJoo Ham 




Re: [PATCH] mm: Support memblock alloc on the exact node for sparse_buffer_init()

2019-09-18 Thread Mike Rapoport
Hi,

On Wed, Sep 18, 2019 at 12:22:29PM +0800, Yunfeng Ye wrote:
> Currently, when memblock_find_in_range_node() fail on the exact node, it
> will use %NUMA_NO_NODE to find memblock from other nodes. At present,
> the work is good, but when the large memory is insufficient and the
> small memory is enough, we want to allocate the small memory of this
> node first, and do not need to allocate large memory from other nodes.
> 
> In sparse_buffer_init(), it will prepare large chunks of memory for page
> structure. The page management structure requires a lot of memory, but
> if the node does not have enough memory, it can be converted to a small
> memory allocation without having to allocate it from other nodes.
> 
> Add %MEMBLOCK_ALLOC_EXACT_NODE flag for this situation. Normally, the
> behavior is the same with %MEMBLOCK_ALLOC_ACCESSIBLE, only that it will
> not allocate from other nodes when a single node fails to allocate.
> 
> If large contiguous block memory allocated fail in sparse_buffer_init(),
> it will allocates small block memmory section by section later.

Did you see the sparse_buffer_init() actually falling back to allocate from a
different node? If a node does not have enough memory to hold it's own
memory map, filling only it with parts of the memory map will not make such
node usable.
 
> Signed-off-by: Yunfeng Ye 
> ---
>  include/linux/memblock.h | 1 +
>  mm/memblock.c| 3 ++-
>  mm/sparse.c  | 2 +-
>  3 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/memblock.h b/include/linux/memblock.h
> index f491690..9a81d9c 100644
> --- a/include/linux/memblock.h
> +++ b/include/linux/memblock.h
> @@ -339,6 +339,7 @@ static inline int memblock_get_region_node(const struct 
> memblock_region *r)
>  #define MEMBLOCK_ALLOC_ANYWHERE  (~(phys_addr_t)0)
>  #define MEMBLOCK_ALLOC_ACCESSIBLE0
>  #define MEMBLOCK_ALLOC_KASAN 1
> +#define MEMBLOCK_ALLOC_EXACT_NODE2
> 
>  /* We are using top down, so it is safe to use 0 here */
>  #define MEMBLOCK_LOW_LIMIT 0
> diff --git a/mm/memblock.c b/mm/memblock.c
> index 7d4f61a..dbd52c3c 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -277,6 +277,7 @@ static phys_addr_t __init_memblock 
> memblock_find_in_range_node(phys_addr_t size,
> 
>   /* pump up @end */
>   if (end == MEMBLOCK_ALLOC_ACCESSIBLE ||
> + end == MEMBLOCK_ALLOC_EXACT_NODE ||
>   end == MEMBLOCK_ALLOC_KASAN)
>   end = memblock.current_limit;
> 
> @@ -1365,7 +1366,7 @@ static phys_addr_t __init 
> memblock_alloc_range_nid(phys_addr_t size,
>   if (found && !memblock_reserve(found, size))
>   goto done;
> 
> - if (nid != NUMA_NO_NODE) {
> + if (end != MEMBLOCK_ALLOC_EXACT_NODE && nid != NUMA_NO_NODE) {
>   found = memblock_find_in_range_node(size, align, start,
>   end, NUMA_NO_NODE,
>   flags);
> diff --git a/mm/sparse.c b/mm/sparse.c
> index 72f010d..828db46 100644
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -477,7 +477,7 @@ static void __init sparse_buffer_init(unsigned long size, 
> int nid)
>   sparsemap_buf =
>   memblock_alloc_try_nid_raw(size, PAGE_SIZE,
>   addr,
> - MEMBLOCK_ALLOC_ACCESSIBLE, nid);
> + MEMBLOCK_ALLOC_EXACT_NODE, nid);
>   sparsemap_buf_end = sparsemap_buf + size;
>  }
> 
> -- 
> 2.7.4.huawei.3
> 
> 

-- 
Sincerely yours,
Mike.



Re: [PATCH] staging: mt7621-pci-phy: Use devm_platform_ioremap_resource() in mt7621_pci_phy_probe()

2019-09-18 Thread Sergio Paracuellos
Hi Markus,

Thanks for the patch. It looks good to me.

On Wed, Sep 18, 2019 at 9:12 PM Markus Elfring  wrote:
>
> From: Markus Elfring 
> Date: Wed, 18 Sep 2019 21:01:32 +0200
>
> Simplify this function implementation by using a known wrapper function.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring 
> ---
>  drivers/staging/mt7621-pci-phy/pci-mt7621-phy.c | 10 +-
>  1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/drivers/staging/mt7621-pci-phy/pci-mt7621-phy.c 
> b/drivers/staging/mt7621-pci-phy/pci-mt7621-phy.c
> index d2a07f145143..6ca4a33d13c3 100644
> --- a/drivers/staging/mt7621-pci-phy/pci-mt7621-phy.c
> +++ b/drivers/staging/mt7621-pci-phy/pci-mt7621-phy.c
> @@ -324,7 +324,6 @@ static int mt7621_pci_phy_probe(struct platform_device 
> *pdev)
> const struct soc_device_attribute *attr;
> struct phy_provider *provider;
> struct mt7621_pci_phy *phy;
> -   struct resource *res;
> int port;
> void __iomem *port_base;
>
> @@ -344,14 +343,7 @@ static int mt7621_pci_phy_probe(struct platform_device 
> *pdev)
>
> phy->dev = dev;
> platform_set_drvdata(pdev, phy);
> -
> -   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -   if (!res) {
> -   dev_err(dev, "failed to get address resource\n");
> -   return -ENXIO;
> -   }
> -
> -   port_base = devm_ioremap_resource(dev, res);
> +   port_base = devm_platform_ioremap_resource(pdev, 0);
> if (IS_ERR(port_base)) {
> dev_err(dev, "failed to remap phy regs\n");
> return PTR_ERR(port_base);
> --
> 2.23.0
>

Reviewed-by: Sergio Paracuellos 


RE: [EXT] Re: [v4 2/2] clk: ls1028a: Add clock driver for Display output interface

2019-09-18 Thread Wen He


> -Original Message-
> From: Stephen Boyd 
> Sent: 2019年9月19日 1:01
> To: devicet...@vger.kernel.org; linux-...@vger.kernel.org;
> linux-de...@linux.nxdi.nxp.com; linux-kernel@vger.kernel.org; Mark Rutland
> ; Michael Turquette ;
> Rob Herring ; Wen He 
> Cc: Leo Li ; liviu.du...@arm.com
> Subject: RE: [EXT] Re: [v4 2/2] clk: ls1028a: Add clock driver for Display 
> output
> interface
> 
> 
> Quoting Wen He (2019-09-18 02:20:26)
> > > -Original Message-
> > > From: Stephen Boyd  Quoting Wen He (2019-08-29
> > > 03:59:19)
> > > > diff --git a/drivers/clk/clk-plldig.c b/drivers/clk/clk-plldig.c
> > > > new file mode 100644 index ..d3239bcf59de
> > > > --- /dev/null
> > > > +++ b/drivers/clk/clk-plldig.c
> > > > @@ -0,0 +1,298 @@
> [...]
> >
> > >
> > > > +
> > > > +/* Maximum of the divider */
> > > > +#define MAX_RFDPHI1  63
> > > > +
> > > > +/* Best value of multiplication factor divider */
> > > > +#define PLLDIG_DEFAULE_MULT 44
> > > > +
> > > > +/*
> > > > + * Clock configuration relationship between the PHI1
> > > > +frequency(fpll_phi) and
> > > > + * the output frequency of the PLL is determined by the PLLDV,
> > > > +according to
> > > > + * the following equation:
> > > > + * fpll_phi = (pll_ref * mfd) / div_rfdphi1  */ struct
> > > > +plldig_phi1_param {
> > > > +   unsigned long rate;
> > > > +   unsigned int rfdphi1;
> > > > +   unsigned int mfd;
> > > > +};
> > > > +
> > > > +enum plldig_phi1_freq_range {
> > > > +   PHI1_MIN= 2700U,
> > > > +   PHI1_MAX= 6U
> > > > +};
> > >
> > > Please just inline these values in the one place they're used.
> > >
> > > > +
> > > > +struct clk_plldig {
> > > > +   struct clk_hw hw;
> > > > +   void __iomem *regs;
> > > > +   struct device *dev;
> > >
> > > Please remove this, it is unused.
> >
> > It is used for probe.
> 
> Use a local variable and don't store it away forever in the struct.
> 

Understand, will remove it.

> > >
> > > > +
> > > > +   val = readl(data->regs + PLLDIG_REG_PLLDV);
> > > > +   val = phi1_param.mfd;
> > > > +   rfdphi1 = phi1_param.rfdphi1;
> > > > +   val |= rfdphi1;
> > > > +
> > > > +   writel(val, data->regs + PLLDIG_REG_PLLDV);
> > > > +
> > > > +   /* delay 200us make sure that old lock state is cleared */
> > > > +   udelay(200);
> > > > +
> > > > +   /* Wait until PLL is locked or timeout (maximum 1000 usecs) */
> > > > +   ret = readl_poll_timeout_atomic(data->regs +
> > > > + PLLDIG_REG_PLLSR,
> > > cond,
> > > > +   cond &
> PLLDIG_LOCK_MASK,
> > > 0,
> > > > +   USEC_PER_MSEC);
> > > > +
> > > > +   return ret;
> > >
> > > Just return readl_poll_timeout_atomic(...) here.
> >
> > Maybe use below code will to best describes.
> >
> > If (ret)
> > return -ETIMEOUT;
> >
> > return 0;
> 
> No, just return readl_poll_timeout_atomic().

Understand, I will send next version patch for this.

Thanks && Best Regards,
Wen



Re: [PATCH] [RFC] vmscan.c: add a sysctl entry for controlling memory reclaim IO congestion_wait length

2019-09-18 Thread Matthew Wilcox
On Thu, Sep 19, 2019 at 10:33:10AM +0800, Lin Feng wrote:
> On 9/18/19 20:33, Michal Hocko wrote:
> > I absolutely agree here. From you changelog it is also not clear what is
> > the underlying problem. Both congestion_wait and wait_iff_congested
> > should wake up early if the congestion is handled. Is this not the case?
> 
> For now I don't know why, codes seem should work as you said, maybe I need to
> trace more of the internals.
> But weird thing is that once I set the people-disliked-tunable iowait
> drop down instantly, this is contradictory to the code design.

Yes, this is quite strange.  If setting a smaller timeout makes a
difference, that indicates we're not waking up soon enough.  I see
two possibilities; one is that a wakeup is missing somewhere -- ie the
conditions under which we call clear_wb_congested() are wrong.  Or we
need to wake up sooner.

Umm.  We have clear_wb_congested() called from exactly one spot --
clear_bdi_congested().  That is only called from:

drivers/block/pktcdvd.c
fs/ceph/addr.c
fs/fuse/control.c
fs/fuse/dev.c
fs/nfs/write.c

Jens, is something supposed to be calling clear_bdi_congested() in the
block layer?  blk_clear_congested() used to exist until October 29th
last year.  Or is something else supposed to be waking up tasks that
are sleeping on congestion?



Re: [PATCH v3 1/5] powerpc: Allow flush_icache_range to work across ranges >4GB

2019-09-18 Thread Alastair D'Silva
On Thu, 2019-09-19 at 13:43 +1000, Michael Ellerman wrote:
> "Alastair D'Silva"  writes:
> > From: Alastair D'Silva 
> > 
> > When calling flush_icache_range with a size >4GB, we were masking
> > off the upper 32 bits, so we would incorrectly flush a range
> > smaller
> > than intended.
> > 
> > __kernel_sync_dicache in the 64 bit VDSO has the same bug.
> 
> Please fix that in a separate patch.
> 
> Your subject doesn't mention __kernel_sync_dicache(), and also the
> two
> changes backport differently, so it's better if they're done as
> separate
> patches.
> 

Ok.

> cheers
> 
> > This patch replaces the 32 bit shifts with 64 bit ones, so that
> > the full size is accounted for.
> > 
> > Signed-off-by: Alastair D'Silva 
> > Cc: sta...@vger.kernel.org
> > ---
> >  arch/powerpc/kernel/misc_64.S   | 4 ++--
> >  arch/powerpc/kernel/vdso64/cacheflush.S | 4 ++--
> >  2 files changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/arch/powerpc/kernel/misc_64.S
> > b/arch/powerpc/kernel/misc_64.S
> > index b55a7b4cb543..9bc0aa9aeb65 100644
> > --- a/arch/powerpc/kernel/misc_64.S
> > +++ b/arch/powerpc/kernel/misc_64.S
> > @@ -82,7 +82,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
> > subfr8,r6,r4/* compute length */
> > add r8,r8,r5/* ensure we get enough */
> > lwz r9,DCACHEL1LOGBLOCKSIZE(r10)/* Get log-2 of cache block
> > size */
> > -   srw.r8,r8,r9/* compute line count */
> > +   srd.r8,r8,r9/* compute line count */
> > beqlr   /* nothing to do? */
> > mtctr   r8
> >  1: dcbst   0,r6
> > @@ -98,7 +98,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
> > subfr8,r6,r4/* compute length */
> > add r8,r8,r5
> > lwz r9,ICACHEL1LOGBLOCKSIZE(r10)/* Get log-2 of Icache
> > block size */
> > -   srw.r8,r8,r9/* compute line count */
> > +   srd.r8,r8,r9/* compute line count */
> > beqlr   /* nothing to do? */
> > mtctr   r8
> >  2: icbi0,r6
> > diff --git a/arch/powerpc/kernel/vdso64/cacheflush.S
> > b/arch/powerpc/kernel/vdso64/cacheflush.S
> > index 3f92561a64c4..526f5ba2593e 100644
> > --- a/arch/powerpc/kernel/vdso64/cacheflush.S
> > +++ b/arch/powerpc/kernel/vdso64/cacheflush.S
> > @@ -35,7 +35,7 @@ V_FUNCTION_BEGIN(__kernel_sync_dicache)
> > subfr8,r6,r4/* compute length */
> > add r8,r8,r5/* ensure we get enough */
> > lwz r9,CFG_DCACHE_LOGBLOCKSZ(r10)
> > -   srw.r8,r8,r9/* compute line count */
> > +   srd.r8,r8,r9/* compute line count */
> > crclr   cr0*4+so
> > beqlr   /* nothing to do? */
> > mtctr   r8
> > @@ -52,7 +52,7 @@ V_FUNCTION_BEGIN(__kernel_sync_dicache)
> > subfr8,r6,r4/* compute length */
> > add r8,r8,r5
> > lwz r9,CFG_ICACHE_LOGBLOCKSZ(r10)
> > -   srw.r8,r8,r9/* compute line count */
> > +   srd.r8,r8,r9/* compute line count */
> > crclr   cr0*4+so
> > beqlr   /* nothing to do? */
> > mtctr   r8
> > -- 
> > 2.21.0
-- 
Alastair D'Silva
Open Source Developer
Linux Technology Centre, IBM Australia
mob: 0423 762 819



Re: [PATCH v3 1/5] powerpc: Allow flush_icache_range to work across ranges >4GB

2019-09-18 Thread Michael Ellerman
"Alastair D'Silva"  writes:
> From: Alastair D'Silva 
>
> When calling flush_icache_range with a size >4GB, we were masking
> off the upper 32 bits, so we would incorrectly flush a range smaller
> than intended.
>
> __kernel_sync_dicache in the 64 bit VDSO has the same bug.

Please fix that in a separate patch.

Your subject doesn't mention __kernel_sync_dicache(), and also the two
changes backport differently, so it's better if they're done as separate
patches.

cheers

> This patch replaces the 32 bit shifts with 64 bit ones, so that
> the full size is accounted for.
>
> Signed-off-by: Alastair D'Silva 
> Cc: sta...@vger.kernel.org
> ---
>  arch/powerpc/kernel/misc_64.S   | 4 ++--
>  arch/powerpc/kernel/vdso64/cacheflush.S | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S
> index b55a7b4cb543..9bc0aa9aeb65 100644
> --- a/arch/powerpc/kernel/misc_64.S
> +++ b/arch/powerpc/kernel/misc_64.S
> @@ -82,7 +82,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
>   subfr8,r6,r4/* compute length */
>   add r8,r8,r5/* ensure we get enough */
>   lwz r9,DCACHEL1LOGBLOCKSIZE(r10)/* Get log-2 of cache block 
> size */
> - srw.r8,r8,r9/* compute line count */
> + srd.r8,r8,r9/* compute line count */
>   beqlr   /* nothing to do? */
>   mtctr   r8
>  1:   dcbst   0,r6
> @@ -98,7 +98,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
>   subfr8,r6,r4/* compute length */
>   add r8,r8,r5
>   lwz r9,ICACHEL1LOGBLOCKSIZE(r10)/* Get log-2 of Icache block 
> size */
> - srw.r8,r8,r9/* compute line count */
> + srd.r8,r8,r9/* compute line count */
>   beqlr   /* nothing to do? */
>   mtctr   r8
>  2:   icbi0,r6
> diff --git a/arch/powerpc/kernel/vdso64/cacheflush.S 
> b/arch/powerpc/kernel/vdso64/cacheflush.S
> index 3f92561a64c4..526f5ba2593e 100644
> --- a/arch/powerpc/kernel/vdso64/cacheflush.S
> +++ b/arch/powerpc/kernel/vdso64/cacheflush.S
> @@ -35,7 +35,7 @@ V_FUNCTION_BEGIN(__kernel_sync_dicache)
>   subfr8,r6,r4/* compute length */
>   add r8,r8,r5/* ensure we get enough */
>   lwz r9,CFG_DCACHE_LOGBLOCKSZ(r10)
> - srw.r8,r8,r9/* compute line count */
> + srd.r8,r8,r9/* compute line count */
>   crclr   cr0*4+so
>   beqlr   /* nothing to do? */
>   mtctr   r8
> @@ -52,7 +52,7 @@ V_FUNCTION_BEGIN(__kernel_sync_dicache)
>   subfr8,r6,r4/* compute length */
>   add r8,r8,r5
>   lwz r9,CFG_ICACHE_LOGBLOCKSZ(r10)
> - srw.r8,r8,r9/* compute line count */
> + srd.r8,r8,r9/* compute line count */
>   crclr   cr0*4+so
>   beqlr   /* nothing to do? */
>   mtctr   r8
> -- 
> 2.21.0


[PATCH] perf/probe: Skip same probe address

2019-09-18 Thread Masami Hiramatsu
Fix to skip making a same probe address on given line.

Since dwarf line info contains several entries for one line
with different column, perf probe will make a different
probe on same address if user specifies a probe point by
"function:line" or "file:line".

e.g.
 $ perf probe -D kernel_read:8
 p:probe/kernel_read_L8 kernel_read+39
 p:probe/kernel_read_L8_1 kernel_read+39

This skips such duplicated probe address.

Signed-off-by: Masami Hiramatsu 
---
 tools/perf/util/probe-finder.c |   19 +++
 1 file changed, 19 insertions(+)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 025fc4491993..02ca95deaf2c 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -1244,6 +1244,17 @@ static int expand_probe_args(Dwarf_Die *sc_die, struct 
probe_finder *pf,
return n;
 }
 
+static bool trace_event_finder_overlap(struct trace_event_finder *tf)
+{
+   int i;
+
+   for (i = 0; i < tf->ntevs; i++) {
+   if (tf->pf.addr == tf->tevs[i].point.address)
+   return true;
+   }
+   return false;
+}
+
 /* Add a found probe point into trace event list */
 static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf)
 {
@@ -1254,6 +1265,14 @@ static int add_probe_trace_event(Dwarf_Die *sc_die, 
struct probe_finder *pf)
struct perf_probe_arg *args = NULL;
int ret, i;
 
+   /*
+* For some reason (e.g. different column assigned to same address)
+* This callback can be called with the address which already passed.
+* Ignore it first.
+*/
+   if (trace_event_finder_overlap(tf))
+   return 0;
+
/* Check number of tevs */
if (tf->ntevs == tf->max_tevs) {
pr_warning("Too many( > %d) probe point found.\n",



Re: [PATCH v2] serial: sprd: Add polling IO support

2019-09-18 Thread hhome liu
Baolin Wang  于2019年9月19日周四 上午11:21写道:
>
> Hi,
>
> On Thu, 19 Sep 2019 at 11:10, Lanqing Liu  wrote:
> >
> > In order to access the UART without the interrupts, the kernel uses
> > the basic polling methods for IO with the device. With these methods
> > implemented, it is now possible to enable kgdb during early boot over 
> > serial.
> >
> > Signed-off-by: Lanqing Liu 
> > ---
> > Change from v1:
> >  - Add poll_init() support.
>
> Looks good to me and the KGDB can work well on my board, so feel free
> to add my tags:
> Reviewed-by: Baolin Wang 
> Tested-by: Baolin Wang 
>
ok, thanks
> > ---
> >  drivers/tty/serial/sprd_serial.c | 33 +
> >  1 file changed, 33 insertions(+)
> >
> > diff --git a/drivers/tty/serial/sprd_serial.c 
> > b/drivers/tty/serial/sprd_serial.c
> > index 73d71a4..d833160 100644
> > --- a/drivers/tty/serial/sprd_serial.c
> > +++ b/drivers/tty/serial/sprd_serial.c
> > @@ -911,6 +911,34 @@ static void sprd_pm(struct uart_port *port, unsigned 
> > int state,
> > }
> >  }
> >
> > +#ifdef CONFIG_CONSOLE_POLL
> > +static int sprd_poll_init(struct uart_port *port)
> > +{
> > +   if (port->state->pm_state != UART_PM_STATE_ON) {
> > +   sprd_pm(port, UART_PM_STATE_ON, 0);
> > +   port->state->pm_state = UART_PM_STATE_ON;
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> > +static int sprd_poll_get_char(struct uart_port *port)
> > +{
> > +   while (!(serial_in(port, SPRD_STS1) & SPRD_RX_FIFO_CNT_MASK))
> > +   cpu_relax();
> > +
> > +   return serial_in(port, SPRD_RXD);
> > +}
> > +
> > +static void sprd_poll_put_char(struct uart_port *port, unsigned char ch)
> > +{
> > +   while (serial_in(port, SPRD_STS1) & SPRD_TX_FIFO_CNT_MASK)
> > +   cpu_relax();
> > +
> > +   serial_out(port, SPRD_TXD, ch);
> > +}
> > +#endif
> > +
> >  static const struct uart_ops serial_sprd_ops = {
> > .tx_empty = sprd_tx_empty,
> > .get_mctrl = sprd_get_mctrl,
> > @@ -928,6 +956,11 @@ static void sprd_pm(struct uart_port *port, unsigned 
> > int state,
> > .config_port = sprd_config_port,
> > .verify_port = sprd_verify_port,
> > .pm = sprd_pm,
> > +#ifdef CONFIG_CONSOLE_POLL
> > +   .poll_init  = sprd_poll_init,
> > +   .poll_get_char  = sprd_poll_get_char,
> > +   .poll_put_char  = sprd_poll_put_char,
> > +#endif
> >  };
> >
> >  #ifdef CONFIG_SERIAL_SPRD_CONSOLE
> > --
> > 1.9.1
> >
>
>
> --
> Baolin Wang
> Best Regards


Re: [PATCH v3 3/3] HID: core: fix dmesg flooding if report field larger than 32bit

2019-09-18 Thread Joshua Clayton
Thanks!
It means a lot to have this accepted.
I actually started working on it, thinking "how hard can it be to
increase the size of a data structure"? It only has to be forward
compatible anyway.
My gut feeling is the existing code is working way too hard to do what
should be a memcpy, and the impulse to "fix" it is strong, despite my
absolute lack of usb-hid experience.

But the history of this little bit of code is already fraught with
complaints about big endian breakage.
I'm tempted to make it much simpler for size>32 bits (fix it only for
future users), or just way simpler for little endian,
But what do I know about usb and big endian? I sure don't have the
equipment to test it. And I worry a little I might be forgetting some
oddball non-byte-aligned data structure, which the spec would
theoretically allow.
Perhaps I'll have to time and courage to take another stab.

~Joshua

On Wed, Sep 18, 2019 at 11:35 AM Benjamin Tissoires
 wrote:
>
> On Thu, Aug 29, 2019 at 1:26 AM Joshua Clayton  
> wrote:
> >
> > ping?
> > I'd love to see this get in.
> > with distro kernel I have effectively no dmesg due to this issue
>
> Apologies for the delay.
>
> I really thought we should find a better way of fixing this, until I
> got a laptop affected by it. This series is a must have.
>
> Applied to for-5.4/core
>
> Cheers,
> Benjamin
>
> >
> > On Mon, Aug 12, 2019 at 9:20 AM  wrote:
> > >
> > > From: Joshua Clayton 
> > >
> > > Only warn once of oversize hid report value field
> > >
> > > On HP spectre x360 convertible the message:
> > > hid-sensor-hub 001F:8087:0AC2.0002: hid_field_extract() called with n 
> > > (192) > 32! (kworker/1:2)
> > > is continually printed many times per second, crowding out all else.
> > > Protect dmesg by printing the warning only one time.
> > >
> > > The size of the hid report field data structure should probably be 
> > > increased.
> > > The data structure is treated as a u32 in Linux, but an unlimited number
> > > of bits in the USB hid spec, so there is some rearchitecture needed now 
> > > that
> > > devices are sending more than 32 bits.
> > >
> > > Signed-off-by: Joshua Clayton 
> > >
> > > diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> > > index 210b81a56e1a..3eaee2c37931 100644
> > > --- a/drivers/hid/hid-core.c
> > > +++ b/drivers/hid/hid-core.c
> > > @@ -1311,8 +1311,8 @@ u32 hid_field_extract(const struct hid_device *hid, 
> > > u8 *report,
> > > unsigned offset, unsigned n)
> > >  {
> > > if (n > 32) {
> > > -   hid_warn(hid, "hid_field_extract() called with n (%d) > 
> > > 32! (%s)\n",
> > > -n, current->comm);
> > > +   hid_warn_once(hid, "%s() called with n (%d) > 32! (%s)\n",
> > > + __func__, n, current->comm);
> > > n = 32;
> > > }
> > >
> > > --
> > > 2.21.0
> > >
>


Re: [PATCH v2 3/6] platform/x86: huawei-wmi: Implement huawei wmi management

2019-09-18 Thread kbuild test robot
Hi Ayman,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[cannot apply to v5.3 next-20190918]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:
https://github.com/0day-ci/linux/commits/Ayman-Bagabas/platform-x86-Huawei-WMI-laptop-extras-driver/20190919-090022
config: x86_64-allyesconfig (attached as .config)
compiler: gcc-7 (Debian 7.4.0-13) 7.4.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot 

All warnings (new ones prefixed by >>):

   In file included from include/uapi/linux/posix_types.h:5:0,
from include/uapi/linux/types.h:14,
from include/linux/compiler.h:180,
from include/linux/ioport.h:13,
from include/linux/acpi.h:12,
from drivers/platform/x86/huawei-wmi.c:8:
   drivers/platform/x86/huawei-wmi.c: In function 'huawei_wmi_micmute_led_set':
>> include/linux/stddef.h:8:14: warning: passing argument 3 of 'huawei_wmi_cmd' 
>> makes integer from pointer without a cast [-Wint-conversion]
#define NULL ((void *)0)
 ^
>> drivers/platform/x86/huawei-wmi.c:290:40: note: in expansion of macro 'NULL'
  return huawei_wmi_cmd(arg.cmd, NULL, NULL);
   ^~~~
   drivers/platform/x86/huawei-wmi.c:161:12: note: expected 'size_t {aka long 
unsigned int}' but argument is of type 'void *'
static int huawei_wmi_cmd(u64 arg, u8 *buf, size_t buflen)
   ^~

vim +/huawei_wmi_cmd +8 include/linux/stddef.h

^1da177e4c3f41 Linus Torvalds   2005-04-16  6  
^1da177e4c3f41 Linus Torvalds   2005-04-16  7  #undef NULL
^1da177e4c3f41 Linus Torvalds   2005-04-16 @8  #define NULL ((void *)0)
6e218287432472 Richard Knutsson 2006-09-30  9  

:: The code at line 8 was first introduced by commit
:: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:: TO: Linus Torvalds 
:: CC: Linus Torvalds 

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


.config.gz
Description: application/gzip


Re: arch/riscv: disable too many harts before pick main boot hart

2019-09-18 Thread Xiang Wang






‐‐‐ Original Message ‐‐‐
On 2019年9月14日SaturdayAM3点04分, Palmer Dabbelt  wrote:

> On Thu, 05 Sep 2019 23:51:15 PDT (-0700), me...@hardenedlinux.org wrote:
>
> > From 12300865d1103618c9d4c375f7d7fbe601b6618c Mon Sep 17 00:00:00 2001
> > From: Xiang Wang me...@hardenedlinux.org
> > Date: Fri, 6 Sep 2019 11:56:09 +0800
> > Subject: [PATCH] arch/riscv: disable too many harts before pick main boot 
> > hart
> > These harts with id greater than or equal to CONFIG_NR_CPUS need to be 
> > disabled.
> > But pick the main Hart can choose any one. So, before pick the main hart, 
> > you
> > need to disable the hart with id greater than or equal to CONFIG_NR_CPUS.
> >
> > Signed-off-by: Xiang Wang me...@hardenedlinux.org
> >
> > --
> >
> > arch/riscv/kernel/head.S | 8 +---
> > 1 file changed, 5 insertions(+), 3 deletions(-)
> > diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S
> > index 0f1ba17e476f..cfffea38eb17 100644
> > --- a/arch/riscv/kernel/head.S
> > +++ b/arch/riscv/kernel/head.S
> > @@ -63,6 +63,11 @@ _start_kernel:
> > li t0, SR_FS
> > csrc sstatus, t0
> > +#ifdef CONFIG_SMP
> >
> > -   li t0, CONFIG_NR_CPUS
> > -   bgeu a0, t0, .Lsecondary_park
> > +#endif
> >
> > -
> >
> > /* Pick one hart to run the main boot sequence */
> > la a3, hart_lottery
> > li a2, 1
> > @@ -154,9 +159,6 @@ relocate:
> > .Lsecondary_start:
> > #ifdef CONFIG_SMP
> >
> > -   li a1, CONFIG_NR_CPUS
> > -   bgeu a0, a1, .Lsecondary_park
> > -
> >
> > /* Set trap vector to spin forever to help debug */
> > la a3, .Lsecondary_park
> > csrw CSR_STVEC, a3
>
> It would be better to decouple the hart masks from NR_CPUS, as there's really
> no reason for these to be the same.

This may be new feature. Need to define new macros such as disabled_hart_mask,
this patch is used to fix bug and not add new feature.

>
> Reviewed-by: Palmer Dabbelt pal...@sifive.com




Re: [PATCH v2] serial: sprd: Add polling IO support

2019-09-18 Thread Baolin Wang
Hi,

On Thu, 19 Sep 2019 at 11:10, Lanqing Liu  wrote:
>
> In order to access the UART without the interrupts, the kernel uses
> the basic polling methods for IO with the device. With these methods
> implemented, it is now possible to enable kgdb during early boot over serial.
>
> Signed-off-by: Lanqing Liu 
> ---
> Change from v1:
>  - Add poll_init() support.

Looks good to me and the KGDB can work well on my board, so feel free
to add my tags:
Reviewed-by: Baolin Wang 
Tested-by: Baolin Wang 

> ---
>  drivers/tty/serial/sprd_serial.c | 33 +
>  1 file changed, 33 insertions(+)
>
> diff --git a/drivers/tty/serial/sprd_serial.c 
> b/drivers/tty/serial/sprd_serial.c
> index 73d71a4..d833160 100644
> --- a/drivers/tty/serial/sprd_serial.c
> +++ b/drivers/tty/serial/sprd_serial.c
> @@ -911,6 +911,34 @@ static void sprd_pm(struct uart_port *port, unsigned int 
> state,
> }
>  }
>
> +#ifdef CONFIG_CONSOLE_POLL
> +static int sprd_poll_init(struct uart_port *port)
> +{
> +   if (port->state->pm_state != UART_PM_STATE_ON) {
> +   sprd_pm(port, UART_PM_STATE_ON, 0);
> +   port->state->pm_state = UART_PM_STATE_ON;
> +   }
> +
> +   return 0;
> +}
> +
> +static int sprd_poll_get_char(struct uart_port *port)
> +{
> +   while (!(serial_in(port, SPRD_STS1) & SPRD_RX_FIFO_CNT_MASK))
> +   cpu_relax();
> +
> +   return serial_in(port, SPRD_RXD);
> +}
> +
> +static void sprd_poll_put_char(struct uart_port *port, unsigned char ch)
> +{
> +   while (serial_in(port, SPRD_STS1) & SPRD_TX_FIFO_CNT_MASK)
> +   cpu_relax();
> +
> +   serial_out(port, SPRD_TXD, ch);
> +}
> +#endif
> +
>  static const struct uart_ops serial_sprd_ops = {
> .tx_empty = sprd_tx_empty,
> .get_mctrl = sprd_get_mctrl,
> @@ -928,6 +956,11 @@ static void sprd_pm(struct uart_port *port, unsigned int 
> state,
> .config_port = sprd_config_port,
> .verify_port = sprd_verify_port,
> .pm = sprd_pm,
> +#ifdef CONFIG_CONSOLE_POLL
> +   .poll_init  = sprd_poll_init,
> +   .poll_get_char  = sprd_poll_get_char,
> +   .poll_put_char  = sprd_poll_put_char,
> +#endif
>  };
>
>  #ifdef CONFIG_SERIAL_SPRD_CONSOLE
> --
> 1.9.1
>


-- 
Baolin Wang
Best Regards


[PATCH v2] serial: sprd: Add polling IO support

2019-09-18 Thread Lanqing Liu
In order to access the UART without the interrupts, the kernel uses
the basic polling methods for IO with the device. With these methods
implemented, it is now possible to enable kgdb during early boot over serial.

Signed-off-by: Lanqing Liu 
---
Change from v1:
 - Add poll_init() support.
---
 drivers/tty/serial/sprd_serial.c | 33 +
 1 file changed, 33 insertions(+)

diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
index 73d71a4..d833160 100644
--- a/drivers/tty/serial/sprd_serial.c
+++ b/drivers/tty/serial/sprd_serial.c
@@ -911,6 +911,34 @@ static void sprd_pm(struct uart_port *port, unsigned int 
state,
}
 }
 
+#ifdef CONFIG_CONSOLE_POLL
+static int sprd_poll_init(struct uart_port *port)
+{
+   if (port->state->pm_state != UART_PM_STATE_ON) {
+   sprd_pm(port, UART_PM_STATE_ON, 0);
+   port->state->pm_state = UART_PM_STATE_ON;
+   }
+
+   return 0;
+}
+
+static int sprd_poll_get_char(struct uart_port *port)
+{
+   while (!(serial_in(port, SPRD_STS1) & SPRD_RX_FIFO_CNT_MASK))
+   cpu_relax();
+
+   return serial_in(port, SPRD_RXD);
+}
+
+static void sprd_poll_put_char(struct uart_port *port, unsigned char ch)
+{
+   while (serial_in(port, SPRD_STS1) & SPRD_TX_FIFO_CNT_MASK)
+   cpu_relax();
+
+   serial_out(port, SPRD_TXD, ch);
+}
+#endif
+
 static const struct uart_ops serial_sprd_ops = {
.tx_empty = sprd_tx_empty,
.get_mctrl = sprd_get_mctrl,
@@ -928,6 +956,11 @@ static void sprd_pm(struct uart_port *port, unsigned int 
state,
.config_port = sprd_config_port,
.verify_port = sprd_verify_port,
.pm = sprd_pm,
+#ifdef CONFIG_CONSOLE_POLL
+   .poll_init  = sprd_poll_init,
+   .poll_get_char  = sprd_poll_get_char,
+   .poll_put_char  = sprd_poll_put_char,
+#endif
 };
 
 #ifdef CONFIG_SERIAL_SPRD_CONSOLE
-- 
1.9.1



[PATCH v2] clk: imx7ulp: remove IMX7ULP_CLK_MIPI_PLL clock

2019-09-18 Thread Fancy Fang
The mipi pll clock comes from the MIPI PHY PLL output, so
it should not be a fixed clock.

MIPI PHY PLL is in the MIPI DSI space, and it is used as
the bit clock for transferring the pixel data out and its
output clock is configured according to the display mode.

So it should be used only for MIPI DSI and not be exported
out for other usages.

Signed-off-by: Fancy Fang 
---
ChangeLog v1->v2:
 * Keep other clock indexes unchanged as Shawn suggested.

 Documentation/devicetree/bindings/clock/imx7ulp-clock.txt | 1 -
 drivers/clk/imx/clk-imx7ulp.c | 3 +--
 include/dt-bindings/clock/imx7ulp-clock.h | 1 -
 3 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/clock/imx7ulp-clock.txt 
b/Documentation/devicetree/bindings/clock/imx7ulp-clock.txt
index a4f8cd478f92..93d89adb7afe 100644
--- a/Documentation/devicetree/bindings/clock/imx7ulp-clock.txt
+++ b/Documentation/devicetree/bindings/clock/imx7ulp-clock.txt
@@ -82,7 +82,6 @@ pcc2: pcc2@403f {
 < IMX7ULP_CLK_APLL_PFD0>,
 < IMX7ULP_CLK_UPLL>,
 < IMX7ULP_CLK_SOSC_BUS_CLK>,
-< IMX7ULP_CLK_MIPI_PLL>,
 < IMX7ULP_CLK_FIRC_BUS_CLK>,
 < IMX7ULP_CLK_ROSC>,
 < IMX7ULP_CLK_SPLL_BUS_CLK>;
diff --git a/drivers/clk/imx/clk-imx7ulp.c b/drivers/clk/imx/clk-imx7ulp.c
index 995a4ad10904..936c39f767df 100644
--- a/drivers/clk/imx/clk-imx7ulp.c
+++ b/drivers/clk/imx/clk-imx7ulp.c
@@ -28,7 +28,7 @@ static const char * const scs_sels[]  = { "dummy", 
"sosc", "sirc", "firc", "dumm
 static const char * const ddr_sels[]   = { "apll_pfd_sel", "upll", };
 static const char * const nic_sels[]   = { "firc", "ddr_clk", };
 static const char * const periph_plat_sels[]   = { "dummy", "nic1_bus_clk", 
"nic1_clk", "ddr_clk", "apll_pfd2", "apll_pfd1", "apll_pfd0", "upll", };
-static const char * const periph_bus_sels[]= { "dummy", "sosc_bus_clk", 
"mpll", "firc_bus_clk", "rosc", "nic1_bus_clk", "nic1_clk", "spll_bus_clk", };
+static const char * const periph_bus_sels[]= { "dummy", "sosc_bus_clk", 
"dummy", "firc_bus_clk", "rosc", "nic1_bus_clk", "nic1_clk", "spll_bus_clk", };
 static const char * const arm_sels[]   = { "divcore", "dummy", 
"dummy", "hsrun_divcore", };
 
 /* used by sosc/sirc/firc/ddr/spll/apll dividers */
@@ -75,7 +75,6 @@ static void __init imx7ulp_clk_scg1_init(struct device_node 
*np)
clks[IMX7ULP_CLK_SOSC]  = imx_obtain_fixed_clk_hw(np, "sosc");
clks[IMX7ULP_CLK_SIRC]  = imx_obtain_fixed_clk_hw(np, "sirc");
clks[IMX7ULP_CLK_FIRC]  = imx_obtain_fixed_clk_hw(np, "firc");
-   clks[IMX7ULP_CLK_MIPI_PLL]  = imx_obtain_fixed_clk_hw(np, "mpll");
clks[IMX7ULP_CLK_UPLL]  = imx_obtain_fixed_clk_hw(np, "upll");
 
/* SCG1 */
diff --git a/include/dt-bindings/clock/imx7ulp-clock.h 
b/include/dt-bindings/clock/imx7ulp-clock.h
index 6f66f9005c81..a39b0c40cb41 100644
--- a/include/dt-bindings/clock/imx7ulp-clock.h
+++ b/include/dt-bindings/clock/imx7ulp-clock.h
@@ -49,7 +49,6 @@
 #define IMX7ULP_CLK_NIC1_DIV   36
 #define IMX7ULP_CLK_NIC1_BUS_DIV   37
 #define IMX7ULP_CLK_NIC1_EXT_DIV   38
-#define IMX7ULP_CLK_MIPI_PLL   39
 #define IMX7ULP_CLK_SIRC   40
 #define IMX7ULP_CLK_SOSC_BUS_CLK   41
 #define IMX7ULP_CLK_FIRC_BUS_CLK   42
-- 
2.17.1



[PATCH v2] clk: imx7ulp: remove IMX7ULP_CLK_MIPI_PLL clock

2019-09-18 Thread Fancy Fang
The mipi pll clock comes from the MIPI PHY PLL output, so
it should not be a fixed clock.

MIPI PHY PLL is in the MIPI DSI space, and it is used as
the bit clock for transferring the pixel data out and its
output clock is configured according to the display mode.

So it should be used only for MIPI DSI and not be exported
out for other usages.

Signed-off-by: Fancy Fang 
---
ChangeLog v1->v2:
 * Keep other clock indexes unchanged as Shawn suggested.

 Documentation/devicetree/bindings/clock/imx7ulp-clock.txt | 1 -
 drivers/clk/imx/clk-imx7ulp.c | 3 +--
 include/dt-bindings/clock/imx7ulp-clock.h | 1 -
 3 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/clock/imx7ulp-clock.txt 
b/Documentation/devicetree/bindings/clock/imx7ulp-clock.txt
index a4f8cd478f92..93d89adb7afe 100644
--- a/Documentation/devicetree/bindings/clock/imx7ulp-clock.txt
+++ b/Documentation/devicetree/bindings/clock/imx7ulp-clock.txt
@@ -82,7 +82,6 @@ pcc2: pcc2@403f {
 < IMX7ULP_CLK_APLL_PFD0>,
 < IMX7ULP_CLK_UPLL>,
 < IMX7ULP_CLK_SOSC_BUS_CLK>,
-< IMX7ULP_CLK_MIPI_PLL>,
 < IMX7ULP_CLK_FIRC_BUS_CLK>,
 < IMX7ULP_CLK_ROSC>,
 < IMX7ULP_CLK_SPLL_BUS_CLK>;
diff --git a/drivers/clk/imx/clk-imx7ulp.c b/drivers/clk/imx/clk-imx7ulp.c
index 995a4ad10904..936c39f767df 100644
--- a/drivers/clk/imx/clk-imx7ulp.c
+++ b/drivers/clk/imx/clk-imx7ulp.c
@@ -28,7 +28,7 @@ static const char * const scs_sels[]  = { "dummy", 
"sosc", "sirc", "firc", "dumm
 static const char * const ddr_sels[]   = { "apll_pfd_sel", "upll", };
 static const char * const nic_sels[]   = { "firc", "ddr_clk", };
 static const char * const periph_plat_sels[]   = { "dummy", "nic1_bus_clk", 
"nic1_clk", "ddr_clk", "apll_pfd2", "apll_pfd1", "apll_pfd0", "upll", };
-static const char * const periph_bus_sels[]= { "dummy", "sosc_bus_clk", 
"mpll", "firc_bus_clk", "rosc", "nic1_bus_clk", "nic1_clk", "spll_bus_clk", };
+static const char * const periph_bus_sels[]= { "dummy", "sosc_bus_clk", 
"dummy", "firc_bus_clk", "rosc", "nic1_bus_clk", "nic1_clk", "spll_bus_clk", };
 static const char * const arm_sels[]   = { "divcore", "dummy", 
"dummy", "hsrun_divcore", };
 
 /* used by sosc/sirc/firc/ddr/spll/apll dividers */
@@ -75,7 +75,6 @@ static void __init imx7ulp_clk_scg1_init(struct device_node 
*np)
clks[IMX7ULP_CLK_SOSC]  = imx_obtain_fixed_clk_hw(np, "sosc");
clks[IMX7ULP_CLK_SIRC]  = imx_obtain_fixed_clk_hw(np, "sirc");
clks[IMX7ULP_CLK_FIRC]  = imx_obtain_fixed_clk_hw(np, "firc");
-   clks[IMX7ULP_CLK_MIPI_PLL]  = imx_obtain_fixed_clk_hw(np, "mpll");
clks[IMX7ULP_CLK_UPLL]  = imx_obtain_fixed_clk_hw(np, "upll");
 
/* SCG1 */
diff --git a/include/dt-bindings/clock/imx7ulp-clock.h 
b/include/dt-bindings/clock/imx7ulp-clock.h
index 6f66f9005c81..a39b0c40cb41 100644
--- a/include/dt-bindings/clock/imx7ulp-clock.h
+++ b/include/dt-bindings/clock/imx7ulp-clock.h
@@ -49,7 +49,6 @@
 #define IMX7ULP_CLK_NIC1_DIV   36
 #define IMX7ULP_CLK_NIC1_BUS_DIV   37
 #define IMX7ULP_CLK_NIC1_EXT_DIV   38
-#define IMX7ULP_CLK_MIPI_PLL   39
 #define IMX7ULP_CLK_SIRC   40
 #define IMX7ULP_CLK_SOSC_BUS_CLK   41
 #define IMX7ULP_CLK_FIRC_BUS_CLK   42
-- 
2.17.1



Re: [PATCH v2 4/6] platform/x86: huawei-wmi: Add battery charging thresholds

2019-09-18 Thread kbuild test robot
Hi Ayman,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[cannot apply to v5.3 next-20190918]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:
https://github.com/0day-ci/linux/commits/Ayman-Bagabas/platform-x86-Huawei-WMI-laptop-extras-driver/20190919-090022
config: x86_64-randconfig-s1-201937 (attached as .config)
compiler: gcc-5 (Ubuntu 5.5.0-12ubuntu1) 5.5.0 20171010
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot 

All errors (new ones prefixed by >>):

   ld: drivers/platform/x86/asus-wmi.o: in function `asus_wmi_battery_init':
   drivers/platform/x86/asus-wmi.c:457: undefined reference to 
`battery_hook_register'
   ld: drivers/platform/x86/asus-wmi.o: in function `asus_wmi_battery_exit':
   drivers/platform/x86/asus-wmi.c:464: undefined reference to 
`battery_hook_unregister'
   ld: drivers/platform/x86/huawei-wmi.o: in function `huawei_wmi_battery_exit':
>> drivers/platform/x86/huawei-wmi.c:513: undefined reference to 
>> `battery_hook_unregister'
   ld: drivers/platform/x86/huawei-wmi.o: in function 
`huawei_wmi_battery_setup':
>> drivers/platform/x86/huawei-wmi.c:504: undefined reference to 
>> `battery_hook_register'

vim +513 drivers/platform/x86/huawei-wmi.c

   493  
   494  static void huawei_wmi_battery_setup(struct device *dev)
   495  {
   496  struct huawei_wmi *huawei = dev_get_drvdata(dev);
   497  
   498  huawei->battery_available = true;
   499  if (huawei_wmi_battery_get(NULL, NULL)) {
   500  huawei->battery_available = false;
   501  return;
   502  }
   503  
 > 504  battery_hook_register(_wmi_battery_hook);
   505  device_create_file(dev, _attr_charge_control_thresholds);
   506  }
   507  
   508  static void huawei_wmi_battery_exit(struct device *dev)
   509  {
   510  struct huawei_wmi *huawei = dev_get_drvdata(dev);
   511  
   512  if (huawei->battery_available) {
 > 513  battery_hook_unregister(_wmi_battery_hook);
   514  device_remove_file(dev, 
_attr_charge_control_thresholds);
   515  }
   516  }
   517  

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


.config.gz
Description: application/gzip


[PATCH v4 1/3] kernel/notifier.c: intercepting duplicate registrations to avoid infinite loops

2019-09-18 Thread Xiaoming Ni
Registering the same notifier to a hook repeatedly can cause the hook
list to form a ring or lose other members of the list.

case1: An infinite loop in notifier_chain_register() can cause soft lockup
atomic_notifier_chain_register(_notifier_list, );
atomic_notifier_chain_register(_notifier_list, );
atomic_notifier_chain_register(_notifier_list, );

case2: An infinite loop in notifier_chain_register() can cause soft lockup
atomic_notifier_chain_register(_notifier_list, );
atomic_notifier_chain_register(_notifier_list, );
atomic_notifier_call_chain(_notifier_list, 0, NULL);

case3: lose other hook test2
atomic_notifier_chain_register(_notifier_list, );
atomic_notifier_chain_register(_notifier_list, );
atomic_notifier_chain_register(_notifier_list, );

case4: Unregister returns 0, but the hook is still in the linked list,
and it is not really registered. If you call notifier_call_chain
after ko is unloaded, it will trigger oops.

If the system is configured with softlockup_panic and the same
hook is repeatedly registered on the panic_notifier_list, it
will cause a loop panic.

Add a check in notifier_chain_register(),
Intercepting duplicate registrations to avoid infinite loops

Signed-off-by: Xiaoming Ni 
Reviewed-by: Vasily Averin 
---
 kernel/notifier.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/notifier.c b/kernel/notifier.c
index d9f5081..30bedb8 100644
--- a/kernel/notifier.c
+++ b/kernel/notifier.c
@@ -23,7 +23,10 @@ static int notifier_chain_register(struct notifier_block 
**nl,
struct notifier_block *n)
 {
while ((*nl) != NULL) {
-   WARN_ONCE(((*nl) == n), "double register detected");
+   if (unlikely((*nl) == n)) {
+   WARN(1, "double register detected");
+   return 0;
+   }
if (n->priority > (*nl)->priority)
break;
nl = &((*nl)->next);
-- 
1.8.5.6



[PATCH v4 0/3] kernel/notifier.c: intercepting duplicate registrations to avoid infinite loops

2019-09-18 Thread Xiaoming Ni
Registering the same notifier to a hook repeatedly can cause the hook
list to form a ring or lose other members of the list.
so, need add a check in in notifier_chain_register(),
intercepting duplicate registrations to avoid infinite loops


v1:
* use notifier_chain_cond_register replace notifier_chain_register

v2:
* Add a check in notifier_chain_register() to avoid duplicate registration
* remove notifier_chain_cond_register() to avoid duplicate code 
* remove blocking_notifier_chain_cond_register() to avoid duplicate code

v3:
* Add a cover letter.

v4:
* Add Reviewed-by and adjust the title.

Xiaoming Ni (3):
  kernel/notifier.c: intercepting duplicate registrations to avoid
infinite loops
  kernel/notifier.c: remove notifier_chain_cond_register()
  kernel/notifier.c: remove blocking_notifier_chain_cond_register()

 include/linux/notifier.h |  4 
 kernel/notifier.c| 41 +++--
 net/sunrpc/rpc_pipe.c|  2 +-
 3 files changed, 4 insertions(+), 43 deletions(-)

-- 
1.8.5.6



[PATCH v4 3/3] kernel/notifier.c: remove blocking_notifier_chain_cond_register()

2019-09-18 Thread Xiaoming Ni
blocking_notifier_chain_cond_register() does not consider
system_booting state, which is the only difference between this
function and blocking_notifier_cain_register(). This can be a bug
and is a piece of duplicate code.

Delete blocking_notifier_chain_cond_register()

Signed-off-by: Xiaoming Ni 
---
 include/linux/notifier.h |  4 
 kernel/notifier.c| 23 ---
 net/sunrpc/rpc_pipe.c|  2 +-
 3 files changed, 1 insertion(+), 28 deletions(-)

diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index 0096a05..0189476 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -150,10 +150,6 @@ extern int raw_notifier_chain_register(struct 
raw_notifier_head *nh,
 extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
struct notifier_block *nb);
 
-extern int blocking_notifier_chain_cond_register(
-   struct blocking_notifier_head *nh,
-   struct notifier_block *nb);
-
 extern int atomic_notifier_chain_unregister(struct atomic_notifier_head *nh,
struct notifier_block *nb);
 extern int blocking_notifier_chain_unregister(struct blocking_notifier_head 
*nh,
diff --git a/kernel/notifier.c b/kernel/notifier.c
index e3d221f..63d7501 100644
--- a/kernel/notifier.c
+++ b/kernel/notifier.c
@@ -221,29 +221,6 @@ int blocking_notifier_chain_register(struct 
blocking_notifier_head *nh,
 EXPORT_SYMBOL_GPL(blocking_notifier_chain_register);
 
 /**
- * blocking_notifier_chain_cond_register - Cond add notifier to a blocking 
notifier chain
- * @nh: Pointer to head of the blocking notifier chain
- * @n: New entry in notifier chain
- *
- * Adds a notifier to a blocking notifier chain, only if not already
- * present in the chain.
- * Must be called in process context.
- *
- * Currently always returns zero.
- */
-int blocking_notifier_chain_cond_register(struct blocking_notifier_head *nh,
-   struct notifier_block *n)
-{
-   int ret;
-
-   down_write(>rwsem);
-   ret = notifier_chain_register(>head, n);
-   up_write(>rwsem);
-   return ret;
-}
-EXPORT_SYMBOL_GPL(blocking_notifier_chain_cond_register);
-
-/**
  * blocking_notifier_chain_unregister - Remove notifier from a blocking 
notifier chain
  * @nh: Pointer to head of the blocking notifier chain
  * @n: Entry to remove from notifier chain
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index b71a39d..39e14d5 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -51,7 +51,7 @@
 
 int rpc_pipefs_notifier_register(struct notifier_block *nb)
 {
-   return blocking_notifier_chain_cond_register(_pipefs_notifier_list, 
nb);
+   return blocking_notifier_chain_register(_pipefs_notifier_list, nb);
 }
 EXPORT_SYMBOL_GPL(rpc_pipefs_notifier_register);
 
-- 
1.8.5.6



RE: [PATCH V2 3/4] ASoC: pcm_dmaengine: Extract snd_dmaengine_pcm_set_runtime_hwparams

2019-09-18 Thread S.j. Wang
Hi

> 
> When set the runtime hardware parameters, we may need to query the
> capability of DMA to complete the parameters.
> 
> This patch is to Extract this operation from
> dmaengine_pcm_set_runtime_hwparams function to a separate function
> snd_dmaengine_pcm_set_runtime_hwparams, that other components
> which need this feature can call this function.
> 
> Signed-off-by: Shengjiu Wang 
> ---

kbuild test robot report compile issue, will resend v3 after fixing.

Best regards
Wang shengjiu


[PATCH v4 2/3] kernel/notifier.c: remove notifier_chain_cond_register()

2019-09-18 Thread Xiaoming Ni
The only difference between notifier_chain_cond_register() and
notifier_chain_register() is the lack of warning hints for duplicate
registrations.
Consider using notifier_chain_register() instead of
notifier_chain_cond_register() to avoid duplicate code

Signed-off-by: Xiaoming Ni 
---
 kernel/notifier.c | 17 +
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/kernel/notifier.c b/kernel/notifier.c
index 30bedb8..e3d221f 100644
--- a/kernel/notifier.c
+++ b/kernel/notifier.c
@@ -36,21 +36,6 @@ static int notifier_chain_register(struct notifier_block 
**nl,
return 0;
 }
 
-static int notifier_chain_cond_register(struct notifier_block **nl,
-   struct notifier_block *n)
-{
-   while ((*nl) != NULL) {
-   if ((*nl) == n)
-   return 0;
-   if (n->priority > (*nl)->priority)
-   break;
-   nl = &((*nl)->next);
-   }
-   n->next = *nl;
-   rcu_assign_pointer(*nl, n);
-   return 0;
-}
-
 static int notifier_chain_unregister(struct notifier_block **nl,
struct notifier_block *n)
 {
@@ -252,7 +237,7 @@ int blocking_notifier_chain_cond_register(struct 
blocking_notifier_head *nh,
int ret;
 
down_write(>rwsem);
-   ret = notifier_chain_cond_register(>head, n);
+   ret = notifier_chain_register(>head, n);
up_write(>rwsem);
return ret;
 }
-- 
1.8.5.6



Re: [PATCH] workqueue: Fix spurious sanity check failures in destroy_workqueue()

2019-09-18 Thread Lai Jiangshan
Looks good to me.

There is one test in show_pwq()
"""
 worker == pwq->wq->rescuer ? "(RESCUER)" : "",
"""
I'm wondering if it needs to be updated to
"""
worker->rescue_wq ? "(RESCUER)" : "",
"""

And document "/* MD: rescue worker */" might be better
than current "/* I: rescue worker */", although ->rescuer can
be accessed without wq_mayday_lock lock in some code.

Reviewed-by: Lai Jiangshan 



On Thu, Sep 19, 2019 at 9:43 AM Tejun Heo  wrote:
>
> Before actually destrying a workqueue, destroy_workqueue() checks
> whether it's actually idle.  If it isn't, it prints out a bunch of
> warning messages and leaves the workqueue dangling.  It unfortunately
> has a couple issues.
>
> * Mayday list queueing increments pwq's refcnts which gets detected as
>   busy and fails the sanity checks.  However, because mayday list
>   queueing is asynchronous, this condition can happen without any
>   actual work items left in the workqueue.
>
> * Sanity check failure leaves the sysfs interface behind too which can
>   lead to init failure of newer instances of the workqueue.
>
> This patch fixes the above two by
>
> * If a workqueue has a rescuer, disable and kill the rescuer before
>   sanity checks.  Disabling and killing is guaranteed to flush the
>   existing mayday list.
>
> * Remove sysfs interface before sanity checks.
>
> Signed-off-by: Tejun Heo 
> Reported-by: Marcin Pawlowski 
> Reported-by: "Williams, Gerald S" 
> Cc: sta...@vger.kernel.org
> ---
> Applying to wq/for-5.4.
>
> Thanks.
>
>  kernel/workqueue.c | 24 +++-
>  1 file changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index 95aea04ff722..73e3ea9e31d3 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -4318,9 +4318,28 @@ void destroy_workqueue(struct workqueue_struct *wq)
> struct pool_workqueue *pwq;
> int node;
>
> +   /*
> +* Remove it from sysfs first so that sanity check failure doesn't
> +* lead to sysfs name conflicts.
> +*/
> +   workqueue_sysfs_unregister(wq);
> +
> /* drain it before proceeding with destruction */
> drain_workqueue(wq);
>
> +   /* kill rescuer, if sanity checks fail, leave it w/o rescuer */
> +   if (wq->rescuer) {
> +   struct worker *rescuer = wq->rescuer;
> +
> +   /* this prevents new queueing */
> +   spin_lock_irq(_mayday_lock);
> +   wq->rescuer = NULL;
> +   spin_unlock_irq(_mayday_lock);
> +
> +   /* rescuer will empty maydays list before exiting */
> +   kthread_stop(rescuer->task);
> +   }
> +
> /* sanity checks */
> mutex_lock(>mutex);
> for_each_pwq(pwq, wq) {
> @@ -4352,11 +4371,6 @@ void destroy_workqueue(struct workqueue_struct *wq)
> list_del_rcu(>list);
> mutex_unlock(_pool_mutex);
>
> -   workqueue_sysfs_unregister(wq);
> -
> -   if (wq->rescuer)
> -   kthread_stop(wq->rescuer->task);
> -
> if (!(wq->flags & WQ_UNBOUND)) {
> wq_unregister_lockdep(wq);
> /*
> --
> 2.17.1
>


Re: Re: Re: [PATCH] connector: report comm change event when modifying /proc/pid/task/tid/comm

2019-09-18 Thread KeMeng Shi
On 2019/9/18 at 1:08, Will Deacon wrote:
>On Tue, Sep 17, 2019 at 09:56:28AM -0400, KeMeng Shi wrote:
>>on 2019/9/17 at 5:10, Will Deacon wrote:
>>>The rough idea looks ok to me but I have two concerns:
>>>
>>>  (1) This looks like it will be visible to userspace, and this changes
>>>  the behaviour after ~8 years of not reporting this event.
>>This do bother for users who only care the comm change via prctl, but 
>>it also benefits users who want all comm changes. Maybe the best way 
>>is add something like config or switch to meet the both conditions 
>>above. In my opinion, users cares comm change event rather than how it
>>change.
>
>I was really just looking for some intuition as to how this event is currently
>used and why extending it like this is unlikely to break those existing users.

By listening these comm change events, user is able to monitor and control
specific threads that they are interested. For instance, a process control
daemon listening to proc connector and following comm value policies can
place specific threads to assigned cgroup partitions (quota from commit
 f786ecba415888 ("connector: add comm change event report to proc
 connector")).  It's harmless as user ignore the threads with names that
they are not interested.

>>>(2) What prevents proc_comm_connector(p) running concurrently with 
>>>itself  via the prctl()? The locking seems to be confined to set_task_comm().
>>To be honest, I did not consider the concurrence problem at beginning. 
>>And some comm change events may lost or are reported repeatly as follows:
>>set name via procfs   set name via prctl
>>set_task_comm
>>  set_task_comm
>>proc_comm_connector
>>  proc_comm_connector
>>Comm change event belong to procfs losts and the fresh comm change 
>>belong to prctl is reported twice. Actually, there is also concurrence 
>>problem without this update as follows:
>>set name via procfs   set name via prctl
>>  set_task_comm
>>set_task_comm
>>  proc_comm_connector
>>Comm change event from procfs is reported instead of prctl, this may 
>>bothers user who only care the comm change via prctl.
>
>Perhaps, although given that proc_comm_connector() is currently only
>called on the prctl() path, then it does at least provide the comm
>from the most recent prctl() invocation. With your path, the calls
>can go out of order, so I think that probably needs fixing.

It's indeed necessary to fix the concurrence problem. I will submit
a v2 patch when I fix this.

Thanks for your review and advise.
KeMeng Shi


[PATCH] PCI: Enhance the ACS quirk for Cavium devices

2019-09-18 Thread George Cherian
Enhance the ACS quirk for Cavium Processors. Add the root port
vendor ID's in an array and use the same in match function.
For newer devices add the vendor ID's in the array so that the
match function is simpler.

Signed-off-by: George Cherian 
---
 drivers/pci/quirks.c | 28 +++-
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 44c4ae1abd00..64deeaddd51c 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -4241,17 +4241,27 @@ static int pci_quirk_amd_sb_acs(struct pci_dev *dev, 
u16 acs_flags)
 #endif
 }
 
+static const u16 pci_quirk_cavium_acs_ids[] = {
+   /* CN88xx family of devices */
+   0xa180, 0xa170,
+   /* CN99xx family of devices */
+   0xaf84,
+   /* CN11xxx family of devices */
+   0xb884,
+};
+
 static bool pci_quirk_cavium_acs_match(struct pci_dev *dev)
 {
-   /*
-* Effectively selects all downstream ports for whole ThunderX 1
-* family by 0xf800 mask (which represents 8 SoCs), while the lower
-* bits of device ID are used to indicate which subdevice is used
-* within the SoC.
-*/
-   return (pci_is_pcie(dev) &&
-   (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) &&
-   ((dev->device & 0xf800) == 0xa000));
+   int i;
+
+   if (!pci_is_pcie(dev) || pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT)
+   return false;
+
+   for (i = 0; i < ARRAY_SIZE(pci_quirk_cavium_acs_ids); i++)
+   if (pci_quirk_cavium_acs_ids[i] == dev->device)
+   return true;
+
+   return false;
 }
 
 static int pci_quirk_cavium_acs(struct pci_dev *dev, u16 acs_flags)
-- 
2.17.1



Re: [PATCH] staging: tracing/kprobe: filter kprobe based perf event

2019-09-18 Thread Jinshan Xiong
That's bloody true. Thanks for your insights.

I will make an example program and commit into bcc repository.

Jinshan


On Wed, Sep 18, 2019 at 1:22 PM Alexei Starovoitov
 wrote:
>
> On Wed, Sep 18, 2019 at 8:13 AM Jinshan Xiong  wrote:
> >
> > The problem with the current approach is that it would be difficult to 
> > filter cgroup, especially the cgroup in question has descendents, and also 
> > it would spawn new descendents after BPF program is installed. it's hard to 
> > filter it inside a BPF program.
>
> Why is that?
> bpf_current_task_under_cgroup() fits exactly that purpose.


Re: [PATCH] [RFC] vmscan.c: add a sysctl entry for controlling memory reclaim IO congestion_wait length

2019-09-18 Thread Lin Feng




On 9/18/19 20:33, Michal Hocko wrote:

+mm_reclaim_congestion_wait_jiffies
+==
+
+This control is used to define how long kernel will wait/sleep while
+system memory is under pressure and memroy reclaim is relatively active.
+Lower values will decrease the kernel wait/sleep time.
+
+It's suggested to lower this value on high-end box that system is under memory
+pressure but with low storage IO utils and high CPU iowait, which could also
+potentially decrease user application response time in this case.
+
+Keep this control as it were if your box are not above case.
+
+The default value is HZ/10, which is of equal value to 100ms independ of how
+many HZ is defined.

Adding a new tunable is not the right solution.  The right way is
to make Linux auto-tune itself to avoid the problem.

I absolutely agree here. From you changelog it is also not clear what is
the underlying problem. Both congestion_wait and wait_iff_congested
should wake up early if the congestion is handled. Is this not the case?


For now I don't know why, codes seem should work as you said, maybe I need to
trace more of the internals.
But weird thing is that once I set the people-disliked-tunable iowait
drop down instantly, this is contradictory to the code design.



Why? Are you sure a shorter timeout is not just going to cause problems
elsewhere. These sleeps are used to throttle the reclaim. I do agree
there is no great deal of design behind them so they are more of "let's
hope it works" kinda thing but making their timeout configurable just
doesn't solve this at all. You are effectively exporting a very subtle
implementation detail into the userspace.


Kind of agree, but it does fix the issue at least mine and user response
time also improve in the meantime.
So, just make it as it were and exported to someone needs it..



Re: [PATCH 2/3] dt-bindings: reset: add bindings for the Meson-A1 SoC Reset Controller

2019-09-18 Thread Xingyu Chen

Hi, Neil
Thanks for your review

On 2019/9/18 20:39, Neil Armstrong wrote:

Hi,

On 18/09/2019 14:12, Xingyu Chen wrote:

Add DT bindings for the Meson-A1 SoC Reset Controller include file,
and also slightly update documentation.

Signed-off-by: Xingyu Chen 
Signed-off-by: Jianxin Pan 
---
  .../bindings/reset/amlogic,meson-reset.txt |  4 +-


The reset bindings has been moved to yaml, either rebase on linux-next or wait 
for v5.4-rc1 :
https://kernel.googlesource.com/pub/scm/linux/kernel/git/next/linux-next/+/refs/tags/next-20190917/Documentation/devicetree/bindings/reset/amlogic%2Cmeson-reset.yaml

NeilI will fix it in next version.


  include/dt-bindings/reset/amlogic,meson-a1-reset.h | 59 ++
  2 files changed, 61 insertions(+), 2 deletions(-)
  create mode 100644 include/dt-bindings/reset/amlogic,meson-a1-reset.h

diff --git a/Documentation/devicetree/bindings/reset/amlogic,meson-reset.txt 
b/Documentation/devicetree/bindings/reset/amlogic,meson-reset.txt
index 28ef6c2..011151a 100644
--- a/Documentation/devicetree/bindings/reset/amlogic,meson-reset.txt
+++ b/Documentation/devicetree/bindings/reset/amlogic,meson-reset.txt
@@ -5,8 +5,8 @@ Please also refer to reset.txt in this directory for common 
reset
  controller binding usage.
  
  Required properties:

-- compatible: Should be "amlogic,meson8b-reset", "amlogic,meson-gxbb-reset" or
-   "amlogic,meson-axg-reset".
+- compatible: Should be "amlogic,meson8b-reset", "amlogic,meson-gxbb-reset",
+   "amlogic,meson-axg-reset" or "amlogic,meson-a1-reset".
  - reg: should contain the register address base
  - #reset-cells: 1, see below
  
diff --git a/include/dt-bindings/reset/amlogic,meson-a1-reset.h b/include/dt-bindings/reset/amlogic,meson-a1-reset.h

new file mode 100644
index ..8d76a47
--- /dev/null
+++ b/include/dt-bindings/reset/amlogic,meson-a1-reset.h
@@ -0,0 +1,59 @@
+/* SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+ *
+ * Copyright (c) 2019 Amlogic, Inc. All rights reserved.
+ * Author: Xingyu Chen 
+ *
+ */
+
+#ifndef _DT_BINDINGS_AMLOGIC_MESON_A1_RESET_H
+#define _DT_BINDINGS_AMLOGIC_MESON_A1_RESET_H
+
+/* RESET0 */
+#define RESET_AM2AXI_VAD   1
+#define RESET_PSRAM4
+#define RESET_PAD_CTRL 5
+#define RESET_TEMP_SENSOR  7
+#define RESET_AM2AXI_DEV   8
+#define RESET_SPICC_A  10
+#define RESET_MSR_CLK  11
+#define RESET_AUDIO12
+#define RESET_ANALOG_CTRL  13
+#define RESET_SAR_ADC  14
+#define RESET_AUDIO_VAD15
+#define RESET_CEC  16
+#define RESET_PWM_EF   17
+#define RESET_PWM_CD   18
+#define RESET_PWM_AB   19
+#define RESET_IR_CTRL  21
+#define RESET_I2C_S_A  22
+#define RESET_I2C_M_D  24
+#define RESET_I2C_M_C  25
+#define RESET_I2C_M_B  26
+#define RESET_I2C_M_A  27
+#define RESET_I2C_PROD_AHB 28
+#define RESET_I2C_PROD 29
+
+/* RESET1 */
+#define RESET_ACODEC   32
+#define RESET_DMA  33
+#define RESET_SD_EMMC_A34
+#define RESET_USBCTRL  36
+#define RESET_USBPHY   38
+#define RESET_RSA  42
+#define RESET_DMC  43
+#define RESET_IRQ_CTRL 45
+#define RESET_NIC_VAD  47
+#define RESET_NIC_AXI  48
+#define RESET_RAMA 49
+#define RESET_RAMB 50
+#define RESET_ROM  53
+#define RESET_SPIFC54
+#define RESET_GIC  55
+#define RESET_UART_C   56
+#define RESET_UART_B   57
+#define RESET_UART_A   58
+#define RESET_OSC_RING 59
+
+/* RESET2 Reserved */
+
+#endif



.



Re: [PATCH] [RFC] vmscan.c: add a sysctl entry for controlling memory reclaim IO congestion_wait length

2019-09-18 Thread Lin Feng

Hi,

On 9/18/19 19:38, Matthew Wilcox wrote:

On Wed, Sep 18, 2019 at 11:21:04AM +0800, Lin Feng wrote:

Adding a new tunable is not the right solution.  The right way is
to make Linux auto-tune itself to avoid the problem.  For example,
bdi_writeback contains an estimated write bandwidth (calculated by the
memory management layer).  Given that, we should be able to make an
estimate for how long to wait for the queues to drain.



Yes, I had ever considered that, auto-tuning is definitely the senior AI way.
While considering all kinds of production environments hybird storage solution
is also common today, servers' dirty pages' bdi drivers can span from high end
ssds to low end sata disk, so we have to think of a *formula(AI core)* by using
the factors of dirty pages' amount and bdis' write bandwidth, and this AI-core
will depend on if the estimated write bandwidth is sane and moreover the to be
written back dirty pages is sequential or random if the bdi is rotational disk,
it's likey to give a not-sane number and hurt guys who dont't want that, while
if only consider ssd is relatively simple.

So IMHO it's not sane to brute force add a guessing logic into memory writeback
codes and pray on inventing a formula that caters everyone's need.
Add a sysctl entry may be a right choice that give people who need it and
doesn't hurt people who don't want it.


You're making this sound far harder than it is.  All the writeback code
needs to know is "How long should I sleep for in order for the queues
to drain a substantial amount".  Since you know the bandwidth and how
many pages you've queued up, it's a simple calculation.



Ah, I should have read more of the writeback codes ;-)
Based on Michal's comments:
> the underlying problem. Both congestion_wait and wait_iff_congested
> should wake up early if the congestion is handled. Is this not the case?
If process is waken up once bdi congested is clear, this timeout length's role
seems not that important. I need to trace more if I can reproduce this issue
without online network traffic. But still weird thing is that once I set the
people-disliked-tunable iowait drop down instantly, they are contradictory.

Anyway, thanks a lot for your suggestions!
linfeng



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

2019-09-18 Thread Gene Chen
Lee Jones  於 2019年9月18日 週三 下午6:51寫道:
>
> On Wed, 18 Sep 2019, Gene Chen wrote:
>
> > From: Gene Chen 
> >
> > Add mfd driver for mt6360 pmic chip include
> > Battery Charger/USB_PD/Flash LED/RGB LED/LDO/Buck
> >
> > Signed-off-by: Gene Chen  > ---
>
> This looks different from the one you sent before, but I don't see a
> version bump or any changelog in this space.  Please re-submit with
> the differences noted.
>

the change is
1. add missing include file
2. modify commit message

this patch is regarded as version 1

> >  drivers/mfd/Kconfig|  12 +
> >  drivers/mfd/Makefile   |   1 +
> >  drivers/mfd/mt6360-core.c  | 463 
> > +
> >  include/linux/mfd/mt6360-private.h | 279 ++
> >  include/linux/mfd/mt6360.h |  33 +++
> >  5 files changed, 788 insertions(+)
> >  create mode 100644 drivers/mfd/mt6360-core.c
> >  create mode 100644 include/linux/mfd/mt6360-private.h
> >  create mode 100644 include/linux/mfd/mt6360.h
>
> --
> Lee Jones [李琼斯]
> Linaro Services Technical Lead
> Linaro.org │ Open source software for ARM SoCs
> Follow Linaro: Facebook | Twitter | Blog


[PATCH 4/4] thermal: step_wise: Extend thermal step-wise governor to monitor falling temperature.

2019-09-18 Thread Thara Gopinath
>From the step wise governor point of view, the policy decisions
that has to taken on a thermal trip point that is defined to be monitored
for falling temprature is the mirror opposite of the decisions it has
to take on a trip point that is monitored for rising temperature.

Signed-off-by: Thara Gopinath 
---
 drivers/thermal/step_wise.c | 59 +
 1 file changed, 44 insertions(+), 15 deletions(-)

diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
index 6e051cb..aa8e0a0 100644
--- a/drivers/thermal/step_wise.c
+++ b/drivers/thermal/step_wise.c
@@ -35,7 +35,8 @@
  *   deactivate the thermal instance
  */
 static unsigned long get_target_state(struct thermal_instance *instance,
-   enum thermal_trend trend, bool throttle)
+   enum thermal_trend trend, bool throttle,
+   enum thermal_trip_monitor_type type)
 {
struct thermal_cooling_device *cdev = instance->cdev;
unsigned long cur_state;
@@ -65,11 +66,21 @@ static unsigned long get_target_state(struct 
thermal_instance *instance,
 
switch (trend) {
case THERMAL_TREND_RAISING:
-   if (throttle) {
-   next_target = cur_state < instance->upper ?
-   (cur_state + 1) : instance->upper;
-   if (next_target < instance->lower)
-   next_target = instance->lower;
+   if (type == THERMAL_TRIP_MONITOR_FALLING) {
+   if (cur_state <= instance->lower) {
+   if (!throttle)
+   next_target = THERMAL_NO_TARGET;
+   } else {
+   if (!throttle)
+   next_target = cur_state - 1;
+   }
+   } else {
+   if (throttle) {
+   next_target = cur_state < instance->upper ?
+   (cur_state + 1) : instance->upper;
+   if (next_target < instance->lower)
+   next_target = instance->lower;
+   }
}
break;
case THERMAL_TREND_RAISE_FULL:
@@ -77,14 +88,23 @@ static unsigned long get_target_state(struct 
thermal_instance *instance,
next_target = instance->upper;
break;
case THERMAL_TREND_DROPPING:
-   if (cur_state <= instance->lower) {
-   if (!throttle)
-   next_target = THERMAL_NO_TARGET;
+   if (type == THERMAL_TRIP_MONITOR_FALLING) {
+   if (throttle) {
+   next_target = cur_state < instance->upper ?
+   (cur_state + 1) : instance->upper;
+   if (next_target < instance->lower)
+   next_target = instance->lower;
+   }
} else {
-   if (!throttle) {
-   next_target = cur_state - 1;
-   if (next_target > instance->upper)
-   next_target = instance->upper;
+   if (cur_state <= instance->lower) {
+   if (!throttle)
+   next_target = THERMAL_NO_TARGET;
+   } else {
+   if (!throttle) {
+   next_target = cur_state - 1;
+   if (next_target > instance->upper)
+   next_target = instance->upper;
+   }
}
}
break;
@@ -117,6 +137,8 @@ static void thermal_zone_trip_update(struct 
thermal_zone_device *tz, int trip)
 {
int trip_temp;
enum thermal_trip_type trip_type;
+   enum thermal_trip_monitor_type monitor_type =
+   THERMAL_TRIP_MONITOR_RISING;
enum thermal_trend trend;
struct thermal_instance *instance;
bool throttle = false;
@@ -130,9 +152,15 @@ static void thermal_zone_trip_update(struct 
thermal_zone_device *tz, int trip)
tz->ops->get_trip_type(tz, trip, _type);
}
 
+   if (tz->ops->get_trip_monitor_type)
+   tz->ops->get_trip_monitor_type(tz, trip, _type);
+
trend = get_tz_trend(tz, trip);
 
-   if (tz->temperature >= trip_temp) {
+   if (((monitor_type == THERMAL_TRIP_MONITOR_RISING) &&
+ (tz->temperature >= trip_temp)) ||
+ ((monitor_type == THERMAL_TRIP_MONITOR_FALLING) &&
+ (tz->temperature 

[PATCH 2/4] thermal: Thermal core and sysfs changes needed to support bi-directional monitoring of trip points.

2019-09-18 Thread Thara Gopinath
Thermal trip points can be defined to indicate whether a
temperature rise or a temperature fall is to be monitored. This
property can now be defined in the DT bindings for a trip point.
To support this following three changes are introduced to thermal
core and sysfs code.
1. Define a new variable in thermal_trip to capture the monitor
   rising/falling information from trip point DT bindings.
2. Define a new ops in thermal_zone_device_ops that can be populated
   to indicate whether a trip is being monitored for rising or falling
   temperature. If the ops is not populated or if the binding is missing
   in the DT, it is assumed that the trip is being monitored for rising
   temperature. (default behavior today)
3. Introduce sysfs entries for each trip point to read the direction of
   monitoring.

Signed-off-by: Thara Gopinath 
---
 drivers/thermal/thermal_sysfs.c | 60 ++---
 include/linux/thermal.h | 10 +++
 include/uapi/linux/thermal.h|  2 +-
 3 files changed, 67 insertions(+), 5 deletions(-)

diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
index aa99edb..b4ef6be 100644
--- a/drivers/thermal/thermal_sysfs.c
+++ b/drivers/thermal/thermal_sysfs.c
@@ -216,6 +216,31 @@ trip_point_hyst_show(struct device *dev, struct 
device_attribute *attr,
 }
 
 static ssize_t
+trip_point_monitor_type_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct thermal_zone_device *tz = to_thermal_zone(dev);
+   enum thermal_trip_monitor_type type;
+   int trip, result;
+
+   if (sscanf(attr->attr.name, "trip_point_%d_monitor_type", ) != 1)
+   return -EINVAL;
+
+   if (!tz->ops->get_trip_monitor_type)
+   goto exit;
+
+   result = tz->ops->get_trip_monitor_type(tz, trip, );
+   if (result)
+   return result;
+
+   if (type == THERMAL_TRIP_MONITOR_FALLING)
+   return sprintf(buf, "falling\n");
+
+exit:
+   return sprintf(buf, "rising\n");
+}
+
+static ssize_t
 passive_store(struct device *dev, struct device_attribute *attr,
  const char *buf, size_t count)
 {
@@ -520,10 +545,20 @@ static int create_trip_attrs(struct thermal_zone_device 
*tz, int mask)
if (!tz->trip_type_attrs)
return -ENOMEM;
 
+   tz->trip_monitor_type_attrs = kcalloc
+   (tz->trips,
+   sizeof(*tz->trip_monitor_type_attrs),
+   GFP_KERNEL);
+   if (!tz->trip_monitor_type_attrs) {
+   kfree(tz->trip_type_attrs);
+   return -ENOMEM;
+   }
+
tz->trip_temp_attrs = kcalloc(tz->trips, sizeof(*tz->trip_temp_attrs),
  GFP_KERNEL);
if (!tz->trip_temp_attrs) {
kfree(tz->trip_type_attrs);
+   kfree(tz->trip_monitor_type_attrs);
return -ENOMEM;
}
 
@@ -533,14 +568,16 @@ static int create_trip_attrs(struct thermal_zone_device 
*tz, int mask)
  GFP_KERNEL);
if (!tz->trip_hyst_attrs) {
kfree(tz->trip_type_attrs);
+   kfree(tz->trip_monitor_type_attrs);
kfree(tz->trip_temp_attrs);
return -ENOMEM;
}
}
 
-   attrs = kcalloc(tz->trips * 3 + 1, sizeof(*attrs), GFP_KERNEL);
+   attrs = kcalloc(tz->trips * 4 + 1, sizeof(*attrs), GFP_KERNEL);
if (!attrs) {
kfree(tz->trip_type_attrs);
+   kfree(tz->trip_monitor_type_attrs);
kfree(tz->trip_temp_attrs);
if (tz->ops->get_trip_hyst)
kfree(tz->trip_hyst_attrs);
@@ -559,6 +596,20 @@ static int create_trip_attrs(struct thermal_zone_device 
*tz, int mask)
tz->trip_type_attrs[indx].attr.show = trip_point_type_show;
attrs[indx] = >trip_type_attrs[indx].attr.attr;
 
+   /* create trip monitor type attribute */
+   snprintf(tz->trip_monitor_type_attrs[indx].name,
+THERMAL_NAME_LENGTH, "trip_point_%d_monitor_type",
+indx);
+
+   sysfs_attr_init(>trip_monitor_type_attrs[indx].attr.attr);
+   tz->trip_monitor_type_attrs[indx].attr.attr.name =
+   tz->trip_monitor_type_attrs[indx].name;
+   tz->trip_monitor_type_attrs[indx].attr.attr.mode = S_IRUGO;
+   tz->trip_monitor_type_attrs[indx].attr.show =
+   trip_point_monitor_type_show;
+   attrs[indx + tz->trips] =
+   >trip_monitor_type_attrs[indx].attr.attr;
+
/* create trip temp attribute */
snprintf(tz->trip_temp_attrs[indx].name, 

[PATCH 0/4] thermal: Introduce support for monitoring falling temperatures.

2019-09-18 Thread Thara Gopinath
Thermal framework today supports monitoring for rising temperatures and
subsequently initiating cooling action in case of a trip point being 
crossed. There are scenarios where a SoC needs some warming action to be
activated if the temperature falls below a cetain allowable limit.
Since warming action can be considered mirror opposite of cooling action,
most of the thermal framework can be re-used to achieve this.

To enable thermal framework to monitor falling temperature, a new parameter
is added to the thermal trip point binding in the device tree to indicate
the direction(rising/falling) of temperature monitoring. Thermal DT
driver is extended to capture this information from the device tree 
entries and to reflect it in the thermal framework as a new enum
variable in the thermal trip point structure.
As an initial attempt, step-wise governor is extended to support
bi-directional monitoring of temprature if a trip point is hit, depending
on the newly introduced enum variable. Finally thermal sysfs entries are
extended to indicate the trip point monitor direction.

Patch series introducing various resources that are used as warming devices
on Qualcomm sdm845:
https://lkml.org/lkml/2019/7/29/749 (already merged)

https://lkml.org/lkml/2019/9/10/727 (under review)


Thara Gopinath (4):
  dt-bindings: thermal: Introduce monitor-falling binding to thermal
trip point description
  thermal: Thermal core and sysfs changes needed to support
bi-directional monitoring of trip points.
  thermal: of-thermal: Extend thermal dt driver to support
bi-directional monitoring of a thermal trip point.
  thermal: step_wise: Extend thermal step-wise governor to monitor
falling temperature.

 .../devicetree/bindings/thermal/thermal.txt|  8 +++
 drivers/thermal/of-thermal.c   | 22 
 drivers/thermal/step_wise.c| 59 +++--
 drivers/thermal/thermal_sysfs.c| 60 --
 include/linux/thermal.h| 10 
 include/uapi/linux/thermal.h   |  2 +-
 6 files changed, 141 insertions(+), 20 deletions(-)

-- 
2.1.4



[PATCH 3/4] thermal: of-thermal: Extend thermal dt driver to support bi-directional monitoring of a thermal trip point.

2019-09-18 Thread Thara Gopinath
Introduce of_thermal_get_trip_monitor_type to return the direction
of monitoring of a thermal trip point. Also translate the DT information
regarding trip point monitor direction into the thermal framework.

Signed-off-by: Thara Gopinath 
---
 drivers/thermal/of-thermal.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index dc5093b..a5f6fdc 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -377,6 +377,20 @@ static int of_thermal_set_trip_hyst(struct 
thermal_zone_device *tz, int trip,
return 0;
 }
 
+static int of_thermal_get_trip_monitor_type
+   (struct thermal_zone_device *tz, int trip,
+enum thermal_trip_monitor_type *type)
+{
+   struct __thermal_zone *data = tz->devdata;
+
+   if (trip >= data->ntrips || trip < 0)
+   return -EDOM;
+
+   *type = data->trips[trip].monitor_type;
+
+   return 0;
+}
+
 static int of_thermal_get_crit_temp(struct thermal_zone_device *tz,
int *temp)
 {
@@ -401,6 +415,7 @@ static struct thermal_zone_device_ops of_thermal_ops = {
.set_trip_temp = of_thermal_set_trip_temp,
.get_trip_hyst = of_thermal_get_trip_hyst,
.set_trip_hyst = of_thermal_set_trip_hyst,
+   .get_trip_monitor_type = of_thermal_get_trip_monitor_type,
.get_crit_temp = of_thermal_get_crit_temp,
 
.bind = of_thermal_bind,
@@ -809,6 +824,7 @@ static int thermal_of_populate_trip(struct device_node *np,
 {
int prop;
int ret;
+   bool is_monitor_falling;
 
ret = of_property_read_u32(np, "temperature", );
if (ret < 0) {
@@ -830,6 +846,12 @@ static int thermal_of_populate_trip(struct device_node *np,
return ret;
}
 
+   is_monitor_falling = of_property_read_bool(np, "monitor-falling");
+   if (is_monitor_falling)
+   trip->monitor_type = THERMAL_TRIP_MONITOR_FALLING;
+   else
+   trip->monitor_type = THERMAL_TRIP_MONITOR_RISING;
+
/* Required for cooling map matching */
trip->np = np;
of_node_get(np);
-- 
2.1.4



[PATCH 1/4] dt-bindings: thermal: Introduce monitor-falling parameter to thermal trip point binding

2019-09-18 Thread Thara Gopinath
Introduce a new binding parameter to thermal trip point description
to indicate whether the temperature level specified by the trip point
is monitored for a rise or fall in temperature.

Signed-off-by: Thara Gopinath 
---
 Documentation/devicetree/bindings/thermal/thermal.txt | 8 
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/thermal/thermal.txt 
b/Documentation/devicetree/bindings/thermal/thermal.txt
index ca14ba9..849a2a9 100644
--- a/Documentation/devicetree/bindings/thermal/thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/thermal.txt
@@ -90,6 +90,14 @@ Required properties:
"critical": Hardware not reliable.
   Type: string
 
+Optional property:
+- monitor-falling: Indicate whether the system action is kick
+  Type: booleanstarted when the temperature falls below or 
rises
+   above the trip temperature level indicated in
+   "temperature".If true, the trip point is monitored
+   for falling temperature else the trip point is
+   monitored for rising temperature.
+
 * Cooling device maps
 
 The cooling device maps node is a node to describe how cooling devices
-- 
2.1.4



Re: [PATCH v4 3/3] mm: fix double page fault on arm64 if PTE_AF is cleared

2019-09-18 Thread Jia He

Hi Kirill

[On behalf of justin...@arm.com because some mails are filted...]

On 2019/9/18 22:00, Kirill A. Shutemov wrote:

On Wed, Sep 18, 2019 at 09:19:14PM +0800, Jia He wrote:

When we tested pmdk unit test [1] vmmalloc_fork TEST1 in arm64 guest, there
will be a double page fault in __copy_from_user_inatomic of cow_user_page.

Below call trace is from arm64 do_page_fault for debugging purpose
[  110.016195] Call trace:
[  110.016826]  do_page_fault+0x5a4/0x690
[  110.017812]  do_mem_abort+0x50/0xb0
[  110.018726]  el1_da+0x20/0xc4
[  110.019492]  __arch_copy_from_user+0x180/0x280
[  110.020646]  do_wp_page+0xb0/0x860
[  110.021517]  __handle_mm_fault+0x994/0x1338
[  110.022606]  handle_mm_fault+0xe8/0x180
[  110.023584]  do_page_fault+0x240/0x690
[  110.024535]  do_mem_abort+0x50/0xb0
[  110.025423]  el0_da+0x20/0x24

The pte info before __copy_from_user_inatomic is (PTE_AF is cleared):
[9b007000] pgd=00023d4f8003, pud=00023da9b003, 
pmd=00023d4b3003, pte=36298607bd3

As told by Catalin: "On arm64 without hardware Access Flag, copying from
user will fail because the pte is old and cannot be marked young. So we
always end up with zeroed page after fork() + CoW for pfn mappings. we
don't always have a hardware-managed access flag on arm64."

This patch fix it by calling pte_mkyoung. Also, the parameter is
changed because vmf should be passed to cow_user_page()

[1] https://github.com/pmem/pmdk/tree/master/src/test/vmmalloc_fork

Reported-by: Yibo Cai 
Signed-off-by: Jia He 
---
  mm/memory.c | 35 ++-
  1 file changed, 30 insertions(+), 5 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index e2bb51b6242e..d2c130a5883b 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -118,6 +118,13 @@ int randomize_va_space __read_mostly =
2;
  #endif
  
+#ifndef arch_faults_on_old_pte

+static inline bool arch_faults_on_old_pte(void)
+{
+   return false;
+}
+#endif
+
  static int __init disable_randmaps(char *s)
  {
randomize_va_space = 0;
@@ -2140,8 +2147,12 @@ static inline int pte_unmap_same(struct mm_struct *mm, 
pmd_t *pmd,
return same;
  }
  
-static inline void cow_user_page(struct page *dst, struct page *src, unsigned long va, struct vm_area_struct *vma)

+static inline void cow_user_page(struct page *dst, struct page *src,
+struct vm_fault *vmf)
  {
+   struct vm_area_struct *vma = vmf->vma;
+   unsigned long addr = vmf->address;
+
debug_dma_assert_idle(src);
  
  	/*

@@ -2152,20 +2163,34 @@ static inline void cow_user_page(struct page *dst, 
struct page *src, unsigned lo
 */
if (unlikely(!src)) {
void *kaddr = kmap_atomic(dst);
-   void __user *uaddr = (void __user *)(va & PAGE_MASK);
+   void __user *uaddr = (void __user *)(addr & PAGE_MASK);
+   pte_t entry;
  
  		/*

 * This really shouldn't fail, because the page is there
 * in the page tables. But it might just be unreadable,
 * in which case we just give up and fill the result with
-* zeroes.
+* zeroes. On architectures with software "accessed" bits,
+* we would take a double page fault here, so mark it
+* accessed here.
 */
+   if (arch_faults_on_old_pte() && !pte_young(vmf->orig_pte)) {
+   spin_lock(vmf->ptl);
+   if (likely(pte_same(*vmf->pte, vmf->orig_pte))) {
+   entry = pte_mkyoung(vmf->orig_pte);
+   if (ptep_set_access_flags(vma, addr,
+ vmf->pte, entry, 0))
+   update_mmu_cache(vma, addr, vmf->pte);
+   }

I don't follow.

So if pte has changed under you, you don't set the accessed bit, but never
the less copy from the user.

What makes you think it will not trigger the same problem?

I think we need to make cow_user_page() fail in this case and caller --
wp_page_copy() -- return zero. If the fault was solved by other thread, we
are fine. If not userspace would re-fault on the same address and we will
handle the fault from the second attempt.


Thanks for the pointing. How about make cow_user_page() be returned

VM_FAULT_RETRY? Then in do_page_fault(), it can retry the page fault?

---
Cheers,
Justin (Jia He)




+   spin_unlock(vmf->ptl);
+   }
+
if (__copy_from_user_inatomic(kaddr, uaddr, PAGE_SIZE))
clear_page(kaddr);
kunmap_atomic(kaddr);
flush_dcache_page(dst);
} else
-   copy_user_highpage(dst, src, va, vma);
+   copy_user_highpage(dst, src, addr, vma);
  }
  
  static gfp_t __get_fault_gfp_mask(struct vm_area_struct *vma)

@@ -2318,7 

RE: [PATCH] staging: exfat: add exfat filesystem code to

2019-09-18 Thread Namjae Jeon
[..]
> Put it in drivers/staging/sdfat/.
> 
> But really we want someone from Samsung to say that they will treat
> the staging version as upstream.  It doesn't work when people apply
> fixes to their version and a year later back port the fixes into
> staging.  The staging tree is going to have tons and tons of white space
> fixes so backports are a pain.  All development needs to be upstream
> first where the staging driver is upstream.  Otherwise we should just
> wait for Samsung to get it read to be merged in fs/ and not through the
> staging tree.
Quite frankly,
This whole thing came as a huge-huge surprise to us, we did not initiate
upstreaming of exfat/sdfat code and, as of this moment, I'm not exactly
sure that we are prepared for any immediate radical changes to our internal
development process which people all of a sudden want from us. I need to
discuss with related people on internal thread.
please wait a while:)

Thanks!
> 
> regards,
> dan carpenter
> 




Re: [PATCH] serial: sprd: Add polling IO support

2019-09-18 Thread hhome liu
Baolin Wang  于2019年9月18日周三 下午8:10写道:
>
> Hi Lanqing,
>
> On Wed, 18 Sep 2019 at 16:16, Lanqing Liu  wrote:
> >
> > In order to access the UART without the interrupts, the kernel uses
> > the basic polling methods for IO with the device. With these methods
> > implemented, it is now possible to enable kgdb during early boot over 
> > serial.
> >
> > Signed-off-by: Lanqing Liu 
> > ---
> >  drivers/tty/serial/sprd_serial.c | 22 ++
> >  1 file changed, 22 insertions(+)
> >
> > diff --git a/drivers/tty/serial/sprd_serial.c 
> > b/drivers/tty/serial/sprd_serial.c
> > index 73d71a4..579ab41 100644
> > --- a/drivers/tty/serial/sprd_serial.c
> > +++ b/drivers/tty/serial/sprd_serial.c
> > @@ -911,6 +911,24 @@ static void sprd_pm(struct uart_port *port, unsigned 
> > int state,
> > }
> >  }
> >
> > +#ifdef CONFIG_CONSOLE_POLL
> > +static int sprd_poll_get_char(struct uart_port *port)
> > +{
> > +   while (!(serial_in(port, SPRD_STS1) & SPRD_RX_FIFO_CNT_MASK))
> > +   cpu_relax();
> > +
> > +   return serial_in(port, SPRD_RXD);
> > +}
> > +
> > +static void sprd_poll_put_char(struct uart_port *port, unsigned char ch)
> > +{
> > +   while (serial_in(port, SPRD_STS1) & SPRD_TX_FIFO_CNT_MASK)
> > +   cpu_relax();
> > +
> > +   serial_out(port, SPRD_TXD, ch);
> > +}
> > +#endif
>
> When I tested your patch, I found only one case can work if the port
> used by KGDB is same with the port selected as console, which means
> this port will be powered on all the time. We had implemented the
> power management for the UART ports, so I think you should enable the
> clock for the port used by KGDB in poll_init(), then other ports can
> be used by KGDB.
>
Yes, agree with you. I will add poll_init()  support.  Thanks for your
comments.
> > +
> >  static const struct uart_ops serial_sprd_ops = {
> > .tx_empty = sprd_tx_empty,
> > .get_mctrl = sprd_get_mctrl,
> > @@ -928,6 +946,10 @@ static void sprd_pm(struct uart_port *port, unsigned 
> > int state,
> > .config_port = sprd_config_port,
> > .verify_port = sprd_verify_port,
> > .pm = sprd_pm,
> > +#ifdef CONFIG_CONSOLE_POLL
> > +   .poll_get_char  = sprd_poll_get_char,
> > +   .poll_put_char  = sprd_poll_put_char,
> > +#endif
> >  };
> >
> >  #ifdef CONFIG_SERIAL_SPRD_CONSOLE
> > --
> > 1.9.1
> >
>
>
> --
> Baolin Wang
> Best Regards


[git pull] autofs-related stuff

2019-09-18 Thread Al Viro
The most interesting part here is getting rid of the last trylock
loop on dentry->d_lock - the ones in fs/dcache.c had been dealt with
several years ago, but there'd been leftovers in fs/autofs/expire.c

The following changes since commit 5f9e832c137075045d15cd6899ab0505cfb2ca4b:

  Linus 5.3-rc1 (2019-07-21 14:05:38 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git work.autofs

for you to fetch changes up to 5f68056ca50fdd3954a93ae66fea7452abddb66f:

  autofs_lookup(): hold ->d_lock over playing with ->d_flags (2019-07-27 
10:03:14 -0400)


Al Viro (3):
  autofs: simplify get_next_positive_...(), get rid of trylocks
  get rid of autofs_info->active_count
  autofs_lookup(): hold ->d_lock over playing with ->d_flags

 fs/autofs/autofs_i.h |   1 -
 fs/autofs/expire.c   | 103 ---
 fs/autofs/root.c |  44 ++
 3 files changed, 44 insertions(+), 104 deletions(-)


[PATCH 2/2] x86/mm: replace a goto by merging two if clause

2019-09-18 Thread Wei Yang
There is only one place to use good_area jump, which could be reduced by
merging the following two if clause.

Signed-off-by: Wei Yang 
---
 arch/x86/mm/fault.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 9d18b73b5f77..72ce6c69e195 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -1390,18 +1390,17 @@ void do_user_addr_fault(struct pt_regs *regs,
vma = find_vma(mm, address);
if (unlikely(!vma))
goto bad_area;
-   if (likely(vma->vm_start <= address))
-   goto good_area;
-   if (unlikely(!(vma->vm_flags & VM_GROWSDOWN)))
-   goto bad_area;
-   if (unlikely(expand_stack(vma, address)))
+   if (likely(vma->vm_start <= address)) {
+   /* good area, do nothing */
+   } else if (unlikely(!(vma->vm_flags & VM_GROWSDOWN)) ||
+  unlikely(expand_stack(vma, address))) {
goto bad_area;
+   }
 
/*
 * Ok, we have a good vm_area for this memory access, so
 * we can handle it..
 */
-good_area:
if (unlikely(access_error(hw_error_code, vma))) {
bad_area_access_error(regs, hw_error_code, address, vma);
return;
-- 
2.17.1



[PATCH 1/2] x86/mm: consolidate bad_area handling to the end

2019-09-18 Thread Wei Yang
There are totally 7 bad_area[_nosemaphore] error branch in
do_user_addr_fault().

Consolidate all these handling to the end to make the code a little
neat.

BTW, after doing so, function bad_area is not used any more. Remove it.

Signed-off-by: Wei Yang 
---
 arch/x86/mm/fault.c | 44 
 1 file changed, 16 insertions(+), 28 deletions(-)

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 9ceacd1156db..9d18b73b5f77 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -933,12 +933,6 @@ __bad_area(struct pt_regs *regs, unsigned long error_code,
__bad_area_nosemaphore(regs, error_code, address, pkey, si_code);
 }
 
-static noinline void
-bad_area(struct pt_regs *regs, unsigned long error_code, unsigned long address)
-{
-   __bad_area(regs, error_code, address, 0, SEGV_MAPERR);
-}
-
 static inline bool bad_area_access_from_pkeys(unsigned long error_code,
struct vm_area_struct *vma)
 {
@@ -1313,19 +1307,14 @@ void do_user_addr_fault(struct pt_regs *regs,
if (unlikely(cpu_feature_enabled(X86_FEATURE_SMAP) &&
 !(hw_error_code & X86_PF_USER) &&
 !(regs->flags & X86_EFLAGS_AC)))
-   {
-   bad_area_nosemaphore(regs, hw_error_code, address);
-   return;
-   }
+   goto bad_area_nosem;
 
/*
 * If we're in an interrupt, have no user context or are running
 * in a region with pagefaults disabled then we must not take the fault
 */
-   if (unlikely(faulthandler_disabled() || !mm)) {
-   bad_area_nosemaphore(regs, hw_error_code, address);
-   return;
-   }
+   if (unlikely(faulthandler_disabled() || !mm))
+   goto bad_area_nosem;
 
/*
 * It's safe to allow irq's after cr2 has been saved and the
@@ -1385,8 +1374,7 @@ void do_user_addr_fault(struct pt_regs *regs,
 * Fault from code in kernel from
 * which we do not expect faults.
 */
-   bad_area_nosemaphore(regs, hw_error_code, address);
-   return;
+   goto bad_area_nosem;
}
 retry:
down_read(>mmap_sem);
@@ -1400,20 +1388,14 @@ void do_user_addr_fault(struct pt_regs *regs,
}
 
vma = find_vma(mm, address);
-   if (unlikely(!vma)) {
-   bad_area(regs, hw_error_code, address);
-   return;
-   }
+   if (unlikely(!vma))
+   goto bad_area;
if (likely(vma->vm_start <= address))
goto good_area;
-   if (unlikely(!(vma->vm_flags & VM_GROWSDOWN))) {
-   bad_area(regs, hw_error_code, address);
-   return;
-   }
-   if (unlikely(expand_stack(vma, address))) {
-   bad_area(regs, hw_error_code, address);
-   return;
-   }
+   if (unlikely(!(vma->vm_flags & VM_GROWSDOWN)))
+   goto bad_area;
+   if (unlikely(expand_stack(vma, address)))
+   goto bad_area;
 
/*
 * Ok, we have a good vm_area for this memory access, so
@@ -1483,6 +1465,12 @@ void do_user_addr_fault(struct pt_regs *regs,
}
 
check_v8086_mode(regs, address, tsk);
+   return;
+
+bad_area:
+   up_read(>mmap_sem);
+bad_area_nosem:
+   bad_area_nosemaphore(regs, hw_error_code, address);
 }
 NOKPROBE_SYMBOL(do_user_addr_fault);
 
-- 
2.17.1



[git pull] more mount API conversions

2019-09-18 Thread Al Viro
Conversions to new API for shmem and friends and for mount_mtd()-using
filesystems.

As for the rest of the work.mount in -next, some of the conversions
belong in the individual trees (e.g. binderfs one should definitely go through
android folks, after getting redone on top of their changes).  I'm going to
drop those and send the rest (trivial ones + stuff ACKed by maintainers) in
a separate series - by that point they are independent from each other.

Some stuff has already migrated into individual trees (NFS conversion,
for example, or FUSE stuff, etc.); those presumably will go through the
regular merges from corresponding trees.

The following changes since commit 0f071004109d9c8de7023b9a64fa2ba3fa87cbed:

  mtd: Provide fs_context-aware mount_mtd() replacement (2019-09-05 14:34:23 
-0400)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git work.mount2

for you to fetch changes up to 74983ac20aeafc88d9ceed64a8bf2a9024c488d5:

  vfs: Make fs_parse() handle fs_param_is_fd-type params better (2019-09-12 
21:06:14 -0400)


Al Viro (7):
  devtmpfs: don't mix {ramfs,shmem}_fill_super() with mount_single()
  make ramfs_fill_super() static
  make shmem_fill_super() static
  shmem_parse_options(): use a separate structure to keep the results
  shmem_parse_options(): don't bother with mpol in separate variable
  shmem_parse_options(): take handling a single option into a helper
  shmem_parse_one(): switch to use of fs_parse()

David Howells (8):
  vfs: Add a single-or-reconfig keying to vfs_get_super()
  vfs: Convert romfs to use the new mount API
  vfs: Convert cramfs to use the new mount API
  vfs: Convert jffs2 to use the new mount API
  mtd: Kill mount_mtd()
  vfs: Convert squashfs to use the new mount API
  vfs: Convert ramfs, shmem, tmpfs, devtmpfs, rootfs to use the new mount 
API
  vfs: Make fs_parse() handle fs_param_is_fd-type params better

 drivers/base/devtmpfs.c|  38 +++--
 drivers/mtd/mtdsuper.c | 189 --
 fs/cramfs/inode.c  |  69 
 fs/fs_parser.c |  18 ++-
 fs/jffs2/fs.c  |  21 +--
 fs/jffs2/os-linux.h|   4 +-
 fs/jffs2/super.c   | 172 ++--
 fs/ramfs/inode.c   |  99 +++-
 fs/romfs/super.c   |  46 +++---
 fs/squashfs/super.c| 100 ++--
 fs/super.c |  35 -
 include/linux/fs_context.h |   4 +
 include/linux/mtd/super.h  |   3 -
 include/linux/ramfs.h  |   6 +-
 include/linux/shmem_fs.h   |   3 +-
 init/do_mounts.c   |  11 +-
 mm/shmem.c | 385 +
 17 files changed, 609 insertions(+), 594 deletions(-)


[v5,2/2] rtc: pcf85263/pcf85363: support PM, wakeup device, improve performance

2019-09-18 Thread Biwen Li
Add some features as follow:
- Set quartz oscillator load capacitance by DT
  (generate more accuracy frequency)
- Set quartz oscillator drive control by DT
  (reduce/increase the current consumption)
- Set low jitter mode by DT
  (improve jitter performance)
- Set wakeup source by DT
  (wakeup device from suspend
- Select interrupt output pin by DT
  (INTA/TS(INTB))
- Select interrupt type by DT
- Add power management
- Add ioctl to check rtc status
  (check whether oscillator of pcf85263/pcf85363 is stopped)

Datasheet url:
- https://www.nxp.com/docs/en/data-sheet/PCF85263A.pdf
- https://www.nxp.com/docs/en/data-sheet/PCF85363A.pdf

Signed-off-by: Martin Fuzzey 
Signed-off-by: Biwen Li 
---
Change in v5:
- Replace nxp,quartz-drive-strength
  with quartz-drive-strength-ohms
- Select ohm unit for quartz drive strength

Change in v4:
- Add nxp,rtc-interrupt-type property
- Interrupt output pin Cooperate with interrupt type

Change in v3:
- Fix compilation error

Change in v2:
- Replace properties name
  quartz-load-capacitance -> quartz-load-femtofarads
  quartz-drive-strength -> nxp,quartz-drive-strength
  quartz-low-jitter -> nxp,quartz-low-jitter
- Set default interrupt-output-pin as "INTA"

 drivers/rtc/rtc-pcf85363.c | 372 ++---
 1 file changed, 349 insertions(+), 23 deletions(-)

diff --git a/drivers/rtc/rtc-pcf85363.c b/drivers/rtc/rtc-pcf85363.c
index 3450d615974d..4240c6b57875 100644
--- a/drivers/rtc/rtc-pcf85363.c
+++ b/drivers/rtc/rtc-pcf85363.c
@@ -18,6 +18,16 @@
 #include 
 #include 
 
+/* Quartz capacitance */
+#define PCF85363_QUARTZCAP_7pF 0
+#define PCF85363_QUARTZCAP_6pF 1
+#define PCF85363_QUARTZCAP_12p5pF  2
+
+/* Quartz drive strength */
+#define PCF85363_QUARTZDRIVE_NORMAL0
+#define PCF85363_QUARTZDRIVE_LOW   1
+#define PCF85363_QUARTZDRIVE_HIGH  2
+
 /*
  * Date/Time registers
  */
@@ -96,10 +106,20 @@
 #define FLAGS_PIF  BIT(7)
 
 #define PIN_IO_INTAPM  GENMASK(1, 0)
-#define PIN_IO_INTA_CLK0
-#define PIN_IO_INTA_BAT1
-#define PIN_IO_INTA_OUT2
-#define PIN_IO_INTA_HIZ3
+#define PIN_IO_INTAPM_SHIFT0
+#define PIN_IO_INTA_CLK(0 << PIN_IO_INTAPM_SHIFT)
+#define PIN_IO_INTA_BAT(1 << PIN_IO_INTAPM_SHIFT)
+#define PIN_IO_INTA_OUT(2 << PIN_IO_INTAPM_SHIFT)
+#define PIN_IO_INTA_HIZ(3 << PIN_IO_INTAPM_SHIFT)
+
+#define PIN_IO_TSPM GENMASK(3, 2)
+#define PIN_IO_TSPM_SHIFT  2
+#define PIN_IO_TS_DISABLE  (0x0 << PIN_IO_TSPM_SHIFT)
+#define PIN_IO_TS_INTB_OUT (0x1 << PIN_IO_TSPM_SHIFT)
+#define PIN_IO_TS_CLK_OUT  (0x2 << PIN_IO_TSPM_SHIFT)
+#define PIN_IO_TS_IN   (0x3 << PIN_IO_TSPM_SHIFT)
+
+#define PIN_IO_CLKPM   BIT(7) /* 0 = enable CLK pin,1 = disable CLK pin */
 
 #define STOP_EN_STOP   BIT(0)
 
@@ -107,9 +127,35 @@
 
 #define NVRAM_SIZE 0x40
 
+#define DT_SECS_OS BIT(7)
+
+#define CTRL_OSCILLATOR_CL_MASKGENMASK(1, 0)
+#define CTRL_OSCILLATOR_CL_SHIFT   0
+#define CTRL_OSCILLATOR_OSCD_MASK  GENMASK(3, 2)
+#define CTRL_OSCILLATOR_OSCD_SHIFT 2
+#define CTRL_OSCILLATOR_LOWJ   BIT(4)
+
+#define CTRL_FUNCTION_COF_OFF  0x7 /* No clock output */
+
+enum pcf85363_irqpin {
+   IRQPIN_INTA,
+   IRQPIN_INTB,
+   IRQPIN_MAX,
+};
+
+static const char *const pcf85363_irqpin_names[] = {
+   [IRQPIN_INTA] = "INTA",
+   [IRQPIN_INTB] = "INTB",
+   [IRQPIN_MAX] = "",
+};
+
+
 struct pcf85363 {
+   struct device *dev;
struct rtc_device   *rtc;
struct regmap   *regmap;
+   int irq;
+   u8 irq_type[IRQPIN_MAX];
 };
 
 struct pcf85x63_config {
@@ -205,26 +251,60 @@ static int pcf85363_rtc_read_alarm(struct device *dev, 
struct rtc_wkalrm *alrm)
return 0;
 }
 
-static int _pcf85363_rtc_alarm_irq_enable(struct pcf85363 *pcf85363, unsigned
- int enabled)
+static int _pcf85363_rtc_alarm_irq_enable(struct pcf85363 *pcf85363,
+ unsigned int enabled,
+ int irq_pin)
 {
-   unsigned int alarm_flags = ALRM_SEC_A1E | ALRM_MIN_A1E | ALRM_HR_A1E |
+   unsigned int alarm1_flags = ALRM_SEC_A1E | ALRM_MIN_A1E | ALRM_HR_A1E |
   ALRM_DAY_A1E | ALRM_MON_A1E;
-   int ret;
+   unsigned int alarm2_flags = ALRM_MIN_A2E | ALRM_HR_A2E | ALRM_DAY_A2E;
+   unsigned int alarm_flags = 0;
+   int ret, reg;
+   u8 reg_val = 0, ctrl_flags = FLAGS_A1F;
+
+   if (pcf85363->irq_type[irq_pin] & INT_A1IE) {
+   alarm_flags = alarm1_flags;
+   ctrl_flags = FLAGS_A1F;
+   }
 
+   if (pcf85363->irq_type[irq_pin] & INT_A2IE) {
+   alarm_flags |= alarm2_flags;
+   ctrl_flags |= FLAGS_A2F;
+   }
ret = 

RE: [PATCH v4 1/3] arm64: cpufeature: introduce helper cpu_has_hw_af()

2019-09-18 Thread Justin He (Arm Technology China)
Hi Suzuki

> -Original Message-
> From: Catalin Marinas 
> Sent: 2019年9月19日 0:46
> To: Suzuki Poulose 
> Cc: Justin He (Arm Technology China) ; Will Deacon
> ; Mark Rutland ; James Morse
> ; Marc Zyngier ; Matthew
> Wilcox ; Kirill A. Shutemov
> ; linux-arm-ker...@lists.infradead.org;
> linux-kernel@vger.kernel.org; linux...@kvack.org; Punit Agrawal
> ; Anshuman Khandual
> ; Jun Yao ;
> Alex Van Brunt ; Robin Murphy
> ; Thomas Gleixner ;
> Andrew Morton ; Jérôme Glisse
> ; Ralph Campbell ;
> hejia...@gmail.com; Kaly Xin (Arm Technology China) 
> Subject: Re: [PATCH v4 1/3] arm64: cpufeature: introduce helper
> cpu_has_hw_af()
>
> On Wed, Sep 18, 2019 at 03:20:41PM +0100, Suzuki K Poulose wrote:
> > On 18/09/2019 14:19, Jia He wrote:
> > > diff --git a/arch/arm64/include/asm/cpufeature.h
> b/arch/arm64/include/asm/cpufeature.h
> > > index c96ffa4722d3..206b6e3954cf 100644
> > > --- a/arch/arm64/include/asm/cpufeature.h
> > > +++ b/arch/arm64/include/asm/cpufeature.h
> > > @@ -390,6 +390,7 @@ extern DECLARE_BITMAP(boot_capabilities,
> ARM64_NPATCHABLE);
> > >   for_each_set_bit(cap, cpu_hwcaps, ARM64_NCAPS)
> > >   bool this_cpu_has_cap(unsigned int cap);
> > > +bool cpu_has_hw_af(void);
> > >   void cpu_set_feature(unsigned int num);
> > >   bool cpu_have_feature(unsigned int num);
> > >   unsigned long cpu_get_elf_hwcap(void);
> > > diff --git a/arch/arm64/kernel/cpufeature.c
> b/arch/arm64/kernel/cpufeature.c
> > > index b1fdc486aed8..c5097f58649d 100644
> > > --- a/arch/arm64/kernel/cpufeature.c
> > > +++ b/arch/arm64/kernel/cpufeature.c
> > > @@ -1141,6 +1141,12 @@ static bool has_hw_dbm(const struct
> arm64_cpu_capabilities *cap,
> > >   return true;
> > >   }
> > > +/* Decouple AF from AFDBM. */
> > > +bool cpu_has_hw_af(void)
> > > +{
> > Sorry for not having asked this earlier. Are we interested in,
> >
> > "whether *this* CPU has AF support ?" or "whether *at least one*
> > CPU has the AF support" ? The following code does the former.
> >
> > > + return (read_cpuid(ID_AA64MMFR1_EL1) & 0xf);
>
> In a non-preemptible context, the former is ok (per-CPU).

Yes, just as what Catalin explained, we need the former because the
pagefault occurred in every cpus

--
Cheers,
Justin (Jia He)


>
> --
> Catalin
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.


[v5,1/2] dt-bindings: rtc: pcf85263/pcf85363: add some properties

2019-09-18 Thread Biwen Li
Add some properties for pcf85263/pcf85363 as follows:
  - nxp,rtc-interrupt-type: integer type
  - nxp,rtc-interrupt-output-pin: string type
  - quartz-load-femtofarads: integer type
  - quartz-drive-strength-ohms: integer type
  - nxp,quartz-low-jitter: bool type
  - wakeup-source: bool type

Signed-off-by: Martin Fuzzey 
Signed-off-by: Biwen Li 
---
Change in v5:
- Replace nxp,quartz-drive-strength with
  quartz-drive-strength-ohms
- Select ohm unit for quartz drive strength

Change in v4:
- Drop robust defines in include/dt-bindings/rtc/pcf85363.h
- Add nxp,rtc-interrupt-type property
- Replace interrupt-output-pin with nxp,rtc-interrupt-output-pin

Change in v3:
- None

Change in v2:
- Replace properties name
  quartz-load-capacitance -> quartz-load-femtofarads
  quartz-drive-strength -> nxp,quartz-drive-strength
  quartz-low-jitter -> nxp,quartz-low-jitter
- Replace drive strength name
  PCF85263_QUARTZDRIVE_NORMAL -> PCF85263_QUARTZDRIVE_100ko
  PCF85263_QUARTZDRIVE_LOW -> PCF85263_QUARTZDRIVE_60ko
  PCF85263_QUARTZDRIVE_HIGH -> PCF85263_QUARTZDRIVE_500ko
- Set default interrupt-output-pin as "INTA"

 .../devicetree/bindings/rtc/pcf85363.txt  | 44 ++-
 include/dt-bindings/rtc/pcf85363.h| 14 ++
 2 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100644 include/dt-bindings/rtc/pcf85363.h

diff --git a/Documentation/devicetree/bindings/rtc/pcf85363.txt 
b/Documentation/devicetree/bindings/rtc/pcf85363.txt
index 94adc1cf93d9..7f907581d5db 100644
--- a/Documentation/devicetree/bindings/rtc/pcf85363.txt
+++ b/Documentation/devicetree/bindings/rtc/pcf85363.txt
@@ -8,10 +8,52 @@ Required properties:
 Optional properties:
 - interrupts: IRQ line for the RTC (not implemented).
 
+- nxp,rtc-interrupt-type: integer property, represent the interrupt's
+  type. Valid values are
+  INT_PIE(periodic interrupt enable),
+  INT_OIE(offset correction interrupt enable),
+  INT_A1IE(alarm1 interrupt enable),
+  INT_A2IE(alarm2 interrupt enable),
+  INT_TSRIE(timestamp register interrupt enable)
+  INT_BSIE(battery switch interrupt enable),
+  INT_WDIE(WatchDog interrupt enable,and
+  compose these values such as: INT_A1IE | INT_A2IE,
+  but currently only support INT_A1IE, default value is INT_A1IE.
+  The property and property nxp,rtc-interrupt-output-pin
+  work together to generate some interrupts on some pins.
+
+- nxp,rtc-interrupt-output-pin: The interrupt output pin must be
+  "INTA" or "INTB", default value is "INTA". The property and property
+  nxp,rtc-interrupt-type work together to generate some interrupts on
+  some pins.
+
+- quartz-load-femtofarads: The internal capacitor to select for the quartz,
+  expressed in femto Farad (fF). Valid values are 6000, 7000 and 12500.
+  Default value is 12500fF.
+
+- quartz-drive-strength-ohms: Drive strength for the quartz,
+  expressed in ohm, Valid values are 6, 10 and 50.
+  Default value is 10 ohm.
+
+- nxp,quartz-low-jitter: Boolean property, if present enables low jitter mode
+  which reduces jitter at the cost of increased power consumption.
+
+- wakeup-source: Boolean property, Please refer to
+  Documentation/devicetree/bindings/power/wakeup-source.txt
+
 Example:
 
 pcf85363: pcf85363@51 {
compatible = "nxp,pcf85363";
reg = <0x51>;
-};
 
+   interrupt-parent = <>;
+   interrupts = <18 IRQ_TYPE_EDGE_FALLING>;
+
+   wakeup-source;
+   nxp,rtc-interrupt-output-pin = "INTA";
+   nxp,rtc-interrupt-type = ;
+   quartz-load-femtofarads = <12500>;
+   quartz-drive-strength-ohms = <6>;
+   nxp,quartz-low-jitter;
+};
diff --git a/include/dt-bindings/rtc/pcf85363.h 
b/include/dt-bindings/rtc/pcf85363.h
new file mode 100644
index ..6340bf2da8f5
--- /dev/null
+++ b/include/dt-bindings/rtc/pcf85363.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _DT_BINDINGS_RTC_PCF85363_H
+#define _DT_BINDINGS_RTC_PCF85363_H
+
+/* Interrupt type */
+#define INT_WDIE   (1 << 0)
+#define INT_BSIE   (1 << 1)
+#define INT_TSRIE  (1 << 2)
+#define INT_A2IE   (1 << 3)
+#define INT_A1IE   (1 << 4)
+#define INT_OIE(1 << 5)
+#define INT_PIE(1 << 6)
+
+#endif /* _DT_BINDINGS_RTC_PCF85363_H */
-- 
2.17.1



Re: [GIT PULL] vfs: prohibit writes to active swap devices

2019-09-18 Thread pr-tracker-bot
The pull request you sent on Tue, 17 Sep 2019 08:06:09 -0700:

> git://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git tags/vfs-5.4-merge-1

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/e6bc9de714972cac34daa1dc1567ee48a47a9342

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [GIT PULL] xfs: new code for 5.4

2019-09-18 Thread pr-tracker-bot
The pull request you sent on Tue, 17 Sep 2019 10:16:45 -0700:

> git://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git tags/xfs-5.4-merge-7

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/b41dae061bbd722b9d7fa828f35d22035b218e18

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [GIT PULL afs: Development for 5.4

2019-09-18 Thread pr-tracker-bot
The pull request you sent on Mon, 16 Sep 2019 12:09:27 +0100:

> git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git 
> tags/afs-next-20190915

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/0bb73e42f027db64054fff4c3b3203c1626b9dc1

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [GIT PULL] overlayfs fixes for 5.3

2019-09-18 Thread pr-tracker-bot
The pull request you sent on Tue, 17 Sep 2019 10:31:35 +0200:

> git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git 
> tags/ovl-fixes-5.3

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/b6c0d35772468173b5d3a7f6162079611e68a1e8

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [PATCH v4 8/9] hugetlb_cgroup: Add hugetlb_cgroup reservation tests

2019-09-18 Thread Mina Almasry
On Mon, Sep 16, 2019 at 6:52 PM shuah  wrote:
>
> On 9/10/19 5:31 PM, Mina Almasry wrote:
> > The tests use both shared and private mapped hugetlb memory, and
> > monitors the hugetlb usage counter as well as the hugetlb reservation
> > counter. They test different configurations such as hugetlb memory usage
> > via hugetlbfs, or MAP_HUGETLB, or shmget/shmat, and with and without
> > MAP_POPULATE.
> >
> > Signed-off-by: Mina Almasry 
> > ---
> >   tools/testing/selftests/vm/.gitignore |   1 +
> >   tools/testing/selftests/vm/Makefile   |   4 +
> >   .../selftests/vm/charge_reserved_hugetlb.sh   | 440 ++
> >   .../selftests/vm/write_hugetlb_memory.sh  |  22 +
> >   .../testing/selftests/vm/write_to_hugetlbfs.c | 252 ++
> >   5 files changed, 719 insertions(+)
> >   create mode 100755 tools/testing/selftests/vm/charge_reserved_hugetlb.sh
> >   create mode 100644 tools/testing/selftests/vm/write_hugetlb_memory.sh
> >   create mode 100644 tools/testing/selftests/vm/write_to_hugetlbfs.c
> >
> > diff --git a/tools/testing/selftests/vm/.gitignore 
> > b/tools/testing/selftests/vm/.gitignore
> > index 31b3c98b6d34d..d3bed9407773c 100644
> > --- a/tools/testing/selftests/vm/.gitignore
> > +++ b/tools/testing/selftests/vm/.gitignore
> > @@ -14,3 +14,4 @@ virtual_address_range
> >   gup_benchmark
> >   va_128TBswitch
> >   map_fixed_noreplace
> > +write_to_hugetlbfs
> > diff --git a/tools/testing/selftests/vm/Makefile 
> > b/tools/testing/selftests/vm/Makefile
> > index 9534dc2bc9295..8d37d5409b52c 100644
> > --- a/tools/testing/selftests/vm/Makefile
> > +++ b/tools/testing/selftests/vm/Makefile
> > @@ -18,6 +18,7 @@ TEST_GEN_FILES += transhuge-stress
> >   TEST_GEN_FILES += userfaultfd
> >   TEST_GEN_FILES += va_128TBswitch
> >   TEST_GEN_FILES += virtual_address_range
> > +TEST_GEN_FILES += write_to_hugetlbfs
> >
> >   TEST_PROGS := run_vmtests
> >
> > @@ -29,3 +30,6 @@ include ../lib.mk
> >   $(OUTPUT)/userfaultfd: LDLIBS += -lpthread
> >
> >   $(OUTPUT)/mlock-random-test: LDLIBS += -lcap
> > +
> > +# Why does adding $(OUTPUT)/ like above not apply this flag..?
>
> Can you verify the following and remove this comment, once you figure
> out if you need $(OUTPUT)/
> > +write_to_hugetlbfs: CFLAGS += -static
>
> It should. Did you test "make O=" and "KBUILD_OUTPUT" kselftest
> use-cases?
>

Turns out I don't need -static actually.

> > diff --git a/tools/testing/selftests/vm/charge_reserved_hugetlb.sh 
> > b/tools/testing/selftests/vm/charge_reserved_hugetlb.sh
> > new file mode 100755
> > index 0..09e90e8f6fab4
> > --- /dev/null
> > +++ b/tools/testing/selftests/vm/charge_reserved_hugetlb.sh
> > @@ -0,0 +1,440 @@
> > +#!/bin/sh
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +set -e
> > +
> > +cgroup_path=/dev/cgroup/memory
> > +if [[ ! -e $cgroup_path ]]; then
> > +  mkdir -p $cgroup_path
> > +  mount -t cgroup -o hugetlb,memory cgroup $cgroup_path
> > +fi
> > +
>
> Does this test need root access? If yes, please add root check
> and skip the test when a non-root runs the test.
>
> > +cleanup () {
> > + echo $$ > $cgroup_path/tasks
> > +
> > + set +e
> > + if [[ "$(pgrep write_to_hugetlbfs)" != "" ]]; then
> > +   kill -2 write_to_hugetlbfs
> > +   # Wait for hugetlbfs memory to get depleted.
> > +   sleep 0.5
>
> This time looks arbitrary. How can you be sure it gets depleted?
> Is there another way to check for it.
>
> > + fi
> > + set -e
> > +
> > + if [[ -e /mnt/huge ]]; then
> > +   rm -rf /mnt/huge/*
> > +   umount /mnt/huge || echo error
> > +   rmdir /mnt/huge
> > + fi
> > + if [[ -e $cgroup_path/hugetlb_cgroup_test ]]; then
> > +   rmdir $cgroup_path/hugetlb_cgroup_test
> > + fi
> > + if [[ -e $cgroup_path/hugetlb_cgroup_test1 ]]; then
> > +   rmdir $cgroup_path/hugetlb_cgroup_test1
> > + fi
> > + if [[ -e $cgroup_path/hugetlb_cgroup_test2 ]]; then
> > +   rmdir $cgroup_path/hugetlb_cgroup_test2
> > + fi
> > + echo 0 > /proc/sys/vm/nr_hugepages
> > + echo CLEANUP DONE
> > +}
> > +
> > +cleanup
> > +
> > +function expect_equal() {
> > +  local expected="$1"
> > +  local actual="$2"
> > +  local error="$3"
> > +
> > +  if [[ "$expected" != "$actual" ]]; then
> > + echo "expected ($expected) != actual ($actual): $3"
> > + cleanup
> > + exit 1
> > +  fi
> > +}
> > +
> > +function setup_cgroup() {
> > +  local name="$1"
> > +  local cgroup_limit="$2"
> > +  local reservation_limit="$3"
> > +
> > +  mkdir $cgroup_path/$name
> > +
> > +  echo writing cgroup limit: "$cgroup_limit"
> > +  echo "$cgroup_limit" > $cgroup_path/$name/hugetlb.2MB.limit_in_bytes
> > +
> > +  echo writing reseravation limit: "$reservation_limit"
> > +  echo "$reservation_limit" > \
> > + $cgroup_path/$name/hugetlb.2MB.reservation_limit_in_bytes
> > +  echo 0 

Re: [PATCH V9 5/5] mmc: host: sdhci-pci: Add Genesys Logic GL975x support

2019-09-18 Thread Ben Chuang
On Wed, Sep 18, 2019 at 7:09 PM Adrian Hunter  wrote:
>
> On 18/09/19 1:47 PM, Michael K. Johnson wrote:
> > I see that the first four patches made it into Linus's kernel
> > yesterday. Is there any chance of this final patch that actually
> > enables the hardware making it into another pull request still
> > intended for 5.4?  Waiting on additional acked-by on Ben's work
> > addressing all the review comments?
> >
> > Thanks.
> >
> > On Wed, Sep 11, 2019 at 03:23:44PM +0800, Ben Chuang wrote:
> >> From: Ben Chuang 
> >>
> >> Add support for the GL9750 and GL9755 chipsets.
> >>
> >> Enable v4 mode and wait 5ms after set 1.8V signal enable for GL9750/
> >> GL9755. Fix the value of SDHCI_MAX_CURRENT register and use the vendor
> >> tuning flow for GL9750.
> >
>
> It is OK by me:
>
> Acked-by: Adrian Hunter 

Thank you. Also thanks to other people who have given me their comments.
Ben


RE: [PATCH v4 3/3] mm: fix double page fault on arm64 if PTE_AF is cleared

2019-09-18 Thread Justin He (Arm Technology China)


> -Original Message-
> From: kbuild test robot 
> Sent: 2019年9月19日 3:36
> To: Justin He (Arm Technology China) 
> Cc: kbuild-...@01.org; Catalin Marinas ; Will
> Deacon ; Mark Rutland ;
> James Morse ; Marc Zyngier ;
> Matthew Wilcox ; Kirill A. Shutemov
> ; linux-arm-ker...@lists.infradead.org;
> linux-kernel@vger.kernel.org; linux...@kvack.org; Suzuki Poulose
> ; Punit Agrawal ;
> Anshuman Khandual ; Jun Yao
> ; Alex Van Brunt ;
> Robin Murphy ; Thomas Gleixner
> ; Andrew Morton ;
> jgli...@redhat.com; Ralph Campbell ;
> hejia...@gmail.com; Kaly Xin (Arm Technology China)
> ; Justin He (Arm Technology China)
> 
> Subject: Re: [PATCH v4 3/3] mm: fix double page fault on arm64 if PTE_AF
> is cleared
>
> Hi Jia,
>
> Thank you for the patch! Yet something to improve:
>
> [auto build test ERROR on linus/master]
> [cannot apply to v5.3 next-20190917]
> [if your patch is applied to the wrong git tree, please drop us a note to help
> improve the system]
>
> url:https://github.com/0day-ci/linux/commits/Jia-He/fix-double-page-
> fault-on-arm64/20190918-220036
> config: arm64-allnoconfig (attached as .config)
> compiler: aarch64-linux-gcc (GCC) 7.4.0
> reproduce:
> wget https://raw.githubusercontent.com/intel/lkp-
> tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> GCC_VERSION=7.4.0 make.cross ARCH=arm64
>
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot 
>
> All errors (new ones prefixed by >>):
>
>mm/memory.o: In function `wp_page_copy':
> >> memory.c:(.text+0x8fc): undefined reference to `cpu_has_hw_af'
>memory.c:(.text+0x8fc): relocation truncated to fit: R_AARCH64_CALL26
> against undefined symbol `cpu_has_hw_af'
>
Ah, I should add a stub for CONFIG_ARM64_HW_AFDBM is 'N' on arm64 arch
Will fix it asap

--
Cheers,
Justin (Jia He)


> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.


Re: [PATCH v2] rtl8xxxu: add bluetooth co-existence support for single antenna

2019-09-18 Thread Chris Chiu
On Wed, Sep 11, 2019 at 10:50 AM Chris Chiu  wrote:
>
>
> Notes:
>   v2:
>- Add helper functions to replace bunch of tdma settings
>- Reformat some lines to meet kernel coding style
>
>

Gentle ping. Any suggestions would be appreciated. Thanks.

Chris


[PATCH] workqueue: Fix spurious sanity check failures in destroy_workqueue()

2019-09-18 Thread Tejun Heo
Before actually destrying a workqueue, destroy_workqueue() checks
whether it's actually idle.  If it isn't, it prints out a bunch of
warning messages and leaves the workqueue dangling.  It unfortunately
has a couple issues.

* Mayday list queueing increments pwq's refcnts which gets detected as
  busy and fails the sanity checks.  However, because mayday list
  queueing is asynchronous, this condition can happen without any
  actual work items left in the workqueue.

* Sanity check failure leaves the sysfs interface behind too which can
  lead to init failure of newer instances of the workqueue.

This patch fixes the above two by

* If a workqueue has a rescuer, disable and kill the rescuer before
  sanity checks.  Disabling and killing is guaranteed to flush the
  existing mayday list.

* Remove sysfs interface before sanity checks.

Signed-off-by: Tejun Heo 
Reported-by: Marcin Pawlowski 
Reported-by: "Williams, Gerald S" 
Cc: sta...@vger.kernel.org
---
Applying to wq/for-5.4.

Thanks.

 kernel/workqueue.c | 24 +++-
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 95aea04ff722..73e3ea9e31d3 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -4318,9 +4318,28 @@ void destroy_workqueue(struct workqueue_struct *wq)
struct pool_workqueue *pwq;
int node;
 
+   /*
+* Remove it from sysfs first so that sanity check failure doesn't
+* lead to sysfs name conflicts.
+*/
+   workqueue_sysfs_unregister(wq);
+
/* drain it before proceeding with destruction */
drain_workqueue(wq);
 
+   /* kill rescuer, if sanity checks fail, leave it w/o rescuer */
+   if (wq->rescuer) {
+   struct worker *rescuer = wq->rescuer;
+
+   /* this prevents new queueing */
+   spin_lock_irq(_mayday_lock);
+   wq->rescuer = NULL;
+   spin_unlock_irq(_mayday_lock);
+
+   /* rescuer will empty maydays list before exiting */
+   kthread_stop(rescuer->task);
+   }
+
/* sanity checks */
mutex_lock(>mutex);
for_each_pwq(pwq, wq) {
@@ -4352,11 +4371,6 @@ void destroy_workqueue(struct workqueue_struct *wq)
list_del_rcu(>list);
mutex_unlock(_pool_mutex);
 
-   workqueue_sysfs_unregister(wq);
-
-   if (wq->rescuer)
-   kthread_stop(wq->rescuer->task);
-
if (!(wq->flags & WQ_UNBOUND)) {
wq_unregister_lockdep(wq);
/*
-- 
2.17.1



[PATCH] UBI: fix warning static is not at beginning of declaration

2019-09-18 Thread Rishi Gupta
Compiler generates following warning when kernel is built with W=1:

drivers/mtd/ubi/ubi.h:971:1: warning: ‘static’ is not at beginning
of declaration [-Wold-style-declaration]

This commit fixes this by correctly ordering keywords.

Signed-off-by: Rishi Gupta 
---
 drivers/mtd/ubi/ubi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 721b6aa..75e818ca 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -968,7 +968,7 @@ int ubi_fastmap_init_checkmap(struct ubi_volume *vol, int 
leb_count);
 void ubi_fastmap_destroy_checkmap(struct ubi_volume *vol);
 #else
 static inline int ubi_update_fastmap(struct ubi_device *ubi) { return 0; }
-int static inline ubi_fastmap_init_checkmap(struct ubi_volume *vol, int 
leb_count) { return 0; }
+static inline int ubi_fastmap_init_checkmap(struct ubi_volume *vol, int 
leb_count) { return 0; }
 static inline void ubi_fastmap_destroy_checkmap(struct ubi_volume *vol) {}
 #endif
 
-- 
2.7.4



Re: [PATCH] [RESEND] vmscan.c: add a sysctl entry for controlling memory reclaim IO congestion_wait length

2019-09-18 Thread Lin Feng




On 9/18/19 20:27, Michal Hocko wrote:

Please do not post a new version with a minor compile fixes until there
is a general agreement on the approach. Willy had comments which really
need to be resolved first. 


Sorry, but thanks for pointing out.



Also does this
[...]

Reported-by: kbuild test robot

really hold? Because it suggests that the problem has been spotted by
the kbuild bot which is kinda unexpected... I suspect you have just
added that for the minor compilation issue that you have fixed since the
last version.


Yes, I do know the issue is not reported by the robot, but
just followed the kbuild robot tip, this Reported-by suggested by kbuild robot
seems a little misleading, I'm not sure if it has other meanings.
'If you fix the issue, kindly add following tag
Reported-by: kbuild test robot '



Re: [PATCH] hugetlbfs: hugetlb_fault_mutex_hash cleanup

2019-09-18 Thread Nathan Chancellor
On Wed, Sep 18, 2019 at 06:18:47PM -0700, Mike Kravetz wrote:
> A new clang diagnostic (-Wsizeof-array-div) warns about the calculation
> to determine the number of u32's in an array of unsigned longs. Suppress
> warning by adding parentheses.
> 
> While looking at the above issue, noticed that the 'address' parameter
> to hugetlb_fault_mutex_hash is no longer used. So, remove it from the
> definition and all callers.
> 
> No functional change.
> 
> Reported-by: Nathan Chancellor 
> Signed-off-by: Mike Kravetz 

Thanks for the patch!

Reviewed-by: Nathan Chancellor 


Re: [PATCH 4.14 00/45] 4.14.145-stable review

2019-09-18 Thread shuah

On 9/18/19 12:18 AM, Greg Kroah-Hartman wrote:

This is the start of the stable review cycle for the 4.14.145 release.
There are 45 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Fri 20 Sep 2019 06:09:47 AM UTC.
Anything received after that time might be too late.

The whole patch series can be found in one patch at:

https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.145-rc1.gz
or in the git tree and branch at:

git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
linux-4.14.y
and the diffstat can be found below.

thanks,

greg k-h



Compiled and booted on my test system. No dmesg regressions.

thanks,
-- Shuah


[PATCH ghak90 V7 06/21] audit: contid limit of 32k imposed to avoid DoS

2019-09-18 Thread Richard Guy Briggs
Set an arbitrary limit on the number of audit container identifiers to
limit abuse.

Signed-off-by: Richard Guy Briggs 
---
 kernel/audit.c | 8 
 kernel/audit.h | 4 
 2 files changed, 12 insertions(+)

diff --git a/kernel/audit.c b/kernel/audit.c
index 53d13d638c63..329916534dd2 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -139,6 +139,7 @@ struct audit_net {
 struct list_head audit_inode_hash[AUDIT_INODE_BUCKETS];
 /* Hash for contid-based rules */
 struct list_head audit_contid_hash[AUDIT_CONTID_BUCKETS];
+int audit_contid_count = 0;
 
 static struct kmem_cache *audit_buffer_cache;
 
@@ -2384,6 +2385,7 @@ void audit_cont_put(struct audit_cont *cont)
put_task_struct(cont->owner);
list_del_rcu(>list);
kfree_rcu(cont, rcu);
+   audit_contid_count--;
}
 }
 
@@ -2456,6 +2458,11 @@ int audit_set_contid(struct task_struct *task, u64 
contid)
goto conterror;
}
}
+   /* Set max contids */
+   if (audit_contid_count > AUDIT_CONTID_COUNT) {
+   rc = -ENOSPC;
+   goto conterror;
+   }
if (!newcont) {
newcont = kmalloc(sizeof(struct audit_cont), 
GFP_ATOMIC);
if (newcont) {
@@ -2465,6 +2472,7 @@ int audit_set_contid(struct task_struct *task, u64 contid)
newcont->owner = current;
refcount_set(>refcount, 1);
list_add_rcu(>list, 
_contid_hash[h]);
+   audit_contid_count++;
} else {
rc = -ENOMEM;
goto conterror;
diff --git a/kernel/audit.h b/kernel/audit.h
index 162de8366b32..543f1334ba47 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -219,6 +219,10 @@ static inline int audit_hash_contid(u64 contid)
return (contid & (AUDIT_CONTID_BUCKETS-1));
 }
 
+extern int audit_contid_count;
+
+#define AUDIT_CONTID_COUNT 1 << 16
+
 /* Indicates that audit should log the full pathname. */
 #define AUDIT_NAME_FULL -1
 
-- 
1.8.3.1



Re: [PATCH 4/5] ocxl: Add functions to map/unmap LPC memory

2019-09-18 Thread Alastair D'Silva
On Tue, 2019-09-17 at 11:43 +1000, Alastair D'Silva wrote:
> From: Alastair D'Silva 
> 
> Add functions to map/unmap LPC memory
> 
> Signed-off-by: Alastair D'Silva 
> ---
>  drivers/misc/ocxl/config.c|  4 +++
>  drivers/misc/ocxl/core.c  | 50
> +++
>  drivers/misc/ocxl/link.c  |  4 +--
>  drivers/misc/ocxl/ocxl_internal.h | 10 +--
>  include/misc/ocxl.h   | 18 +++
>  5 files changed, 82 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/misc/ocxl/config.c b/drivers/misc/ocxl/config.c
> index c8e19bfb5ef9..fb0c3b6f8312 100644
> --- a/drivers/misc/ocxl/config.c
> +++ b/drivers/misc/ocxl/config.c
> @@ -568,6 +568,10 @@ static int read_afu_lpc_memory_info(struct
> pci_dev *dev,
>   afu->special_purpose_mem_size =
>   total_mem_size - lpc_mem_size;
>   }
> +
> + dev_info(>dev, "Probed LPC memory of %#llx bytes and
> special purpose memory of %#llx bytes\n",
> + afu->lpc_mem_size, afu->special_purpose_mem_size);
> +
>   return 0;
>  }
>  
> diff --git a/drivers/misc/ocxl/core.c b/drivers/misc/ocxl/core.c
> index fdfe4e0a34e1..eb24bb9d655f 100644
> --- a/drivers/misc/ocxl/core.c
> +++ b/drivers/misc/ocxl/core.c
> @@ -210,6 +210,55 @@ static void unmap_mmio_areas(struct ocxl_afu
> *afu)
>   release_fn_bar(afu->fn, afu->config.global_mmio_bar);
>  }
>  
> +int ocxl_map_lpc_mem(struct ocxl_afu *afu)
> +{
> + struct pci_dev *dev = to_pci_dev(afu->fn->dev.parent);
> +
> + if ((afu->config.lpc_mem_size + afu-
> >config.special_purpose_mem_size) == 0)
> + return 0;
> +
> + afu->lpc_base_addr = ocxl_link_lpc_online(afu->fn->link, dev);
> + if (afu->lpc_base_addr == 0)
> + return -EINVAL;
> +
> + if (afu->config.lpc_mem_size) {
> + afu->lpc_res.start = afu->lpc_base_addr + afu-
> >config.lpc_mem_offset;
> + afu->lpc_res.end = afu->lpc_res.start + afu-
> >config.lpc_mem_size - 1;
> + }
> +
> + if (afu->config.special_purpose_mem_size) {
> + afu->special_purpose_res.start = afu->lpc_base_addr +
> +  afu-
> >config.special_purpose_mem_offset;
> + afu->special_purpose_res.end = afu-
> >special_purpose_res.start +
> +afu-
> >config.special_purpose_mem_size - 1;
> + }
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(ocxl_map_lpc_mem);
> +
> +struct resource *ocxl_afu_lpc_mem(struct ocxl_afu *afu)
> +{
> + return >lpc_res;
> +}
> +EXPORT_SYMBOL(ocxl_afu_lpc_mem);
> +
> +static void unmap_lpc_mem(struct ocxl_afu *afu)
> +{
> + struct pci_dev *dev = to_pci_dev(afu->fn->dev.parent);
> +
> + if (afu->lpc_res.start || afu->special_purpose_res.start) {
> + void *link = afu->fn->link;
> +
> + ocxl_link_lpc_offline(link, dev);
> +
> + afu->lpc_res.start = 0;
> + afu->lpc_res.end = 0;
> + afu->special_purpose_res.start = 0;
> + afu->special_purpose_res.end = 0;
> + }
> +}
> +
>  static int configure_afu(struct ocxl_afu *afu, u8 afu_idx, struct
> pci_dev *dev)
>  {
>   int rc;
> @@ -250,6 +299,7 @@ static int configure_afu(struct ocxl_afu *afu, u8
> afu_idx, struct pci_dev *dev)
>  
>  static void deconfigure_afu(struct ocxl_afu *afu)
>  {
> + unmap_lpc_mem(afu);
>   unmap_mmio_areas(afu);
>   reclaim_afu_pasid(afu);
>   reclaim_afu_actag(afu);
> diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c
> index 2874811a4398..9e303a5f4d85 100644
> --- a/drivers/misc/ocxl/link.c
> +++ b/drivers/misc/ocxl/link.c
> @@ -738,7 +738,7 @@ int ocxl_link_add_lpc_mem(void *link_handle, u64
> size)
>  }
>  EXPORT_SYMBOL_GPL(ocxl_link_add_lpc_mem);
>  
> -u64 ocxl_link_lpc_map(void *link_handle, struct pci_dev *pdev)
> +u64 ocxl_link_lpc_online(void *link_handle, struct pci_dev *pdev)
>  {
>   struct ocxl_link *link = (struct ocxl_link *) link_handle;
>  
> @@ -759,7 +759,7 @@ u64 ocxl_link_lpc_map(void *link_handle, struct
> pci_dev *pdev)
>   return link->lpc_mem;
>  }
>  
> -void ocxl_link_lpc_release(void *link_handle, struct pci_dev *pdev)
> +void ocxl_link_lpc_offline(void *link_handle, struct pci_dev *pdev)
>  {
>   struct ocxl_link *link = (struct ocxl_link *) link_handle;
>  
> diff --git a/drivers/misc/ocxl/ocxl_internal.h
> b/drivers/misc/ocxl/ocxl_internal.h
> index db2647a90fc8..5656a4aab5b7 100644
> --- a/drivers/misc/ocxl/ocxl_internal.h
> +++ b/drivers/misc/ocxl/ocxl_internal.h
> @@ -52,6 +52,12 @@ struct ocxl_afu {
>   void __iomem *global_mmio_ptr;
>   u64 pp_mmio_start;
>   void *private;
> + u64 lpc_base_addr; /* Covers both LPC & special purpose memory
> */
> + struct bin_attribute attr_global_mmio;
> + struct bin_attribute attr_lpc_mem;

The bin_attributes are not needed here.

> + struct resource lpc_res;
> + struct bin_attribute 

[PATCH ghak90 V7 01/21] audit: collect audit task parameters

2019-09-18 Thread Richard Guy Briggs
The audit-related parameters in struct task_struct should ideally be
collected together and accessed through a standard audit API.

Collect the existing loginuid, sessionid and audit_context together in a
new struct audit_task_info called "audit" in struct task_struct.

Use kmem_cache to manage this pool of memory.
Un-inline audit_free() to be able to always recover that memory.

Please see the upstream github issue
https://github.com/linux-audit/audit-kernel/issues/81

Signed-off-by: Richard Guy Briggs 
Acked-by: Neil Horman 
Reviewed-by: Ondrej Mosnacek 
---
 include/linux/audit.h | 49 +++
 include/linux/sched.h |  7 +
 init/init_task.c  |  3 +--
 init/main.c   |  2 ++
 kernel/audit.c| 71 +--
 kernel/audit.h|  5 
 kernel/auditsc.c  | 26 ++-
 kernel/fork.c |  1 -
 8 files changed, 124 insertions(+), 40 deletions(-)

diff --git a/include/linux/audit.h b/include/linux/audit.h
index 97d0925454df..4fbda55f3cf2 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -95,6 +95,16 @@ struct audit_ntp_data {
 struct audit_ntp_data {};
 #endif
 
+struct audit_task_info {
+   kuid_t  loginuid;
+   unsigned intsessionid;
+#ifdef CONFIG_AUDITSYSCALL
+   struct audit_context*ctx;
+#endif
+};
+
+extern struct audit_task_info init_struct_audit;
+
 extern int is_audit_feature_set(int which);
 
 extern int __init audit_register_class(int class, unsigned *list);
@@ -131,6 +141,9 @@ struct audit_ntp_data {
 #ifdef CONFIG_AUDIT
 /* These are defined in audit.c */
/* Public API */
+extern int  audit_alloc(struct task_struct *task);
+extern void audit_free(struct task_struct *task);
+extern void __init audit_task_init(void);
 extern __printf(4, 5)
 void audit_log(struct audit_context *ctx, gfp_t gfp_mask, int type,
   const char *fmt, ...);
@@ -173,12 +186,16 @@ extern void   audit_log_key(struct 
audit_buffer *ab,
 
 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
 {
-   return tsk->loginuid;
+   if (!tsk->audit)
+   return INVALID_UID;
+   return tsk->audit->loginuid;
 }
 
 static inline unsigned int audit_get_sessionid(struct task_struct *tsk)
 {
-   return tsk->sessionid;
+   if (!tsk->audit)
+   return AUDIT_SID_UNSET;
+   return tsk->audit->sessionid;
 }
 
 extern u32 audit_enabled;
@@ -186,6 +203,14 @@ static inline unsigned int audit_get_sessionid(struct 
task_struct *tsk)
 extern int audit_signal_info(int sig, struct task_struct *t);
 
 #else /* CONFIG_AUDIT */
+static inline int audit_alloc(struct task_struct *task)
+{
+   return 0;
+}
+static inline void audit_free(struct task_struct *task)
+{ }
+static inline void __init audit_task_init(void)
+{ }
 static inline __printf(4, 5)
 void audit_log(struct audit_context *ctx, gfp_t gfp_mask, int type,
   const char *fmt, ...)
@@ -257,8 +282,6 @@ static inline int audit_signal_info(int sig, struct 
task_struct *t)
 
 /* These are defined in auditsc.c */
/* Public API */
-extern int  audit_alloc(struct task_struct *task);
-extern void __audit_free(struct task_struct *task);
 extern void __audit_syscall_entry(int major, unsigned long a0, unsigned long 
a1,
  unsigned long a2, unsigned long a3);
 extern void __audit_syscall_exit(int ret_success, long ret_value);
@@ -281,12 +304,14 @@ extern void audit_seccomp_actions_logged(const char 
*names,
 
 static inline void audit_set_context(struct task_struct *task, struct 
audit_context *ctx)
 {
-   task->audit_context = ctx;
+   task->audit->ctx = ctx;
 }
 
 static inline struct audit_context *audit_context(void)
 {
-   return current->audit_context;
+   if (!current->audit)
+   return NULL;
+   return current->audit->ctx;
 }
 
 static inline bool audit_dummy_context(void)
@@ -294,11 +319,7 @@ static inline bool audit_dummy_context(void)
void *p = audit_context();
return !p || *(int *)p;
 }
-static inline void audit_free(struct task_struct *task)
-{
-   if (unlikely(task->audit_context))
-   __audit_free(task);
-}
+
 static inline void audit_syscall_entry(int major, unsigned long a0,
   unsigned long a1, unsigned long a2,
   unsigned long a3)
@@ -523,12 +544,6 @@ static inline void audit_ntp_log(const struct 
audit_ntp_data *ad)
 extern int audit_n_rules;
 extern int audit_signals;
 #else /* CONFIG_AUDITSYSCALL */
-static inline int audit_alloc(struct task_struct *task)
-{
-   return 0;
-}
-static inline void audit_free(struct task_struct *task)
-{ }
 static inline void audit_syscall_entry(int major, unsigned long a0,
   unsigned long a1, unsigned long a2,
   

Re: [PATCH 4.19 00/50] 4.19.74-stable review

2019-09-18 Thread shuah

On 9/18/19 12:18 AM, Greg Kroah-Hartman wrote:

This is the start of the stable review cycle for the 4.19.74 release.
There are 50 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Fri 20 Sep 2019 06:09:47 AM UTC.
Anything received after that time might be too late.

The whole patch series can be found in one patch at:

https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.74-rc1.gz
or in the git tree and branch at:

git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
linux-4.19.y
and the diffstat can be found below.

thanks,

greg k-h



Compiled and booted on my test system. No dmesg regressions.

thanks,
-- Shuah


[PATCH ghak90 V7 04/21] audit: convert to contid list to check for orch/engine ownership

2019-09-18 Thread Richard Guy Briggs
Store the audit container identifier in a refcounted kernel object that
is added to the master list of audit container identifiers.  This will
allow multiple container orchestrators/engines to work on the same
machine without danger of inadvertantly re-using an existing identifier.
It will also allow an orchestrator to inject a process into an existing
container by checking if the original container owner is the one
injecting the task.  A hash table list is used to optimize searches.

Signed-off-by: Richard Guy Briggs 
---
 include/linux/audit.h | 26 ++--
 kernel/audit.c| 86 ---
 kernel/audit.h|  8 +
 3 files changed, 112 insertions(+), 8 deletions(-)

diff --git a/include/linux/audit.h b/include/linux/audit.h
index f2e3b81f2942..e317807cdd3e 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -95,10 +95,18 @@ struct audit_ntp_data {
 struct audit_ntp_data {};
 #endif
 
+struct audit_cont {
+   struct list_headlist;
+   u64 id;
+   struct task_struct  *owner;
+   refcount_t  refcount;
+   struct rcu_head rcu;
+};
+
 struct audit_task_info {
kuid_t  loginuid;
unsigned intsessionid;
-   u64 contid;
+   struct audit_cont   *cont;
 #ifdef CONFIG_AUDITSYSCALL
struct audit_context*ctx;
 #endif
@@ -203,11 +211,15 @@ static inline unsigned int audit_get_sessionid(struct 
task_struct *tsk)
 
 static inline u64 audit_get_contid(struct task_struct *tsk)
 {
-   if (!tsk->audit)
+   if (!tsk->audit || !tsk->audit->cont)
return AUDIT_CID_UNSET;
-   return tsk->audit->contid;
+   return tsk->audit->cont->id;
 }
 
+extern struct audit_cont *audit_cont(struct task_struct *tsk);
+
+extern void audit_cont_put(struct audit_cont *cont);
+
 extern u32 audit_enabled;
 
 extern int audit_signal_info(int sig, struct task_struct *t);
@@ -277,6 +289,14 @@ static inline u64 audit_get_contid(struct task_struct *tsk)
return AUDIT_CID_UNSET;
 }
 
+static inline struct audit_cont *audit_cont(struct task_struct *tsk)
+{
+   return NULL;
+}
+
+static inline void audit_cont_put(struct audit_cont *cont)
+{ }
+
 #define audit_enabled AUDIT_OFF
 
 static inline int audit_signal_info(int sig, struct task_struct *t)
diff --git a/kernel/audit.c b/kernel/audit.c
index a36ea57cbb61..ea0899130cc1 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -137,6 +137,8 @@ struct audit_net {
 
 /* Hash for inode-based rules */
 struct list_head audit_inode_hash[AUDIT_INODE_BUCKETS];
+/* Hash for contid-based rules */
+struct list_head audit_contid_hash[AUDIT_CONTID_BUCKETS];
 
 static struct kmem_cache *audit_buffer_cache;
 
@@ -204,6 +206,8 @@ struct audit_reply {
 
 static struct kmem_cache *audit_task_cache;
 
+static DEFINE_SPINLOCK(audit_contid_list_lock);
+
 void __init audit_task_init(void)
 {
audit_task_cache = kmem_cache_create("audit_task",
@@ -231,7 +235,9 @@ int audit_alloc(struct task_struct *tsk)
}
info->loginuid = audit_get_loginuid(current);
info->sessionid = audit_get_sessionid(current);
-   info->contid = audit_get_contid(current);
+   info->cont = audit_cont(current);
+   if (info->cont)
+   refcount_inc(>cont->refcount);
tsk->audit = info;
 
ret = audit_alloc_syscall(tsk);
@@ -246,7 +252,7 @@ int audit_alloc(struct task_struct *tsk)
 struct audit_task_info init_struct_audit = {
.loginuid = INVALID_UID,
.sessionid = AUDIT_SID_UNSET,
-   .contid = AUDIT_CID_UNSET,
+   .cont = NULL,
 #ifdef CONFIG_AUDITSYSCALL
.ctx = NULL,
 #endif
@@ -266,6 +272,9 @@ void audit_free(struct task_struct *tsk)
/* Freeing the audit_task_info struct must be performed after
 * audit_log_exit() due to need for loginuid and sessionid.
 */
+   spin_lock(_contid_list_lock); 
+   audit_cont_put(tsk->audit->cont);
+   spin_unlock(_contid_list_lock); 
info = tsk->audit;
tsk->audit = NULL;
kmem_cache_free(audit_task_cache, info);
@@ -1657,6 +1666,9 @@ static int __init audit_init(void)
for (i = 0; i < AUDIT_INODE_BUCKETS; i++)
INIT_LIST_HEAD(_inode_hash[i]);
 
+   for (i = 0; i < AUDIT_CONTID_BUCKETS; i++)
+   INIT_LIST_HEAD(_contid_hash[i]);
+
mutex_init(_cmd_mutex.lock);
audit_cmd_mutex.owner = NULL;
 
@@ -2356,6 +2368,32 @@ int audit_signal_info(int sig, struct task_struct *t)
return audit_signal_info_syscall(t);
 }
 
+struct audit_cont *audit_cont(struct task_struct *tsk)
+{
+   if (!tsk->audit || !tsk->audit->cont)
+   return NULL;
+   return tsk->audit->cont;
+}
+
+/* audit_contid_list_lock must be held by caller */
+void audit_cont_put(struct audit_cont *cont)
+{
+   if (!cont)
+   return;
+   if 

[PATCH ghak90 V7 03/21] audit: read container ID of a process

2019-09-18 Thread Richard Guy Briggs
Add support for reading the audit container identifier from the proc
filesystem.

This is a read from the proc entry of the form
/proc/PID/audit_containerid where PID is the process ID of the task
whose audit container identifier is sought.

The read expects up to a u64 value (unset: 18446744073709551615).

This read requires CAP_AUDIT_CONTROL.

Signed-off-by: Richard Guy Briggs 
Acked-by: Serge Hallyn 
Acked-by: Neil Horman 
Reviewed-by: Ondrej Mosnacek 
---
 fs/proc/base.c | 25 ++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index e2e7c9f4702f..26091800180c 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1224,7 +1224,7 @@ static ssize_t oom_score_adj_write(struct file *file, 
const char __user *buf,
 };
 
 #ifdef CONFIG_AUDIT
-#define TMPBUFLEN 11
+#define TMPBUFLEN 21
 static ssize_t proc_loginuid_read(struct file * file, char __user * buf,
  size_t count, loff_t *ppos)
 {
@@ -1308,6 +1308,24 @@ static ssize_t proc_sessionid_read(struct file * file, 
char __user * buf,
.llseek = generic_file_llseek,
 };
 
+static ssize_t proc_contid_read(struct file *file, char __user *buf,
+ size_t count, loff_t *ppos)
+{
+   struct inode *inode = file_inode(file);
+   struct task_struct *task = get_proc_task(inode);
+   ssize_t length;
+   char tmpbuf[TMPBUFLEN];
+
+   if (!task)
+   return -ESRCH;
+   /* if we don't have caps, reject */
+   if (!capable(CAP_AUDIT_CONTROL))
+   return -EPERM;
+   length = scnprintf(tmpbuf, TMPBUFLEN, "%llu", audit_get_contid(task));
+   put_task_struct(task);
+   return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
+}
+
 static ssize_t proc_contid_write(struct file *file, const char __user *buf,
   size_t count, loff_t *ppos)
 {
@@ -1338,6 +1356,7 @@ static ssize_t proc_contid_write(struct file *file, const 
char __user *buf,
 }
 
 static const struct file_operations proc_contid_operations = {
+   .read   = proc_contid_read,
.write  = proc_contid_write,
.llseek = generic_file_llseek,
 };
@@ -3101,7 +3120,7 @@ static int proc_stack_depth(struct seq_file *m, struct 
pid_namespace *ns,
 #ifdef CONFIG_AUDIT
REG("loginuid",   S_IWUSR|S_IRUGO, proc_loginuid_operations),
REG("sessionid",  S_IRUGO, proc_sessionid_operations),
-   REG("audit_containerid", S_IWUSR, proc_contid_operations),
+   REG("audit_containerid", S_IWUSR|S_IRUSR, proc_contid_operations),
 #endif
 #ifdef CONFIG_FAULT_INJECTION
REG("make-it-fail", S_IRUGO|S_IWUSR, proc_fault_inject_operations),
@@ -3502,7 +3521,7 @@ static int proc_tid_comm_permission(struct inode *inode, 
int mask)
 #ifdef CONFIG_AUDIT
REG("loginuid",  S_IWUSR|S_IRUGO, proc_loginuid_operations),
REG("sessionid",  S_IRUGO, proc_sessionid_operations),
-   REG("audit_containerid", S_IWUSR, proc_contid_operations),
+   REG("audit_containerid", S_IWUSR|S_IRUSR, proc_contid_operations),
 #endif
 #ifdef CONFIG_FAULT_INJECTION
REG("make-it-fail", S_IRUGO|S_IWUSR, proc_fault_inject_operations),
-- 
1.8.3.1



[PATCH ghak90 V7 00/21] audit: implement container identifier

2019-09-18 Thread Richard Guy Briggs
Implement kernel audit container identifier.

This patchset is a seventh based on the proposal document (V3)
posted:
https://www.redhat.com/archives/linux-audit/2018-January/msg00014.html

The first patch was the last patch from ghak81 that was absorbed into
this patchset since its primary justification is the rest of this
patchset.

The second patch implements the proc fs write to set the audit container
identifier of a process, emitting an AUDIT_CONTAINER_OP record to
announce the registration of that audit container identifier on that
process.  This patch requires userspace support for record acceptance
and proper type display.

The third implements reading the audit container identifier from the
proc filesystem for debugging.  This patch wasn't planned for upstream
inclusion but is starting to become more likely.

The fourth converts over from a simple u64 to a list member that includes
owner information to check for descendancy, allow process injection into
a container and prevent id reuse by other orchestrators.

The fifth logs the drop of an audit container identifier once all tasks
using that audit container identifier have exited.

The 6th limits the total number of containers on a system.

The 7th implements the auxiliary record AUDIT_CONTAINER_ID if an audit
container identifier is associated with an event.  This patch requires
userspace support for proper type display.

The 8th adds audit daemon signalling provenance through audit_sig_info2.

The 9th creates a local audit context to be able to bind a standalone
record with a locally created auxiliary record.

The 10th patch adds audit container identifier records to the user
standalone records.

The 11th adds audit container identifier filtering to the exit,
exclude and user lists.  This patch adds the AUDIT_CONTID field and
requires auditctl userspace support for the --contid option.

The 12th adds network namespace audit container identifier labelling
based on member tasks' audit container identifier labels.

The 13th adds audit container identifier support to standalone netfilter
records that don't have a task context and lists each container to which
that net namespace belongs.

The 14th checks that the target is a descendant for nesting and the 15th
refactors to avoid a duplicate of the copied function.

The 16th and 17th add audit netlink interfaces for the /proc
audit_containerid, loginuid and sessionid.

The 18th adds tracking and reporting for container nesting.  This patch
could be split up and the chunks applied to earlier patches if this
nesting tracking and reporting approach is acceptable.  Arguably this is
the only way to be able to report activity in a nested container that
also affects its parent containers.

The 19th limits the container nesting depth.

The 20th adds a mechanism to allow a process to be designated as a
container orchestrator/engine in non-init user namespaces and the 21st
adds a /proc interface for testing only.


Example: Set an audit container identifier of 123456 to the "sleep" task:

  sleep 2&
  child=$!
  echo 123456 > /proc/$child/audit_containerid; echo $?
  ausearch -ts recent -m container_op
  echo child:$child contid:$( cat /proc/$child/audit_containerid)

This should produce a record such as:

  type=CONTAINER_OP msg=audit(2018-06-06 12:39:29.636:26949) : op=set opid=2209 
contid=123456 old-contid=18446744073709551615 pid=628 auid=root uid=root 
tty=ttyS0 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 
comm=bash exe=/usr/bin/bash res=yes


Example: Set a filter on an audit container identifier 123459 on 
/tmp/tmpcontainerid:

  contid=123459
  key=tmpcontainerid
  auditctl -a exit,always -F dir=/tmp -F perm=wa -F contid=$contid -F key=$key
  perl -e "sleep 1; open(my \$tmpfile, '>', \"/tmp/$key\"); close(\$tmpfile);" &
  child=$!
  echo $contid > /proc/$child/audit_containerid
  sleep 2
  ausearch -i -ts recent -k $key
  auditctl -d exit,always -F dir=/tmp -F perm=wa -F contid=$contid -F key=$key
  rm -f /tmp/$key

This should produce an event such as:

  type=CONTAINER_ID msg=audit(2018-06-06 12:46:31.707:26953) : contid=123459
  type=PROCTITLE msg=audit(2018-06-06 12:46:31.707:26953) : proctitle=perl -e 
sleep 1; open(my $tmpfile, '>', "/tmp/tmpcontainerid"); close($tmpfile);
  type=PATH msg=audit(2018-06-06 12:46:31.707:26953) : item=1 
name=/tmp/tmpcontainerid inode=25656 dev=00:26 mode=file,644 ouid=root 
ogid=root rdev=00:00 obj=unconfined_u:object_r:user_tmp_t:s0 nametype=CREATE 
cap_fp=none cap_fi=none cap_fe=0 cap_fver=0
  type=PATH msg=audit(2018-06-06 12:46:31.707:26953) : item=0 name=/tmp/ 
inode=8985 dev=00:26 mode=dir,sticky,777 ouid=root ogid=root rdev=00:00 
obj=system_u:object_r:tmp_t:s0 nametype=PARENT cap_fp=none cap_fi=none cap_fe=0 
cap_fver=0
  type=CWD msg=audit(2018-06-06 12:46:31.707:26953) : cwd=/root
  type=SYSCALL msg=audit(2018-06-06 12:46:31.707:26953) : arch=x86_64 
syscall=openat success=yes exit=3 a0=0xff9c a1=0x5621f2b81900 

Re: [PATCH 5.2 00/85] 5.2.16-stable review

2019-09-18 Thread shuah

On 9/18/19 12:18 AM, Greg Kroah-Hartman wrote:

This is the start of the stable review cycle for the 5.2.16 release.
There are 85 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Fri 20 Sep 2019 06:09:47 AM UTC.
Anything received after that time might be too late.

The whole patch series can be found in one patch at:

https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.16-rc1.gz
or in the git tree and branch at:

git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
linux-5.2.y
and the diffstat can be found below.

thanks,

greg k-h



Compiled and booted on my test system. No dmesg regressions.

thanks,
-- Shuah


Re: [PATCH 4/5] ocxl: Add functions to map/unmap LPC memory

2019-09-18 Thread Alastair D'Silva
On Wed, 2019-09-18 at 16:03 +0200, Frederic Barrat wrote:
> 
> Le 17/09/2019 à 03:43, Alastair D'Silva a écrit :
> > From: Alastair D'Silva 
> > 
> > Add functions to map/unmap LPC memory
> > 
> > Signed-off-by: Alastair D'Silva 
> > ---
> >   drivers/misc/ocxl/config.c|  4 +++
> >   drivers/misc/ocxl/core.c  | 50
> > +++
> >   drivers/misc/ocxl/link.c  |  4 +--
> >   drivers/misc/ocxl/ocxl_internal.h | 10 +--
> >   include/misc/ocxl.h   | 18 +++
> >   5 files changed, 82 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/misc/ocxl/config.c
> > b/drivers/misc/ocxl/config.c
> > index c8e19bfb5ef9..fb0c3b6f8312 100644
> > --- a/drivers/misc/ocxl/config.c
> > +++ b/drivers/misc/ocxl/config.c
> > @@ -568,6 +568,10 @@ static int read_afu_lpc_memory_info(struct
> > pci_dev *dev,
> > afu->special_purpose_mem_size =
> > total_mem_size - lpc_mem_size;
> > }
> > +
> > +   dev_info(>dev, "Probed LPC memory of %#llx bytes and
> > special purpose memory of %#llx bytes\n",
> > +   afu->lpc_mem_size, afu->special_purpose_mem_size);
> > +
> > return 0;
> >   }
> >   
> > diff --git a/drivers/misc/ocxl/core.c b/drivers/misc/ocxl/core.c
> > index fdfe4e0a34e1..eb24bb9d655f 100644
> > --- a/drivers/misc/ocxl/core.c
> > +++ b/drivers/misc/ocxl/core.c
> > @@ -210,6 +210,55 @@ static void unmap_mmio_areas(struct ocxl_afu
> > *afu)
> > release_fn_bar(afu->fn, afu->config.global_mmio_bar);
> >   }
> >   
> > +int ocxl_map_lpc_mem(struct ocxl_afu *afu)
> > +{
> > +   struct pci_dev *dev = to_pci_dev(afu->fn->dev.parent);
> > +
> > +   if ((afu->config.lpc_mem_size + afu-
> > >config.special_purpose_mem_size) == 0)
> > +   return 0;
> > +
> > +   afu->lpc_base_addr = ocxl_link_lpc_online(afu->fn->link, dev);
> > +   if (afu->lpc_base_addr == 0)
> > +   return -EINVAL;
> > +
> > +   if (afu->config.lpc_mem_size) {
> > +   afu->lpc_res.start = afu->lpc_base_addr + afu-
> > >config.lpc_mem_offset;
> > +   afu->lpc_res.end = afu->lpc_res.start + afu-
> > >config.lpc_mem_size - 1;
> > +   }
> > +
> > +   if (afu->config.special_purpose_mem_size) {
> > +   afu->special_purpose_res.start = afu->lpc_base_addr +
> > +afu-
> > >config.special_purpose_mem_offset;
> > +   afu->special_purpose_res.end = afu-
> > >special_purpose_res.start +
> > +  afu-
> > >config.special_purpose_mem_size - 1;
> > +   }
> > +
> > +   return 0;
> > +}
> > +EXPORT_SYMBOL(ocxl_map_lpc_mem);
> > +
> > +struct resource *ocxl_afu_lpc_mem(struct ocxl_afu *afu)
> > +{
> > +   return >lpc_res;
> > +}
> > +EXPORT_SYMBOL(ocxl_afu_lpc_mem);
> > +
> > +static void unmap_lpc_mem(struct ocxl_afu *afu)
> > +{
> > +   struct pci_dev *dev = to_pci_dev(afu->fn->dev.parent);
> > +
> > +   if (afu->lpc_res.start || afu->special_purpose_res.start) {
> > +   void *link = afu->fn->link;
> > +
> > +   ocxl_link_lpc_offline(link, dev);
> > +
> > +   afu->lpc_res.start = 0;
> > +   afu->lpc_res.end = 0;
> > +   afu->special_purpose_res.start = 0;
> > +   afu->special_purpose_res.end = 0;
> > +   }
> > +}
> > +
> >   static int configure_afu(struct ocxl_afu *afu, u8 afu_idx, struct
> > pci_dev *dev)
> >   {
> > int rc;
> > @@ -250,6 +299,7 @@ static int configure_afu(struct ocxl_afu *afu,
> > u8 afu_idx, struct pci_dev *dev)
> >   
> >   static void deconfigure_afu(struct ocxl_afu *afu)
> >   {
> > +   unmap_lpc_mem(afu);
> > unmap_mmio_areas(afu);
> > reclaim_afu_pasid(afu);
> > reclaim_afu_actag(afu);
> > diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c
> > index 2874811a4398..9e303a5f4d85 100644
> > --- a/drivers/misc/ocxl/link.c
> > +++ b/drivers/misc/ocxl/link.c
> > @@ -738,7 +738,7 @@ int ocxl_link_add_lpc_mem(void *link_handle,
> > u64 size)
> >   }
> >   EXPORT_SYMBOL_GPL(ocxl_link_add_lpc_mem);
> >   
> > -u64 ocxl_link_lpc_map(void *link_handle, struct pci_dev *pdev)
> > +u64 ocxl_link_lpc_online(void *link_handle, struct pci_dev *pdev)
> >   {
> > struct ocxl_link *link = (struct ocxl_link *) link_handle;
> >   
> > @@ -759,7 +759,7 @@ u64 ocxl_link_lpc_map(void *link_handle, struct
> > pci_dev *pdev)
> > return link->lpc_mem;
> >   }
> >   
> > -void ocxl_link_lpc_release(void *link_handle, struct pci_dev
> > *pdev)
> > +void ocxl_link_lpc_offline(void *link_handle, struct pci_dev
> > *pdev)
> 
> Could we avoid the renaming by squashing it with the previous patch?
> 

Yup, good catch.

> 
> >   {
> > struct ocxl_link *link = (struct ocxl_link *) link_handle;
> >   
> > diff --git a/drivers/misc/ocxl/ocxl_internal.h
> > b/drivers/misc/ocxl/ocxl_internal.h
> > index db2647a90fc8..5656a4aab5b7 100644
> > --- a/drivers/misc/ocxl/ocxl_internal.h
> > +++ b/drivers/misc/ocxl/ocxl_internal.h
> > @@ -52,6 +52,12 @@ struct ocxl_afu 

[PATCH] hugetlbfs: hugetlb_fault_mutex_hash cleanup

2019-09-18 Thread Mike Kravetz
A new clang diagnostic (-Wsizeof-array-div) warns about the calculation
to determine the number of u32's in an array of unsigned longs. Suppress
warning by adding parentheses.

While looking at the above issue, noticed that the 'address' parameter
to hugetlb_fault_mutex_hash is no longer used. So, remove it from the
definition and all callers.

No functional change.

Reported-by: Nathan Chancellor 
Signed-off-by: Mike Kravetz 
---
 fs/hugetlbfs/inode.c|  4 ++--
 include/linux/hugetlb.h |  2 +-
 mm/hugetlb.c| 10 +-
 mm/userfaultfd.c|  2 +-
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index a478df035651..6e5eadee6b0d 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -440,7 +440,7 @@ static void remove_inode_hugepages(struct inode *inode, 
loff_t lstart,
u32 hash;
 
index = page->index;
-   hash = hugetlb_fault_mutex_hash(h, mapping, index, 0);
+   hash = hugetlb_fault_mutex_hash(h, mapping, index);
mutex_lock(_fault_mutex_table[hash]);
 
/*
@@ -644,7 +644,7 @@ static long hugetlbfs_fallocate(struct file *file, int 
mode, loff_t offset,
addr = index * hpage_size;
 
/* mutex taken here, fault path and hole punch */
-   hash = hugetlb_fault_mutex_hash(h, mapping, index, addr);
+   hash = hugetlb_fault_mutex_hash(h, mapping, index);
mutex_lock(_fault_mutex_table[hash]);
 
/* See if already present in mapping to avoid alloc/free */
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index edfca4278319..5bf11fffbbd4 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -106,7 +106,7 @@ void free_huge_page(struct page *page);
 void hugetlb_fix_reserve_counts(struct inode *inode);
 extern struct mutex *hugetlb_fault_mutex_table;
 u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping,
-   pgoff_t idx, unsigned long address);
+   pgoff_t idx);
 
 pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud);
 
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 6d7296dd11b8..3705d3c69e32 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3847,7 +3847,7 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm,
 * handling userfault.  Reacquire after handling
 * fault to make calling code simpler.
 */
-   hash = hugetlb_fault_mutex_hash(h, mapping, idx, haddr);
+   hash = hugetlb_fault_mutex_hash(h, mapping, idx);
mutex_unlock(_fault_mutex_table[hash]);
ret = handle_userfault(, VM_UFFD_MISSING);
mutex_lock(_fault_mutex_table[hash]);
@@ -3975,7 +3975,7 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm,
 
 #ifdef CONFIG_SMP
 u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping,
-   pgoff_t idx, unsigned long address)
+   pgoff_t idx)
 {
unsigned long key[2];
u32 hash;
@@ -3983,7 +3983,7 @@ u32 hugetlb_fault_mutex_hash(struct hstate *h, struct 
address_space *mapping,
key[0] = (unsigned long) mapping;
key[1] = idx;
 
-   hash = jhash2((u32 *), sizeof(key)/sizeof(u32), 0);
+   hash = jhash2((u32 *), sizeof(key)/(sizeof(u32)), 0);
 
return hash & (num_fault_mutexes - 1);
 }
@@ -3993,7 +3993,7 @@ u32 hugetlb_fault_mutex_hash(struct hstate *h, struct 
address_space *mapping,
  * return 0 and avoid the hashing overhead.
  */
 u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping,
-   pgoff_t idx, unsigned long address)
+   pgoff_t idx)
 {
return 0;
 }
@@ -4037,7 +4037,7 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct 
vm_area_struct *vma,
 * get spurious allocation failures if two CPUs race to instantiate
 * the same page in the page cache.
 */
-   hash = hugetlb_fault_mutex_hash(h, mapping, idx, haddr);
+   hash = hugetlb_fault_mutex_hash(h, mapping, idx);
mutex_lock(_fault_mutex_table[hash]);
 
entry = huge_ptep_get(ptep);
diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
index c7ae74ce5ff3..640ff2bd9a69 100644
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -269,7 +269,7 @@ static __always_inline ssize_t 
__mcopy_atomic_hugetlb(struct mm_struct *dst_mm,
 */
idx = linear_page_index(dst_vma, dst_addr);
mapping = dst_vma->vm_file->f_mapping;
-   hash = hugetlb_fault_mutex_hash(h, mapping, idx, dst_addr);
+   hash = hugetlb_fault_mutex_hash(h, mapping, idx);

Re: [PATCH v6 6/9] leds: multicolor: Introduce a multicolor class definition

2019-09-18 Thread Dan Murphy

Jacek

On 9/18/19 4:27 PM, Jacek Anaszewski wrote:

Hi Dan,

I think Greg's guidance clarified everything nicely -
we will avoid  sub-dirs in favour of prefixes
to *intensity and *max_intensity.

Yes I will make the change accordingly.  It will simplify the code.


Before you will send an update I have some improvement
ideas regarding the remnants after the previous approach,
where single color intensity update resulted in updating
hardware state. Now the update will happen only on write to
brightness file, so we will not need color_set/color_get ops
anymore.


I left those call backs in specifically for the LP50xx. Otherwise the 
LEDs are only updated when the brightness file is written.


The LP50xx has an engine that performs the intensity computation for the 
specific LED.  So there is no call back to the MC FW for calculating the 
intensity.


The brightness and intensity are written directly to the device and the 
MCU in the device does all the computations so you have real time update.


For the LP55xx device the LEDs are only updated when the brightness file 
is written.


I think we can leave those call backs in if device driver or product 
development teams would like to use them.


Dan



On 9/17/19 7:59 PM, Dan Murphy wrote:

Introduce a multicolor class that groups colored LEDs
within a LED node.

The framework allows for dynamically setting individual LEDs
or setting brightness levels of LEDs and updating them virtually
simultaneously.

Signed-off-by: Dan Murphy 
---

v6 removed color_id and color_mix files, used sysfs_create_groups instead of
kobject call for LED color directory, kept kobject_create for the "colors" 
directory,
removed the calculate function, updated the export for the intensity 
calculations.


  drivers/leds/Kconfig |  10 +
  drivers/leds/Makefile|   1 +
  drivers/leds/led-class-multicolor.c  | 306 +++
  include/linux/led-class-multicolor.h |  90 
  4 files changed, 407 insertions(+)
  create mode 100644 drivers/leds/led-class-multicolor.c
  create mode 100644 include/linux/led-class-multicolor.h

diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 1988de1d64c0..71e7fd4f6f15 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -30,6 +30,16 @@ config LEDS_CLASS_FLASH
  for the flash related features of a LED device. It can be built
  as a module.
  
+config LEDS_CLASS_MULTI_COLOR

+   tristate "LED Mulit Color LED Class Support"
+   depends on LEDS_CLASS
+   help
+ This option enables the multicolor LED sysfs class in /sys/class/leds.
+ It wraps LED class and adds multicolor LED specific sysfs attributes
+ and kernel internal API to it. You'll need this to provide support
+ for multicolor LEDs that are grouped together. This class is not
+ intended for single color LEDs. It can be built as a module.
+
  config LEDS_BRIGHTNESS_HW_CHANGED
bool "LED Class brightness_hw_changed attribute support"
depends on LEDS_CLASS
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 41fb073a39c1..897b810257dd 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -4,6 +4,7 @@
  obj-$(CONFIG_NEW_LEDS)+= led-core.o
  obj-$(CONFIG_LEDS_CLASS)  += led-class.o
  obj-$(CONFIG_LEDS_CLASS_FLASH)+= led-class-flash.o
+obj-$(CONFIG_LEDS_CLASS_MULTI_COLOR)   += led-class-multicolor.o
  obj-$(CONFIG_LEDS_TRIGGERS)   += led-triggers.o
  
  # LED Platform Drivers

diff --git a/drivers/leds/led-class-multicolor.c 
b/drivers/leds/led-class-multicolor.c
new file mode 100644
index ..d43bd344ed4c
--- /dev/null
+++ b/drivers/leds/led-class-multicolor.c
@@ -0,0 +1,306 @@
+// SPDX-License-Identifier: GPL-2.0
+// LED Multi Color class interface
+// Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "leds.h"
+
+struct led_mc_color_entry {
+   struct led_classdev_mc *mcled_cdev;
+
+   struct device_attribute max_intensity_attr;
+   struct device_attribute intensity_attr;
+
+   enum led_brightness max_intensity;
+   enum led_brightness intensity;
+
+   struct list_head list;
+
+   int led_color_id;
+};
+
+void led_mc_calc_brightness(struct led_classdev_mc *mcled_cdev,
+   enum led_brightness brightness,
+   int brightness_val[])
+{
+   struct led_classdev_mc_data *data = mcled_cdev->data;
+   struct led_mc_color_entry *priv;
+   int i = 0;
+
+   list_for_each_entry(priv, >color_list, list) {
+   brightness_val[i] = brightness *
+   priv->intensity / priv->max_intensity;
+   i++;
+   }
+}
+EXPORT_SYMBOL_GPL(led_mc_calc_brightness);
+
+static ssize_t intensity_store(struct device *dev,
+

Re: [PATCH 2/5] powerpc: Map & release OpenCAPI LPC memory

2019-09-18 Thread Alastair D'Silva
On Wed, 2019-09-18 at 16:03 +0200, Frederic Barrat wrote:
> 
> Le 17/09/2019 à 03:42, Alastair D'Silva a écrit :
> > From: Alastair D'Silva 
> > 
> > Map & release OpenCAPI LPC memory.
> > 
> > Signed-off-by: Alastair D'Silva 
> > ---
> >   arch/powerpc/include/asm/pnv-ocxl.h   |  2 ++
> >   arch/powerpc/platforms/powernv/ocxl.c | 42
> > +++
> >   2 files changed, 44 insertions(+)
> > 
> > diff --git a/arch/powerpc/include/asm/pnv-ocxl.h
> > b/arch/powerpc/include/asm/pnv-ocxl.h
> > index 7de82647e761..f8f8ffb48aa8 100644
> > --- a/arch/powerpc/include/asm/pnv-ocxl.h
> > +++ b/arch/powerpc/include/asm/pnv-ocxl.h
> > @@ -32,5 +32,7 @@ extern int pnv_ocxl_spa_remove_pe_from_cache(void
> > *platform_data, int pe_handle)
> >   
> >   extern int pnv_ocxl_alloc_xive_irq(u32 *irq, u64 *trigger_addr);
> >   extern void pnv_ocxl_free_xive_irq(u32 irq);
> > +extern u64 pnv_ocxl_platform_lpc_setup(struct pci_dev *pdev, u64
> > size);
> > +extern void pnv_ocxl_platform_lpc_release(struct pci_dev *pdev);
> >   
> >   #endif /* _ASM_PNV_OCXL_H */
> > diff --git a/arch/powerpc/platforms/powernv/ocxl.c
> > b/arch/powerpc/platforms/powernv/ocxl.c
> > index 8c65aacda9c8..81393728d6a3 100644
> > --- a/arch/powerpc/platforms/powernv/ocxl.c
> > +++ b/arch/powerpc/platforms/powernv/ocxl.c
> > @@ -475,6 +475,48 @@ void pnv_ocxl_spa_release(void *platform_data)
> >   }
> >   EXPORT_SYMBOL_GPL(pnv_ocxl_spa_release);
> >   
> > +u64 pnv_ocxl_platform_lpc_setup(struct pci_dev *pdev, u64 size)
> > +{
> > +   struct pci_controller *hose = pci_bus_to_host(pdev->bus);
> > +   struct pnv_phb *phb = hose->private_data;
> > +   struct pci_dn *pdn = pci_get_pdn(pdev);
> > +   u32 bdfn = (pdn->busno << 8) | pdn->devfn;
> 
> We can spare a call to pci_get_pdn() with
> bdfn = (pdev->bus->number << 8) | pdev->devfn;
> 

Ok.

> 
> > +   u64 base_addr = 0;
> > +
> > +   int rc = opal_npu_mem_alloc(phb->opal_id, bdfn, size,
> > _addr);
> > +
> > +   WARN_ON(rc);
> 
> Instead of a WARN, we should catch the error and return a null
> address 
> to the caller.
> 

base_addr will be 0 in the error case, are you suggesting we just
remove the WARN_ON()?

> > +
> > +   base_addr = be64_to_cpu(base_addr);
> > +
> > +   rc = check_hotplug_memory_addressable(base_addr, base_addr +
> > size);
> 
> That code is missing?
> 

That's added in the following patch on the mm list:
 [PATCH v3 1/2] memory_hotplug: Add a bounds check to
check_hotplug_memory_range()

> 
> > +   if (rc) {
> > +   dev_warn(>dev,
> > +"LPC memory range 0x%llx-0x%llx is not fully
> > addressable",
> > +base_addr, base_addr + size - 1);
> > +   return 0;
> > +   }
> > +
> > +
> > +   return base_addr;
> > +}
> > +EXPORT_SYMBOL_GPL(pnv_ocxl_platform_lpc_setup);
> > +
> > +void pnv_ocxl_platform_lpc_release(struct pci_dev *pdev)
> > +{
> > +   struct pci_controller *hose = pci_bus_to_host(pdev->bus);
> > +   struct pnv_phb *phb = hose->private_data;
> > +   struct pci_dn *pdn = pci_get_pdn(pdev);
> > +   u32 bdfn;
> > +   int rc;
> > +
> > +   bdfn = (pdn->busno << 8) | pdn->devfn;
> > +   rc = opal_npu_mem_release(phb->opal_id, bdfn);
> > +   WARN_ON(rc);
> 
> Same comments as above.
> 
>Fred
> 
> 
> 
> > +}
> > +EXPORT_SYMBOL_GPL(pnv_ocxl_platform_lpc_release);
> > +
> > +
> >   int pnv_ocxl_spa_remove_pe_from_cache(void *platform_data, int
> > pe_handle)
> >   {
> > struct spa_data *data = (struct spa_data *) platform_data;
> > 
-- 
Alastair D'Silva
Open Source Developer
Linux Technology Centre, IBM Australia
mob: 0423 762 819



[PATCH v2 5/6] platform/x86: huawei-wmi: Add fn-lock support

2019-09-18 Thread Ayman Bagabas
Huawei Matebook laptops uses Fn key and toggle to access F1-F12 keys.
Along with that, there is this feature called fn-lock that inverts the
behavior of this Fn key and the F1-F12 row.

Signed-off-by: Ayman Bagabas 
---
 drivers/platform/x86/huawei-wmi.c | 85 +++
 1 file changed, 85 insertions(+)

diff --git a/drivers/platform/x86/huawei-wmi.c 
b/drivers/platform/x86/huawei-wmi.c
index 231b5cce00db..48be55c6027e 100644
--- a/drivers/platform/x86/huawei-wmi.c
+++ b/drivers/platform/x86/huawei-wmi.c
@@ -59,6 +59,7 @@ struct huawei_wmi_debug {
 
 struct huawei_wmi {
bool battery_available;
+   bool fn_lock_available;
 
struct huawei_wmi_debug debug;
struct input_dev *idev[2];
@@ -515,6 +516,88 @@ static void huawei_wmi_battery_exit(struct device *dev)
}
 }
 
+/* Fn lock */
+
+static int huawei_wmi_fn_lock_get(int *on)
+{
+   u8 ret[0x100] = { 0 };
+   int err, i;
+
+   err = huawei_wmi_cmd(FN_LOCK_GET, ret, 0x100);
+   if (err)
+   return err;
+
+   /* Find the first non-zero value. Return status is ignored. */
+   i = 1;
+   do {
+   if (on)
+   *on = ret[i] - 1; // -1 undefined, 0 off, 1 on.
+   } while (i < 0x100 && !ret[i++]);
+
+   return 0;
+}
+
+static int huawei_wmi_fn_lock_set(int on)
+{
+   union hwmi_arg arg;
+
+   arg.cmd = FN_LOCK_SET;
+   arg.args[2] = on + 1; // 0 undefined, 1 off, 2 on.
+
+   return huawei_wmi_cmd(arg.cmd, NULL, NULL);
+}
+
+static ssize_t fn_lock_state_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
+{
+   int err, on;
+
+   err = huawei_wmi_fn_lock_get();
+   if (err)
+   return err;
+
+   return sprintf(buf, "%d\n", on);
+}
+
+static ssize_t fn_lock_state_store(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t size)
+{
+   int on, err;
+
+   if (kstrtoint(buf, 10, ) ||
+   on < 0 || on > 1)
+   return -EINVAL;
+
+   err = huawei_wmi_fn_lock_set(on);
+   if (err)
+   return err;
+
+   return size;
+}
+
+static DEVICE_ATTR_RW(fn_lock_state);
+
+static void huawei_wmi_fn_lock_setup(struct device *dev)
+{
+   struct huawei_wmi *huawei = dev_get_drvdata(dev);
+
+   huawei->fn_lock_available = true;
+   if (huawei_wmi_fn_lock_get(NULL)) {
+   huawei->fn_lock_available = false;
+   return;
+   }
+
+   device_create_file(dev, _attr_fn_lock_state);
+}
+
+static void huawei_wmi_fn_lock_exit(struct device *dev)
+{
+   if (huawei_wmi->fn_lock_available)
+   device_remove_file(dev, _attr_fn_lock_state);
+}
+
 /* Input */
 
 static void huawei_wmi_process_key(struct input_dev *idev, int code)
@@ -638,6 +721,7 @@ static int huawei_wmi_probe(struct platform_device *pdev)
mutex_init(_wmi->battery_lock);
 
huawei_wmi_leds_setup(>dev);
+   huawei_wmi_fn_lock_setup(>dev);
huawei_wmi_battery_setup(>dev);
}
 
@@ -657,6 +741,7 @@ static int huawei_wmi_remove(struct platform_device *pdev)
 
if (wmi_has_guid(HWMI_METHOD_GUID)) {
huawei_wmi_battery_exit(>dev);
+   huawei_wmi_fn_lock_exit(>dev);
}
 
return 0;
-- 
2.21.0



[PATCH v2 4/6] platform/x86: huawei-wmi: Add battery charging thresholds

2019-09-18 Thread Ayman Bagabas
Controll battery charge thresholds through the battery API and driver's
attributes.

Setting battery charging thresholds can introduce a race condition with
MACH-WX9 where two or more threads are trying to read/write values
from/to EC memory.

Signed-off-by: Ayman Bagabas 
---
 drivers/platform/x86/huawei-wmi.c | 212 ++
 1 file changed, 212 insertions(+)

diff --git a/drivers/platform/x86/huawei-wmi.c 
b/drivers/platform/x86/huawei-wmi.c
index 904ef38944b6..231b5cce00db 100644
--- a/drivers/platform/x86/huawei-wmi.c
+++ b/drivers/platform/x86/huawei-wmi.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -13,7 +14,10 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
+#include 
 
 /*
  * Huawei WMI GUIDs
@@ -54,11 +58,14 @@ struct huawei_wmi_debug {
 };
 
 struct huawei_wmi {
+   bool battery_available;
+
struct huawei_wmi_debug debug;
struct input_dev *idev[2];
struct led_classdev cdev;
struct platform_device *pdev;
 
+   struct mutex battery_lock;
struct mutex wmi_lock;
 };
 
@@ -306,6 +313,208 @@ static void huawei_wmi_leds_setup(struct device *dev)
devm_led_classdev_register(dev, >cdev);
 }
 
+/* Battery protection */
+
+static int huawei_wmi_battery_get(int *start, int *end)
+{
+   u8 ret[0x100];
+   int err, i;
+
+   err = huawei_wmi_cmd(BATTERY_THRESH_GET, ret, 0x100);
+   if (err)
+   return err;
+
+   /* Find the last two non-zero values. Return status is ignored. */
+   i = 0x100;
+   do {
+   if (start)
+   *start = ret[i-1];
+   if (end)
+   *end = ret[i];
+   } while (i > 2 && !ret[i--]);
+
+   return 0;
+}
+
+static int huawei_wmi_battery_set(int start, int end)
+{
+   union hwmi_arg arg;
+   int err;
+
+   if (start < 0 || end > 100)
+   return -EINVAL;
+
+   arg.cmd = BATTERY_THRESH_SET;
+   arg.args[2] = start;
+   arg.args[3] = end;
+
+   /* This is an edge case were some models turn battery protection
+* off without changing their thresholds values. We clear the
+* values before turning off protection. Sometimes we need a sleep 
delay to
+* make sure these values make their way to EC memory.
+*/
+   if (quirks && quirks->battery_reset && start == 0 && end == 100) {
+   err = huawei_wmi_battery_set(0, 0);
+   if (err)
+   return err;
+
+   msleep(1000);
+   }
+
+   err = huawei_wmi_cmd(arg.cmd, NULL, NULL);
+
+   return err;
+}
+
+static ssize_t charge_control_start_threshold_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
+{
+   int err, start;
+
+   err = huawei_wmi_battery_get(, NULL);
+   if (err)
+   return err;
+
+   return sprintf(buf, "%d\n", start);
+}
+
+static ssize_t charge_control_end_threshold_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
+{
+   int err, end;
+
+   err = huawei_wmi_battery_get(NULL, );
+   if (err)
+   return err;
+
+   return sprintf(buf, "%d\n", end);
+}
+
+static ssize_t charge_control_thresholds_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
+{
+   int err, start, end;
+
+   err = huawei_wmi_battery_get(, );
+   if (err)
+   return err;
+
+   return sprintf(buf, "%d %d\n", start, end);
+}
+
+static ssize_t charge_control_start_threshold_store(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t size)
+{
+   int err, start, end;
+
+   err = huawei_wmi_battery_get(NULL, );
+   if (err)
+   return err;
+
+   if (sscanf(buf, "%d", ) != 1)
+   return -EINVAL;
+
+   err = huawei_wmi_battery_set(start, end);
+   if (err)
+   return err;
+
+   return size;
+}
+
+static ssize_t charge_control_end_threshold_store(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t size)
+{
+   int err, start, end;
+
+   err = huawei_wmi_battery_get(, NULL);
+   if (err)
+   return err;
+
+   if (sscanf(buf, "%d", ) != 1)
+   return -EINVAL;
+
+   err = huawei_wmi_battery_set(start, end);
+   if (err)
+   return err;
+
+   return size;
+}
+
+static ssize_t charge_control_thresholds_store(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t size)
+{
+   int err, start, end;
+
+   if (sscanf(buf, "%d %d", , ) != 2)
+   return -EINVAL;
+
+   err = huawei_wmi_battery_set(start, end);
+   if (err)
+   return err;
+
+   return size;
+}
+

[PATCH v2 6/6] platform/x86: huawei-wmi: Add debugfs support

2019-09-18 Thread Ayman Bagabas
Add a debugfs interface that can be used to call the WMI management
interface function if available.

Signed-off-by: Ayman Bagabas 
---
 drivers/platform/x86/huawei-wmi.c | 91 +++
 1 file changed, 91 insertions(+)

diff --git a/drivers/platform/x86/huawei-wmi.c 
b/drivers/platform/x86/huawei-wmi.c
index 48be55c6027e..9ae2ecadeb10 100644
--- a/drivers/platform/x86/huawei-wmi.c
+++ b/drivers/platform/x86/huawei-wmi.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -598,6 +599,94 @@ static void huawei_wmi_fn_lock_exit(struct device *dev)
device_remove_file(dev, _attr_fn_lock_state);
 }
 
+/* debugfs */
+
+static void huawei_wmi_debugfs_call_dump(struct seq_file *m, void *data,
+   union acpi_object *obj)
+{
+   struct huawei_wmi *huawei = m->private;
+   int i;
+
+   switch (obj->type) {
+   case ACPI_TYPE_INTEGER:
+   seq_printf(m, "0x%llx", obj->integer.value);
+   break;
+   case ACPI_TYPE_STRING:
+   seq_printf(m, "\"%*s\"", obj->string.length, 
obj->string.pointer);
+   break;
+   case ACPI_TYPE_BUFFER:
+   seq_puts(m, "{");
+   for (i = 0; i < obj->buffer.length; i++) {
+   seq_printf(m, "0x%02x", obj->buffer.pointer[i]);
+   if (i < obj->buffer.length - 1)
+   seq_puts(m, ",");
+   }
+   seq_puts(m, "}");
+   break;
+   case ACPI_TYPE_PACKAGE:
+   seq_puts(m, "[");
+   for (i = 0; i < obj->package.count; i++) {
+   huawei_wmi_debugfs_call_dump(m, huawei, 
>package.elements[i]);
+   if (i < obj->package.count - 1)
+   seq_puts(m, ",");
+   }
+   seq_puts(m, "]");
+   break;
+   default:
+   dev_err(>pdev->dev, "Unexpected obj type, got %d\n", 
obj->type);
+   return;
+   }
+}
+
+static int huawei_wmi_debugfs_call_show(struct seq_file *m, void *data)
+{
+   struct huawei_wmi *huawei = m->private;
+   struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL };
+   struct acpi_buffer in;
+   union acpi_object *obj;
+   int err;
+
+   in.length = sizeof(u64);
+   in.pointer = >debug.arg;
+
+   err = huawei_wmi_call(, );
+   if (err)
+   return err;
+
+   obj = out.pointer;
+   if (!obj) {
+   err = -EIO;
+   goto fail_debugfs_call;
+   }
+
+   huawei_wmi_debugfs_call_dump(m, huawei, obj);
+
+fail_debugfs_call:
+   kfree(out.pointer);
+   return err;
+}
+
+DEFINE_SHOW_ATTRIBUTE(huawei_wmi_debugfs_call);
+
+static void huawei_wmi_debugfs_setup(struct device *dev)
+{
+   struct huawei_wmi *huawei = dev_get_drvdata(dev);
+
+   huawei->debug.root = debugfs_create_dir("huawei-wmi", NULL);
+
+   debugfs_create_x64("arg", 0644, huawei->debug.root,
+   >debug.arg);
+   debugfs_create_file("call", 0400,
+   huawei->debug.root, huawei, _wmi_debugfs_call_fops);
+}
+
+static void huawei_wmi_debugfs_exit(struct device *dev)
+{
+   struct huawei_wmi *huawei = dev_get_drvdata(dev);
+
+   debugfs_remove_recursive(huawei->debug.root);
+}
+
 /* Input */
 
 static void huawei_wmi_process_key(struct input_dev *idev, int code)
@@ -723,6 +812,7 @@ static int huawei_wmi_probe(struct platform_device *pdev)
huawei_wmi_leds_setup(>dev);
huawei_wmi_fn_lock_setup(>dev);
huawei_wmi_battery_setup(>dev);
+   huawei_wmi_debugfs_setup(>dev);
}
 
return 0;
@@ -740,6 +830,7 @@ static int huawei_wmi_remove(struct platform_device *pdev)
}
 
if (wmi_has_guid(HWMI_METHOD_GUID)) {
+   huawei_wmi_debugfs_exit(>dev);
huawei_wmi_battery_exit(>dev);
huawei_wmi_fn_lock_exit(>dev);
}
-- 
2.21.0



[PATCH v2 3/6] platform/x86: huawei-wmi: Implement huawei wmi management

2019-09-18 Thread Ayman Bagabas
Huawei Matebook laptops come with a WMI management interface that can
control various aspects of the device. This interface is also found on
the old Matebook X released in 2017.

Use that to control the mic mute LED.

Signed-off-by: Ayman Bagabas 
---
 drivers/platform/x86/huawei-wmi.c | 217 +-
 1 file changed, 180 insertions(+), 37 deletions(-)

diff --git a/drivers/platform/x86/huawei-wmi.c 
b/drivers/platform/x86/huawei-wmi.c
index 97ff3d868765..904ef38944b6 100644
--- a/drivers/platform/x86/huawei-wmi.c
+++ b/drivers/platform/x86/huawei-wmi.c
@@ -11,18 +11,35 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
 /*
  * Huawei WMI GUIDs
  */
+#define HWMI_METHOD_GUID "ABBC0F5B-8EA1-11D1-A000-C9062910"
 #define HWMI_EVENT_GUID "ABBC0F5C-8EA1-11D1-A000-C9062910"
 
 /* Legacy GUIDs */
 #define WMI0_EXPENSIVE_GUID "39142400-C6A3-40fa-BADB-8A2652834100"
 #define WMI0_EVENT_GUID "59142400-C6A3-40fa-BADB-8A2652834100"
 
+/* HWMI commands */
+
+enum {
+   BATTERY_THRESH_GET  = 0x1103, /* \GBTT */
+   BATTERY_THRESH_SET  = 0x1003, /* \SBTT */
+   FN_LOCK_GET = 0x0604, /* \GFRS */
+   FN_LOCK_SET = 0x0704, /* \SFRS */
+   MICMUTE_LED_SET = 0x0b04, /* \SMLS */
+};
+
+union hwmi_arg {
+   u64 cmd;
+   u8 args[8];
+};
+
 struct quirk_entry {
bool battery_reset;
bool ec_micmute;
@@ -41,8 +58,8 @@ struct huawei_wmi {
struct input_dev *idev[2];
struct led_classdev cdev;
struct platform_device *pdev;
-   acpi_handle handle;
-   char *acpi_method;
+
+   struct mutex wmi_lock;
 };
 
 struct huawei_wmi *huawei_wmi;
@@ -116,52 +133,168 @@ static const struct dmi_system_id huawei_quirks[] = {
{  }
 };
 
+/* Utils */
+
+static int huawei_wmi_call(struct acpi_buffer *in, struct acpi_buffer *out)
+{
+   acpi_status status;
+
+   mutex_lock(_wmi->wmi_lock);
+   status = wmi_evaluate_method(HWMI_METHOD_GUID, 0, 1, in, out);
+   mutex_unlock(_wmi->wmi_lock);
+   if (ACPI_FAILURE(status)) {
+   dev_err(_wmi->pdev->dev, "Failed to evaluate wmi 
method\n");
+   return -ENODEV;
+   }
+
+   return 0;
+}
+
+/* HWMI takes a 64 bit input and returns either a package with 2 buffers, one 
of
+ * 4 bytes and the other of 256 bytes, or one buffer of size 0x104 (260) bytes.
+ * The first 4 bytes are ignored, we ignore the first 4 bytes buffer if we got 
a
+ * package, or skip the first 4 if a buffer of 0x104 is used. The first byte of
+ * the remaining 0x100 sized buffer has the return status of every call. In 
case
+ * the return status is non-zero, we return -ENODEV but still copy the returned
+ * buffer to the given buffer parameter (buf).
+ */
+static int huawei_wmi_cmd(u64 arg, u8 *buf, size_t buflen)
+{
+   struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL };
+   struct acpi_buffer in;
+   union acpi_object *obj;
+   size_t len;
+   int err, i;
+
+   in.length = sizeof(arg);
+   in.pointer = 
+
+   /* Some models require calling HWMI twice to execute a command. We 
evaluate
+* HWMI and if we get a non-zero return status we evaluate it again.
+*/
+   for (i = 0; i < 2; i++) {
+   err = huawei_wmi_call(, );
+   if (err)
+   goto fail_cmd;
+
+   obj = out.pointer;
+   if (!obj) {
+   err = -EIO;
+   goto fail_cmd;
+   }
+
+   switch (obj->type) {
+   /* Models that implement both "legacy" and HWMI tend to return 
a 0x104
+* sized buffer instead of a package of 0x4 and 0x100 buffers.
+*/
+   case ACPI_TYPE_BUFFER:
+   if (obj->buffer.length == 0x104) {
+   // Skip the first 4 bytes.
+   obj->buffer.pointer += 4;
+   len = 0x100;
+   } else {
+   dev_err(_wmi->pdev->dev, "Bad buffer 
length, got %d\n", obj->buffer.length);
+   err = -EIO;
+   goto fail_cmd;
+   }
+
+   break;
+   /* HWMI returns a package with 2 buffer elements, one of 4 
bytes and the
+* other is 256 bytes.
+*/
+   case ACPI_TYPE_PACKAGE:
+   if (obj->package.count != 2) {
+   dev_err(_wmi->pdev->dev, "Bad package 
count, got %d\n", obj->package.count);
+   err = -EIO;
+   goto fail_cmd;
+   }
+
+   obj = >package.elements[1];
+   if (obj->type != ACPI_TYPE_BUFFER) {
+

  1   2   3   4   5   6   7   8   9   10   >