[PATCH kernel] KVM: PPC: Book3s: Fix warning about xics_rm_h_xirr_x

2022-06-21 Thread Alexey Kardashevskiy
This fixes "no previous prototype":

arch/powerpc/kvm/book3s_hv_rm_xics.c:482:15:
warning: no previous prototype for 'xics_rm_h_xirr_x' [-Wmissing-prototypes]

Reported by the kernel test robot.

Fixes: b22af9041927 ("KVM: PPC: Book3s: Remove real mode interrupt controller 
hcalls handlers")
Signed-off-by: Alexey Kardashevskiy 
---
 arch/powerpc/kvm/book3s_xics.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/kvm/book3s_xics.h b/arch/powerpc/kvm/book3s_xics.h
index 8e4c79e2fcd8..08fb0843faf5 100644
--- a/arch/powerpc/kvm/book3s_xics.h
+++ b/arch/powerpc/kvm/book3s_xics.h
@@ -143,6 +143,7 @@ static inline struct kvmppc_ics 
*kvmppc_xics_find_ics(struct kvmppc_xics *xics,
 }
 
 extern unsigned long xics_rm_h_xirr(struct kvm_vcpu *vcpu);
+extern unsigned long xics_rm_h_xirr_x(struct kvm_vcpu *vcpu);
 extern int xics_rm_h_ipi(struct kvm_vcpu *vcpu, unsigned long server,
 unsigned long mfrr);
 extern int xics_rm_h_cppr(struct kvm_vcpu *vcpu, unsigned long cppr);
-- 
2.30.2



Re: [PATCHv2 1/2] mm: eliminate ifdef of HAVE_IOREMAP_PROT in .c files

2022-06-21 Thread kernel test robot
Hi Wang,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on akpm-mm/mm-everything]

url:
https://github.com/intel-lab-lkp/linux/commits/Wang-Wenhu/mm-eliminate-ifdef-of-HAVE_IOREMAP_PROT-in-c-files/20220615-140135
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git 
mm-everything
config: m68k-buildonly-randconfig-r001-20220622 
(https://download.01.org/0day-ci/archive/20220622/202206221102.w7hylfxn-...@intel.com/config)
compiler: m68k-linux-gcc (GCC) 11.3.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/intel-lab-lkp/linux/commit/b20efcc877829b6f416cf111bd5ad2b13a0cd08e
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Wang-Wenhu/mm-eliminate-ifdef-of-HAVE_IOREMAP_PROT-in-c-files/20220615-140135
git checkout b20efcc877829b6f416cf111bd5ad2b13a0cd08e
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 
O=build_dir ARCH=m68k SHELL=/bin/bash

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

All errors (new ones prefixed by >>):

>> m68k-linux-ld: drivers/char/mem.o:(.rodata+0x37c): undefined reference to 
>> `generic_access_phys'

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp


Re: [PATCH v5] powerpc/powernv: wire up rng during setup_arch

2022-06-21 Thread Michael Ellerman
Christophe Leroy  writes:
> Le 21/06/2022 à 20:47, Jason A. Donenfeld a écrit :
>> On Tue, Jun 21, 2022 at 06:33:11PM +, Christophe Leroy wrote:
>>> Le 21/06/2022 à 16:08, Jason A. Donenfeld a écrit :
 The platform's RNG must be available before random_init() in order to be
 useful for initial seeding, which in turn means that it needs to be
 called from setup_arch(), rather than from an init call. Fortunately,
 each platform already has a setup_arch function pointer, which means we
 can wire it up that way. Complicating things, however, is that POWER8
 systems need some per-cpu state and kmalloc, which isn't available at
 this stage. So we split things up into an early phase and a later
 opportunistic phase. This commit also removes some noisy log messages
 that don't add much.
>>>
>>> Regarding the kmalloc(), I have not looked at it in details, but usually
>>> you can use memblock_alloc() when kmalloc is not available yet.
>> 
>> That seems a bit excessive, especially as those allocations are long
>> lived. And we don't even *need* it that early, but just before
>> random_init(). Michael is running this v5 on the test rig overnight, so
>> we'll learn in the Australian morning whether this finally did the trick
>> (I hope).
>
> The fact that they are long lived make them a good candidate for 
> memblock_alloc().
>
> But fair enough, if they are not required that early then just do it later.

memblock works but then we trip on ioremap vs early_ioremap.

Fixing that is a bit of a pain as we'd have to stop using of_iomap() and
we'd also need to switch the mappings to ioremap() later in boot.

We'd also have to defer the percpu initialisation.

So it's all just a bit of a pain when we actually only need to get the
hook ready before random_init() which is called much later in boot when
slab/ioremap/percpu are all ready.

cheers


Re: [PATCHv2 1/2] mm: eliminate ifdef of HAVE_IOREMAP_PROT in .c files

2022-06-21 Thread kernel test robot
Hi Wang,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on akpm-mm/mm-everything]

url:
https://github.com/intel-lab-lkp/linux/commits/Wang-Wenhu/mm-eliminate-ifdef-of-HAVE_IOREMAP_PROT-in-c-files/20220615-140135
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git 
mm-everything
config: arm-randconfig-s032-20220622 
(https://download.01.org/0day-ci/archive/20220622/202206221053.gv7bywql-...@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 11.3.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-31-g4880bd19-dirty
# 
https://github.com/intel-lab-lkp/linux/commit/b20efcc877829b6f416cf111bd5ad2b13a0cd08e
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Wang-Wenhu/mm-eliminate-ifdef-of-HAVE_IOREMAP_PROT-in-c-files/20220615-140135
git checkout b20efcc877829b6f416cf111bd5ad2b13a0cd08e
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross C=1 
CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=arm SHELL=/bin/bash

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

All errors (new ones prefixed by >>):

>> arm-linux-gnueabi-ld: drivers/char/mem.o:(.rodata+0x144): undefined 
>> reference to `generic_access_phys'

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp


[PATCH v2 4/4] hugetlb: Lazy page table copies in fork()

2022-06-21 Thread Mike Kravetz
Lazy page table copying at fork time was introduced with commit
d992895ba2b2 ("[PATCH] Lazy page table copies in fork()").  At the
time, hugetlb was very new and did not support page faulting.  As a
result, it was excluded.  When full page fault support was added for
hugetlb, the exclusion was not removed.

Simply remove the check that prevents lazy copying of hugetlb page
tables at fork.  Of course, like other mappings this only applies to
shared mappings.

Lazy page table copying at fork will be less advantageous for hugetlb
mappings because:
- There are fewer page table entries with hugetlb
- hugetlb pmds can be shared instead of copied

In any case, completely eliminating the copy at fork time should speed
things up.

Signed-off-by: Mike Kravetz 
Acked-by: Muchun Song 
Acked-by: David Hildenbrand 
---
 mm/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memory.c b/mm/memory.c
index fee2884481f2..90d2a614b2de 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1262,7 +1262,7 @@ vma_needs_copy(struct vm_area_struct *dst_vma, struct 
vm_area_struct *src_vma)
if (userfaultfd_wp(dst_vma))
return true;
 
-   if (src_vma->vm_flags & (VM_HUGETLB | VM_PFNMAP | VM_MIXEDMAP))
+   if (src_vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
return true;
 
if (src_vma->anon_vma)
-- 
2.35.3



[PATCH v2 0/4] hugetlb: speed up linear address scanning

2022-06-21 Thread Mike Kravetz
At unmap, fork and remap time hugetlb address ranges are linearly
scanned.  We can optimize these scans if the ranges are sparsely
populated.

Also, enable page table "Lazy copy" for hugetlb at fork.

NOTE: Architectures not defining CONFIG_ARCH_WANT_GENERAL_HUGETLB
need to add an arch specific version hugetlb_mask_last_page() to
take advantage of sparse address scanning improvements.  Baolin Wang
added the routine for arm64.  Other architectures which could be
optimized are: ia64, mips, parisc, powerpc, s390, sh and sparc.

v1->v2  Change hugetlb_mask_last_page default code to 0 instead of ~0.  Peter
Fix build issues on i386, including going back to if-else-if
instead of switch in hugetlb_mask_last_page. kernel test robot
Update commit message. Rolf Eike Beer
Changes were relatively minor, so I left the Reviewed-by and
ACKed-by tags.

Baolin Wang (1):
  arm64/hugetlb: Implement arm64 specific hugetlb_mask_last_page

Mike Kravetz (3):
  hugetlb: skip to end of PT page mapping when pte not present
  hugetlb: do not update address in huge_pmd_unshare
  hugetlb: Lazy page table copies in fork()

 arch/arm64/mm/hugetlbpage.c |  20 +++
 include/linux/hugetlb.h |   5 +-
 mm/hugetlb.c| 102 +---
 mm/memory.c |   2 +-
 mm/rmap.c   |   4 +-
 5 files changed, 96 insertions(+), 37 deletions(-)

-- 
2.35.3



[PATCH v2 3/4] hugetlb: do not update address in huge_pmd_unshare

2022-06-21 Thread Mike Kravetz
As an optimization for loops sequentially processing hugetlb address
ranges, huge_pmd_unshare would update a passed address if it unshared a
pmd.  Updating a loop control variable outside the loop like this is
generally a bad idea.  These loops are now using hugetlb_mask_last_page
to optimize scanning when non-present ptes are discovered.  The same
can be done when huge_pmd_unshare returns 1 indicating a pmd was
unshared.

Remove address update from huge_pmd_unshare.  Change the passed argument
type and update all callers.  In loops sequentially processing addresses
use hugetlb_mask_last_page to update address if pmd is unshared.

Signed-off-by: Mike Kravetz 
Acked-by: Muchun Song 
Reviewed-by: Baolin Wang 
---
 include/linux/hugetlb.h |  4 ++--
 mm/hugetlb.c| 46 +
 mm/rmap.c   |  4 ++--
 3 files changed, 23 insertions(+), 31 deletions(-)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index e37465e830fe..ee9a28ef26ee 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -199,7 +199,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm,
   unsigned long addr, unsigned long sz);
 unsigned long hugetlb_mask_last_page(struct hstate *h);
 int huge_pmd_unshare(struct mm_struct *mm, struct vm_area_struct *vma,
-   unsigned long *addr, pte_t *ptep);
+   unsigned long addr, pte_t *ptep);
 void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma,
unsigned long *start, unsigned long *end);
 struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address,
@@ -246,7 +246,7 @@ static inline struct address_space 
*hugetlb_page_mapping_lock_write(
 
 static inline int huge_pmd_unshare(struct mm_struct *mm,
struct vm_area_struct *vma,
-   unsigned long *addr, pte_t *ptep)
+   unsigned long addr, pte_t *ptep)
 {
return 0;
 }
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 0e4877cea62e..2e4a92cebd9c 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4945,7 +4945,6 @@ int move_hugetlb_page_tables(struct vm_area_struct *vma,
struct mm_struct *mm = vma->vm_mm;
unsigned long old_end = old_addr + len;
unsigned long last_addr_mask;
-   unsigned long old_addr_copy;
pte_t *src_pte, *dst_pte;
struct mmu_notifier_range range;
bool shared_pmd = false;
@@ -4973,14 +4972,10 @@ int move_hugetlb_page_tables(struct vm_area_struct *vma,
if (huge_pte_none(huge_ptep_get(src_pte)))
continue;
 
-   /* old_addr arg to huge_pmd_unshare() is a pointer and so the
-* arg may be modified. Pass a copy instead to preserve the
-* value in old_addr.
-*/
-   old_addr_copy = old_addr;
-
-   if (huge_pmd_unshare(mm, vma, _addr_copy, src_pte)) {
+   if (huge_pmd_unshare(mm, vma, old_addr, src_pte)) {
shared_pmd = true;
+   old_addr |= last_addr_mask;
+   new_addr |= last_addr_mask;
continue;
}
 
@@ -5045,10 +5040,11 @@ static void __unmap_hugepage_range(struct mmu_gather 
*tlb, struct vm_area_struct
}
 
ptl = huge_pte_lock(h, mm, ptep);
-   if (huge_pmd_unshare(mm, vma, , ptep)) {
+   if (huge_pmd_unshare(mm, vma, address, ptep)) {
spin_unlock(ptl);
tlb_flush_pmd_range(tlb, address & PUD_MASK, PUD_SIZE);
force_flush = true;
+   address |= last_addr_mask;
continue;
}
 
@@ -6343,7 +6339,7 @@ unsigned long hugetlb_change_protection(struct 
vm_area_struct *vma,
continue;
}
ptl = huge_pte_lock(h, mm, ptep);
-   if (huge_pmd_unshare(mm, vma, , ptep)) {
+   if (huge_pmd_unshare(mm, vma, address, ptep)) {
/*
 * When uffd-wp is enabled on the vma, unshare
 * shouldn't happen at all.  Warn about it if it
@@ -6353,6 +6349,7 @@ unsigned long hugetlb_change_protection(struct 
vm_area_struct *vma,
pages++;
spin_unlock(ptl);
shared_pmd = true;
+   address |= last_addr_mask;
continue;
}
pte = huge_ptep_get(ptep);
@@ -6776,11 +6773,11 @@ pte_t *huge_pmd_share(struct mm_struct *mm, struct 
vm_area_struct *vma,
  * 0 the underlying pte page is not shared, or it is the last user
  */
 int huge_pmd_unshare(struct mm_struct *mm, struct vm_area_struct *vma,
-  

[PATCH v2 2/4] arm64/hugetlb: Implement arm64 specific hugetlb_mask_last_page

2022-06-21 Thread Mike Kravetz
From: Baolin Wang 

The HugeTLB address ranges are linearly scanned during fork, unmap and
remap operations, and the linear scan can skip to the end of range mapped
by the page table page if hitting a non-present entry, which can help
to speed linear scanning of the HugeTLB address ranges.

So hugetlb_mask_last_page() is introduced to help to update the address in
the loop of HugeTLB linear scanning with getting the last huge page mapped
by the associated page table page[1], when a non-present entry is encountered.

Considering ARM64 specific cont-pte/pmd size HugeTLB, this patch implemented
an ARM64 specific hugetlb_mask_last_page() to help this case.

[1] 
https://lore.kernel.org/linux-mm/20220527225849.284839-1-mike.krav...@oracle.com/

Signed-off-by: Baolin Wang 
Signed-off-by: Mike Kravetz 
Acked-by: Muchun Song 
---
 arch/arm64/mm/hugetlbpage.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
index e2a5ec9fdc0d..c9e076683e5d 100644
--- a/arch/arm64/mm/hugetlbpage.c
+++ b/arch/arm64/mm/hugetlbpage.c
@@ -368,6 +368,26 @@ pte_t *huge_pte_offset(struct mm_struct *mm,
return NULL;
 }
 
+unsigned long hugetlb_mask_last_page(struct hstate *h)
+{
+   unsigned long hp_size = huge_page_size(h);
+
+   switch (hp_size) {
+   case PUD_SIZE:
+   return PGDIR_SIZE - PUD_SIZE;
+   case CONT_PMD_SIZE:
+   return PUD_SIZE - CONT_PMD_SIZE;
+   case PMD_SIZE:
+   return PUD_SIZE - PMD_SIZE;
+   case CONT_PTE_SIZE:
+   return PMD_SIZE - CONT_PTE_SIZE;
+   default:
+   break;
+   }
+
+   return 0UL;
+}
+
 pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags)
 {
size_t pagesize = 1UL << shift;
-- 
2.35.3



[PATCH v2 1/4] hugetlb: skip to end of PT page mapping when pte not present

2022-06-21 Thread Mike Kravetz
HugeTLB address ranges are linearly scanned during fork, unmap and
remap operations.  If a non-present entry is encountered, the code
currently continues to the next huge page aligned address.  However,
a non-present entry implies that the page table page for that entry
is not present.  Therefore, the linear scan can skip to the end of
range mapped by the page table page.  This can speed operations on
large sparsely populated hugetlb mappings.

Create a new routine hugetlb_mask_last_page() that will return an
address mask.  When the mask is ORed with an address, the result
will be the address of the last huge page mapped by the associated
page table page.  Use this mask to update addresses in routines which
linearly scan hugetlb address ranges when a non-present pte is
encountered.

hugetlb_mask_last_page is related to the implementation of
huge_pte_offset as hugetlb_mask_last_page is called when huge_pte_offset
returns NULL.  This patch only provides a complete hugetlb_mask_last_page
implementation when CONFIG_ARCH_WANT_GENERAL_HUGETLB is defined.
Architectures which provide their own versions of huge_pte_offset can also
provide their own version of hugetlb_mask_last_page.

Signed-off-by: Mike Kravetz 
Tested-by: Baolin Wang 
Reviewed-by: Baolin Wang 
Acked-by: Muchun Song 
Reported-by: kernel test robot 
---
 include/linux/hugetlb.h |  1 +
 mm/hugetlb.c| 56 +
 2 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 642a39016f9a..e37465e830fe 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -197,6 +197,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct 
vm_area_struct *vma,
unsigned long addr, unsigned long sz);
 pte_t *huge_pte_offset(struct mm_struct *mm,
   unsigned long addr, unsigned long sz);
+unsigned long hugetlb_mask_last_page(struct hstate *h);
 int huge_pmd_unshare(struct mm_struct *mm, struct vm_area_struct *vma,
unsigned long *addr, pte_t *ptep);
 void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma,
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 98492733cc64..0e4877cea62e 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4736,6 +4736,7 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct 
mm_struct *src,
unsigned long npages = pages_per_huge_page(h);
struct address_space *mapping = src_vma->vm_file->f_mapping;
struct mmu_notifier_range range;
+   unsigned long last_addr_mask;
int ret = 0;
 
if (cow) {
@@ -4755,11 +4756,14 @@ int copy_hugetlb_page_range(struct mm_struct *dst, 
struct mm_struct *src,
i_mmap_lock_read(mapping);
}
 
+   last_addr_mask = hugetlb_mask_last_page(h);
for (addr = src_vma->vm_start; addr < src_vma->vm_end; addr += sz) {
spinlock_t *src_ptl, *dst_ptl;
src_pte = huge_pte_offset(src, addr, sz);
-   if (!src_pte)
+   if (!src_pte) {
+   addr |= last_addr_mask;
continue;
+   }
dst_pte = huge_pte_alloc(dst, dst_vma, addr, sz);
if (!dst_pte) {
ret = -ENOMEM;
@@ -4776,8 +4780,10 @@ int copy_hugetlb_page_range(struct mm_struct *dst, 
struct mm_struct *src,
 * after taking the lock below.
 */
dst_entry = huge_ptep_get(dst_pte);
-   if ((dst_pte == src_pte) || !huge_pte_none(dst_entry))
+   if ((dst_pte == src_pte) || !huge_pte_none(dst_entry)) {
+   addr |= last_addr_mask;
continue;
+   }
 
dst_ptl = huge_pte_lock(h, dst, dst_pte);
src_ptl = huge_pte_lockptr(h, src, src_pte);
@@ -4938,6 +4944,7 @@ int move_hugetlb_page_tables(struct vm_area_struct *vma,
unsigned long sz = huge_page_size(h);
struct mm_struct *mm = vma->vm_mm;
unsigned long old_end = old_addr + len;
+   unsigned long last_addr_mask;
unsigned long old_addr_copy;
pte_t *src_pte, *dst_pte;
struct mmu_notifier_range range;
@@ -4953,12 +4960,16 @@ int move_hugetlb_page_tables(struct vm_area_struct *vma,
flush_cache_range(vma, range.start, range.end);
 
mmu_notifier_invalidate_range_start();
+   last_addr_mask = hugetlb_mask_last_page(h);
/* Prevent race with file truncation */
i_mmap_lock_write(mapping);
for (; old_addr < old_end; old_addr += sz, new_addr += sz) {
src_pte = huge_pte_offset(mm, old_addr, sz);
-   if (!src_pte)
+   if (!src_pte) {
+   old_addr |= last_addr_mask;
+   new_addr |= last_addr_mask;
continue;
+   }
if 

Re: [PATCH v2 1/4] powerpc/pseries: hvcall.h: add H_WATCHDOG opcode, H_NOOP return code

2022-06-21 Thread Nathan Lynch
Segher Boessenkool  writes:

> Hi!
>
> On Tue, Jun 21, 2022 at 09:44:42AM -0500, Nathan Lynch wrote:
>> Not a problem to fix in your series, but I guess these should be
>> parenthesized i.e.
>> 
>> #define H_P7 (-60)
>> #define H_P8 (-61)
>> #define H_P9 (-62)
>> #define H_NOOP   (-63)
>
> Why?  It does not change the semantics of any correct code.  For what
> incorrect code will it make the diagnostics clearer?

Yeah never mind, I was confused.


[PATCH RFC] drivers/usb/ehci-fsl: Fix interrupt setup in host mode.

2022-06-21 Thread Darren Stevens
In patch a1a2b7125e1079 (Drop static setup of IRQ resource from DT
core) we stopped platform_get_resource() from returning the IRQ, as all
drivers were supposed to have switched to platform_get_irq()
Unfortunately the Freescale EHCI driver in host mode got missed. Fix
it. Also fix allocation of resources to work with current kernel.

Fixes:a1a2b7125e1079 (Drop static setup of IRQ resource from DT core)
Reported-by Christian Zigotzky 
Signed-off-by Darren Stevens 
---
Tested on AmigaOne X5000/20 and X5000/40 not sure if this is entirely
correct fix though. Contains code by Rob Herring (in fsl-mph-dr-of.c)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 385be30..d0bf7fb 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "ehci.h"
@@ -46,9 +47,10 @@ static struct hc_driver __read_mostly
fsl_ehci_hc_driver; */
 static int fsl_ehci_drv_probe(struct platform_device *pdev)
 {
+   struct device_node *dn = pdev->dev.of_node;
struct fsl_usb2_platform_data *pdata;
struct usb_hcd *hcd;
-   struct resource *res;
+   struct resource res;
int irq;
int retval;
u32 tmp;
@@ -76,14 +78,10 @@ static int fsl_ehci_drv_probe(struct
platform_device *pdev) return -ENODEV;
}
 
-   res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-   if (!res) {
-   dev_err(>dev,
-   "Found HC with no IRQ. Check %s setup!\n",
-   dev_name(>dev));
-   return -ENODEV;
+   irq = platform_get_irq(pdev, 0);
+   if (irq < 0) {
+   return irq;
}
-   irq = res->start;
 
hcd = __usb_create_hcd(_ehci_hc_driver, pdev->dev.parent,
   >dev, dev_name(>dev), NULL);
@@ -92,15 +90,21 @@ static int fsl_ehci_drv_probe(struct
platform_device *pdev) goto err1;
}
 
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   hcd->regs = devm_ioremap_resource(>dev, res);
+   platform_set_drvdata(pdev, hcd);
+   pdev->dev.platform_data = pdata;
+
+   tmp = of_address_to_resource(dn, 0, );
+   if (tmp)
+   return tmp;
+
+   hcd->regs = devm_ioremap_resource(>dev, );
if (IS_ERR(hcd->regs)) {
retval = PTR_ERR(hcd->regs);
goto err2;
}
 
-   hcd->rsrc_start = res->start;
-   hcd->rsrc_len = resource_size(res);
+   hcd->rsrc_start = res.start;
+   hcd->rsrc_len = resource_size();
 
pdata->regs = hcd->regs;
 
diff --git a/drivers/usb/host/fsl-mph-dr-of.c
b/drivers/usb/host/fsl-mph-dr-of.c index 44a7e58..766e4ab 100644
--- a/drivers/usb/host/fsl-mph-dr-of.c
+++ b/drivers/usb/host/fsl-mph-dr-of.c
@@ -80,8 +80,6 @@ static struct platform_device
*fsl_usb2_device_register( const char *name, int id)
 {
struct platform_device *pdev;
-   const struct resource *res = ofdev->resource;
-   unsigned int num = ofdev->num_resources;
int retval;
 
pdev = platform_device_alloc(name, id);
@@ -106,11 +104,8 @@ static struct platform_device
*fsl_usb2_device_register( if (retval)
goto error;
 
-   if (num) {
-   retval = platform_device_add_resources(pdev, res, num);
-   if (retval)
-   goto error;
-   }
+   pdev->dev.of_node = ofdev->dev.of_node;
+   pdev->dev.of_node_reused = true;
 
retval = platform_device_add(pdev);
if (retval)


[linux-next:master] BUILD REGRESSION 34d1d36073ea4d4c532e8c8345627a9702be799e

2022-06-21 Thread kernel test robot
tree/branch: 
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
branch HEAD: 34d1d36073ea4d4c532e8c8345627a9702be799e  Add linux-next specific 
files for 20220621

Error/Warning reports:

https://lore.kernel.org/linux-mm/202206212029.yr5m7cd3-...@intel.com
https://lore.kernel.org/linux-mm/202206212033.3lgl72fw-...@intel.com
https://lore.kernel.org/lkml/202206071511.fi7wldzo-...@intel.com

Error/Warning: (recently discovered and may have been fixed)

ERROR: modpost: "acpi_dev_for_each_child" [drivers/mfd/mfd-core.ko] undefined!
arch/powerpc/kernel/interrupt.c:542:55: warning: suggest braces around empty 
body in an 'if' statement [-Wempty-body]
drivers/ntb/test/ntb_perf.c:1067: undefined reference to `__umoddi3'
irq-xilinx-intc.c:(.init.text+0x8c): undefined reference to `of_iomap'
microblaze-linux-ld: drivers/ntb/test/ntb_perf.c:1095: undefined reference to 
`__umoddi3'
net/ipv6/raw.c:335:25: warning: variable 'saddr' set but not used 
[-Wunused-but-set-variable]
net/ipv6/raw.c:335:32: warning: variable 'saddr' set but not used 
[-Wunused-but-set-variable]
net/ipv6/raw.c:335:33: warning: variable 'daddr' set but not used 
[-Wunused-but-set-variable]
net/ipv6/raw.c:335:40: warning: variable 'daddr' set but not used 
[-Wunused-but-set-variable]
net/ipv6/raw.c:338:25: warning: variable 'saddr' set but not used 
[-Wunused-but-set-variable]
net/ipv6/raw.c:338:32: warning: variable 'saddr' set but not used 
[-Wunused-but-set-variable]
net/ipv6/raw.c:338:33: warning: variable 'daddr' set but not used 
[-Wunused-but-set-variable]
net/ipv6/raw.c:338:40: warning: variable 'daddr' set but not used 
[-Wunused-but-set-variable]
s390-linux-ld: irq-xilinx-intc.c:(.init.text+0x3ba): undefined reference to 
`iounmap'

Unverified Error/Warning (likely false positive, please contact us if 
interested):

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9143:27: warning: 
variable 'abo' set but not used [-Wunused-but-set-variable]

Error/Warning ids grouped by kconfigs:

gcc_recent_errors
|-- alpha-allyesconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-amdgpu_dm-amdgpu_dm.c:warning:variable-abo-set-but-not-used
|   |-- 
drivers-staging-rtl8723bs-hal-hal_btcoex.c:warning:variable-pHalData-set-but-not-used
|   |-- net-ipv6-raw.c:warning:variable-daddr-set-but-not-used
|   `-- net-ipv6-raw.c:warning:variable-saddr-set-but-not-used
|-- alpha-buildonly-randconfig-r001-20220620
|   `-- 
drivers-gpu-drm-amd-amdgpu-..-display-amdgpu_dm-amdgpu_dm.c:warning:variable-abo-set-but-not-used
|-- alpha-buildonly-randconfig-r006-20220621
|   |-- net-ipv6-raw.c:warning:variable-daddr-set-but-not-used
|   `-- net-ipv6-raw.c:warning:variable-saddr-set-but-not-used
|-- arc-allyesconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-amdgpu_dm-amdgpu_dm.c:warning:variable-abo-set-but-not-used
|   `-- 
drivers-staging-rtl8723bs-hal-hal_btcoex.c:warning:variable-pHalData-set-but-not-used
|-- arm-allmodconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-amdgpu_dm-amdgpu_dm.c:warning:variable-abo-set-but-not-used
|   |-- 
drivers-staging-rtl8723bs-hal-hal_btcoex.c:warning:variable-pHalData-set-but-not-used
|   |-- net-ipv6-raw.c:warning:variable-daddr-set-but-not-used
|   `-- net-ipv6-raw.c:warning:variable-saddr-set-but-not-used
|-- arm-allyesconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-amdgpu_dm-amdgpu_dm.c:warning:variable-abo-set-but-not-used
|   |-- 
drivers-staging-rtl8723bs-hal-hal_btcoex.c:warning:variable-pHalData-set-but-not-used
|   |-- net-ipv6-raw.c:warning:variable-daddr-set-but-not-used
|   `-- net-ipv6-raw.c:warning:variable-saddr-set-but-not-used
|-- arm-defconfig
|   |-- net-ipv6-raw.c:warning:variable-daddr-set-but-not-used
|   `-- net-ipv6-raw.c:warning:variable-saddr-set-but-not-used
|-- arm-randconfig-r022-20220620
|   |-- net-ipv6-raw.c:warning:variable-daddr-set-but-not-used
|   `-- net-ipv6-raw.c:warning:variable-saddr-set-but-not-used
|-- arm-randconfig-r031-20220619
|   |-- net-ipv6-raw.c:warning:variable-daddr-set-but-not-used
|   `-- net-ipv6-raw.c:warning:variable-saddr-set-but-not-used
|-- arm64-allyesconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-amdgpu_dm-amdgpu_dm.c:warning:variable-abo-set-but-not-used
|   |-- 
drivers-staging-rtl8723bs-hal-hal_btcoex.c:warning:variable-pHalData-set-but-not-used
|   |-- net-ipv6-raw.c:warning:variable-daddr-set-but-not-used
|   `-- net-ipv6-raw.c:warning:variable-saddr-set-but-not-used
|-- arm64-defconfig
|   |-- net-ipv6-raw.c:warning:variable-daddr-set-but-not-used
|   `-- net-ipv6-raw.c:warning:variable-saddr-set-but-not-used
|-- i386-allyesconfig
|   |-- 
drivers-gpu-drm-amd-amdgpu-..-display-amdgpu_dm-amdgpu_dm.c:warning:variable-abo-set-but-not-used
|   `-- 
drivers-staging-rtl8723bs-hal-hal_btcoex.c:warning:variable-pHalData-set-but-not-used
|-- i386-debian-10.3-kselftests
|   `-- ERROR:acpi_dev_for_each_child-drivers-mfd-mfd-core.ko-undefined
|-- i386-randconfig-a001
|   `-- ntb_perf.c:(.text):undefined

Re: [PATCH v2 2/3] scsi: BusLogic remove bus_to_virt

2022-06-21 Thread Khalid Aziz

On 6/17/22 06:57, Arnd Bergmann wrote:

From: Arnd Bergmann 

The BusLogic driver is the last remaining driver that relies on the
deprecated bus_to_virt() function, which in turn only works on a few
architectures, and is incompatible with both swiotlb and iommu support.

Before commit 391e2f25601e ("[SCSI] BusLogic: Port driver to 64-bit."),
the driver had a dependency on x86-32, presumably because of this
problem. However, the change introduced another bug that made it still
impossible to use the driver on any 64-bit machine.

This was in turn fixed in commit 56f396146af2 ("scsi: BusLogic: Fix
64-bit system enumeration error for Buslogic"), 8 years later, which
shows that there are not a lot of users.

Maciej is still using the driver on 32-bit hardware, and Khalid mentioned
that the driver works with the device emulation used in VirtualBox
and VMware. Both of those only emulate it for Windows 2000 and older
operating systems that did not ship with the better LSI logic driver.

Do a minimum fix that searches through the list of descriptors to find
one that matches the bus address. This is clearly as inefficient as
was indicated in the code comment about the lack of a bus_to_virt()
replacement. A better fix would likely involve changing out the entire
descriptor allocation for a simpler one, but that would be much
more invasive.

Cc: Maciej W. Rozycki 
Cc: Matt Wang 
Cc: Khalid Aziz 
Signed-off-by: Arnd Bergmann 
---
  drivers/scsi/BusLogic.c | 27 ---
  drivers/scsi/Kconfig|  2 +-
  2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index a897c8f914cf..d057abfcdd5c 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -2515,12 +2515,26 @@ static int blogic_resultcode(struct blogic_adapter 
*adapter,
return (hoststatus << 16) | tgt_status;
  }
  
+/*

+ * turn the dma address from an inbox into a ccb pointer
+ * This is rather inefficient.
+ */
+static struct blogic_ccb *
+blogic_inbox_to_ccb(struct blogic_adapter *adapter, struct blogic_inbox *inbox)
+{
+   struct blogic_ccb *ccb;
+
+   for (ccb = adapter->all_ccbs; ccb; ccb = ccb->next_all)
+   if (inbox->ccb == ccb->dma_handle)
+   break;
+
+   return ccb;
+}
  
  /*

blogic_scan_inbox scans the Incoming Mailboxes saving any
Incoming Mailbox entries for completion processing.
  */
-
  static void blogic_scan_inbox(struct blogic_adapter *adapter)
  {
/*
@@ -2540,16 +2554,7 @@ static void blogic_scan_inbox(struct blogic_adapter 
*adapter)
enum blogic_cmplt_code comp_code;
  
  	while ((comp_code = next_inbox->comp_code) != BLOGIC_INBOX_FREE) {

-   /*
-  We are only allowed to do this because we limit our
-  architectures we run on to machines where bus_to_virt(
-  actually works.  There *needs* to be a dma_addr_to_virt()
-  in the new PCI DMA mapping interface to replace
-  bus_to_virt() or else this code is going to become very
-  innefficient.
-*/
-   struct blogic_ccb *ccb =
-   (struct blogic_ccb *) bus_to_virt(next_inbox->ccb);
+   struct blogic_ccb *ccb = blogic_inbox_to_ccb(adapter, 
adapter->next_inbox);


This change looks good enough as workaround to not use bus_to_virt() for 
now. There are two problems I see though. One, I do worry about 
blogic_inbox_to_ccb() returning NULL for ccb which should not happen 
unless the mailbox pointer was corrupted which would indicate a bigger 
problem. Nevertheless a NULL pointer causing kernel panic concerns me. 
How about adding a check before we dereference ccb?


Second, with this patch applied, I am seeing errors from the driver:

=
[ 1623.902685]  sdb: sdb1 sdb2
[ 1623.903245] sd 2:0:0:0: [sdb] Attached SCSI disk
[ 1623.911000] scsi2: Illegal CCB #76 status 2 in Incoming Mailbox
[ 1623.911005] scsi2: Illegal CCB #76 status 2 in Incoming Mailbox
[ 1623.911070] scsi2: Illegal CCB #79 status 2 in Incoming Mailbox
[ 1651.458008] scsi2: Warning: Partition Table appears to have Geometry 
256/63 which is
[ 1651.458013] scsi2: not compatible with current BusLogic Host Adapter 
Geometry 255/63

[ 1658.797609] scsi2: Resetting BusLogic BT-958D Failed
[ 1659.533208] sd 2:0:0:0: Device offlined - not ready after error recovery
[ 1659.51] sd 2:0:0:0: Device offlined - not ready after error recovery
[ 1659.53] sd 2:0:0:0: Device offlined - not ready after error recovery
[ 1659.533342] sd 2:0:0:0: [sdb] tag#101 FAILED Result: 
hostbyte=DID_TIME_OUT driverbyte=DRIVER_OK cmd_age=35s
[ 1659.533345] sd 2:0:0:0: [sdb] tag#101 CDB: Read(10) 28 00 00 00 00 28 
00 00 10 00
[ 1659.533346] I/O error, dev sdb, sector 40 op 0x0:(READ) flags 0x80700 
phys_seg 1 prio class 0


=

This is on VirtualBox using emulated BusLogic adapter.

This 

Re: [PATCH v5] powerpc/powernv: wire up rng during setup_arch

2022-06-21 Thread Christophe Leroy


Le 21/06/2022 à 20:47, Jason A. Donenfeld a écrit :
> Hi Christophe,
> 
> On Tue, Jun 21, 2022 at 06:33:11PM +, Christophe Leroy wrote:
>> Le 21/06/2022 à 16:08, Jason A. Donenfeld a écrit :
>>> The platform's RNG must be available before random_init() in order to be
>>> useful for initial seeding, which in turn means that it needs to be
>>> called from setup_arch(), rather than from an init call. Fortunately,
>>> each platform already has a setup_arch function pointer, which means we
>>> can wire it up that way. Complicating things, however, is that POWER8
>>> systems need some per-cpu state and kmalloc, which isn't available at
>>> this stage. So we split things up into an early phase and a later
>>> opportunistic phase. This commit also removes some noisy log messages
>>> that don't add much.
>>
>> Regarding the kmalloc(), I have not looked at it in details, but usually
>> you can use memblock_alloc() when kmalloc is not available yet.
> 
> That seems a bit excessive, especially as those allocations are long
> lived. And we don't even *need* it that early, but just before
> random_init(). Michael is running this v5 on the test rig overnight, so
> we'll learn in the Australian morning whether this finally did the trick
> (I hope).
> 

The fact that they are long lived make them a good candidate for 
memblock_alloc().

But fair enough, if they are not required that early then just do it later.

Christophe

Re: [PATCH v5] powerpc/powernv: wire up rng during setup_arch

2022-06-21 Thread Jason A. Donenfeld
Hi Christophe,

On Tue, Jun 21, 2022 at 06:33:11PM +, Christophe Leroy wrote:
> Le 21/06/2022 à 16:08, Jason A. Donenfeld a écrit :
> > The platform's RNG must be available before random_init() in order to be
> > useful for initial seeding, which in turn means that it needs to be
> > called from setup_arch(), rather than from an init call. Fortunately,
> > each platform already has a setup_arch function pointer, which means we
> > can wire it up that way. Complicating things, however, is that POWER8
> > systems need some per-cpu state and kmalloc, which isn't available at
> > this stage. So we split things up into an early phase and a later
> > opportunistic phase. This commit also removes some noisy log messages
> > that don't add much.
> 
> Regarding the kmalloc(), I have not looked at it in details, but usually 
> you can use memblock_alloc() when kmalloc is not available yet.

That seems a bit excessive, especially as those allocations are long
lived. And we don't even *need* it that early, but just before
random_init(). Michael is running this v5 on the test rig overnight, so
we'll learn in the Australian morning whether this finally did the trick
(I hope).

Jason


Re: [PATCH v5] powerpc/powernv: wire up rng during setup_arch

2022-06-21 Thread Christophe Leroy


Le 21/06/2022 à 16:08, Jason A. Donenfeld a écrit :
> The platform's RNG must be available before random_init() in order to be
> useful for initial seeding, which in turn means that it needs to be
> called from setup_arch(), rather than from an init call. Fortunately,
> each platform already has a setup_arch function pointer, which means we
> can wire it up that way. Complicating things, however, is that POWER8
> systems need some per-cpu state and kmalloc, which isn't available at
> this stage. So we split things up into an early phase and a later
> opportunistic phase. This commit also removes some noisy log messages
> that don't add much.

Regarding the kmalloc(), I have not looked at it in details, but usually 
you can use memblock_alloc() when kmalloc is not available yet.

Christophe

Re: [PATCH v2 1/4] powerpc/pseries: hvcall.h: add H_WATCHDOG opcode, H_NOOP return code

2022-06-21 Thread Segher Boessenkool
Hi!

On Tue, Jun 21, 2022 at 09:44:42AM -0500, Nathan Lynch wrote:
> Not a problem to fix in your series, but I guess these should be
> parenthesized i.e.
> 
> #define H_P7  (-60)
> #define H_P8  (-61)
> #define H_P9  (-62)
> #define H_NOOP(-63)

Why?  It does not change the semantics of any correct code.  For what
incorrect code will it make the diagnostics clearer?


Segher


Re: [PATCH v3 2/5] of: remove __of_node_dup() allocflags parameter

2022-06-21 Thread Bjorn Helgaas
On Mon, Jun 20, 2022 at 12:41:20PM +0200, Clément Léger wrote:
> The alloclags are always set to GFP_KERNEL so remove this specific flag.
> Moreover, this function is going to be based on one that does not
> provides passing gfp flags, so be prepared for this.

s/alloclags/allocflags/

s/provides passing/supports passing/


Re: [PATCH v2 1/4] powerpc/mobility: Wait for memory transfer to complete

2022-06-21 Thread Nathan Lynch
Laurent Dufour  writes:

> In pseries_migration_partition(), loop until the memory transfer is
> complete. This way the calling drmgr process will not exit earlier,
> allowing callbacks to be run only once the migration is fully completed.
>
> If reading the VASI state is done after the hypervisor has completed the
> migration, the HCALL is returning H_PARAMETER. We can safely assume that
> the memory transfer is achieved if this happens.
>
> This will also allow to manage the NMI watchdog state in the next commits.
>
> Signed-off-by: Laurent Dufour 
> ---
>  arch/powerpc/platforms/pseries/mobility.c | 42 +--
>  1 file changed, 40 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/platforms/pseries/mobility.c 
> b/arch/powerpc/platforms/pseries/mobility.c
> index 78f3f74c7056..179bbd4ae881 100644
> --- a/arch/powerpc/platforms/pseries/mobility.c
> +++ b/arch/powerpc/platforms/pseries/mobility.c
> @@ -427,6 +427,43 @@ static int wait_for_vasi_session_suspending(u64 handle)
>   return ret;
>  }
>  
> +static void wait_for_vasi_session_completed(u64 handle)
> +{
> + unsigned long state = 0;
> + int ret;
> +
> + pr_info("waiting for memory transfert to complete...\n");
> + /*
> +  * Wait for transition from H_VASI_RESUMED to
> +  * H_VASI_COMPLETED. Treat anything else as an error.

"Treat anything else as an error" does not match the code since there is
a special case for when the stream handle has expired. So that should be
dropped from this comment.

> +  */
> + while (true) {
> + ret = poll_vasi_state(handle, );
> +
> + /*
> +  * If the memory transfer is already complete and the migration
> +  * has been cleaned up by the hypervisor, H_PARAMETER is return,
> +  * which is translate in EINVAL by poll_vasi_state().
> +  */
> + if (ret == -EINVAL || (!ret && state == H_VASI_COMPLETED)) {
> + pr_info("memory transfert completed.\n");
> + break;
> + }
> +
> + if (ret) {
> + pr_err("H_VASI_STATE return error (%d)\n", ret);
> + break;
> + }
> +
> + if (state != H_VASI_RESUMED) {
> + pr_err("unexpected H_VASI_STATE result %lu\n", state);
> + break;
> + }
> +
> + msleep(500);
> + }
> +}
> +
>  static void prod_single(unsigned int target_cpu)
>  {
>   long hvrc;
> @@ -673,9 +710,10 @@ static int pseries_migrate_partition(u64 handle)
>   vas_migration_handler(VAS_SUSPEND);
>  
>   ret = pseries_suspend(handle);
> - if (ret == 0)
> + if (ret == 0) {
>   post_mobility_fixup();
> - else
> + wait_for_vasi_session_completed(handle);
> + } else
>   pseries_cancel_migration(handle, ret);
>  
>   vas_migration_handler(VAS_RESUME);

While this may noticeably lengthen the time it takes for drmgr to return
from the system call, it seems like the right thing to do. The migration
should not be considered complete until the VASI stream poll yields a
"Complete" status. And we still need to add code to send gratuitous ARPs
through ibmveth interfaces while waiting for the transition, which would
likely build on this.

I believe the HMC and associated software can cope with the drmgr
command taking a longer time to return in cases where the partition
memory needs a while to completely sync to the destination.

Apart from the small critique on the comment in
wait_for_vasi_session_completed(), this looks fine to me.

Reviewed-by: Nathan Lynch 


Re: [PATCH] cxl: drop unexpected word "the" in the comments

2022-06-21 Thread Andrew Donnellan
On Tue, 2022-06-21 at 20:53 +0800, Jiang Jian wrote:
> there is an unexpected word "the" in the comments that need to be
> dropped
> 
> file: drivers/misc/cxl/cxl.h
> line: 1107
> +/* check if the given pci_dev is on the the cxl vphb bus */
> changed to
> +/* check if the given pci_dev is on the cxl vphb bus */
> 
> Signed-off-by: Jiang Jian 

Thanks!

Acked-by: Andrew Donnellan 

> ---
>  drivers/misc/cxl/cxl.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
> index 7a6dd91987fd..0562071cdd4a 100644
> --- a/drivers/misc/cxl/cxl.h
> +++ b/drivers/misc/cxl/cxl.h
> @@ -1104,7 +1104,7 @@ extern const struct cxl_backend_ops
> cxl_native_ops;
>  extern const struct cxl_backend_ops cxl_guest_ops;
>  extern const struct cxl_backend_ops *cxl_ops;
>  
> -/* check if the given pci_dev is on the the cxl vphb bus */
> +/* check if the given pci_dev is on the cxl vphb bus */
>  bool cxl_pci_is_vphb_device(struct pci_dev *dev);
>  
>  /* decode AFU error bits in the PSL register PSL_SERR_An */




Re: [PATCH v2 4/4] watchdog/pseries-wdt: initial support for H_WATCHDOG-based watchdog timers

2022-06-21 Thread Nathan Lynch
Scott Cheloha  writes:
> PAPR v2.12 defines a new hypercall, H_WATCHDOG.  The hypercall permits
> guest control of one or more virtual watchdog timers.  The timers have
> millisecond granularity.  The guest is terminated when a timer
> expires.
>
> This patch adds a watchdog driver for these timers, "pseries-wdt".
>
> pseries_wdt_probe() currently assumes the existence of only one
> platform device and always assigns it watchdogNumber 1.  If we ever
> expose more than one timer to userspace we will need to devise a way
> to assign a distinct watchdogNumber to each platform device at device
> registration time.
>
> Signed-off-by: Scott Cheloha 

Reviewed-by: Nathan Lynch 


Re: [PATCH v2 3/4] powerpc/pseries: register pseries-wdt device with platform bus

2022-06-21 Thread Nathan Lynch
Scott Cheloha  writes:
> PAPR v2.12 defines a new hypercall, H_WATCHDOG.  The hypercall permits
> guest control of one or more virtual watchdog timers.
>
> These timers do not conform to PowerPC device conventions.  They are
> not affixed to any extant bus, nor do they have full representation in
> the device tree.
>
> As a workaround we represent them as platform devices.
>
> This patch registers a single platform device, "pseries-wdt", with the
> platform bus if the FW_FEATURE_WATCHDOG flag is set.
>
> A driver for this device, "pseries-wdt", will be introduced in a
> subsequent patch.
>
> Signed-off-by: Scott Cheloha 
> ---
>  arch/powerpc/platforms/pseries/setup.c | 17 +
>  1 file changed, 17 insertions(+)
>
> diff --git a/arch/powerpc/platforms/pseries/setup.c 
> b/arch/powerpc/platforms/pseries/setup.c
> index afb074269b42..233c64f59815 100644
> --- a/arch/powerpc/platforms/pseries/setup.c
> +++ b/arch/powerpc/platforms/pseries/setup.c
> @@ -14,6 +14,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -169,6 +170,22 @@ static void __init fwnmi_init(void)
>  #endif
>  }
>  
> +/*
> + * Affix a device for the first timer to the platform bus if
> + * we have firmware support for the H_WATCHDOG hypercall.
> + */
> +static struct platform_device *pseries_wdt_pdev;
> +
> +static __init int pseries_wdt_init(void)
> +{
> + if (!firmware_has_feature(FW_FEATURE_WATCHDOG))
> + return 0;
> + pseries_wdt_pdev = platform_device_register_simple("pseries-wdt",
> +0, NULL, 0);
> + return 0;
> +}
> +machine_subsys_initcall(pseries, pseries_wdt_init);
> +

Seems like we don't need pseries_wdt_pdev as it's unused elsewhere? But
that's quite minor.

Reviewed-by: Nathan Lynch 


Re: [PATCH v2 2/4] powerpc/pseries: add FW_FEATURE_WATCHDOG flag

2022-06-21 Thread Nathan Lynch
Scott Cheloha  writes:
> PAPR v2.12 specifies a new optional function set, "hcall-watchdog",
> for the /rtas/ibm,hypertas-functions property.  The presence of this
> function set indicates support for the H_WATCHDOG hypercall.
>
> Check for this function set and, if present, set the new
> FW_FEATURE_WATCHDOG flag.
>
> Signed-off-by: Scott Cheloha 

...

> diff --git a/arch/powerpc/include/asm/firmware.h 
> b/arch/powerpc/include/asm/firmware.h
> index 834b8ecf..398e0b5e485f 100644
> --- a/arch/powerpc/include/asm/firmware.h
> +++ b/arch/powerpc/include/asm/firmware.h
> @@ -55,6 +55,7 @@
>  #define FW_FEATURE_RPT_INVALIDATE ASM_CONST(0x0100)
>  #define FW_FEATURE_FORM2_AFFINITY ASM_CONST(0x0200)
>  #define FW_FEATURE_ENERGY_SCALE_INFO ASM_CONST(0x0400)
> +#define FW_FEATURE_WATCHDOG  ASM_CONST(0x0800)
>  
>  #ifndef __ASSEMBLY__
>  
> @@ -76,7 +77,7 @@ enum {
>   FW_FEATURE_DRC_INFO | FW_FEATURE_BLOCK_REMOVE |
>   FW_FEATURE_PAPR_SCM | FW_FEATURE_ULTRAVISOR |
>   FW_FEATURE_RPT_INVALIDATE | FW_FEATURE_FORM2_AFFINITY |
> - FW_FEATURE_ENERGY_SCALE_INFO,
> + FW_FEATURE_ENERGY_SCALE_INFO | FW_FEATURE_WATCHDOG,
>   FW_FEATURE_PSERIES_ALWAYS = 0,
>   FW_FEATURE_POWERNV_POSSIBLE = FW_FEATURE_OPAL | FW_FEATURE_ULTRAVISOR,
>   FW_FEATURE_POWERNV_ALWAYS = 0,
> diff --git a/arch/powerpc/platforms/pseries/firmware.c 
> b/arch/powerpc/platforms/pseries/firmware.c
> index 09c119b2f623..080108d129ed 100644
> --- a/arch/powerpc/platforms/pseries/firmware.c
> +++ b/arch/powerpc/platforms/pseries/firmware.c
> @@ -67,6 +67,7 @@ hypertas_fw_features_table[] = {
>   {FW_FEATURE_PAPR_SCM,   "hcall-scm"},
>   {FW_FEATURE_RPT_INVALIDATE, "hcall-rpt-invalidate"},
>   {FW_FEATURE_ENERGY_SCALE_INFO,  "hcall-energy-scale-info"},
> + {FW_FEATURE_WATCHDOG,   "hcall-watchdog"},
>  };

All looks correct.

Reviewed-by: Nathan Lynch 


Re: [PATCH v2 1/4] powerpc/pseries: hvcall.h: add H_WATCHDOG opcode, H_NOOP return code

2022-06-21 Thread Nathan Lynch
Scott Cheloha  writes:
> PAPR v2.12 defines a new hypercall, H_WATCHDOG.  The hypercall permits
> guest control of one or more virtual watchdog timers.
>
> Add the opcode for the H_WATCHDOG hypercall to hvcall.h.  While here,
> add a definition for H_NOOP, a possible return code for H_WATCHDOG.
>
> Signed-off-by: Scott Cheloha 
> ---
>  arch/powerpc/include/asm/hvcall.h | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/include/asm/hvcall.h 
> b/arch/powerpc/include/asm/hvcall.h
> index d92a20a85395..4b4f69c35b4f 100644
> --- a/arch/powerpc/include/asm/hvcall.h
> +++ b/arch/powerpc/include/asm/hvcall.h
> @@ -87,6 +87,7 @@
>  #define H_P7 -60
>  #define H_P8 -61
>  #define H_P9 -62
> +#define H_NOOP   -63
>  #define H_TOO_BIG-64
>  #define H_UNSUPPORTED-67
>  #define H_OVERLAP-68

Not a problem to fix in your series, but I guess these should be
parenthesized i.e.

#define H_P7(-60)
#define H_P8(-61)
#define H_P9(-62)
#define H_NOOP  (-63)

> @@ -324,7 +325,8 @@
>  #define H_RPT_INVALIDATE 0x448
>  #define H_SCM_FLUSH  0x44C
>  #define H_GET_ENERGY_SCALE_INFO  0x450
> -#define MAX_HCALL_OPCODE H_GET_ENERGY_SCALE_INFO
> +#define H_WATCHDOG   0x45C
> +#define MAX_HCALL_OPCODE H_WATCHDOG
>

Looks fine.

Reviewed-by: Nathan Lynch 



[PATCH v5] powerpc/powernv: wire up rng during setup_arch

2022-06-21 Thread Jason A. Donenfeld
The platform's RNG must be available before random_init() in order to be
useful for initial seeding, which in turn means that it needs to be
called from setup_arch(), rather than from an init call. Fortunately,
each platform already has a setup_arch function pointer, which means we
can wire it up that way. Complicating things, however, is that POWER8
systems need some per-cpu state and kmalloc, which isn't available at
this stage. So we split things up into an early phase and a later
opportunistic phase. This commit also removes some noisy log messages
that don't add much.

Cc: sta...@vger.kernel.org
Cc: Michael Ellerman 
Reviewed-by: Christophe Leroy 
Fixes: a4da0d50b2a0 ("powerpc: Implement arch_get_random_long/int() for 
powernv")
Signed-off-by: Jason A. Donenfeld 
---
 arch/powerpc/platforms/powernv/powernv.h |  2 +
 arch/powerpc/platforms/powernv/rng.c | 47 
 arch/powerpc/platforms/powernv/setup.c   |  2 +
 3 files changed, 35 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/powernv.h 
b/arch/powerpc/platforms/powernv/powernv.h
index e297bf4abfcb..fd3f5e1eb10b 100644
--- a/arch/powerpc/platforms/powernv/powernv.h
+++ b/arch/powerpc/platforms/powernv/powernv.h
@@ -42,4 +42,6 @@ ssize_t memcons_copy(struct memcons *mc, char *to, loff_t 
pos, size_t count);
 u32 __init memcons_get_size(struct memcons *mc);
 struct memcons *__init memcons_init(struct device_node *node, const char 
*mc_prop_name);
 
+void powernv_rng_init(void);
+
 #endif /* _POWERNV_H */
diff --git a/arch/powerpc/platforms/powernv/rng.c 
b/arch/powerpc/platforms/powernv/rng.c
index e3d44b36ae98..e332e72e1857 100644
--- a/arch/powerpc/platforms/powernv/rng.c
+++ b/arch/powerpc/platforms/powernv/rng.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include "powernv.h"
 
 #define DARN_ERR 0xul
 
@@ -28,7 +29,6 @@ struct powernv_rng {
 
 static DEFINE_PER_CPU(struct powernv_rng *, powernv_rng);
 
-
 int powernv_hwrng_present(void)
 {
struct powernv_rng *rng;
@@ -98,9 +98,6 @@ static int __init initialise_darn(void)
return 0;
}
}
-
-   pr_warn("Unable to use DARN for get_random_seed()\n");
-
return -EIO;
 }
 
@@ -163,32 +160,50 @@ static __init int rng_create(struct device_node *dn)
 
rng_init_per_cpu(rng, dn);
 
-   pr_info_once("Registering arch random hook.\n");
-
ppc_md.get_random_seed = powernv_get_random_long;
 
return 0;
 }
 
-static __init int rng_init(void)
+static int __init powernv_get_random_long_early(unsigned long *v)
 {
struct device_node *dn;
-   int rc;
+
+   if (!slab_is_available())
+   return 0;
+
+   if (cmpxchg(_md.get_random_seed, powernv_get_random_long_early,
+   NULL) != powernv_get_random_long_early)
+   return 0;
 
for_each_compatible_node(dn, NULL, "ibm,power-rng") {
-   rc = rng_create(dn);
-   if (rc) {
-   pr_err("Failed creating rng for %pOF (%d).\n",
-   dn, rc);
+   if (rng_create(dn))
continue;
-   }
-
/* Create devices for hwrng driver */
of_platform_device_create(dn, NULL, NULL);
}
 
-   initialise_darn();
+   if (!ppc_md.get_random_seed)
+   return 0;
+   return ppc_md.get_random_seed(v);
+}
+
+void __init powernv_rng_init(void)
+{
+   /* Prefer darn over the rest. */
+   if (!initialise_darn())
+   return;
+
+   if (of_find_compatible_node(NULL, NULL, "ibm,power-rng"))
+   ppc_md.get_random_seed = powernv_get_random_long_early;
+}
 
+static int __init powernv_rng_late_init(void)
+{
+   unsigned long v;
+   /* In case it wasn't called during init for some other reason. */
+   if (ppc_md.get_random_seed == powernv_get_random_long_early)
+   powernv_get_random_long_early();
return 0;
 }
-machine_subsys_initcall(powernv, rng_init);
+machine_subsys_initcall(powernv, powernv_rng_late_init);
diff --git a/arch/powerpc/platforms/powernv/setup.c 
b/arch/powerpc/platforms/powernv/setup.c
index 824c3ad7a0fa..a5fcb6796b22 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -203,6 +203,8 @@ static void __init pnv_setup_arch(void)
pnv_check_guarded_cores();
 
/* XXX PMCS */
+
+   powernv_rng_init();
 }
 
 static void __init pnv_init(void)
-- 
2.35.1



Re: [PATCH 4/4] ASoC: wm8904: add DMIC support

2022-06-21 Thread Mark Brown
On Mon, Jun 20, 2022 at 07:53:56PM +, Pierluigi Passaro wrote:

> > This means that DMICDAT2 is not usefully selectable at runtime, you've
> > got IN1 as digital and IN2 as analogue, so while the DMIC/ADC switch is
> > useful the DMIC1/2 switch is not.

> A customer could have the following working configuration
> - pin 1: DMIC_CLK
> - pin 24: LINEIN2R
> - pin 25: DMICDAT2
> - pin 26: LINEIN2L
> - pin 27: DMICDAT1

> with no shared pins: here there's the chance to select DMIC1, DMIC2 and
> LINEIN2 at runtime: I can't find a reason for a fixed behavior.
> Can you please elaborate ?

So in that case the driver should offer the DMIC1/2 selection.  The
driver should be looking at which pins are wired up as DMICs and only
registering controls that can actually be used in the system based on
the pins that are wired up.


signature.asc
Description: PGP signature


[PATCH] powerpc/pseries: Hold reference and fix refcount leak bugs

2022-06-21 Thread Liang He
In pseries_cpuhp_cache_use_count() and pseries_cpuhp_detach_nodes(),
we need carefully hold the reference returned by
of_find_next_cache_node() and use it to call of_node_put() to keep
refcount balance.

Signed-off-by: Liang He 
---
 arch/powerpc/platforms/pseries/hotplug-cpu.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c 
b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index 0f8cd8b06432..e0a7ac5db15d 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -619,17 +619,21 @@ static ssize_t dlpar_cpu_add(u32 drc_index)
 static unsigned int pseries_cpuhp_cache_use_count(const struct device_node 
*cachedn)
 {
unsigned int use_count = 0;
-   struct device_node *dn;
+   struct device_node *dn, *tn;
 
WARN_ON(!of_node_is_type(cachedn, "cache"));
 
for_each_of_cpu_node(dn) {
-   if (of_find_next_cache_node(dn) == cachedn)
+   tn = of_find_next_cache_node(dn);
+   of_node_put(tn);
+   if (tn == cachedn)
use_count++;
}
 
for_each_node_by_type(dn, "cache") {
-   if (of_find_next_cache_node(dn) == cachedn)
+   tn = of_find_next_cache_node(dn);
+   of_node_put(tn);
+   if (tn == cachedn)
use_count++;
}
 
@@ -649,10 +653,13 @@ static int pseries_cpuhp_detach_nodes(struct device_node 
*cpudn)
 
dn = cpudn;
while ((dn = of_find_next_cache_node(dn))) {
-   if (pseries_cpuhp_cache_use_count(dn) > 1)
+   if (pseries_cpuhp_cache_use_count(dn) > 1) {
+   of_node_put(dn);
break;
+   }
 
ret = of_changeset_detach_node(, dn);
+   of_node_put(dn);
if (ret)
goto out;
}
-- 
2.25.1



Re: [PATCH v5 1/5] powerpc/kexec: make update_cpus_node non-static

2022-06-21 Thread Laurent Dufour
On 20/06/2022, 09:01:02, Sourabh Jain wrote:
> Make the update_cpus_node function non-static and export it for
> usage in other kexec components.
> 
> The update_cpus_node definition is moved to core_64.c so that it
> can be used with both kexec_load and kexec_file_load system calls.
> 
> No functional change intended.

And FWIW
Reviewed-by: Laurent Dufour 
> 
> Signed-off-by: Sourabh Jain 
> ---
>  arch/powerpc/include/asm/kexec.h  |  1 +
>  arch/powerpc/kexec/core_64.c  | 88 +++
>  arch/powerpc/kexec/file_load_64.c | 87 --
>  3 files changed, 89 insertions(+), 87 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/kexec.h 
> b/arch/powerpc/include/asm/kexec.h
> index 2aefe14e1442..c8040c93b15a 100644
> --- a/arch/powerpc/include/asm/kexec.h
> +++ b/arch/powerpc/include/asm/kexec.h
> @@ -129,6 +129,7 @@ unsigned int kexec_extra_fdt_size_ppc64(struct kimage 
> *image);
>  int setup_new_fdt_ppc64(const struct kimage *image, void *fdt,
>   unsigned long initrd_load_addr,
>   unsigned long initrd_len, const char *cmdline);
> +int update_cpus_node(void *fdt);
>  #endif /* CONFIG_PPC64 */
>  
>  #endif /* CONFIG_KEXEC_FILE */
> diff --git a/arch/powerpc/kexec/core_64.c b/arch/powerpc/kexec/core_64.c
> index 6cc7793b8420..65b3afb2169a 100644
> --- a/arch/powerpc/kexec/core_64.c
> +++ b/arch/powerpc/kexec/core_64.c
> @@ -16,6 +16,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  #include 
> @@ -377,6 +378,93 @@ void default_machine_kexec(struct kimage *image)
>   /* NOTREACHED */
>  }
>  
> +/**
> + * add_node_props - Reads node properties from device node structure and add
> + *  them to fdt.
> + * @fdt:Flattened device tree of the kernel
> + * @node_offset:offset of the node to add a property at
> + * @dn: device node pointer
> + *
> + * Returns 0 on success, negative errno on error.
> + */
> +static int add_node_props(void *fdt, int node_offset, const struct 
> device_node *dn)
> +{
> + int ret = 0;
> + struct property *pp;
> +
> + if (!dn)
> + return -EINVAL;
> +
> + for_each_property_of_node(dn, pp) {
> + ret = fdt_setprop(fdt, node_offset, pp->name, pp->value, 
> pp->length);
> + if (ret < 0) {
> + pr_err("Unable to add %s property: %s\n", pp->name, 
> fdt_strerror(ret));
> + return ret;
> + }
> + }
> + return ret;
> +}
> +
> +/**
> + * update_cpus_node - Update cpus node of flattened device tree using of_root
> + *device node.
> + * @fdt:  Flattened device tree of the kernel.
> + *
> + * Returns 0 on success, negative errno on error.
> + */
> +int update_cpus_node(void *fdt)
> +{
> + struct device_node *cpus_node, *dn;
> + int cpus_offset, cpus_subnode_offset, ret = 0;
> +
> + cpus_offset = fdt_path_offset(fdt, "/cpus");
> + if (cpus_offset < 0 && cpus_offset != -FDT_ERR_NOTFOUND) {
> + pr_err("Malformed device tree: error reading /cpus node: %s\n",
> +fdt_strerror(cpus_offset));
> + return cpus_offset;
> + }
> +
> + if (cpus_offset > 0) {
> + ret = fdt_del_node(fdt, cpus_offset);
> + if (ret < 0) {
> + pr_err("Error deleting /cpus node: %s\n", 
> fdt_strerror(ret));
> + return -EINVAL;
> + }
> + }
> +
> + /* Add cpus node to fdt */
> + cpus_offset = fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"), "cpus");
> + if (cpus_offset < 0) {
> + pr_err("Error creating /cpus node: %s\n", 
> fdt_strerror(cpus_offset));
> + return -EINVAL;
> + }
> +
> + /* Add cpus node properties */
> + cpus_node = of_find_node_by_path("/cpus");
> + ret = add_node_props(fdt, cpus_offset, cpus_node);
> + of_node_put(cpus_node);
> + if (ret < 0)
> + return ret;
> +
> + /* Loop through all subnodes of cpus and add them to fdt */
> + for_each_node_by_type(dn, "cpu") {
> + cpus_subnode_offset = fdt_add_subnode(fdt, cpus_offset, 
> dn->full_name);
> + if (cpus_subnode_offset < 0) {
> + pr_err("Unable to add %s subnode: %s\n", dn->full_name,
> +fdt_strerror(cpus_subnode_offset));
> + ret = cpus_subnode_offset;
> + goto out;
> + }
> +
> + ret = add_node_props(fdt, cpus_subnode_offset, dn);
> + if (ret < 0)
> + goto out;
> + }
> +out:
> + of_node_put(dn);
> + return ret;
> +}
> +
>  #ifdef CONFIG_PPC_64S_HASH_MMU
>  /* Values we need to export to the second kernel via the device tree. */
>  static unsigned long htab_base;
> diff --git a/arch/powerpc/kexec/file_load_64.c 
> b/arch/powerpc/kexec/file_load_64.c
> index 

Re: [PATCH v2 2/3] scsi: BusLogic remove bus_to_virt

2022-06-21 Thread Hannes Reinecke

On 6/17/22 14:57, Arnd Bergmann wrote:

From: Arnd Bergmann 

The BusLogic driver is the last remaining driver that relies on the
deprecated bus_to_virt() function, which in turn only works on a few
architectures, and is incompatible with both swiotlb and iommu support.

Before commit 391e2f25601e ("[SCSI] BusLogic: Port driver to 64-bit."),
the driver had a dependency on x86-32, presumably because of this
problem. However, the change introduced another bug that made it still
impossible to use the driver on any 64-bit machine.

This was in turn fixed in commit 56f396146af2 ("scsi: BusLogic: Fix
64-bit system enumeration error for Buslogic"), 8 years later, which
shows that there are not a lot of users.

Maciej is still using the driver on 32-bit hardware, and Khalid mentioned
that the driver works with the device emulation used in VirtualBox
and VMware. Both of those only emulate it for Windows 2000 and older
operating systems that did not ship with the better LSI logic driver.

Do a minimum fix that searches through the list of descriptors to find
one that matches the bus address. This is clearly as inefficient as
was indicated in the code comment about the lack of a bus_to_virt()
replacement. A better fix would likely involve changing out the entire
descriptor allocation for a simpler one, but that would be much
more invasive.

Cc: Maciej W. Rozycki 
Cc: Matt Wang 
Cc: Khalid Aziz 
Signed-off-by: Arnd Bergmann 
---
  drivers/scsi/BusLogic.c | 27 ---
  drivers/scsi/Kconfig|  2 +-
  2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index a897c8f914cf..d057abfcdd5c 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -2515,12 +2515,26 @@ static int blogic_resultcode(struct blogic_adapter 
*adapter,
return (hoststatus << 16) | tgt_status;
  }
  
+/*

+ * turn the dma address from an inbox into a ccb pointer
+ * This is rather inefficient.
+ */
+static struct blogic_ccb *
+blogic_inbox_to_ccb(struct blogic_adapter *adapter, struct blogic_inbox *inbox)
+{
+   struct blogic_ccb *ccb;
+
+   for (ccb = adapter->all_ccbs; ccb; ccb = ccb->next_all)
+   if (inbox->ccb == ccb->dma_handle)
+   break;
+
+   return ccb;
+}
  
  /*

blogic_scan_inbox scans the Incoming Mailboxes saving any
Incoming Mailbox entries for completion processing.
  */
-
  static void blogic_scan_inbox(struct blogic_adapter *adapter)
  {
/*
@@ -2540,16 +2554,7 @@ static void blogic_scan_inbox(struct blogic_adapter 
*adapter)
enum blogic_cmplt_code comp_code;
  
  	while ((comp_code = next_inbox->comp_code) != BLOGIC_INBOX_FREE) {

-   /*
-  We are only allowed to do this because we limit our
-  architectures we run on to machines where bus_to_virt(
-  actually works.  There *needs* to be a dma_addr_to_virt()
-  in the new PCI DMA mapping interface to replace
-  bus_to_virt() or else this code is going to become very
-  innefficient.
-*/
-   struct blogic_ccb *ccb =
-   (struct blogic_ccb *) bus_to_virt(next_inbox->ccb);
+   struct blogic_ccb *ccb = blogic_inbox_to_ccb(adapter, 
adapter->next_inbox);
if (comp_code != BLOGIC_CMD_NOTFOUND) {
if (ccb->status == BLOGIC_CCB_ACTIVE ||
ccb->status == BLOGIC_CCB_RESET) {
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index cf75588a2587..56bdc08d0b77 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -513,7 +513,7 @@ config SCSI_HPTIOP
  
  config SCSI_BUSLOGIC

tristate "BusLogic SCSI support"
-   depends on PCI && SCSI && VIRT_TO_BUS
+   depends on PCI && SCSI
help
  This is support for BusLogic MultiMaster and FlashPoint SCSI Host
  Adapters. Consult the SCSI-HOWTO, available from


CCB handling in the driver is ugly anyway, so that'll be good enough.

Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
--
Dr. Hannes ReineckeKernel Storage Architect
h...@suse.de  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer


Re: [PATCH v2 1/3] scsi: dpt_i2o: drop stale VIRT_TO_BUS dependency

2022-06-21 Thread Hannes Reinecke

On 6/17/22 14:57, Arnd Bergmann wrote:

From: Arnd Bergmann 

The dpt_i2o driver was fixed to stop using virt_to_bus() in 2008, but
it still has a stale reference in an error handling code path that could
never work.

Fix it up to build without VIRT_TO_BUS and remove the Kconfig dependency.

The alternative to this would be to just remove the driver, as it is
clearly obsolete. The i2o driver layer was removed in 2015 with commit
4a72a7af462d ("staging: remove i2o subsystem"), but the even older
dpt_i2o scsi driver stayed around.

The last non-cleanup patches I could find were from Miquel van Smoorenburg
and Mark Salyzyn back in 2008, they might know if there is any chance
of the hardware still being used anywhere.

Fixes: 67af2b060e02 ("[SCSI] dpt_i2o: move from virt_to_bus/bus_to_virt to 
dma_alloc_coherent")
Cc: Miquel van Smoorenburg 
Cc: Mark Salyzyn 
Signed-off-by: Arnd Bergmann 
---
  drivers/scsi/Kconfig   | 2 +-
  drivers/scsi/dpt_i2o.c | 4 ++--
  2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index a9fe5152addd..cf75588a2587 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -460,7 +460,7 @@ config SCSI_MVUMI
  
  config SCSI_DPT_I2O

tristate "Adaptec I2O RAID support "
-   depends on SCSI && PCI && VIRT_TO_BUS
+   depends on SCSI && PCI
help
  This driver supports all of Adaptec's I2O based RAID controllers as
  well as the DPT SmartRaid V cards.  This is an Adaptec maintained
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 2e9155ba7408..55dfe7011912 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -52,11 +52,11 @@ MODULE_DESCRIPTION("Adaptec I2O RAID Driver");
  
  #include 

  #include 
+#include 
  #include 
  #include 
  
  #include 	/* for boot_cpu_data */

-#include   /* for virt_to_bus, etc. */
  
  #include 

  #include 
@@ -2112,7 +2112,7 @@ static irqreturn_t adpt_isr(int irq, void *dev_id)
} else {
/* Ick, we should *never* be here */
printk(KERN_ERR "dpti: reply frame not from pool\n");
-   reply = (u8 *)bus_to_virt(m);
+   goto out;
}
  
  		if (readl(reply) & MSG_FAIL) {


Reviewed-by: Hannes Reinecke 

Personally I wouldn't mind to see this driver gone, as it's being built 
upon the (long-defunct) I2O specification. We already deleted the i2o 
subsystem years ago, so maybe it's time to consign this driver to 
history, too.


Cheers,

Hannes
--
Dr. Hannes ReineckeKernel Storage Architect
h...@suse.de  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer


[PATCH] powerpc/83xx: Hold the reference returned by of_find_compatible_node

2022-06-21 Thread Liang He
In mpc832x_spi_init(), we should hold the reference returned by
of_find_compatible_node() and use it to call of_node_put() for
refcount balance.

Signed-off-by: Liang He 
---
 arch/powerpc/platforms/83xx/mpc832x_rdb.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/83xx/mpc832x_rdb.c 
b/arch/powerpc/platforms/83xx/mpc832x_rdb.c
index bb8caa5071f8..e12cb44e717f 100644
--- a/arch/powerpc/platforms/83xx/mpc832x_rdb.c
+++ b/arch/powerpc/platforms/83xx/mpc832x_rdb.c
@@ -162,6 +162,8 @@ static struct spi_board_info mpc832x_spi_boardinfo = {
 
 static int __init mpc832x_spi_init(void)
 {
+   struct device_node *np;
+
par_io_config_pin(3,  0, 3, 0, 1, 0); /* SPI1 MOSI, I/O */
par_io_config_pin(3,  1, 3, 0, 1, 0); /* SPI1 MISO, I/O */
par_io_config_pin(3,  2, 3, 0, 1, 0); /* SPI1 CLK,  I/O */
@@ -175,7 +177,9 @@ static int __init mpc832x_spi_init(void)
 * Don't bother with legacy stuff when device tree contains
 * mmc-spi-slot node.
 */
-   if (of_find_compatible_node(NULL, NULL, "mmc-spi-slot"))
+   np = of_find_compatible_node(NULL, NULL, "mmc-spi-slot");
+   of_node_put(np);
+   if (np)
return 0;
return fsl_spi_init(_spi_boardinfo, 1, mpc83xx_spi_cs_control);
 }
-- 
2.25.1



[PATCH] powerpc/512x: Hold the reference returned by of_find_compatible_node

2022-06-21 Thread Liang He
In mpc5121_clk_provide_migration_support(), we need to hold the
reference returned by of_find_compatible_node() and use it to call
of_node_put for refcount balance.

Signed-off-by: Liang He 
---
 arch/powerpc/platforms/512x/clock-commonclk.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/512x/clock-commonclk.c 
b/arch/powerpc/platforms/512x/clock-commonclk.c
index ca475462e95b..42abeba4f698 100644
--- a/arch/powerpc/platforms/512x/clock-commonclk.c
+++ b/arch/powerpc/platforms/512x/clock-commonclk.c
@@ -950,7 +950,7 @@ static void __init mpc5121_clk_register_of_provider(struct 
device_node *np)
  */
 static void __init mpc5121_clk_provide_migration_support(void)
 {
-
+   struct device_node *np;
/*
 * pre-enable those clock items which are not yet appropriately
 * acquired by their peripheral driver
@@ -970,7 +970,9 @@ static void __init 
mpc5121_clk_provide_migration_support(void)
 * unused and so it gets disabled
 */
clk_prepare_enable(clks[MPC512x_CLK_PSC3_MCLK]);/* serial console */
-   if (of_find_compatible_node(NULL, "pci", "fsl,mpc5121-pci"))
+   np = of_find_compatible_node(NULL, "pci", "fsl,mpc5121-pci");
+   of_node_put(np);
+   if (np)
clk_prepare_enable(clks[MPC512x_CLK_PCI]);
 }
 
-- 
2.25.1



[PATCH] powerpc/cell: Hold reference returned by of_find_node_by_xxx APIs

2022-06-21 Thread Liang He
In cell_iommu_init_disabled() and cbe_get_be_node(), we need to
hold the reference returned by of_find_node_by_xxx APIs and use
it to call of_node_put() for refcount balance.

Signed-off-by: Liang He 
---
 arch/powerpc/platforms/cell/cbe_regs.c | 10 --
 arch/powerpc/platforms/cell/iommu.c|  5 -
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/cell/cbe_regs.c 
b/arch/powerpc/platforms/cell/cbe_regs.c
index 316e533afc00..09cbdfc070b3 100644
--- a/arch/powerpc/platforms/cell/cbe_regs.c
+++ b/arch/powerpc/platforms/cell/cbe_regs.c
@@ -182,9 +182,15 @@ static struct device_node *__init cbe_get_be_node(int 
cpu_id)
if (WARN_ON_ONCE(!cpu_handle))
return np;
 
-   for (i=0; i