Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/jdolecek-ncqfixes]: src/sys/dev/ata convert from malloc()/free() to kmem...
details: https://anonhg.NetBSD.org/src/rev/a7eebea6d01d
branches: jdolecek-ncqfixes
changeset: 850578:a7eebea6d01d
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Mon Sep 17 20:54:41 2018 +0000
description:
convert from malloc()/free() to kmem_zalloc()/kmem_free()
diffstat:
sys/dev/ata/TODO.ncq | 3 ++-
sys/dev/ata/ata.c | 21 ++++++++++-----------
sys/dev/ata/ata_raid.c | 7 +++----
sys/dev/ata/ata_raid_adaptec.c | 9 ++++-----
sys/dev/ata/ata_raid_intel.c | 10 +++++-----
sys/dev/ata/ata_raid_jmicron.c | 9 ++++-----
sys/dev/ata/ata_raid_nvidia.c | 11 +++++------
sys/dev/ata/ata_raid_promise.c | 9 ++++-----
sys/dev/ata/ata_raid_via.c | 9 ++++-----
sys/dev/ata/ata_subr.c | 5 +++--
sys/dev/ata/ata_wdc.c | 5 ++---
sys/dev/ata/ld_ataraid.c | 5 ++---
sys/dev/ata/wd.c | 28 ++++++++++++++++------------
13 files changed, 64 insertions(+), 67 deletions(-)
diffs (truncated from 601 to 300 lines):
diff -r 5dc19ed7fdc1 -r a7eebea6d01d sys/dev/ata/TODO.ncq
--- a/sys/dev/ata/TODO.ncq Mon Sep 17 19:30:25 2018 +0000
+++ b/sys/dev/ata/TODO.ncq Mon Sep 17 20:54:41 2018 +0000
@@ -1,6 +1,7 @@
jdolecek-ncqfixes goals:
- make ata_xfer dynamically allocated using a pool
- - fixes: queue is allocated regardless if there are any drives, fix?
+ - will fix: queue is allocated regardless if there are any drives, fix?
+ - malloc() -> kmem_zalloc() in ata_queue_alloc() once this is done
- remove limit of queued ata_xfers, allow any number of pending xfers;
this should fix kern/52614 AKA wdc-attached ATAPI cd(4)
- remove the wd(4) flush condition, just allocate a dynamic ata_xfer
diff -r 5dc19ed7fdc1 -r a7eebea6d01d sys/dev/ata/ata.c
--- a/sys/dev/ata/ata.c Mon Sep 17 19:30:25 2018 +0000
+++ b/sys/dev/ata/ata.c Mon Sep 17 20:54:41 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata.c,v 1.141.6.4 2018/09/17 19:00:43 jdolecek Exp $ */
+/* $NetBSD: ata.c,v 1.141.6.5 2018/09/17 20:54:41 jdolecek Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved.
@@ -25,14 +25,13 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.4 2018/09/17 19:00:43 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.5 2018/09/17 20:54:41 jdolecek Exp $");
#include "opt_ata.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
-#include <sys/malloc.h>
#include <sys/device.h>
#include <sys/conf.h>
#include <sys/fcntl.h>
@@ -292,7 +291,7 @@
cv_broadcast(&atabus_qcv);
mutex_exit(&atabus_qlock);
- free(atabus_initq, M_DEVBUF);
+ kmem_free(atabus_initq, sizeof(*atabus_initq));
ata_delref(chp);
@@ -418,7 +417,7 @@
cv_broadcast(&atabus_qcv);
mutex_exit(&atabus_qlock);
- free(atabus_initq, M_DEVBUF);
+ kmem_free(atabus_initq, sizeof(*atabus_initq));
ata_delref(chp);
@@ -569,7 +568,7 @@
RUN_ONCE(&ata_init_ctrl, atabus_init);
- initq = malloc(sizeof(*initq), M_DEVBUF, M_WAITOK);
+ initq = kmem_zalloc(sizeof(*initq), KM_SLEEP);
initq->atabus_sc = sc;
mutex_enter(&atabus_qlock);
TAILQ_INSERT_TAIL(&atabus_initq_head, initq, atabus_initq);
@@ -716,9 +715,8 @@
if (chp->ch_ndrives != ndrives)
atabus_free_drives(chp);
if (chp->ch_drive == NULL) {
- chp->ch_drive = malloc(
- sizeof(struct ata_drive_datas) * ndrives,
- M_DEVBUF, M_NOWAIT | M_ZERO);
+ chp->ch_drive = kmem_zalloc(
+ sizeof(struct ata_drive_datas) * ndrives, KM_NOSLEEP);
}
if (chp->ch_drive == NULL) {
aprint_error_dev(chp->ch_atac->atac_dev,
@@ -761,8 +759,9 @@
if (chp->ch_drive == NULL)
return;
+ kmem_free(chp->ch_drive,
+ sizeof(struct ata_drive_datas) * chp->ch_ndrives);
chp->ch_ndrives = 0;
- free(chp->ch_drive, M_DEVBUF);
chp->ch_drive = NULL;
}
@@ -2218,7 +2217,7 @@
}
}
- initq = malloc(sizeof(*initq), M_DEVBUF, M_WAITOK);
+ initq = kmem_zalloc(sizeof(*initq), KM_SLEEP);
initq->atabus_sc = sc;
mutex_enter(&atabus_qlock);
TAILQ_INSERT_TAIL(&atabus_initq_head, initq, atabus_initq);
diff -r 5dc19ed7fdc1 -r a7eebea6d01d sys/dev/ata/ata_raid.c
--- a/sys/dev/ata/ata_raid.c Mon Sep 17 19:30:25 2018 +0000
+++ b/sys/dev/ata/ata_raid.c Mon Sep 17 20:54:41 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid.c,v 1.40 2018/06/22 09:06:04 pgoyette Exp $ */
+/* $NetBSD: ata_raid.c,v 1.40.4.1 2018/09/17 20:54:41 jdolecek Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.40 2018/06/22 09:06:04 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.40.4.1 2018/09/17 20:54:41 jdolecek Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -50,7 +50,6 @@
#include <sys/disk.h>
#include <sys/disklabel.h>
#include <sys/fcntl.h>
-#include <sys/malloc.h>
#include <sys/vnode.h>
#include <sys/proc.h>
#include <sys/module.h>
@@ -274,7 +273,7 @@
}
/* Need to allocate a new one. */
- aai = malloc(sizeof(*aai), M_DEVBUF, M_WAITOK | M_ZERO);
+ aai = kmem_zalloc(sizeof(*aai), KM_SLEEP);
aai->aai_type = type;
aai->aai_arrayno = arrayno;
aai->aai_curdisk = 0;
diff -r 5dc19ed7fdc1 -r a7eebea6d01d sys/dev/ata/ata_raid_adaptec.c
--- a/sys/dev/ata/ata_raid_adaptec.c Mon Sep 17 19:30:25 2018 +0000
+++ b/sys/dev/ata/ata_raid_adaptec.c Mon Sep 17 20:54:41 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid_adaptec.c,v 1.10 2017/11/01 19:34:46 mlelstv Exp $ */
+/* $NetBSD: ata_raid_adaptec.c,v 1.10.6.1 2018/09/17 20:54:41 jdolecek Exp $ */
/*-
* Copyright (c) 2000,2001,2002 Søren Schmidt <sos%FreeBSD.org@localhost>
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_adaptec.c,v 1.10 2017/11/01 19:34:46 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_adaptec.c,v 1.10.6.1 2018/09/17 20:54:41 jdolecek Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -45,7 +45,6 @@
#include <sys/disk.h>
#include <sys/disklabel.h>
#include <sys/fcntl.h>
-#include <sys/malloc.h>
#include <sys/vnode.h>
#include <sys/kauth.h>
@@ -77,7 +76,7 @@
struct ataraid_array_info *aai;
struct ataraid_disk_info *adi;
- info = malloc(sizeof(*info), M_DEVBUF, M_WAITOK);
+ info = kmem_zalloc(sizeof(*info), KM_SLEEP);
bmajor = devsw_name2blk(dksc->sc_xname, NULL, 0);
@@ -189,6 +188,6 @@
error = 0;
out:
- free(info, M_DEVBUF);
+ kmem_free(info, sizeof(*info));
return (error);
}
diff -r 5dc19ed7fdc1 -r a7eebea6d01d sys/dev/ata/ata_raid_intel.c
--- a/sys/dev/ata/ata_raid_intel.c Mon Sep 17 19:30:25 2018 +0000
+++ b/sys/dev/ata/ata_raid_intel.c Mon Sep 17 20:54:41 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid_intel.c,v 1.8 2017/11/01 19:34:46 mlelstv Exp $ */
+/* $NetBSD: ata_raid_intel.c,v 1.8.6.1 2018/09/17 20:54:41 jdolecek Exp $ */
/*-
* Copyright (c) 2000-2008 Søren Schmidt <sos%FreeBSD.org@localhost>
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_intel.c,v 1.8 2017/11/01 19:34:46 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_intel.c,v 1.8.6.1 2018/09/17 20:54:41 jdolecek Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -43,7 +43,6 @@
#include <sys/disk.h>
#include <sys/disklabel.h>
#include <sys/fcntl.h>
-#include <sys/malloc.h>
#include <sys/vnode.h>
#include <sys/kauth.h>
@@ -138,6 +137,7 @@
{
struct dk_softc *dksc = &sc->sc_dksc;
struct intel_raid_conf *info;
+ const size_t infosz = 1536;
struct intel_raid_mapping *map;
struct ataraid_array_info *aai;
struct ataraid_disk_info *adi;
@@ -148,7 +148,7 @@
dev_t dev;
int volumeid, diskidx;
- info = malloc(1536, M_DEVBUF, M_WAITOK|M_ZERO);
+ info = kmem_zalloc(infosz, KM_SLEEP);
bmajor = devsw_name2blk(dksc->sc_xname, NULL, 0);
@@ -298,7 +298,7 @@
}
out:
- free(info, M_DEVBUF);
+ kmem_free(info, infosz);
return error;
}
diff -r 5dc19ed7fdc1 -r a7eebea6d01d sys/dev/ata/ata_raid_jmicron.c
--- a/sys/dev/ata/ata_raid_jmicron.c Mon Sep 17 19:30:25 2018 +0000
+++ b/sys/dev/ata/ata_raid_jmicron.c Mon Sep 17 20:54:41 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid_jmicron.c,v 1.6 2017/11/01 19:34:46 mlelstv Exp $ */
+/* $NetBSD: ata_raid_jmicron.c,v 1.6.6.1 2018/09/17 20:54:41 jdolecek Exp $ */
/*-
* Copyright (c) 2000-2008 Søren Schmidt <sos%FreeBSD.org@localhost>
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_jmicron.c,v 1.6 2017/11/01 19:34:46 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_jmicron.c,v 1.6.6.1 2018/09/17 20:54:41 jdolecek Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -45,7 +45,6 @@
#include <sys/disk.h>
#include <sys/disklabel.h>
#include <sys/fcntl.h>
-#include <sys/malloc.h>
#include <sys/vnode.h>
#include <sys/kauth.h>
@@ -130,7 +129,7 @@
int bmajor, error, count, disk, total_disks;
dev_t dev;
- info = malloc(sizeof(*info), M_DEVBUF, M_WAITOK|M_ZERO);
+ info = kmem_zalloc(sizeof(*info), KM_SLEEP);
bmajor = devsw_name2blk(dksc->sc_xname, NULL, 0);
@@ -265,6 +264,6 @@
error = 0;
out:
- free(info, M_DEVBUF);
+ kmem_free(info, sizeof(*info));
return error;
}
diff -r 5dc19ed7fdc1 -r a7eebea6d01d sys/dev/ata/ata_raid_nvidia.c
--- a/sys/dev/ata/ata_raid_nvidia.c Mon Sep 17 19:30:25 2018 +0000
+++ b/sys/dev/ata/ata_raid_nvidia.c Mon Sep 17 20:54:41 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid_nvidia.c,v 1.3 2017/11/01 19:34:46 mlelstv Exp $ */
+/* $NetBSD: ata_raid_nvidia.c,v 1.3.6.1 2018/09/17 20:54:41 jdolecek Exp $ */
/*-
* Copyright (c) 2000 - 2008 Søren Schmidt <sos%FreeBSD.org@localhost>
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_nvidia.c,v 1.3 2017/11/01 19:34:46 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_nvidia.c,v 1.3.6.1 2018/09/17 20:54:41 jdolecek Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -43,7 +43,6 @@
#include <sys/disk.h>
#include <sys/disklabel.h>
#include <sys/fcntl.h>
-#include <sys/malloc.h>
#include <sys/vnode.h>
#include <sys/kauth.h>
@@ -136,7 +135,7 @@
struct _arrayno *next;
} arrayno = { 0, 0, NULL}, *anptr;
- info = malloc(sizeof(*info), M_DEVBUF, M_WAITOK);
Home |
Main Index |
Thread Index |
Old Index