Re: [PATCH 1/2] tools/perf/tests: perf all metrics test fails when perf_event access is restricted

2023-08-03 Thread Athira Rajeev



> On 05-Jul-2023, at 11:54 PM, Namhyung Kim  wrote:
> 
> On Mon, Jul 3, 2023 at 10:04 PM Athira Rajeev
>  wrote:
>> 
>> 
>> 
>>> On 15-Jun-2023, at 1:08 PM, Athira Rajeev  
>>> wrote:
>>> 
>>> Perf all metrics test fails as below when perf_event access
>>> is restricted.
>>> 
>>>   ./perf test -v "perf all metrics test"
>>>   Metric 'Memory_RD_BW_Chip' not printed in:
>>>   Error:
>>>   Access to performance monitoring and observability operations is limited.
>>>   Enforced MAC policy settings (SELinux) can limit access to performance
>>>   —
>>>   access to performance monitoring and observability operations for 
>>> processes
>>>   without CAP_PERFMON, CAP_SYS_PTRACE or CAP_SYS_ADMIN Linux capability.
>>>   —
>>>   test child finished with -1
>>>    end 
>>>   perf all metrics test: FAILED!
> 
> In my system, it fails like below:
> 
>  $ ./perf test -v 101
>  101: perf all metrics test   :
>  --- start ---
>  test child forked, pid 398458
>  Testing branch_misprediction_ratio
>  Testing all_remote_links_outbound
>  Metric 'all_remote_links_outbound' not printed in:
>  Error:
>  Invalid event (remote_outbound_data_controller_3:u) in per-thread
> mode, enable system wide with '-a'.
>  Testing nps1_die_to_dram
>  ...
> 
> Thanks,
> Namhyung



Hi Namhyung,

I have posted a V2 for this :
[PATCH V2 1/2] tools/perf/tests: perf all metrics test fails when perf_event 
access is restricted
[PATCH V2 2/2] tools/perf/tests: perf all metricgroups test fails when 
perf_event access is restricted

Please review and test the V2 version, and let me know your feedback.

If any other metric fails even with this fix, that would be an event fail I 
believe and not a test issue.
But looking for your test results with the V2 patchset

Thanks
Athira
> 
>> 
>> 
>> Hi,
>> 
>> Looking for review comments on this patch.
>> 
>> Thanks
>>> 
>>> The perf all metrics test picks the input events from
>>> "perf list --raw-dump metrics" and runs "perf stat -M "$m""
>>> for each of the metrics in the list. It fails here for some
>>> of the metrics which needs access, since it collects system
>>> wide resource details/statistics. Fix the testcase to skip
>>> those metric events.
>>> 
>>> Signed-off-by: Athira Rajeev 
>>> ---
>>> tools/perf/tests/shell/stat_all_metrics.sh | 4 +++-
>>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>> 
>>> diff --git a/tools/perf/tests/shell/stat_all_metrics.sh 
>>> b/tools/perf/tests/shell/stat_all_metrics.sh
>>> index 54774525e18a..14b96484a359 100755
>>> --- a/tools/perf/tests/shell/stat_all_metrics.sh
>>> +++ b/tools/perf/tests/shell/stat_all_metrics.sh
>>> @@ -6,7 +6,9 @@ err=0
>>> for m in $(perf list --raw-dump metrics); do
>>>  echo "Testing $m"
>>>  result=$(perf stat -M "$m" true 2>&1)
>>> -  if [[ "$result" =~ ${m:0:50} ]] || [[ "$result" =~ "" ]]
>>> +  # Skip if there is no access to perf_events monitoring
>>> +  # and observability operations
>>> +  if [[ "$result" =~ ${m:0:50} ]] || [[ "$result" =~ "" ]] 
>>> || [[ "$result" =~ "Access to performance monitoring and observability 
>>> operations is limited" ]]
>>>  then
>>>continue
>>>  fi
>>> --
>>> 2.31.1




[PATCH V2 2/2] tools/perf/tests: perf all metricgroups test fails when perf_event access is restricted

2023-08-03 Thread Athira Rajeev
Perf all metricgroups test fails as below when perf_event access
is restricted.

./perf test -v "perf all metricgroups test"
Testing Memory_BW
Error:
Access to performance monitoring and observability operations is limited.
Enforced MAC policy settings (SELinux) can limit access to performance
access to performance monitoring and observability operations for processes
without CAP_PERFMON, CAP_SYS_PTRACE or CAP_SYS_ADMIN Linux capability.

test child finished with -1
 end 
perf all metricgroups test: FAILED!

Fix the testcase to skip those metric events which needs perf_event access
explicitly. The exit code of the testcase is based on return code of
the perf stat command ( enabled by set -e option ). Hence save the
exit status in a variable and use that to decide success or fail for the
testcase.

Signed-off-by: Athira Rajeev 
---
Changelog:
v1 -> v2:
 Changed the condition to use "echo" and "grep" so it works on
 Posix shell as well.

 tools/perf/tests/shell/stat_all_metricgroups.sh | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/perf/tests/shell/stat_all_metricgroups.sh 
b/tools/perf/tests/shell/stat_all_metricgroups.sh
index cb35e488809a..eaa5e1172294 100755
--- a/tools/perf/tests/shell/stat_all_metricgroups.sh
+++ b/tools/perf/tests/shell/stat_all_metricgroups.sh
@@ -2,11 +2,19 @@
 # perf all metricgroups test
 # SPDX-License-Identifier: GPL-2.0
 
-set -e
-
 for m in $(perf list --raw-dump metricgroups); do
   echo "Testing $m"
-  perf stat -M "$m" -a true
+  result=$(perf stat -M "$m" -a true 2>&1)
+  rc=$?
+  # Skip if there is no access to perf_events monitoring
+  # Otherwise exit based on the return code of perf comamnd.
+  if echo "$result" | grep -q "Access to performance monitoring and 
observability operations is limited";
+  then
+  continue
+  else
+  [ $rc -ne 0 ] && exit $rc
+  fi
+
 done
 
 exit 0
-- 
2.31.1



[PATCH V2 1/2] tools/perf/tests: perf all metrics test fails when perf_event access is restricted

2023-08-03 Thread Athira Rajeev
Perf all metrics test fails as below when perf_event access
is restricted.

   ./perf test -v "perf all metrics test"
   Metric 'Memory_RD_BW_Chip' not printed in:
   Error:
   Access to performance monitoring and observability operations is limited.
   Enforced MAC policy settings (SELinux) can limit access to performance
   —
   access to performance monitoring and observability operations for processes
   without CAP_PERFMON, CAP_SYS_PTRACE or CAP_SYS_ADMIN Linux capability.
   —
   test child finished with -1
    end 
   perf all metrics test: FAILED!

The perf all metrics test picks the input events from
"perf list --raw-dump metrics" and runs "perf stat -M "$m""
for each of the metrics in the list. It fails here for some
of the metrics which needs access, since it collects system
wide resource details/statistics. Fix the testcase to skip
those metric events. The check is added at two places:
- When metric is run for workload monitoring
- when metric is run for system wide.

It could happen that some of the metric events are not valid
in per-thread mode. Example from an x86 system:

$ ./perf stat -M smi_cycles true
Error:
Invalid event (msr/smi/u) in per-thread mode, enable system wide with '-a'.

The test fallbacks to system wide if first stage fails.
But when run with system wide for this metric, it hits the
issue with access restriction.

$ ./perf stat -M smi_cycles -a sleep 0.1
Error:
Access to performance monitoring and observability operations is limited.

Similar some events report not supported while running with system wide.

Example from an x86 system:

   $ ./perf stat -M tma_info_system_socket_clks -a sleep 0.1

   Performance counter stats for 'system wide':

  cbox_0/event=0x0/u

   0.102633747 seconds time elapsed

Hence the checks for unsupported events and access restrictions is
added for both cases.

Signed-off-by: Athira Rajeev 
---
Changelog:
v1 -> v2:
 Added the check for access restriction in workload as
 well as system wide check.

 tools/perf/tests/shell/stat_all_metrics.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/tests/shell/stat_all_metrics.sh 
b/tools/perf/tests/shell/stat_all_metrics.sh
index 54774525e18a..b26420885560 100755
--- a/tools/perf/tests/shell/stat_all_metrics.sh
+++ b/tools/perf/tests/shell/stat_all_metrics.sh
@@ -1,18 +1,18 @@
 #!/bin/bash
 # perf all metrics test
 # SPDX-License-Identifier: GPL-2.0
-
 err=0
+//list="tma_info_system_socket_clks"
 for m in $(perf list --raw-dump metrics); do
   echo "Testing $m"
   result=$(perf stat -M "$m" true 2>&1)
-  if [[ "$result" =~ ${m:0:50} ]] || [[ "$result" =~ "" ]]
+  if [[ "$result" =~ ${m:0:50} ]] || [[ "$result" =~ "" ]] || 
[[ "$result" =~ "Access to performance monitoring and observability operations 
is limited" ]]
   then
 continue
   fi
   # Failed so try system wide.
   result=$(perf stat -M "$m" -a sleep 0.01 2>&1)
-  if [[ "$result" =~ ${m:0:50} ]]
+  if [[ "$result" =~ ${m:0:50} ]] || [[ "$result" =~ "" ]] ||  
[[ "$result" =~ "Access to performance monitoring and observability operations 
is limited" ]]
   then
 continue
   fi
-- 
2.31.1



Re: [PATCH v6 21/38] powerpc: Implement the new page table range API

2023-08-03 Thread Matthew Wilcox
On Thu, Aug 03, 2023 at 04:38:14PM -0700, Nathan Chancellor wrote:
> > -EXPORT_SYMBOL(flush_dcache_icache_page);
> 
> Apologies if this has already been fixed or reported, I searched lore
> and did not find anything. The dropping of this export in combination
> with the conversion above appears to cause ARCH=powerpc allmodconfig to
> fail with:
> 
>   ERROR: modpost: "flush_dcache_icache_folio" [arch/powerpc/kvm/kvm-pr.ko] 
> undefined!
> 
> I don't know if this should be re-exported or not but that does
> obviously resolve the issue.

Well, that was clumsy of me.  I (and the Intel build bot) did test several
build combos, but clearly didn't manage to find a config that showed
this problem.  Andrew, a fix patch for you to integrate, if you would:

diff --git a/arch/powerpc/mm/cacheflush.c b/arch/powerpc/mm/cacheflush.c
index 8760d2223abe..15189592da09 100644
--- a/arch/powerpc/mm/cacheflush.c
+++ b/arch/powerpc/mm/cacheflush.c
@@ -172,6 +172,7 @@ void flush_dcache_icache_folio(struct folio *folio)
flush_dcache_icache_phys((pfn + i) * PAGE_SIZE);
}
 }
+EXPORT_SYMBOL(flush_dcache_icache_folio);
 
 void clear_user_page(void *page, unsigned long vaddr, struct page *pg)
 {


Re: [PATCH v2] syscalls: Cleanup references to sys_lookup_dcookie()

2023-08-03 Thread Sohil Mehta
Hi Arnd,

On 7/10/2023 11:51 AM, Sohil Mehta wrote:
> commit 'be65de6b03aa ("fs: Remove dcookies support")' removed the
> syscall definition for lookup_dcookie.  However, syscall tables still
> point to the old sys_lookup_dcookie() definition. Update syscall tables
> of all architectures to directly point to sys_ni_syscall() instead.
> 
> Signed-off-by: Sohil Mehta 
> Reviewed-by: Randy Dunlap 
> Acked-by: Namhyung Kim  # for perf

The patch has received a couple of additional Acks.

Does this seem like a valuable cleanup? If so, should it go through the
asm-generic tree?

Sohil


[PATCH 2/4] arch/*/configs/*_defconfig cleanup: drop CONFIG_IP_NF_TARGET_CLUSTERIP

2023-08-03 Thread Trevor Woerner
Drop CONFIG_IP_NF_TARGET_CLUSTERIP as it was removed in commit 9db5d918e2c0
("netfilter: ip_tables: remove clusterip target").

Signed-off-by: Trevor Woerner 
---
 arch/arm/configs/keystone_defconfig| 1 -
 arch/arm/configs/omap2plus_defconfig   | 1 -
 arch/loongarch/configs/loongson3_defconfig | 1 -
 arch/mips/configs/ip22_defconfig   | 1 -
 arch/mips/configs/malta_defconfig  | 1 -
 arch/mips/configs/malta_kvm_defconfig  | 1 -
 arch/mips/configs/maltaup_xpa_defconfig| 1 -
 arch/mips/configs/rm200_defconfig  | 1 -
 arch/powerpc/configs/ppc6xx_defconfig  | 1 -
 9 files changed, 9 deletions(-)

diff --git a/arch/arm/configs/keystone_defconfig 
b/arch/arm/configs/keystone_defconfig
index 1cb145633a91..61179b75cf1f 100644
--- a/arch/arm/configs/keystone_defconfig
+++ b/arch/arm/configs/keystone_defconfig
@@ -98,7 +98,6 @@ CONFIG_IP_NF_MATCH_TTL=y
 CONFIG_IP_NF_FILTER=y
 CONFIG_IP_NF_TARGET_REJECT=y
 CONFIG_IP_NF_MANGLE=y
-CONFIG_IP_NF_TARGET_CLUSTERIP=y
 CONFIG_IP_NF_TARGET_ECN=y
 CONFIG_IP_NF_TARGET_TTL=y
 CONFIG_IP_NF_RAW=y
diff --git a/arch/arm/configs/omap2plus_defconfig 
b/arch/arm/configs/omap2plus_defconfig
index a87d7d4001b9..047b625e677f 100644
--- a/arch/arm/configs/omap2plus_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -190,7 +190,6 @@ CONFIG_IP_NF_TARGET_MASQUERADE=m
 CONFIG_IP_NF_TARGET_NETMAP=m
 CONFIG_IP_NF_TARGET_REDIRECT=m
 CONFIG_IP_NF_MANGLE=m
-CONFIG_IP_NF_TARGET_CLUSTERIP=m
 CONFIG_IP_NF_TARGET_ECN=m
 CONFIG_IP_NF_TARGET_TTL=m
 CONFIG_IP_NF_RAW=m
diff --git a/arch/loongarch/configs/loongson3_defconfig 
b/arch/loongarch/configs/loongson3_defconfig
index d64849b4cba1..04665c517c74 100644
--- a/arch/loongarch/configs/loongson3_defconfig
+++ b/arch/loongarch/configs/loongson3_defconfig
@@ -227,7 +227,6 @@ CONFIG_IP_NF_TARGET_MASQUERADE=m
 CONFIG_IP_NF_TARGET_NETMAP=m
 CONFIG_IP_NF_TARGET_REDIRECT=m
 CONFIG_IP_NF_MANGLE=m
-CONFIG_IP_NF_TARGET_CLUSTERIP=m
 CONFIG_IP_NF_TARGET_ECN=m
 CONFIG_IP_NF_TARGET_TTL=m
 CONFIG_IP_NF_RAW=m
diff --git a/arch/mips/configs/ip22_defconfig b/arch/mips/configs/ip22_defconfig
index 44821f497261..dc49b09d492b 100644
--- a/arch/mips/configs/ip22_defconfig
+++ b/arch/mips/configs/ip22_defconfig
@@ -127,7 +127,6 @@ CONFIG_IP_NF_MATCH_TTL=m
 CONFIG_IP_NF_FILTER=m
 CONFIG_IP_NF_TARGET_REJECT=m
 CONFIG_IP_NF_MANGLE=m
-CONFIG_IP_NF_TARGET_CLUSTERIP=m
 CONFIG_IP_NF_TARGET_ECN=m
 CONFIG_IP_NF_TARGET_TTL=m
 CONFIG_IP_NF_RAW=m
diff --git a/arch/mips/configs/malta_defconfig 
b/arch/mips/configs/malta_defconfig
index 743209047792..ae1a7793e810 100644
--- a/arch/mips/configs/malta_defconfig
+++ b/arch/mips/configs/malta_defconfig
@@ -127,7 +127,6 @@ CONFIG_IP_NF_MATCH_TTL=m
 CONFIG_IP_NF_FILTER=m
 CONFIG_IP_NF_TARGET_REJECT=m
 CONFIG_IP_NF_MANGLE=m
-CONFIG_IP_NF_TARGET_CLUSTERIP=m
 CONFIG_IP_NF_TARGET_ECN=m
 CONFIG_IP_NF_TARGET_TTL=m
 CONFIG_IP_NF_RAW=m
diff --git a/arch/mips/configs/malta_kvm_defconfig 
b/arch/mips/configs/malta_kvm_defconfig
index dd2b9c181f32..c07e30f63d8b 100644
--- a/arch/mips/configs/malta_kvm_defconfig
+++ b/arch/mips/configs/malta_kvm_defconfig
@@ -131,7 +131,6 @@ CONFIG_IP_NF_MATCH_TTL=m
 CONFIG_IP_NF_FILTER=m
 CONFIG_IP_NF_TARGET_REJECT=m
 CONFIG_IP_NF_MANGLE=m
-CONFIG_IP_NF_TARGET_CLUSTERIP=m
 CONFIG_IP_NF_TARGET_ECN=m
 CONFIG_IP_NF_TARGET_TTL=m
 CONFIG_IP_NF_RAW=m
diff --git a/arch/mips/configs/maltaup_xpa_defconfig 
b/arch/mips/configs/maltaup_xpa_defconfig
index 97c2d7f530b3..0a5701020d3f 100644
--- a/arch/mips/configs/maltaup_xpa_defconfig
+++ b/arch/mips/configs/maltaup_xpa_defconfig
@@ -128,7 +128,6 @@ CONFIG_IP_NF_MATCH_TTL=m
 CONFIG_IP_NF_FILTER=m
 CONFIG_IP_NF_TARGET_REJECT=m
 CONFIG_IP_NF_MANGLE=m
-CONFIG_IP_NF_TARGET_CLUSTERIP=m
 CONFIG_IP_NF_TARGET_ECN=m
 CONFIG_IP_NF_TARGET_TTL=m
 CONFIG_IP_NF_RAW=m
diff --git a/arch/mips/configs/rm200_defconfig 
b/arch/mips/configs/rm200_defconfig
index e0e312dd968a..5c5e2186210c 100644
--- a/arch/mips/configs/rm200_defconfig
+++ b/arch/mips/configs/rm200_defconfig
@@ -90,7 +90,6 @@ CONFIG_IP_NF_MATCH_TTL=m
 CONFIG_IP_NF_FILTER=m
 CONFIG_IP_NF_TARGET_REJECT=m
 CONFIG_IP_NF_MANGLE=m
-CONFIG_IP_NF_TARGET_CLUSTERIP=m
 CONFIG_IP_NF_TARGET_ECN=m
 CONFIG_IP_NF_TARGET_TTL=m
 CONFIG_IP_NF_RAW=m
diff --git a/arch/powerpc/configs/ppc6xx_defconfig 
b/arch/powerpc/configs/ppc6xx_defconfig
index 1034aeabdd6c..eaf3273372a9 100644
--- a/arch/powerpc/configs/ppc6xx_defconfig
+++ b/arch/powerpc/configs/ppc6xx_defconfig
@@ -183,7 +183,6 @@ CONFIG_IP_NF_MATCH_TTL=m
 CONFIG_IP_NF_FILTER=m
 CONFIG_IP_NF_TARGET_REJECT=m
 CONFIG_IP_NF_MANGLE=m
-CONFIG_IP_NF_TARGET_CLUSTERIP=m
 CONFIG_IP_NF_TARGET_ECN=m
 CONFIG_IP_NF_TARGET_TTL=m
 CONFIG_IP_NF_RAW=m
-- 
2.41.0.327.gaa9166bcc0ba



Re: [RFC PATCH v11 12/29] KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory

2023-08-03 Thread Ryan Afranji
> +static struct folio *kvm_gmem_get_folio(struct file *file, pgoff_t index)
> +{
> + struct folio *folio;
> +
> + /* TODO: Support huge pages. */
> + folio = filemap_grab_folio(file->f_mapping, index);
> + if (!folio)
> + return NULL;

In Linux 6.4, filemap_grab_folio() may also return an error value.
Instead of just checking for NULL, "IS_ERR_OR_NULL(folio)" will be needed.


Re: [RFC PATCH 01/21] crypto: scomp - Revert "add support for deflate rfc1950 (zlib)"

2023-08-03 Thread Giovanni Cabiddu
On Thu, Aug 03, 2023 at 11:59:00AM +0200, Ard Biesheuvel wrote:
> Any clue why zlib_deflate was chosen in this case?
I believe it was done for integrity.
The output of zlib_deflate is raw deflate with an header and a footer
defined in rfc1950. The footer contains a checksum which gets
calculated over the uncompressed data during compression and checked
after decompression.

-- 
Giovanni


Re: [RFC PATCH 01/21] crypto: scomp - Revert "add support for deflate rfc1950 (zlib)"

2023-08-03 Thread Giovanni Cabiddu
Hi Ard,

On Tue, Jul 18, 2023 at 01:58:27PM +0100, Ard Biesheuvel wrote:
> This reverts commit a368f43d6e3a001e684e9191a27df384fbff12f5.
> 
> "zlib-deflate" was introduced 6 years ago, but it does not have any
> users. So let's remove the generic implementation and the test vectors,
> but retain the "zlib-deflate" entry in the testmgr code to avoid
> introducing warning messages on systems that implement zlib-deflate in
> hardware.
> 
> Note that RFC 1950 which forms the basis of this algorithm dates back to
> 1996, and predates RFC 1951, on which the existing IPcomp is based and
> which we have supported in the kernel since 2003. So it seems rather
> unlikely that we will ever grow the need to support zlib-deflate.
> 
> Signed-off-by: Ard Biesheuvel 
Support for zlib-deflate was added for [1] but that work was not
completed.

Based on [2], either we leave this SW implementation or we remove the HW
implementations in the QAT [3] and in the Hisilicon Zip [4] drivers.

[1] 
https://patchwork.kernel.org/project/linux-btrfs/patch/1467083180-111750-1-git-send-email-weigang...@intel.com/
[2] https://lore.kernel.org/lkml/ziw%2fjtxdg6o1o...@gondor.apana.org.au/
[3] 
https://elixir.bootlin.com/linux/latest/source/drivers/crypto/intel/qat/qat_common/qat_comp_algs.c#L457
[4] 
https://elixir.bootlin.com/linux/latest/source/drivers/crypto/hisilicon/zip/zip_crypto.c#L754

Regards,

-- 
Giovanni


Re: [PATCH v3 10/13] mm/khugepaged: collapse_pte_mapped_thp() with mmap_read_lock()

2023-08-03 Thread Qi Zheng

Hi,

On 2023/7/12 12:42, Hugh Dickins wrote:

Bring collapse_and_free_pmd() back into collapse_pte_mapped_thp().
It does need mmap_read_lock(), but it does not need mmap_write_lock(),
nor vma_start_write() nor i_mmap lock nor anon_vma lock.  All racing
paths are relying on pte_offset_map_lock() and pmd_lock(), so use those.

Follow the pattern in retract_page_tables(); and using pte_free_defer()
removes most of the need for tlb_remove_table_sync_one() here; but call
pmdp_get_lockless_sync() to use it in the PAE case.

First check the VMA, in case page tables are being torn down: from JannH.
Confirm the preliminary find_pmd_or_thp_or_none() once page lock has been
acquired and the page looks suitable: from then on its state is stable.

However, collapse_pte_mapped_thp() was doing something others don't:
freeing a page table still containing "valid" entries.  i_mmap lock did
stop a racing truncate from double-freeing those pages, but we prefer
collapse_pte_mapped_thp() to clear the entries as usual.  Their TLB
flush can wait until the pmdp_collapse_flush() which follows, but the
mmu_notifier_invalidate_range_start() has to be done earlier.

Do the "step 1" checking loop without mmu_notifier: it wouldn't be good
for khugepaged to keep on repeatedly invalidating a range which is then
found unsuitable e.g. contains COWs.  "step 2", which does the clearing,
must then be more careful (after dropping ptl to do mmu_notifier), with
abort prepared to correct the accounting like "step 3".  But with those
entries now cleared, "step 4" (after dropping ptl to do pmd_lock) is kept
safe by the huge page lock, which stops new PTEs from being faulted in.

Signed-off-by: Hugh Dickins 
---
  mm/khugepaged.c | 172 ++
  1 file changed, 77 insertions(+), 95 deletions(-)

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 3bb05147961b..46986eb4eebb 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1483,7 +1483,7 @@ static bool khugepaged_add_pte_mapped_thp(struct 
mm_struct *mm,
return ret;
  }
  
-/* hpage must be locked, and mmap_lock must be held in write */

+/* hpage must be locked, and mmap_lock must be held */
  static int set_huge_pmd(struct vm_area_struct *vma, unsigned long addr,
pmd_t *pmdp, struct page *hpage)
  {
@@ -1495,7 +1495,7 @@ static int set_huge_pmd(struct vm_area_struct *vma, 
unsigned long addr,
};
  
  	VM_BUG_ON(!PageTransHuge(hpage));

-   mmap_assert_write_locked(vma->vm_mm);
+   mmap_assert_locked(vma->vm_mm);
  
  	if (do_set_pmd(, hpage))

return SCAN_FAIL;
@@ -1504,48 +1504,6 @@ static int set_huge_pmd(struct vm_area_struct *vma, 
unsigned long addr,
return SCAN_SUCCEED;
  }
  
-/*

- * A note about locking:
- * Trying to take the page table spinlocks would be useless here because those
- * are only used to synchronize:
- *
- *  - modifying terminal entries (ones that point to a data page, not to 
another
- *page table)
- *  - installing *new* non-terminal entries
- *
- * Instead, we need roughly the same kind of protection as free_pgtables() or
- * mm_take_all_locks() (but only for a single VMA):
- * The mmap lock together with this VMA's rmap locks covers all paths towards
- * the page table entries we're messing with here, except for hardware page
- * table walks and lockless_pages_from_mm().
- */
-static void collapse_and_free_pmd(struct mm_struct *mm, struct vm_area_struct 
*vma,
- unsigned long addr, pmd_t *pmdp)
-{
-   pmd_t pmd;
-   struct mmu_notifier_range range;
-
-   mmap_assert_write_locked(mm);
-   if (vma->vm_file)
-   
lockdep_assert_held_write(>vm_file->f_mapping->i_mmap_rwsem);
-   /*
-* All anon_vmas attached to the VMA have the same root and are
-* therefore locked by the same lock.
-*/
-   if (vma->anon_vma)
-   lockdep_assert_held_write(>anon_vma->root->rwsem);
-
-   mmu_notifier_range_init(, MMU_NOTIFY_CLEAR, 0, mm, addr,
-   addr + HPAGE_PMD_SIZE);
-   mmu_notifier_invalidate_range_start();
-   pmd = pmdp_collapse_flush(vma, addr, pmdp);
-   tlb_remove_table_sync_one();
-   mmu_notifier_invalidate_range_end();
-   mm_dec_nr_ptes(mm);
-   page_table_check_pte_clear_range(mm, addr, pmd);
-   pte_free(mm, pmd_pgtable(pmd));
-}
-
  /**
   * collapse_pte_mapped_thp - Try to collapse a pte-mapped THP for mm at
   * address haddr.
@@ -1561,26 +1519,29 @@ static void collapse_and_free_pmd(struct mm_struct *mm, 
struct vm_area_struct *v
  int collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr,
bool install_pmd)
  {
+   struct mmu_notifier_range range;
+   bool notified = false;
unsigned long haddr = addr & HPAGE_PMD_MASK;
struct vm_area_struct *vma = vma_lookup(mm, haddr);
struct page *hpage;
pte_t *start_pte, 

Re: [PATCH v6 21/38] powerpc: Implement the new page table range API

2023-08-03 Thread Nathan Chancellor
Hi Matthew,

On Wed, Aug 02, 2023 at 04:13:49PM +0100, Matthew Wilcox (Oracle) wrote:
> Add set_ptes(), update_mmu_cache_range() and flush_dcache_folio().
> Change the PG_arch_1 (aka PG_dcache_dirty) flag from being per-page to
> per-folio.
> 
> Signed-off-by: Matthew Wilcox (Oracle) 
> Acked-by: Mike Rapoport (IBM) 
> Cc: Michael Ellerman 
> Cc: Nicholas Piggin 
> Cc: Christophe Leroy 
> Cc: linuxppc-dev@lists.ozlabs.org
...
> diff --git a/arch/powerpc/include/asm/kvm_ppc.h 
> b/arch/powerpc/include/asm/kvm_ppc.h
> index d16d80ad2ae4..b4da8514af43 100644
> --- a/arch/powerpc/include/asm/kvm_ppc.h
> +++ b/arch/powerpc/include/asm/kvm_ppc.h
> @@ -894,7 +894,7 @@ void kvmppc_init_lpid(unsigned long nr_lpids);
>  
>  static inline void kvmppc_mmu_flush_icache(kvm_pfn_t pfn)
>  {
> - struct page *page;
> + struct folio *folio;
>   /*
>* We can only access pages that the kernel maps
>* as memory. Bail out for unmapped ones.
> @@ -903,10 +903,10 @@ static inline void kvmppc_mmu_flush_icache(kvm_pfn_t 
> pfn)
>   return;
>  
>   /* Clear i-cache for new pages */
> - page = pfn_to_page(pfn);
> - if (!test_bit(PG_dcache_clean, >flags)) {
> - flush_dcache_icache_page(page);
> - set_bit(PG_dcache_clean, >flags);
> + folio = page_folio(pfn_to_page(pfn));
> + if (!test_bit(PG_dcache_clean, >flags)) {
> + flush_dcache_icache_folio(folio);
> + set_bit(PG_dcache_clean, >flags);
>   }
>  }
...
> diff --git a/arch/powerpc/mm/cacheflush.c b/arch/powerpc/mm/cacheflush.c
> index 0e9b4879c0f9..8760d2223abe 100644
> --- a/arch/powerpc/mm/cacheflush.c
> +++ b/arch/powerpc/mm/cacheflush.c
> @@ -148,44 +148,30 @@ static void __flush_dcache_icache(void *p)
>   invalidate_icache_range(addr, addr + PAGE_SIZE);
>  }
>  
> -static void flush_dcache_icache_hugepage(struct page *page)
> +void flush_dcache_icache_folio(struct folio *folio)
>  {
> - int i;
> - int nr = compound_nr(page);
> + unsigned int i, nr = folio_nr_pages(folio);
>  
> - if (!PageHighMem(page)) {
> + if (flush_coherent_icache())
> + return;
> +
> + if (!folio_test_highmem(folio)) {
> + void *addr = folio_address(folio);
>   for (i = 0; i < nr; i++)
> - __flush_dcache_icache(lowmem_page_address(page + i));
> - } else {
> + __flush_dcache_icache(addr + i * PAGE_SIZE);
> + } else if (IS_ENABLED(CONFIG_BOOKE) || sizeof(phys_addr_t) > 
> sizeof(void *)) {
>   for (i = 0; i < nr; i++) {
> - void *start = kmap_local_page(page + i);
> + void *start = kmap_local_folio(folio, i * PAGE_SIZE);
>  
>   __flush_dcache_icache(start);
>   kunmap_local(start);
>   }
> - }
> -}
> -
> -void flush_dcache_icache_page(struct page *page)
> -{
> - if (flush_coherent_icache())
> - return;
> -
> - if (PageCompound(page))
> - return flush_dcache_icache_hugepage(page);
> -
> - if (!PageHighMem(page)) {
> - __flush_dcache_icache(lowmem_page_address(page));
> - } else if (IS_ENABLED(CONFIG_BOOKE) || sizeof(phys_addr_t) > 
> sizeof(void *)) {
> - void *start = kmap_local_page(page);
> -
> - __flush_dcache_icache(start);
> - kunmap_local(start);
>   } else {
> - flush_dcache_icache_phys(page_to_phys(page));
> + unsigned long pfn = folio_pfn(folio);
> + for (i = 0; i < nr; i++)
> + flush_dcache_icache_phys((pfn + i) * PAGE_SIZE);
>   }
>  }
> -EXPORT_SYMBOL(flush_dcache_icache_page);

Apologies if this has already been fixed or reported, I searched lore
and did not find anything. The dropping of this export in combination
with the conversion above appears to cause ARCH=powerpc allmodconfig to
fail with:

  ERROR: modpost: "flush_dcache_icache_folio" [arch/powerpc/kvm/kvm-pr.ko] 
undefined!

I don't know if this should be re-exported or not but that does
obviously resolve the issue.

Cheers,
Nathan


[PATCH v3 1/2] nmi_backtrace: Allow excluding an arbitrary CPU

2023-08-03 Thread Douglas Anderson
The APIs that allow backtracing across CPUs have always had a way to
exclude the current CPU. This convenience means callers didn't need to
find a place to allocate a CPU mask just to handle the common case.

Let's extend the API to take a CPU ID to exclude instead of just a
boolean. This isn't any more complex for the API to handle and allows
the hardlockup detector to exclude a different CPU (the one it already
did a trace for) without needing to find space for a CPU mask.

Arguably, this new API also encourages safer behavior. Specifically if
the caller wants to avoid tracing the current CPU (maybe because they
already traced the current CPU) this makes it more obvious to the
caller that they need to make sure that the current CPU ID can't
change.

Signed-off-by: Douglas Anderson 
---

Changes in v3:
- ("nmi_backtrace: Allow excluding an arbitrary CPU") new for v3.

 arch/arm/include/asm/irq.h   |  2 +-
 arch/arm/kernel/smp.c|  4 ++--
 arch/loongarch/include/asm/irq.h |  2 +-
 arch/loongarch/kernel/process.c  |  4 ++--
 arch/mips/include/asm/irq.h  |  2 +-
 arch/mips/kernel/process.c   |  4 ++--
 arch/powerpc/include/asm/irq.h   |  2 +-
 arch/powerpc/kernel/stacktrace.c |  4 ++--
 arch/powerpc/kernel/watchdog.c   |  4 ++--
 arch/sparc/include/asm/irq_64.h  |  2 +-
 arch/sparc/kernel/process_64.c   |  6 +++---
 arch/x86/include/asm/irq.h   |  2 +-
 arch/x86/kernel/apic/hw_nmi.c|  4 ++--
 include/linux/nmi.h  | 12 ++--
 kernel/watchdog.c|  2 +-
 lib/nmi_backtrace.c  |  6 +++---
 16 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/arch/arm/include/asm/irq.h b/arch/arm/include/asm/irq.h
index 18605f1b3580..26c1d2ced4ce 100644
--- a/arch/arm/include/asm/irq.h
+++ b/arch/arm/include/asm/irq.h
@@ -32,7 +32,7 @@ void handle_IRQ(unsigned int, struct pt_regs *);
 #include 
 
 extern void arch_trigger_cpumask_backtrace(const cpumask_t *mask,
-  bool exclude_self);
+  int exclude_cpu);
 #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace
 #endif
 
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 6756203e45f3..3431c0553f45 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -846,7 +846,7 @@ static void raise_nmi(cpumask_t *mask)
__ipi_send_mask(ipi_desc[IPI_CPU_BACKTRACE], mask);
 }
 
-void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self)
+void arch_trigger_cpumask_backtrace(const cpumask_t *mask, int exclude_cpu)
 {
-   nmi_trigger_cpumask_backtrace(mask, exclude_self, raise_nmi);
+   nmi_trigger_cpumask_backtrace(mask, exclude_cpu, raise_nmi);
 }
diff --git a/arch/loongarch/include/asm/irq.h b/arch/loongarch/include/asm/irq.h
index a115e8999c69..218b4da0ea90 100644
--- a/arch/loongarch/include/asm/irq.h
+++ b/arch/loongarch/include/asm/irq.h
@@ -40,7 +40,7 @@ void spurious_interrupt(void);
 #define NR_IRQS_LEGACY 16
 
 #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace
-void arch_trigger_cpumask_backtrace(const struct cpumask *mask, bool 
exclude_self);
+void arch_trigger_cpumask_backtrace(const struct cpumask *mask, int 
exclude_cpu);
 
 #define MAX_IO_PICS 2
 #define NR_IRQS(64 + (256 * MAX_IO_PICS))
diff --git a/arch/loongarch/kernel/process.c b/arch/loongarch/kernel/process.c
index 2e04eb07abb6..778e8d09953e 100644
--- a/arch/loongarch/kernel/process.c
+++ b/arch/loongarch/kernel/process.c
@@ -345,9 +345,9 @@ static void raise_backtrace(cpumask_t *mask)
}
 }
 
-void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self)
+void arch_trigger_cpumask_backtrace(const cpumask_t *mask, int exclude_cpu)
 {
-   nmi_trigger_cpumask_backtrace(mask, exclude_self, raise_backtrace);
+   nmi_trigger_cpumask_backtrace(mask, exclude_cpu, raise_backtrace);
 }
 
 #ifdef CONFIG_64BIT
diff --git a/arch/mips/include/asm/irq.h b/arch/mips/include/asm/irq.h
index 75abfa834ab7..3a848e7e69f7 100644
--- a/arch/mips/include/asm/irq.h
+++ b/arch/mips/include/asm/irq.h
@@ -77,7 +77,7 @@ extern int cp0_fdc_irq;
 extern int get_c0_fdc_int(void);
 
 void arch_trigger_cpumask_backtrace(const struct cpumask *mask,
-   bool exclude_self);
+   int exclude_cpu);
 #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace
 
 #endif /* _ASM_IRQ_H */
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index a3225912c862..5387ed0a5186 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -750,9 +750,9 @@ static void raise_backtrace(cpumask_t *mask)
}
 }
 
-void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self)
+void arch_trigger_cpumask_backtrace(const cpumask_t *mask, int exclude_cpu)
 {
-   nmi_trigger_cpumask_backtrace(mask, exclude_self, raise_backtrace);
+   

Re: [PATCH v3] powerpc/inst: add PPC_TLBILX_LPID

2023-08-03 Thread Nick Desaulniers
On Thu, Aug 3, 2023 at 11:47 AM Christophe Leroy
 wrote:
>
>
>
> Le 03/08/2023 à 20:33, Nick Desaulniers a écrit :
> > Clang didn't recognize the instruction tlbilxlpid. This was fixed in
> > clang-18 [0] then backported to clang-17 [1].  To support clang-16 and
> > older, rather than using that instruction bare in inline asm, add it to
> > ppc-opcode.h and use that macro as is done elsewhere for other
> > instructions.
> >
> > Link: https://github.com/ClangBuiltLinux/linux/issues/1891
> > Link: https://github.com/llvm/llvm-project/issues/64080
> > Link: 
> > https://github.com/llvm/llvm-project/commit/53648ac1d0c953ae6d008864dd2eddb437a92468
> >  [0]
> > Link: 
> > https://github.com/llvm/llvm-project-release-prs/commit/0af7e5e54a8c7ac665773ac1ada328713e8338f5
> >  [1]
> > Reported-by: kernel test robot 
> > Closes: https://lore.kernel.org/llvm/202307211945.tspcyohh-...@intel.com/
> > Suggested-by: Michael Ellerman 
> > Signed-off-by: Nick Desaulniers 
>
> Not sure why you changed the order of #includes , nevertheless

Habit to sort; can drop if maintaining git blame is more important
than cleaning that up.

>
> Reviewed-by: Christophe Leroy 
>
> > ---
> > Changes in v3:
> > - left comment @ 
> > https://github.com/linuxppc/issues/issues/350#issuecomment-1664417212
> > - restore PPC_RAW_TLBILX previous definition
> > - fix comment style
> > - Link to v2: 
> > https://lore.kernel.org/r/20230803-ppc_tlbilxlpid-v2-1-211ffa1df...@google.com
> >
> > Changes in v2:
> > - add 2 missing tabs to PPC_RAW_TLBILX_LPID
> > - Link to v1: 
> > https://lore.kernel.org/r/20230803-ppc_tlbilxlpid-v1-1-84a1bc5cf...@google.com
> > ---
> >   arch/powerpc/include/asm/ppc-opcode.h |  2 ++
> >   arch/powerpc/kvm/e500mc.c | 11 ---
> >   2 files changed, 10 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/powerpc/include/asm/ppc-opcode.h 
> > b/arch/powerpc/include/asm/ppc-opcode.h
> > index ef6972aa33b9..005601243dda 100644
> > --- a/arch/powerpc/include/asm/ppc-opcode.h
> > +++ b/arch/powerpc/include/asm/ppc-opcode.h
> > @@ -397,6 +397,7 @@
> >   #define PPC_RAW_RFCI(0x4c66)
> >   #define PPC_RAW_RFDI(0x4c4e)
> >   #define PPC_RAW_RFMCI   (0x4c4c)
> > +#define PPC_RAW_TLBILX_LPID  (0x7c24)
> >   #define PPC_RAW_TLBILX(t, a, b) (0x7c24 | __PPC_T_TLB(t) 
> > |  __PPC_RA0(a) | __PPC_RB(b))
> >   #define PPC_RAW_WAIT_v203   (0x7c7c)
> >   #define PPC_RAW_WAIT(w, p)  (0x7c3c | __PPC_WC(w) | 
> > __PPC_PL(p))
> > @@ -616,6 +617,7 @@
> >   #define PPC_TLBILX(t, a, b) stringify_in_c(.long PPC_RAW_TLBILX(t, a, b))
> >   #define PPC_TLBILX_ALL(a, b)PPC_TLBILX(0, a, b)
> >   #define PPC_TLBILX_PID(a, b)PPC_TLBILX(1, a, b)
> > +#define PPC_TLBILX_LPID  stringify_in_c(.long 
> > PPC_RAW_TLBILX_LPID)
> >   #define PPC_TLBILX_VA(a, b) PPC_TLBILX(3, a, b)
> >   #define PPC_WAIT_v203   stringify_in_c(.long 
> > PPC_RAW_WAIT_v203)
> >   #define PPC_WAIT(w, p)  stringify_in_c(.long PPC_RAW_WAIT(w, 
> > p))
> > diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c
> > index d58df71ace58..7c09c000c330 100644
> > --- a/arch/powerpc/kvm/e500mc.c
> > +++ b/arch/powerpc/kvm/e500mc.c
> > @@ -16,10 +16,11 @@
> >   #include 
> >   #include 
> >
> > -#include 
> >   #include 
> > -#include 
> >   #include 
> > +#include 
> > +#include 
> > +#include 
> >
> >   #include "booke.h"
> >   #include "e500.h"
> > @@ -92,7 +93,11 @@ void kvmppc_e500_tlbil_all(struct kvmppc_vcpu_e500 
> > *vcpu_e500)
> >
> >   local_irq_save(flags);
> >   mtspr(SPRN_MAS5, MAS5_SGS | get_lpid(_e500->vcpu));
> > - asm volatile("tlbilxlpid");
> > + /*
> > +  * clang-17 and older could not assemble tlbilxlpid.
> > +  * https://github.com/ClangBuiltLinux/linux/issues/1891
> > +  */
> > + asm volatile (PPC_TLBILX_LPID);
> >   mtspr(SPRN_MAS5, 0);
> >   local_irq_restore(flags);
> >   }
> >
> > ---
> > base-commit: 7bafbd4027ae86572f308c4ddf93120c90126332
> > change-id: 20230803-ppc_tlbilxlpid-cfdbf4fd4f7f
> >
> > Best regards,



-- 
Thanks,
~Nick Desaulniers


Re: [PATCH v3] powerpc/inst: add PPC_TLBILX_LPID

2023-08-03 Thread Christophe Leroy


Le 03/08/2023 à 20:33, Nick Desaulniers a écrit :
> Clang didn't recognize the instruction tlbilxlpid. This was fixed in
> clang-18 [0] then backported to clang-17 [1].  To support clang-16 and
> older, rather than using that instruction bare in inline asm, add it to
> ppc-opcode.h and use that macro as is done elsewhere for other
> instructions.
> 
> Link: https://github.com/ClangBuiltLinux/linux/issues/1891
> Link: https://github.com/llvm/llvm-project/issues/64080
> Link: 
> https://github.com/llvm/llvm-project/commit/53648ac1d0c953ae6d008864dd2eddb437a92468
>  [0]
> Link: 
> https://github.com/llvm/llvm-project-release-prs/commit/0af7e5e54a8c7ac665773ac1ada328713e8338f5
>  [1]
> Reported-by: kernel test robot 
> Closes: https://lore.kernel.org/llvm/202307211945.tspcyohh-...@intel.com/
> Suggested-by: Michael Ellerman 
> Signed-off-by: Nick Desaulniers 

Not sure why you changed the order of #includes , nevertheless

Reviewed-by: Christophe Leroy 

> ---
> Changes in v3:
> - left comment @ 
> https://github.com/linuxppc/issues/issues/350#issuecomment-1664417212
> - restore PPC_RAW_TLBILX previous definition
> - fix comment style
> - Link to v2: 
> https://lore.kernel.org/r/20230803-ppc_tlbilxlpid-v2-1-211ffa1df...@google.com
> 
> Changes in v2:
> - add 2 missing tabs to PPC_RAW_TLBILX_LPID
> - Link to v1: 
> https://lore.kernel.org/r/20230803-ppc_tlbilxlpid-v1-1-84a1bc5cf...@google.com
> ---
>   arch/powerpc/include/asm/ppc-opcode.h |  2 ++
>   arch/powerpc/kvm/e500mc.c | 11 ---
>   2 files changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/ppc-opcode.h 
> b/arch/powerpc/include/asm/ppc-opcode.h
> index ef6972aa33b9..005601243dda 100644
> --- a/arch/powerpc/include/asm/ppc-opcode.h
> +++ b/arch/powerpc/include/asm/ppc-opcode.h
> @@ -397,6 +397,7 @@
>   #define PPC_RAW_RFCI(0x4c66)
>   #define PPC_RAW_RFDI(0x4c4e)
>   #define PPC_RAW_RFMCI   (0x4c4c)
> +#define PPC_RAW_TLBILX_LPID  (0x7c24)
>   #define PPC_RAW_TLBILX(t, a, b) (0x7c24 | __PPC_T_TLB(t) |  
> __PPC_RA0(a) | __PPC_RB(b))
>   #define PPC_RAW_WAIT_v203   (0x7c7c)
>   #define PPC_RAW_WAIT(w, p)  (0x7c3c | __PPC_WC(w) | __PPC_PL(p))
> @@ -616,6 +617,7 @@
>   #define PPC_TLBILX(t, a, b) stringify_in_c(.long PPC_RAW_TLBILX(t, a, b))
>   #define PPC_TLBILX_ALL(a, b)PPC_TLBILX(0, a, b)
>   #define PPC_TLBILX_PID(a, b)PPC_TLBILX(1, a, b)
> +#define PPC_TLBILX_LPID  stringify_in_c(.long 
> PPC_RAW_TLBILX_LPID)
>   #define PPC_TLBILX_VA(a, b) PPC_TLBILX(3, a, b)
>   #define PPC_WAIT_v203   stringify_in_c(.long PPC_RAW_WAIT_v203)
>   #define PPC_WAIT(w, p)  stringify_in_c(.long PPC_RAW_WAIT(w, p))
> diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c
> index d58df71ace58..7c09c000c330 100644
> --- a/arch/powerpc/kvm/e500mc.c
> +++ b/arch/powerpc/kvm/e500mc.c
> @@ -16,10 +16,11 @@
>   #include 
>   #include 
>   
> -#include 
>   #include 
> -#include 
>   #include 
> +#include 
> +#include 
> +#include 
>   
>   #include "booke.h"
>   #include "e500.h"
> @@ -92,7 +93,11 @@ void kvmppc_e500_tlbil_all(struct kvmppc_vcpu_e500 
> *vcpu_e500)
>   
>   local_irq_save(flags);
>   mtspr(SPRN_MAS5, MAS5_SGS | get_lpid(_e500->vcpu));
> - asm volatile("tlbilxlpid");
> + /*
> +  * clang-17 and older could not assemble tlbilxlpid.
> +  * https://github.com/ClangBuiltLinux/linux/issues/1891
> +  */
> + asm volatile (PPC_TLBILX_LPID);
>   mtspr(SPRN_MAS5, 0);
>   local_irq_restore(flags);
>   }
> 
> ---
> base-commit: 7bafbd4027ae86572f308c4ddf93120c90126332
> change-id: 20230803-ppc_tlbilxlpid-cfdbf4fd4f7f
> 
> Best regards,


[PATCH v3] powerpc/inst: add PPC_TLBILX_LPID

2023-08-03 Thread Nick Desaulniers
Clang didn't recognize the instruction tlbilxlpid. This was fixed in
clang-18 [0] then backported to clang-17 [1].  To support clang-16 and
older, rather than using that instruction bare in inline asm, add it to
ppc-opcode.h and use that macro as is done elsewhere for other
instructions.

Link: https://github.com/ClangBuiltLinux/linux/issues/1891
Link: https://github.com/llvm/llvm-project/issues/64080
Link: 
https://github.com/llvm/llvm-project/commit/53648ac1d0c953ae6d008864dd2eddb437a92468
 [0]
Link: 
https://github.com/llvm/llvm-project-release-prs/commit/0af7e5e54a8c7ac665773ac1ada328713e8338f5
 [1]
Reported-by: kernel test robot 
Closes: https://lore.kernel.org/llvm/202307211945.tspcyohh-...@intel.com/
Suggested-by: Michael Ellerman 
Signed-off-by: Nick Desaulniers 
---
Changes in v3:
- left comment @ 
https://github.com/linuxppc/issues/issues/350#issuecomment-1664417212
- restore PPC_RAW_TLBILX previous definition
- fix comment style
- Link to v2: 
https://lore.kernel.org/r/20230803-ppc_tlbilxlpid-v2-1-211ffa1df...@google.com

Changes in v2:
- add 2 missing tabs to PPC_RAW_TLBILX_LPID
- Link to v1: 
https://lore.kernel.org/r/20230803-ppc_tlbilxlpid-v1-1-84a1bc5cf...@google.com
---
 arch/powerpc/include/asm/ppc-opcode.h |  2 ++
 arch/powerpc/kvm/e500mc.c | 11 ---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/include/asm/ppc-opcode.h 
b/arch/powerpc/include/asm/ppc-opcode.h
index ef6972aa33b9..005601243dda 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -397,6 +397,7 @@
 #define PPC_RAW_RFCI   (0x4c66)
 #define PPC_RAW_RFDI   (0x4c4e)
 #define PPC_RAW_RFMCI  (0x4c4c)
+#define PPC_RAW_TLBILX_LPID(0x7c24)
 #define PPC_RAW_TLBILX(t, a, b)(0x7c24 | __PPC_T_TLB(t) |  
__PPC_RA0(a) | __PPC_RB(b))
 #define PPC_RAW_WAIT_v203  (0x7c7c)
 #define PPC_RAW_WAIT(w, p) (0x7c3c | __PPC_WC(w) | __PPC_PL(p))
@@ -616,6 +617,7 @@
 #define PPC_TLBILX(t, a, b)stringify_in_c(.long PPC_RAW_TLBILX(t, a, b))
 #define PPC_TLBILX_ALL(a, b)   PPC_TLBILX(0, a, b)
 #define PPC_TLBILX_PID(a, b)   PPC_TLBILX(1, a, b)
+#define PPC_TLBILX_LPIDstringify_in_c(.long 
PPC_RAW_TLBILX_LPID)
 #define PPC_TLBILX_VA(a, b)PPC_TLBILX(3, a, b)
 #define PPC_WAIT_v203  stringify_in_c(.long PPC_RAW_WAIT_v203)
 #define PPC_WAIT(w, p) stringify_in_c(.long PPC_RAW_WAIT(w, p))
diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c
index d58df71ace58..7c09c000c330 100644
--- a/arch/powerpc/kvm/e500mc.c
+++ b/arch/powerpc/kvm/e500mc.c
@@ -16,10 +16,11 @@
 #include 
 #include 
 
-#include 
 #include 
-#include 
 #include 
+#include 
+#include 
+#include 
 
 #include "booke.h"
 #include "e500.h"
@@ -92,7 +93,11 @@ void kvmppc_e500_tlbil_all(struct kvmppc_vcpu_e500 
*vcpu_e500)
 
local_irq_save(flags);
mtspr(SPRN_MAS5, MAS5_SGS | get_lpid(_e500->vcpu));
-   asm volatile("tlbilxlpid");
+   /*
+* clang-17 and older could not assemble tlbilxlpid.
+* https://github.com/ClangBuiltLinux/linux/issues/1891
+*/
+   asm volatile (PPC_TLBILX_LPID);
mtspr(SPRN_MAS5, 0);
local_irq_restore(flags);
 }

---
base-commit: 7bafbd4027ae86572f308c4ddf93120c90126332
change-id: 20230803-ppc_tlbilxlpid-cfdbf4fd4f7f

Best regards,
-- 
Nick Desaulniers 



Re: [PATCH v2 RESEND*3] ASoC: fsl MPC52xx drivers require PPC_BESTCOMM

2023-08-03 Thread Mark Brown
On Thu, Aug 03, 2023 at 11:09:43AM -0700, Randy Dunlap wrote:
> On 8/3/23 04:27, Mark Brown wrote:
> > On Wed, Aug 02, 2023 at 07:59:41PM -0700, Randy Dunlap wrote:

> >> Both SND_MPC52xx_SOC_PCM030 and SND_MPC52xx_SOC_EFIKA select
> >> SND_SOC_MPC5200_AC97. The latter symbol depends on PPC_BESTCOMM,
> >> so the 2 former symbols should also depend on PPC_BESTCOMM since
> >> "select" does not follow any dependency chains.

> > Take a hint, it's not clear that the patch is tasteful.

> Thank you for replying.  I'll drop it and just report the build errors.

To be clear I generally don't give you review comments because in the
past I grew so frustrated with having them and their escalations
ignored that it seemed better to just not start.  If the patch seems
fine I generally apply it, usually you just don't resend patches so that
works. 


signature.asc
Description: PGP signature


Re: [PATCH v2 RESEND*3] ASoC: fsl MPC52xx drivers require PPC_BESTCOMM

2023-08-03 Thread Randy Dunlap



On 8/3/23 04:27, Mark Brown wrote:
> On Wed, Aug 02, 2023 at 07:59:41PM -0700, Randy Dunlap wrote:
>> Both SND_MPC52xx_SOC_PCM030 and SND_MPC52xx_SOC_EFIKA select
>> SND_SOC_MPC5200_AC97. The latter symbol depends on PPC_BESTCOMM,
>> so the 2 former symbols should also depend on PPC_BESTCOMM since
>> "select" does not follow any dependency chains.
> 
> Take a hint, it's not clear that the patch is tasteful.

Thank you for replying.  I'll drop it and just report the build errors.

-- 
~Randy


Re: [PATCH v2] powerpc/inst: add PPC_TLBILX_LPID

2023-08-03 Thread Christophe Leroy


Le 03/08/2023 à 19:33, Nick Desaulniers a écrit :
> Clang didn't recognize the instruction tlbilxlpid. This was fixed in
> clang-18 [0] then backported to clang-17 [1].  To support clang-16 and
> older, rather than using that instruction bare in inline asm, add it to
> ppc-opcode.h and use that macro as is done elsewhere for other
> instructions.

Can you mention that patch in https://github.com/linuxppc/issues/issues/350

> 
> Link: https://github.com/ClangBuiltLinux/linux/issues/1891
> Link: https://github.com/llvm/llvm-project/issues/64080
> Link: 
> https://github.com/llvm/llvm-project/commit/53648ac1d0c953ae6d008864dd2eddb437a92468
>  [0]
> Link: 
> https://github.com/llvm/llvm-project-release-prs/commit/0af7e5e54a8c7ac665773ac1ada328713e8338f5
>  [1]
> Reported-by: kernel test robot 
> Closes: https://lore.kernel.org/llvm/202307211945.tspcyohh-...@intel.com/
> Suggested-by: Michael Ellerman 
> Signed-off-by: Nick Desaulniers 
> ---
> Changes in v2:
> - add 2 missing tabs to PPC_RAW_TLBILX_LPID
> - Link to v1: 
> https://lore.kernel.org/r/20230803-ppc_tlbilxlpid-v1-1-84a1bc5cf...@google.com
> ---
>   arch/powerpc/include/asm/ppc-opcode.h |  4 +++-
>   arch/powerpc/kvm/e500mc.c | 10 +++---
>   2 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/ppc-opcode.h 
> b/arch/powerpc/include/asm/ppc-opcode.h
> index ef6972aa33b9..f37d8d8cbec6 100644
> --- a/arch/powerpc/include/asm/ppc-opcode.h
> +++ b/arch/powerpc/include/asm/ppc-opcode.h
> @@ -397,7 +397,8 @@
>   #define PPC_RAW_RFCI(0x4c66)
>   #define PPC_RAW_RFDI(0x4c4e)
>   #define PPC_RAW_RFMCI   (0x4c4c)
> -#define PPC_RAW_TLBILX(t, a, b)  (0x7c24 | __PPC_T_TLB(t) |  
> __PPC_RA0(a) | __PPC_RB(b))
> +#define PPC_RAW_TLBILX_LPID  (0x7c24)
> +#define PPC_RAW_TLBILX(t, a, b)  (PPC_RAW_TLBILX_LPID | 
> __PPC_T_TLB(t) | __PPC_RA0(a) | __PPC_RB(b))

Can we avoid changing PPC_RAW_TLBILX to minimise the churn and minimise 
the churn when we remove PPC_RAW_TLBILX_LPID in two years.

>   #define PPC_RAW_WAIT_v203   (0x7c7c)
>   #define PPC_RAW_WAIT(w, p)  (0x7c3c | __PPC_WC(w) | __PPC_PL(p))
>   #define PPC_RAW_TLBIE(lp, a)(0x7c000264 | ___PPC_RB(a) | 
> ___PPC_RS(lp))
> @@ -616,6 +617,7 @@
>   #define PPC_TLBILX(t, a, b) stringify_in_c(.long PPC_RAW_TLBILX(t, a, b))
>   #define PPC_TLBILX_ALL(a, b)PPC_TLBILX(0, a, b)
>   #define PPC_TLBILX_PID(a, b)PPC_TLBILX(1, a, b)
> +#define PPC_TLBILX_LPID  stringify_in_c(.long 
> PPC_RAW_TLBILX_LPID)
>   #define PPC_TLBILX_VA(a, b) PPC_TLBILX(3, a, b)
>   #define PPC_WAIT_v203   stringify_in_c(.long PPC_RAW_WAIT_v203)
>   #define PPC_WAIT(w, p)  stringify_in_c(.long PPC_RAW_WAIT(w, p))
> diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c
> index d58df71ace58..dc054b8b5032 100644
> --- a/arch/powerpc/kvm/e500mc.c
> +++ b/arch/powerpc/kvm/e500mc.c
> @@ -16,10 +16,11 @@
>   #include 
>   #include 
>   
> -#include 
>   #include 
> -#include 
>   #include 
> +#include 
> +#include 
> +#include 
>   
>   #include "booke.h"
>   #include "e500.h"
> @@ -92,7 +93,10 @@ void kvmppc_e500_tlbil_all(struct kvmppc_vcpu_e500 
> *vcpu_e500)
>   
>   local_irq_save(flags);
>   mtspr(SPRN_MAS5, MAS5_SGS | get_lpid(_e500->vcpu));
> - asm volatile("tlbilxlpid");
> + /* clang-17 and older could not assemble tlbilxlpid.
> +  * https://github.com/ClangBuiltLinux/linux/issues/1891
> +  */

I think that's the networking subsystem comments style.
Other parts of kernel have /* on its own empty line and the text starts 
following line.

> + asm volatile (PPC_TLBILX_LPID);
>   mtspr(SPRN_MAS5, 0);
>   local_irq_restore(flags);
>   }
> 
> ---
> base-commit: 7bafbd4027ae86572f308c4ddf93120c90126332
> change-id: 20230803-ppc_tlbilxlpid-cfdbf4fd4f7f
> 
> Best regards,


Christophe


[PATCH v2] powerpc/inst: add PPC_TLBILX_LPID

2023-08-03 Thread Nick Desaulniers
Clang didn't recognize the instruction tlbilxlpid. This was fixed in
clang-18 [0] then backported to clang-17 [1].  To support clang-16 and
older, rather than using that instruction bare in inline asm, add it to
ppc-opcode.h and use that macro as is done elsewhere for other
instructions.

Link: https://github.com/ClangBuiltLinux/linux/issues/1891
Link: https://github.com/llvm/llvm-project/issues/64080
Link: 
https://github.com/llvm/llvm-project/commit/53648ac1d0c953ae6d008864dd2eddb437a92468
 [0]
Link: 
https://github.com/llvm/llvm-project-release-prs/commit/0af7e5e54a8c7ac665773ac1ada328713e8338f5
 [1]
Reported-by: kernel test robot 
Closes: https://lore.kernel.org/llvm/202307211945.tspcyohh-...@intel.com/
Suggested-by: Michael Ellerman 
Signed-off-by: Nick Desaulniers 
---
Changes in v2:
- add 2 missing tabs to PPC_RAW_TLBILX_LPID
- Link to v1: 
https://lore.kernel.org/r/20230803-ppc_tlbilxlpid-v1-1-84a1bc5cf...@google.com
---
 arch/powerpc/include/asm/ppc-opcode.h |  4 +++-
 arch/powerpc/kvm/e500mc.c | 10 +++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/include/asm/ppc-opcode.h 
b/arch/powerpc/include/asm/ppc-opcode.h
index ef6972aa33b9..f37d8d8cbec6 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -397,7 +397,8 @@
 #define PPC_RAW_RFCI   (0x4c66)
 #define PPC_RAW_RFDI   (0x4c4e)
 #define PPC_RAW_RFMCI  (0x4c4c)
-#define PPC_RAW_TLBILX(t, a, b)(0x7c24 | __PPC_T_TLB(t) |  
__PPC_RA0(a) | __PPC_RB(b))
+#define PPC_RAW_TLBILX_LPID(0x7c24)
+#define PPC_RAW_TLBILX(t, a, b)(PPC_RAW_TLBILX_LPID | 
__PPC_T_TLB(t) | __PPC_RA0(a) | __PPC_RB(b))
 #define PPC_RAW_WAIT_v203  (0x7c7c)
 #define PPC_RAW_WAIT(w, p) (0x7c3c | __PPC_WC(w) | __PPC_PL(p))
 #define PPC_RAW_TLBIE(lp, a)   (0x7c000264 | ___PPC_RB(a) | 
___PPC_RS(lp))
@@ -616,6 +617,7 @@
 #define PPC_TLBILX(t, a, b)stringify_in_c(.long PPC_RAW_TLBILX(t, a, b))
 #define PPC_TLBILX_ALL(a, b)   PPC_TLBILX(0, a, b)
 #define PPC_TLBILX_PID(a, b)   PPC_TLBILX(1, a, b)
+#define PPC_TLBILX_LPIDstringify_in_c(.long 
PPC_RAW_TLBILX_LPID)
 #define PPC_TLBILX_VA(a, b)PPC_TLBILX(3, a, b)
 #define PPC_WAIT_v203  stringify_in_c(.long PPC_RAW_WAIT_v203)
 #define PPC_WAIT(w, p) stringify_in_c(.long PPC_RAW_WAIT(w, p))
diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c
index d58df71ace58..dc054b8b5032 100644
--- a/arch/powerpc/kvm/e500mc.c
+++ b/arch/powerpc/kvm/e500mc.c
@@ -16,10 +16,11 @@
 #include 
 #include 
 
-#include 
 #include 
-#include 
 #include 
+#include 
+#include 
+#include 
 
 #include "booke.h"
 #include "e500.h"
@@ -92,7 +93,10 @@ void kvmppc_e500_tlbil_all(struct kvmppc_vcpu_e500 
*vcpu_e500)
 
local_irq_save(flags);
mtspr(SPRN_MAS5, MAS5_SGS | get_lpid(_e500->vcpu));
-   asm volatile("tlbilxlpid");
+   /* clang-17 and older could not assemble tlbilxlpid.
+* https://github.com/ClangBuiltLinux/linux/issues/1891
+*/
+   asm volatile (PPC_TLBILX_LPID);
mtspr(SPRN_MAS5, 0);
local_irq_restore(flags);
 }

---
base-commit: 7bafbd4027ae86572f308c4ddf93120c90126332
change-id: 20230803-ppc_tlbilxlpid-cfdbf4fd4f7f

Best regards,
-- 
Nick Desaulniers 



Re: [PATCH] powerpc/inst: add PPC_TLBILX_LPID

2023-08-03 Thread Nick Desaulniers
On Thu, Aug 3, 2023 at 10:00 AM  wrote:
>
> Clang didn't recognize the instruction tlbilxlpid. This was fixed in
> clang-18 [0] then backported to clang-17 [1].  To support clang-16 and
> older, rather than using that instruction bare in inline asm, add it to
> ppc-opcode.h and use that macro as is done elsewhere for other
> instructions.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/1891
> Link: https://github.com/llvm/llvm-project/issues/64080
> Link: 
> https://github.com/llvm/llvm-project/commit/53648ac1d0c953ae6d008864dd2eddb437a92468
>  [0]
> Link: 
> https://github.com/llvm/llvm-project-release-prs/commit/0af7e5e54a8c7ac665773ac1ada328713e8338f5
>  [1]
> Reported-by: kernel test robot 
> Closes: https://lore.kernel.org/llvm/202307211945.tspcyohh-...@intel.com/
> Suggested-by: Michael Ellerman 
> Signed-off-by: Nick Desaulniers 
> ---
>  arch/powerpc/include/asm/ppc-opcode.h |  4 +++-
>  arch/powerpc/kvm/e500mc.c | 10 +++---
>  2 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/ppc-opcode.h 
> b/arch/powerpc/include/asm/ppc-opcode.h
> index ef6972aa33b9..72f184e06bec 100644
> --- a/arch/powerpc/include/asm/ppc-opcode.h
> +++ b/arch/powerpc/include/asm/ppc-opcode.h
> @@ -397,7 +397,8 @@
>  #define PPC_RAW_RFCI   (0x4c66)
>  #define PPC_RAW_RFDI   (0x4c4e)
>  #define PPC_RAW_RFMCI  (0x4c4c)
> -#define PPC_RAW_TLBILX(t, a, b)(0x7c24 | __PPC_T_TLB(t) 
> |  __PPC_RA0(a) | __PPC_RB(b))
> +#define PPC_RAW_TLBILX_LPID (0x7c24)

^ missing two tabs.

I'm also having issues with b4 and my external mailer setting the From
header correctly.  To test up local modifications to b4, I'm going to
send a v2.

> +#define PPC_RAW_TLBILX(t, a, b)(PPC_RAW_TLBILX_LPID | 
> __PPC_T_TLB(t) | __PPC_RA0(a) | __PPC_RB(b))
>  #define PPC_RAW_WAIT_v203  (0x7c7c)
>  #define PPC_RAW_WAIT(w, p) (0x7c3c | __PPC_WC(w) | 
> __PPC_PL(p))
>  #define PPC_RAW_TLBIE(lp, a)   (0x7c000264 | ___PPC_RB(a) | 
> ___PPC_RS(lp))
> @@ -616,6 +617,7 @@
>  #define PPC_TLBILX(t, a, b)stringify_in_c(.long PPC_RAW_TLBILX(t, a, b))
>  #define PPC_TLBILX_ALL(a, b)   PPC_TLBILX(0, a, b)
>  #define PPC_TLBILX_PID(a, b)   PPC_TLBILX(1, a, b)
> +#define PPC_TLBILX_LPIDstringify_in_c(.long 
> PPC_RAW_TLBILX_LPID)
>  #define PPC_TLBILX_VA(a, b)PPC_TLBILX(3, a, b)
>  #define PPC_WAIT_v203  stringify_in_c(.long PPC_RAW_WAIT_v203)
>  #define PPC_WAIT(w, p) stringify_in_c(.long PPC_RAW_WAIT(w, p))
> diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c
> index d58df71ace58..dc054b8b5032 100644
> --- a/arch/powerpc/kvm/e500mc.c
> +++ b/arch/powerpc/kvm/e500mc.c
> @@ -16,10 +16,11 @@
>  #include 
>  #include 
>
> -#include 
>  #include 
> -#include 
>  #include 
> +#include 
> +#include 
> +#include 
>
>  #include "booke.h"
>  #include "e500.h"
> @@ -92,7 +93,10 @@ void kvmppc_e500_tlbil_all(struct kvmppc_vcpu_e500 
> *vcpu_e500)
>
> local_irq_save(flags);
> mtspr(SPRN_MAS5, MAS5_SGS | get_lpid(_e500->vcpu));
> -   asm volatile("tlbilxlpid");
> +   /* clang-17 and older could not assemble tlbilxlpid.
> +    * https://github.com/ClangBuiltLinux/linux/issues/1891
> +*/
> +   asm volatile (PPC_TLBILX_LPID);
> mtspr(SPRN_MAS5, 0);
> local_irq_restore(flags);
>  }
>
> ---
> base-commit: 7bafbd4027ae86572f308c4ddf93120c90126332
> change-id: 20230803-ppc_tlbilxlpid-cfdbf4fd4f7f
>
> Best regards,
> --
> Nick Desaulniers 
>


-- 
Thanks,
~Nick Desaulniers


[PATCH] powerpc/inst: add PPC_TLBILX_LPID

2023-08-03 Thread ndesaulniers
Clang didn't recognize the instruction tlbilxlpid. This was fixed in
clang-18 [0] then backported to clang-17 [1].  To support clang-16 and
older, rather than using that instruction bare in inline asm, add it to
ppc-opcode.h and use that macro as is done elsewhere for other
instructions.

Link: https://github.com/ClangBuiltLinux/linux/issues/1891
Link: https://github.com/llvm/llvm-project/issues/64080
Link: 
https://github.com/llvm/llvm-project/commit/53648ac1d0c953ae6d008864dd2eddb437a92468
 [0]
Link: 
https://github.com/llvm/llvm-project-release-prs/commit/0af7e5e54a8c7ac665773ac1ada328713e8338f5
 [1]
Reported-by: kernel test robot 
Closes: https://lore.kernel.org/llvm/202307211945.tspcyohh-...@intel.com/
Suggested-by: Michael Ellerman 
Signed-off-by: Nick Desaulniers 
---
 arch/powerpc/include/asm/ppc-opcode.h |  4 +++-
 arch/powerpc/kvm/e500mc.c | 10 +++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/include/asm/ppc-opcode.h 
b/arch/powerpc/include/asm/ppc-opcode.h
index ef6972aa33b9..72f184e06bec 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -397,7 +397,8 @@
 #define PPC_RAW_RFCI   (0x4c66)
 #define PPC_RAW_RFDI   (0x4c4e)
 #define PPC_RAW_RFMCI  (0x4c4c)
-#define PPC_RAW_TLBILX(t, a, b)(0x7c24 | __PPC_T_TLB(t) |  
__PPC_RA0(a) | __PPC_RB(b))
+#define PPC_RAW_TLBILX_LPID (0x7c24)
+#define PPC_RAW_TLBILX(t, a, b)(PPC_RAW_TLBILX_LPID | 
__PPC_T_TLB(t) | __PPC_RA0(a) | __PPC_RB(b))
 #define PPC_RAW_WAIT_v203  (0x7c7c)
 #define PPC_RAW_WAIT(w, p) (0x7c3c | __PPC_WC(w) | __PPC_PL(p))
 #define PPC_RAW_TLBIE(lp, a)   (0x7c000264 | ___PPC_RB(a) | 
___PPC_RS(lp))
@@ -616,6 +617,7 @@
 #define PPC_TLBILX(t, a, b)stringify_in_c(.long PPC_RAW_TLBILX(t, a, b))
 #define PPC_TLBILX_ALL(a, b)   PPC_TLBILX(0, a, b)
 #define PPC_TLBILX_PID(a, b)   PPC_TLBILX(1, a, b)
+#define PPC_TLBILX_LPIDstringify_in_c(.long 
PPC_RAW_TLBILX_LPID)
 #define PPC_TLBILX_VA(a, b)PPC_TLBILX(3, a, b)
 #define PPC_WAIT_v203  stringify_in_c(.long PPC_RAW_WAIT_v203)
 #define PPC_WAIT(w, p) stringify_in_c(.long PPC_RAW_WAIT(w, p))
diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c
index d58df71ace58..dc054b8b5032 100644
--- a/arch/powerpc/kvm/e500mc.c
+++ b/arch/powerpc/kvm/e500mc.c
@@ -16,10 +16,11 @@
 #include 
 #include 
 
-#include 
 #include 
-#include 
 #include 
+#include 
+#include 
+#include 
 
 #include "booke.h"
 #include "e500.h"
@@ -92,7 +93,10 @@ void kvmppc_e500_tlbil_all(struct kvmppc_vcpu_e500 
*vcpu_e500)
 
local_irq_save(flags);
mtspr(SPRN_MAS5, MAS5_SGS | get_lpid(_e500->vcpu));
-   asm volatile("tlbilxlpid");
+   /* clang-17 and older could not assemble tlbilxlpid.
+* https://github.com/ClangBuiltLinux/linux/issues/1891
+*/
+   asm volatile (PPC_TLBILX_LPID);
mtspr(SPRN_MAS5, 0);
local_irq_restore(flags);
 }

---
base-commit: 7bafbd4027ae86572f308c4ddf93120c90126332
change-id: 20230803-ppc_tlbilxlpid-cfdbf4fd4f7f

Best regards,
-- 
Nick Desaulniers 



[PATCH v1 09/12] serial: cpm_uart: Remove cpm_uart/ subdirectory

2023-08-03 Thread Christophe Leroy
cpm_uart/ subdirectory only has cpm_uart_core.c and cpm_uart.h now.

Move them up and remove cpm_uart/ directory while renaming
cpm_uart_core.c as cpm_uart.c

Signed-off-by: Christophe Leroy 
---
 drivers/tty/serial/Makefile | 2 +-
 drivers/tty/serial/{cpm_uart/cpm_uart_core.c => cpm_uart.c} | 0
 drivers/tty/serial/{cpm_uart => }/cpm_uart.h| 0
 drivers/tty/serial/cpm_uart/Makefile| 6 --
 4 files changed, 1 insertion(+), 7 deletions(-)
 rename drivers/tty/serial/{cpm_uart/cpm_uart_core.c => cpm_uart.c} (100%)
 rename drivers/tty/serial/{cpm_uart => }/cpm_uart.h (100%)
 delete mode 100644 drivers/tty/serial/cpm_uart/Makefile

diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
index d4123469583d..138abbc89738 100644
--- a/drivers/tty/serial/Makefile
+++ b/drivers/tty/serial/Makefile
@@ -41,7 +41,7 @@ obj-$(CONFIG_SERIAL_HS_LPC32XX) += lpc32xx_hs.o
 obj-$(CONFIG_SERIAL_DZ) += dz.o
 obj-$(CONFIG_SERIAL_ZS) += zs.o
 obj-$(CONFIG_SERIAL_SH_SCI) += sh-sci.o
-obj-$(CONFIG_SERIAL_CPM) += cpm_uart/
+obj-$(CONFIG_SERIAL_CPM) += cpm_uart.o
 obj-$(CONFIG_SERIAL_IMX) += imx.o
 obj-$(CONFIG_SERIAL_IMX_EARLYCON) += imx_earlycon.o
 obj-$(CONFIG_SERIAL_MPC52xx) += mpc52xx_uart.o
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c 
b/drivers/tty/serial/cpm_uart.c
similarity index 100%
rename from drivers/tty/serial/cpm_uart/cpm_uart_core.c
rename to drivers/tty/serial/cpm_uart.c
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart.h 
b/drivers/tty/serial/cpm_uart.h
similarity index 100%
rename from drivers/tty/serial/cpm_uart/cpm_uart.h
rename to drivers/tty/serial/cpm_uart.h
diff --git a/drivers/tty/serial/cpm_uart/Makefile 
b/drivers/tty/serial/cpm_uart/Makefile
deleted file mode 100644
index 91f202fa5251..
--- a/drivers/tty/serial/cpm_uart/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# Makefile for the Motorola 8xx FEC ethernet controller
-#
-
-obj-$(CONFIG_SERIAL_CPM) += cpm_uart_core.o
-- 
2.41.0



[PATCH v1 12/12] serial: cpm_uart: Remove linux/fs_uart_pd.h

2023-08-03 Thread Christophe Leroy
linux/fs_uart_pd.h is not used anymore. Remove it.

Signed-off-by: Christophe Leroy 
---
 include/linux/fs_uart_pd.h | 71 --
 1 file changed, 71 deletions(-)
 delete mode 100644 include/linux/fs_uart_pd.h

diff --git a/include/linux/fs_uart_pd.h b/include/linux/fs_uart_pd.h
deleted file mode 100644
index 36b61ff39277..
--- a/include/linux/fs_uart_pd.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Platform information definitions for the CPM Uart driver.
- *
- * 2006 (c) MontaVista Software, Inc.
- * Vitaly Bordug 
- *
- * This file is licensed under the terms of the GNU General Public License
- * version 2. This program is licensed "as is" without any warranty of any
- * kind, whether express or implied.
- */
-
-#ifndef FS_UART_PD_H
-#define FS_UART_PD_H
-
-#include 
-
-enum fs_uart_id {
-   fsid_smc1_uart,
-   fsid_smc2_uart,
-   fsid_scc1_uart,
-   fsid_scc2_uart,
-   fsid_scc3_uart,
-   fsid_scc4_uart,
-   fs_uart_nr,
-};
-
-static inline int fs_uart_id_scc2fsid(int id)
-{
-return fsid_scc1_uart + id - 1;
-}
-
-static inline int fs_uart_id_fsid2scc(int id)
-{
-return id - fsid_scc1_uart + 1;
-}
-
-static inline int fs_uart_id_smc2fsid(int id)
-{
-return fsid_smc1_uart + id - 1;
-}
-
-static inline int fs_uart_id_fsid2smc(int id)
-{
-return id - fsid_smc1_uart + 1;
-}
-
-struct fs_uart_platform_info {
-void(*init_ioports)(struct fs_uart_platform_info *);
-   /* device specific information */
-   int fs_no;  /* controller index */
-   char fs_type[4];/* controller type  */
-   u32 uart_clk;
-   u8 tx_num_fifo;
-   u8 tx_buf_size;
-   u8 rx_num_fifo;
-   u8 rx_buf_size;
-   u8 brg;
-   u8 clk_rx;
-   u8 clk_tx;
-};
-
-static inline int fs_uart_get_id(struct fs_uart_platform_info *fpi)
-{
-if(strstr(fpi->fs_type, "SMC"))
-return fs_uart_id_smc2fsid(fpi->fs_no);
-if(strstr(fpi->fs_type, "SCC"))
-return fs_uart_id_scc2fsid(fpi->fs_no);
-return fpi->fs_no;
-}
-
-#endif
-- 
2.41.0



[PATCH v1 07/12] serial: cpm_uart: Refactor cpm_uart_allocbuf()/cpm_uart_freebuf()

2023-08-03 Thread Christophe Leroy
cpm_uart_freebuf() is identical for CPM1 and CPM2.

cpm_uart_allocbuf() only has a small difference between CPM1 and CPM2
as shown below:

CPM1:
if (is_con) {
/* was hostalloc but changed cause it blows away the */
/* large tlb mapping when pinning the kernel area*/
mem_addr = (u8 *) cpm_dpram_addr(cpm_dpalloc(memsz, 8));
dma_addr = (u32)cpm_dpram_phys(mem_addr);
} else
mem_addr = dma_alloc_coherent(pinfo->port.dev, memsz, _addr,
  GFP_KERNEL);

CPM2:

if (is_con) {
mem_addr = kzalloc(memsz, GFP_NOWAIT);
dma_addr = virt_to_bus(mem_addr);
}
else
mem_addr = dma_alloc_coherent(pinfo->port.dev, memsz, _addr,
  GFP_KERNEL);

Refactor this by using IS_ENABLED(CONFIG_CPM1)
and move both functions in cpm_uart_core.c as they are used only there.

While doing this, add the necessary casts to silence sparse for the CPM1
part. This is because a dma alloc is not expected to be an iomem but
for CPM1 as we use DPRAM this is seen as iomem.

Also replace calls to cpm_dp() by relevant cpm_muram_() calls.
This is needed at least for cpm_dpram_phys() which is only defined
for CPM1. Just do the same for all so that cpm_dp() macros can get
droped in the future.

To silence checkpatch, replace printk(KERN_ERR by pr_err( and display
function name instead of hard coded filename. Also replace
mem_addr == NULL by !mem_addr.

Signed-off-by: Christophe Leroy 
---
 drivers/tty/serial/cpm_uart/cpm_uart.h  |  2 -
 drivers/tty/serial/cpm_uart/cpm_uart_core.c | 72 +
 drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c | 69 
 drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c | 69 
 4 files changed, 72 insertions(+), 140 deletions(-)

diff --git a/drivers/tty/serial/cpm_uart/cpm_uart.h 
b/drivers/tty/serial/cpm_uart/cpm_uart.h
index 1b5523474ab4..6d6046d45bec 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart.h
+++ b/drivers/tty/serial/cpm_uart/cpm_uart.h
@@ -79,8 +79,6 @@ struct uart_cpm_port {
 void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
struct device_node *np);
 void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram);
-int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con);
-void cpm_uart_freebuf(struct uart_cpm_port *pinfo);
 
 /*
virtual to phys transtalion
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c 
b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index e6f3e4da3144..fa5466518536 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -868,6 +868,78 @@ static void cpm_uart_init_smc(struct uart_cpm_port *pinfo)
setbits16(>smc_smcmr, SMCMR_REN | SMCMR_TEN);
 }
 
+/*
+ * Allocate DP-Ram and memory buffers. We need to allocate a transmit and
+ * receive buffer descriptors from dual port ram, and a character
+ * buffer area from host mem. If we are allocating for the console we need
+ * to do it from bootmem
+ */
+static int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con)
+{
+   int dpmemsz, memsz;
+   u8 __iomem *dp_mem;
+   unsigned long dp_offset;
+   u8 *mem_addr;
+   dma_addr_t dma_addr = 0;
+
+   pr_debug("CPM uart[%d]:allocbuf\n", pinfo->port.line);
+
+   dpmemsz = sizeof(cbd_t) * (pinfo->rx_nrfifos + pinfo->tx_nrfifos);
+   dp_offset = cpm_muram_alloc(dpmemsz, 8);
+   if (IS_ERR_VALUE(dp_offset)) {
+   pr_err("%s: could not allocate buffer descriptors\n", __func__);
+   return -ENOMEM;
+   }
+
+   dp_mem = cpm_muram_addr(dp_offset);
+
+   memsz = L1_CACHE_ALIGN(pinfo->rx_nrfifos * pinfo->rx_fifosize) +
+   L1_CACHE_ALIGN(pinfo->tx_nrfifos * pinfo->tx_fifosize);
+   if (IS_ENABLED(CONFIG_CPM1) && is_con) {
+   /* was hostalloc but changed cause it blows away the */
+   /* large tlb mapping when pinning the kernel area*/
+   mem_addr = (u8 __force *)cpm_muram_addr(cpm_muram_alloc(memsz, 
8));
+   dma_addr = cpm_muram_dma((void __iomem *)mem_addr);
+   } else if (is_con) {
+   mem_addr = kzalloc(memsz, GFP_NOWAIT);
+   dma_addr = virt_to_bus(mem_addr);
+   } else {
+   mem_addr = dma_alloc_coherent(pinfo->port.dev, memsz, _addr,
+ GFP_KERNEL);
+   }
+
+   if (!mem_addr) {
+   cpm_muram_free(dp_offset);
+   pr_err("%s: could not allocate coherent memory\n", __func__);
+   return -ENOMEM;
+   }
+
+   pinfo->dp_addr = dp_offset;
+   pinfo->mem_addr = mem_addr;
+   pinfo->dma_addr = dma_addr;
+   pinfo->mem_size = memsz;
+
+   pinfo->rx_buf = mem_addr;
+   

[PATCH v1 08/12] serial: cpm_uart: Refactor cpm_uart_[un]map_pram()

2023-08-03 Thread Christophe Leroy
cpm_uart_map_pram() and cpm_uart_unmap_pram() are very
similar for CPM1 and CPM2.

On CPM1 cpm_uart_map_pram() uses of_iomap() while CPM2 uses
of_address_to_resource()/ioremap(). CPM2 version will also
work on CPM1.

On CPM2 cpm_uart_map_pram() and cpm_uart_unmap_pram() has a special
handling for SMC. Just gate it by an IS_ENABLED(CONFIG_CPM2).

So move the CPM2 version into cpm_uart_core.c which is the only
user of those two fonctions and refactor to also handle CPM1 as
mentionned above.

PROFF_SMC_SIZE is only defined for SMC2 and used only there. To make
it simple, just use the numerical value 64, this is the only place
it is used and anyway there's already the same numerical value for
the alignment.

Use cpm_muram_alloc() instead of cpm_dpalloc() macro.

Then cpm_uart_cpm1.c and cpm_uart_cpm2.c are now empty and go away.

Replace printk(KERN_WARN by pr_warn( to make checkpatch happier.

Signed-off-by: Christophe Leroy 
---
 drivers/tty/serial/cpm_uart/Makefile|  8 +-
 drivers/tty/serial/cpm_uart/cpm_uart.h  |  5 --
 drivers/tty/serial/cpm_uart/cpm_uart_core.c | 48 
 drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c | 48 
 drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c | 82 -
 5 files changed, 49 insertions(+), 142 deletions(-)
 delete mode 100644 drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
 delete mode 100644 drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c

diff --git a/drivers/tty/serial/cpm_uart/Makefile 
b/drivers/tty/serial/cpm_uart/Makefile
index 3f3a6ed02ed4..91f202fa5251 100644
--- a/drivers/tty/serial/cpm_uart/Makefile
+++ b/drivers/tty/serial/cpm_uart/Makefile
@@ -3,10 +3,4 @@
 # Makefile for the Motorola 8xx FEC ethernet controller
 #
 
-obj-$(CONFIG_SERIAL_CPM) += cpm_uart.o
-
-# Select the correct platform objects.
-cpm_uart-objs-$(CONFIG_CPM2)   += cpm_uart_cpm2.o
-cpm_uart-objs-$(CONFIG_CPM1)   += cpm_uart_cpm1.o
-
-cpm_uart-objs  := cpm_uart_core.o $(cpm_uart-objs-y)
+obj-$(CONFIG_SERIAL_CPM) += cpm_uart_core.o
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart.h 
b/drivers/tty/serial/cpm_uart/cpm_uart.h
index 6d6046d45bec..37bb6e976e03 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart.h
+++ b/drivers/tty/serial/cpm_uart/cpm_uart.h
@@ -75,11 +75,6 @@ struct uart_cpm_port {
struct gpio_desc*gpios[NUM_GPIOS];
 };
 
-/* these are located in their respective files */
-void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
-   struct device_node *np);
-void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram);
-
 /*
virtual to phys transtalion
 */
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c 
b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index fa5466518536..626423022d62 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -1207,6 +1207,54 @@ static const struct uart_ops cpm_uart_pops = {
 
 static struct uart_cpm_port cpm_uart_ports[UART_NR];
 
+static void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
+  struct device_node *np)
+{
+   void __iomem *pram;
+   unsigned long offset;
+   struct resource res;
+   resource_size_t len;
+
+   /* Don't remap parameter RAM if it has already been initialized
+* during console setup.
+*/
+   if (IS_SMC(port) && port->smcup)
+   return port->smcup;
+   else if (!IS_SMC(port) && port->sccup)
+   return port->sccup;
+
+   if (of_address_to_resource(np, 1, ))
+   return NULL;
+
+   len = resource_size();
+   pram = ioremap(res.start, len);
+   if (!pram)
+   return NULL;
+
+   if (!IS_ENABLED(CONFIG_CPM2) || !IS_SMC(port))
+   return pram;
+
+   if (len != 2) {
+   pr_warn("cpm_uart[%d]: device tree references "
+   "SMC pram, using boot loader/wrapper pram mapping. "
+   "Please fix your device tree to reference the pram "
+   "base register instead.\n",
+   port->port.line);
+   return pram;
+   }
+
+   offset = cpm_muram_alloc(64, 64);
+   out_be16(pram, offset);
+   iounmap(pram);
+   return cpm_muram_addr(offset);
+}
+
+static void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram)
+{
+   if (!IS_ENABLED(CONFIG_CPM2) || !IS_SMC(port))
+   iounmap(pram);
+}
+
 static int cpm_uart_init_port(struct device_node *np,
   struct uart_cpm_port *pinfo)
 {
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c 
b/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
deleted file mode 100644
index 3fe436dc2f95..
--- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
+++ /dev/null
@@ -1,48 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- *  Driver for CPM (SCC/SMC) serial ports; CPM1 definitions
- *
- *  Maintainer: Kumar Gala 

[PATCH v1 06/12] serial: cpm_uart: Deduplicate cpm_line_cr_cmd()

2023-08-03 Thread Christophe Leroy
cpm_line_cr_cmd() is identical for CPM1 and CPM2 and
is used only in cpm_uart_core.c. Move it there.

Signed-off-by: Christophe Leroy 
---
 drivers/tty/serial/cpm_uart/cpm_uart.h  | 1 -
 drivers/tty/serial/cpm_uart/cpm_uart_core.c | 5 +
 drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c | 5 -
 drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c | 5 -
 4 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/tty/serial/cpm_uart/cpm_uart.h 
b/drivers/tty/serial/cpm_uart/cpm_uart.h
index 81c1c5f97d19..1b5523474ab4 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart.h
+++ b/drivers/tty/serial/cpm_uart/cpm_uart.h
@@ -76,7 +76,6 @@ struct uart_cpm_port {
 };
 
 /* these are located in their respective files */
-void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd);
 void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
struct device_node *np);
 void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram);
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c 
b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index 743892c0e143..e6f3e4da3144 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -54,6 +54,11 @@ static void cpm_uart_initbd(struct uart_cpm_port *pinfo);
 
 #define HW_BUF_SPD_THRESHOLD2400
 
+static void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd)
+{
+   cpm_command(port->command, cmd);
+}
+
 /*
  * Check, if transmit buffers are processed
 */
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c 
b/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
index 56fc527015cb..b5680376ff3c 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
@@ -36,11 +36,6 @@
 
 /**/
 
-void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd)
-{
-   cpm_command(port->command, cmd);
-}
-
 void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
struct device_node *np)
 {
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c 
b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
index 108af254e8f3..35f539fcfde8 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
@@ -33,11 +33,6 @@
 
 /**/
 
-void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd)
-{
-   cpm_command(port->command, cmd);
-}
-
 void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
struct device_node *np)
 {
-- 
2.41.0



[PATCH v1 05/12] serial: cpm_uart: Deduplicate cpm_set_{brg/smc_fcr/scc_fcr}()

2023-08-03 Thread Christophe Leroy
CPMFCR_EB is the same as SMC_EB and is defined
for both CPM1 and CPM2.

CPMFCR_GBL is defined as 0 for CPM1.

Therefore the CPM2 version of cpm_set_scc_fcr() and
cpm_set_smc_fcr() can be used on both CPM1 and CPM2.

And cpm_set_brg() is already identical and just a
wrapper of cpm_setbrg().

In addition those three fonctions are only called once
from cpm_uart_core.c, so just replace the calls with
the content of the CPM2 versions of them.

And DPRAM_BASE is identical so can go in cpm_uart.h. While
moving it, use cpm_muram_addr() directly instead of the
cpm_dpram_addr() macro and remove __force tag which isn't needed.

Then cpm_uart_cpm1.h and cpm_uart_cpm2.h go away.

Signed-off-by: Christophe Leroy 
---
 drivers/tty/serial/cpm_uart/cpm_uart.h  |  6 ++--
 drivers/tty/serial/cpm_uart/cpm_uart_core.c |  8 +++--
 drivers/tty/serial/cpm_uart/cpm_uart_cpm1.h | 33 -
 drivers/tty/serial/cpm_uart/cpm_uart_cpm2.h | 33 -
 4 files changed, 9 insertions(+), 71 deletions(-)
 delete mode 100644 drivers/tty/serial/cpm_uart/cpm_uart_cpm1.h
 delete mode 100644 drivers/tty/serial/cpm_uart/cpm_uart_cpm2.h

diff --git a/drivers/tty/serial/cpm_uart/cpm_uart.h 
b/drivers/tty/serial/cpm_uart/cpm_uart.h
index c220700df693..81c1c5f97d19 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart.h
+++ b/drivers/tty/serial/cpm_uart/cpm_uart.h
@@ -15,11 +15,13 @@
 struct gpio_desc;
 
 #if defined(CONFIG_CPM2)
-#include "cpm_uart_cpm2.h"
+#include "asm/cpm2.h"
 #elif defined(CONFIG_CPM1)
-#include "cpm_uart_cpm1.h"
+#include "asm/cpm1.h"
 #endif
 
+#define DPRAM_BASE ((u8 __iomem *)cpm_muram_addr(0))
+
 #define SERIAL_CPM_MAJOR   204
 #define SERIAL_CPM_MINOR   46
 
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c 
b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index 36bac4390c13..743892c0e143 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -603,7 +603,7 @@ static void cpm_uart_set_termios(struct uart_port *port,
if (pinfo->clk)
clk_set_rate(pinfo->clk, baud);
else
-   cpm_set_brg(pinfo->brg - 1, baud);
+   cpm_setbrg(pinfo->brg - 1, baud);
spin_unlock_irqrestore(>lock, flags);
 }
 
@@ -769,7 +769,8 @@ static void cpm_uart_init_scc(struct uart_cpm_port *pinfo)
 * parameter ram.
 */
 
-   cpm_set_scc_fcr(sup);
+   out_8(>scc_genscc.scc_rfcr, CPMFCR_GBL | CPMFCR_EB);
+   out_8(>scc_genscc.scc_tfcr, CPMFCR_GBL | CPMFCR_EB);
 
out_be16(>scc_genscc.scc_mrblr, pinfo->rx_fifosize);
out_be16(>scc_maxidl, 0x10);
@@ -840,7 +841,8 @@ static void cpm_uart_init_smc(struct uart_cpm_port *pinfo)
/* Set up the uart parameters in the
 * parameter ram.
 */
-   cpm_set_smc_fcr(up);
+   out_8(>smc_rfcr, CPMFCR_GBL | CPMFCR_EB);
+   out_8(>smc_tfcr, CPMFCR_GBL | CPMFCR_EB);
 
/* Using idle character time requires some additional tuning.  */
out_be16(>smc_mrblr, pinfo->rx_fifosize);
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.h 
b/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.h
deleted file mode 100644
index 18ec0849918a..
--- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Driver for CPM (SCC/SMC) serial ports
- *
- * definitions for cpm1
- *
- */
-
-#ifndef CPM_UART_CPM1_H
-#define CPM_UART_CPM1_H
-
-#include 
-
-static inline void cpm_set_brg(int brg, int baud)
-{
-   cpm_setbrg(brg, baud);
-}
-
-static inline void cpm_set_scc_fcr(scc_uart_t __iomem * sup)
-{
-   out_8(>scc_genscc.scc_rfcr, SMC_EB);
-   out_8(>scc_genscc.scc_tfcr, SMC_EB);
-}
-
-static inline void cpm_set_smc_fcr(smc_uart_t __iomem * up)
-{
-   out_8(>smc_rfcr, SMC_EB);
-   out_8(>smc_tfcr, SMC_EB);
-}
-
-#define DPRAM_BASE ((u8 __iomem __force *)cpm_dpram_addr(0))
-
-#endif
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.h 
b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.h
deleted file mode 100644
index 051a8509c3e5..
--- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Driver for CPM (SCC/SMC) serial ports
- *
- * definitions for cpm2
- *
- */
-
-#ifndef CPM_UART_CPM2_H
-#define CPM_UART_CPM2_H
-
-#include 
-
-static inline void cpm_set_brg(int brg, int baud)
-{
-   cpm_setbrg(brg, baud);
-}
-
-static inline void cpm_set_scc_fcr(scc_uart_t __iomem *sup)
-{
-   out_8(>scc_genscc.scc_rfcr, CPMFCR_GBL | CPMFCR_EB);
-   out_8(>scc_genscc.scc_tfcr, CPMFCR_GBL | CPMFCR_EB);
-}
-
-static inline void cpm_set_smc_fcr(smc_uart_t __iomem *up)
-{
-   out_8(>smc_rfcr, CPMFCR_GBL | CPMFCR_EB);
-   out_8(>smc_tfcr, CPMFCR_GBL | CPMFCR_EB);
-}
-
-#define DPRAM_BASE ((u8 __iomem __force *)cpm_dpram_addr(0))
-
-#endif
-- 
2.41.0



[PATCH v1 04/12] serial: cpm_uart: Use get_baudrate() instead of uart_baudrate()

2023-08-03 Thread Christophe Leroy
uart_baudrate() is just a trivial wrapper to get_baudrate().

Use get_baudrate() directly and remove assignment in if condition.

And also remove uart_clock() which is not used since
commit 0b2a2e5b7747 ("cpm_uart: Remove !CONFIG_PPC_CPM_NEW_BINDING
code")

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/include/asm/fs_pd.h| 10 --
 drivers/tty/serial/cpm_uart/cpm_uart_core.c |  6 --
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/include/asm/fs_pd.h b/arch/powerpc/include/asm/fs_pd.h
index 8def56ec05c6..7b61b80f212d 100644
--- a/arch/powerpc/include/asm/fs_pd.h
+++ b/arch/powerpc/include/asm/fs_pd.h
@@ -36,14 +36,4 @@ extern immap_t __iomem *mpc8xx_immr;
 #define immr_unmap(addr) do {} while (0)
 #endif
 
-static inline int uart_baudrate(void)
-{
-return get_baudrate();
-}
-
-static inline int uart_clock(void)
-{
-return ppc_proc_freq;
-}
-
 #endif
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c 
b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index c5a896f79d80..36bac4390c13 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -32,10 +32,11 @@
 #include 
 #include 
 
+#include 
+
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
@@ -1311,7 +1312,8 @@ static int __init cpm_uart_console_setup(struct console 
*co, char *options)
if (options) {
uart_parse_options(options, , , , );
} else {
-   if ((baud = uart_baudrate()) == -1)
+   baud = get_baudrate();
+   if (baud == -1)
baud = 9600;
}
 
-- 
2.41.0



[PATCH v1 10/12] serial: cpm_uart: Remove stale prototype in powerpc/fsl_soc.c

2023-08-03 Thread Christophe Leroy
Commit 0b5cf10691eb ("[POWERPC] 8xx: Convert mpc866ads to the new
device binding.") removed last definition of init_smc_ioports().

Remove it.

And don't include anymore fs_uart_pd.h which is only included to
provide fs_uart_platform_info structure.

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/sysdev/fsl_soc.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index e71b3ede147e..46431c4daaed 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -23,7 +23,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
@@ -38,7 +37,6 @@
 
 extern void init_fcc_ioports(struct fs_platform_info*);
 extern void init_fec_ioports(struct fs_platform_info*);
-extern void init_smc_ioports(struct fs_uart_platform_info*);
 static phys_addr_t immrbase = -1;
 
 phys_addr_t get_immrbase(void)
-- 
2.41.0



[PATCH v1 11/12] serial: cpm_uart: Don't include fs_uart_pd.h when not needed

2023-08-03 Thread Christophe Leroy
Remove inclusion of fs_uart_pd.h from all files not using
anything from that file.

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/platforms/8xx/mpc885ads_setup.c | 1 -
 arch/powerpc/platforms/8xx/tqm8xx_setup.c| 1 -
 drivers/tty/serial/ucc_uart.c| 1 -
 3 files changed, 3 deletions(-)

diff --git a/arch/powerpc/platforms/8xx/mpc885ads_setup.c 
b/arch/powerpc/platforms/8xx/mpc885ads_setup.c
index 2fc7cacbcd96..6ecc7fa2a816 100644
--- a/arch/powerpc/platforms/8xx/mpc885ads_setup.c
+++ b/arch/powerpc/platforms/8xx/mpc885ads_setup.c
@@ -22,7 +22,6 @@
 #include 
 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/arch/powerpc/platforms/8xx/tqm8xx_setup.c 
b/arch/powerpc/platforms/8xx/tqm8xx_setup.c
index 7d8eb50bb9cd..a451f5003abd 100644
--- a/arch/powerpc/platforms/8xx/tqm8xx_setup.c
+++ b/arch/powerpc/platforms/8xx/tqm8xx_setup.c
@@ -25,7 +25,6 @@
 #include 
 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c
index 404230c1ebb2..6995c10938a8 100644
--- a/drivers/tty/serial/ucc_uart.c
+++ b/drivers/tty/serial/ucc_uart.c
@@ -28,7 +28,6 @@
 #include 
 #include 
 
-#include 
 #include 
 
 #include 
-- 
2.41.0



[PATCH v1 00/12] serial: cpm_uart: Cleanup and refactoring

2023-08-03 Thread Christophe Leroy
This series is a dust removal and cleanup of cpm_uart serial driver.

After cleaning up things we see that CPM1 and CPM2 have so much in
common that it is not worth keeping separate code.

Once refactoring is done, there is only one .c and one .h in cpm_uart/
subdirectory so its worth getting rid of cpm_uart/ subdir.

The last part leads to the complete removal of include/linux/fs_uart_pd.h

Christophe Leroy (12):
  serial: cpm_uart: Avoid suspicious locking
  serial: cpm_uart: Remove stale prototypes and table and macros
  serial: cpm_uart: Stop using fs_uart_id enum
  serial: cpm_uart: Use get_baudrate() instead of uart_baudrate()
  serial: cpm_uart: Deduplicate cpm_set_{brg/smc_fcr/scc_fcr}()
  serial: cpm_uart: Deduplicate cpm_line_cr_cmd()
  serial: cpm_uart: Refactor cpm_uart_allocbuf()/cpm_uart_freebuf()
  serial: cpm_uart: Refactor cpm_uart_[un]map_pram()
  serial: cpm_uart: Remove cpm_uart/ subdirectory
  serial: cpm_uart: Remove stale prototype in powerpc/fsl_soc.c
  serial: cpm_uart: Don't include fs_uart_pd.h when not needed
  serial: cpm_uart: Remove linux/fs_uart_pd.h

 arch/powerpc/include/asm/fs_pd.h  |  10 --
 arch/powerpc/platforms/8xx/mpc885ads_setup.c  |   1 -
 arch/powerpc/platforms/8xx/tqm8xx_setup.c |   1 -
 arch/powerpc/sysdev/fsl_soc.c |   2 -
 drivers/tty/serial/Makefile   |   2 +-
 .../{cpm_uart/cpm_uart_core.c => cpm_uart.c}  | 157 --
 drivers/tty/serial/{cpm_uart => }/cpm_uart.h  |  38 +
 drivers/tty/serial/cpm_uart/Makefile  |  12 --
 drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c   | 122 --
 drivers/tty/serial/cpm_uart/cpm_uart_cpm1.h   |  33 
 drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c   | 156 -
 drivers/tty/serial/cpm_uart/cpm_uart_cpm2.h   |  33 
 drivers/tty/serial/ucc_uart.c |   1 -
 include/linux/fs_uart_pd.h|  71 
 14 files changed, 145 insertions(+), 494 deletions(-)
 rename drivers/tty/serial/{cpm_uart/cpm_uart_core.c => cpm_uart.c} (90%)
 rename drivers/tty/serial/{cpm_uart => }/cpm_uart.h (64%)
 delete mode 100644 drivers/tty/serial/cpm_uart/Makefile
 delete mode 100644 drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
 delete mode 100644 drivers/tty/serial/cpm_uart/cpm_uart_cpm1.h
 delete mode 100644 drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
 delete mode 100644 drivers/tty/serial/cpm_uart/cpm_uart_cpm2.h
 delete mode 100644 include/linux/fs_uart_pd.h

-- 
2.41.0



[PATCH v1 02/12] serial: cpm_uart: Remove stale prototypes and table and macros

2023-08-03 Thread Christophe Leroy
cpm_uart_init_portdesc()
smc1_lineif()
smc2_lineif()
scc1_lineif()
scc2_lineif()
scc3_lineif()
scc4_lineif()

Those functions were removed by commit 0b2a2e5b7747 ("cpm_uart: Remove
!CONFIG_PPC_CPM_NEW_BINDING code"). Remove stale prototypes.

UART_SMC{1..2} and UART_SCC{1..4} and SCC_WAIT_CLOSING macros are not
used anymore since the above commit.

cpm_uart_ports[] isn't used outside cpm_uart_core.c since the
same commit, so make it static.

cpm_uart_init_smc() and cpm_uart_init_scc() don't need a forward
declaration.

FLAG_DISCARDING and IS_DISCARDING have never been used since at
least 2.6.12 and the start of git repository for kernel.

Signed-off-by: Christophe Leroy 
---
 drivers/tty/serial/cpm_uart/cpm_uart.h  | 21 -
 drivers/tty/serial/cpm_uart/cpm_uart_core.c |  4 +---
 2 files changed, 1 insertion(+), 24 deletions(-)

diff --git a/drivers/tty/serial/cpm_uart/cpm_uart.h 
b/drivers/tty/serial/cpm_uart/cpm_uart.h
index 46c03ed71c31..687b48fc6fb6 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart.h
+++ b/drivers/tty/serial/cpm_uart/cpm_uart.h
@@ -25,18 +25,9 @@ struct gpio_desc;
 #define SERIAL_CPM_MINOR   46
 
 #define IS_SMC(pinfo)  (pinfo->flags & FLAG_SMC)
-#define IS_DISCARDING(pinfo)   (pinfo->flags & FLAG_DISCARDING)
-#define FLAG_DISCARDING0x0004  /* when set, don't discard */
 #define FLAG_SMC   0x0002
 #define FLAG_CONSOLE   0x0001
 
-#define UART_SMC1  fsid_smc1_uart
-#define UART_SMC2  fsid_smc2_uart
-#define UART_SCC1  fsid_scc1_uart
-#define UART_SCC2  fsid_scc2_uart
-#define UART_SCC3  fsid_scc3_uart
-#define UART_SCC4  fsid_scc4_uart
-
 #define UART_NRfs_uart_nr
 
 #define RX_NUM_FIFO4
@@ -44,8 +35,6 @@ struct gpio_desc;
 #define TX_NUM_FIFO4
 #define TX_BUF_SIZE32
 
-#define SCC_WAIT_CLOSING 100
-
 #define GPIO_CTS   0
 #define GPIO_RTS   1
 #define GPIO_DCD   2
@@ -85,24 +74,14 @@ struct uart_cpm_port {
struct gpio_desc*gpios[NUM_GPIOS];
 };
 
-extern struct uart_cpm_port cpm_uart_ports[UART_NR];
-
 /* these are located in their respective files */
 void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd);
 void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
struct device_node *np);
 void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram);
-int cpm_uart_init_portdesc(void);
 int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con);
 void cpm_uart_freebuf(struct uart_cpm_port *pinfo);
 
-void smc1_lineif(struct uart_cpm_port *pinfo);
-void smc2_lineif(struct uart_cpm_port *pinfo);
-void scc1_lineif(struct uart_cpm_port *pinfo);
-void scc2_lineif(struct uart_cpm_port *pinfo);
-void scc3_lineif(struct uart_cpm_port *pinfo);
-void scc4_lineif(struct uart_cpm_port *pinfo);
-
 /*
virtual to phys transtalion
 */
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c 
b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index 71366a4cea22..d804dd4019c0 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -48,8 +48,6 @@
 /**/
 
 static int  cpm_uart_tx_pump(struct uart_port *port);
-static void cpm_uart_init_smc(struct uart_cpm_port *pinfo);
-static void cpm_uart_init_scc(struct uart_cpm_port *pinfo);
 static void cpm_uart_initbd(struct uart_cpm_port *pinfo);
 
 /**/
@@ -1128,7 +1126,7 @@ static const struct uart_ops cpm_uart_pops = {
 #endif
 };
 
-struct uart_cpm_port cpm_uart_ports[UART_NR];
+static struct uart_cpm_port cpm_uart_ports[UART_NR];
 
 static int cpm_uart_init_port(struct device_node *np,
   struct uart_cpm_port *pinfo)
-- 
2.41.0



[PATCH v1 01/12] serial: cpm_uart: Avoid suspicious locking

2023-08-03 Thread Christophe Leroy
  CHECK   drivers/tty/serial/cpm_uart/cpm_uart_core.c
drivers/tty/serial/cpm_uart/cpm_uart_core.c:1271:39: warning: context imbalance 
in 'cpm_uart_console_write' - unexpected unlock

Allthough 'nolock' is not expected to change, sparse find the following
form suspicious:

if (unlikely(nolock)) {
local_irq_save(flags);
} else {
spin_lock_irqsave(>port.lock, flags);
}

cpm_uart_early_write(pinfo, s, count, true);

if (unlikely(nolock)) {
local_irq_restore(flags);
} else {
spin_unlock_irqrestore(>port.lock, flags);
}

Rewrite it a more obvious form:

if (unlikely(oops_in_progress)) {
local_irq_save(flags);
cpm_uart_early_write(pinfo, s, count, true);
local_irq_restore(flags);
} else {
spin_lock_irqsave(>port.lock, flags);
cpm_uart_early_write(pinfo, s, count, true);
spin_unlock_irqrestore(>port.lock, flags);
}

Signed-off-by: Christophe Leroy 
---
 drivers/tty/serial/cpm_uart/cpm_uart_core.c | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c 
b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index 66afa9bea6bf..71366a4cea22 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -1255,19 +1255,14 @@ static void cpm_uart_console_write(struct console *co, 
const char *s,
 {
struct uart_cpm_port *pinfo = _uart_ports[co->index];
unsigned long flags;
-   int nolock = oops_in_progress;
 
-   if (unlikely(nolock)) {
+   if (unlikely(oops_in_progress)) {
local_irq_save(flags);
-   } else {
-   spin_lock_irqsave(>port.lock, flags);
-   }
-
-   cpm_uart_early_write(pinfo, s, count, true);
-
-   if (unlikely(nolock)) {
+   cpm_uart_early_write(pinfo, s, count, true);
local_irq_restore(flags);
} else {
+   spin_lock_irqsave(>port.lock, flags);
+   cpm_uart_early_write(pinfo, s, count, true);
spin_unlock_irqrestore(>port.lock, flags);
}
 }
-- 
2.41.0



[PATCH v1 03/12] serial: cpm_uart: Stop using fs_uart_id enum

2023-08-03 Thread Christophe Leroy
Using an enum indirection to define numeric macros is
pointless. Directly use the wanted numeric value.

Signed-off-by: Christophe Leroy 
---
 drivers/tty/serial/cpm_uart/cpm_uart.h  | 3 +--
 drivers/tty/serial/cpm_uart/cpm_uart_core.c | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/tty/serial/cpm_uart/cpm_uart.h 
b/drivers/tty/serial/cpm_uart/cpm_uart.h
index 687b48fc6fb6..c220700df693 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart.h
+++ b/drivers/tty/serial/cpm_uart/cpm_uart.h
@@ -11,7 +11,6 @@
 #define CPM_UART_H
 
 #include 
-#include 
 
 struct gpio_desc;
 
@@ -28,7 +27,7 @@ struct gpio_desc;
 #define FLAG_SMC   0x0002
 #define FLAG_CONSOLE   0x0001
 
-#define UART_NRfs_uart_nr
+#define UART_NR6
 
 #define RX_NUM_FIFO4
 #define RX_BUF_SIZE32
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c 
b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index d804dd4019c0..c5a896f79d80 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -26,7 +26,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
2.41.0



Re: [RFC PATCH v2 0/7] Add audio support in v4l2 framework

2023-08-03 Thread Shengjiu Wang
On Thu, Aug 3, 2023 at 1:28 AM Mark Brown  wrote:
>
> On Wed, Aug 02, 2023 at 10:41:43PM +0800, Shengjiu Wang wrote:
>
> > Currently the ASRC in ALSA is to connect to another I2S device as
> > a sound card.  But we'd like to the ASRC can be used by user space directly
> > that user space application can get the output after conversion from ASRC.
>
> That sort of use case would be handled via DPCM at the minute, though
> persuading it to connect two front ends together might be fun (which is
> the sort of reason why we want to push digital information down into
> DAPM and make everything a component).

Thanks.

ASRC M2M case needs to run as fast as possible, no sync clock control.
If use sound card to handle ASRC M2M case,  the user application
should be aplay/arecord, then we need to consider xrun issue, buffer
may timeout, sync between aplay and arecord,  these should't be
considered by pure memory to memory operation.

DPCM may achitect all the audio things in components and sound
card,  it is good. but for the M2M case, it is complcated. not sure
it is doable.

best regards
wang shengjiu


[PATCH AUTOSEL 5.4 2/2] powerpc/kasan: Disable KCOV in KASAN code

2023-08-03 Thread Sasha Levin
From: Benjamin Gray 

[ Upstream commit ccb381e1af1ace292153c88eb1fffa5683d16a20 ]

As per the generic KASAN code in mm/kasan, disable KCOV with
KCOV_INSTRUMENT := n in the makefile.

This fixes a ppc64 boot hang when KCOV and KASAN are enabled.
kasan_early_init() gets called before a PACA is initialised, but the
KCOV hook expects a valid PACA.

Suggested-by: Christophe Leroy 
Signed-off-by: Benjamin Gray 
Signed-off-by: Michael Ellerman 
Link: https://msgid.link/20230710044143.146840-1-bg...@linux.ibm.com
Signed-off-by: Sasha Levin 
---
 arch/powerpc/mm/kasan/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/mm/kasan/Makefile b/arch/powerpc/mm/kasan/Makefile
index 6577897673dda..22f1a7c3f4362 100644
--- a/arch/powerpc/mm/kasan/Makefile
+++ b/arch/powerpc/mm/kasan/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
 KASAN_SANITIZE := n
+KCOV_INSTRUMENT := n
 
 obj-$(CONFIG_PPC32)   += kasan_init_32.o
-- 
2.40.1



[PATCH AUTOSEL 5.10 2/3] powerpc/kasan: Disable KCOV in KASAN code

2023-08-03 Thread Sasha Levin
From: Benjamin Gray 

[ Upstream commit ccb381e1af1ace292153c88eb1fffa5683d16a20 ]

As per the generic KASAN code in mm/kasan, disable KCOV with
KCOV_INSTRUMENT := n in the makefile.

This fixes a ppc64 boot hang when KCOV and KASAN are enabled.
kasan_early_init() gets called before a PACA is initialised, but the
KCOV hook expects a valid PACA.

Suggested-by: Christophe Leroy 
Signed-off-by: Benjamin Gray 
Signed-off-by: Michael Ellerman 
Link: https://msgid.link/20230710044143.146840-1-bg...@linux.ibm.com
Signed-off-by: Sasha Levin 
---
 arch/powerpc/mm/kasan/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/mm/kasan/Makefile b/arch/powerpc/mm/kasan/Makefile
index bb1a5408b86b2..8636b17c6a20f 100644
--- a/arch/powerpc/mm/kasan/Makefile
+++ b/arch/powerpc/mm/kasan/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
 KASAN_SANITIZE := n
+KCOV_INSTRUMENT := n
 
 obj-$(CONFIG_PPC32)   += kasan_init_32.o
 obj-$(CONFIG_PPC_8xx)  += 8xx.o
-- 
2.40.1



[PATCH AUTOSEL 5.15 2/3] powerpc/kasan: Disable KCOV in KASAN code

2023-08-03 Thread Sasha Levin
From: Benjamin Gray 

[ Upstream commit ccb381e1af1ace292153c88eb1fffa5683d16a20 ]

As per the generic KASAN code in mm/kasan, disable KCOV with
KCOV_INSTRUMENT := n in the makefile.

This fixes a ppc64 boot hang when KCOV and KASAN are enabled.
kasan_early_init() gets called before a PACA is initialised, but the
KCOV hook expects a valid PACA.

Suggested-by: Christophe Leroy 
Signed-off-by: Benjamin Gray 
Signed-off-by: Michael Ellerman 
Link: https://msgid.link/20230710044143.146840-1-bg...@linux.ibm.com
Signed-off-by: Sasha Levin 
---
 arch/powerpc/mm/kasan/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/mm/kasan/Makefile b/arch/powerpc/mm/kasan/Makefile
index bb1a5408b86b2..8636b17c6a20f 100644
--- a/arch/powerpc/mm/kasan/Makefile
+++ b/arch/powerpc/mm/kasan/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
 KASAN_SANITIZE := n
+KCOV_INSTRUMENT := n
 
 obj-$(CONFIG_PPC32)   += kasan_init_32.o
 obj-$(CONFIG_PPC_8xx)  += 8xx.o
-- 
2.40.1



[PATCH AUTOSEL 6.1 2/4] powerpc/kasan: Disable KCOV in KASAN code

2023-08-03 Thread Sasha Levin
From: Benjamin Gray 

[ Upstream commit ccb381e1af1ace292153c88eb1fffa5683d16a20 ]

As per the generic KASAN code in mm/kasan, disable KCOV with
KCOV_INSTRUMENT := n in the makefile.

This fixes a ppc64 boot hang when KCOV and KASAN are enabled.
kasan_early_init() gets called before a PACA is initialised, but the
KCOV hook expects a valid PACA.

Suggested-by: Christophe Leroy 
Signed-off-by: Benjamin Gray 
Signed-off-by: Michael Ellerman 
Link: https://msgid.link/20230710044143.146840-1-bg...@linux.ibm.com
Signed-off-by: Sasha Levin 
---
 arch/powerpc/mm/kasan/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/mm/kasan/Makefile b/arch/powerpc/mm/kasan/Makefile
index 699eeffd9f551..f9522fd70b2f3 100644
--- a/arch/powerpc/mm/kasan/Makefile
+++ b/arch/powerpc/mm/kasan/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
 KASAN_SANITIZE := n
+KCOV_INSTRUMENT := n
 
 obj-$(CONFIG_PPC32)+= init_32.o
 obj-$(CONFIG_PPC_8xx)  += 8xx.o
-- 
2.40.1



[PATCH AUTOSEL 6.4 2/4] powerpc/kasan: Disable KCOV in KASAN code

2023-08-03 Thread Sasha Levin
From: Benjamin Gray 

[ Upstream commit ccb381e1af1ace292153c88eb1fffa5683d16a20 ]

As per the generic KASAN code in mm/kasan, disable KCOV with
KCOV_INSTRUMENT := n in the makefile.

This fixes a ppc64 boot hang when KCOV and KASAN are enabled.
kasan_early_init() gets called before a PACA is initialised, but the
KCOV hook expects a valid PACA.

Suggested-by: Christophe Leroy 
Signed-off-by: Benjamin Gray 
Signed-off-by: Michael Ellerman 
Link: https://msgid.link/20230710044143.146840-1-bg...@linux.ibm.com
Signed-off-by: Sasha Levin 
---
 arch/powerpc/mm/kasan/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/mm/kasan/Makefile b/arch/powerpc/mm/kasan/Makefile
index 699eeffd9f551..f9522fd70b2f3 100644
--- a/arch/powerpc/mm/kasan/Makefile
+++ b/arch/powerpc/mm/kasan/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
 KASAN_SANITIZE := n
+KCOV_INSTRUMENT := n
 
 obj-$(CONFIG_PPC32)+= init_32.o
 obj-$(CONFIG_PPC_8xx)  += 8xx.o
-- 
2.40.1



Re: [PATCH v2 RESEND*3] ASoC: fsl MPC52xx drivers require PPC_BESTCOMM

2023-08-03 Thread Mark Brown
On Wed, Aug 02, 2023 at 07:59:41PM -0700, Randy Dunlap wrote:
> Both SND_MPC52xx_SOC_PCM030 and SND_MPC52xx_SOC_EFIKA select
> SND_SOC_MPC5200_AC97. The latter symbol depends on PPC_BESTCOMM,
> so the 2 former symbols should also depend on PPC_BESTCOMM since
> "select" does not follow any dependency chains.

Take a hint, it's not clear that the patch is tasteful.


signature.asc
Description: PGP signature


[PATCH -next 0/2] soc: Do not check for 0 return after calling platform_get_irq()

2023-08-03 Thread Ruan Jinjie
Since commit ce753ad1549c ("platform: finally disallow IRQ0 in
platform_get_irq() and its ilk"), there is no possible for
platform_get_irq() to return 0.

And the return value of platform_get_irq() is
more sensible to show the error reason.

Ruan Jinjie (2):
  soc: fsl: qe: Do not check for 0 return after calling
platform_get_irq()
  soc: xilinx: Do not check for 0 return after calling
platform_get_irq()

 drivers/soc/fsl/qe/qe_ic.c| 4 ++--
 drivers/soc/xilinx/zynqmp_power.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

-- 
2.34.1



[PATCH -next 1/2] soc: fsl: qe: Do not check for 0 return after calling platform_get_irq()

2023-08-03 Thread Ruan Jinjie
There is no possible for platform_get_irq() to
return 0. Use the return value from platform_get_irq().

Signed-off-by: Ruan Jinjie 
---
 drivers/soc/fsl/qe/qe_ic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/fsl/qe/qe_ic.c b/drivers/soc/fsl/qe/qe_ic.c
index bbae3d39c7be..8ab6e51e4f28 100644
--- a/drivers/soc/fsl/qe/qe_ic.c
+++ b/drivers/soc/fsl/qe/qe_ic.c
@@ -435,8 +435,8 @@ static int qe_ic_init(struct platform_device *pdev)
qe_ic->virq_high = platform_get_irq(pdev, 0);
qe_ic->virq_low = platform_get_irq(pdev, 1);
 
-   if (qe_ic->virq_low <= 0)
-   return -ENODEV;
+   if (qe_ic->virq_low < 0)
+   return qe_ic->virq_low;
 
if (qe_ic->virq_high > 0 && qe_ic->virq_high != qe_ic->virq_low) {
low_handler = qe_ic_cascade_low;
-- 
2.34.1



[PATCH -next 2/2] soc: xilinx: Do not check for 0 return after calling platform_get_irq()

2023-08-03 Thread Ruan Jinjie
There is no possible for platform_get_irq() to
return 0. Use the return value from platform_get_irq().

Signed-off-by: Ruan Jinjie 
---
 drivers/soc/xilinx/zynqmp_power.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/xilinx/zynqmp_power.c 
b/drivers/soc/xilinx/zynqmp_power.c
index 641dcc958911..eddfc8141a42 100644
--- a/drivers/soc/xilinx/zynqmp_power.c
+++ b/drivers/soc/xilinx/zynqmp_power.c
@@ -242,8 +242,8 @@ static int zynqmp_pm_probe(struct platform_device *pdev)
}
} else if (of_property_present(pdev->dev.of_node, "interrupts")) {
irq = platform_get_irq(pdev, 0);
-   if (irq <= 0)
-   return -ENXIO;
+   if (irq < 0)
+   return irq;
 
ret = devm_request_threaded_irq(>dev, irq, NULL,
zynqmp_pm_isr,
-- 
2.34.1



Re: [RFC PATCH v11 00/29] KVM: guest_memfd() and per-page attributes

2023-08-03 Thread Vlastimil Babka
On 7/26/23 13:20, Nikunj A. Dadhania wrote:
> Hi Sean,
> 
> On 7/24/2023 10:30 PM, Sean Christopherson wrote:
>> On Mon, Jul 24, 2023, Nikunj A. Dadhania wrote:
>>> On 7/19/2023 5:14 AM, Sean Christopherson wrote:
 This is the next iteration of implementing fd-based (instead of vma-based)
 memory for KVM guests.  If you want the full background of why we are doing
 this, please go read the v10 cover letter[1].

 The biggest change from v10 is to implement the backing storage in KVM
 itself, and expose it via a KVM ioctl() instead of a "generic" sycall.
 See link[2] for details on why we pivoted to a KVM-specific approach.

 Key word is "biggest".  Relative to v10, there are many big changes.
 Highlights below (I can't remember everything that got changed at
 this point).

 Tagged RFC as there are a lot of empty changelogs, and a lot of missing
 documentation.  And ideally, we'll have even more tests before merging.
 There are also several gaps/opens (to be discussed in tomorrow's PUCK).
>>>
>>> As per our discussion on the PUCK call, here are the memory/NUMA accounting 
>>> related observations that I had while working on SNP guest secure page 
>>> migration:
>>>
>>> * gmem allocations are currently treated as file page allocations
>>>   accounted to the kernel and not to the QEMU process.
>> 
>> We need to level set on terminology: these are all *stats*, not accounting.  
>> That
>> distinction matters because we have wiggle room on stats, e.g. we can 
>> probably get
>> away with just about any definition of how guest_memfd memory impacts stats, 
>> so
>> long as the information that is surfaced to userspace is useful and expected.
>> 
>> But we absolutely need to get accounting correct, specifically the 
>> allocations
>> need to be correctly accounted in memcg.  And unless I'm missing something,
>> nothing in here shows anything related to memcg.
> 
> I tried out memcg after creating a separate cgroup for the qemu process. 
> Guest 
> memory is accounted in memcg.
> 
>   $ egrep -w "file|file_thp|unevictable" memory.stat
>   file 42978775040
>   file_thp 42949672960
>   unevictable 42953588736 
> 
> NUMA allocations are coming from right nodes as set by the numactl.
> 
>   $ egrep -w "file|file_thp|unevictable" memory.numa_stat
>   file N0=0 N1=20480 N2=21489377280 N3=21489377280
>   file_thp N0=0 N1=0 N2=21472739328 N3=21476933632
>   unevictable N0=0 N1=0 N2=21474697216 N3=21478891520
> 
>> 
>>>   Starting an SNP guest with 40G memory with memory interleave between
>>>   Node2 and Node3
>>>
>>>   $ numactl -i 2,3 ./bootg_snp.sh
>>>
>>> PID USER  PR  NIVIRTRESSHR S  %CPU  %MEM TIME+ 
>>> COMMAND
>>>  242179 root  20   0   40.4g  99580  51676 S  78.0   0.0   0:56.58 
>>> qemu-system-x86
>>>
>>>   -> Incorrect process resident memory and shared memory is reported
>> 
>> I don't know that I would call these "incorrect".  Shared memory definitely 
>> is
>> correct, because by definition guest_memfd isn't shared.  RSS is less clear 
>> cut;
>> gmem memory is resident in RAM, but if we show gmem in RSS then we'll end up 
>> with
>> scenarios where RSS > VIRT, which will be quite confusing for unaware users 
>> (I'm
>> assuming the 40g of VIRT here comes from QEMU mapping the shared half of gmem
>> memslots).
> 
> I am not sure why will RSS exceed the VIRT, it should be at max 40G (assuming 
> all the
> memory is private)
> 
> As per my experiments with a hack below. MM_FILEPAGES does get accounted to 
> RSS/SHR in top
> 
> PID USER  PR  NIVIRTRESSHR S  %CPU  %MEM TIME+ COMMAND
>4339 root  20   0   40.4g  40.1g  40.1g S  76.7  16.0   0:13.83 
> qemu-system-x86
> 
> diff --git a/mm/memory.c b/mm/memory.c
> index f456f3b5049c..5b1f48a2e714 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -166,6 +166,7 @@ void mm_trace_rss_stat(struct mm_struct *mm, int member)
>  {
> trace_rss_stat(mm, member);
>  }
> +EXPORT_SYMBOL(mm_trace_rss_stat);
> 
>  /*
>   * Note: this doesn't free the actual pages themselves. That
> diff --git a/virt/kvm/guest_mem.c b/virt/kvm/guest_mem.c
> index a7e926af4255..e4f268bf9ce2 100644
> --- a/virt/kvm/guest_mem.c
> +++ b/virt/kvm/guest_mem.c
> @@ -91,6 +91,10 @@ static struct folio *kvm_gmem_get_folio(struct file *file, 
> pgoff_t index)
> clear_highpage(folio_page(folio, i));
> }
> 
> +   /* Account only once for the first time */
> +   if (!folio_test_dirty(folio))
> +   add_mm_counter(current->mm, MM_FILEPAGES, 
> folio_nr_pages(folio));

I think this alone would cause "Bad rss-counter" messages when the process
exits, because there's no corresponding decrement when page tables are torn
down. We would probably have to instantiate the page tables (i.e. with
PROT_NONE so userspace can't really do accesses through them) for this to
work properly.

So then it wouldn't technically be "unmapped private memory" 

Re: [RFC PATCH 01/21] crypto: scomp - Revert "add support for deflate rfc1950 (zlib)"

2023-08-03 Thread Ard Biesheuvel
Hello Giovanni,

On Thu, 3 Aug 2023 at 11:51, Giovanni Cabiddu
 wrote:
>
> Hi Ard,
>
> On Tue, Jul 18, 2023 at 01:58:27PM +0100, Ard Biesheuvel wrote:
> > This reverts commit a368f43d6e3a001e684e9191a27df384fbff12f5.
> >
> > "zlib-deflate" was introduced 6 years ago, but it does not have any
> > users. So let's remove the generic implementation and the test vectors,
> > but retain the "zlib-deflate" entry in the testmgr code to avoid
> > introducing warning messages on systems that implement zlib-deflate in
> > hardware.
> >
> > Note that RFC 1950 which forms the basis of this algorithm dates back to
> > 1996, and predates RFC 1951, on which the existing IPcomp is based and
> > which we have supported in the kernel since 2003. So it seems rather
> > unlikely that we will ever grow the need to support zlib-deflate.
> >
> > Signed-off-by: Ard Biesheuvel 
> Support for zlib-deflate was added for [1] but that work was not
> completed.
>

Any clue why zlib_deflate was chosen in this case?

/me also notes that this is another occurrence of the antipattern
where we use an asynchronous API and subsequently sleep on the
completion.

> Based on [2], either we leave this SW implementation or we remove the HW
> implementations in the QAT [3] and in the Hisilicon Zip [4] drivers.
>

That would work for me as well - dead code is just busywork.

> [1] 
> https://patchwork.kernel.org/project/linux-btrfs/patch/1467083180-111750-1-git-send-email-weigang...@intel.com/
> [2] https://lore.kernel.org/lkml/ziw%2fjtxdg6o1o...@gondor.apana.org.au/
> [3] 
> https://elixir.bootlin.com/linux/latest/source/drivers/crypto/intel/qat/qat_common/qat_comp_algs.c#L457
> [4] 
> https://elixir.bootlin.com/linux/latest/source/drivers/crypto/hisilicon/zip/zip_crypto.c#L754
>
> Regards,
>
> --
> Giovanni


Re: [PATCH v7 7/7] mm/memory_hotplug: Enable runtime update of memmap_on_memory parameter

2023-08-03 Thread David Hildenbrand

On 03.08.23 10:52, Michal Hocko wrote:

On Wed 02-08-23 18:59:04, Michal Hocko wrote:

On Wed 02-08-23 17:54:04, David Hildenbrand wrote:

On 02.08.23 17:50, Michal Hocko wrote:

On Wed 02-08-23 10:15:04, Aneesh Kumar K V wrote:

On 8/1/23 4:20 PM, Michal Hocko wrote:

On Tue 01-08-23 14:58:29, Aneesh Kumar K V wrote:

On 8/1/23 2:28 PM, Michal Hocko wrote:

On Tue 01-08-23 10:11:16, Aneesh Kumar K.V wrote:

Allow updating memmap_on_memory mode after the kernel boot. Memory
hotplug done after the mode update will use the new mmemap_on_memory
value.


Well, this is a user space kABI extension and as such you should spend
more words about the usecase. Why we could live with this static and now
need dynamic?



This enables easy testing of memmap_on_memory feature without a kernel reboot.


Testing alone is rather weak argument to be honest.


I also expect people wanting to use that when they find dax kmem memory online
failing because of struct page allocation failures[1]. User could reboot back 
with
memmap_on_memory=y kernel parameter. But being able to enable it via sysfs makes
the feature much more useful.


Sure it can be useful but that holds for any feature, right. The main
question is whether this is worth maintaing. The current implementation
seems rather trivial which is an argument to have it but are there any
risks long term? Have you evaluated a potential long term maintenance
cost? There is no easy way to go back and disable it later on without
breaking some userspace.

All that should be in the changelog!


I updated it as below.

mm/memory_hotplug: Enable runtime update of memmap_on_memory parameter

Allow updating memmap_on_memory mode after the kernel boot. Memory
hotplug done after the mode update will use the new mmemap_on_memory
value.

It is now possible to test the memmap_on_memory feature easily without
the need for a kernel reboot. Additionally, for those encountering
struct page allocation failures while using dax kmem memory online, this
feature may prove useful. Instead of rebooting with the
memmap_on_memory=y kernel parameter, users can now enable it via sysfs,
which greatly enhances its usefulness.



I do not really see a solid argument why rebooting is really a problem
TBH. Also is the global policy knob really the right fit for existing
hotplug usecases? In other words, if we really want to make
memmap_on_memory more flexible would it make more sense to have it per
memory block property instead (the global knob being the default if
admin doesn't specify it differently).


Per memory block isn't possible, due to the creation order.


I am not sure I follow. Could you elaborate more?


Must have been a tired brain. Now I see what you mean of course. vmemmap
is allocated at the time the range is registered and therefore memory
block sysfs created. So you are right that it is too late in some sense
but I still believe that this would be doable. The memmap_on_memory file


Exactly.


would be readable only when the block is offline and it would reallocate
vmemmap on the change. Makes sense? Are there any risks? Maybe pfn
walkers?


The question is: is it of any real value such that it would be worth the 
cost and risk?



One of the primary reasons for memmap_on_memory is that *memory hotplug* 
succeeds even in low-memory situations (including, low on ZONE_NORMAL 
situations). So you want that behavior already when hotplugging such 
devices. While there might be value to relocate it later, I'm not sure 
if that is really worth it, and it does not solve the main use case.


For dax/kmem memory hotplug this is controlled by user space, so user 
space can easily configure it. For DIMMs it's just a hotplug event that 
triggers all that in the kernel, and one has to plan ahead (e.g., set 
the global kernel parameter).


Besides, devices like virtio-mem really cannot universally support 
memmap_on_memory.


--
Cheers,

David / dhildenb



Re: [PATCH v7 7/7] mm/memory_hotplug: Enable runtime update of memmap_on_memory parameter

2023-08-03 Thread Michal Hocko
On Wed 02-08-23 18:59:04, Michal Hocko wrote:
> On Wed 02-08-23 17:54:04, David Hildenbrand wrote:
> > On 02.08.23 17:50, Michal Hocko wrote:
> > > On Wed 02-08-23 10:15:04, Aneesh Kumar K V wrote:
> > > > On 8/1/23 4:20 PM, Michal Hocko wrote:
> > > > > On Tue 01-08-23 14:58:29, Aneesh Kumar K V wrote:
> > > > > > On 8/1/23 2:28 PM, Michal Hocko wrote:
> > > > > > > On Tue 01-08-23 10:11:16, Aneesh Kumar K.V wrote:
> > > > > > > > Allow updating memmap_on_memory mode after the kernel boot. 
> > > > > > > > Memory
> > > > > > > > hotplug done after the mode update will use the new 
> > > > > > > > mmemap_on_memory
> > > > > > > > value.
> > > > > > > 
> > > > > > > Well, this is a user space kABI extension and as such you should 
> > > > > > > spend
> > > > > > > more words about the usecase. Why we could live with this static 
> > > > > > > and now
> > > > > > > need dynamic?
> > > > > > > 
> > > > > > 
> > > > > > This enables easy testing of memmap_on_memory feature without a 
> > > > > > kernel reboot.
> > > > > 
> > > > > Testing alone is rather weak argument to be honest.
> > > > > 
> > > > > > I also expect people wanting to use that when they find dax kmem 
> > > > > > memory online
> > > > > > failing because of struct page allocation failures[1]. User could 
> > > > > > reboot back with
> > > > > > memmap_on_memory=y kernel parameter. But being able to enable it 
> > > > > > via sysfs makes
> > > > > > the feature much more useful.
> > > > > 
> > > > > Sure it can be useful but that holds for any feature, right. The main
> > > > > question is whether this is worth maintaing. The current 
> > > > > implementation
> > > > > seems rather trivial which is an argument to have it but are there any
> > > > > risks long term? Have you evaluated a potential long term maintenance
> > > > > cost? There is no easy way to go back and disable it later on without
> > > > > breaking some userspace.
> > > > > 
> > > > > All that should be in the changelog!
> > > > 
> > > > I updated it as below.
> > > > 
> > > > mm/memory_hotplug: Enable runtime update of memmap_on_memory parameter
> > > > 
> > > > Allow updating memmap_on_memory mode after the kernel boot. Memory
> > > > hotplug done after the mode update will use the new mmemap_on_memory
> > > > value.
> > > > 
> > > > It is now possible to test the memmap_on_memory feature easily without
> > > > the need for a kernel reboot. Additionally, for those encountering
> > > > struct page allocation failures while using dax kmem memory online, this
> > > > feature may prove useful. Instead of rebooting with the
> > > > memmap_on_memory=y kernel parameter, users can now enable it via sysfs,
> > > > which greatly enhances its usefulness.
> > > 
> > > 
> > > I do not really see a solid argument why rebooting is really a problem
> > > TBH. Also is the global policy knob really the right fit for existing
> > > hotplug usecases? In other words, if we really want to make
> > > memmap_on_memory more flexible would it make more sense to have it per
> > > memory block property instead (the global knob being the default if
> > > admin doesn't specify it differently).
> > 
> > Per memory block isn't possible, due to the creation order.
> 
> I am not sure I follow. Could you elaborate more?

Must have been a tired brain. Now I see what you mean of course. vmemmap
is allocated at the time the range is registered and therefore memory
block sysfs created. So you are right that it is too late in some sense
but I still believe that this would be doable. The memmap_on_memory file
would be readable only when the block is offline and it would reallocate
vmemmap on the change. Makes sense? Are there any risks? Maybe pfn
walkers?

-- 
Michal Hocko
SUSE Labs


Re: [PATCH v2 27/28] dt-bindings: net: fsl,qmc-hdlc: Add framer support

2023-08-03 Thread Herve Codina
Hi Rob,

On Wed, 2 Aug 2023 18:42:59 -0600
Rob Herring  wrote:

> On Wed, Jul 26, 2023 at 05:02:23PM +0200, Herve Codina wrote:
> > A framer can be connected to the QMC HDLC.
> > If present, this framer is the interface between the TDM used by the QMC
> > HDLC and the E1/T1 line.
> > The QMC HDLC can use this framer to get information about the line and
> > configure the line.
> > 
> > Add an optional framer property to reference the framer itself.
> > 
> > Signed-off-by: Herve Codina 
> > ---
> >  Documentation/devicetree/bindings/net/fsl,qmc-hdlc.yaml | 5 +
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/net/fsl,qmc-hdlc.yaml 
> > b/Documentation/devicetree/bindings/net/fsl,qmc-hdlc.yaml
> > index 8bb6f34602d9..bf29863ab419 100644
> > --- a/Documentation/devicetree/bindings/net/fsl,qmc-hdlc.yaml
> > +++ b/Documentation/devicetree/bindings/net/fsl,qmc-hdlc.yaml
> > @@ -27,6 +27,11 @@ properties:
> >Should be a phandle/number pair. The phandle to QMC node and the QMC
> >channel to use.
> >  
> > +  framer:
> > +$ref: /schemas/types.yaml#/definitions/phandle  
> 
> Now you've defined this property twice. Please avoid doing that.

I don't see what you mean.

I previously defined the framer property at the framer-codec node as it is
a framer consumer (it was a mistake because this framer-codec node is a child of
the framer node but that's an other story).

Here, at the qmc-hdlc node, I define this property in order to use the framer 
as a
consumer too.

What is wrong ?

Best regards,
Hervé

> 
> > +description:
> > +  phandle to the framer node
> > +
> >  required:
> >- compatible
> >- fsl,qmc-chan
> > -- 
> > 2.41.0
> >   


Re: [PATCH v2 21/28] dt-bindings: net: Add the Lantiq PEF2256 E1/T1/J1 framer

2023-08-03 Thread Herve Codina
Hi Rob,

On Wed, 2 Aug 2023 18:40:54 -0600
Rob Herring  wrote:

> On Wed, Jul 26, 2023 at 05:02:17PM +0200, Herve Codina wrote:
> > The Lantiq PEF2256 is a framer and line interface component designed to
> > fulfill all required interfacing between an analog E1/T1/J1 line and the
> > digital PCM system highway/H.100 bus.
> > 
> > Signed-off-by: Herve Codina 
> > ---
> >  .../bindings/net/lantiq,pef2256.yaml  | 226 ++
> >  1 file changed, 226 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/net/lantiq,pef2256.yaml
> > 
> > diff --git a/Documentation/devicetree/bindings/net/lantiq,pef2256.yaml 
> > b/Documentation/devicetree/bindings/net/lantiq,pef2256.yaml
> > new file mode 100644
> > index ..b369a20d61b1
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/net/lantiq,pef2256.yaml
> > @@ -0,0 +1,226 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/net/lantiq,pef2256.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Lantiq PEF2256
> > +
> > +maintainers:
> > +  - Herve Codina 
> > +
> > +description:
> > +  The Lantiq PEF2256, also known as Infineon PEF2256 or FALC56, is a 
> > framer and
> > +  line interface component designed to fulfill all required interfacing 
> > between
> > +  an analog E1/T1/J1 line and the digital PCM system highway/H.100 bus.
> > +
> > +properties:
> > +  compatible:
> > +items:
> > +  - const: lantiq,pef2256
> > +
> > +  reg:
> > +maxItems: 1
> > +
> > +  clocks:
> > +items:
> > +  - description: Master clock
> > +  - description: Receive System Clock
> > +  - description: Transmit System Clock
> > +
> > +  clock-names:
> > +items:
> > +  - const: mclk
> > +  - const: sclkr
> > +  - const: sclkx
> > +
> > +  interrupts:
> > +maxItems: 1
> > +
> > +  reset-gpios:
> > +description:
> > +  GPIO used to reset the device.
> > +maxItems: 1
> > +
> > +  '#framer-cells':  
> 
> Looks generic, but no such property is defined. You don't need something 
> like this unless there are multiple providers and you need each 
> provider to define the number of cells.

With the framer infrastructure introduced in this series, multiple providers
can be present. Some framer chips are dual or quad framers.

With this pef2256 framer provider, consumers use "framer = <>;"
but with some others framer provider, we can have "framer = < 1>;"

That's the reason why I set '#framer-cells' in this first framer provider,
even if the value is 0.

> 
> > +const: 0
> > +
> > +  pinctrl:
> > +$ref: /schemas/pinctrl/pinctrl.yaml#
> > +additionalProperties: false
> > +
> > +patternProperties:
> > +  '-pins$':
> > +type: object
> > +$ref: /schemas/pinctrl/pincfg-node.yaml#
> > +additionalProperties: false
> > +
> > +properties:
> > +  pins:
> > +enum: [ RPA, RPB, RPC, RPD, XPA, XPB, XPC, XPD ]
> > +
> > +  function:
> > +enum: [ SYPR, RFM, RFMB, RSIGM, RSIG, DLR, FREEZE, RFSP, LOS,
> > +SYPX, XFMS, XSIG, TCLK, XMFB, XSIGM, DLX, XCLK, XLT,
> > +GPI, GPOH, GPOL ]
> > +
> > +required:
> > +  - pins
> > +  - function
> > +
> > +  lantiq,data-rate-bps:
> > +$ref: /schemas/types.yaml#/definitions/uint32
> > +enum: [2048000, 4096000, 8192000, 16384000]
> > +default: 2048000
> > +description:
> > +  Data rate (bit per seconds) on the system highway.
> > +
> > +  lantiq,clock-falling-edge:
> > +$ref: /schemas/types.yaml#/definitions/flag
> > +description:
> > +  Data is sent on falling edge of the clock (and received on the rising
> > +  edge). If 'clock-falling-edge' is not present, data is sent on the
> > +  rising edge (and received on the falling edge).
> > +
> > +  lantiq,channel-phase:
> > +$ref: /schemas/types.yaml#/definitions/uint32
> > +enum: [0, 1, 2, 3, 4, 5, 6, 7]
> > +default: 0
> > +description:
> > +  The pef2256 delivers a full frame (32 8bit time-slots in E1 and 24 
> > 8bit
> > +  time-slots 8 8bit signaling in E1/J1) every 125us. This lead to a 
> > data
> > +  rate of 2048000 bit/s. When lantiq,data-rate-bps is more than 2048000
> > +  bit/s, the data (all 32 8bit) present in the frame are interleave 
> > with
> > +  unused time-slots. The lantiq,channel-phase property allows to set 
> > the
> > +  correct alignment of the interleave mechanism.
> > +  For instance, suppose lantiq,data-rate-bps = 8192000 (ie 4*2048000), 
> > and
> > +  lantiq,channel-phase = 2, the interleave schema with unused 
> > time-slots
> > +  (nu) and used time-slots (XX) for TSi is
> > +nu nu XX nu nu nu XX nu nu nu XX nu
> > +<-- TSi --> <- TSi+1 -> <- TSi+2 ->
> > +  With lantiq,data-rate-bps = 8192000, and 

Re: [PATCH 1/1] perf tests task_analyzer: Check perf build options for libtraceevent support

2023-08-03 Thread Athira Rajeev



> On 03-Aug-2023, at 8:33 AM, Aditya Gupta  wrote:
> 
> Hi Arnaldo,
> I am working on a patch for 'perf version --has', and will send a patch next

Hi Aditya,

I believe, it will be “perf build —has” option. And not “perf version —has”  ?

Thanks
Athira
> week using that instead of 'perf version --build-options'.
> 
> You can skip this patch if not needed.
> 
> Thanks,
> - Aditya G