Re: [PATCH v3 1/2] pci/hotplug/pnv_php: Fix hotplug driver crash on Powernv

2024-06-27 Thread Michael Ellerman
Bjorn Helgaas  writes:
> I expect this series would go through the powerpc tree since that's
> where most of the chance is.

Thanks, yeah I'll plan to merge v4 with your comments addressed.

cheers

> On Mon, Jun 24, 2024 at 05:39:27PM +0530, Krishna Kumar wrote:
>> Description of the problem: The hotplug driver for powerpc
>> (pci/hotplug/pnv_php.c) gives kernel crash when we try to
>> hot-unplug/disable the PCIe switch/bridge from the PHB.
>> 
>> Root Cause of Crash: The crash is due to the reason that, though the msi
>> data structure has been released during disable/hot-unplug path and it
>> has been assigned with NULL, still during unregistartion the code was
>> again trying to explicitly disable the msi which causes the Null pointer
>> dereference and kernel crash.
>
> s/unregistartion/unregistration/
> s/Null/NULL/ to match previous use
> s/msi/MSI/ to match spec usage
>
>> Proposed Fix : The fix is to correct the check during unregistration path
>> so that the code should not  try to invoke pci_disable_msi/msix() if its
>> data structure is already freed.
>
> s/Proposed Fix : The fix is to// ... Just say what the patch does.
>
> If/when the powerpc folks like this, add my:
>
> Acked-by: Bjorn Helgaas 
>
>> Cc: Michael Ellerman 
>> Cc: Nicholas Piggin 
>> Cc: Christophe Leroy 
>> Cc: "Aneesh Kumar K.V" 
>> Cc: Bjorn Helgaas 
>> Cc: Gaurav Batra 
>> Cc: Nathan Lynch 
>> Cc: Brian King 
>> 
>> Signed-off-by: Krishna Kumar 
>> ---
>>  drivers/pci/hotplug/pnv_php.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>> 
>> diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c
>> index 694349be9d0a..573a41869c15 100644
>> --- a/drivers/pci/hotplug/pnv_php.c
>> +++ b/drivers/pci/hotplug/pnv_php.c
>> @@ -40,7 +40,6 @@ static void pnv_php_disable_irq(struct pnv_php_slot 
>> *php_slot,
>>  bool disable_device)
>>  {
>>  struct pci_dev *pdev = php_slot->pdev;
>> -int irq = php_slot->irq;
>>  u16 ctrl;
>>  
>>  if (php_slot->irq > 0) {
>> @@ -59,7 +58,7 @@ static void pnv_php_disable_irq(struct pnv_php_slot 
>> *php_slot,
>>  php_slot->wq = NULL;
>>  }
>>  
>> -if (disable_device || irq > 0) {
>> +if (disable_device) {
>>  if (pdev->msix_enabled)
>>  pci_disable_msix(pdev);
>>  else if (pdev->msi_enabled)
>> -- 
>> 2.45.0
>> 


Re: [PATCH v3 1/2] pci/hotplug/pnv_php: Fix hotplug driver crash on Powernv

2024-06-27 Thread Michael Ellerman
Shawn Anastasio  writes:
> Hi Krishna,
>
> On 6/24/24 7:09 AM, Krishna Kumar wrote:
>> Description of the problem: The hotplug driver for powerpc
>> (pci/hotplug/pnv_php.c) gives kernel crash when we try to
>> hot-unplug/disable the PCIe switch/bridge from the PHB.
>> 
>> Root Cause of Crash: The crash is due to the reason that, though the msi
>> data structure has been released during disable/hot-unplug path and it
>> has been assigned with NULL, still during unregistartion the code was
>> again trying to explicitly disable the msi which causes the Null pointer
>> dereference and kernel crash.
>> 
>> Proposed Fix : The fix is to correct the check during unregistration path
>> so that the code should not  try to invoke pci_disable_msi/msix() if its
>> data structure is already freed.
>> 
>> Cc: Michael Ellerman 
>> Cc: Nicholas Piggin 
>> Cc: Christophe Leroy 
>> Cc: "Aneesh Kumar K.V" 
>> Cc: Bjorn Helgaas 
>> Cc: Gaurav Batra 
>> Cc: Nathan Lynch 
>> Cc: Brian King 
>> 
>> Signed-off-by: Krishna Kumar 
>
> As with v1, I can confirm that this patch solves the panic encountered
> when hotplugging PCIe bridges on POWER9.

Was the panic reported anywhere? So we can link to the report in the
commit.

cheers


Re: [PATCH 13/13] mm: Remove devmap related functions and page table bits

2024-06-27 Thread kernel test robot
Hi Alistair,

kernel test robot noticed the following build errors:

[auto build test ERROR on f2661062f16b2de5d7b6a5c42a9a5c96326b8454]

url:
https://github.com/intel-lab-lkp/linux/commits/Alistair-Popple/mm-gup-c-Remove-redundant-check-for-PCI-P2PDMA-page/20240627-191709
base:   f2661062f16b2de5d7b6a5c42a9a5c96326b8454
patch link:
https://lore.kernel.org/r/47c26640cd85f3db2e0a2796047199bb984d1b3f.1719386613.git-series.apopple%40nvidia.com
patch subject: [PATCH 13/13] mm: Remove devmap related functions and page table 
bits
config: powerpc-allyesconfig 
(https://download.01.org/0day-ci/archive/20240628/202406280920.vnwstzzt-...@intel.com/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 
326ba38a991250a8587a399a260b0f7af2c9166a)
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20240628/202406280920.vnwstzzt-...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202406280920.vnwstzzt-...@intel.com/

All errors (new ones prefixed by >>):

   In file included from arch/powerpc/kernel/asm-offsets.c:12:
   In file included from include/linux/compat.h:14:
   In file included from include/linux/sem.h:5:
   In file included from include/uapi/linux/sem.h:5:
   In file included from include/linux/ipc.h:7:
   In file included from include/linux/rhashtable-types.h:12:
   In file included from include/linux/alloc_tag.h:11:
   In file included from include/linux/preempt.h:79:
   In file included from ./arch/powerpc/include/generated/asm/preempt.h:1:
   In file included from include/asm-generic/preempt.h:5:
   In file included from include/linux/thread_info.h:23:
   In file included from arch/powerpc/include/asm/current.h:13:
   In file included from arch/powerpc/include/asm/paca.h:18:
   In file included from arch/powerpc/include/asm/mmu.h:385:
   In file included from arch/powerpc/include/asm/book3s/64/mmu.h:32:
   In file included from arch/powerpc/include/asm/book3s/64/mmu-hash.h:20:
>> arch/powerpc/include/asm/book3s/64/pgtable.h:1371:1: error: extraneous 
>> closing brace ('}')
1371 | }
 | ^
   In file included from arch/powerpc/kernel/asm-offsets.c:12:
   In file included from include/linux/compat.h:17:
   In file included from include/linux/fs.h:33:
   In file included from include/linux/percpu-rwsem.h:7:
   In file included from include/linux/rcuwait.h:6:
   In file included from include/linux/sched/signal.h:6:
   include/linux/signal.h:98:11: warning: array index 3 is past the end of the 
array (that has type 'unsigned long[1]') [-Warray-bounds]
  98 | return (set->sig[3] | set->sig[2] |
 | ^~
   arch/powerpc/include/uapi/asm/signal.h:18:2: note: array 'sig' declared here
  18 | unsigned long sig[_NSIG_WORDS];
 | ^
   In file included from arch/powerpc/kernel/asm-offsets.c:12:
   In file included from include/linux/compat.h:17:
   In file included from include/linux/fs.h:33:
   In file included from include/linux/percpu-rwsem.h:7:
   In file included from include/linux/rcuwait.h:6:
   In file included from include/linux/sched/signal.h:6:
   include/linux/signal.h:98:25: warning: array index 2 is past the end of the 
array (that has type 'unsigned long[1]') [-Warray-bounds]
  98 | return (set->sig[3] | set->sig[2] |
 |   ^~
   arch/powerpc/include/uapi/asm/signal.h:18:2: note: array 'sig' declared here
  18 | unsigned long sig[_NSIG_WORDS];
 | ^
   In file included from arch/powerpc/kernel/asm-offsets.c:12:
   In file included from include/linux/compat.h:17:
   In file included from include/linux/fs.h:33:
   In file included from include/linux/percpu-rwsem.h:7:
   In file included from include/linux/rcuwait.h:6:
   In file included from include/linux/sched/signal.h:6:
   include/linux/signal.h:99:4: warning: array index 1 is past the end of the 
array (that has type 'unsigned long[1]') [-Warray-bounds]
  99 | set->sig[1] | set->sig[0]) == 0;
 | ^~
   arch/powerpc/include/uapi/asm/signal.h:18:2: note: array 'sig' declared here
  18 | unsigned long sig[_NSIG_WORDS];
 | ^
   In file included from arch/powerpc/kernel/asm-offsets.c:12:
   In file included from include/linux/compat.h:17:
   In file included from include/linux/fs.h:33:
   In file included from include/linux/percpu-rwsem.h:7:
   In file included from include/linux/rcuwait.h:6:
   In file included from include/linux/sched/signal.h:6:
   include/linux/signal.h:101:11: warning: array index 1 is past the end of the 
array (that has type 'unsigned long[1]') [-Warray-bounds]
 101 

Re: [PATCH] tpm: ibmvtpm: Call tpm2_sessions_init() to initialize session support

2024-06-27 Thread Michael Ellerman
Stefan Berger  writes:
> Fix the following type of error message caused by a missing call to
> tpm2_sessions_init() in the IBM vTPM driver:
>
> [2.987131] tpm tpm0: tpm2_load_context: failed with a TPM error 0x01C4
> [2.987140] ima: Error Communicating to TPM chip, result: -14
>
> Fixes: d2add27cf2b8 ("tpm: Add NULL primary creation")
> Signed-off-by: Stefan Berger 
> ---
>  drivers/char/tpm/tpm_ibmvtpm.c | 4 
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c
> index d3989b257f42..1e5b107d1f3b 100644
> --- a/drivers/char/tpm/tpm_ibmvtpm.c
> +++ b/drivers/char/tpm/tpm_ibmvtpm.c
> @@ -698,6 +698,10 @@ static int tpm_ibmvtpm_probe(struct vio_dev *vio_dev,
>   rc = tpm2_get_cc_attrs_tbl(chip);
>   if (rc)
>   goto init_irq_cleanup;
> +
> + rc = tpm2_sessions_init(chip);
> + if (rc)
> + goto init_irq_cleanup;
>   }
>  
>   return tpm_chip_register(chip);

#regzbot ^introduced: d2add27cf2b8 


Re: [PATCH 00/13] fs/dax: Fix FS DAX page reference counts

2024-06-27 Thread Alistair Popple


Dan Williams  writes:

> Alistair Popple wrote:
>> 
>> Dan Williams  writes:
>> 
>> > Alistair Popple wrote:
>> >> FS DAX pages have always maintained their own page reference counts
>> >> without following the normal rules for page reference counting. In
>> >> particular pages are considered free when the refcount hits one rather
>> >> than zero and refcounts are not added when mapping the page.
>> >> 
>> >> Tracking this requires special PTE bits (PTE_DEVMAP) and a secondary
>> >> mechanism for allowing GUP to hold references on the page (see
>> >> get_dev_pagemap). However there doesn't seem to be any reason why FS
>> >> DAX pages need their own reference counting scheme.
>> >> 
>> >> By treating the refcounts on these pages the same way as normal pages
>> >> we can remove a lot of special checks. In particular pXd_trans_huge()
>> >> becomes the same as pXd_leaf(), although I haven't made that change
>> >> here. It also frees up a valuable SW define PTE bit on architectures
>> >> that have devmap PTE bits defined.
>> >> 
>> >> It also almost certainly allows further clean-up of the devmap managed
>> >> functions, but I have left that as a future improvment.
>> >> 
>> >> This is an update to the original RFC rebased onto v6.10-rc5. Unlike
>> >> the original RFC it passes the same number of ndctl test suite
>> >> (https://github.com/pmem/ndctl) tests as my current development
>> >> environment does without these patches.
>> >
>> > Are you seeing the 'mmap.sh' test fail even without these patches?
>> 
>> No. But I also don't see it failing with these patches :)
>> 
>> For reference this is what I see on my test machine with or without:
>> 
>> [1/70] Generating version.h with a custom command
>>  1/13 ndctl:dax / daxdev-errors.sh  SKIP 0.06s   exit 
>> status 77
>>  2/13 ndctl:dax / multi-dax.sh  SKIP 0.05s   exit 
>> status 77
>>  3/13 ndctl:dax / sub-section.shSKIP 0.14s   exit 
>> status 77
>
> I really need to get this test built as a service as this shows a
> pre-req is missing, and it's not quite fair to expect submitters to put
> it all together.

Ok. I didn't dig into why this was being skipped but I might if I find
some time. The rest of the tests seemed more relevant anyway and turned
up enough bugs with my initial implementation to keep me busy which gave
me some confidence.

If I'm being honest though I found the whole test setup a bit of a
pain. In particular remembering you have to manually (re)build the
special test versions of the modules tripped me up a few times until I
updated my build scripts. But I got there in the end.

>>  4/13 ndctl:dax / dax-dev   OK   0.02s
>>  5/13 ndctl:dax / dax-ext4.sh   OK  12.97s
>>  6/13 ndctl:dax / dax-xfs.shOK  12.44s
>>  7/13 ndctl:dax / device-daxOK  13.40s
>>  8/13 ndctl:dax / revoke-devmem FAIL 0.31s   (exit 
>> status 250 or signal 122 SIGinvalid)
>> >>> TEST_PATH=/home/apopple/ndctl/build/test 
>> >>> LD_LIBRARY_PATH=/home/apopple/ndctl/build/cxl/lib:/home/apopple/ndctl/build/daxctl/lib:/home/apopple/ndctl/build/ndctl/lib
>> >>>  NDCTL=/home/apopple/ndctl/build/ndctl/ndctl MALLOC_PERTURB_=227 
>> >>> DATA_PATH=/home/apopple/ndctl/test 
>> >>> DAXCTL=/home/apopple/ndctl/build/daxctl/daxctl 
>> >>> /home/apopple/ndctl/build/test/revoke_devmem
>> 
>>  9/13 ndctl:dax / device-dax-fio.sh OK  32.43s
>> 10/13 ndctl:dax / daxctl-devices.sh SKIP 0.07s   exit 
>> status 77
>> 11/13 ndctl:dax / daxctl-create.sh  SKIP 0.04s   exit 
>> status 77
>> 12/13 ndctl:dax / dm.sh FAIL 0.08s   exit 
>> status 1
>> >>> MALLOC_PERTURB_=209 TEST_PATH=/home/apopple/ndctl/build/test 
>> >>> LD_LIBRARY_PATH=/home/apopple/ndctl/build/cxl/lib:/home/apopple/ndctl/build/daxctl/lib:/home/apopple/ndctl/build/ndctl/lib
>> >>>  NDCTL=/home/apopple/ndctl/build/ndctl/ndctl 
>> >>> DATA_PATH=/home/apopple/ndctl/test 
>> >>> DAXCTL=/home/apopple/ndctl/build/daxctl/daxctl 
>> >>> /home/apopple/ndctl/test/dm.sh
>> 
>> 13/13 ndctl:dax / mmap.sh   OK 107.57s
>
> I need to think through why this one might false succeed, but that can
> wait until we get this series reviewed. For now my failure is stable
> which allows it to be bisected.
>
>> 
>> Ok: 6   
>> Expected Fail:  0   
>> Fail:   2   
>> Unexpected Pass:0   
>> Skipped:5   
>> Timeout:0   
>> 
>> I have been using QEMU for my testing. Maybe I missed some condition in
>> the unmap path though so will take another look.
>
> I was able to bisect to:

I could have guessed that one, as it's pretty much the crux of this
series given it's the one that switches everything away from
pXX_devmap. That means pXX_leaf/_trans_huge will start returning true
for DAX pages.


Re: [PATCH 04/13] fs/dax: Add dax_page_free callback

2024-06-27 Thread Alistair Popple


Christoph Hellwig  writes:

> On Thu, Jun 27, 2024 at 10:54:19AM +1000, Alistair Popple wrote:
>> When a fs dax page is freed it has to notify filesystems that the page
>> has been unpinned/unmapped and is free. Currently this involves
>> special code in the page free paths to detect a transition of refcount
>> from 2 to 1 and to call some fs dax specific code.
>> 
>> A future change will require this to happen when the page refcount
>> drops to zero. In this case we can use the existing
>> pgmap->ops->page_free() callback so wire that up for all devices that
>> support FS DAX (nvdimm and virtio).
>
> Given that ->page_ffree is only called from free_zone_device_folio
> and right next to a switch on the the type, can't we just do the
> wake_up_var there without the somewhat confusing indirect call that
> just back in common code without any driver logic?

Longer term I'm hoping we can get rid of that switch on type entirely as
I don't think the whole get/put_dev_pagemap() thing is very useful. Less
indirection is good though so will move the wake_up_var there.


Re: [PATCH 13/13] mm: Remove devmap related functions and page table bits

2024-06-27 Thread kernel test robot
Hi Alistair,

kernel test robot noticed the following build errors:

[auto build test ERROR on f2661062f16b2de5d7b6a5c42a9a5c96326b8454]

url:
https://github.com/intel-lab-lkp/linux/commits/Alistair-Popple/mm-gup-c-Remove-redundant-check-for-PCI-P2PDMA-page/20240627-191709
base:   f2661062f16b2de5d7b6a5c42a9a5c96326b8454
patch link:
https://lore.kernel.org/r/47c26640cd85f3db2e0a2796047199bb984d1b3f.1719386613.git-series.apopple%40nvidia.com
patch subject: [PATCH 13/13] mm: Remove devmap related functions and page table 
bits
config: powerpc-allmodconfig 
(https://download.01.org/0day-ci/archive/20240628/202406280658.1pp5cw2f-...@intel.com/config)
compiler: powerpc64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20240628/202406280658.1pp5cw2f-...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202406280658.1pp5cw2f-...@intel.com/

All errors (new ones prefixed by >>):

   In file included from arch/powerpc/include/asm/book3s/64/mmu-hash.h:20,
from arch/powerpc/include/asm/book3s/64/mmu.h:32,
from arch/powerpc/include/asm/mmu.h:385,
from arch/powerpc/include/asm/paca.h:18,
from arch/powerpc/include/asm/current.h:13,
from include/linux/thread_info.h:23,
from include/asm-generic/preempt.h:5,
from ./arch/powerpc/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:79,
from include/linux/alloc_tag.h:11,
from include/linux/rhashtable-types.h:12,
from include/linux/ipc.h:7,
from include/uapi/linux/sem.h:5,
from include/linux/sem.h:5,
from include/linux/compat.h:14,
from arch/powerpc/kernel/asm-offsets.c:12:
>> arch/powerpc/include/asm/book3s/64/pgtable.h:1371:1: error: expected 
>> identifier or '(' before '}' token
1371 | }
 | ^
   make[3]: *** [scripts/Makefile.build:117: arch/powerpc/kernel/asm-offsets.s] 
Error 1
   make[3]: Target 'prepare' not remade because of errors.
   make[2]: *** [Makefile:1208: prepare0] Error 2
   make[2]: Target 'prepare' not remade because of errors.
   make[1]: *** [Makefile:240: __sub-make] Error 2
   make[1]: Target 'prepare' not remade because of errors.
   make: *** [Makefile:240: __sub-make] Error 2
   make: Target 'prepare' not remade because of errors.


vim +1371 arch/powerpc/include/asm/book3s/64/pgtable.h

953c66c2b22a30 Aneesh Kumar K.V  2016-12-12  1370  
ebd31197931d75 Oliver O'Halloran 2017-06-28 @1371  }
6a1ea36260f69f Aneesh Kumar K.V  2016-04-29  1372  #endif /* 
CONFIG_TRANSPARENT_HUGEPAGE */
ebd31197931d75 Oliver O'Halloran 2017-06-28  1373  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


Re: [PATCH 07/13] huge_memory: Allow mappings of PUD sized pages

2024-06-27 Thread kernel test robot
Hi Alistair,

kernel test robot noticed the following build errors:

[auto build test ERROR on f2661062f16b2de5d7b6a5c42a9a5c96326b8454]

url:
https://github.com/intel-lab-lkp/linux/commits/Alistair-Popple/mm-gup-c-Remove-redundant-check-for-PCI-P2PDMA-page/20240627-191709
base:   f2661062f16b2de5d7b6a5c42a9a5c96326b8454
patch link:
https://lore.kernel.org/r/bd332b0d3971b03152b3541f97470817c5147b51.1719386613.git-series.apopple%40nvidia.com
patch subject: [PATCH 07/13] huge_memory: Allow mappings of PUD sized pages
config: x86_64-allnoconfig 
(https://download.01.org/0day-ci/archive/20240628/202406280637.147dyrrv-...@intel.com/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 
617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20240628/202406280637.147dyrrv-...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202406280637.147dyrrv-...@intel.com/

All errors (new ones prefixed by >>):

>> mm/rmap.c:1513:37: error: call to '__compiletime_assert_279' declared with 
>> 'error' attribute: BUILD_BUG failed
1513 | __folio_add_file_rmap(folio, page, HPAGE_PUD_NR, vma, 
RMAP_LEVEL_PUD);
 |^
   include/linux/huge_mm.h:111:26: note: expanded from macro 'HPAGE_PUD_NR'
 111 | #define HPAGE_PUD_NR (1<:72:1: note: expanded from here
  72 | __compiletime_assert_279
 | ^
   mm/rmap.c:1660:35: error: call to '__compiletime_assert_280' declared with 
'error' attribute: BUILD_BUG failed
1660 | __folio_remove_rmap(folio, page, HPAGE_PUD_NR, vma, 
RMAP_LEVEL_PUD);
 |  ^
   include/linux/huge_mm.h:111:26: note: expanded from macro 'HPAGE_PUD_NR'
 111 | #define HPAGE_PUD_NR (1<:79:1: note: expanded from here
  79 | __compiletime_assert_280
 | ^
   2 errors generated.


vim +1513 mm/rmap.c

  1498  
  1499  /**
  1500   * folio_add_file_rmap_pud - add a PUD mapping to a page range of a 
folio
  1501   * @folio:  The folio to add the mapping to
  1502   * @page:   The first page to add
  1503   * @vma:The vm area in which the mapping is added
  1504   *
  1505   * The page range of the folio is defined by [page, page + HPAGE_PUD_NR)
  1506   *
  1507   * The caller needs to hold the page table lock.
  1508   */
  1509  void folio_add_file_rmap_pud(struct folio *folio, struct page *page,
  1510  struct vm_area_struct *vma)
  1511  {
  1512  #ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD
> 1513  __folio_add_file_rmap(folio, page, HPAGE_PUD_NR, vma, 
> RMAP_LEVEL_PUD);
  1514  #else
  1515  WARN_ON_ONCE(true);
  1516  #endif
  1517  }
  1518  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


Re: [PATCH 09/10] dt-bindings: sound: fsl,qmc-audio: Add support for multiple QMC channels per DAI

2024-06-27 Thread Rob Herring (Arm)


On Thu, 20 Jun 2024 10:42:56 +0200, Herve Codina wrote:
> The QMC audio uses one QMC channel per DAI and uses this QMC channel to
> transmit interleaved audio channel samples.
> 
> In order to work in non-interleave mode, a QMC audio DAI needs to use
> multiple QMC channels. In that case, the DAI maps each QMC channel to
> exactly one audio channel.
> 
> Allow QMC audio DAIs with multiple QMC channels attached.
> 
> Signed-off-by: Herve Codina 
> ---
>  .../bindings/sound/fsl,qmc-audio.yaml | 41 ---
>  1 file changed, 35 insertions(+), 6 deletions(-)
> 

Reviewed-by: Rob Herring (Arm) 



Re: [PATCH 00/13] fs/dax: Fix FS DAX page reference counts

2024-06-27 Thread Dan Williams
Alistair Popple wrote:
> 
> Dan Williams  writes:
> 
> > Alistair Popple wrote:
> >> FS DAX pages have always maintained their own page reference counts
> >> without following the normal rules for page reference counting. In
> >> particular pages are considered free when the refcount hits one rather
> >> than zero and refcounts are not added when mapping the page.
> >> 
> >> Tracking this requires special PTE bits (PTE_DEVMAP) and a secondary
> >> mechanism for allowing GUP to hold references on the page (see
> >> get_dev_pagemap). However there doesn't seem to be any reason why FS
> >> DAX pages need their own reference counting scheme.
> >> 
> >> By treating the refcounts on these pages the same way as normal pages
> >> we can remove a lot of special checks. In particular pXd_trans_huge()
> >> becomes the same as pXd_leaf(), although I haven't made that change
> >> here. It also frees up a valuable SW define PTE bit on architectures
> >> that have devmap PTE bits defined.
> >> 
> >> It also almost certainly allows further clean-up of the devmap managed
> >> functions, but I have left that as a future improvment.
> >> 
> >> This is an update to the original RFC rebased onto v6.10-rc5. Unlike
> >> the original RFC it passes the same number of ndctl test suite
> >> (https://github.com/pmem/ndctl) tests as my current development
> >> environment does without these patches.
> >
> > Are you seeing the 'mmap.sh' test fail even without these patches?
> 
> No. But I also don't see it failing with these patches :)
> 
> For reference this is what I see on my test machine with or without:
> 
> [1/70] Generating version.h with a custom command
>  1/13 ndctl:dax / daxdev-errors.sh  SKIP 0.06s   exit 
> status 77
>  2/13 ndctl:dax / multi-dax.sh  SKIP 0.05s   exit 
> status 77
>  3/13 ndctl:dax / sub-section.shSKIP 0.14s   exit 
> status 77

I really need to get this test built as a service as this shows a
pre-req is missing, and it's not quite fair to expect submitters to put
it all together.

>  4/13 ndctl:dax / dax-dev   OK   0.02s
>  5/13 ndctl:dax / dax-ext4.sh   OK  12.97s
>  6/13 ndctl:dax / dax-xfs.shOK  12.44s
>  7/13 ndctl:dax / device-daxOK  13.40s
>  8/13 ndctl:dax / revoke-devmem FAIL 0.31s   (exit 
> status 250 or signal 122 SIGinvalid)
> >>> TEST_PATH=/home/apopple/ndctl/build/test 
> >>> LD_LIBRARY_PATH=/home/apopple/ndctl/build/cxl/lib:/home/apopple/ndctl/build/daxctl/lib:/home/apopple/ndctl/build/ndctl/lib
> >>>  NDCTL=/home/apopple/ndctl/build/ndctl/ndctl MALLOC_PERTURB_=227 
> >>> DATA_PATH=/home/apopple/ndctl/test 
> >>> DAXCTL=/home/apopple/ndctl/build/daxctl/daxctl 
> >>> /home/apopple/ndctl/build/test/revoke_devmem
> 
>  9/13 ndctl:dax / device-dax-fio.sh OK  32.43s
> 10/13 ndctl:dax / daxctl-devices.sh SKIP 0.07s   exit 
> status 77
> 11/13 ndctl:dax / daxctl-create.sh  SKIP 0.04s   exit 
> status 77
> 12/13 ndctl:dax / dm.sh FAIL 0.08s   exit 
> status 1
> >>> MALLOC_PERTURB_=209 TEST_PATH=/home/apopple/ndctl/build/test 
> >>> LD_LIBRARY_PATH=/home/apopple/ndctl/build/cxl/lib:/home/apopple/ndctl/build/daxctl/lib:/home/apopple/ndctl/build/ndctl/lib
> >>>  NDCTL=/home/apopple/ndctl/build/ndctl/ndctl 
> >>> DATA_PATH=/home/apopple/ndctl/test 
> >>> DAXCTL=/home/apopple/ndctl/build/daxctl/daxctl 
> >>> /home/apopple/ndctl/test/dm.sh
> 
> 13/13 ndctl:dax / mmap.sh   OK 107.57s

I need to think through why this one might false succeed, but that can
wait until we get this series reviewed. For now my failure is stable
which allows it to be bisected.

> 
> Ok: 6   
> Expected Fail:  0   
> Fail:   2   
> Unexpected Pass:0   
> Skipped:5   
> Timeout:0   
> 
> I have been using QEMU for my testing. Maybe I missed some condition in
> the unmap path though so will take another look.

I was able to bisect to:

[PATCH 10/13] fs/dax: Properly refcount fs dax pages

...I will prioritize that one in my review queue.


Re: [PATCH 1/4] soc: fsl: qbman: FSL_DPAA depends on COMPILE_TEST

2024-06-27 Thread Breno Leitao
Hello Vladimir,

On Wed, Jun 26, 2024 at 05:06:23PM +0300, Vladimir Oltean wrote:
> On Wed, Jun 26, 2024 at 08:09:53PM +0800, kernel test robot wrote:

> > All warnings (new ones prefixed by >>):
> > 
> > >> drivers/net/ethernet/freescale/dpaa/dpaa_eth.c:3280:12: warning: stack 
> > >> frame size (16664) exceeds limit (2048) in 'dpaa_eth_probe' 
> > >> [-Wframe-larger-than]
> > 3280 | static int dpaa_eth_probe(struct platform_device *pdev)
> >  |^
> >1 warning generated.
> > --
> > >> drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c:454:12: warning: 
> > >> stack frame size (8264) exceeds limit (2048) in 'dpaa_set_coalesce' 
> > >> [-Wframe-larger-than]
> >  454 | static int dpaa_set_coalesce(struct net_device *dev,
> >  |^
> >1 warning generated.
> 
> Arrays of NR_CPUS elements are what it probably doesn't like?

Can it use the number of online CPUs instead of NR_CPUS?

Other than that, I would say we can drop this patch in the meantime, so,
we can move with the others, while this one is being addressed.


[RFC PATCH 2/2] arch/powerpc/kvm: Fix doorbells for nested KVM guests on PowerNV

2024-06-27 Thread Gautam Menghani
commit 6398326b9ba1("KVM: PPC: Book3S HV P9: Stop using vc->dpdes")
introduced an optimization to use only vcpu->doorbell_request for SMT
emulation for Power9 and above guests, but the code for nested guests 
still relies on the old way of handling doorbells, due to which an L2
guest cannot be booted with XICS with SMT>1. The command to repro
this issue is:

qemu-system-ppc64 \
-drive file=rhel.qcow2,format=qcow2 \
-m 20G \
-smp 8,cores=1,threads=8 \
-cpu  host \
-nographic \
-machine pseries,ic-mode=xics -accel kvm

Fix the plumbing to utilize vcpu->doorbell_request instead of vcore->dpdes 
on P9 and above.

Fixes: 6398326b9ba1 ("KVM: PPC: Book3S HV P9: Stop using vc->dpdes")
Signed-off-by: Gautam Menghani 
---
 arch/powerpc/kvm/book3s_hv.c|  9 -
 arch/powerpc/kvm/book3s_hv_nested.c | 20 
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index cea28ac05923..0586fa636707 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -4178,6 +4178,9 @@ static int kvmhv_vcpu_entry_p9_nested(struct kvm_vcpu 
*vcpu, u64 time_limit, uns
}
hvregs.hdec_expiry = time_limit;
 
+   // clear doorbell bit as hvregs already has the info
+   vcpu->arch.doorbell_request = 0;
+
/*
 * When setting DEC, we must always deal with irq_work_raise
 * via NMI vs setting DEC. The problem occurs right as we
@@ -4694,6 +4697,7 @@ int kvmhv_run_single_vcpu(struct kvm_vcpu *vcpu, u64 
time_limit,
struct kvm_nested_guest *nested = vcpu->arch.nested;
unsigned long flags;
u64 tb;
+   bool doorbell_pending;
 
trace_kvmppc_run_vcpu_enter(vcpu);
 
@@ -4752,6 +4756,9 @@ int kvmhv_run_single_vcpu(struct kvm_vcpu *vcpu, u64 
time_limit,
 */
smp_mb();
 
+   doorbell_pending = !cpu_has_feature(CPU_FTR_ARCH_300) &&
+   vcpu->arch.doorbell_request;
+
if (!nested) {
kvmppc_core_prepare_to_enter(vcpu);
if (test_bit(BOOK3S_IRQPRIO_EXTERNAL,
@@ -4769,7 +4776,7 @@ int kvmhv_run_single_vcpu(struct kvm_vcpu *vcpu, u64 
time_limit,
lpcr |= LPCR_MER;
}
} else if (vcpu->arch.pending_exceptions ||
-  vcpu->arch.doorbell_request ||
+  doorbell_pending ||
   xive_interrupt_pending(vcpu)) {
vcpu->arch.ret = RESUME_HOST;
goto out;
diff --git a/arch/powerpc/kvm/book3s_hv_nested.c 
b/arch/powerpc/kvm/book3s_hv_nested.c
index 05f5220960c6..b34eefa6b268 100644
--- a/arch/powerpc/kvm/book3s_hv_nested.c
+++ b/arch/powerpc/kvm/book3s_hv_nested.c
@@ -32,7 +32,10 @@ void kvmhv_save_hv_regs(struct kvm_vcpu *vcpu, struct 
hv_guest_state *hr)
struct kvmppc_vcore *vc = vcpu->arch.vcore;
 
hr->pcr = vc->pcr | PCR_MASK;
-   hr->dpdes = vc->dpdes;
+   if (cpu_has_feature(CPU_FTR_ARCH_300))
+   hr->dpdes = vcpu->arch.doorbell_request;
+   else
+   hr->dpdes = vc->dpdes;
hr->hfscr = vcpu->arch.hfscr;
hr->tb_offset = vc->tb_offset;
hr->dawr0 = vcpu->arch.dawr0;
@@ -105,7 +108,10 @@ static void save_hv_return_state(struct kvm_vcpu *vcpu,
 {
struct kvmppc_vcore *vc = vcpu->arch.vcore;
 
-   hr->dpdes = vc->dpdes;
+   if (cpu_has_feature(CPU_FTR_ARCH_300))
+   hr->dpdes = vcpu->arch.doorbell_request;
+   else
+   hr->dpdes = vc->dpdes;
hr->purr = vcpu->arch.purr;
hr->spurr = vcpu->arch.spurr;
hr->ic = vcpu->arch.ic;
@@ -143,7 +149,10 @@ static void restore_hv_regs(struct kvm_vcpu *vcpu, const 
struct hv_guest_state *
struct kvmppc_vcore *vc = vcpu->arch.vcore;
 
vc->pcr = hr->pcr | PCR_MASK;
-   vc->dpdes = hr->dpdes;
+   if (cpu_has_feature(CPU_FTR_ARCH_300))
+   vcpu->arch.doorbell_request = hr->dpdes;
+   else
+   vc->dpdes = hr->dpdes;
vcpu->arch.hfscr = hr->hfscr;
vcpu->arch.dawr0 = hr->dawr0;
vcpu->arch.dawrx0 = hr->dawrx0;
@@ -170,7 +179,10 @@ void kvmhv_restore_hv_return_state(struct kvm_vcpu *vcpu,
 {
struct kvmppc_vcore *vc = vcpu->arch.vcore;
 
-   vc->dpdes = hr->dpdes;
+   if (cpu_has_feature(CPU_FTR_ARCH_300) && !vcpu->arch.doorbell_request)
+   vcpu->arch.doorbell_request = hr->dpdes;
+   else
+   vc->dpdes = hr->dpdes;
vcpu->arch.hfscr = hr->hfscr;
vcpu->arch.purr = hr->purr;
vcpu->arch.spurr = hr->spurr;
-- 
2.45.1



[RFC PATCH 1/2] Revert "KVM: PPC: Book3S HV Nested: Stop forwarding all HFUs to L1"

2024-06-27 Thread Gautam Menghani
This reverts commit 7c3ded5735141ff4d049747c9f76672a8b737c49.

On PowerNV, when a nested guest tries to use a feature prohibited by
HFSCR, the nested hypervisor (L1) should get a H_FAC_UNAVAILABLE trap
and then L1 can emulate the feature. But with the change introduced by
commit 7c3ded573514 ("KVM: PPC: Book3S HV Nested: Stop forwarding all HFUs to 
L1")
the L1 ends up getting a H_EMUL_ASSIST because of which, the L1 ends up
injecting a SIGILL when L2 (nested guest) tries to use doorbells.

Signed-off-by: Gautam Menghani 
---
 arch/powerpc/kvm/book3s_hv.c | 31 ++-
 1 file changed, 2 insertions(+), 29 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index daaf7faf21a5..cea28ac05923 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -2052,36 +2052,9 @@ static int kvmppc_handle_nested_exit(struct kvm_vcpu 
*vcpu)
fallthrough; /* go to facility unavailable handler */
 #endif
 
-   case BOOK3S_INTERRUPT_H_FAC_UNAVAIL: {
-   u64 cause = vcpu->arch.hfscr >> 56;
-
-   /*
-* Only pass HFU interrupts to the L1 if the facility is
-* permitted but disabled by the L1's HFSCR, otherwise
-* the interrupt does not make sense to the L1 so turn
-* it into a HEAI.
-*/
-   if (!(vcpu->arch.hfscr_permitted & (1UL << cause)) ||
-   (vcpu->arch.nested_hfscr & (1UL << cause))) {
-   ppc_inst_t pinst;
-   vcpu->arch.trap = BOOK3S_INTERRUPT_H_EMUL_ASSIST;
-
-   /*
-* If the fetch failed, return to guest and
-* try executing it again.
-*/
-   r = kvmppc_get_last_inst(vcpu, INST_GENERIC, );
-   vcpu->arch.emul_inst = ppc_inst_val(pinst);
-   if (r != EMULATE_DONE)
-   r = RESUME_GUEST;
-   else
-   r = RESUME_HOST;
-   } else {
-   r = RESUME_HOST;
-   }
-
+   case BOOK3S_INTERRUPT_H_FAC_UNAVAIL:
+   r = RESUME_HOST;
break;
-   }
 
case BOOK3S_INTERRUPT_HV_RM_HARD:
vcpu->arch.trap = 0;
-- 
2.45.1



[RFC PATCH 0/2] Fix doorbell emulation for nested KVM guests in V1 API

2024-06-27 Thread Gautam Menghani
Doorbell emulation for nested KVM guests in V1 API is broken because of
2 reasons:
1. L0 presenting H_EMUL_ASSIST to L1 instead of H_FAC_UNAVAIL
2. Broken plumbing for passing around doorbell state.

Fix the trap passed to L1 and the plumbing for maintaining doorbell
state.

Gautam Menghani (2):
  Revert "KVM: PPC: Book3S HV Nested: Stop forwarding all HFUs to L1"
  arch/powerpc/kvm: Fix doorbells for nested KVM guests on PowerNV

 arch/powerpc/kvm/book3s_hv.c| 40 -
 arch/powerpc/kvm/book3s_hv_nested.c | 20 ---
 2 files changed, 26 insertions(+), 34 deletions(-)

-- 
2.45.1



[PATCH RESEND v6 13/18] EDAC/mc: Re-use generic unique MC index allocation procedure

2024-06-27 Thread Serge Semin
The EDAC drivers locally maintaining a statically defined
memory-controllers counter don't care much about the MC index assigned as
long as it's unique so the EDAC core perceives it. Convert these drivers
to be using the generic MC index allocation procedure recently added to
the EDAC core.

Signed-off-by: Serge Semin 

---

Changelog v4:
- Initial patch introduction.
---
 drivers/edac/dmc520_edac.c | 4 +---
 drivers/edac/pasemi_edac.c | 5 +
 drivers/edac/ppc4xx_edac.c | 5 +
 3 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/edac/dmc520_edac.c b/drivers/edac/dmc520_edac.c
index 4e30b989a1a4..93734a97a67b 100644
--- a/drivers/edac/dmc520_edac.c
+++ b/drivers/edac/dmc520_edac.c
@@ -173,8 +173,6 @@ struct dmc520_edac {
int masks[NUMBER_OF_IRQS];
 };
 
-static int dmc520_mc_idx;
-
 static u32 dmc520_read_reg(struct dmc520_edac *pvt, u32 offset)
 {
return readl(pvt->reg_base + offset);
@@ -517,7 +515,7 @@ static int dmc520_edac_probe(struct platform_device *pdev)
layers[0].size = dmc520_get_rank_count(reg_base);
layers[0].is_virt_csrow = true;
 
-   mci = edac_mc_alloc(dmc520_mc_idx++, ARRAY_SIZE(layers), layers, 
sizeof(*pvt));
+   mci = edac_mc_alloc(EDAC_AUTO_MC_NUM, ARRAY_SIZE(layers), layers, 
sizeof(*pvt));
if (!mci) {
edac_printk(KERN_ERR, EDAC_MOD_NAME,
"Failed to allocate memory for mc instance\n");
diff --git a/drivers/edac/pasemi_edac.c b/drivers/edac/pasemi_edac.c
index 1a1c3296ccc8..afebfbda1ea0 100644
--- a/drivers/edac/pasemi_edac.c
+++ b/drivers/edac/pasemi_edac.c
@@ -57,8 +57,6 @@
 #define PASEMI_EDAC_ERROR_GRAIN64
 
 static int last_page_in_mmc;
-static int system_mmc_id;
-
 
 static u32 pasemi_edac_get_error_info(struct mem_ctl_info *mci)
 {
@@ -203,8 +201,7 @@ static int pasemi_edac_probe(struct pci_dev *pdev,
layers[1].type = EDAC_MC_LAYER_CHANNEL;
layers[1].size = PASEMI_EDAC_NR_CHANS;
layers[1].is_virt_csrow = false;
-   mci = edac_mc_alloc(system_mmc_id++, ARRAY_SIZE(layers), layers,
-   0);
+   mci = edac_mc_alloc(EDAC_AUTO_MC_NUM, ARRAY_SIZE(layers), layers, 0);
if (mci == NULL)
return -ENOMEM;
 
diff --git a/drivers/edac/ppc4xx_edac.c b/drivers/edac/ppc4xx_edac.c
index 1eea3341a916..06d267d40a6a 100644
--- a/drivers/edac/ppc4xx_edac.c
+++ b/drivers/edac/ppc4xx_edac.c
@@ -1214,7 +1214,6 @@ static int ppc4xx_edac_probe(struct platform_device *op)
const struct device_node *np = op->dev.of_node;
struct mem_ctl_info *mci = NULL;
struct edac_mc_layer layers[2];
-   static int ppc4xx_edac_instance;
 
/*
 * At this point, we only support the controller realized on
@@ -1265,7 +1264,7 @@ static int ppc4xx_edac_probe(struct platform_device *op)
layers[1].type = EDAC_MC_LAYER_CHANNEL;
layers[1].size = ppc4xx_edac_nr_chans;
layers[1].is_virt_csrow = false;
-   mci = edac_mc_alloc(ppc4xx_edac_instance, ARRAY_SIZE(layers), layers,
+   mci = edac_mc_alloc(EDAC_AUTO_MC_NUM, ARRAY_SIZE(layers), layers,
sizeof(struct ppc4xx_edac_pdata));
if (mci == NULL) {
ppc4xx_edac_printk(KERN_ERR, "%pOF: "
@@ -1303,8 +1302,6 @@ static int ppc4xx_edac_probe(struct platform_device *op)
goto fail1;
}
 
-   ppc4xx_edac_instance++;
-
return 0;
 
  fail1:
-- 
2.43.0



Re: [PATCH] Perf: Calling available function for stats printing

2024-06-27 Thread Ian Rogers
On Thu, Jun 27, 2024 at 6:37 AM Abhishek Dubey  wrote:
>
> For printing dump_trace, just use existing stats_print()
> function.
>
> Signed-off-by: Abhishek Dubey 

Thanks Abishek, the change looks good but it needs to be rebased on
top of Commit 411ee13598ef ("perf hist: Add symbol_conf.skip_empty") -
https://lore.kernel.org/r/20240607202918.2357459-4-namhy...@kernel.org
. Recently Howard Chu wrote a guide on this:
https://sberm.cn/blog/how-to-contrib-perf

Another small issue is the commit message should be "perf report: ..."
rather than "Perf: ...".

Thanks,
Ian


Re: [PATCH 1/2] pci/hotplug/pnv_php: Fix hotplug driver crash on Powernv

2024-06-27 Thread Shawn Anastasio
Hi Krishna,

On 5/9/24 7:05 AM, Krishna Kumar wrote:
> Description of the problem: The hotplug driver for powerpc
> (pci/hotplug/pnv_php.c) gives kernel crash when we try to
> hot-unplug/disable the PCIe switch/bridge from the PHB.
> 
> 
> Root Cause of Crash: The crash is due to the reason that, though the msi
> data structure has been released during disable/hot-unplug path and it
> has been assigned with NULL, still during unregistartion the code was
> again trying to explicitly disable the msi which causes the Null pointer
> dereference and kernel crash.
> 
> 
> Proposed Fix : The fix is to correct the check during unregistration path
> so that the code should not  try to invoke pci_disable_msi/msix() if its
> data structure is already freed.
> 
> 
> Signed-off-by: Krishna Kumar 

I've tested this on a POWER9 box and can confirm that it fixes the panics
when hotplugging PCIe bridges.

Tested-by: Shawn Anastasio 

Thanks,
Shawn


Re: [PATCH v3 2/2] powerpc: hotplug driver bridge support

2024-06-27 Thread Shawn Anastasio
Hi Krishna,

On 6/24/24 7:09 AM, Krishna Kumar wrote:
> There is an issue with the hotplug operation when it's done on the
> bridge/switch slot. The bridge-port and devices behind the bridge, which
> become offline by hot-unplug operation, don't get hot-plugged/enabled by
> doing hot-plug operation on that slot. Only the first port of the bridge
> gets enabled and the remaining port/devices remain unplugged. The hot
> plug/unplug operation is done by the hotplug driver
> (drivers/pci/hotplug/pnv_php.c).
> 
> Root Cause Analysis: This behavior is due to missing code for the
> switch/bridge. The existing driver depends on pci_hp_add_devices()
> function for device enablement. This function calls pci_scan_slot() on
> only one device-node/port of the bridge, not on all the siblings'
> device-node/port.
> 
> The missing code needs to be added which will find all the sibling
> device-nodes/bridge-ports and will run explicit pci_scan_slot() on
> those.  A new function has been added for this purpose which gets
> invoked from pci_hp_add_devices(). This new function
> pci_traverse_sibling_nodes_and_scan_slot() gets all the sibling
> bridge-ports by traversal and explicitly invokes pci_scan_slot on them.
> 
> Cc: Michael Ellerman 
> Cc: Nicholas Piggin 
> Cc: Christophe Leroy 
> Cc: "Aneesh Kumar K.V" 
> Cc: Bjorn Helgaas 
> Cc: Gaurav Batra 
> Cc: Nathan Lynch 
> Cc: Brian King 
> 
> Signed-off-by: Krishna Kumar 

Other than the case with NVMe devices failing that we discussed in v1's
thread, I can confirm that this patch resolves many of the issues we've
encountered with PCIe hotplug on POWER9.

Tested-by: Shawn Anastasio 

Thanks,
Shawn


Re: [PATCH v3 1/2] pci/hotplug/pnv_php: Fix hotplug driver crash on Powernv

2024-06-27 Thread Shawn Anastasio
Hi Krishna,

On 6/24/24 7:09 AM, Krishna Kumar wrote:
> Description of the problem: The hotplug driver for powerpc
> (pci/hotplug/pnv_php.c) gives kernel crash when we try to
> hot-unplug/disable the PCIe switch/bridge from the PHB.
> 
> Root Cause of Crash: The crash is due to the reason that, though the msi
> data structure has been released during disable/hot-unplug path and it
> has been assigned with NULL, still during unregistartion the code was
> again trying to explicitly disable the msi which causes the Null pointer
> dereference and kernel crash.
> 
> Proposed Fix : The fix is to correct the check during unregistration path
> so that the code should not  try to invoke pci_disable_msi/msix() if its
> data structure is already freed.
> 
> Cc: Michael Ellerman 
> Cc: Nicholas Piggin 
> Cc: Christophe Leroy 
> Cc: "Aneesh Kumar K.V" 
> Cc: Bjorn Helgaas 
> Cc: Gaurav Batra 
> Cc: Nathan Lynch 
> Cc: Brian King 
> 
> Signed-off-by: Krishna Kumar 

As with v1, I can confirm that this patch solves the panic encountered
when hotplugging PCIe bridges on POWER9.

Tested-by: Shawn Anastasio 

Thanks,
Shawn


[Patch v5 12/12] i2x: pnx: Fix potential deadlock warning from del_timer_sync() call in isr

2024-06-27 Thread Piotr Wojtaszczyk
When del_timer_sync() is called in an interrupt context it throws a warning
because of potential deadlock. The timer is used only to exit from
wait_for_completion() after a timeout so replacing the call with
wait_for_completion_timeout() allows to remove the problematic timer and
its related functions altogether.

Signed-off-by: Piotr Wojtaszczyk 
---
Changes for v5:
- Replaced wait_for_completion() with wait_for_completion_timeout().
- Removed unneded "alg_data->mif.timer" and its functions
- Request irq with devm_request_irq() as before the patch
- Renamed the patch and reword description for the new way to fix
  the warning

Changes for v4:
- Request irq with devm_request_threaded_irq() to prevent the warning

 drivers/i2c/busses/i2c-pnx.c | 48 
 1 file changed, 10 insertions(+), 38 deletions(-)

diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index a12525b3186b..f448505d5468 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -15,7 +15,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -32,7 +31,6 @@ struct i2c_pnx_mif {
int ret;/* Return value */
int mode;   /* Interface mode */
struct completion   complete;   /* I/O completion */
-   struct timer_list   timer;  /* Timeout */
u8 *buf;/* Data buffer */
int len;/* Length of data buffer */
int order;  /* RX Bytes to order via TX */
@@ -117,24 +115,6 @@ static inline int wait_reset(struct i2c_pnx_algo_data 
*data)
return (timeout <= 0);
 }
 
-static inline void i2c_pnx_arm_timer(struct i2c_pnx_algo_data *alg_data)
-{
-   struct timer_list *timer = _data->mif.timer;
-   unsigned long expires = msecs_to_jiffies(alg_data->timeout);
-
-   if (expires <= 1)
-   expires = 2;
-
-   del_timer_sync(timer);
-
-   dev_dbg(_data->adapter.dev, "Timer armed at %lu plus %lu 
jiffies.\n",
-   jiffies, expires);
-
-   timer->expires = jiffies + expires;
-
-   add_timer(timer);
-}
-
 /**
  * i2c_pnx_start - start a device
  * @slave_addr:slave address
@@ -259,8 +239,6 @@ static int i2c_pnx_master_xmit(struct i2c_pnx_algo_data 
*alg_data)
~(mcntrl_afie | mcntrl_naie | mcntrl_drmie),
  I2C_REG_CTL(alg_data));
 
-   del_timer_sync(_data->mif.timer);
-
dev_dbg(_data->adapter.dev,
"%s(): Waking up xfer routine.\n",
__func__);
@@ -276,8 +254,6 @@ static int i2c_pnx_master_xmit(struct i2c_pnx_algo_data 
*alg_data)
~(mcntrl_afie | mcntrl_naie | mcntrl_drmie),
  I2C_REG_CTL(alg_data));
 
-   /* Stop timer. */
-   del_timer_sync(_data->mif.timer);
dev_dbg(_data->adapter.dev,
"%s(): Waking up xfer routine after zero-xfer.\n",
__func__);
@@ -364,8 +340,6 @@ static int i2c_pnx_master_rcv(struct i2c_pnx_algo_data 
*alg_data)
 mcntrl_drmie | mcntrl_daie);
iowrite32(ctl, I2C_REG_CTL(alg_data));
 
-   /* Kill timer. */
-   del_timer_sync(_data->mif.timer);
complete(_data->mif.complete);
}
}
@@ -400,8 +374,6 @@ static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id)
 mcntrl_drmie);
iowrite32(ctl, I2C_REG_CTL(alg_data));
 
-   /* Stop timer, to prevent timeout. */
-   del_timer_sync(_data->mif.timer);
complete(_data->mif.complete);
} else if (stat & mstatus_nai) {
/* Slave did not acknowledge, generate a STOP */
@@ -419,8 +391,6 @@ static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id)
/* Our return value. */
alg_data->mif.ret = -EIO;
 
-   /* Stop timer, to prevent timeout. */
-   del_timer_sync(_data->mif.timer);
complete(_data->mif.complete);
} else {
/*
@@ -453,9 +423,8 @@ static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
 }
 
-static void i2c_pnx_timeout(struct timer_list *t)
+static void i2c_pnx_timeout(struct i2c_pnx_algo_data *alg_data)
 {
-   struct i2c_pnx_algo_data *alg_data = from_timer(alg_data, t, mif.timer);
u32 ctl;
 
dev_err(_data->adapter.dev,
@@ -472,7 +441,6 @@ static void i2c_pnx_timeout(struct timer_list *t)
iowrite32(ctl, I2C_REG_CTL(alg_data));
wait_reset(alg_data);
alg_data->mif.ret = -EIO;
-   

[Patch v5 11/12] ASoC: fsl: Add i2s and pcm drivers for LPC32xx CPUs

2024-06-27 Thread Piotr Wojtaszczyk
This driver was ported from an old version in linux 2.6.27 and adjusted
for the new ASoC framework and DMA API.

Signed-off-by: Piotr Wojtaszczyk 
---
Changes for v5:
- Removed "N:" from the MAINTAINERS entry
- Removed unused filter_data and flags variables

Changes for v4:
- Add to MAINTAINERS
- Use guard(mutex)(_info_p->lock) when possible
- Request dma chennels using DT entries in devm_snd_dmaengine_pcm_register

Changes for v3:
- Split previous commit for separate subsystems
- Add support and  as a maintainer for the driver
- Replaced `SND_SOC` config dependency with COMPILE_TEST
- Moved `snd-soc-fsl-lpc3xxx-y` in Makefile up in the list to maintain 
alfabedical order
- Changed comment to c++ format
- replaced custom absd32() with standard abs() function
- Added clock provider check in lpc3xxx_i2s_set_dai_fmt()
- Removed empty lpc32xx_i2s_remove() function
- Reworked i2s regs definitions to include LPC3XXX prefix
- Replaced custom _BIT, _SBD with standard BIT and FIELD_PREP macros

Changes for v2:
- Coding Style cleanup
- Use dev_err_probe() for error handling in probe function
- Removed unneded err_clk_disable label
- Removed empty function
- Droped of_match_ptr in lpc32xx_i2s_match DT match table
- ASoC struct adjustmes for the latest 6.10-rc3 kernel

 MAINTAINERS |   1 +
 sound/soc/fsl/Kconfig   |   7 +
 sound/soc/fsl/Makefile  |   2 +
 sound/soc/fsl/lpc3xxx-i2s.c | 375 
 sound/soc/fsl/lpc3xxx-i2s.h |  79 
 sound/soc/fsl/lpc3xxx-pcm.c |  72 +++
 6 files changed, 536 insertions(+)
 create mode 100644 sound/soc/fsl/lpc3xxx-i2s.c
 create mode 100644 sound/soc/fsl/lpc3xxx-i2s.h
 create mode 100644 sound/soc/fsl/lpc3xxx-pcm.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 118d48747641..adfe07a99c1a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8927,6 +8927,7 @@ L:alsa-de...@alsa-project.org (moderated for 
non-subscribers)
 L: linuxppc-dev@lists.ozlabs.org
 S: Maintained
 F: Documentation/devicetree/bindings/sound/nxp,lpc3220-i2s.yaml
+F: sound/soc/fsl/lpc3xxx-*
 
 FREESCALE SOC SOUND QMC DRIVER
 M: Herve Codina 
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index 270726c134b3..72f2d4d15696 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -130,6 +130,13 @@ config SND_SOC_FSL_RPMSG
  This option is only useful for out-of-tree drivers since
  in-tree drivers select it automatically.
 
+config SND_SOC_FSL_LPC3XXX
+   tristate "SoC Audio for NXP LPC32XX CPUs"
+   depends on ARCH_LPC32XX || COMPILE_TEST
+   select SND_SOC_GENERIC_DMAENGINE_PCM
+   help
+ Say Y or M if you want to add support for the LPC3XXX I2S interface.
+
 config SND_SOC_IMX_PCM_DMA
tristate
select SND_SOC_GENERIC_DMAENGINE_PCM
diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile
index 2fe78eed3a48..2a61e2f96438 100644
--- a/sound/soc/fsl/Makefile
+++ b/sound/soc/fsl/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_SND_SOC_P1022_RDK) += snd-soc-p1022-rdk.o
 snd-soc-fsl-audmix-y := fsl_audmix.o
 snd-soc-fsl-asoc-card-y := fsl-asoc-card.o
 snd-soc-fsl-asrc-y := fsl_asrc.o fsl_asrc_dma.o
+snd-soc-fsl-lpc3xxx-y := lpc3xxx-pcm.o lpc3xxx-i2s.o
 snd-soc-fsl-sai-y := fsl_sai.o
 snd-soc-fsl-ssi-y := fsl_ssi.o
 snd-soc-fsl-ssi-$(CONFIG_DEBUG_FS) += fsl_ssi_dbg.o
@@ -29,6 +30,7 @@ snd-soc-fsl-qmc-audio-y := fsl_qmc_audio.o
 obj-$(CONFIG_SND_SOC_FSL_AUDMIX) += snd-soc-fsl-audmix.o
 obj-$(CONFIG_SND_SOC_FSL_ASOC_CARD) += snd-soc-fsl-asoc-card.o
 obj-$(CONFIG_SND_SOC_FSL_ASRC) += snd-soc-fsl-asrc.o
+obj-$(CONFIG_SND_SOC_FSL_LPC3XXX) += snd-soc-fsl-lpc3xxx.o
 obj-$(CONFIG_SND_SOC_FSL_SAI) += snd-soc-fsl-sai.o
 obj-$(CONFIG_SND_SOC_FSL_SSI) += snd-soc-fsl-ssi.o
 obj-$(CONFIG_SND_SOC_FSL_SPDIF) += snd-soc-fsl-spdif.o
diff --git a/sound/soc/fsl/lpc3xxx-i2s.c b/sound/soc/fsl/lpc3xxx-i2s.c
new file mode 100644
index ..0e5b4d5202ff
--- /dev/null
+++ b/sound/soc/fsl/lpc3xxx-i2s.c
@@ -0,0 +1,375 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+//
+// Author: Kevin Wells 
+//
+// Copyright (C) 2008 NXP Semiconductors
+// Copyright 2023 Timesys Corporation 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "lpc3xxx-i2s.h"
+
+#define I2S_PLAYBACK_FLAG 0x1
+#define I2S_CAPTURE_FLAG 0x2
+
+#define LPC3XXX_I2S_RATES ( \
+   SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | \
+   SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \
+   SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000)
+
+#define LPC3XXX_I2S_FORMATS ( \
+   SNDRV_PCM_FMTBIT_S8 | \
+   SNDRV_PCM_FMTBIT_S16_LE | \
+   SNDRV_PCM_FMTBIT_S32_LE)
+
+static void __lpc3xxx_find_clkdiv(u32 *clkx, u32 *clky, int freq, int xbytes, 
u32 clkrate)
+{
+   u32 i2srate;
+   u32 idxx, idyy;
+   u32 savedbitclkrate, diff, trate, baseclk;
+
+   /* Adjust rate for sample size (bits) and 2 channels 

[Patch v5 10/12] mtd: rawnand: lpx32xx: Request DMA channels using DT entries

2024-06-27 Thread Piotr Wojtaszczyk
Move away from pl08x platform data towards device tree.

Signed-off-by: Piotr Wojtaszczyk 
---
Changes for v5:
- Added fallback dma channel request for backward compatibility with DMA with
  platform data instead DT

Changes for v4:
- This patch is new in v4

 drivers/mtd/nand/raw/lpc32xx_mlc.c | 26 +++---
 drivers/mtd/nand/raw/lpc32xx_slc.c | 26 +++---
 2 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/drivers/mtd/nand/raw/lpc32xx_mlc.c 
b/drivers/mtd/nand/raw/lpc32xx_mlc.c
index 677fcb03f9be..92cebe871bb4 100644
--- a/drivers/mtd/nand/raw/lpc32xx_mlc.c
+++ b/drivers/mtd/nand/raw/lpc32xx_mlc.c
@@ -574,18 +574,22 @@ static int lpc32xx_dma_setup(struct lpc32xx_nand_host 
*host)
struct mtd_info *mtd = nand_to_mtd(>nand_chip);
dma_cap_mask_t mask;
 
-   if (!host->pdata || !host->pdata->dma_filter) {
-   dev_err(mtd->dev.parent, "no DMA platform data\n");
-   return -ENOENT;
-   }
-
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   host->dma_chan = dma_request_channel(mask, host->pdata->dma_filter,
-"nand-mlc");
+   host->dma_chan = dma_request_chan(mtd->dev.parent, "rx-tx");
if (!host->dma_chan) {
-   dev_err(mtd->dev.parent, "Failed to request DMA channel\n");
-   return -EBUSY;
+   /* fallback to request using platform data */
+   if (!host->pdata || !host->pdata->dma_filter) {
+   dev_err(mtd->dev.parent, "no DMA platform data\n");
+   return -ENOENT;
+   }
+
+   dma_cap_zero(mask);
+   dma_cap_set(DMA_SLAVE, mask);
+   host->dma_chan = dma_request_channel(mask, 
host->pdata->dma_filter, "nand-mlc");
+
+   if (!host->dma_chan) {
+   dev_err(mtd->dev.parent, "Failed to request DMA 
channel\n");
+   return -EBUSY;
+   }
}
 
/*
diff --git a/drivers/mtd/nand/raw/lpc32xx_slc.c 
b/drivers/mtd/nand/raw/lpc32xx_slc.c
index 1c5fa855b9f2..3b7e3d259785 100644
--- a/drivers/mtd/nand/raw/lpc32xx_slc.c
+++ b/drivers/mtd/nand/raw/lpc32xx_slc.c
@@ -721,18 +721,22 @@ static int lpc32xx_nand_dma_setup(struct 
lpc32xx_nand_host *host)
struct mtd_info *mtd = nand_to_mtd(>nand_chip);
dma_cap_mask_t mask;
 
-   if (!host->pdata || !host->pdata->dma_filter) {
-   dev_err(mtd->dev.parent, "no DMA platform data\n");
-   return -ENOENT;
-   }
-
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   host->dma_chan = dma_request_channel(mask, host->pdata->dma_filter,
-"nand-slc");
+   host->dma_chan = dma_request_chan(mtd->dev.parent, "rx-tx");
if (!host->dma_chan) {
-   dev_err(mtd->dev.parent, "Failed to request DMA channel\n");
-   return -EBUSY;
+   /* fallback to request using platform data */
+   if (!host->pdata || !host->pdata->dma_filter) {
+   dev_err(mtd->dev.parent, "no DMA platform data\n");
+   return -ENOENT;
+   }
+
+   dma_cap_zero(mask);
+   dma_cap_set(DMA_SLAVE, mask);
+   host->dma_chan = dma_request_channel(mask, 
host->pdata->dma_filter, "nand-slc");
+
+   if (!host->dma_chan) {
+   dev_err(mtd->dev.parent, "Failed to request DMA 
channel\n");
+   return -EBUSY;
+   }
}
 
return 0;
-- 
2.25.1



[Patch v5 09/12] ARM: lpc32xx: Remove pl08x platform data in favor for device tree

2024-06-27 Thread Piotr Wojtaszczyk
With the driver for nxp,lpc3220-dmamux we can remove the pl08x platform
data and let pl08x driver to create peripheral channels from the DT
properties.

Signed-off-by: Piotr Wojtaszczyk 
---
Changes for v4:
- This patch is new in v4

 arch/arm/mach-lpc32xx/phy3250.c | 54 -
 1 file changed, 54 deletions(-)

diff --git a/arch/arm/mach-lpc32xx/phy3250.c b/arch/arm/mach-lpc32xx/phy3250.c
index 66701bf43248..0c7797a0e44e 100644
--- a/arch/arm/mach-lpc32xx/phy3250.c
+++ b/arch/arm/mach-lpc32xx/phy3250.c
@@ -16,64 +16,10 @@
 #include 
 #include "common.h"
 
-static struct pl08x_channel_data pl08x_slave_channels[] = {
-   {
-   .bus_id = "nand-slc",
-   .min_signal = 1, /* SLC NAND Flash */
-   .max_signal = 1,
-   .periph_buses = PL08X_AHB1,
-   },
-   {
-   .bus_id = "nand-mlc",
-   .min_signal = 12, /* MLC NAND Flash */
-   .max_signal = 12,
-   .periph_buses = PL08X_AHB1,
-   },
-};
-
-static int pl08x_get_signal(const struct pl08x_channel_data *cd)
-{
-   return cd->min_signal;
-}
-
-static void pl08x_put_signal(const struct pl08x_channel_data *cd, int ch)
-{
-}
-
-static struct pl08x_platform_data pl08x_pd = {
-   /* Some reasonable memcpy defaults */
-   .memcpy_burst_size = PL08X_BURST_SZ_256,
-   .memcpy_bus_width = PL08X_BUS_WIDTH_32_BITS,
-   .slave_channels = _slave_channels[0],
-   .num_slave_channels = ARRAY_SIZE(pl08x_slave_channels),
-   .get_xfer_signal = pl08x_get_signal,
-   .put_xfer_signal = pl08x_put_signal,
-   .lli_buses = PL08X_AHB1,
-   .mem_buses = PL08X_AHB1,
-};
-
-static struct lpc32xx_slc_platform_data lpc32xx_slc_data = {
-   .dma_filter = pl08x_filter_id,
-};
-
-static struct lpc32xx_mlc_platform_data lpc32xx_mlc_data = {
-   .dma_filter = pl08x_filter_id,
-};
-
-static const struct of_dev_auxdata lpc32xx_auxdata_lookup[] __initconst = {
-   OF_DEV_AUXDATA("arm,pl080", 0x3100, "pl08xdmac", _pd),
-   OF_DEV_AUXDATA("nxp,lpc3220-slc", 0x2002, "2002.flash",
-  _slc_data),
-   OF_DEV_AUXDATA("nxp,lpc3220-mlc", 0x200a8000, "200a8000.flash",
-  _mlc_data),
-   { }
-};
-
 static void __init lpc3250_machine_init(void)
 {
lpc32xx_serial_init();
 
-   of_platform_default_populate(NULL, lpc32xx_auxdata_lookup, NULL);
 }
 
 static const char *const lpc32xx_dt_compat[] __initconst = {
-- 
2.25.1



[Patch v5 08/12] dmaengine: Add dma router for pl08x in LPC32XX SoC

2024-06-27 Thread Piotr Wojtaszczyk
LPC32XX connects few of its peripherals to pl08x DMA thru a multiplexer,
this driver allows to route a signal request line thru the multiplexer for
given peripheral.

Signed-off-by: Piotr Wojtaszczyk 
---
Changes for v5:
- Fix struct declaration order
- Removed unused variables
- Break search loop if expected lpc32xx_muxes[i].signal is found

Changes for v4:
- This patch is new in v4

 MAINTAINERS  |   1 +
 drivers/dma/Kconfig  |   9 ++
 drivers/dma/Makefile |   1 +
 drivers/dma/lpc32xx-dmamux.c | 195 +++
 4 files changed, 206 insertions(+)
 create mode 100644 drivers/dma/lpc32xx-dmamux.c

diff --git a/MAINTAINERS b/MAINTAINERS
index ceec359c68fc..118d48747641 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2404,6 +2404,7 @@ R:Vladimir Zapolskiy 
 L: linux-arm-ker...@lists.infradead.org (moderated for non-subscribers)
 S: Maintained
 F: Documentation/devicetree/bindings/dma/nxp,lpc3220-dmamux.yaml
+F: drivers/dma/lpc32xx-dmamux.c
 
 ARM/Marvell Dove/MV78xx0/Orion SOC support
 M: Andrew Lunn 
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 002a5ec80620..aeace3d7e066 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -378,6 +378,15 @@ config LPC18XX_DMAMUX
  Enable support for DMA on NXP LPC18xx/43xx platforms
  with PL080 and multiplexed DMA request lines.
 
+config LPC32XX_DMAMUX
+   bool "NXP LPC32xx DMA MUX for PL080"
+   depends on ARCH_LPC32XX || COMPILE_TEST
+   depends on OF && AMBA_PL08X
+   select MFD_SYSCON
+   help
+ Support for PL080 multiplexed DMA request lines on
+ LPC32XX platrofm.
+
 config LS2X_APB_DMA
tristate "Loongson LS2X APB DMA support"
depends on LOONGARCH || COMPILE_TEST
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index 802ca916f05f..6f1350b62e7f 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -50,6 +50,7 @@ obj-$(CONFIG_INTEL_IOATDMA) += ioat/
 obj-y += idxd/
 obj-$(CONFIG_K3_DMA) += k3dma.o
 obj-$(CONFIG_LPC18XX_DMAMUX) += lpc18xx-dmamux.o
+obj-$(CONFIG_LPC32XX_DMAMUX) += lpc32xx-dmamux.o
 obj-$(CONFIG_LS2X_APB_DMA) += ls2x-apb-dma.o
 obj-$(CONFIG_MILBEAUT_HDMAC) += milbeaut-hdmac.o
 obj-$(CONFIG_MILBEAUT_XDMAC) += milbeaut-xdmac.o
diff --git a/drivers/dma/lpc32xx-dmamux.c b/drivers/dma/lpc32xx-dmamux.c
new file mode 100644
index ..351d7e23e615
--- /dev/null
+++ b/drivers/dma/lpc32xx-dmamux.c
@@ -0,0 +1,195 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright 2024 Timesys Corporation 
+//
+// Based on TI DMA Crossbar driver by:
+//   Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com
+//   Author: Peter Ujfalusi 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define LPC32XX_SSP_CLK_CTRL 0x78
+#define LPC32XX_I2S_CLK_CTRL 0x7c
+
+struct lpc32xx_dmamux {
+   int signal;
+   char *name_sel0;
+   char *name_sel1;
+   int muxval;
+   int muxreg;
+   int bit;
+   bool busy;
+};
+
+struct lpc32xx_dmamux_data {
+   struct dma_router dmarouter;
+   struct regmap *reg;
+   spinlock_t lock; /* protects busy status flag */
+};
+
+/* From LPC32x0 User manual "3.2.1 DMA request signals" */
+static struct lpc32xx_dmamux lpc32xx_muxes[] = {
+   {
+   .signal = 3,
+   .name_sel0 = "spi2-rx-tx",
+   .name_sel1 = "ssp1-rx",
+   .muxreg = LPC32XX_SSP_CLK_CTRL,
+   .bit = 5,
+   },
+   {
+   .signal = 10,
+   .name_sel0 = "uart7-rx",
+   .name_sel1 = "i2s1-dma1",
+   .muxreg = LPC32XX_I2S_CLK_CTRL,
+   .bit = 4,
+   },
+   {
+   .signal = 11,
+   .name_sel0 = "spi1-rx-tx",
+   .name_sel1 = "ssp1-tx",
+   .muxreg = LPC32XX_SSP_CLK_CTRL,
+   .bit = 4,
+   },
+   {
+   .signal = 14,
+   .name_sel0 = "none",
+   .name_sel1 = "ssp0-rx",
+   .muxreg = LPC32XX_SSP_CLK_CTRL,
+   .bit = 3,
+   },
+   {
+   .signal = 15,
+   .name_sel0 = "none",
+   .name_sel1 = "ssp0-tx",
+   .muxreg = LPC32XX_SSP_CLK_CTRL,
+   .bit = 2,
+   },
+};
+
+static void lpc32xx_dmamux_release(struct device *dev, void *route_data)
+{
+   struct lpc32xx_dmamux_data *dmamux = dev_get_drvdata(dev);
+   struct lpc32xx_dmamux *mux = route_data;
+
+   dev_dbg(dev, "releasing dma request signal %d routed to %s\n",
+   mux->signal, mux->muxval ? mux->name_sel1 : mux->name_sel1);
+
+   guard(spinlock)(>lock);
+
+   mux->busy = false;
+}
+
+static void *lpc32xx_dmamux_reserve(struct of_phandle_args *dma_spec,
+   struct of_dma *ofdma)
+{
+   struct platform_device *pdev = 

[Patch v5 07/12] clk: lpc32xx: initialize regmap using parent syscon

2024-06-27 Thread Piotr Wojtaszczyk
This allows to share the regmap with other simple-mfd devices like
nxp,lpc32xx-dmamux

Signed-off-by: Piotr Wojtaszczyk 
---
Changes for v5:
- Add fallback regmap for previous simple-bus DT entry

Changes for v4:
- This patch is new in v4

 drivers/clk/Kconfig   |  1 +
 drivers/clk/nxp/clk-lpc32xx.c | 26 +++---
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 3e9099504fad..85ef57d5cccf 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -346,6 +346,7 @@ config COMMON_CLK_LOONGSON2
 config COMMON_CLK_NXP
def_bool COMMON_CLK && (ARCH_LPC18XX || ARCH_LPC32XX)
select REGMAP_MMIO if ARCH_LPC32XX
+   select MFD_SYSCON if ARCH_LPC32XX
select MFD_SYSCON if ARCH_LPC18XX
help
  Support for clock providers on NXP platforms.
diff --git a/drivers/clk/nxp/clk-lpc32xx.c b/drivers/clk/nxp/clk-lpc32xx.c
index d0f870eff0d6..b8de7f66d1b5 100644
--- a/drivers/clk/nxp/clk-lpc32xx.c
+++ b/drivers/clk/nxp/clk-lpc32xx.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -1511,18 +1512,21 @@ static void __init lpc32xx_clk_init(struct device_node 
*np)
return;
}
 
-   base = of_iomap(np, 0);
-   if (!base) {
-   pr_err("failed to map system control block registers\n");
-   return;
-   }
-
-   clk_regmap = regmap_init_mmio(NULL, base, _scb_regmap_config);
+   clk_regmap = syscon_node_to_regmap(np->parent);
if (IS_ERR(clk_regmap)) {
-   pr_err("failed to regmap system control block: %ld\n",
-   PTR_ERR(clk_regmap));
-   iounmap(base);
-   return;
+   /* fallback to mmio if syscon fails */
+   base = of_iomap(np, 0);
+   if (!base) {
+   pr_err("failed to map system control block 
registers\n");
+   return;
+   }
+   clk_regmap = regmap_init_mmio(NULL, base, 
_scb_regmap_config);
+   if (IS_ERR(clk_regmap)) {
+   pr_err("failed to regmap system control block: %ld\n",
+  PTR_ERR(clk_regmap));
+   iounmap(base);
+   return;
+   }
}
 
/*
-- 
2.25.1



[Patch v5 06/12] ARM: dts: lpc32xx: Add missing i2s properties

2024-06-27 Thread Piotr Wojtaszczyk
Adds properties declared in the new DT binding nxp,lpc3220-i2s.yaml

Signed-off-by: Piotr Wojtaszczyk 
---
Changes for v5:
- This patch is new in v5
- Split previous patch for lpc32xx.dtsi in to 3 patches

 arch/arm/boot/dts/nxp/lpc/lpc32xx.dtsi | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/nxp/lpc/lpc32xx.dtsi 
b/arch/arm/boot/dts/nxp/lpc/lpc32xx.dtsi
index 6135ce4dde61..c58dc127e59f 100644
--- a/arch/arm/boot/dts/nxp/lpc/lpc32xx.dtsi
+++ b/arch/arm/boot/dts/nxp/lpc/lpc32xx.dtsi
@@ -240,8 +240,11 @@ spi2: spi@2009 {
i2s0: i2s@20094000 {
compatible = "nxp,lpc3220-i2s";
reg = <0x20094000 0x1000>;
+   interrupts = <22 IRQ_TYPE_LEVEL_HIGH>;
+   clocks = < LPC32XX_CLK_I2S0>;
dmas = < 0 1>, < 13 1>;
dma-names = "rx", "tx";
+   #sound-dai-cells = <0>;
status = "disabled";
};
 
@@ -260,8 +263,11 @@ sd: sd@20098000 {
i2s1: i2s@2009c000 {
compatible = "nxp,lpc3220-i2s";
reg = <0x2009c000 0x1000>;
+   interrupts = <23 IRQ_TYPE_LEVEL_HIGH>;
+   clocks = < LPC32XX_CLK_I2S1>;
dmas = < 2 1>, < 10 1 1>;
dma-names = "rx", "tx";
+   #sound-dai-cells = <0>;
status = "disabled";
};
 
-- 
2.25.1



[Patch v5 05/12] ARM: dts: lpc32xx: Add missing dma properties

2024-06-27 Thread Piotr Wojtaszczyk
Adds properties declared in the new DT binding nxp,lpc3220-dmamux.yaml
and corresponding phandles.

Signed-off-by: Piotr Wojtaszczyk 
---
Changes for v5:
- This patch is new in v5
- Split previous patch for lpc32xx.dtsi in to 3 patches

 arch/arm/boot/dts/nxp/lpc/lpc32xx.dtsi | 38 ++
 1 file changed, 38 insertions(+)

diff --git a/arch/arm/boot/dts/nxp/lpc/lpc32xx.dtsi 
b/arch/arm/boot/dts/nxp/lpc/lpc32xx.dtsi
index 8bf88d141e5b..6135ce4dde61 100644
--- a/arch/arm/boot/dts/nxp/lpc/lpc32xx.dtsi
+++ b/arch/arm/boot/dts/nxp/lpc/lpc32xx.dtsi
@@ -67,6 +67,8 @@ slc: flash@2002 {
reg = <0x2002 0x1000>;
clocks = < LPC32XX_CLK_SLC>;
status = "disabled";
+   dmas = < 1 1>;
+   dma-names = "rx-tx";
};
 
mlc: flash@200a8000 {
@@ -75,6 +77,8 @@ mlc: flash@200a8000 {
interrupts = <11 IRQ_TYPE_LEVEL_HIGH>;
clocks = < LPC32XX_CLK_MLC>;
status = "disabled";
+   dmas = < 12 1>;
+   dma-names = "rx-tx";
};
 
dma: dma@3100 {
@@ -83,6 +87,13 @@ dma: dma@3100 {
interrupts = <28 IRQ_TYPE_LEVEL_HIGH>;
clocks = < LPC32XX_CLK_DMA>;
clock-names = "apb_pclk";
+   #dma-cells = <2>;
+   dma-channels = <8>;
+   dma-requests = <16>;
+   lli-bus-interface-ahb1;
+   mem-bus-interface-ahb1;
+   memcpy-burst-size = <256>;
+   memcpy-bus-width = <32>;
};
 
usb {
@@ -182,6 +193,8 @@ ssp0: spi@20084000 {
clock-names = "apb_pclk";
#address-cells = <1>;
#size-cells = <0>;
+   dmas = < 14 1 1>, < 15 1 1>;
+   dma-names = "rx", "tx";
status = "disabled";
};
 
@@ -191,6 +204,8 @@ spi1: spi@20088000 {
clocks = < LPC32XX_CLK_SPI1>;
#address-cells = <1>;
#size-cells = <0>;
+   dmas = < 11 1 0>;
+   dma-names = "rx-tx";
status = "disabled";
};
 
@@ -206,6 +221,8 @@ ssp1: spi@2008c000 {
clock-names = "apb_pclk";
#address-cells = <1>;
#size-cells = <0>;
+   dmas = < 3 1 1>, < 11 1 1>;
+   dma-names = "rx", "tx";
status = "disabled";
};
 
@@ -215,12 +232,16 @@ spi2: spi@2009 {
clocks = < LPC32XX_CLK_SPI2>;
#address-cells = <1>;
#size-cells = <0>;
+   dmas = < 3 1 0>;
+   dma-names = "rx-tx";
status = "disabled";
};
 
i2s0: i2s@20094000 {
compatible = "nxp,lpc3220-i2s";
reg = <0x20094000 0x1000>;
+   dmas = < 0 1>, < 13 1>;
+   dma-names = "rx", "tx";
status = "disabled";
};
 
@@ -231,12 +252,16 @@ sd: sd@20098000 {
 <13 IRQ_TYPE_LEVEL_HIGH>;
clocks = < LPC32XX_CLK_SD>;
clock-names = "apb_pclk";
+   dmas = < 4 1>;
+   dma-names = "rx";
status = "disabled";
};
 
i2s1: i2s@2009c000 {
compatible = "nxp,lpc3220-i2s";
reg = <0x2009c000 0x1000>;
+   dmas = < 2 1>, < 10 1 1>;
+   dma-names = "rx", "tx";
status = "disabled";
};
 
@@ -326,6 +351,13 @@ clk: clock-controller@0 {
clocks = <_32k>, <>;
clock-names = "xtal_32k", "xtal";
};
+
+   dmamux: dma-router@7c {
+   compatible = "nxp,lpc3220-dmamux";
+   reg = <0x7c 0x8>;
+   

[Patch v5 04/12] ARM: dts: lpc32xx: Use simple-mfd for clock control block

2024-06-27 Thread Piotr Wojtaszczyk
The clock control block shares registers with other Soc components

Signed-off-by: Piotr Wojtaszczyk 
---
Changes for v5:
- This patch is new in v5
- Split previous patch for lpc32xx.dtsi in to 3 patches

 arch/arm/boot/dts/nxp/lpc/lpc32xx.dtsi | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/arm/boot/dts/nxp/lpc/lpc32xx.dtsi 
b/arch/arm/boot/dts/nxp/lpc/lpc32xx.dtsi
index 974410918f35..8bf88d141e5b 100644
--- a/arch/arm/boot/dts/nxp/lpc/lpc32xx.dtsi
+++ b/arch/arm/boot/dts/nxp/lpc/lpc32xx.dtsi
@@ -312,18 +312,17 @@ fab {
compatible = "simple-bus";
ranges = <0x2000 0x2000 0x3000>;
 
-   /* System Control Block */
-   scb {
-   compatible = "simple-bus";
-   ranges = <0x0 0x40004000 0x1000>;
+   syscon@40004000 {
+   compatible = "nxp,lpc3220-creg", "syscon", 
"simple-mfd";
+   reg = <0x40004000 0x114>;
#address-cells = <1>;
#size-cells = <1>;
+   ranges = <0 0x40004000 0x114>;
 
clk: clock-controller@0 {
compatible = "nxp,lpc3220-clk";
reg = <0x00 0x114>;
#clock-cells = <1>;
-
clocks = <_32k>, <>;
clock-names = "xtal_32k", "xtal";
};
-- 
2.25.1



[Patch v5 03/12] ASoC: dt-bindings: lpc32xx: Add lpc32xx i2s DT binding

2024-06-27 Thread Piotr Wojtaszczyk
Add nxp,lpc3220-i2s DT binding documentation.

Signed-off-by: Piotr Wojtaszczyk 
Reviewed-by: Krzysztof Kozlowski 
---
Changes for v5:
- Removed "N:" from the MAINTAINERS entry

Changes for v4:
- Custom dma-vc-names property with standard dmas and dma-names
- Added to MAINTAINERS

Changes for v3:
- Added '$ref: dai-common.yaml#' and '#sound-dai-cells'
- Dropped all clock-names, references
- Dropped status property from the example
- Added interrupts property
- 'make dt_binding_check' pass

Changes for v2:
- Added maintainers field
- Dropped clock-names
- Dropped unused unneded interrupts field

 .../bindings/sound/nxp,lpc3220-i2s.yaml   | 73 +++
 MAINTAINERS   |  9 +++
 2 files changed, 82 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/nxp,lpc3220-i2s.yaml

diff --git a/Documentation/devicetree/bindings/sound/nxp,lpc3220-i2s.yaml 
b/Documentation/devicetree/bindings/sound/nxp,lpc3220-i2s.yaml
new file mode 100644
index ..40a0877a8aba
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/nxp,lpc3220-i2s.yaml
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/nxp,lpc3220-i2s.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NXP LPC32XX I2S Controller
+
+description:
+  The I2S controller in LPC32XX SoCs, ASoC DAI.
+
+maintainers:
+  - J.M.B. Downing 
+  - Piotr Wojtaszczyk 
+
+allOf:
+  - $ref: dai-common.yaml#
+
+properties:
+  compatible:
+enum:
+  - nxp,lpc3220-i2s
+
+  reg:
+maxItems: 1
+
+  interrupts:
+maxItems: 1
+
+  clocks:
+items:
+  - description: input clock of the peripheral.
+
+  dmas:
+items:
+  - description: RX DMA Channel
+  - description: TX DMA Channel
+
+  dma-names:
+items:
+  - const: rx
+  - const: tx
+
+  "#sound-dai-cells":
+const: 0
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - dmas
+  - dma-names
+  - '#sound-dai-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+#include 
+
+i2s@20094000 {
+  compatible = "nxp,lpc3220-i2s";
+  reg = <0x20094000 0x1000>;
+  interrupts = <22 IRQ_TYPE_LEVEL_HIGH>;
+  clocks = < LPC32XX_CLK_I2S0>;
+  dmas = < 0 1>, < 13 1>;
+  dma-names = "rx", "tx";
+  #sound-dai-cells = <0>;
+};
+
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index 79b44addc139..ceec359c68fc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8918,6 +8918,15 @@ S:   Maintained
 F: sound/soc/fsl/fsl*
 F: sound/soc/fsl/imx*
 
+FREESCALE SOC LPC32XX SOUND DRIVERS
+M: J.M.B. Downing 
+M: Piotr Wojtaszczyk 
+R: Vladimir Zapolskiy 
+L: alsa-de...@alsa-project.org (moderated for non-subscribers)
+L: linuxppc-dev@lists.ozlabs.org
+S: Maintained
+F: Documentation/devicetree/bindings/sound/nxp,lpc3220-i2s.yaml
+
 FREESCALE SOC SOUND QMC DRIVER
 M: Herve Codina 
 L: alsa-de...@alsa-project.org (moderated for non-subscribers)
-- 
2.25.1



[Patch v5 02/12] dt-bindings: dma: Add lpc32xx DMA mux binding

2024-06-27 Thread Piotr Wojtaszczyk
LPC32XX SoCs use pl080 dma controller which have few request signals
multiplexed between peripherals. This binding describes how devices can
use the multiplexed request signals.

Signed-off-by: Piotr Wojtaszczyk 
---
Changes for v5:
- Corrected property order
- Added maxItems to properties
- Fixed example
- Removed "N:: from the MAINTAINERS entry
- Added Piotr Wojtaszczyk  to LPC32XX maintainers

Changes for v4:
- This patch is new in v4

 .../bindings/dma/nxp,lpc3220-dmamux.yaml  | 49 +++
 MAINTAINERS   |  9 
 2 files changed, 58 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/dma/nxp,lpc3220-dmamux.yaml

diff --git a/Documentation/devicetree/bindings/dma/nxp,lpc3220-dmamux.yaml 
b/Documentation/devicetree/bindings/dma/nxp,lpc3220-dmamux.yaml
new file mode 100644
index ..32f208744154
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/nxp,lpc3220-dmamux.yaml
@@ -0,0 +1,49 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/dma/nxp,lpc3220-dmamux.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: DMA multiplexer for LPC32XX SoC (DMA request router)
+
+maintainers:
+  - J.M.B. Downing 
+  - Piotr Wojtaszczyk 
+
+allOf:
+  - $ref: dma-router.yaml#
+
+properties:
+  compatible:
+const: nxp,lpc3220-dmamux
+
+  reg:
+maxItems: 1
+
+  dma-masters:
+description: phandle to a dma node compatible with arm,pl080
+maxItems: 1
+
+  "#dma-cells":
+const: 3
+description: |
+  First two cells same as for device pointed in dma-masters.
+  Third cell represents mux value for the request.
+
+required:
+  - compatible
+  - reg
+  - dma-masters
+
+additionalProperties: false
+
+examples:
+  - |
+dma-router@7c {
+  compatible = "nxp,lpc3220-dmamux";
+  reg = <0x7c 0x8>;
+  dma-masters = <>;
+  #dma-cells = <3>;
+};
+
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index aacccb376c28..79b44addc139 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2384,6 +2384,7 @@ N:lpc18xx
 
 ARM/LPC32XX SOC SUPPORT
 M: Vladimir Zapolskiy 
+M: Piotr Wojtaszczyk 
 L: linux-arm-ker...@lists.infradead.org (moderated for non-subscribers)
 S: Maintained
 T: git git://github.com/vzapolskiy/linux-lpc32xx.git
@@ -2396,6 +2397,14 @@ F:   drivers/usb/host/ohci-nxp.c
 F: drivers/watchdog/pnx4008_wdt.c
 N: lpc32xx
 
+LPC32XX DMAMUX SUPPORT
+M: J.M.B. Downing 
+M: Piotr Wojtaszczyk 
+R: Vladimir Zapolskiy 
+L: linux-arm-ker...@lists.infradead.org (moderated for non-subscribers)
+S: Maintained
+F: Documentation/devicetree/bindings/dma/nxp,lpc3220-dmamux.yaml
+
 ARM/Marvell Dove/MV78xx0/Orion SOC support
 M: Andrew Lunn 
 M: Sebastian Hesselbarth 
-- 
2.25.1



[Patch v5 01/12] dt-bindings: dma: pl08x: Add dma-cells description

2024-06-27 Thread Piotr Wojtaszczyk
Recover dma-cells description from the legacy DT binding.

Signed-off-by: Piotr Wojtaszczyk 
Fixes: 6f64aa5746d2 ("dt-bindings: dma: convert arm-pl08x to yaml")
Reviewed-by: Krzysztof Kozlowski 
---
Changes for v4:
- This patch is new in v4

 Documentation/devicetree/bindings/dma/arm-pl08x.yaml | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/dma/arm-pl08x.yaml 
b/Documentation/devicetree/bindings/dma/arm-pl08x.yaml
index ab25ae63d2c3..191215d36c85 100644
--- a/Documentation/devicetree/bindings/dma/arm-pl08x.yaml
+++ b/Documentation/devicetree/bindings/dma/arm-pl08x.yaml
@@ -52,6 +52,13 @@ properties:
   clock-names:
 maxItems: 1
 
+  "#dma-cells":
+const: 2
+description: |
+  First cell should contain the DMA request,
+  second cell should contain either 1 or 2 depending on
+  which AHB master that is used.
+
   lli-bus-interface-ahb1:
 type: boolean
 description: if AHB master 1 is eligible for fetching LLIs
-- 
2.25.1



[Patch v5 00/12] Add audio support for LPC32XX CPUs

2024-06-27 Thread Piotr Wojtaszczyk
This pach set is to bring back audio to machines with a LPC32XX CPU.
The legacy LPC32XX SoC used to have audio spport in linux 2.6.27.
The support was dropped due to lack of interest from mainaeners.

Piotr Wojtaszczyk (12):
  dt-bindings: dma: pl08x: Add dma-cells description
  dt-bindings: dma: Add lpc32xx DMA mux binding
  ASoC: dt-bindings: lpc32xx: Add lpc32xx i2s DT binding
  ARM: dts: lpc32xx: Use simple-mfd for clock control block
  ARM: dts: lpc32xx: Add missing dma properties
  ARM: dts: lpc32xx: Add missing i2s properties
  clk: lpc32xx: initialize regmap using parent syscon
  dmaengine: Add dma router for pl08x in LPC32XX SoC
  ARM: lpc32xx: Remove pl08x platform data in favor for device tree
  mtd: rawnand: lpx32xx: Request DMA channels using DT entries
  ASoC: fsl: Add i2s and pcm drivers for LPC32xx CPUs
  i2x: pnx: Fix potential deadlock warning from del_timer_sync() call in
isr

 .../devicetree/bindings/dma/arm-pl08x.yaml|   7 +
 .../bindings/dma/nxp,lpc3220-dmamux.yaml  |  49 +++
 .../bindings/sound/nxp,lpc3220-i2s.yaml   |  73 
 MAINTAINERS   |  20 +
 arch/arm/boot/dts/nxp/lpc/lpc32xx.dtsi|  53 ++-
 arch/arm/mach-lpc32xx/phy3250.c   |  54 ---
 drivers/clk/Kconfig   |   1 +
 drivers/clk/nxp/clk-lpc32xx.c |  26 +-
 drivers/dma/Kconfig   |   9 +
 drivers/dma/Makefile  |   1 +
 drivers/dma/lpc32xx-dmamux.c  | 195 +
 drivers/i2c/busses/i2c-pnx.c  |  48 +--
 drivers/mtd/nand/raw/lpc32xx_mlc.c|  26 +-
 drivers/mtd/nand/raw/lpc32xx_slc.c|  26 +-
 sound/soc/fsl/Kconfig |   7 +
 sound/soc/fsl/Makefile|   2 +
 sound/soc/fsl/lpc3xxx-i2s.c   | 375 ++
 sound/soc/fsl/lpc3xxx-i2s.h   |  79 
 sound/soc/fsl/lpc3xxx-pcm.c   |  72 
 19 files changed, 993 insertions(+), 130 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/dma/nxp,lpc3220-dmamux.yaml
 create mode 100644 Documentation/devicetree/bindings/sound/nxp,lpc3220-i2s.yaml
 create mode 100644 drivers/dma/lpc32xx-dmamux.c
 create mode 100644 sound/soc/fsl/lpc3xxx-i2s.c
 create mode 100644 sound/soc/fsl/lpc3xxx-i2s.h
 create mode 100644 sound/soc/fsl/lpc3xxx-pcm.c

-- 
2.25.1



[PATCH] Perf: Calling available function for stats printing

2024-06-27 Thread Abhishek Dubey
For printing dump_trace, just use existing stats_print()
function.

Signed-off-by: Abhishek Dubey 
---
 tools/perf/builtin-report.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 69618fb0110b..8678eebc49e6 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -1089,10 +1089,7 @@ static int __cmd_report(struct report *rep)
perf_session__fprintf_dsos(session, stdout);
 
if (dump_trace) {
-   perf_session__fprintf_nr_events(session, stdout,
-   rep->skip_empty);
-   evlist__fprintf_nr_events(session->evlist, stdout,
- rep->skip_empty);
+   stats_print(rep);
return 0;
}
}
-- 
2.44.0



[PATCH v3] PowerPC: Replace kretprobe with rethook

2024-06-27 Thread Abhishek Dubey
This is an adaptation of commit f3a112c0c40d ("x86,rethook,kprobes:
Replace kretprobe with rethook on x86") to PowerPC.

Replaces the kretprobe code with rethook on Power. With this patch,
kretprobe on Power uses the rethook instead of kretprobe specific
trampoline code.

Reference to other archs:
commit b57c2f124098 ("riscv: add riscv rethook implementation")
commit 7b0a096436c2 ("LoongArch: Replace kretprobe with rethook")

Signed-off-by: Abhishek Dubey 
---

Changes in v3:
* Fixing return address moved to arch_rethook_fixup_return()
* Addressed other minor comments
* show_stack mods to show correct fn name to go in separate patch
---
 arch/powerpc/Kconfig |  1 +
 arch/powerpc/kernel/Makefile |  1 +
 arch/powerpc/kernel/kprobes.c| 65 +--
 arch/powerpc/kernel/optprobes.c  |  2 +-
 arch/powerpc/kernel/rethook.c| 77 
 arch/powerpc/kernel/stacktrace.c |  6 ++-
 6 files changed, 85 insertions(+), 67 deletions(-)
 create mode 100644 arch/powerpc/kernel/rethook.c

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index c88c6d46a5bc..fa0b1ab3f935 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -270,6 +270,7 @@ config PPC
select HAVE_PERF_EVENTS_NMI if PPC64
select HAVE_PERF_REGS
select HAVE_PERF_USER_STACK_DUMP
+   select HAVE_RETHOOK
select HAVE_REGS_AND_STACK_ACCESS_API
select HAVE_RELIABLE_STACKTRACE
select HAVE_RSEQ
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 8585d03c02d3..7dd1b523b17f 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -140,6 +140,7 @@ obj-$(CONFIG_KPROBES)   += kprobes.o
 obj-$(CONFIG_OPTPROBES)+= optprobes.o optprobes_head.o
 obj-$(CONFIG_KPROBES_ON_FTRACE)+= kprobes-ftrace.o
 obj-$(CONFIG_UPROBES)  += uprobes.o
+obj-$(CONFIG_RETHOOK)   += rethook.o
 obj-$(CONFIG_PPC_UDBG_16550)   += legacy_serial.o udbg_16550.o
 obj-$(CONFIG_SWIOTLB)  += dma-swiotlb.o
 obj-$(CONFIG_ARCH_HAS_DMA_SET_MASK) += dma-mask.o
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index 14c5ddec3056..f8aa91bc3b17 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -228,16 +228,6 @@ static nokprobe_inline void set_current_kprobe(struct 
kprobe *p, struct pt_regs
kcb->kprobe_saved_msr = regs->msr;
 }
 
-void arch_prepare_kretprobe(struct kretprobe_instance *ri, struct pt_regs 
*regs)
-{
-   ri->ret_addr = (kprobe_opcode_t *)regs->link;
-   ri->fp = NULL;
-
-   /* Replace the return addr with trampoline addr */
-   regs->link = (unsigned long)__kretprobe_trampoline;
-}
-NOKPROBE_SYMBOL(arch_prepare_kretprobe);
-
 static int try_to_emulate(struct kprobe *p, struct pt_regs *regs)
 {
int ret;
@@ -394,49 +384,6 @@ int kprobe_handler(struct pt_regs *regs)
 }
 NOKPROBE_SYMBOL(kprobe_handler);
 
-/*
- * Function return probe trampoline:
- * - init_kprobes() establishes a probepoint here
- * - When the probed function returns, this probe
- * causes the handlers to fire
- */
-asm(".global __kretprobe_trampoline\n"
-   ".type __kretprobe_trampoline, @function\n"
-   "__kretprobe_trampoline:\n"
-   "nop\n"
-   "blr\n"
-   ".size __kretprobe_trampoline, .-__kretprobe_trampoline\n");
-
-/*
- * Called when the probe at kretprobe trampoline is hit
- */
-static int trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
-{
-   unsigned long orig_ret_address;
-
-   orig_ret_address = __kretprobe_trampoline_handler(regs, NULL);
-   /*
-* We get here through one of two paths:
-* 1. by taking a trap -> kprobe_handler() -> here
-* 2. by optprobe branch -> optimized_callback() -> opt_pre_handler() 
-> here
-*
-* When going back through (1), we need regs->nip to be setup properly
-* as it is used to determine the return address from the trap.
-* For (2), since nip is not honoured with optprobes, we instead setup
-* the link register properly so that the subsequent 'blr' in
-* __kretprobe_trampoline jumps back to the right instruction.
-*
-* For nip, we should set the address to the previous instruction since
-* we end up emulating it in kprobe_handler(), which increments the nip
-* again.
-*/
-   regs_set_return_ip(regs, orig_ret_address - 4);
-   regs->link = orig_ret_address;
-
-   return 0;
-}
-NOKPROBE_SYMBOL(trampoline_probe_handler);
-
 /*
  * Called after single-stepping.  p->addr is the address of the
  * instruction whose first byte has been replaced by the "breakpoint"
@@ -539,19 +486,9 @@ int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
 }
 NOKPROBE_SYMBOL(kprobe_fault_handler);
 
-static struct kprobe trampoline_p = {
-   .addr = (kprobe_opcode_t *) 

Re: powerpc: nvram_64.c:75:13: error: 'oops_to_nvram' used but never defined [-Werror]

2024-06-27 Thread Arnd Bergmann
On Thu, Jun 27, 2024, at 14:49, Naresh Kamboju wrote:
> The powerpc builds failed on Linux next-20240626 tag due to following 
> 
> arch/powerpc/kernel/nvram_64.c:79:17: error: initialization of 'void
> (*)(struct kmsg_dumper *, enum kmsg_dump_reason,  const char *)' from
> incompatible pointer type 'void (*)(struct kmsg_dumper *, enum
> kmsg_dump_reason)' [-Werror=incompatible-pointer-types]
>79 | .dump = oops_to_nvram
>   | ^
> arch/powerpc/kernel/nvram_64.c:79:17: note: (near initialization for
> 'nvram_kmsg_dumper.dump')
> arch/powerpc/kernel/nvram_64.c:645:13: error: conflicting types for
> 'oops_to_nvram'; have 'void(struct kmsg_dumper *, enum
> kmsg_dump_reason,  const char *)'
>   645 | static void oops_to_nvram(struct kmsg_dumper *dumper,
>   | ^
> arch/powerpc/kernel/nvram_64.c:75:13: note: previous declaration of
> 'oops_to_nvram' with type 'void(struct kmsg_dumper *, enum
> kmsg_dump_reason)'
>75 | static void oops_to_nvram(struct kmsg_dumper *dumper,
>   | ^
> arch/powerpc/kernel/nvram_64.c:75:13: error: 'oops_to_nvram' used but
> never defined [-Werror]
> arch/powerpc/kernel/nvram_64.c:645:13: error: 'oops_to_nvram' defined
> but not used [-Werror=unused-function]
>   645 | static void oops_to_nvram(struct kmsg_dumper *dumper,
>   | ^
> cc1: all warnings being treated as error

The problem is the forward declaration that was not changed
as part of commit 7e72bb7504d1 ("printk: add a short
description string to kmsg_dump()"). This should fix it:

diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index e385d3164648..a9da83c4243a 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -73,7 +73,8 @@ static const char *nvram_os_partitions[] = {
 };
 
 static void oops_to_nvram(struct kmsg_dumper *dumper,
- enum kmsg_dump_reason reason);
+ enum kmsg_dump_reason reason,
+ const char *desc);
 
 static struct kmsg_dumper nvram_kmsg_dumper = {
.dump = oops_to_nvram


  Arnd


powerpc: nvram_64.c:75:13: error: 'oops_to_nvram' used but never defined [-Werror]

2024-06-27 Thread Naresh Kamboju
The powerpc builds failed on Linux next-20240626 tag due to following warnings
and errors with gcc-13, gcc-8 and clang-18.

Reported-by: Linux Kernel Functional Testing 

Regressions found on powerpc:

  - clang-nightly-ppc64e_defconfig
  - clang-18-maple_defconfig
  - clang-nightly-defconfig
  - clang-18-defconfig
  - gcc-13-maple_defconfig
  - gcc-8-cell_defconfig
  - gcc-8-maple_defconfig
  - clang-18-ppc64e_defconfig
  - clang-nightly-cell_defconfig
  - clang-nightly-maple_defconfig
  - gcc-8-ppc64e_defconfig
  - gcc-13-cell_defconfig
  - gcc-13-defconfig
  - gcc-13-ppc64e_defconfig
  - clang-18-cell_defconfig
  - gcc-8-defconfig

Build errors:

arch/powerpc/kernel/nvram_64.c:79:17: error: initialization of 'void
(*)(struct kmsg_dumper *, enum kmsg_dump_reason,  const char *)' from
incompatible pointer type 'void (*)(struct kmsg_dumper *, enum
kmsg_dump_reason)' [-Werror=incompatible-pointer-types]
   79 | .dump = oops_to_nvram
  | ^
arch/powerpc/kernel/nvram_64.c:79:17: note: (near initialization for
'nvram_kmsg_dumper.dump')
arch/powerpc/kernel/nvram_64.c:645:13: error: conflicting types for
'oops_to_nvram'; have 'void(struct kmsg_dumper *, enum
kmsg_dump_reason,  const char *)'
  645 | static void oops_to_nvram(struct kmsg_dumper *dumper,
  | ^
arch/powerpc/kernel/nvram_64.c:75:13: note: previous declaration of
'oops_to_nvram' with type 'void(struct kmsg_dumper *, enum
kmsg_dump_reason)'
   75 | static void oops_to_nvram(struct kmsg_dumper *dumper,
  | ^
arch/powerpc/kernel/nvram_64.c:75:13: error: 'oops_to_nvram' used but
never defined [-Werror]
arch/powerpc/kernel/nvram_64.c:645:13: error: 'oops_to_nvram' defined
but not used [-Werror=unused-function]
  645 | static void oops_to_nvram(struct kmsg_dumper *dumper,
  | ^
cc1: all warnings being treated as errors

metadata:
--
  git_describe: next-20240626
  git_repo: https://gitlab.com/Linaro/lkft/mirrors/next/linux-next
  git_short_log: df9574a57d02 ("Add linux-next specific files for 20240626")
  arch: powerpc
  toolchain: gcc-13, gcc-8 and clang-18

Steps to reproduce:
-

# tuxmake --runtime podman --target-arch powerpc --toolchain gcc-13
--kconfig ppc64e_defconfig


Links:
--
 - 
https://storage.tuxsuite.com/public/linaro/lkft/builds/2iQqkMfvFPihkYnvWC7UxrVhb1X/
 - 
https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20240626/testrun/24453163/suite/build/test/gcc-13-ppc64e_defconfig/details/
- 
https://storage.tuxsuite.com/public/linaro/lkft/builds/2iQqkMfvFPihkYnvWC7UxrVhb1X/config

--
Linaro LKFT
https://lkft.linaro.org


Re: [PATCH 0/3] ASoC: imx-audmix: Split capture device to be a new device

2024-06-27 Thread Mark Brown
On Wed, 12 Jun 2024 14:40:49 +0800, Shengjiu Wang wrote:
> The transmitter and receiver part of the SAI interface need to be
> configured with different master/slave mode, especially to work
> with the audiomix module.
> 
> The SAI1 TX is in master mode, but SAI1 RX is in slave mode.
> So add another two DAIs for TX and RX separately in fsl_sai driver.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/3] ASoC: fsl_sai: Add separate DAI for transmitter and receiver
  commit: 15c958390460f964ec707ae6c5d1843638ebfe69
[2/3] ASoC: fsl_audmix: Split playback and capture stream to different DAI
  commit: 6232a7eb1afc842d0daf1c0314e1eda65731783f
[3/3] ASoC: imx-audmix: Split capture device for audmix
  commit: 05d996e113481fdd9ac40ccf5cadabd1e73f2404

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark



Re: [PATCH v1 1/2] powerpc/mmiotrace: Add MMIO Tracing tool for PowerPC

2024-06-27 Thread kernel test robot
Hi Jialong,

kernel test robot noticed the following build errors:

[auto build test ERROR on powerpc/next]
[also build test ERROR on powerpc/fixes linus/master v6.10-rc5 next-20240626]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Jialong-Yang/powerpc-mmiotrace-bind-ioremap-and-page-fault-to-active-mmiotrace/20240624-163027
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
patch link:
https://lore.kernel.org/r/2bf90acf7d29641ba6643934ff8dbba897dbd2d9.1718873074.git.jialong.yang%40shingroup.cn
patch subject: [PATCH v1 1/2] powerpc/mmiotrace: Add MMIO Tracing tool for 
PowerPC
config: powerpc-randconfig-r113-20240627 
(https://download.01.org/0day-ci/archive/20240627/202406271946.a6jwffay-...@intel.com/config)
compiler: powerpc-linux-gcc (GCC) 13.2.0
reproduce: 
(https://download.01.org/0day-ci/archive/20240627/202406271946.a6jwffay-...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202406271946.a6jwffay-...@intel.com/

All error/warnings (new ones prefixed by >>):

   arch/powerpc/mm/kmmio.c: In function 'pmd_mkinvalid':
>> arch/powerpc/mm/kmmio.c:140:16: error: implicit declaration of function 
>> '__pmd_raw' [-Werror=implicit-function-declaration]
 140 | return __pmd_raw(pmd_raw(pmd) & ~cpu_to_be64(_PAGE_PRESENT | 
_PAGE_INVALID));
 |^
>> arch/powerpc/mm/kmmio.c:140:26: error: implicit declaration of function 
>> 'pmd_raw'; did you mean 'pmd_bad'? [-Werror=implicit-function-declaration]
 140 | return __pmd_raw(pmd_raw(pmd) & ~cpu_to_be64(_PAGE_PRESENT | 
_PAGE_INVALID));
 |  ^~~
 |  pmd_bad
   In file included from include/linux/byteorder/big_endian.h:5,
from arch/powerpc/include/uapi/asm/byteorder.h:14,
from include/asm-generic/bitops/le.h:6,
from arch/powerpc/include/asm/bitops.h:325,
from include/linux/bitops.h:63,
from include/linux/thread_info.h:27,
from arch/powerpc/include/asm/ptrace.h:342,
from arch/powerpc/include/asm/hw_irq.h:12,
from arch/powerpc/include/asm/irqflags.h:12,
from include/linux/irqflags.h:18,
from include/asm-generic/cmpxchg-local.h:6,
from arch/powerpc/include/asm/cmpxchg.h:755,
from arch/powerpc/include/asm/atomic.h:11,
from include/linux/atomic.h:7,
from include/linux/rcupdate.h:25,
from include/linux/rculist.h:11,
from arch/powerpc/mm/kmmio.c:10:
>> arch/powerpc/mm/kmmio.c:140:70: error: '_PAGE_INVALID' undeclared (first use 
>> in this function); did you mean 'RPM_INVALID'?
 140 | return __pmd_raw(pmd_raw(pmd) & ~cpu_to_be64(_PAGE_PRESENT | 
_PAGE_INVALID));
 |  
^
   include/uapi/linux/byteorder/big_endian.h:38:51: note: in definition of 
macro '__cpu_to_be64'
  38 | #define __cpu_to_be64(x) ((__force __be64)(__u64)(x))
 |   ^
   arch/powerpc/mm/kmmio.c:140:42: note: in expansion of macro 'cpu_to_be64'
 140 | return __pmd_raw(pmd_raw(pmd) & ~cpu_to_be64(_PAGE_PRESENT | 
_PAGE_INVALID));
 |  ^~~
   arch/powerpc/mm/kmmio.c:140:70: note: each undeclared identifier is reported 
only once for each function it appears in
 140 | return __pmd_raw(pmd_raw(pmd) & ~cpu_to_be64(_PAGE_PRESENT | 
_PAGE_INVALID));
 |  
^
   include/uapi/linux/byteorder/big_endian.h:38:51: note: in definition of 
macro '__cpu_to_be64'
  38 | #define __cpu_to_be64(x) ((__force __be64)(__u64)(x))
 |   ^
   arch/powerpc/mm/kmmio.c:140:42: note: in expansion of macro 'cpu_to_be64'
 140 | return __pmd_raw(pmd_raw(pmd) & ~cpu_to_be64(_PAGE_PRESENT | 
_PAGE_INVALID));
 |  ^~~
   arch/powerpc/mm/kmmio.c: In function 'kmmio_handler':
>> arch/powerpc/mm/kmmio.c:318:32: error: 'struct pt_regs' has no member named 
>> 'softe'
 318 | ctx->saved_softe = regs->softe;
 | 

Re: [PATCH 06/13] mm/memory: Add dax_insert_pfn

2024-06-27 Thread Jan Kara
On Thu 27-06-24 10:54:21, Alistair Popple wrote:
> Currently to map a DAX page the DAX driver calls vmf_insert_pfn. This
> creates a special devmap PTE entry for the pfn but does not take a
> reference on the underlying struct page for the mapping. This is
> because DAX page refcounts are treated specially, as indicated by the
> presence of a devmap entry.
> 
> To allow DAX page refcounts to be managed the same as normal page
> refcounts introduce dax_insert_pfn. This will take a reference on the
> underlying page much the same as vmf_insert_page, except it also
> permits upgrading an existing mapping to be writable if
> requested/possible.
> 
> Signed-off-by: Alistair Popple 

Overall this looks good to me. Some comments below.

> ---
>  include/linux/mm.h |  4 ++-
>  mm/memory.c| 79 ++-
>  2 files changed, 76 insertions(+), 7 deletions(-)
> 
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 9a5652c..b84368b 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -1080,6 +1080,8 @@ int vma_is_stack_for_current(struct vm_area_struct 
> *vma);
>  struct mmu_gather;
>  struct inode;
>  
> +extern void prep_compound_page(struct page *page, unsigned int order);
> +

You don't seem to use this function in this patch?

> diff --git a/mm/memory.c b/mm/memory.c
> index ce48a05..4f26a1f 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -1989,14 +1989,42 @@ static int validate_page_before_insert(struct page 
> *page)
>  }
>  
>  static int insert_page_into_pte_locked(struct vm_area_struct *vma, pte_t 
> *pte,
> - unsigned long addr, struct page *page, pgprot_t prot)
> + unsigned long addr, struct page *page, pgprot_t prot, 
> bool mkwrite)
>  {
>   struct folio *folio = page_folio(page);
> + pte_t entry = ptep_get(pte);
>  
> - if (!pte_none(ptep_get(pte)))
> + if (!pte_none(entry)) {
> + if (mkwrite) {
> + /*
> +  * For read faults on private mappings the PFN passed
> +  * in may not match the PFN we have mapped if the
> +  * mapped PFN is a writeable COW page.  In the mkwrite
> +  * case we are creating a writable PTE for a shared
> +  * mapping and we expect the PFNs to match. If they
> +  * don't match, we are likely racing with block
> +  * allocation and mapping invalidation so just skip the
> +  * update.
> +  */
> + if (pte_pfn(entry) != page_to_pfn(page)) {
> + WARN_ON_ONCE(!is_zero_pfn(pte_pfn(entry)));
> + return -EFAULT;
> + }
> + entry = maybe_mkwrite(entry, vma);
> + entry = pte_mkyoung(entry);
> + if (ptep_set_access_flags(vma, addr, pte, entry, 1))
> + update_mmu_cache(vma, addr, pte);
> + return 0;
> + }
>   return -EBUSY;

If you do this like:

if (!mkwrite)
return -EBUSY;

You can reduce indentation of the big block and also making the flow more
obvious...

> + }
> +
>   /* Ok, finally just insert the thing.. */
>   folio_get(folio);
> + if (mkwrite)
> + entry = maybe_mkwrite(mk_pte(page, prot), vma);
> + else
> + entry = mk_pte(page, prot);

I'd prefer:

entry = mk_pte(page, prot);
if (mkwrite)
entry = maybe_mkwrite(entry, vma);

but I don't insist. Also insert_pfn() additionally has pte_mkyoung() and
pte_mkdirty(). Why was it left out here?

Honza
-- 
Jan Kara 
SUSE Labs, CR


Re: [Patch v4 10/10] i2x: pnx: Use threaded irq to fix warning from del_timer_sync()

2024-06-27 Thread Piotr Wojtaszczyk
On Tue, Jun 25, 2024 at 11:12 PM Andi Shyti  wrote:
>
> Hi Piotr,
>
> On Fri, Jun 21, 2024 at 02:08:03PM GMT, Piotr Wojtaszczyk wrote:
> > On Fri, Jun 21, 2024 at 12:57 AM Andi Shyti  wrote:
> > > On Thu, Jun 20, 2024 at 07:56:41PM GMT, Piotr Wojtaszczyk wrote:
> > > > When del_timer_sync() is called in an interrupt context it throws a 
> > > > warning
> > > > because of potential deadlock. Threaded irq handler fixes the potential
> > > > problem.
> > > >
> > > > Signed-off-by: Piotr Wojtaszczyk 
> > >
> > > did you run into a lockdep splat?
> > >
> > > Anything against using del_timer(), instead? Have you tried?
> >
> > I didn't get a lockdep splat but console was flooded with warnings from
> > https://github.com/torvalds/linux/blob/v6.10-rc4/kernel/time/timer.c#L1655
> > In the linux kernel v5.15 I didn't see these warnings.
> >
> > I'm not a maintainer of the driver and I didn't do any research on
> > what kind of impact
> > would have using del_timer() instad. Maybe Vladimir Zapolskiy will know 
> > that.
>
> Your patch is definitely correct, no doubt about that.
>
> And I don't have anything aginast changing irq handlers to
> threaded handlers. But I would be careful at doing that depending
> on the use of the controller and for accepting such change I
> would need an ack from someone who knows the device. Vladimir,
> perhaps?
>
> There are cases where using threaded handlers are not totally
> right, for example when the controller is used at early boot for
> power management handling. I don't think it's the case for this
> driver, but I can't be 100% sure.
>
> If you were able to see the flood of WARN_ON's, would be
> interesting to know how it behaves with del_timer(). Mind
> giving it a test?
>
> Thanks,
> Andi

I took some time to take a closer look at this and it turns out that the
timer is used only to exit from the wait_for_completion(), after each
del_timer_sync() there is a complete() call. So I will remove the timer
all together and replace wait_for_completion() with
wait_for_completion_timeout()


-- 
Piotr Wojtaszczyk
Timesys


Re: [V4 05/16] tools/perf: Add disasm_line__parse to parse raw instruction for powerpc

2024-06-27 Thread Athira Rajeev



> On 27 Jun 2024, at 2:47 AM, Namhyung Kim  wrote:
> 
> Hello,
> 
> On Wed, Jun 26, 2024 at 09:38:28AM +0530, Athira Rajeev wrote:
>> 
>> 
>>> On 26 Jun 2024, at 12:15 AM, Namhyung Kim  wrote:
>>> 
>>> On Tue, Jun 25, 2024 at 06:12:51PM +0530, Athira Rajeev wrote:
 
 
> On 25 Jun 2024, at 11:09 AM, Namhyung Kim  wrote:
> 
> On Fri, Jun 14, 2024 at 10:56:20PM +0530, Athira Rajeev wrote:
>> Currently, the perf tool infrastructure disasm_line__parse function to
>> parse disassembled line.
>> 
>> Example snippet from objdump:
>> objdump  --start-address= --stop-address=  -d 
>> --no-show-raw-insn -C 
>> 
>> c10224b4: lwz r10,0(r9)
>> 
>> This line "lwz r10,0(r9)" is parsed to extract instruction name,
>> registers names and offset. In powerpc, the approach for data type
>> profiling uses raw instruction instead of result from objdump to identify
>> the instruction category and extract the source/target registers.
>> 
>> Example: 38 01 81 e8 ld  r4,312(r1)
>> 
>> Here "38 01 81 e8" is the raw instruction representation. Add function
>> "disasm_line__parse_powerpc" to handle parsing of raw instruction.
>> Also update "struct disasm_line" to save the binary code/
>> With the change, function captures:
>> 
>> line -> "38 01 81 e8 ld  r4,312(r1)"
>> raw instruction "38 01 81 e8"
>> 
>> Raw instruction is used later to extract the reg/offset fields. Macros
>> are added to extract opcode and register fields. "struct disasm_line"
>> is updated to carry union of "bytes" and "raw_insn" of 32 bit to carry 
>> raw
>> code (raw). Function "disasm_line__parse_powerpc fills the raw
>> instruction hex value and can use macros to get opcode. There is no
>> changes in existing code paths, which parses the disassembled code.
>> The architecture using the instruction name and present approach is
>> not altered. Since this approach targets powerpc, the macro
>> implementation is added for powerpc as of now.
>> 
>> Since the disasm_line__parse is used in other cases (perf annotate) and
>> not only data tye profiling, the powerpc callback includes changes to
>> work with binary code as well as mneumonic representation. Also in case
>> if the DSO read fails and libcapstone is not supported, the approach
>> fallback to use objdump as option. Hence as option, patch has changes to
>> ensure objdump option also works well.
>> 
>> Signed-off-by: Athira Rajeev 
>> ---
> [SNIP]
>> +/*
>> + * Parses the result captured from symbol__disassemble_*
>> + * Example, line read from DSO file in powerpc:
>> + * line:38 01 81 e8
>> + * opcode: fetched from arch specific get_opcode_insn
>> + * rawp_insn: e8810138
>> + *
>> + * rawp_insn is used later to extract the reg/offset fields
>> + */
>> +#define PPC_OP(op) (((op) >> 26) & 0x3F)
>> +
>> +static int disasm_line__parse_powerpc(struct disasm_line *dl)
>> +{
>> + char *line = dl->al.line;
>> + const char **namep = >ins.name;
>> + char **rawp = >ops.raw;
>> + char tmp, *tmp_raw_insn, *name_raw_insn = skip_spaces(line);
>> + char *name = skip_spaces(name_raw_insn + 11);
>> + int objdump = 0;
>> +
>> + if (strlen(line) > 11)
>> + objdump = 1;
>> +
>> + if (name_raw_insn[0] == '\0')
>> + return -1;
>> +
>> + if (objdump) {
>> + *rawp = name + 1;
>> + while ((*rawp)[0] != '\0' && !isspace((*rawp)[0]))
>> + ++*rawp;
>> + tmp = (*rawp)[0];
>> + (*rawp)[0] = '\0';
>> +
>> + *namep = strdup(name);
>> + if (*namep == NULL)
>> + return -1;
>> +
>> + (*rawp)[0] = tmp;
>> + *rawp = strim(*rawp);
>> + } else
>> + *namep = "";
>>> 
>>> Then can you handle this logic under if (annotate_opts.show_raw_insn)
>>> in disasm_line__parse() instead of adding a new function?
>>> 
>>> Thanks,
>>> Namhyung
>> 
>> Hi Namhyung,
>> 
>> We discussed to have a per-arch disasm_line_parse() here:
>> https://lore.kernel.org/all/cam9d7ci1lda7mot2qdr2qk+dtnlu6zbkmronbdozajuqlqf...@mail.gmail.com/#t
>> 
>> So I added it as a new function : disasm_line__parse_powerpc
>> Since it is not used by other archs, we can go with having new function ?
> 
> Ok, I thought it'd be quite different from disasm_line__parse() but it
> seems that it's mostly similar except for the raw insn.  So I think it's
> better to add the logic to the generic disasm_line__parse().  Sorry for
> the inconvenience.
> 
> Thanks,
> Namhyung

Sure

Thanks
Athira
> 
>> +
>> + tmp_raw_insn = strdup(name_raw_insn);
>> + tmp_raw_insn[11] = '\0';
>> + remove_spaces(tmp_raw_insn);
>> +
>> + dl->raw.raw_insn = strtol(tmp_raw_insn, NULL, 16);
>> + if (objdump)
>> + dl->raw.raw_insn = be32_to_cpu(strtol(tmp_raw_insn, NULL, 16));
> 
> Hmm.. can you use a 

[PATCH v6 7/7] ARM: dts: imx6: update spdif sound card node properties

2024-06-27 Thread Elinor Montmasson
The merge of imx-spdif driver into fsl-asoc-card brought
new DT properties that can be used with the "fsl,imx-audio-spdif"
compatible:
* The "spdif-controller" property from imx-spdif is named "audio-cpu"
  in fsl-asoc-card.
* fsl-asoc-card uses codecs explicitly declared in DT
  with "audio-codec".
  With an S/PDIF, codec drivers spdif_transmitter and
  spdif_receiver should be used.
  Driver imx-spdif used instead the dummy codec and a pair of
  boolean properties, "spdif-in" and "spdif-out".

While backward compatibility is kept to support properties
"spdif-controller", "spdif-in" and "spdif-out", using new properties has
several benefits:
* "audio-cpu" and "audio-codec" are more generic names reflecting
  that the fsl-asoc-card driver supports multiple hardware.
  They are properties already used by devices using the
  fsl-asoc-card driver.
  They are also similar to properties of simple-card: "cpu" and "codec".
* "spdif-in" and "spdif-out" imply the use of the dummy codec in the
  driver. However, there are already two codec drivers for the S/PDIF,
  spdif_transmitter and spdif_receiver.
  It is better to declare S/PDIF Tx and Rx devices in a DT, and then
  reference them with "audio-codec" than using the dummy codec.

For those reasons, this commit updates in-tree DTs to use the new
properties:
* Rename "spdif-controller" property to "audio-cpu".
* Declare S/PDIF transmitter and/or receiver devices, and use them with
  the "audio-codec" property instead of "spdif-out" and/or "spdif-in".

These modifications were tested only on an imx8mn-evk board.

Note that out-of-tree and old DTs are still supported.

Signed-off-by: Elinor Montmasson 
---
 arch/arm/boot/dts/nxp/imx/imx6q-cm-fx6.dts| 15 ---
 arch/arm/boot/dts/nxp/imx/imx6q-prti6q.dts| 15 ---
 arch/arm/boot/dts/nxp/imx/imx6q-tbs2910.dts   |  9 +++--
 arch/arm/boot/dts/nxp/imx/imx6qdl-apalis.dtsi | 15 ---
 arch/arm/boot/dts/nxp/imx/imx6qdl-apf6dev.dtsi|  9 +++--
 arch/arm/boot/dts/nxp/imx/imx6qdl-colibri.dtsi| 15 ---
 arch/arm/boot/dts/nxp/imx/imx6qdl-cubox-i.dtsi|  9 +++--
 .../boot/dts/nxp/imx/imx6qdl-hummingboard.dtsi|  9 +++--
 arch/arm/boot/dts/nxp/imx/imx6qdl-sabreauto.dtsi  |  9 +++--
 arch/arm/boot/dts/nxp/imx/imx6qdl-wandboard.dtsi  |  9 +++--
 arch/arm/boot/dts/nxp/imx/imx6sx-sabreauto.dts|  9 +++--
 arch/arm/boot/dts/nxp/imx/imx6sx-sdb.dtsi |  9 +++--
 12 files changed, 104 insertions(+), 28 deletions(-)

diff --git a/arch/arm/boot/dts/nxp/imx/imx6q-cm-fx6.dts 
b/arch/arm/boot/dts/nxp/imx/imx6q-cm-fx6.dts
index 95b49fc83f7b..5c664c0f2169 100644
--- a/arch/arm/boot/dts/nxp/imx/imx6q-cm-fx6.dts
+++ b/arch/arm/boot/dts/nxp/imx/imx6q-cm-fx6.dts
@@ -127,12 +127,21 @@ simple-audio-card,codec {
};
};
 
+   spdif_out: spdif-out {
+   #sound-dai-cells = <0>;
+   compatible = "linux,spdif-dit";
+   };
+
+   spdif_in: spdif-in {
+   #sound-dai-cells = <0>;
+   compatible = "linux,spdif-dir";
+   };
+
sound-spdif {
compatible = "fsl,imx-audio-spdif";
model = "imx-spdif";
-   spdif-controller = <>;
-   spdif-out;
-   spdif-in;
+   audio-cpu = <>;
+   audio-codec = <_out>, <_in>;
};
 };
 
diff --git a/arch/arm/boot/dts/nxp/imx/imx6q-prti6q.dts 
b/arch/arm/boot/dts/nxp/imx/imx6q-prti6q.dts
index a7d5693c5ab7..8491d656ef17 100644
--- a/arch/arm/boot/dts/nxp/imx/imx6q-prti6q.dts
+++ b/arch/arm/boot/dts/nxp/imx/imx6q-prti6q.dts
@@ -111,12 +111,21 @@ simple-audio-card,codec {
};
};
 
+   spdif_out: spdif-out {
+   #sound-dai-cells = <0>;
+   compatible = "linux,spdif-dit";
+   };
+
+   spdif_in: spdif-in {
+   #sound-dai-cells = <0>;
+   compatible = "linux,spdif-dir";
+   };
+
sound-spdif {
compatible = "fsl,imx-audio-spdif";
model = "imx-spdif";
-   spdif-controller = <>;
-   spdif-in;
-   spdif-out;
+   audio-cpu = <>;
+   audio-codec = <_out>, <_in>;
};
 };
 
diff --git a/arch/arm/boot/dts/nxp/imx/imx6q-tbs2910.dts 
b/arch/arm/boot/dts/nxp/imx/imx6q-tbs2910.dts
index 7c298d9aa21e..ea9a98887c7b 100644
--- a/arch/arm/boot/dts/nxp/imx/imx6q-tbs2910.dts
+++ b/arch/arm/boot/dts/nxp/imx/imx6q-tbs2910.dts
@@ -90,11 +90,16 @@ sound-sgtl5000 {
ssi-controller = <>;
};
 
+   spdif_out: spdif-out {
+   #sound-dai-cells = <0>;
+   compatible = "linux,spdif-dit";
+   };
+
sound-spdif {
compatible = "fsl,imx-audio-spdif";
model = "On-board SPDIF";
-   spdif-controller = <>;
-   spdif-out;
+   audio-cpu = <>;
+   

[PATCH v6 6/7] arm64: dts: imx8m: update spdif sound card node properties

2024-06-27 Thread Elinor Montmasson
The merge of imx-spdif driver into fsl-asoc-card brought
new DT properties that can be used with the "fsl,imx-audio-spdif"
compatible:
* The "spdif-controller" property from imx-spdif is named "audio-cpu"
  in fsl-asoc-card.
* fsl-asoc-card uses codecs explicitly declared in DT
  with "audio-codec".
  With an S/PDIF, codec drivers spdif_transmitter and
  spdif_receiver should be used.
  Driver imx-spdif used instead the dummy codec and a pair of
  boolean properties, "spdif-in" and "spdif-out".

While backward compatibility is kept to support properties
"spdif-controller", "spdif-in" and "spdif-out", using new properties has
several benefits:
* "audio-cpu" and "audio-codec" are more generic names reflecting
  that the fsl-asoc-card driver supports multiple hardware.
  They are properties already used by devices using the
  fsl-asoc-card driver.
  They are also similar to properties of simple-card: "cpu" and "codec".
* "spdif-in" and "spdif-out" imply the use of the dummy codec in the
  driver. However, there are already two codec drivers for the S/PDIF,
  spdif_transmitter and spdif_receiver.
  It is better to declare S/PDIF Tx and Rx devices in a DT, and then
  reference them with "audio-codec" than using the dummy codec.

For those reasons, this commit updates in-tree DTs to use the new
properties:
* Rename "spdif-controller" property to "audio-cpu".
* Declare S/PDIF transmitter and/or receiver devices, and use them with
  the "audio-codec" property instead of "spdif-out" and/or "spdif-in".

These modifications were tested only on an imx8mn-evk board.

Note that out-of-tree and old DTs are still supported.

Signed-off-by: Elinor Montmasson 
---
 arch/arm64/boot/dts/freescale/imx8mm-evk.dtsi | 15 +---
 arch/arm64/boot/dts/freescale/imx8mn-evk.dtsi | 15 +---
 arch/arm64/boot/dts/freescale/imx8mq-evk.dts  | 24 +++
 3 files changed, 43 insertions(+), 11 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mm-evk.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mm-evk.dtsi
index 90d1901df2b1..348855a41852 100644
--- a/arch/arm64/boot/dts/freescale/imx8mm-evk.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mm-evk.dtsi
@@ -180,12 +180,21 @@ cpu {
};
};
 
+   spdif_out: spdif-out {
+   #sound-dai-cells = <0>;
+   compatible = "linux,spdif-dit";
+   };
+
+   spdif_in: spdif-in {
+   #sound-dai-cells = <0>;
+   compatible = "linux,spdif-dir";
+   };
+
sound-spdif {
compatible = "fsl,imx-audio-spdif";
model = "imx-spdif";
-   spdif-controller = <>;
-   spdif-out;
-   spdif-in;
+   audio-cpu = <>;
+   audio-codec = <_out>, <_in>;
};
 };
 
diff --git a/arch/arm64/boot/dts/freescale/imx8mn-evk.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mn-evk.dtsi
index 9e0259ddf4bc..6a47e09703a7 100644
--- a/arch/arm64/boot/dts/freescale/imx8mn-evk.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mn-evk.dtsi
@@ -124,12 +124,21 @@ sound-wm8524 {
"Line Out Jack", "LINEVOUTR";
};
 
+   spdif_out: spdif-out {
+   #sound-dai-cells = <0>;
+   compatible = "linux,spdif-dit";
+   };
+
+   spdif_in: spdif-in {
+   #sound-dai-cells = <0>;
+   compatible = "linux,spdif-dir";
+   };
+
sound-spdif {
compatible = "fsl,imx-audio-spdif";
model = "imx-spdif";
-   spdif-controller = <>;
-   spdif-out;
-   spdif-in;
+   audio-cpu = <>;
+   audio-codec = <_out>, <_in>;
};
 
sound-micfil {
diff --git a/arch/arm64/boot/dts/freescale/imx8mq-evk.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-evk.dts
index 7507548cdb16..b953865f0b46 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-evk.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-evk.dts
@@ -125,19 +125,33 @@ link_codec: simple-audio-card,codec {
};
};
 
+   spdif_out: spdif-out {
+   #sound-dai-cells = <0>;
+   compatible = "linux,spdif-dit";
+   };
+
+   spdif_in: spdif-in {
+   #sound-dai-cells = <0>;
+   compatible = "linux,spdif-dir";
+   };
+
sound-spdif {
compatible = "fsl,imx-audio-spdif";
model = "imx-spdif";
-   spdif-controller = <>;
-   spdif-out;
-   spdif-in;
+   audio-cpu = <>;
+   audio-codec = <_out>, <_in>;
+   };
+
+   hdmi_arc_in: hdmi-arc-in {
+   #sound-dai-cells = <0>;
+   compatible = "linux,spdif-dir";
};
 
sound-hdmi-arc {
compatible = "fsl,imx-audio-spdif";
model = "imx-hdmi-arc";
-   spdif-controller = <>;
-   spdif-in;
+   audio-cpu = <>;
+   

[PATCH v6 5/7] ASoC: dt-bindings: update fsl-asoc-card bindings after imx-spdif merge

2024-06-27 Thread Elinor Montmasson
The S/PDIF audio card support with compatible "fsl,imx-audio-spdif"
was merged from imx-spdif into the fsl-asoc-card driver.
It makes possible to use an S/PDIF with an ASRC.

This merge introduces new DT bindings to use with compatible
"fsl,imx-audio-spdif" to follow the way fsl-asoc-card works:
* the "spdif-controller" property from imx-spdif is named "audio-cpu"
  in fsl-asoc-card.
* fsl-asoc-card uses codecs explicitly declared in DT
  with "audio-codec".
  With an SPDIF, codec drivers spdif_transmitter and
  spdif_receiver should be used.
  Driver imx-spdif used instead the dummy codec and a pair of
  boolean properties, "spdif-in" and "spdif-out".

In an upcoming commit, in-tree DTs will be modified to follow these new
properties:
* Property "spdif-controller" will be renamed "audio-cpu".
* spdif_transmitter and spdif_receiver nodes will be declared
  and linked to the fsl-asoc-card node with the property "audio-codec".

To keep backward compatibility with other DTs, support for
"spdif-controller", "spdif-in" and "spdif-out" properties is kept.
However, it is recommended to use the new properties if possible.
It is better to declare transmitter and/or receiver
in DT than using the dummy codec.

DTs using compatible "fsl,imx-audio-spdif" are still supported, and
fsl-asoc-card will behave the same as imx-spdif for these DTs.

Signed-off-by: Elinor Montmasson 
---
 .../bindings/sound/fsl,imx-audio-spdif.yaml   | 66 ---
 .../bindings/sound/fsl-asoc-card.yaml | 53 +--
 2 files changed, 49 insertions(+), 70 deletions(-)
 delete mode 100644 
Documentation/devicetree/bindings/sound/fsl,imx-audio-spdif.yaml

diff --git a/Documentation/devicetree/bindings/sound/fsl,imx-audio-spdif.yaml 
b/Documentation/devicetree/bindings/sound/fsl,imx-audio-spdif.yaml
deleted file mode 100644
index 5fc543d02ecb..
--- a/Documentation/devicetree/bindings/sound/fsl,imx-audio-spdif.yaml
+++ /dev/null
@@ -1,66 +0,0 @@
-# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
-%YAML 1.2

-$id: http://devicetree.org/schemas/sound/fsl,imx-audio-spdif.yaml#
-$schema: http://devicetree.org/meta-schemas/core.yaml#
-
-title: Freescale i.MX audio complex with S/PDIF transceiver
-
-maintainers:
-  - Shengjiu Wang 
-
-properties:
-  compatible:
-oneOf:
-  - items:
-  - enum:
-  - fsl,imx-sabreauto-spdif
-  - fsl,imx6sx-sdb-spdif
-  - const: fsl,imx-audio-spdif
-  - enum:
-  - fsl,imx-audio-spdif
-
-  model:
-$ref: /schemas/types.yaml#/definitions/string
-description: User specified audio sound card name
-
-  spdif-controller:
-$ref: /schemas/types.yaml#/definitions/phandle
-description: The phandle of the i.MX S/PDIF controller
-
-  spdif-out:
-type: boolean
-description:
-  If present, the transmitting function of S/PDIF will be enabled,
-  indicating there's a physical S/PDIF out connector or jack on the
-  board or it's connecting to some other IP block, such as an HDMI
-  encoder or display-controller.
-
-  spdif-in:
-type: boolean
-description:
-  If present, the receiving function of S/PDIF will be enabled,
-  indicating there is a physical S/PDIF in connector/jack on the board.
-
-required:
-  - compatible
-  - model
-  - spdif-controller
-
-anyOf:
-  - required:
-  - spdif-in
-  - required:
-  - spdif-out
-
-additionalProperties: false
-
-examples:
-  - |
-sound-spdif {
-compatible = "fsl,imx-audio-spdif";
-model = "imx-spdif";
-spdif-controller = <>;
-spdif-out;
-spdif-in;
-};
diff --git a/Documentation/devicetree/bindings/sound/fsl-asoc-card.yaml 
b/Documentation/devicetree/bindings/sound/fsl-asoc-card.yaml
index 9922664d5ccc..92aa47ec72c7 100644
--- a/Documentation/devicetree/bindings/sound/fsl-asoc-card.yaml
+++ b/Documentation/devicetree/bindings/sound/fsl-asoc-card.yaml
@@ -65,6 +65,11 @@ properties:
   - fsl,imx-audio-sgtl5000
   - fsl,imx-audio-wm8960
   - fsl,imx-audio-wm8962
+  - items:
+  - enum:
+  - fsl,imx-sabreauto-spdif
+  - fsl,imx6sx-sdb-spdif
+  - const: fsl,imx-audio-spdif
   - items:
   - enum:
   - fsl,imx-audio-ac97
@@ -81,6 +86,7 @@ properties:
   - fsl,imx-audio-wm8960
   - fsl,imx-audio-wm8962
   - fsl,imx-audio-wm8958
+  - fsl,imx-audio-spdif
 
   model:
 $ref: /schemas/types.yaml#/definitions/string
@@ -93,8 +99,15 @@ properties:
   need to add ASRC support via DPCM.
 
   audio-codec:
-$ref: /schemas/types.yaml#/definitions/phandle
-description: The phandle of an audio codec
+$ref: /schemas/types.yaml#/definitions/phandle-array
+description: |
+  The phandle of an audio codec.
+  With "fsl,imx-audio-spdif", either SPDIF audio codec spdif_transmitter,
+  spdif_receiver or both.
+minItems: 1
+

[PATCH v6 4/7] ASoC: fsl-asoc-card: merge spdif support from imx-spdif.c

2024-06-27 Thread Elinor Montmasson
The imx-spdif machine driver creates audio card to directly use an
S/PDIF device. However, it doesn't support interacting with an ASRC.
fsl-asoc-card already has the support to create audio card which can
use the ASRC.

Merge the S/PDIF support from imx-spdif into driver fsl-asoc-card
to extend the support of S/PDIF audio card with the use of ASRC devices.

fsl-asoc-card uses slightly different DT properties than imx-spdif:
* the "spdif-controller" property from imx-spdif is named "audio-cpu" in
  fsl-asoc-card.
* fsl-asoc-card uses codecs explicitly declared in DT
  with "audio-codec".
  With an SPDIF, codec drivers spdif_transmitter and
  spdif_receiver should be used.
  Driver imx-spdif used instead the dummy codec and a pair of
  boolean properties, "spdif-in" and "spdif-out".

To keep backward compatibility, support for "spdif-controller",
"spdif-in" and "spdif-out" is also added to fsl-asoc-card.
However, it is recommended to use the new properties if possible.
It is better to declare transmitter and/or receiver in DT
than using the dummy codec.

DTs using compatible "fsl,imx-audio-spdif" are still compatible, and
fsl-asoc-card will behave the same as imx-spdif
for these DTs.

Signed-off-by: Elinor Montmasson 
---
 arch/arm/configs/imx_v6_v7_defconfig |   1 -
 arch/arm64/configs/defconfig |   1 -
 sound/soc/fsl/Kconfig|  10 +--
 sound/soc/fsl/Makefile   |   2 -
 sound/soc/fsl/fsl-asoc-card.c|  85 +-
 sound/soc/fsl/imx-spdif.c| 103 ---
 6 files changed, 84 insertions(+), 118 deletions(-)
 delete mode 100644 sound/soc/fsl/imx-spdif.c

diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
b/arch/arm/configs/imx_v6_v7_defconfig
index cf2480dce285..ac5ae621b2af 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -311,7 +311,6 @@ CONFIG_SND_IMX_SOC=y
 CONFIG_SND_SOC_EUKREA_TLV320=y
 CONFIG_SND_SOC_IMX_ES8328=y
 CONFIG_SND_SOC_IMX_SGTL5000=y
-CONFIG_SND_SOC_IMX_SPDIF=y
 CONFIG_SND_SOC_FSL_ASOC_CARD=y
 CONFIG_SND_SOC_AC97_CODEC=y
 CONFIG_SND_SOC_CS42XX8_I2C=y
diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 57a9abe78ee4..a6c9688fee0e 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -940,7 +940,6 @@ CONFIG_SND_SOC_FSL_MICFIL=m
 CONFIG_SND_SOC_FSL_EASRC=m
 CONFIG_SND_IMX_SOC=m
 CONFIG_SND_SOC_IMX_SGTL5000=m
-CONFIG_SND_SOC_IMX_SPDIF=m
 CONFIG_SND_SOC_FSL_ASOC_CARD=m
 CONFIG_SND_SOC_IMX_AUDMIX=m
 CONFIG_SND_SOC_MT8183=m
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index 9a371d4496c2..e3b2bfb016c8 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -296,15 +296,6 @@ config SND_SOC_IMX_SGTL5000
  SND_SOC_FSL_ASOC_CARD and SND_SOC_SGTL5000 to use the newer
  driver.
 
-config SND_SOC_IMX_SPDIF
-   tristate "SoC Audio support for i.MX boards with S/PDIF"
-   select SND_SOC_IMX_PCM_DMA
-   select SND_SOC_FSL_SPDIF
-   help
- SoC Audio support for i.MX boards with S/PDIF
- Say Y if you want to add support for SoC audio on an i.MX board with
- a S/DPDIF.
-
 config SND_SOC_FSL_ASOC_CARD
tristate "Generic ASoC Sound Card with ASRC support"
depends on OF && I2C
@@ -316,6 +307,7 @@ config SND_SOC_FSL_ASOC_CARD
select SND_SOC_FSL_ESAI
select SND_SOC_FSL_SAI
select SND_SOC_FSL_SSI
+   select SND_SOC_FSL_SPDIF
select SND_SOC_TLV320AIC31XX
select SND_SOC_WM8994
select MFD_WM8994
diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile
index 2fe78eed3a48..1ae181b24a88 100644
--- a/sound/soc/fsl/Makefile
+++ b/sound/soc/fsl/Makefile
@@ -65,7 +65,6 @@ obj-$(CONFIG_SND_SOC_IMX_PCM_RPMSG) += imx-pcm-rpmsg.o
 snd-soc-eukrea-tlv320-y := eukrea-tlv320.o
 snd-soc-imx-es8328-y := imx-es8328.o
 snd-soc-imx-sgtl5000-y := imx-sgtl5000.o
-snd-soc-imx-spdif-y := imx-spdif.o
 snd-soc-imx-audmix-y := imx-audmix.o
 snd-soc-imx-hdmi-y := imx-hdmi.o
 snd-soc-imx-rpmsg-y := imx-rpmsg.o
@@ -74,7 +73,6 @@ snd-soc-imx-card-y := imx-card.o
 obj-$(CONFIG_SND_SOC_EUKREA_TLV320) += snd-soc-eukrea-tlv320.o
 obj-$(CONFIG_SND_SOC_IMX_ES8328) += snd-soc-imx-es8328.o
 obj-$(CONFIG_SND_SOC_IMX_SGTL5000) += snd-soc-imx-sgtl5000.o
-obj-$(CONFIG_SND_SOC_IMX_SPDIF) += snd-soc-imx-spdif.o
 obj-$(CONFIG_SND_SOC_IMX_AUDMIX) += snd-soc-imx-audmix.o
 obj-$(CONFIG_SND_SOC_IMX_HDMI) += snd-soc-imx-hdmi.o
 obj-$(CONFIG_SND_SOC_IMX_RPMSG) += snd-soc-imx-rpmsg.o
diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index 87329731e02d..82df887b3af5 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -477,6 +477,75 @@ static int fsl_asoc_card_audmux_init(struct device_node 
*np,
return 0;
 }
 
+static int fsl_asoc_card_spdif_init(struct device_node *codec_np[],
+   struct device_node *cpu_np,
+   const 

[PATCH v6 3/7] ASoC: fsl-asoc-card: add compatibility to use 2 codecs in dai-links

2024-06-27 Thread Elinor Montmasson
Adapt the driver to work with configurations using two codecs or more.
Modify fsl_asoc_card_probe() to handle use cases where 2 codecs are
given in the device tree.
This will be needed to add support for the SPDIF.

Use cases using one codec will ignore any given codecs other than the
first.

Co-developed-by: Philip-Dylan Gleonec 

Signed-off-by: Philip-Dylan Gleonec 
Signed-off-by: Elinor Montmasson 
---
 sound/soc/fsl/fsl-asoc-card.c | 279 --
 1 file changed, 161 insertions(+), 118 deletions(-)

diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index 805e2030bde4..87329731e02d 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -99,7 +99,7 @@ struct fsl_asoc_card_priv {
struct simple_util_jack hp_jack;
struct simple_util_jack mic_jack;
struct platform_device *pdev;
-   struct codec_priv codec_priv;
+   struct codec_priv codec_priv[2];
struct cpu_priv cpu_priv;
struct snd_soc_card card;
u8 streams;
@@ -172,10 +172,12 @@ static int fsl_asoc_card_hw_params(struct 
snd_pcm_substream *substream,
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct fsl_asoc_card_priv *priv = snd_soc_card_get_drvdata(rtd->card);
bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
-   struct codec_priv *codec_priv = >codec_priv;
+   struct codec_priv *codec_priv;
+   struct snd_soc_dai *codec_dai;
struct cpu_priv *cpu_priv = >cpu_priv;
struct device *dev = rtd->card->dev;
unsigned int pll_out;
+   int codec_idx;
int ret;
 
priv->sample_rate = params_rate(params);
@@ -208,28 +210,32 @@ static int fsl_asoc_card_hw_params(struct 
snd_pcm_substream *substream,
}
 
/* Specific configuration for PLL */
-   if (codec_priv->pll_id >= 0 && codec_priv->fll_id >= 0) {
-   if (priv->sample_format == SNDRV_PCM_FORMAT_S24_LE)
-   pll_out = priv->sample_rate * 384;
-   else
-   pll_out = priv->sample_rate * 256;
+   for_each_rtd_codec_dais(rtd, codec_idx, codec_dai) {
+   codec_priv = >codec_priv[codec_idx];
 
-   ret = snd_soc_dai_set_pll(snd_soc_rtd_to_codec(rtd, 0),
- codec_priv->pll_id,
- codec_priv->mclk_id,
- codec_priv->mclk_freq, pll_out);
-   if (ret) {
-   dev_err(dev, "failed to start FLL: %d\n", ret);
-   goto fail;
-   }
+   if (codec_priv->pll_id >= 0 && codec_priv->fll_id >= 0) {
+   if (priv->sample_format == SNDRV_PCM_FORMAT_S24_LE)
+   pll_out = priv->sample_rate * 384;
+   else
+   pll_out = priv->sample_rate * 256;
 
-   ret = snd_soc_dai_set_sysclk(snd_soc_rtd_to_codec(rtd, 0),
-codec_priv->fll_id,
-pll_out, SND_SOC_CLOCK_IN);
+   ret = snd_soc_dai_set_pll(codec_dai,
+   codec_priv->pll_id,
+   codec_priv->mclk_id,
+   codec_priv->mclk_freq, pll_out);
+   if (ret) {
+   dev_err(dev, "failed to start FLL: %d\n", ret);
+   goto fail;
+   }
 
-   if (ret && ret != -ENOTSUPP) {
-   dev_err(dev, "failed to set SYSCLK: %d\n", ret);
-   goto fail;
+   ret = snd_soc_dai_set_sysclk(codec_dai,
+   codec_priv->fll_id,
+   pll_out, SND_SOC_CLOCK_IN);
+
+   if (ret && ret != -ENOTSUPP) {
+   dev_err(dev, "failed to set SYSCLK: %d\n", ret);
+   goto fail;
+   }
}
}
 
@@ -244,28 +250,34 @@ static int fsl_asoc_card_hw_free(struct snd_pcm_substream 
*substream)
 {
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct fsl_asoc_card_priv *priv = snd_soc_card_get_drvdata(rtd->card);
-   struct codec_priv *codec_priv = >codec_priv;
+   struct codec_priv *codec_priv;
+   struct snd_soc_dai *codec_dai;
struct device *dev = rtd->card->dev;
+   int codec_idx;
int ret;
 
priv->streams &= ~BIT(substream->stream);
 
-   if (!priv->streams && codec_priv->pll_id >= 0 && codec_priv->fll_id >= 
0) {
-   /* Force freq to be free_freq to avoid error message in codec */
-   ret = 

[PATCH v6 2/7] ASoC: fsl-asoc-card: add second dai link component for codecs

2024-06-27 Thread Elinor Montmasson
Add a second dai link component for codecs that will be used for use
cases with 2 codecs.
It is needed for future integration of the SPDIF support, which will
use spdif_receiver and spdif_transmitter drivers.

To prevent deferring in use cases using only one codec, also set
by default the number of codecs to 1 for the relevant dai links.

Co-developed-by: Philip-Dylan Gleonec 

Signed-off-by: Philip-Dylan Gleonec 
Signed-off-by: Elinor Montmasson 
---
 sound/soc/fsl/fsl-asoc-card.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index e8003fbc8092..805e2030bde4 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -296,7 +296,7 @@ static int be_hw_params_fixup(struct snd_soc_pcm_runtime 
*rtd,
 
 SND_SOC_DAILINK_DEFS(hifi,
DAILINK_COMP_ARRAY(COMP_EMPTY()),
-   DAILINK_COMP_ARRAY(COMP_EMPTY()),
+   DAILINK_COMP_ARRAY(COMP_EMPTY(), COMP_EMPTY()),
DAILINK_COMP_ARRAY(COMP_EMPTY()));
 
 SND_SOC_DAILINK_DEFS(hifi_fe,
@@ -306,7 +306,7 @@ SND_SOC_DAILINK_DEFS(hifi_fe,
 
 SND_SOC_DAILINK_DEFS(hifi_be,
DAILINK_COMP_ARRAY(COMP_EMPTY()),
-   DAILINK_COMP_ARRAY(COMP_EMPTY()));
+   DAILINK_COMP_ARRAY(COMP_EMPTY(), COMP_EMPTY()));
 
 static const struct snd_soc_dai_link fsl_asoc_card_dai[] = {
/* Default ASoC DAI Link*/
@@ -622,6 +622,8 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
 
memcpy(priv->dai_link, fsl_asoc_card_dai,
   sizeof(struct snd_soc_dai_link) * ARRAY_SIZE(priv->dai_link));
+   priv->dai_link[0].num_codecs = 1;
+   priv->dai_link[2].num_codecs = 1;
 
priv->card.dapm_routes = audio_map;
priv->card.num_dapm_routes = ARRAY_SIZE(audio_map);
-- 
2.34.1



[PATCH v6 1/7] ASoC: fsl-asoc-card: add support for dai links with multiple codecs

2024-06-27 Thread Elinor Montmasson
Add support for dai links using multiple codecs for multi-codec
use cases.

Co-developed-by: Philip-Dylan Gleonec 

Signed-off-by: Philip-Dylan Gleonec 
Signed-off-by: Elinor Montmasson 
---
 sound/soc/fsl/fsl-asoc-card.c | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index eb67689dcd6e..e8003fbc8092 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -542,6 +542,7 @@ static int fsl_asoc_card_late_probe(struct snd_soc_card 
*card)
 static int fsl_asoc_card_probe(struct platform_device *pdev)
 {
struct device_node *cpu_np, *codec_np, *asrc_np;
+   struct snd_soc_dai_link_component *codec_comp;
struct device_node *np = pdev->dev.of_node;
struct platform_device *asrc_pdev = NULL;
struct device_node *bitclkprovider = NULL;
@@ -552,6 +553,7 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
const char *codec_dai_name;
const char *codec_dev_name;
u32 asrc_fmt = 0;
+   int codec_idx;
u32 width;
int ret;
 
@@ -816,10 +818,10 @@ static int fsl_asoc_card_probe(struct platform_device 
*pdev)
 
/* Normal DAI Link */
priv->dai_link[0].cpus->of_node = cpu_np;
-   priv->dai_link[0].codecs->dai_name = codec_dai_name;
+   priv->dai_link[0].codecs[0].dai_name = codec_dai_name;
 
if (!fsl_asoc_card_is_ac97(priv))
-   priv->dai_link[0].codecs->of_node = codec_np;
+   priv->dai_link[0].codecs[0].of_node = codec_np;
else {
u32 idx;
 
@@ -830,11 +832,11 @@ static int fsl_asoc_card_probe(struct platform_device 
*pdev)
goto asrc_fail;
}
 
-   priv->dai_link[0].codecs->name =
+   priv->dai_link[0].codecs[0].name =
devm_kasprintf(>dev, GFP_KERNEL,
   "ac97-codec.%u",
   (unsigned int)idx);
-   if (!priv->dai_link[0].codecs->name) {
+   if (!priv->dai_link[0].codecs[0].name) {
ret = -ENOMEM;
goto asrc_fail;
}
@@ -848,10 +850,11 @@ static int fsl_asoc_card_probe(struct platform_device 
*pdev)
/* DPCM DAI Links only if ASRC exists */
priv->dai_link[1].cpus->of_node = asrc_np;
priv->dai_link[1].platforms->of_node = asrc_np;
-   priv->dai_link[2].codecs->dai_name = codec_dai_name;
-   priv->dai_link[2].codecs->of_node = codec_np;
-   priv->dai_link[2].codecs->name =
-   priv->dai_link[0].codecs->name;
+   for_each_link_codecs((&(priv->dai_link[2])), codec_idx, 
codec_comp) {
+   codec_comp->dai_name = 
priv->dai_link[0].codecs[codec_idx].dai_name;
+   codec_comp->of_node = 
priv->dai_link[0].codecs[codec_idx].of_node;
+   codec_comp->name = 
priv->dai_link[0].codecs[codec_idx].name;
+   }
priv->dai_link[2].cpus->of_node = cpu_np;
priv->dai_link[2].dai_fmt = priv->dai_fmt;
priv->card.num_links = 3;
-- 
2.34.1



[PATCH v6 0/7] ASoC: fsl-asoc-card: add S/PDIF controller support

2024-06-27 Thread Elinor Montmasson
Hello,

This is the v6 of the series of patches aiming to make the machine
driver `fsl-asoc-card` compatible with S/PDIF controllers on imx boards.
The main goal is to allow the use of S/PDIF controllers with ASRC
modules.

The `imx-spdif` machine driver already has specific support for S/PDIF
controllers but doesn't support using an ASRC with it. However, the
`fsl-asoc-card` machine driver has the necessary code to create a sound
card which can use an ASRC module.
It is then possible to extend the support for S/PDIF audio cards by
merging the `imx-spdif` driver into `fsl-asoc-card`.

The first three patches adapt the `fsl-asoc-card` driver to support
multiple codec use cases.
The driver can get 2 codec phandles from the device tree, and
codec-related variables are doubled.
`for_each_codecs` macros are also used when possible to ease adding
other multi-codec use cases in the future.
It makes possible to use the two S/PDIF dummy codec drivers
`spdif_receiver` and `spdif_transmitter` instead of `snd-soc-dummy`,
which was used in `imx-spdif`.

The fourth patch merges the S/PDIF support from `imx-spdif` to
`fsl-asoc-card`.
`fsl-asoc-card` offers the same functionalities as `imx-spdif` did, but
this merge also extends the S/PDIF support with the possibility of using
an ASRC.
Compatible "fsl,imx-audio-spdif" is kept, but `fsl-asoc-card` uses
different DT properties compared to `imx-spdif`:
* The "spdif-controller" property from `imx-spdif` is named "audio-cpu"
  in `fsl-asoc-card`.
* `fsl-asoc-card` uses codecs explicitly declared in DT with
  "audio-codec". With an S/PDIF, codec drivers `spdif_transmitter` and
  `spdif_receiver` should be used. Driver `imx-spdif` used instead the
  dummy codec and a pair of boolean properties, "spdif-in" and
  "spdif-out".
Backward compatibility is therefore implemented in `fsl-asoc-card`.
However, it is recommended to use the new properties when needed.
Especially, declaring and using S/PDIF transmitter and/or receiver nodes
is better than using the dummy codec.

The last three patches update the device tree bindings of
`fsl-asoc-card` and update all in-tree device trees to use the
`fsl-asoc-card` properties.
Note that as the old properties are still supported:
* previous versions of in-tree device trees are still supported.
* out-of-tree device trees are still supported.

This series of patches was successfully built for arm64 and x86 on top
of the latest??"for-next" branch of the ASoC git tree on the 26th of June
2024.
These modifications have also been tested on an i.MX8MN evaluation board
with a linux kernel RT v6.1.26-rt8.

If you have any questions or remarks about these commits, don't hesitate
to reply to this message.

Best regards,
Elinor Montmasson


Changelog:
v5 -> v6:
* Remove applied patch "ASoC: fsl-asoc-card: set priv->pdev before using
  it".
* Add backward compatibility with `imx-spdif` DT properties.
* Squash removal of `imx-spdif.yaml` into patch updating
  `fsl-asoc-card.yaml`.
* `fsl-asoc-card.yaml`: fix indentation, document use of compatible
  "fsl,imx-audio-spdif" only with "fsl,imx-sabreauto-spdif" or
  "fsl,imx6sx-sdb-spdif".
* Explain better in commit messages why there are new DT properties that
  can be used with "fsl,imx-audio-spdif" and what are the benefits to
  use them. 
* v5 patch series at :
https://lore.kernel.org/all/20240620132511.4291-1-elinor.montmas...@savoirfairelinux.com/

v4 -> v5:
* Focus the contribution to bringing S/PDIF / ASRC support.
* Instead of creating a new compatible for the S/PDIF `fsl-asoc-card`
  support, merge the driver `imx-spdif` into `fsl-asoc-card`, and keep
  the compatible. It preserves the base S/PDIF audio card support but also
  extends it with the possibility to use an ASRC. It also reduces code and
  driver duplication.
* Following driver merge, adapt device trees using "fsl,imx-audio-spdif"
  compatible. 
* Use more `for_each_codecs` macros in `fsl-asoc-card` when adding
  multi-codec support.
* Remove patches about new device-tree bindings that were not relevant
  for an S/PDIF specific support.
* Improve DT schema changes.
* Move `priv->pdev` assignment earlier in "fsl_asoc_card_probe()" to fix
  a NULL pointer dereference in "fsl_asoc_card_audmux_init()".
* v4 patch series at :
https://lore.kernel.org/all/20240515135411.34-1-elinor.montmas...@savoirfairelinux.com/

v3 -> v4:
* Use the standard TDM bidings, as defined in "tdm-slot.txt", for the
  new optional DT bindings setting the TDM slots number and width.
* Use the clock DT bindings to optionally specify the CPU DAI system
  clock frequency, instead of a dedicated new binding.
* Rename the new DT binding "cpu-sysclk-dir-out" to
  "cpu-system-clock-direction-out" to better follow the style of the
  simple-card driver.
* Merge TX an RX bindings for CPU DAI system-clock, to better follow the
  style of the simple-card driver, and also as there was no use case in
  fsl-asoc-card where TX and RX settings had to be different.
* Add the 

Re: [PATCH] printk: Add a short description string to kmsg_dump()

2024-06-27 Thread Jocelyn Falempe




On 26/06/2024 10:00, Petr Mladek wrote:

On Tue 2024-06-25 14:39:29, Jocelyn Falempe wrote:

kmsg_dump doesn't forward the panic reason string to the kmsg_dumper
callback.
This patch adds a new parameter "const char *desc" to the kmsg_dumper
dump() callback, and update all drivers that are using it.

To avoid updating all kmsg_dump() call, it adds a kmsg_dump_desc()
function and a macro for backward compatibility.

I've written this for drm_panic, but it can be useful for other
kmsg_dumper.
It allows to see the panic reason, like "sysrq triggered crash"
or "VFS: Unable to mount root fs on " on the drm panic screen.

Signed-off-by: Jocelyn Falempe 
---
  arch/powerpc/kernel/nvram_64.c |  3 ++-
  arch/powerpc/platforms/powernv/opal-kmsg.c |  3 ++-
  drivers/gpu/drm/drm_panic.c|  3 ++-
  drivers/hv/hv_common.c |  3 ++-
  drivers/mtd/mtdoops.c  |  3 ++-
  fs/pstore/platform.c   |  3 ++-
  include/linux/kmsg_dump.h  | 13 ++---
  kernel/panic.c |  2 +-
  kernel/printk/printk.c |  8 +---
  9 files changed, 28 insertions(+), 13 deletions(-)


The parameter is added into all dumpers. I guess that it would be
used only drm_panic() because it is graphics and might be "fancy".
The others simply dump the log buffer and the reason is in
the dumped log as well.


Ok, I also tried to retrieve the reason from the dumped log, but that's 
really fragile.




Anyway, the passed buffer is static. Alternative solution would
be to make it global and export it like, for example, panic_cpu.


It's not a static buffer, because the string is generated at runtime.
eg: https://elixir.bootlin.com/linux/latest/source/arch/arm/mm/init.c#L158

So it will be hard to avoid race conditions.



Best Regards,
Petr





Re: [PATCH 00/13] fs/dax: Fix FS DAX page reference counts

2024-06-27 Thread Alistair Popple


Dan Williams  writes:

> Alistair Popple wrote:
>> FS DAX pages have always maintained their own page reference counts
>> without following the normal rules for page reference counting. In
>> particular pages are considered free when the refcount hits one rather
>> than zero and refcounts are not added when mapping the page.
>> 
>> Tracking this requires special PTE bits (PTE_DEVMAP) and a secondary
>> mechanism for allowing GUP to hold references on the page (see
>> get_dev_pagemap). However there doesn't seem to be any reason why FS
>> DAX pages need their own reference counting scheme.
>> 
>> By treating the refcounts on these pages the same way as normal pages
>> we can remove a lot of special checks. In particular pXd_trans_huge()
>> becomes the same as pXd_leaf(), although I haven't made that change
>> here. It also frees up a valuable SW define PTE bit on architectures
>> that have devmap PTE bits defined.
>> 
>> It also almost certainly allows further clean-up of the devmap managed
>> functions, but I have left that as a future improvment.
>> 
>> This is an update to the original RFC rebased onto v6.10-rc5. Unlike
>> the original RFC it passes the same number of ndctl test suite
>> (https://github.com/pmem/ndctl) tests as my current development
>> environment does without these patches.
>
> Are you seeing the 'mmap.sh' test fail even without these patches?

No. But I also don't see it failing with these patches :)

For reference this is what I see on my test machine with or without:

[1/70] Generating version.h with a custom command
 1/13 ndctl:dax / daxdev-errors.sh  SKIP 0.06s   exit 
status 77
 2/13 ndctl:dax / multi-dax.sh  SKIP 0.05s   exit 
status 77
 3/13 ndctl:dax / sub-section.shSKIP 0.14s   exit 
status 77
 4/13 ndctl:dax / dax-dev   OK   0.02s
 5/13 ndctl:dax / dax-ext4.sh   OK  12.97s
 6/13 ndctl:dax / dax-xfs.shOK  12.44s
 7/13 ndctl:dax / device-daxOK  13.40s
 8/13 ndctl:dax / revoke-devmem FAIL 0.31s   (exit 
status 250 or signal 122 SIGinvalid)
>>> TEST_PATH=/home/apopple/ndctl/build/test 
>>> LD_LIBRARY_PATH=/home/apopple/ndctl/build/cxl/lib:/home/apopple/ndctl/build/daxctl/lib:/home/apopple/ndctl/build/ndctl/lib
>>>  NDCTL=/home/apopple/ndctl/build/ndctl/ndctl MALLOC_PERTURB_=227 
>>> DATA_PATH=/home/apopple/ndctl/test 
>>> DAXCTL=/home/apopple/ndctl/build/daxctl/daxctl 
>>> /home/apopple/ndctl/build/test/revoke_devmem

 9/13 ndctl:dax / device-dax-fio.sh OK  32.43s
10/13 ndctl:dax / daxctl-devices.sh SKIP 0.07s   exit 
status 77
11/13 ndctl:dax / daxctl-create.sh  SKIP 0.04s   exit 
status 77
12/13 ndctl:dax / dm.sh FAIL 0.08s   exit 
status 1
>>> MALLOC_PERTURB_=209 TEST_PATH=/home/apopple/ndctl/build/test 
>>> LD_LIBRARY_PATH=/home/apopple/ndctl/build/cxl/lib:/home/apopple/ndctl/build/daxctl/lib:/home/apopple/ndctl/build/ndctl/lib
>>>  NDCTL=/home/apopple/ndctl/build/ndctl/ndctl 
>>> DATA_PATH=/home/apopple/ndctl/test 
>>> DAXCTL=/home/apopple/ndctl/build/daxctl/daxctl 
>>> /home/apopple/ndctl/test/dm.sh

13/13 ndctl:dax / mmap.sh   OK 107.57s

Ok: 6   
Expected Fail:  0   
Fail:   2   
Unexpected Pass:0   
Skipped:5   
Timeout:0   

I have been using QEMU for my testing. Maybe I missed some condition in
the unmap path though so will take another look.

> I see this with the patches, will try without in the morning.
>
>  EXT4-fs (pmem0): unmounting filesystem 26ea1463-343a-464f-9f16-91cb176dbdc7.
>  XFS (pmem0): Mounting V5 Filesystem 554953fd-c9f4-460f-bc37-f43979986b68
>  XFS (pmem0): Ending clean mount
>  Oops: general protection fault, probably for non-canonical address 
> 0xdead0518: 00
> T SMP PTI
>  CPU: 15 PID: 1295 Comm: mmap Tainted: G   OEN 6.10.0-rc5+ #261
>  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 
> edk2-20240524-3.fc40 05/24/2024
>  RIP: 0010:folio_mark_dirty+0x25/0x60
>  Code: 90 90 90 90 90 0f 1f 44 00 00 53 48 89 fb e8 22 18 02 00 48 85 c0 74 
> 26 48 89 c7 48
> 0 02 00 74 05 f0 80 63 02 fd <48> 8b 87 18 01 00 00 48 89 de 5b 48 8b 40 18 
> e9 77 90 c0 00
>  RSP: 0018:b073022f7b08 EFLAGS: 00010246
>  RAX: 00482000 RBX: d0d005000300 RCX: 0440
>  RDX:  RSI: 7f400620 RDI: dead0400
>  RBP:  R08: 9a4b04504a30 R09: 000f
>  R10: d0d005000300 R11:  R12: 7f400620
>  R13: 9a4b7c96c000 R14: 9a4b7daba440 R15: b073022f7cb0
>  FS:  7f4046351740() GS:9a4d7778() knlGS:
>  CS:  0010 DS:  ES:  CR0: 80050033
>  CR2: 7f40461ff000 CR3: 00027aea6000 CR4: 06f0
>  DR0: 

Re: [PATCH 00/13] fs/dax: Fix FS DAX page reference counts

2024-06-27 Thread Dan Williams
Alistair Popple wrote:
> FS DAX pages have always maintained their own page reference counts
> without following the normal rules for page reference counting. In
> particular pages are considered free when the refcount hits one rather
> than zero and refcounts are not added when mapping the page.
> 
> Tracking this requires special PTE bits (PTE_DEVMAP) and a secondary
> mechanism for allowing GUP to hold references on the page (see
> get_dev_pagemap). However there doesn't seem to be any reason why FS
> DAX pages need their own reference counting scheme.
> 
> By treating the refcounts on these pages the same way as normal pages
> we can remove a lot of special checks. In particular pXd_trans_huge()
> becomes the same as pXd_leaf(), although I haven't made that change
> here. It also frees up a valuable SW define PTE bit on architectures
> that have devmap PTE bits defined.
> 
> It also almost certainly allows further clean-up of the devmap managed
> functions, but I have left that as a future improvment.
> 
> This is an update to the original RFC rebased onto v6.10-rc5. Unlike
> the original RFC it passes the same number of ndctl test suite
> (https://github.com/pmem/ndctl) tests as my current development
> environment does without these patches.

Are you seeing the 'mmap.sh' test fail even without these patches?

I see this with the patches, will try without in the morning.

 EXT4-fs (pmem0): unmounting filesystem 26ea1463-343a-464f-9f16-91cb176dbdc7.
 XFS (pmem0): Mounting V5 Filesystem 554953fd-c9f4-460f-bc37-f43979986b68
 XFS (pmem0): Ending clean mount
 Oops: general protection fault, probably for non-canonical address 
0xdead0518: 00
T SMP PTI
 CPU: 15 PID: 1295 Comm: mmap Tainted: G   OEN 6.10.0-rc5+ #261
 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS edk2-20240524-3.fc40 
05/24/2024
 RIP: 0010:folio_mark_dirty+0x25/0x60
 Code: 90 90 90 90 90 0f 1f 44 00 00 53 48 89 fb e8 22 18 02 00 48 85 c0 74 26 
48 89 c7 48
0 02 00 74 05 f0 80 63 02 fd <48> 8b 87 18 01 00 00 48 89 de 5b 48 8b 40 18 e9 
77 90 c0 00
 RSP: 0018:b073022f7b08 EFLAGS: 00010246
 RAX: 00482000 RBX: d0d005000300 RCX: 0440
 RDX:  RSI: 7f400620 RDI: dead0400
 RBP:  R08: 9a4b04504a30 R09: 000f
 R10: d0d005000300 R11:  R12: 7f400620
 R13: 9a4b7c96c000 R14: 9a4b7daba440 R15: b073022f7cb0
 FS:  7f4046351740() GS:9a4d7778() knlGS:
 CS:  0010 DS:  ES:  CR0: 80050033
 CR2: 7f40461ff000 CR3: 00027aea6000 CR4: 06f0
 DR0:  DR1:  DR2: 
 DR3:  DR6: fffe0ff0 DR7: 0400
 Call Trace:
  
  ? __die_body.cold+0x19/0x26
  ? die_addr+0x38/0x60
  ? exc_general_protection+0x143/0x420
  ? asm_exc_general_protection+0x22/0x30
  ? folio_mark_dirty+0x25/0x60
  ? folio_mark_dirty+0xe/0x60
  unmap_page_range+0xea5/0x1550
  unmap_vmas+0xf8/0x1e0
  unmap_region.constprop.0+0xd7/0x150
  ? lock_is_held_type+0xd5/0x130
  do_vmi_align_munmap.isra.0+0x3f4/0x580
  ? mas_walk+0x101/0x1b0
  __vm_munmap+0xa6/0x170
  __x64_sys_munmap+0x17/0x20
  do_syscall_64+0x75/0x190
  entry_SYSCALL_64_after_hwframe+0x76/0x7e

$ faddr2line vmlinux folio_mark_dirty+0x25
folio_mark_dirty+0x25/0x58:
folio_mark_dirty at mm/page-writeback.c:2860


Re: [PATCH 01/13] mm/gup.c: Remove redundant check for PCI P2PDMA page

2024-06-27 Thread Dan Williams
Alistair Popple wrote:
> PCI P2PDMA pages are not mapped with pXX_devmap PTEs therefore the
> check in __gup_device_huge() is redundant. Remove it
> 
> Signed-off-by: Alistair Popple 
> Reviewed-by: Jason Gunthorpe 
> Acked-by: David Hildenbrand 

Acked-by: Dan Williams