Module Name: src
Committed By: skrll
Date: Thu Sep 29 06:42:14 UTC 2022
Modified Files:
src/sys/arch/hppa/dev: astro.c uturn.c
Log Message:
malloc -> kmem
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/hppa/dev/astro.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/hppa/dev/uturn.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/hppa/dev/astro.c
diff -u src/sys/arch/hppa/dev/astro.c:1.4 src/sys/arch/hppa/dev/astro.c:1.5
--- src/sys/arch/hppa/dev/astro.c:1.4 Sat Aug 7 16:18:55 2021
+++ src/sys/arch/hppa/dev/astro.c Thu Sep 29 06:42:14 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: astro.c,v 1.4 2021/08/07 16:18:55 thorpej Exp $ */
+/* $NetBSD: astro.c,v 1.5 2022/09/29 06:42:14 skrll Exp $ */
/* $OpenBSD: astro.c,v 1.8 2007/10/06 23:50:54 krw Exp $ */
@@ -19,10 +19,11 @@
*/
#include <sys/param.h>
+
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/extent.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/reboot.h>
#include <sys/tree.h>
@@ -185,7 +186,7 @@ paddr_t iommu_dvmamem_mmap(void *, bus_d
void iommu_enter(struct astro_softc *, bus_addr_t, paddr_t, vaddr_t, int);
void iommu_remove(struct astro_softc *, bus_addr_t);
-struct iommu_map_state *iommu_iomap_create(int);
+struct iommu_map_state *iommu_iomap_create(int, int);
void iommu_iomap_destroy(struct iommu_map_state *);
int iommu_iomap_insert_page(struct iommu_map_state *, vaddr_t, paddr_t);
bus_addr_t iommu_iomap_translate(struct iommu_map_state *, paddr_t);
@@ -362,7 +363,7 @@ iommu_dvmamap_create(void *v, bus_size_t
if (error)
return (error);
- ims = iommu_iomap_create(atop(round_page(size)));
+ ims = iommu_iomap_create(atop(round_page(size)), flags);
if (ims == NULL) {
bus_dmamap_destroy(sc->sc_dmat, map);
return (ENOMEM);
@@ -604,7 +605,7 @@ SPLAY_GENERATE(iommu_page_tree, iommu_pa
* Create a new iomap.
*/
struct iommu_map_state *
-iommu_iomap_create(int n)
+iommu_iomap_create(int n, int flags)
{
struct iommu_map_state *ims;
@@ -613,8 +614,10 @@ iommu_iomap_create(int n)
if (n < 16)
n = 16;
- ims = malloc(sizeof(*ims) + (n - 1) * sizeof(ims->ims_map.ipm_map[0]),
- M_DEVBUF, M_NOWAIT | M_ZERO);
+ const size_t sz =
+ sizeof(*ims) + (n - 1) * sizeof(ims->ims_map.ipm_map[0]);
+
+ ims = kmem_zalloc(sz, (flags & BUS_DMA_NOWAIT) ? KM_NOSLEEP : KM_SLEEP);
if (ims == NULL)
return (NULL);
@@ -636,8 +639,11 @@ iommu_iomap_destroy(struct iommu_map_sta
printf("iommu_iomap_destroy: %d page entries in use\n",
ims->ims_map.ipm_pagecnt);
#endif
+ const int n = ims->ims_map.ipm_maxpage;
+ const size_t sz =
+ sizeof(*ims) + (n - 1) * sizeof(ims->ims_map.ipm_map[0]);
- free(ims, M_DEVBUF);
+ kmem_free(ims, sz);
}
/*
Index: src/sys/arch/hppa/dev/uturn.c
diff -u src/sys/arch/hppa/dev/uturn.c:1.5 src/sys/arch/hppa/dev/uturn.c:1.6
--- src/sys/arch/hppa/dev/uturn.c:1.5 Sat Aug 7 16:18:55 2021
+++ src/sys/arch/hppa/dev/uturn.c Thu Sep 29 06:42:14 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: uturn.c,v 1.5 2021/08/07 16:18:55 thorpej Exp $ */
+/* $NetBSD: uturn.c,v 1.6 2022/09/29 06:42:14 skrll Exp $ */
/* $OpenBSD: uturn.c,v 1.6 2007/12/29 01:26:14 kettenis Exp $ */
@@ -82,12 +82,13 @@
*/
#include <sys/param.h>
+
#include <sys/systm.h>
#include <sys/device.h>
-#include <sys/reboot.h>
-#include <sys/malloc.h>
#include <sys/extent.h>
+#include <sys/kmem.h>
#include <sys/mbuf.h>
+#include <sys/reboot.h>
#include <sys/tree.h>
#include <uvm/uvm.h>
@@ -240,7 +241,7 @@ static void uturn_iommu_enter(struct utu
vaddr_t, paddr_t);
static void uturn_iommu_remove(struct uturn_softc *, bus_addr_t, bus_size_t);
-struct uturn_map_state *uturn_iomap_create(int);
+struct uturn_map_state *uturn_iomap_create(int, int);
void uturn_iomap_destroy(struct uturn_map_state *);
int uturn_iomap_insert_page(struct uturn_map_state *, vaddr_t, paddr_t);
bus_addr_t uturn_iomap_translate(struct uturn_map_state *, paddr_t);
@@ -500,7 +501,7 @@ uturn_dmamap_create(void *v, bus_size_t
if (error)
return (error);
- ums = uturn_iomap_create(atop(round_page(size)));
+ ums = uturn_iomap_create(atop(round_page(size)), flags);
if (ums == NULL) {
bus_dmamap_destroy(sc->sc_dmat, map);
return (ENOMEM);
@@ -743,7 +744,7 @@ SPLAY_GENERATE(uturn_page_tree, uturn_pa
* Create a new iomap.
*/
struct uturn_map_state *
-uturn_iomap_create(int n)
+uturn_iomap_create(int n, int flags)
{
struct uturn_map_state *ums;
@@ -751,9 +752,9 @@ uturn_iomap_create(int n)
n += 4;
if (n < 16)
n = 16;
-
- ums = malloc(sizeof(*ums) + (n - 1) * sizeof(ums->ums_map.upm_map[0]),
- M_DEVBUF, M_NOWAIT | M_ZERO);
+ const size_t sz =
+ sizeof(*ums) + (n - 1) * sizeof(ums->ums_map.upm_map[0]);
+ ums = kmem_zalloc(sz, (flags & BUS_DMA_NOWAIT) ? KM_NOSLEEP : KM_SLEEP);
if (ums == NULL)
return (NULL);
@@ -771,8 +772,11 @@ void
uturn_iomap_destroy(struct uturn_map_state *ums)
{
KASSERT(ums->ums_map.upm_pagecnt == 0);
+ const int n = ums->ums_map.upm_maxpage;
+ const size_t sz =
+ sizeof(*ums) + (n - 1) * sizeof(ums->ums_map.upm_map[0]);
- free(ums, M_DEVBUF);
+ kmem_free(ums, sz);
}
/*