Module Name: src Committed By: chs Date: Tue Oct 15 00:13:53 UTC 2019
Modified Files: src/sys/arch/ia64/ia64: sapic.c src/sys/arch/sparc64/dev: ldc.c src/sys/arch/x86/x86: cpu_ucode_amd.c src/sys/dev/acpi: sdhc_acpi.c src/sys/dev/ata: ata.c src/sys/dev/dm: dm_target_linear.c dm_target_snapshot.c dm_target_stripe.c src/sys/dev/gpio: gpio.c src/sys/dev/marvell: if_mvxpe.c mvxpsec.c Log Message: convert more KM_NOSLEEP to KM_SLEEP and remove code to handle failures. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/ia64/ia64/sapic.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc64/dev/ldc.c cvs rdiff -u -r1.9 -r1.10 src/sys/arch/x86/x86/cpu_ucode_amd.c cvs rdiff -u -r1.7 -r1.8 src/sys/dev/acpi/sdhc_acpi.c cvs rdiff -u -r1.150 -r1.151 src/sys/dev/ata/ata.c cvs rdiff -u -r1.17 -r1.18 src/sys/dev/dm/dm_target_linear.c cvs rdiff -u -r1.19 -r1.20 src/sys/dev/dm/dm_target_snapshot.c cvs rdiff -u -r1.23 -r1.24 src/sys/dev/dm/dm_target_stripe.c cvs rdiff -u -r1.62 -r1.63 src/sys/dev/gpio/gpio.c cvs rdiff -u -r1.29 -r1.30 src/sys/dev/marvell/if_mvxpe.c cvs rdiff -u -r1.2 -r1.3 src/sys/dev/marvell/mvxpsec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/ia64/ia64/sapic.c diff -u src/sys/arch/ia64/ia64/sapic.c:1.2 src/sys/arch/ia64/ia64/sapic.c:1.3 --- src/sys/arch/ia64/ia64/sapic.c:1.2 Sat Oct 27 17:29:03 2012 +++ src/sys/arch/ia64/ia64/sapic.c Tue Oct 15 00:13:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sapic.c,v 1.2 2012/10/27 17:29:03 chs Exp $ */ +/* $NetBSD: sapic.c,v 1.3 2019/10/15 00:13:52 chs Exp $ */ /*- * Copyright (c) 2001 Doug Rabson * All rights reserved. @@ -144,10 +144,7 @@ sapic_create(u_int id, u_int base, uint6 struct sapic *sa; u_int i; - sa = kmem_zalloc(sizeof(struct sapic), KM_NOSLEEP); - if (sa == NULL) - return NULL; - + sa = kmem_zalloc(sizeof(struct sapic), KM_SLEEP); sa->sa_id = id; sa->sa_base = base; sa->sa_registers = IA64_PHYS_TO_RR6(address); Index: src/sys/arch/sparc64/dev/ldc.c diff -u src/sys/arch/sparc64/dev/ldc.c:1.5 src/sys/arch/sparc64/dev/ldc.c:1.6 --- src/sys/arch/sparc64/dev/ldc.c:1.5 Tue Oct 1 18:00:07 2019 +++ src/sys/arch/sparc64/dev/ldc.c Tue Oct 15 00:13:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ldc.c,v 1.5 2019/10/01 18:00:07 chs Exp $ */ +/* $NetBSD: ldc.c,v 1.6 2019/10/15 00:13:52 chs Exp $ */ /* $OpenBSD: ldc.c,v 1.12 2015/03/21 18:02:58 kettenis Exp $ */ /* * Copyright (c) 2009 Mark Kettenis @@ -604,10 +604,7 @@ ldc_map_alloc(int nentries) #if OPENBSD_BUSDMA int nsegs; #endif - lm = kmem_zalloc(sizeof(struct ldc_map), KM_NOSLEEP); - if (lm == NULL) - return NULL; - + lm = kmem_zalloc(sizeof(struct ldc_map), KM_SLEEP); size = roundup(nentries * sizeof(struct ldc_map_slot), PAGE_SIZE); #if OPENBSD_BUSDMA @@ -634,9 +631,7 @@ ldc_map_alloc(int nentries) goto unmap; } #else - va = (vaddr_t)kmem_zalloc(size, KM_NOSLEEP); - if (va == 0) - goto free; + va = (vaddr_t)kmem_zalloc(size, KM_SLEEP); #endif lm->lm_slot = (struct ldc_map_slot *)va; lm->lm_nentries = nentries; @@ -650,9 +645,6 @@ free: bus_dmamem_free(t, &lm->lm_seg, 1); destroy: bus_dmamap_destroy(t, lm->lm_map); -#else -free: - kmem_free(lm, sizeof(struct ldc_map)); #endif return (NULL); } Index: src/sys/arch/x86/x86/cpu_ucode_amd.c diff -u src/sys/arch/x86/x86/cpu_ucode_amd.c:1.9 src/sys/arch/x86/x86/cpu_ucode_amd.c:1.10 --- src/sys/arch/x86/x86/cpu_ucode_amd.c:1.9 Sun Jan 27 02:08:39 2019 +++ src/sys/arch/x86/x86/cpu_ucode_amd.c Tue Oct 15 00:13:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_ucode_amd.c,v 1.9 2019/01/27 02:08:39 pgoyette Exp $ */ +/* $NetBSD: cpu_ucode_amd.c,v 1.10 2019/10/15 00:13:52 chs Exp $ */ /* * Copyright (c) 2012 The NetBSD Foundation, Inc. * All rights reserved. @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_amd.c,v 1.9 2019/01/27 02:08:39 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_amd.c,v 1.10 2019/10/15 00:13:52 chs Exp $"); #ifdef _KERNEL_OPT #include "opt_xen.h" @@ -263,16 +263,8 @@ cpu_ucode_amd_apply(struct cpu_ucode_sof return EINVAL; } - mc.mc_amd = kmem_zalloc(sizeof(*mc.mc_amd), KM_NOSLEEP); - if (mc.mc_amd == NULL) - return ENOMEM; - - mc.mc_amd->ect = kmem_alloc(mc.mc_mpbuf->mpb_len, KM_NOSLEEP); - if (mc.mc_amd->ect == NULL) { - error = ENOMEM; - goto err0; - } - + mc.mc_amd = kmem_zalloc(sizeof(*mc.mc_amd), KM_SLEEP); + mc.mc_amd->ect = kmem_alloc(mc.mc_mpbuf->mpb_len, KM_SLEEP); memcpy(mc.mc_amd->ect, mc.mc_mpbuf->mpb_data, mc.mc_mpbuf->mpb_len); mc.mc_amd->ect_size = mc.mc_mpbuf->mpb_len; @@ -307,7 +299,6 @@ cpu_ucode_amd_apply(struct cpu_ucode_sof err1: kmem_free(mc.mc_amd->ect, mc.mc_amd->ect_size); -err0: kmem_free(mc.mc_amd, sizeof(*mc.mc_amd)); return error; } Index: src/sys/dev/acpi/sdhc_acpi.c diff -u src/sys/dev/acpi/sdhc_acpi.c:1.7 src/sys/dev/acpi/sdhc_acpi.c:1.8 --- src/sys/dev/acpi/sdhc_acpi.c:1.7 Sat Nov 17 07:06:25 2018 +++ src/sys/dev/acpi/sdhc_acpi.c Tue Oct 15 00:13:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sdhc_acpi.c,v 1.7 2018/11/17 07:06:25 kre Exp $ */ +/* $NetBSD: sdhc_acpi.c,v 1.8 2019/10/15 00:13:52 chs Exp $ */ /* * Copyright (c) 2016 Kimihiro Nonaka <non...@netbsd.org> @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sdhc_acpi.c,v 1.7 2018/11/17 07:06:25 kre Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdhc_acpi.c,v 1.8 2019/10/15 00:13:52 chs Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -188,11 +188,7 @@ sdhc_acpi_attach(device_t parent, device goto unmap; } - sc->sc.sc_host = kmem_zalloc(sizeof(struct sdhc_host *), KM_NOSLEEP); - if (sc->sc.sc_host == NULL) { - aprint_error_dev(self, "couldn't alloc memory\n"); - goto intr_disestablish; - } + sc->sc.sc_host = kmem_zalloc(sizeof(struct sdhc_host *), KM_SLEEP); /* Enable DMA transfer */ sc->sc.sc_flags |= SDHC_FLAG_USE_DMA; @@ -215,7 +211,6 @@ fail: if (sc->sc.sc_host != NULL) kmem_free(sc->sc.sc_host, sizeof(struct sdhc_host *)); sc->sc.sc_host = NULL; -intr_disestablish: if (sc->sc_ih != NULL) acpi_intr_disestablish(sc->sc_ih); sc->sc_ih = NULL; Index: src/sys/dev/ata/ata.c diff -u src/sys/dev/ata/ata.c:1.150 src/sys/dev/ata/ata.c:1.151 --- src/sys/dev/ata/ata.c:1.150 Wed Aug 21 04:51:41 2019 +++ src/sys/dev/ata/ata.c Tue Oct 15 00:13:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.150 2019/08/21 04:51:41 msaitoh Exp $ */ +/* $NetBSD: ata.c,v 1.151 2019/10/15 00:13:53 chs Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.150 2019/08/21 04:51:41 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.151 2019/10/15 00:13:53 chs Exp $"); #include "opt_ata.h" @@ -750,14 +750,8 @@ atabus_alloc_drives(struct ata_channel * atabus_free_drives(chp); if (chp->ch_drive == NULL) { chp->ch_drive = kmem_zalloc( - sizeof(struct ata_drive_datas) * ndrives, KM_NOSLEEP); + sizeof(struct ata_drive_datas) * ndrives, KM_SLEEP); } - if (chp->ch_drive == NULL) { - aprint_error_dev(chp->ch_atac->atac_dev, - "can't alloc drive array\n"); - chp->ch_ndrives = 0; - return ENOMEM; - }; for (i = 0; i < ndrives; i++) { chp->ch_drive[i].chnl_softc = chp; chp->ch_drive[i].drive = i; Index: src/sys/dev/dm/dm_target_linear.c diff -u src/sys/dev/dm/dm_target_linear.c:1.17 src/sys/dev/dm/dm_target_linear.c:1.18 --- src/sys/dev/dm/dm_target_linear.c:1.17 Fri Jan 5 14:22:05 2018 +++ src/sys/dev/dm/dm_target_linear.c Tue Oct 15 00:13:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_target_linear.c,v 1.17 2018/01/05 14:22:05 christos Exp $ */ +/* $NetBSD: dm_target_linear.c,v 1.18 2019/10/15 00:13:53 chs Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.17 2018/01/05 14:22:05 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.18 2019/10/15 00:13:53 chs Exp $"); /* * This file implements initial version of device-mapper dklinear target. @@ -111,9 +111,7 @@ dm_target_linear_status(void *target_con aprint_debug("Linear target status function called\n"); - if ((params = kmem_alloc(DM_MAX_PARAMS_SIZE, KM_NOSLEEP)) == NULL) - return NULL; - + params = kmem_alloc(DM_MAX_PARAMS_SIZE, KM_SLEEP); aprint_normal("%s %" PRIu64, tlc->pdev->name, tlc->offset); snprintf(params, DM_MAX_PARAMS_SIZE, "%s %" PRIu64, tlc->pdev->name, tlc->offset); Index: src/sys/dev/dm/dm_target_snapshot.c diff -u src/sys/dev/dm/dm_target_snapshot.c:1.19 src/sys/dev/dm/dm_target_snapshot.c:1.20 --- src/sys/dev/dm/dm_target_snapshot.c:1.19 Fri Jan 5 14:22:05 2018 +++ src/sys/dev/dm/dm_target_snapshot.c Tue Oct 15 00:13:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_target_snapshot.c,v 1.19 2018/01/05 14:22:05 christos Exp $ */ +/* $NetBSD: dm_target_snapshot.c,v 1.20 2019/10/15 00:13:53 chs Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.19 2018/01/05 14:22:05 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_snapshot.c,v 1.20 2019/10/15 00:13:53 chs Exp $"); /* * 1. Suspend my_data to temporarily stop any I/O while the snapshot is being @@ -223,9 +223,7 @@ dm_target_snapshot_init(dm_dev_t * dmv, if ((dmp_snap = dm_pdev_insert(argv[0])) == NULL) return ENOENT; - if ((tsc = kmem_alloc(sizeof(*tsc), KM_NOSLEEP)) == NULL) - return 1; - + tsc = kmem_alloc(sizeof(*tsc), KM_SLEEP); tsc->tsc_persistent_dev = 0; /* There is now cow device for nonpersistent snapshot devices */ @@ -285,8 +283,7 @@ dm_target_snapshot_status(void *target_c /* length of names + count of chars + spaces and null char */ prm_len = strlen(tsc->tsc_snap_dev->name) + cow_len + count + 5; - if ((params = kmem_alloc(prm_len, KM_NOSLEEP)) == NULL) - return NULL; + params = kmem_alloc(prm_len, KM_SLEEP); printf("%s %s %s %" PRIu64 "\n", tsc->tsc_snap_dev->name, tsc->tsc_cow_dev->name, tsc->tsc_persistent_dev ? "p" : "n", @@ -411,10 +408,7 @@ dm_target_snapshot_orig_init(dm_dev_t * if ((dmp_real = dm_pdev_insert(params)) == NULL) return ENOENT; - if ((tsoc = kmem_alloc(sizeof(dm_target_snapshot_origin_config_t), KM_NOSLEEP)) - == NULL) - return 1; - + tsoc = kmem_alloc(sizeof(dm_target_snapshot_origin_config_t), KM_SLEEP); tsoc->tsoc_real_dev = dmp_real; dmv->dev_type = DM_SNAPSHOT_ORIG_DEV; @@ -448,8 +442,7 @@ dm_target_snapshot_orig_status(void *tar printf("real_dev name %s\n", tsoc->tsoc_real_dev->name); - if ((params = kmem_alloc(prm_len, KM_NOSLEEP)) == NULL) - return NULL; + params = kmem_alloc(prm_len, KM_SLEEP); printf("%s\n", tsoc->tsoc_real_dev->name); Index: src/sys/dev/dm/dm_target_stripe.c diff -u src/sys/dev/dm/dm_target_stripe.c:1.23 src/sys/dev/dm/dm_target_stripe.c:1.24 --- src/sys/dev/dm/dm_target_stripe.c:1.23 Fri Jan 5 14:22:26 2018 +++ src/sys/dev/dm/dm_target_stripe.c Tue Oct 15 00:13:53 2019 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_stripe.c,v 1.23 2018/01/05 14:22:26 christos Exp $*/ +/*$NetBSD: dm_target_stripe.c,v 1.24 2019/10/15 00:13:53 chs Exp $*/ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.23 2018/01/05 14:22:26 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.24 2019/10/15 00:13:53 chs Exp $"); /* * This file implements initial version of device-mapper stripe target. @@ -158,8 +158,7 @@ dm_target_stripe_init(dm_dev_t * dmv, vo printf("Stripe target chunk size %s number of stripes %s\n", argv[1], argv[0]); - if ((tsc = kmem_alloc(sizeof(*tsc), KM_NOSLEEP)) == NULL) - return ENOMEM; + tsc = kmem_alloc(sizeof(*tsc), KM_SLEEP); /* Initialize linked list for striping devices */ TAILQ_INIT(&tsc->stripe_devs); @@ -174,7 +173,7 @@ dm_target_stripe_init(dm_dev_t * dmv, vo printf("Stripe target device name %s -- offset %s\n", argv[strpi], argv[strpi+1]); - tlc = kmem_alloc(sizeof(*tlc), KM_NOSLEEP); + tlc = kmem_alloc(sizeof(*tlc), KM_SLEEP); if ((tlc->pdev = dm_pdev_insert(argv[strpi])) == NULL) { kmem_free(tlc, sizeof(*tlc)); dm_target_stripe_fini(tsc); Index: src/sys/dev/gpio/gpio.c diff -u src/sys/dev/gpio/gpio.c:1.62 src/sys/dev/gpio/gpio.c:1.63 --- src/sys/dev/gpio/gpio.c:1.62 Sun Jan 27 02:08:41 2019 +++ src/sys/dev/gpio/gpio.c Tue Oct 15 00:13:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: gpio.c,v 1.62 2019/01/27 02:08:41 pgoyette Exp $ */ +/* $NetBSD: gpio.c,v 1.63 2019/10/15 00:13:53 chs Exp $ */ /* $OpenBSD: gpio.c,v 1.6 2006/01/14 12:33:49 grange Exp $ */ /* @@ -19,7 +19,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.62 2019/01/27 02:08:41 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.63 2019/10/15 00:13:53 chs Exp $"); /* * General Purpose Input/Output framework. @@ -273,9 +273,7 @@ gpio_search(device_t parent, cfdata_t cf ga.ga_mask = cf->cf_loc[GPIOCF_MASK]; ga.ga_flags = cf->cf_loc[GPIOCF_FLAG]; namlen = strlen(cf->cf_name) + 1; - ga.ga_dvname = kmem_alloc(namlen, KM_NOSLEEP); - if (ga.ga_dvname == NULL) - return 0; + ga.ga_dvname = kmem_alloc(namlen, KM_SLEEP); strcpy(ga.ga_dvname, cf->cf_name); if (config_match(parent, cf, &ga) > 0) Index: src/sys/dev/marvell/if_mvxpe.c diff -u src/sys/dev/marvell/if_mvxpe.c:1.29 src/sys/dev/marvell/if_mvxpe.c:1.30 --- src/sys/dev/marvell/if_mvxpe.c:1.29 Tue Oct 1 17:35:09 2019 +++ src/sys/dev/marvell/if_mvxpe.c Tue Oct 15 00:13:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: if_mvxpe.c,v 1.29 2019/10/01 17:35:09 chs Exp $ */ +/* $NetBSD: if_mvxpe.c,v 1.30 2019/10/15 00:13:53 chs Exp $ */ /* * Copyright (c) 2015 Internet Initiative Japan Inc. * All rights reserved. @@ -25,7 +25,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_mvxpe.c,v 1.29 2019/10/01 17:35:09 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_mvxpe.c,v 1.30 2019/10/15 00:13:53 chs Exp $"); #include "opt_multiprocessor.h" @@ -401,9 +401,7 @@ mvxpe_attach(device_t parent, device_t s */ sc->sc_sysctl_mib_size = __arraycount(mvxpe_mib_list) * sizeof(struct mvxpe_sysctl_mib); - sc->sc_sysctl_mib = kmem_alloc(sc->sc_sysctl_mib_size, KM_NOSLEEP); - if (sc->sc_sysctl_mib == NULL) - goto fail; + sc->sc_sysctl_mib = kmem_alloc(sc->sc_sysctl_mib_size, KM_SLEEP); memset(sc->sc_sysctl_mib, 0, sc->sc_sysctl_mib_size); /* Index: src/sys/dev/marvell/mvxpsec.c diff -u src/sys/dev/marvell/mvxpsec.c:1.2 src/sys/dev/marvell/mvxpsec.c:1.3 --- src/sys/dev/marvell/mvxpsec.c:1.2 Thu Nov 9 22:22:58 2017 +++ src/sys/dev/marvell/mvxpsec.c Tue Oct 15 00:13:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: mvxpsec.c,v 1.2 2017/11/09 22:22:58 christos Exp $ */ +/* $NetBSD: mvxpsec.c,v 1.3 2019/10/15 00:13:53 chs Exp $ */ /* * Copyright (c) 2015 Internet Initiative Japan Inc. * All rights reserved. @@ -647,12 +647,7 @@ mvxpsec_alloc_devmem(struct mvxpsec_soft if (sc == NULL) return NULL; - devmem = kmem_alloc(sizeof(*devmem), KM_NOSLEEP); - if (devmem == NULL) { - aprint_error_dev(sc->sc_dev, "can't alloc kmem\n"); - return NULL; - } - + devmem = kmem_alloc(sizeof(*devmem), KM_SLEEP); devmem->size = size; if (phys) { @@ -1102,15 +1097,11 @@ mvxpsec_init_dma(struct mvxpsec_softc *s /* Init Software DMA Handlers */ sc->sc_devmem_desc = mvxpsec_alloc_devmem(sc, 0, PAGE_SIZE * MVXPSEC_DMA_DESC_PAGES); - if (sc->sc_devmem_desc == NULL) - panic("Cannot allocate memory\n"); ndh = (PAGE_SIZE / sizeof(struct mvxpsec_descriptor)) * MVXPSEC_DMA_DESC_PAGES; sc->sc_desc_ring = kmem_alloc(sizeof(struct mvxpsec_descriptor_handle) * ndh, - KM_NOSLEEP); - if (sc->sc_desc_ring == NULL) - panic("Cannot allocate memory\n"); + KM_SLEEP); aprint_normal_dev(sc->sc_dev, "%d DMA handles in %zu bytes array\n", ndh, sizeof(struct mvxpsec_descriptor_handle) * ndh); @@ -3687,4 +3678,3 @@ mvxpsec_dump_acc_maciv(const char *name, return; } #endif -