Re: [PATCH v2 net-next] ethernet: ucc_geth: Use kmemdup() rather than kmalloc+memcpy
Hello: This patch was applied to netdev/net-next.git (refs/heads/master): On Mon, 24 May 2021 09:07:01 +0800 you wrote: > Issue identified with Coccinelle. > > Signed-off-by: YueHaibing > --- > v2: keep kmemdup oneline > > drivers/net/ethernet/freescale/ucc_geth.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) Here is the summary with links: - [v2,net-next] ethernet: ucc_geth: Use kmemdup() rather than kmalloc+memcpy https://git.kernel.org/netdev/net-next/c/ec7d6dd870d4 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Re: [PATCH 1/1] powerpc/ps3: Fix error return code in ps3_register_devices()
On 2021/5/24 4:15, Geoff Levand wrote: > Hi, > > On 5/20/21 5:20 AM, Michael Ellerman wrote: >> Zhen Lei writes: >>> When call ps3_start_probe_thread() failed, further initialization should >>> be stopped and the returned error code should be propagated. > ... >>> --- a/arch/powerpc/platforms/ps3/device-init.c >>> >>> result = ps3_start_probe_thread(PS3_BUS_TYPE_STORAGE); >>> + if (result < 0) >>> + return result; >> >> If you bail out here you skip: >> >>> ps3_register_vuart_devices(); >> >> Which I suspect means there will be no console output? >> >> Presumably the system won't boot if the probe thread fails, but it might >> at least print an oops, whereas if we return we might get nothing at >> all. Though I'm just guessing, I don't know this code that well. > > That probe is for the storage devices (PS3_BUS_TYPE_STORAGE). > > There are cases where the system is usable even if the storage > devices are not available, for example, when using an NFS root > filesystem. > > ps3_start_probe_thread was made to be quite verbose on error > to make up for it's return value not being checked. So should we delete the local variable 'result' and ignore the return value? - result = ps3_start_probe_thread(PS3_BUS_TYPE_STORAGE); - (void)ps3_start_probe_thread(PS3_BUS_TYPE_STORAGE); > >> Anyway please leave this code alone unless you're willing to test your >> changes, or at least provide a more thorough justification for them. > > Agreed, this change should not be merged. > > -Geoff > > . >
Re: [PATCH v2 net-next] ethernet: ucc_geth: Use kmemdup() rather than kmalloc+memcpy
On Mon, May 24, 2021 at 09:07:01AM +0800, YueHaibing wrote: > Issue identified with Coccinelle. > > Signed-off-by: YueHaibing Reviewed-by: Andrew Lunn Andrew
[PATCH v2 net-next] ethernet: ucc_geth: Use kmemdup() rather than kmalloc+memcpy
Issue identified with Coccinelle. Signed-off-by: YueHaibing --- v2: keep kmemdup oneline drivers/net/ethernet/freescale/ucc_geth.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c index e0936510fa34..0acfafb73db1 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c @@ -3590,10 +3590,9 @@ static int ucc_geth_probe(struct platform_device* ofdev) if ((ucc_num < 0) || (ucc_num > 7)) return -ENODEV; - ug_info = kmalloc(sizeof(*ug_info), GFP_KERNEL); + ug_info = kmemdup(_primary_info, sizeof(*ug_info), GFP_KERNEL); if (ug_info == NULL) return -ENOMEM; - memcpy(ug_info, _primary_info, sizeof(*ug_info)); ug_info->uf_info.ucc_num = ucc_num; -- 2.17.1
Re: [PATCH net-next] ethernet: ucc_geth: Use kmemdup() rather than kmalloc+memcpy
On 2021/5/23 22:26, Andrew Lunn wrote: > On Sun, May 23, 2021 at 03:29:37PM +0200, Christophe Leroy wrote: >> YueHaibing a écrit : >> >>> Issue identified with Coccinelle. >>> >>> Signed-off-by: YueHaibing >>> --- >>> drivers/net/ethernet/freescale/ucc_geth.c | 4 ++-- >>> 1 file changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/net/ethernet/freescale/ucc_geth.c >>> b/drivers/net/ethernet/freescale/ucc_geth.c >>> index e0936510fa34..51206272cc25 100644 >>> --- a/drivers/net/ethernet/freescale/ucc_geth.c >>> +++ b/drivers/net/ethernet/freescale/ucc_geth.c >>> @@ -3590,10 +3590,10 @@ static int ucc_geth_probe(struct >>> platform_device* ofdev) >>> if ((ucc_num < 0) || (ucc_num > 7)) >>> return -ENODEV; >>> >>> - ug_info = kmalloc(sizeof(*ug_info), GFP_KERNEL); >>> + ug_info = kmemdup(_primary_info, sizeof(*ug_info), >>> + GFP_KERNEL); >> >> Can you keep that as a single line ? The tolerance is 100 chars per line now. > > Networking prefers 80. If it fits a single 80 char line, please use a single > line. > Otherwise please leave it as it is. Ok, will send v2. > > Andrew > . >
[powerpc:merge] BUILD SUCCESS 8dbbcb8a8856c6b4e56ae705218d8dad1f9cf1e9
allnoconfig ia64 allmodconfig ia64defconfig ia64 allyesconfig m68k allmodconfig m68kdefconfig m68k allyesconfig nios2 defconfig arc allyesconfig nds32 allnoconfig nds32 defconfig nios2allyesconfig cskydefconfig alpha defconfig alphaallyesconfig xtensa allyesconfig arc defconfig sh allmodconfig s390defconfig parisc defconfig s390 allmodconfig parisc allyesconfig i386 allyesconfig sparcallyesconfig sparc defconfig mips allyesconfig mips allmodconfig powerpc allyesconfig powerpc allmodconfig powerpc allnoconfig i386 randconfig-a001-20210523 i386 randconfig-a002-20210523 i386 randconfig-a003-20210523 i386 randconfig-a004-20210523 i386 randconfig-a001-20210524 i386 randconfig-a002-20210524 i386 randconfig-a005-20210524 i386 randconfig-a006-20210524 i386 randconfig-a004-20210524 i386 randconfig-a003-20210524 i386 randconfig-a005-20210523 i386 randconfig-a006-20210523 x86_64 randconfig-a014-20210523 x86_64 randconfig-a016-20210523 x86_64 randconfig-a015-20210523 x86_64 randconfig-a013-20210523 x86_64 randconfig-a012-20210523 x86_64 randconfig-a011-20210523 i386 randconfig-a016-20210523 i386 randconfig-a011-20210523 i386 randconfig-a015-20210523 i386 randconfig-a012-20210523 i386 randconfig-a014-20210523 i386 randconfig-a013-20210523 x86_64 randconfig-a005-20210524 x86_64 randconfig-a001-20210524 x86_64 randconfig-a006-20210524 x86_64 randconfig-a003-20210524 x86_64 randconfig-a004-20210524 x86_64 randconfig-a002-20210524 riscvallyesconfig riscv allnoconfig riscv defconfig riscv rv32_defconfig riscvallmodconfig um allmodconfig umallnoconfig um allyesconfig um defconfig x86_64 allyesconfig x86_64rhel-8.3-kselftests x86_64 defconfig x86_64 rhel-8.3 x86_64 rhel-8.3-kbuiltin x86_64 kexec clang tested configs: x86_64 randconfig-b001-20210524 x86_64 randconfig-b001-20210523 x86_64 randconfig-a013-20210524 x86_64 randconfig-a012-20210524 x86_64 randconfig-a014-20210524 x86_64 randconfig-a016-20210524 x86_64 randconfig-a015-20210524 x86_64 randconfig-a011-20210524 x86_64 randconfig-a006-20210523 x86_64 randconfig-a001-20210523 x86_64 randconfig-a005-20210523 x86_64 randconfig-a003-20210523 x86_64 randconfig-a004-20210523 x86_64 randconfig-a002-20210523 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org
[powerpc:fixes-test] BUILD SUCCESS b49f9d9b0e428909796b4a7e7f1049f489859e0f
randconfig-a001-20210524 x86_64 randconfig-a006-20210524 x86_64 randconfig-a003-20210524 x86_64 randconfig-a004-20210524 x86_64 randconfig-a002-20210524 i386 randconfig-a001-20210524 i386 randconfig-a002-20210524 i386 randconfig-a005-20210524 i386 randconfig-a006-20210524 i386 randconfig-a004-20210524 i386 randconfig-a003-20210524 i386 randconfig-a001-20210523 i386 randconfig-a005-20210523 i386 randconfig-a002-20210523 i386 randconfig-a003-20210523 i386 randconfig-a004-20210523 i386 randconfig-a006-20210523 i386 randconfig-a001-20210522 i386 randconfig-a005-20210522 i386 randconfig-a002-20210522 i386 randconfig-a004-20210522 i386 randconfig-a003-20210522 i386 randconfig-a006-20210522 x86_64 randconfig-a013-20210523 x86_64 randconfig-a014-20210523 x86_64 randconfig-a012-20210523 x86_64 randconfig-a016-20210523 x86_64 randconfig-a015-20210523 x86_64 randconfig-a011-20210523 i386 randconfig-a016-20210523 i386 randconfig-a011-20210523 i386 randconfig-a015-20210523 i386 randconfig-a012-20210523 i386 randconfig-a014-20210523 i386 randconfig-a013-20210523 i386 randconfig-a016-20210522 i386 randconfig-a011-20210522 i386 randconfig-a015-20210522 i386 randconfig-a012-20210522 i386 randconfig-a014-20210522 i386 randconfig-a013-20210522 i386 randconfig-a011-20210524 i386 randconfig-a016-20210524 i386 randconfig-a015-20210524 i386 randconfig-a012-20210524 i386 randconfig-a014-20210524 i386 randconfig-a013-20210524 riscvallyesconfig riscv allnoconfig riscv rv32_defconfig riscvallmodconfig um allmodconfig umallnoconfig um allyesconfig um defconfig x86_64 allyesconfig x86_64rhel-8.3-kselftests x86_64 defconfig x86_64 rhel-8.3 x86_64 rhel-8.3-kbuiltin x86_64 kexec clang tested configs: x86_64 randconfig-b001-20210524 x86_64 randconfig-b001-20210522 x86_64 randconfig-b001-20210523 x86_64 randconfig-a006-20210523 x86_64 randconfig-a001-20210523 x86_64 randconfig-a005-20210523 x86_64 randconfig-a003-20210523 x86_64 randconfig-a004-20210523 x86_64 randconfig-a002-20210523 x86_64 randconfig-a013-20210524 x86_64 randconfig-a012-20210524 x86_64 randconfig-a014-20210524 x86_64 randconfig-a016-20210524 x86_64 randconfig-a015-20210524 x86_64 randconfig-a011-20210524 x86_64 randconfig-a013-20210522 x86_64 randconfig-a014-20210522 x86_64 randconfig-a012-20210522 x86_64 randconfig-a016-20210522 x86_64 randconfig-a015-20210522 x86_64 randconfig-a011-20210522 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org
Re: [PATCH 1/1] powerpc/ps3: Fix error return code in ps3_register_devices()
Hi, On 5/20/21 5:20 AM, Michael Ellerman wrote: > Zhen Lei writes: >> When call ps3_start_probe_thread() failed, further initialization should >> be stopped and the returned error code should be propagated. ... >> --- a/arch/powerpc/platforms/ps3/device-init.c >> >> result = ps3_start_probe_thread(PS3_BUS_TYPE_STORAGE); >> +if (result < 0) >> +return result; > > If you bail out here you skip: > >> ps3_register_vuart_devices(); > > Which I suspect means there will be no console output? > > Presumably the system won't boot if the probe thread fails, but it might > at least print an oops, whereas if we return we might get nothing at > all. Though I'm just guessing, I don't know this code that well. That probe is for the storage devices (PS3_BUS_TYPE_STORAGE). There are cases where the system is usable even if the storage devices are not available, for example, when using an NFS root filesystem. ps3_start_probe_thread was made to be quite verbose on error to make up for it's return value not being checked. > Anyway please leave this code alone unless you're willing to test your > changes, or at least provide a more thorough justification for them. Agreed, this change should not be merged. -Geoff
Re: [PATCH 12/26] bcache: convert to blk_alloc_disk/blk_cleanup_disk
On 5/21/21 1:51 PM, Christoph Hellwig wrote: > Convert the bcache driver to use the blk_alloc_disk and blk_cleanup_disk > helpers to simplify gendisk and request_queue allocation. > > Signed-off-by: Christoph Hellwig Acked-by: Coly Li Thanks. Coly Li > --- > drivers/md/bcache/super.c | 15 --- > 1 file changed, 4 insertions(+), 11 deletions(-) > > diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c > index bea8c4429ae8..185246a0d855 100644 > --- a/drivers/md/bcache/super.c > +++ b/drivers/md/bcache/super.c > @@ -890,13 +890,9 @@ static void bcache_device_free(struct bcache_device *d) > if (disk_added) > del_gendisk(disk); > > - if (disk->queue) > - blk_cleanup_queue(disk->queue); > - > + blk_cleanup_disk(disk); > ida_simple_remove(_device_idx, > first_minor_to_idx(disk->first_minor)); > - if (disk_added) > - put_disk(disk); > } > > bioset_exit(>bio_split); > @@ -946,7 +942,7 @@ static int bcache_device_init(struct bcache_device *d, > unsigned int block_size, > BIOSET_NEED_BVECS|BIOSET_NEED_RESCUER)) > goto err; > > - d->disk = alloc_disk(BCACHE_MINORS); > + d->disk = blk_alloc_disk(NUMA_NO_NODE); > if (!d->disk) > goto err; > > @@ -955,14 +951,11 @@ static int bcache_device_init(struct bcache_device *d, > unsigned int block_size, > > d->disk->major = bcache_major; > d->disk->first_minor= idx_to_first_minor(idx); > + d->disk->minors = BCACHE_MINORS; > d->disk->fops = ops; > d->disk->private_data = d; > > - q = blk_alloc_queue(NUMA_NO_NODE); > - if (!q) > - return -ENOMEM; > - > - d->disk->queue = q; > + q = d->disk->queue; > q->limits.max_hw_sectors= UINT_MAX; > q->limits.max_sectors = UINT_MAX; > q->limits.max_segment_size = UINT_MAX; >
Re: [GIT PULL] Please pull powerpc/linux.git powerpc-5.13-4 tag
The pull request you sent on Sun, 23 May 2021 20:31:42 +1000: > https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git > tags/powerpc-5.13-4 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/28ceac6959e1db015729c52ec74e0a4ff496c2b8 Thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html
Re: [PATCH] KVM: PPC: Book3S HV: Fix reverse map real-mode address lookup with huge vmalloc
Nicholas Piggin a écrit : real_vmalloc_addr() does not currently work for huge vmalloc, which is what the reverse map can be allocated with for radix host, hash guest. Add huge page awareness to the function. Fixes: 8abddd968a30 ("powerpc/64s/radix: Enable huge vmalloc mappings") Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv_rm_mmu.c | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/arch/powerpc/kvm/book3s_hv_rm_mmu.c index 7af7c70f1468..5f68cb5cc009 100644 --- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c +++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c @@ -26,16 +26,23 @@ static void *real_vmalloc_addr(void *x) { unsigned long addr = (unsigned long) x; + unsigned long mask; + int shift; pte_t *p; + /* -* assume we don't have huge pages in vmalloc space... -* So don't worry about THP collapse/split. Called -* Only in realmode with MSR_EE = 0, hence won't need irq_save/restore. +* This is called only in realmode with MSR_EE = 0, hence won't need +* irq_save/restore around find_init_mm_pte. */ - p = find_init_mm_pte(addr, NULL); + p = find_init_mm_pte(addr, ); if (!p || !pte_present(*p)) return NULL; - addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & ~PAGE_MASK); + if (!shift) + shift = PAGE_SHIFT; + + mask = (1UL << shift) - 1; + addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & mask); Looks strange, before we have ~MASK now we have mask without the ~ Also use PFN_PHYS() instead of open coding ? + return __va(addr); } -- 2.23.0
[PATCH] KVM: PPC: Book3S HV: Fix reverse map real-mode address lookup with huge vmalloc
real_vmalloc_addr() does not currently work for huge vmalloc, which is what the reverse map can be allocated with for radix host, hash guest. Add huge page awareness to the function. Fixes: 8abddd968a30 ("powerpc/64s/radix: Enable huge vmalloc mappings") Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv_rm_mmu.c | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/arch/powerpc/kvm/book3s_hv_rm_mmu.c index 7af7c70f1468..5f68cb5cc009 100644 --- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c +++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c @@ -26,16 +26,23 @@ static void *real_vmalloc_addr(void *x) { unsigned long addr = (unsigned long) x; + unsigned long mask; + int shift; pte_t *p; + /* -* assume we don't have huge pages in vmalloc space... -* So don't worry about THP collapse/split. Called -* Only in realmode with MSR_EE = 0, hence won't need irq_save/restore. +* This is called only in realmode with MSR_EE = 0, hence won't need +* irq_save/restore around find_init_mm_pte. */ - p = find_init_mm_pte(addr, NULL); + p = find_init_mm_pte(addr, ); if (!p || !pte_present(*p)) return NULL; - addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & ~PAGE_MASK); + if (!shift) + shift = PAGE_SHIFT; + + mask = (1UL << shift) - 1; + addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & mask); + return __va(addr); } -- 2.23.0
Re: [PATCH net-next] ethernet: ucc_geth: Use kmemdup() rather than kmalloc+memcpy
On Sun, May 23, 2021 at 03:29:37PM +0200, Christophe Leroy wrote: > YueHaibing a écrit : > > > Issue identified with Coccinelle. > > > > Signed-off-by: YueHaibing > > --- > > drivers/net/ethernet/freescale/ucc_geth.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/net/ethernet/freescale/ucc_geth.c > > b/drivers/net/ethernet/freescale/ucc_geth.c > > index e0936510fa34..51206272cc25 100644 > > --- a/drivers/net/ethernet/freescale/ucc_geth.c > > +++ b/drivers/net/ethernet/freescale/ucc_geth.c > > @@ -3590,10 +3590,10 @@ static int ucc_geth_probe(struct > > platform_device* ofdev) > > if ((ucc_num < 0) || (ucc_num > 7)) > > return -ENODEV; > > > > - ug_info = kmalloc(sizeof(*ug_info), GFP_KERNEL); > > + ug_info = kmemdup(_primary_info, sizeof(*ug_info), > > + GFP_KERNEL); > > Can you keep that as a single line ? The tolerance is 100 chars per line now. Networking prefers 80. If it fits a single 80 char line, please use a single line. Otherwise please leave it as it is. Andrew
Re: [PATCH] KVM: PPC: Book3S HV: Save host FSCR in the P7/8 path
Excerpts from Nicholas Piggin's message of May 23, 2021 10:21 pm: > Similar to commit 25edcc50d76c ("KVM: PPC: Book3S HV: Save and restore > FSCR in the P9 path"), ensure the P7/8 path saves and restores the host > FSCR. The logic explained in that patch actually applies there to the > old path well: a context switch can be made before kvmppc_vcpu_run_hv > restores the host FSCR and returns. > > Fixes: b005255e12a3 ("KVM: PPC: Book3S HV: Context-switch new POWER8 SPRs") > Signed-off-by: Nicholas Piggin > --- > arch/powerpc/kvm/book3s_hv_rmhandlers.S | 11 +-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S > b/arch/powerpc/kvm/book3s_hv_rmhandlers.S > index 5e634db4809b..2b98e710c7a1 100644 > --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S > +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S > @@ -44,7 +44,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_300) > #define NAPPING_UNSPLIT 3 > > /* Stack frame offsets for kvmppc_hv_entry */ > -#define SFS 208 > +#define SFS 216 > #define STACK_SLOT_TRAP (SFS-4) > #define STACK_SLOT_SHORT_PATH(SFS-8) > #define STACK_SLOT_TID (SFS-16) > @@ -59,8 +59,9 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_300) > #define STACK_SLOT_UAMOR (SFS-88) > #define STACK_SLOT_DAWR1 (SFS-96) > #define STACK_SLOT_DAWRX1(SFS-104) > +#define STACK_SLOT_FSCR (SFS-112) > /* the following is used by the P9 short path */ > -#define STACK_SLOT_NVGPRS(SFS-152) /* 18 gprs */ > +#define STACK_SLOT_NVGPRS(SFS-160) /* 18 gprs */ Actually, hmm.. this is wrong because nvgprs are subtracted from this offset. But then I can't work out why 95a6432ce9038 raised SFS from 160 to 208. Thanks, Nick
Re: [PATCH net-next] ethernet: ucc_geth: Use kmemdup() rather than kmalloc+memcpy
YueHaibing a écrit : Issue identified with Coccinelle. Signed-off-by: YueHaibing --- drivers/net/ethernet/freescale/ucc_geth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c index e0936510fa34..51206272cc25 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c @@ -3590,10 +3590,10 @@ static int ucc_geth_probe(struct platform_device* ofdev) if ((ucc_num < 0) || (ucc_num > 7)) return -ENODEV; - ug_info = kmalloc(sizeof(*ug_info), GFP_KERNEL); + ug_info = kmemdup(_primary_info, sizeof(*ug_info), + GFP_KERNEL); Can you keep that as a single line ? The tolerance is 100 chars per line now. if (ug_info == NULL) return -ENOMEM; - memcpy(ug_info, _primary_info, sizeof(*ug_info)); ug_info->uf_info.ucc_num = ucc_num; -- 2.17.1
[PATCH] KVM: PPC: Book3S HV: Save host FSCR in the P7/8 path
Similar to commit 25edcc50d76c ("KVM: PPC: Book3S HV: Save and restore FSCR in the P9 path"), ensure the P7/8 path saves and restores the host FSCR. The logic explained in that patch actually applies there to the old path well: a context switch can be made before kvmppc_vcpu_run_hv restores the host FSCR and returns. Fixes: b005255e12a3 ("KVM: PPC: Book3S HV: Context-switch new POWER8 SPRs") Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S index 5e634db4809b..2b98e710c7a1 100644 --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S @@ -44,7 +44,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_300) #define NAPPING_UNSPLIT3 /* Stack frame offsets for kvmppc_hv_entry */ -#define SFS208 +#define SFS216 #define STACK_SLOT_TRAP(SFS-4) #define STACK_SLOT_SHORT_PATH (SFS-8) #define STACK_SLOT_TID (SFS-16) @@ -59,8 +59,9 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_300) #define STACK_SLOT_UAMOR (SFS-88) #define STACK_SLOT_DAWR1 (SFS-96) #define STACK_SLOT_DAWRX1 (SFS-104) +#define STACK_SLOT_FSCR(SFS-112) /* the following is used by the P9 short path */ -#define STACK_SLOT_NVGPRS (SFS-152) /* 18 gprs */ +#define STACK_SLOT_NVGPRS (SFS-160) /* 18 gprs */ /* * Call kvmppc_hv_entry in real mode. @@ -686,6 +687,8 @@ BEGIN_FTR_SECTION std r6, STACK_SLOT_DAWR0(r1) std r7, STACK_SLOT_DAWRX0(r1) std r8, STACK_SLOT_IAMR(r1) + mfspr r5, SPRN_FSCR + std r5, STACK_SLOT_FSCR(r1) END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) BEGIN_FTR_SECTION mfspr r6, SPRN_DAWR1 @@ -1663,6 +1666,10 @@ FTR_SECTION_ELSE ld r7, STACK_SLOT_HFSCR(r1) mtspr SPRN_HFSCR, r7 ALT_FTR_SECTION_END_IFCLR(CPU_FTR_ARCH_300) +BEGIN_FTR_SECTION + ld r5, STACK_SLOT_FSCR(r1) + mtspr SPRN_FSCR, r5 +END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) /* * Restore various registers to 0, where non-zero values * set by the guest could disrupt the host. -- 2.23.0
Re: [PATCH V2 1/1] powerpc/perf: Fix PMU callbacks to clear pending PMI before resetting an overflown PMC
> On 17-May-2021, at 8:50 AM, Nicholas Piggin wrote: > > Sorry I missed this :( > > Excerpts from Athira Rajeev's message of April 20, 2021 1:01 pm: >> Running perf fuzzer showed below in dmesg logs: >> "Can't find PMC that caused IRQ" >> >> This means a PMU exception happened, but none of the PMC's (Performance >> Monitor Counter) were found to be overflown. There are some corner cases >> that clears the PMCs after PMI gets masked. In such cases, the perf >> interrupt handler will not find the active PMC values that had caused >> the overflow and thus leads to this message while replaying. >> >> Case 1: PMU Interrupt happens during replay of other interrupts and >> counter values gets cleared by PMU callbacks before replay: >> >> During replay of interrupts like timer, __do_irq and doorbell exception, we >> conditionally enable interrupts via may_hard_irq_enable(). This could >> potentially create a window to generate a PMI. Since irq soft mask is set >> to ALL_DISABLED, the PMI will get masked here. We could get IPIs run before >> perf interrupt is replayed and the PMU events could deleted or stopped. >> This will change the PMU SPR values and resets the counters. Snippet of >> ftrace log showing PMU callbacks invoked in "__do_irq": >> >> -0 [051] dns. 132025441306354: __do_irq <-call_do_irq >> -0 [051] dns. 132025441306430: irq_enter <-__do_irq >> -0 [051] dns. 132025441306503: irq_enter_rcu <-__do_irq >> -0 [051] dnH. 132025441306599: xive_get_irq <-__do_irq >> <<>> >> -0 [051] dnH. 132025441307770: >> generic_smp_call_function_single_interrupt <-smp_ipi_demux_relaxed >> -0 [051] dnH. 132025441307839: flush_smp_call_function_queue >> <-smp_ipi_demux_relaxed >> -0 [051] dnH. 132025441308057: _raw_spin_lock <-event_function >> -0 [051] dnH. 132025441308206: power_pmu_disable <-perf_pmu_disable >> -0 [051] dnH. 132025441308337: power_pmu_del <-event_sched_out >> -0 [051] dnH. 132025441308407: power_pmu_read <-power_pmu_del >> -0 [051] dnH. 132025441308477: read_pmc <-power_pmu_read >> -0 [051] dnH. 132025441308590: isa207_disable_pmc <-power_pmu_del >> -0 [051] dnH. 132025441308663: write_pmc <-power_pmu_del >> -0 [051] dnH. 132025441308787: power_pmu_event_idx >> <-perf_event_update_userpage >> -0 [051] dnH. 132025441308859: rcu_read_unlock_strict >> <-perf_event_update_userpage >> -0 [051] dnH. 132025441308975: power_pmu_enable <-perf_pmu_enable >> <<>> >> -0 [051] dnH. 132025441311108: irq_exit <-__do_irq >> -0 [051] dns. 132025441311319: performance_monitor_exception >> <-replay_soft_interrupts >> >> Case 2: PMI's masked during local_* operations, example local_add. >> If the local_add operation happens within a local_irq_save, replay of >> PMI will be during local_irq_restore. Similar to case 1, this could >> also create a window before replay where PMU events gets deleted or >> stopped. >> >> Patch adds a fix to update the PMU callback functions (del,stop,enable) to >> check for pending perf interrupt. If there is an overflown PMC and pending >> perf interrupt indicated in Paca or by PMAO bit set in MMCR0, clear the PMI >> bit in paca to drop that sample. Also clear the MMCR0 PMAO bit which >> otherwise could lead to spurious interrupts in some corner cases. Example, >> a timer after power_pmu_del which will re-enable interrupts since PMI is >> cleared and triggers a PMI again since PMAO bit is still set. Another >> condition occures if had disabled MSR[EE] right before perf interrupt >> came in. Re-enabling interrupt will trigger PMI since PMAO is still set. >> But fails to find valid overflow if PMC get cleared before enabling EE. >> >> We can't just replay PMI any time. Hence this approach is preferred rather >> than replaying PMI before resetting overflown PMC. Patch also documents >> core-book3s on a race condition which can trigger these PMC messages during >> idle path in PowerNV. >> >> Fixes: f442d004806e ("powerpc/64s: Add support to mask perf interrupts and >> replay them") >> Reported-by: Nageswara R Sastry >> Suggested-by: Nicholas Piggin > > I would say you can leave ^ this line out. You and Maddy did the hard > work of coming up with the fix, I just suggested a few minor changes. Thanks Nick for reviewing the patch and your suggestions helped us in the solution approach :) > >> Suggested-by: Madhavan Srinivasan >> Signed-off-by: Athira Rajeev >> --- >> arch/powerpc/include/asm/hw_irq.h | 19 >> arch/powerpc/perf/core-book3s.c | 77 +++ >> 2 files changed, 96 insertions(+) >> >> diff --git a/arch/powerpc/include/asm/hw_irq.h >> b/arch/powerpc/include/asm/hw_irq.h >> index 56a98936a6a9..7e192bd8253b 100644 >> --- a/arch/powerpc/include/asm/hw_irq.h >> +++ b/arch/powerpc/include/asm/hw_irq.h >> @@ -215,6 +215,23 @@ static inline bool arch_irqs_disabled(void) >> return arch_irqs_disabled_flags(arch_local_save_flags()); >> } >> >> +static inline int get_clear_pmi_irq_pending(void) >> +{ >> +/* >> + * Some
Re: [PATCH] powerpc/udbg_hvc: retry putc on -EAGAIN
Greg KH writes: > On Fri, May 14, 2021 at 04:44:22PM -0500, Nathan Lynch wrote: >> hvterm_raw_put_chars() calls hvc_put_chars(), which may return -EAGAIN >> when the underlying hcall returns a "busy" status, but udbg_hvc_putc() >> doesn't handle this. When using xmon on a PowerVM guest, this can >> result in incomplete or garbled output when printing relatively large >> amounts of data quickly, such as when dumping the kernel log buffer. >> >> Call again on -EAGAIN. >> >> Signed-off-by: Nathan Lynch >> --- >> drivers/tty/hvc/hvc_vio.c | 2 +- > > Subject line does not match up with this file name. > > Don't you want "tty" and "hvc" in there somewhere? It's a powerpc only driver, but I guess the subject should still be "tty: hvc: ..." to match convention. I was planning to take this via the powerpc tree, but I can drop it if you'd rather take it. cheers
[GIT PULL] Please pull powerpc/linux.git powerpc-5.13-4 tag
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Hi Linus, Please pull some more powerpc fixes for 5.13. It's not obvious from the diff, but the seccomp_bpf.c change is entirely inside a __powerpc__ ifdef. cheers The following changes since commit d07f6ca923ea0927a1024dfccafc5b53b61cfecc: Linux 5.13-rc2 (2021-05-16 15:27:44 -0700) are available in the git repository at: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git tags/powerpc-5.13-4 for you to fetch changes up to d72500f992849d31ebae8f821a023660ddd0dcc2: powerpc/64s/syscall: Fix ptrace syscall info with scv syscalls (2021-05-21 00:58:56 +1000) - -- powerpc fixes for 5.13 #4 Fix breakage of strace (and other ptracers etc.) when using the new scv ABI (Power9 or later with glibc >= 2.33). Fix early_ioremap() on 64-bit, which broke booting on some machines. Thanks to: Dmitry V. Levin, Nicholas Piggin, Alexey Kardashevskiy, Christophe Leroy. - -- Alexey Kardashevskiy (1): powerpc: Fix early setup to make early_ioremap() work Nicholas Piggin (2): powerpc/64s/syscall: Use pt_regs.trap to distinguish syscall ABI difference between sc and scv syscalls powerpc/64s/syscall: Fix ptrace syscall info with scv syscalls Documentation/powerpc/syscall64-abi.rst | 10 + arch/powerpc/include/asm/ptrace.h | 45 +++- arch/powerpc/include/asm/syscall.h| 42 +++--- arch/powerpc/kernel/setup_64.c| 4 +- tools/testing/selftests/seccomp/seccomp_bpf.c | 27 5 files changed, 82 insertions(+), 46 deletions(-) -BEGIN PGP SIGNATURE- iQIzBAEBCAAdFiEEJFGtCPCthwEv2Y/bUevqPMjhpYAFAmCqLoUACgkQUevqPMjh pYBx+g/8Cn2ZwpkN2QZ9bB0sqdjuU74jPzaAnEn+6soqCjySQ7fQI6a61M1Iv8Tv fuA04jAl07TKcE42JTEflFc0FxdvfYOhxHtRq68AdYBVCaA6Fd3hMY0WnWugUgPR +UEeMptSeDjBYfzq0h8VSRJj/slMqkDfn5EMTzjaNtOIY17dz3Mhpz1uXmiSuS/1 6xTGKFvlmauaGzgdlM5rjJZcRU70nDqG1F6brpUgHjEJfgOPKtEQRghWhetEUKuw EG3zi96no7L2WTFPlVLS2F1bYuItEnSmP8Abe0dttRDamFHX/gp349P8sOX+iwrI QZszmprjWU/IjTN8FT3qyFp9zquKiz7b3zwiMlrIf9WuN5eDxE4hK76M5Gx13obP 3jEnQvukw0GqiY+hSEvNaudnN6WzTlQN307bK76gV5xgGGp7eF4q93lhKgpj8Heg 1DBCquOODVk0TyeKmKs7v2/7PXBLkzSlzrYsHJmMv6E+Hdb0A1pYWxBQgmYp3/ON g3So3jTIruG3shukXYzn6Ay7Uq8rU7Pjhy1oWXGCTjv675Q06YS4X0ClIrkImayZ Um/lDsmwahroD2GRfbEt+JZmrulV5FTdYoMGSWk/wUfrEwB8ms3tte1dqGrnrQrY BUnJyLCXVhJknEnrOMxPgpzfTb91cseLE3/AI5HzdUf9Y963PRQ= =kF6i -END PGP SIGNATURE-
Re: [PATCH 26/26] block: unexport blk_alloc_queue
On 5/21/21 7:51 AM, Christoph Hellwig wrote: blk_alloc_queue is just an internal helper now, unexport it and remove it from the public header. Signed-off-by: Christoph Hellwig --- block/blk-core.c | 1 - block/blk.h| 2 ++ include/linux/blkdev.h | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 25/26] null_blk: convert to blk_alloc_disk/blk_cleanup_disk
On 5/21/21 7:51 AM, Christoph Hellwig wrote: Convert the null_blk driver to use the blk_alloc_disk and blk_cleanup_disk helpers to simplify gendisk and request_queue allocation. Note that the blk-mq mode is left with its own allocations scheme, to be handled later. Signed-off-by: Christoph Hellwig --- drivers/block/null_blk/main.c | 38 +-- 1 file changed, 19 insertions(+), 19 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 24/26] xpram: convert to blk_alloc_disk/blk_cleanup_disk
On 5/21/21 7:51 AM, Christoph Hellwig wrote: Convert the xpram driver to use the blk_alloc_disk and blk_cleanup_disk helpers to simplify gendisk and request_queue allocation. Signed-off-by: Christoph Hellwig --- drivers/s390/block/xpram.c | 26 +- 1 file changed, 9 insertions(+), 17 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 23/26] dcssblk: convert to blk_alloc_disk/blk_cleanup_disk
On 5/21/21 7:51 AM, Christoph Hellwig wrote: Convert the dcssblk driver to use the blk_alloc_disk and blk_cleanup_disk helpers to simplify gendisk and request_queue allocation. Signed-off-by: Christoph Hellwig --- drivers/s390/block/dcssblk.c | 26 -- 1 file changed, 8 insertions(+), 18 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 22/26] ps3vram: convert to blk_alloc_disk/blk_cleanup_disk
On 5/21/21 7:51 AM, Christoph Hellwig wrote: Convert the ps3vram driver to use the blk_alloc_disk and blk_cleanup_disk helpers to simplify gendisk and request_queue allocation. Signed-off-by: Christoph Hellwig --- drivers/block/ps3vram.c | 31 --- 1 file changed, 8 insertions(+), 23 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 21/26] n64cart: convert to blk_alloc_disk
On 5/21/21 7:51 AM, Christoph Hellwig wrote: Convert the n64cart driver to use the blk_alloc_disk helper to simplify gendisk and request_queue allocation. Signed-off-by: Christoph Hellwig --- drivers/block/n64cart.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 20/26] simdisk: convert to blk_alloc_disk/blk_cleanup_disk
On 5/21/21 7:51 AM, Christoph Hellwig wrote: Convert the simdisk driver to use the blk_alloc_disk and blk_cleanup_disk helpers to simplify gendisk and request_queue allocation. Signed-off-by: Christoph Hellwig --- arch/xtensa/platforms/iss/simdisk.c | 29 +++-- 1 file changed, 7 insertions(+), 22 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 19/26] nfblock: convert to blk_alloc_disk/blk_cleanup_disk
On 5/21/21 7:51 AM, Christoph Hellwig wrote: Convert the nfblock driver to use the blk_alloc_disk and blk_cleanup_disk helpers to simplify gendisk and request_queue allocation. Signed-off-by: Christoph Hellwig --- arch/m68k/emu/nfblock.c | 20 +--- 1 file changed, 5 insertions(+), 15 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 18/26] nvme-multipath: convert to blk_alloc_disk/blk_cleanup_disk
On 5/21/21 7:51 AM, Christoph Hellwig wrote: Convert the nvme-multipath driver to use the blk_alloc_disk and blk_cleanup_disk helpers to simplify gendisk and request_queue allocation. Signed-off-by: Christoph Hellwig --- drivers/nvdimm/pmem.c | 1 - drivers/nvme/host/multipath.c | 45 ++- 2 files changed, 13 insertions(+), 33 deletions(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 9fcd05084564..31f3c4bd6f72 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -472,7 +472,6 @@ static int pmem_attach_disk(struct device *dev, blk_queue_flag_set(QUEUE_FLAG_DAX, q); disk->fops = _fops; - disk->queue = q; disk->private_data = pmem; nvdimm_namespace_disk_name(ndns, disk->disk_name); set_capacity(disk, (pmem->size - pmem->pfn_pad - pmem->data_offset) diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index a5d02f236cca..b5fbdb416022 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -427,7 +427,6 @@ static void nvme_requeue_work(struct work_struct *work) int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head) { - struct request_queue *q; bool vwc = false; mutex_init(>lock); @@ -443,33 +442,24 @@ int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head) if (!(ctrl->subsys->cmic & NVME_CTRL_CMIC_MULTI_CTRL) || !multipath) return 0; - q = blk_alloc_queue(ctrl->numa_node); - if (!q) - goto out; - blk_queue_flag_set(QUEUE_FLAG_NONROT, q); - /* set to a default value for 512 until disk is validated */ - blk_queue_logical_block_size(q, 512); - blk_set_stacking_limits(>limits); - - /* we need to propagate up the VMC settings */ - if (ctrl->vwc & NVME_CTRL_VWC_PRESENT) - vwc = true; - blk_queue_write_cache(q, vwc, vwc); - - head->disk = alloc_disk(0); + head->disk = blk_alloc_disk(ctrl->numa_node); if (!head->disk) - goto out_cleanup_queue; + return -ENOMEM; head->disk->fops = _ns_head_ops; head->disk->private_data = head; - head->disk->queue = q; sprintf(head->disk->disk_name, "nvme%dn%d", ctrl->subsys->instance, head->instance); - return 0; -out_cleanup_queue: - blk_cleanup_queue(q); -out: - return -ENOMEM; + blk_queue_flag_set(QUEUE_FLAG_NONROT, head->disk->queue); + /* set to a default value of 512 until the disk is validated */ + blk_queue_logical_block_size(head->disk->queue, 512); + blk_set_stacking_limits(>disk->queue->limits); + + /* we need to propagate up the VMC settings */ + if (ctrl->vwc & NVME_CTRL_VWC_PRESENT) + vwc = true; + blk_queue_write_cache(head->disk->queue, vwc, vwc); + return 0; } static void nvme_mpath_set_live(struct nvme_ns *ns) @@ -768,16 +758,7 @@ void nvme_mpath_remove_disk(struct nvme_ns_head *head) /* make sure all pending bios are cleaned up */ kblockd_schedule_work(>requeue_work); flush_work(>requeue_work); - blk_cleanup_queue(head->disk->queue); - if (!test_bit(NVME_NSHEAD_DISK_LIVE, >flags)) { - /* -* if device_add_disk wasn't called, prevent -* disk release to put a bogus reference on the -* request queue -*/ - head->disk->queue = NULL; - } - put_disk(head->disk); + blk_cleanup_disk(head->disk); } void nvme_mpath_init_ctrl(struct nvme_ctrl *ctrl) What about the check for GENHD_FL_UP a bit further up in line 766? Can this still happen with the new allocation scheme, ie is there still a difference in lifetime between ->disk and ->disk->queue? Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 17/26] nvdimm-pmem: convert to blk_alloc_disk/blk_cleanup_disk
On 5/21/21 7:51 AM, Christoph Hellwig wrote: Convert the nvdimm-pmem driver to use the blk_alloc_disk and blk_cleanup_disk helpers to simplify gendisk and request_queue allocation. Signed-off-by: Christoph Hellwig --- drivers/nvdimm/pmem.c | 15 +-- 1 file changed, 5 insertions(+), 10 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 16/26] nvdimm-btt: convert to blk_alloc_disk/blk_cleanup_disk
On 5/21/21 7:51 AM, Christoph Hellwig wrote: Convert the nvdimm-btt driver to use the blk_alloc_disk and blk_cleanup_disk helpers to simplify gendisk and request_queue allocation. Signed-off-by: Christoph Hellwig --- drivers/nvdimm/btt.c | 24 +++- drivers/nvdimm/btt.h | 2 -- 2 files changed, 7 insertions(+), 19 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 15/26] nvdimm-blk: convert to blk_alloc_disk/blk_cleanup_disk
On 5/21/21 7:51 AM, Christoph Hellwig wrote: Convert the nvdimm-blk driver to use the blk_alloc_disk and blk_cleanup_disk helpers to simplify gendisk and request_queue allocation. Signed-off-by: Christoph Hellwig --- drivers/nvdimm/blk.c | 26 ++ 1 file changed, 6 insertions(+), 20 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 14/26] md: convert to blk_alloc_disk/blk_cleanup_disk
On 5/21/21 7:51 AM, Christoph Hellwig wrote: Convert the md driver to use the blk_alloc_disk and blk_cleanup_disk helpers to simplify gendisk and request_queue allocation. Signed-off-by: Christoph Hellwig --- drivers/md/md.c | 25 + 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 49f897fbb89b..d806be8cc210 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -5598,12 +5598,10 @@ static void md_free(struct kobject *ko) if (mddev->sysfs_level) sysfs_put(mddev->sysfs_level); - if (mddev->gendisk) + if (mddev->gendisk) { del_gendisk(mddev->gendisk); - if (mddev->queue) - blk_cleanup_queue(mddev->queue); - if (mddev->gendisk) - put_disk(mddev->gendisk); + blk_cleanup_disk(mddev->gendisk); + } percpu_ref_exit(>writes_pending); bioset_exit(>bio_set); @@ -5711,20 +5709,13 @@ static int md_alloc(dev_t dev, char *name) goto abort; error = -ENOMEM; - mddev->queue = blk_alloc_queue(NUMA_NO_NODE); - if (!mddev->queue) + disk = blk_alloc_disk(NUMA_NO_NODE); + if (!disk) goto abort; - blk_set_stacking_limits(>queue->limits); - - disk = alloc_disk(1 << shift); - if (!disk) { - blk_cleanup_queue(mddev->queue); - mddev->queue = NULL; - goto abort; - } disk->major = MAJOR(mddev->unit); disk->first_minor = unit << shift; + disk->minors = 1 << shift; if (name) strcpy(disk->disk_name, name); else if (partitioned) @@ -5733,7 +5724,9 @@ static int md_alloc(dev_t dev, char *name) sprintf(disk->disk_name, "md%d", unit); disk->fops = _fops; disk->private_data = mddev; - disk->queue = mddev->queue; + + mddev->queue = disk->queue; + blk_set_stacking_limits(>queue->limits); blk_queue_write_cache(mddev->queue, true, true); /* Allow extended partitions. This makes the * 'mdp' device redundant, but we can't really Wouldn't it make sense to introduce a helper 'blk_queue_from_disk()' or somesuch to avoid having to keep an explicit 'queue' pointer? Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 13/26] dm: convert to blk_alloc_disk/blk_cleanup_disk
On 5/21/21 7:51 AM, Christoph Hellwig wrote: Convert the dm driver to use the blk_alloc_disk and blk_cleanup_disk helpers to simplify gendisk and request_queue allocation. Signed-off-by: Christoph Hellwig --- drivers/md/dm.c | 16 +++- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index ca2aedd8ee7d..3c7c2d257018 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1801,13 +1801,13 @@ static void cleanup_mapped_device(struct mapped_device *md) md->disk->private_data = NULL; spin_unlock(&_minor_lock); del_gendisk(md->disk); - put_disk(md->disk); } - if (md->queue) { + if (md->queue) dm_queue_destroy_keyslot_manager(md->queue); - blk_cleanup_queue(md->queue); - } + + if (md->disk) + blk_cleanup_disk(md->disk); cleanup_srcu_struct(>io_barrier); Can't these conditionals be merged into a single 'if (md->disk)'? Eg like: if (md->disk) { spin_lock(&_minor_lock); md->disk->private_data = NULL; spin_unlock(&_minor_lock); del_gendisk(md->disk); dm_queue_destroy_keyslot_manager(md->queue); blk_cleanup_disk(md->queue); } We're now always allocating 'md->disk' and 'md->queue' together, so how can we end up in a situation where one is set without the other? @@ -1869,13 +1869,10 @@ static struct mapped_device *alloc_dev(int minor) * established. If request-based table is loaded: blk-mq will * override accordingly. */ - md->queue = blk_alloc_queue(numa_node_id); - if (!md->queue) - goto bad; - - md->disk = alloc_disk_node(1, md->numa_node_id); + md->disk = blk_alloc_disk(md->numa_node_id); if (!md->disk) goto bad; + md->queue = md->disk->queue; init_waitqueue_head(>wait); INIT_WORK(>work, dm_wq_work); @@ -1888,6 +1885,7 @@ static struct mapped_device *alloc_dev(int minor) md->disk->major = _major; md->disk->first_minor = minor; + md->disk->minors = 1; md->disk->fops = _blk_dops; md->disk->queue = md->queue; md->disk->private_data = md; Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 12/26] bcache: convert to blk_alloc_disk/blk_cleanup_disk
On 5/21/21 7:51 AM, Christoph Hellwig wrote: Convert the bcache driver to use the blk_alloc_disk and blk_cleanup_disk helpers to simplify gendisk and request_queue allocation. Signed-off-by: Christoph Hellwig --- drivers/md/bcache/super.c | 15 --- 1 file changed, 4 insertions(+), 11 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 11/26] lightnvm: convert to blk_alloc_disk/blk_cleanup_disk
On 5/21/21 7:51 AM, Christoph Hellwig wrote: Convert the lightnvm driver to use the blk_alloc_disk and blk_cleanup_disk helpers to simplify gendisk and request_queue allocation. Signed-off-by: Christoph Hellwig --- drivers/lightnvm/core.c | 23 +-- 1 file changed, 5 insertions(+), 18 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 10/26] zram: convert to blk_alloc_disk/blk_cleanup_disk
On 5/21/21 7:51 AM, Christoph Hellwig wrote: Convert the zram driver to use the blk_alloc_disk and blk_cleanup_disk helpers to simplify gendisk and request_queue allocation. Signed-off-by: Christoph Hellwig --- drivers/block/zram/zram_drv.c | 19 --- 1 file changed, 4 insertions(+), 15 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 09/26] rsxx: convert to blk_alloc_disk/blk_cleanup_disk
On 5/21/21 7:50 AM, Christoph Hellwig wrote: Convert the rsxx driver to use the blk_alloc_disk and blk_cleanup_disk helpers to simplify gendisk and request_queue allocation. Signed-off-by: Christoph Hellwig --- drivers/block/rsxx/dev.c | 39 +- drivers/block/rsxx/rsxx_priv.h | 1 - 2 files changed, 15 insertions(+), 25 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
[PATCH net-next] ethernet: ucc_geth: Use kmemdup() rather than kmalloc+memcpy
Issue identified with Coccinelle. Signed-off-by: YueHaibing --- drivers/net/ethernet/freescale/ucc_geth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c index e0936510fa34..51206272cc25 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c @@ -3590,10 +3590,10 @@ static int ucc_geth_probe(struct platform_device* ofdev) if ((ucc_num < 0) || (ucc_num > 7)) return -ENODEV; - ug_info = kmalloc(sizeof(*ug_info), GFP_KERNEL); + ug_info = kmemdup(_primary_info, sizeof(*ug_info), + GFP_KERNEL); if (ug_info == NULL) return -ENOMEM; - memcpy(ug_info, _primary_info, sizeof(*ug_info)); ug_info->uf_info.ucc_num = ucc_num; -- 2.17.1
Re: [PATCH 08/26] pktcdvd: convert to blk_alloc_disk/blk_cleanup_disk
On 5/21/21 7:50 AM, Christoph Hellwig wrote: Convert the pktcdvd driver to use the blk_alloc_disk and blk_cleanup_disk helpers to simplify gendisk and request_queue allocation. Signed-off-by: Christoph Hellwig --- drivers/block/pktcdvd.c | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 07/26] drbd: convert to blk_alloc_disk/blk_cleanup_disk
On 5/21/21 7:50 AM, Christoph Hellwig wrote: Convert the drbd driver to use the blk_alloc_disk and blk_cleanup_disk helpers to simplify gendisk and request_queue allocation. Signed-off-by: Christoph Hellwig --- drivers/block/drbd/drbd_main.c | 23 --- 1 file changed, 8 insertions(+), 15 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 06/26] brd: convert to blk_alloc_disk/blk_cleanup_disk
On 5/21/21 7:50 AM, Christoph Hellwig wrote: Convert the brd driver to use the blk_alloc_disk and blk_cleanup_disk helpers to simplify gendisk and request_queue allocation. This also allows to remove the request_queue pointer in struct request_queue, and to simplify the initialization as blk_cleanup_disk can be called on any disk returned from blk_alloc_disk. Signed-off-by: Christoph Hellwig --- drivers/block/brd.c | 94 - 1 file changed, 33 insertions(+), 61 deletions(-) diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 7562cf30b14e..95694113e38e 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -38,9 +38,7 @@ * device). */ struct brd_device { - int brd_number; - - struct request_queue*brd_queue; + int brd_number; struct gendisk *brd_disk; struct list_headbrd_list; @@ -372,7 +370,7 @@ static LIST_HEAD(brd_devices); static DEFINE_MUTEX(brd_devices_mutex); static struct dentry *brd_debugfs_dir; -static struct brd_device *brd_alloc(int i) +static int brd_alloc(int i) { struct brd_device *brd; struct gendisk *disk; @@ -380,64 +378,55 @@ static struct brd_device *brd_alloc(int i) brd = kzalloc(sizeof(*brd), GFP_KERNEL); if (!brd) - goto out; + return -ENOMEM; brd->brd_number = i; spin_lock_init(>brd_lock); INIT_RADIX_TREE(>brd_pages, GFP_ATOMIC); - brd->brd_queue = blk_alloc_queue(NUMA_NO_NODE); - if (!brd->brd_queue) - goto out_free_dev; - snprintf(buf, DISK_NAME_LEN, "ram%d", i); if (!IS_ERR_OR_NULL(brd_debugfs_dir)) debugfs_create_u64(buf, 0444, brd_debugfs_dir, >brd_nr_pages); - /* This is so fdisk will align partitions on 4k, because of -* direct_access API needing 4k alignment, returning a PFN -* (This is only a problem on very small devices <= 4M, -* otherwise fdisk will align on 1M. Regardless this call -* is harmless) -*/ - blk_queue_physical_block_size(brd->brd_queue, PAGE_SIZE); - disk = brd->brd_disk = alloc_disk(max_part); + disk = brd->brd_disk = blk_alloc_disk(NUMA_NO_NODE); if (!disk) - goto out_free_queue; + goto out_free_dev; + disk->major = RAMDISK_MAJOR; disk->first_minor= i * max_part; + disk->minors = max_part; disk->fops = _fops; disk->private_data = brd; disk->flags = GENHD_FL_EXT_DEVT; strlcpy(disk->disk_name, buf, DISK_NAME_LEN); set_capacity(disk, rd_size * 2); + + /* +* This is so fdisk will align partitions on 4k, because of +* direct_access API needing 4k alignment, returning a PFN +* (This is only a problem on very small devices <= 4M, +* otherwise fdisk will align on 1M. Regardless this call +* is harmless) +*/ + blk_queue_physical_block_size(disk->queue, PAGE_SIZE); Maybe converting the comment to refer to 'PAGE_SIZE' instead of 4k while you're at it ... /* Tell the block layer that this is not a rotational device */ - blk_queue_flag_set(QUEUE_FLAG_NONROT, brd->brd_queue); - blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, brd->brd_queue); + blk_queue_flag_set(QUEUE_FLAG_NONROT, disk->queue); + blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, disk->queue); + add_disk(disk); + list_add_tail(>brd_list, _devices); - return brd; + return 0; -out_free_queue: - blk_cleanup_queue(brd->brd_queue); out_free_dev: kfree(brd); -out: - return NULL; -} - -static void brd_free(struct brd_device *brd) -{ - put_disk(brd->brd_disk); - blk_cleanup_queue(brd->brd_queue); - brd_free_pages(brd); - kfree(brd); + return -ENOMEM; } static void brd_probe(dev_t dev) { - struct brd_device *brd; int i = MINOR(dev) / max_part; + struct brd_device *brd; mutex_lock(_devices_mutex); list_for_each_entry(brd, _devices, brd_list) { @@ -445,13 +434,7 @@ static void brd_probe(dev_t dev) goto out_unlock; } - brd = brd_alloc(i); - if (brd) { - brd->brd_disk->queue = brd->brd_queue; - add_disk(brd->brd_disk); - list_add_tail(>brd_list, _devices); - } - + brd_alloc(i); out_unlock: mutex_unlock(_devices_mutex); } @@ -460,7 +443,9 @@ static void brd_del_one(struct brd_device *brd) { list_del(>brd_list); del_gendisk(brd->brd_disk); - brd_free(brd); + blk_cleanup_disk(brd->brd_disk); + brd_free_pages(brd); + kfree(brd); } static inline void brd_check_and_reset_par(void) @@ -485,7 +470,7
Re: [PATCH 05/26] block: add blk_alloc_disk and blk_cleanup_disk APIs
On 5/21/21 7:50 AM, Christoph Hellwig wrote: Add two new APIs to allocate and free a gendisk including the request_queue for use with BIO based drivers. This is to avoid boilerplate code in drivers. Signed-off-by: Christoph Hellwig --- block/genhd.c | 35 +++ include/linux/genhd.h | 22 ++ 2 files changed, 57 insertions(+) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 04/26] block: add a flag to make put_disk on partially initalized disks safer
On 5/21/21 7:50 AM, Christoph Hellwig wrote: Add a flag to indicate that __device_add_disk did grab a queue reference so that disk_release only drops it if we actually had it. This sort out one of the major pitfals with partially initialized gendisk that pitfalls a lot of drivers did get wrong or still do. Signed-off-by: Christoph Hellwig --- block/genhd.c | 7 +-- include/linux/genhd.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 03/26] block: automatically enable GENHD_FL_EXT_DEVT
On 5/21/21 7:50 AM, Christoph Hellwig wrote: Automatically set the GENHD_FL_EXT_DEVT flag for all disks allocated without an explicit number of minors. This is what all new block drivers should do, so make sure it is the default without boilerplate code. Signed-off-by: Christoph Hellwig --- block/genhd.c| 2 +- block/partitions/core.c | 4 drivers/block/n64cart.c | 2 +- drivers/lightnvm/core.c | 1 - drivers/memstick/core/ms_block.c | 1 - drivers/nvdimm/blk.c | 1 - drivers/nvdimm/btt.c | 1 - drivers/nvdimm/pmem.c| 1 - drivers/nvme/host/core.c | 1 - drivers/nvme/host/multipath.c| 1 - 10 files changed, 2 insertions(+), 13 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 02/26] block: move the DISK_MAX_PARTS sanity check into __device_add_disk
On 5/21/21 7:50 AM, Christoph Hellwig wrote: Keep this together with the first place that actually looks at ->minors and prepare for not passing a minors argument to alloc_disk. Signed-off-by: Christoph Hellwig --- block/genhd.c | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 01/26] block: refactor device number setup in __device_add_disk
On 5/21/21 7:50 AM, Christoph Hellwig wrote: Untangle the mess around blk_alloc_devt by moving the check for the used allocation scheme into the callers. Signed-off-by: Christoph Hellwig --- block/blk.h | 4 +- block/genhd.c | 96 - block/partitions/core.c | 15 +-- 3 files changed, 49 insertions(+), 66 deletions(-) ... and also fixes an issue with GENHD_FL_UP remained set in an error path in __device_add_disk(). Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeKernel Storage Architect h...@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer