diff options
author | scottl <scottl@FreeBSD.org> | 2007-05-14 21:48:53 +0000 |
---|---|---|
committer | scottl <scottl@FreeBSD.org> | 2007-05-14 21:48:53 +0000 |
commit | df8de31591e57ce88e7c35716ba233b00c120316 (patch) | |
tree | 18031a3dbfa4e78431255febc9dd084cbe13f288 /sys/cam | |
parent | ba2a70ab9b68b48d14ba24cbe6c5f447a2e94e2a (diff) | |
download | FreeBSD-src-df8de31591e57ce88e7c35716ba233b00c120316.zip FreeBSD-src-df8de31591e57ce88e7c35716ba233b00c120316.tar.gz |
Eliminate the use of M_TEMP.
Diffstat (limited to 'sys/cam')
-rw-r--r-- | sys/cam/cam_periph.c | 5 | ||||
-rw-r--r-- | sys/cam/cam_xpt.c | 48 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_cd.c | 134 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_ch.c | 14 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_da.c | 14 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_sa.c | 22 |
6 files changed, 122 insertions, 115 deletions
diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c index 704fa06..5fa7473 100644 --- a/sys/cam/cam_periph.c +++ b/sys/cam/cam_periph.c @@ -102,7 +102,8 @@ periphdriver_register(void *data) int ndrivers; ndrivers = nperiph_drivers + 2; - newdrivers = malloc(sizeof(*newdrivers) * ndrivers, M_TEMP, M_WAITOK); + newdrivers = malloc(sizeof(*newdrivers) * ndrivers, M_CAMPERIPH, + M_WAITOK); if (periph_drivers) bcopy(periph_drivers, newdrivers, sizeof(*newdrivers) * nperiph_drivers); @@ -111,7 +112,7 @@ periphdriver_register(void *data) old = periph_drivers; periph_drivers = newdrivers; if (old) - free(old, M_TEMP); + free(old, M_CAMPERIPH); nperiph_drivers++; } diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index f3d3ab2..882ce61 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -1533,7 +1533,7 @@ xpt_init(void *dummy) */ xsoftc.xpt_config_hook = (struct intr_config_hook *)malloc(sizeof(struct intr_config_hook), - M_TEMP, M_NOWAIT | M_ZERO); + M_CAMXPT, M_NOWAIT | M_ZERO); if (xsoftc.xpt_config_hook == NULL) { printf("xpt_init: Cannot malloc config hook " "- failing attach\n"); @@ -1542,7 +1542,7 @@ xpt_init(void *dummy) xsoftc.xpt_config_hook->ich_func = xpt_config; if (config_intrhook_establish(xsoftc.xpt_config_hook) != 0) { - free (xsoftc.xpt_config_hook, M_TEMP); + free (xsoftc.xpt_config_hook, M_CAMXPT); printf("xpt_init: config_intrhook_establish failed " "- failing attach\n"); } @@ -5243,7 +5243,7 @@ xpt_scan_bus(struct cam_periph *periph, union ccb *request_ccb) /* Save some state for use while we probe for devices */ scan_info = (xpt_scan_bus_info *) - malloc(sizeof(xpt_scan_bus_info), M_TEMP, M_NOWAIT); + malloc(sizeof(xpt_scan_bus_info), M_CAMXPT, M_NOWAIT); scan_info->request_ccb = request_ccb; scan_info->cpi = &work_ccb->cpi; @@ -5277,7 +5277,7 @@ xpt_scan_bus(struct cam_periph *periph, union ccb *request_ccb) printf("xpt_scan_bus: xpt_create_path failed" " with status %#x, bus scan halted\n", status); - free(scan_info, M_TEMP); + free(scan_info, M_CAMXPT); request_ccb->ccb_h.status = status; xpt_free_ccb(work_ccb); xpt_done(request_ccb); @@ -5285,7 +5285,7 @@ xpt_scan_bus(struct cam_periph *periph, union ccb *request_ccb) } work_ccb = xpt_alloc_ccb_nowait(); if (work_ccb == NULL) { - free(scan_info, M_TEMP); + free(scan_info, M_CAMXPT); xpt_free_path(path); request_ccb->ccb_h.status = CAM_RESRC_UNAVAIL; xpt_done(request_ccb); @@ -5398,7 +5398,7 @@ xpt_scan_bus(struct cam_periph *periph, union ccb *request_ccb) xpt_free_ccb(request_ccb); xpt_free_ccb((union ccb *)scan_info->cpi); request_ccb = scan_info->request_ccb; - free(scan_info, M_TEMP); + free(scan_info, M_CAMXPT); request_ccb->ccb_h.status = CAM_REQ_CMP; xpt_done(request_ccb); break; @@ -5417,7 +5417,7 @@ xpt_scan_bus(struct cam_periph *periph, union ccb *request_ccb) xpt_free_ccb(request_ccb); xpt_free_ccb((union ccb *)scan_info->cpi); request_ccb = scan_info->request_ccb; - free(scan_info, M_TEMP); + free(scan_info, M_CAMXPT); request_ccb->ccb_h.status = status; xpt_done(request_ccb); break; @@ -5518,17 +5518,17 @@ xpt_scan_lun(struct cam_periph *periph, struct cam_path *path, } if (request_ccb == NULL) { - request_ccb = malloc(sizeof(union ccb), M_TEMP, M_NOWAIT); + request_ccb = malloc(sizeof(union ccb), M_CAMXPT, M_NOWAIT); if (request_ccb == NULL) { xpt_print(path, "xpt_scan_lun: can't allocate CCB, " "can't continue\n"); return; } - new_path = malloc(sizeof(*new_path), M_TEMP, M_NOWAIT); + new_path = malloc(sizeof(*new_path), M_CAMXPT, M_NOWAIT); if (new_path == NULL) { xpt_print(path, "xpt_scan_lun: can't allocate path, " "can't continue\n"); - free(request_ccb, M_TEMP); + free(request_ccb, M_CAMXPT); return; } status = xpt_compile_path(new_path, xpt_periph, @@ -5539,8 +5539,8 @@ xpt_scan_lun(struct cam_periph *periph, struct cam_path *path, if (status != CAM_REQ_CMP) { xpt_print(path, "xpt_scan_lun: can't compile path, " "can't continue\n"); - free(request_ccb, M_TEMP); - free(new_path, M_TEMP); + free(request_ccb, M_CAMXPT); + free(new_path, M_CAMXPT); return; } xpt_setup_ccb(&request_ccb->ccb_h, new_path, /*priority*/ 1); @@ -5575,8 +5575,8 @@ static void xptscandone(struct cam_periph *periph, union ccb *done_ccb) { xpt_release_path(done_ccb->ccb_h.path); - free(done_ccb->ccb_h.path, M_TEMP); - free(done_ccb, M_TEMP); + free(done_ccb->ccb_h.path, M_CAMXPT); + free(done_ccb, M_CAMXPT); } static cam_status @@ -5598,7 +5598,7 @@ proberegister(struct cam_periph *periph, void *arg) return(CAM_REQ_CMP_ERR); } - softc = (probe_softc *)malloc(sizeof(*softc), M_TEMP, M_NOWAIT); + softc = (probe_softc *)malloc(sizeof(*softc), M_CAMXPT, M_NOWAIT); if (softc == NULL) { printf("proberegister: Unable to probe new device. " @@ -5751,7 +5751,7 @@ probestart(struct cam_periph *periph, union ccb *start_ccb) if (softc->action == PROBE_INQUIRY_BASIC_DV1 || softc->action == PROBE_INQUIRY_BASIC_DV2) { - inq_buf = malloc(inquiry_len, M_TEMP, M_NOWAIT); + inq_buf = malloc(inquiry_len, M_CAMXPT, M_NOWAIT); } if (inq_buf == NULL) { xpt_print(periph->path, "malloc failure- skipping Basic" @@ -5785,7 +5785,7 @@ probestart(struct cam_periph *periph, union ccb *start_ccb) mode_buf_len = sizeof(struct scsi_mode_header_6) + sizeof(struct scsi_mode_blk_desc) + sizeof(struct scsi_control_page); - mode_buf = malloc(mode_buf_len, M_TEMP, M_NOWAIT); + mode_buf = malloc(mode_buf_len, M_CAMXPT, M_NOWAIT); if (mode_buf != NULL) { scsi_mode_sense(csio, /*retries*/4, @@ -5817,7 +5817,7 @@ probestart(struct cam_periph *periph, union ccb *start_ccb) if ((device->quirk->quirks & CAM_QUIRK_NOSERIAL) == 0) serial_buf = (struct scsi_vpd_unit_serial_number *) - malloc(sizeof(*serial_buf), M_TEMP, + malloc(sizeof(*serial_buf), M_CAMXPT, M_NOWAIT | M_ZERO); if (serial_buf != NULL) { @@ -6107,7 +6107,7 @@ probedone(struct cam_periph *periph, union ccb *done_ccb) /*count*/1, /*run_queue*/TRUE); } xpt_release_ccb(done_ccb); - free(mode_hdr, M_TEMP); + free(mode_hdr, M_CAMXPT); softc->action = PROBE_SERIAL_NUM; xpt_schedule(periph, priority); return; @@ -6194,7 +6194,7 @@ probedone(struct cam_periph *periph, union ccb *done_ccb) xpt_async(AC_LOST_DEVICE, path, NULL); } if (serial_buf != NULL) - free(serial_buf, M_TEMP); + free(serial_buf, M_CAMXPT); if (changed != 0) { /* @@ -6283,12 +6283,12 @@ probedone(struct cam_periph *periph, union ccb *done_ccb) /* give up */ softc->action = PROBE_DV_EXIT; } - free(nbuf, M_TEMP); + free(nbuf, M_CAMXPT); xpt_release_ccb(done_ccb); xpt_schedule(periph, priority); return; } - free(nbuf, M_TEMP); + free(nbuf, M_CAMXPT); if (softc->action == PROBE_INQUIRY_BASIC_DV1) { softc->action = PROBE_INQUIRY_BASIC_DV2; xpt_release_ccb(done_ccb); @@ -6327,7 +6327,7 @@ probedone(struct cam_periph *periph, union ccb *done_ccb) static void probecleanup(struct cam_periph *periph) { - free(periph->softc, M_TEMP); + free(periph->softc, M_CAMXPT); } static void @@ -6984,7 +6984,7 @@ xpt_finishconfig_task(void *context, int pending) /* Release our hook so that the boot can continue. */ config_intrhook_disestablish(xsoftc.xpt_config_hook); - free(xsoftc.xpt_config_hook, M_TEMP); + free(xsoftc.xpt_config_hook, M_CAMXPT); xsoftc.xpt_config_hook = NULL; } diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index fde3c25..daff012 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -329,6 +329,8 @@ static struct mtx changerq_mtx; static STAILQ_HEAD(changerlist, cdchanger) changerq; static int num_changers; +MALLOC_DEFINE(M_SCSICD, "scsi_cd", "scsi_cd buffers"); + static void cdinit(void) { @@ -1519,7 +1521,7 @@ cdstart(struct cam_periph *periph, union ccb *start_ccb) { rcap = (struct scsi_read_capacity_data *)malloc(sizeof(*rcap), - M_TEMP, + M_SCSICD, M_NOWAIT); if (rcap == NULL) { xpt_print(periph->path, @@ -1778,7 +1780,7 @@ cddone(struct cam_periph *periph, union ccb *done_ccb) } } } - free(rdcap, M_TEMP); + free(rdcap, M_SCSICD); if (announce_buf[0] != '\0') { xpt_announce_periph(periph, announce_buf); if (softc->flags & CD_FLAG_CHANGER) @@ -1906,7 +1908,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) union cd_pages *page; params.alloc_len = sizeof(union cd_mode_data_6_10); - params.mode_buf = malloc(params.alloc_len, M_TEMP, + params.mode_buf = malloc(params.alloc_len, M_SCSICD, M_WAITOK | M_ZERO); cam_periph_lock(periph); @@ -1915,7 +1917,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) error = cdgetmode(periph, ¶ms, AUDIO_PAGE); if (error) { - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); cam_periph_unlock(periph); break; } @@ -1924,7 +1926,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) page->audio.flags &= ~CD_PA_SOTC; page->audio.flags |= CD_PA_IMMED; error = cdsetmode(periph, ¶ms); - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); if (error) { cam_periph_unlock(periph); break; @@ -2001,7 +2003,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) union cd_pages *page; params.alloc_len = sizeof(union cd_mode_data_6_10); - params.mode_buf = malloc(params.alloc_len, M_TEMP, + params.mode_buf = malloc(params.alloc_len, M_SCSICD, M_WAITOK | M_ZERO); cam_periph_lock(periph); @@ -2010,7 +2012,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) error = cdgetmode(periph, ¶ms, AUDIO_PAGE); if (error) { - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); cam_periph_unlock(periph); break; } @@ -2019,7 +2021,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) page->audio.flags &= ~CD_PA_SOTC; page->audio.flags |= CD_PA_IMMED; error = cdsetmode(periph, ¶ms); - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); if (error) { cam_periph_unlock(periph); break; @@ -2042,7 +2044,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) union cd_pages *page; params.alloc_len = sizeof(union cd_mode_data_6_10); - params.mode_buf = malloc(params.alloc_len, M_TEMP, + params.mode_buf = malloc(params.alloc_len, M_SCSICD, M_WAITOK | M_ZERO); cam_periph_lock(periph); @@ -2052,7 +2054,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) error = cdgetmode(periph, ¶ms, AUDIO_PAGE); if (error) { - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); cam_periph_unlock(periph); break; } @@ -2061,7 +2063,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) page->audio.flags &= ~CD_PA_SOTC; page->audio.flags |= CD_PA_IMMED; error = cdsetmode(periph, ¶ms); - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); if (error) { cam_periph_unlock(periph); break; @@ -2081,7 +2083,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) u_int32_t len = args->data_len; data = malloc(sizeof(struct cd_sub_channel_info), - M_TEMP, M_WAITOK); + M_SCSICD, M_WAITOK); cam_periph_lock(periph); CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE, @@ -2094,7 +2096,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) "cdioreadsubchannel: error, len=%d\n", len); error = EINVAL; - free(data, M_TEMP); + free(data, M_SCSICD); cam_periph_unlock(periph); break; } @@ -2106,7 +2108,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) args->data_format, args->track, data, len); if (error) { - free(data, M_TEMP); + free(data, M_SCSICD); cam_periph_unlock(periph); break; } @@ -2124,7 +2126,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) } else { bcopy(data, args->data, len); } - free(data, M_TEMP); + free(data, M_SCSICD); } break; @@ -2132,7 +2134,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) { struct ioc_toc_header *th; - th = malloc(sizeof(struct ioc_toc_header), M_TEMP, + th = malloc(sizeof(struct ioc_toc_header), M_SCSICD, M_WAITOK); cam_periph_lock(periph); @@ -2142,7 +2144,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) error = cdreadtoc(periph, 0, 0, (u_int8_t *)th, sizeof (*th), /*sense_flags*/0); if (error) { - free(th, M_TEMP); + free(th, M_SCSICD); cam_periph_unlock(periph); break; } @@ -2156,7 +2158,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) } th->len = ntohs(th->len); bcopy(th, addr, sizeof(*th)); - free(th, M_TEMP); + free(th, M_SCSICD); cam_periph_unlock(periph); } break; @@ -2170,8 +2172,8 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) u_int32_t len, readlen, idx, num; u_int32_t starting_track = te->starting_track; - data = malloc(sizeof(*data), M_TEMP, M_WAITOK); - lead = malloc(sizeof(*lead), M_TEMP, M_WAITOK); + data = malloc(sizeof(*data), M_SCSICD, M_WAITOK); + lead = malloc(sizeof(*lead), M_SCSICD, M_WAITOK); cam_periph_lock(periph); CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE, @@ -2184,8 +2186,8 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) error = EINVAL; printf("scsi_cd: error in readtocentries, " "returning EINVAL\n"); - free(data, M_TEMP); - free(lead, M_TEMP); + free(data, M_SCSICD); + free(lead, M_SCSICD); cam_periph_unlock(periph); break; } @@ -2194,8 +2196,8 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) error = cdreadtoc(periph, 0, 0, (u_int8_t *)th, sizeof (*th), /*sense_flags*/0); if (error) { - free(data, M_TEMP); - free(lead, M_TEMP); + free(data, M_SCSICD); + free(lead, M_SCSICD); cam_periph_unlock(periph); break; } @@ -2217,8 +2219,8 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) starting_track > th->ending_track + 1) { printf("scsi_cd: error in readtocentries, " "returning EINVAL\n"); - free(data, M_TEMP); - free(lead, M_TEMP); + free(data, M_SCSICD); + free(lead, M_SCSICD); cam_periph_unlock(periph); error = EINVAL; break; @@ -2239,8 +2241,8 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) printf("scsi_cd: error in readtocentries, " "returning EINVAL\n"); error = EINVAL; - free(data, M_TEMP); - free(lead, M_TEMP); + free(data, M_SCSICD); + free(lead, M_SCSICD); cam_periph_unlock(periph); break; } @@ -2253,8 +2255,8 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) readlen + sizeof (*th), /*sense_flags*/0); if (error) { - free(data, M_TEMP); - free(lead, M_TEMP); + free(data, M_SCSICD); + free(lead, M_SCSICD); cam_periph_unlock(periph); break; } @@ -2270,8 +2272,8 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) sizeof(*lead), /*sense_flags*/0); if (error) { - free(data, M_TEMP); - free(lead, M_TEMP); + free(data, M_SCSICD); + free(lead, M_SCSICD); cam_periph_unlock(periph); break; } @@ -2287,8 +2289,8 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) cam_periph_unlock(periph); error = copyout(data->entries, te->data, len); - free(data, M_TEMP); - free(lead, M_TEMP); + free(data, M_SCSICD); + free(lead, M_SCSICD); } break; case CDIOREADTOCENTRY: @@ -2299,7 +2301,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) struct ioc_toc_header *th; u_int32_t track; - data = malloc(sizeof(*data), M_TEMP, M_WAITOK); + data = malloc(sizeof(*data), M_SCSICD, M_WAITOK); cam_periph_lock(periph); CAM_DEBUG(periph->path, CAM_DEBUG_SUBTRACE, @@ -2309,7 +2311,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) && te->address_format != CD_LBA_FORMAT) { printf("error in readtocentry, " " returning EINVAL\n"); - free(data, M_TEMP); + free(data, M_SCSICD); error = EINVAL; cam_periph_unlock(periph); break; @@ -2319,7 +2321,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) error = cdreadtoc(periph, 0, 0, (u_int8_t *)th, sizeof (*th), /*sense_flags*/0); if (error) { - free(data, M_TEMP); + free(data, M_SCSICD); cam_periph_unlock(periph); break; } @@ -2341,7 +2343,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) track > th->ending_track + 1) { printf("error in readtocentry, " " returning EINVAL\n"); - free(data, M_TEMP); + free(data, M_SCSICD); error = EINVAL; cam_periph_unlock(periph); break; @@ -2351,7 +2353,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) (u_int8_t *)data, sizeof(*data), /*sense_flags*/0); if (error) { - free(data, M_TEMP); + free(data, M_SCSICD); cam_periph_unlock(periph); break; } @@ -2360,7 +2362,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) data->entry.track = bcd2bin(data->entry.track); bcopy(&data->entry, &te->entry, sizeof(struct cd_toc_entry)); - free(data, M_TEMP); + free(data, M_SCSICD); cam_periph_unlock(periph); } break; @@ -2371,7 +2373,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) union cd_pages *page; params.alloc_len = sizeof(union cd_mode_data_6_10); - params.mode_buf = malloc(params.alloc_len, M_TEMP, + params.mode_buf = malloc(params.alloc_len, M_SCSICD, M_WAITOK | M_ZERO); cam_periph_lock(periph); @@ -2380,7 +2382,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) error = cdgetmode(periph, ¶ms, AUDIO_PAGE); if (error) { - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); cam_periph_unlock(periph); break; } @@ -2393,7 +2395,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) page->audio.port[2].channels = arg->patch[2]; page->audio.port[3].channels = arg->patch[3]; error = cdsetmode(periph, ¶ms); - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); cam_periph_unlock(periph); } break; @@ -2404,7 +2406,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) union cd_pages *page; params.alloc_len = sizeof(union cd_mode_data_6_10); - params.mode_buf = malloc(params.alloc_len, M_TEMP, + params.mode_buf = malloc(params.alloc_len, M_SCSICD, M_WAITOK | M_ZERO); cam_periph_lock(periph); @@ -2413,7 +2415,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) error = cdgetmode(periph, ¶ms, AUDIO_PAGE); if (error) { - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); cam_periph_unlock(periph); break; } @@ -2425,7 +2427,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) page->audio.port[RIGHT_PORT].volume; arg->vol[2] = page->audio.port[2].volume; arg->vol[3] = page->audio.port[3].volume; - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); cam_periph_unlock(periph); } break; @@ -2436,7 +2438,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) union cd_pages *page; params.alloc_len = sizeof(union cd_mode_data_6_10); - params.mode_buf = malloc(params.alloc_len, M_TEMP, + params.mode_buf = malloc(params.alloc_len, M_SCSICD, M_WAITOK | M_ZERO); cam_periph_lock(periph); @@ -2445,7 +2447,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) error = cdgetmode(periph, ¶ms, AUDIO_PAGE); if (error) { - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); cam_periph_unlock(periph); break; } @@ -2461,7 +2463,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) page->audio.port[3].volume = arg->vol[3]; error = cdsetmode(periph, ¶ms); cam_periph_unlock(periph); - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); } break; case CDIOCSETMONO: @@ -2470,7 +2472,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) union cd_pages *page; params.alloc_len = sizeof(union cd_mode_data_6_10); - params.mode_buf = malloc(params.alloc_len, M_TEMP, + params.mode_buf = malloc(params.alloc_len, M_SCSICD, M_WAITOK | M_ZERO); cam_periph_lock(periph); @@ -2479,7 +2481,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) error = cdgetmode(periph, ¶ms, AUDIO_PAGE); if (error) { - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); cam_periph_unlock(periph); break; } @@ -2493,7 +2495,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) page->audio.port[3].channels = 0; error = cdsetmode(periph, ¶ms); cam_periph_unlock(periph); - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); } break; case CDIOCSETSTEREO: @@ -2502,7 +2504,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) union cd_pages *page; params.alloc_len = sizeof(union cd_mode_data_6_10); - params.mode_buf = malloc(params.alloc_len, M_TEMP, + params.mode_buf = malloc(params.alloc_len, M_SCSICD, M_WAITOK | M_ZERO); cam_periph_lock(periph); @@ -2511,7 +2513,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) error = cdgetmode(periph, ¶ms, AUDIO_PAGE); if (error) { - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); cam_periph_unlock(periph); break; } @@ -2524,7 +2526,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) page->audio.port[2].channels = 0; page->audio.port[3].channels = 0; error = cdsetmode(periph, ¶ms); - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); cam_periph_unlock(periph); } break; @@ -2534,7 +2536,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) union cd_pages *page; params.alloc_len = sizeof(union cd_mode_data_6_10); - params.mode_buf = malloc(params.alloc_len, M_TEMP, + params.mode_buf = malloc(params.alloc_len, M_SCSICD, M_WAITOK | M_ZERO); cam_periph_lock(periph); @@ -2543,7 +2545,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) error = cdgetmode(periph, ¶ms, AUDIO_PAGE); if (error) { - free(¶ms, M_TEMP); + free(¶ms, M_SCSICD); cam_periph_unlock(periph); break; } @@ -2554,7 +2556,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) page->audio.port[2].channels = 0; page->audio.port[3].channels = 0; error = cdsetmode(periph, ¶ms); - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); cam_periph_unlock(periph); } break; @@ -2564,7 +2566,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) union cd_pages *page; params.alloc_len = sizeof(union cd_mode_data_6_10); - params.mode_buf = malloc(params.alloc_len, M_TEMP, + params.mode_buf = malloc(params.alloc_len, M_SCSICD, M_WAITOK | M_ZERO); cam_periph_lock(periph); @@ -2573,7 +2575,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) error = cdgetmode(periph, ¶ms, AUDIO_PAGE); if (error) { - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); cam_periph_unlock(periph); break; } @@ -2584,7 +2586,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) page->audio.port[2].channels = 0; page->audio.port[3].channels = 0; error = cdsetmode(periph, ¶ms); - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); cam_periph_unlock(periph); } break; @@ -2594,7 +2596,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) union cd_pages *page; params.alloc_len = sizeof(union cd_mode_data_6_10); - params.mode_buf = malloc(params.alloc_len, M_TEMP, + params.mode_buf = malloc(params.alloc_len, M_SCSICD, M_WAITOK | M_ZERO); cam_periph_lock(periph); @@ -2603,7 +2605,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) error = cdgetmode(periph, ¶ms, AUDIO_PAGE); if (error) { - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); cam_periph_unlock(periph); break; } @@ -2614,7 +2616,7 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td) page->audio.port[2].channels = 0; page->audio.port[3].channels = 0; error = cdsetmode(periph, ¶ms); - free(params.mode_buf, M_TEMP); + free(params.mode_buf, M_SCSICD); cam_periph_unlock(periph); } break; @@ -2920,7 +2922,7 @@ cdsize(struct cam_periph *periph, u_int32_t *size) /* XXX Should be M_WAITOK */ rcap_buf = malloc(sizeof(struct scsi_read_capacity_data), - M_TEMP, M_NOWAIT); + M_SCSICD, M_NOWAIT); if (rcap_buf == NULL) return (ENOMEM); @@ -2950,7 +2952,7 @@ cdsize(struct cam_periph *periph, u_int32_t *size) if (softc->params.blksize > 2048 && softc->params.blksize <= 2352) softc->params.blksize = 2048; - free(rcap_buf, M_TEMP); + free(rcap_buf, M_SCSICD); *size = softc->params.disksize; return (error); diff --git a/sys/cam/scsi/scsi_ch.c b/sys/cam/scsi/scsi_ch.c index 337cea3..f678b2a 100644 --- a/sys/cam/scsi/scsi_ch.c +++ b/sys/cam/scsi/scsi_ch.c @@ -218,6 +218,8 @@ static struct cdevsw ch_cdevsw = { .d_name = "ch", }; +MALLOC_DEFINE(M_SCSICH, "scsi_ch", "scsi_ch buffers"); + static void chinit(void) { @@ -508,7 +510,7 @@ chstart(struct cam_periph *periph, union ccb *start_ccb) sizeof(struct scsi_mode_blk_desc) + sizeof(struct page_element_address_assignment); - mode_buffer = malloc(mode_buffer_len, M_TEMP, M_NOWAIT); + mode_buffer = malloc(mode_buffer_len, M_SCSICH, M_NOWAIT); if (mode_buffer == NULL) { printf("chstart: couldn't malloc mode sense data\n"); @@ -655,7 +657,7 @@ chdone(struct cam_periph *periph, union ccb *done_ccb) if (announce_buf[0] != '\0') xpt_announce_periph(periph, announce_buf); softc->state = CH_STATE_NORMAL; - free(mode_header, M_TEMP); + free(mode_header, M_SCSICH); /* * Since our peripheral may be invalidated by an error * above or an external event, we must release our CCB @@ -1353,7 +1355,7 @@ chgetparams(struct cam_periph *periph) */ mode_buffer_len = sizeof(struct scsi_mode_sense_data); - mode_buffer = malloc(mode_buffer_len, M_TEMP, M_NOWAIT); + mode_buffer = malloc(mode_buffer_len, M_SCSICH, M_NOWAIT); if (mode_buffer == NULL) { printf("chgetparams: couldn't malloc mode sense data\n"); @@ -1411,7 +1413,7 @@ chgetparams(struct cam_periph *periph) "chgetparams: error getting element " "address page\n"); xpt_release_ccb(ccb); - free(mode_buffer, M_TEMP); + free(mode_buffer, M_SCSICH); return(error); } } @@ -1474,7 +1476,7 @@ chgetparams(struct cam_periph *periph) "chgetparams: error getting device " "capabilities page\n"); xpt_release_ccb(ccb); - free(mode_buffer, M_TEMP); + free(mode_buffer, M_SCSICH); return(error); } } @@ -1493,7 +1495,7 @@ chgetparams(struct cam_periph *periph) softc->sc_exchangemask[from] = exchanges[from]; } - free(mode_buffer, M_TEMP); + free(mode_buffer, M_SCSICH); return(error); } diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index 19053de..f234290 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -548,6 +548,8 @@ static struct periph_driver dadriver = PERIPHDRIVER_DECLARE(da, dadriver); +MALLOC_DEFINE(M_SCSIDA, "scsi_da", "scsi_da buffers"); + static int daopen(struct disk *dp) { @@ -1329,7 +1331,7 @@ dastart(struct cam_periph *periph, union ccb *start_ccb) struct scsi_read_capacity_data *rcap; rcap = (struct scsi_read_capacity_data *)malloc(sizeof(*rcap), - M_TEMP, + M_SCSIDA, M_NOWAIT); if (rcap == NULL) { printf("dastart: Couldn't malloc read_capacity data\n"); @@ -1355,7 +1357,7 @@ dastart(struct cam_periph *periph, union ccb *start_ccb) struct scsi_read_capacity_data_long *rcaplong; rcaplong = (struct scsi_read_capacity_data_long *) - malloc(sizeof(*rcaplong), M_TEMP, M_NOWAIT); + malloc(sizeof(*rcaplong), M_SCSIDA, M_NOWAIT); if (rcaplong == NULL) { printf("dastart: Couldn't malloc read_capacity data\n"); /* da_free_periph??? */ @@ -1547,7 +1549,7 @@ dadone(struct cam_periph *periph, union ccb *done_ccb) */ if (maxsector == 0xffffffff) { softc->state = DA_STATE_PROBE2; - free(rdcap, M_TEMP); + free(rdcap, M_SCSIDA); xpt_release_ccb(done_ccb); xpt_schedule(periph, /*priority*/5); return; @@ -1675,7 +1677,7 @@ dadone(struct cam_periph *periph, union ccb *done_ccb) } } } - free(csio->data_ptr, M_TEMP); + free(csio->data_ptr, M_SCSIDA); if (announce_buf[0] != '\0') { xpt_announce_periph(periph, announce_buf); /* @@ -1816,7 +1818,7 @@ dagetcapacity(struct cam_periph *periph) /* Do a read capacity */ rcap = (struct scsi_read_capacity_data *)malloc(sizeof(*rcaplong), - M_TEMP, + M_SCSIDA, M_NOWAIT); if (rcap == NULL) return (ENOMEM); @@ -1890,7 +1892,7 @@ done: xpt_release_ccb(ccb); - free(rcap, M_TEMP); + free(rcap, M_SCSIDA); return (error); } diff --git a/sys/cam/scsi/scsi_sa.c b/sys/cam/scsi/scsi_sa.c index 69d99d2..c963d89 100644 --- a/sys/cam/scsi/scsi_sa.c +++ b/sys/cam/scsi/scsi_sa.c @@ -1953,7 +1953,7 @@ samount(struct cam_periph *periph, int oflags, struct cdev *dev) * read a full record. */ rblim = (struct scsi_read_block_limits_data *) - malloc(8192, M_TEMP, M_WAITOK); + malloc(8192, M_SCSISA, M_WAITOK); if (rblim == NULL) { xpt_print(periph->path, "no memory for test read\n"); xpt_release_ccb(ccb); @@ -2273,7 +2273,7 @@ tryagain: } exit: if (rblim != NULL) - free(rblim, M_TEMP); + free(rblim, M_SCSISA); if (error != 0) { softc->dsreg = MTIO_DSREG_NIL; @@ -2574,7 +2574,7 @@ retry: mode_buffer_len += sizeof (sa_comp_t); } - mode_buffer = malloc(mode_buffer_len, M_TEMP, M_WAITOK | M_ZERO); + mode_buffer = malloc(mode_buffer_len, M_SCSISA, M_WAITOK | M_ZERO); mode_hdr = (struct scsi_mode_header_6 *)mode_buffer; mode_blk = (struct scsi_mode_blk_desc *)&mode_hdr[1]; @@ -2603,7 +2603,7 @@ retry: goto retry; } softc->quirks |= SA_QUIRK_NOCOMP; - free(mode_buffer, M_TEMP); + free(mode_buffer, M_SCSISA); goto retry; } else if (status == CAM_SCSI_STATUS_ERROR) { /* Tell the user about the fatal error. */ @@ -2712,7 +2712,7 @@ retry: sagetparamsexit: xpt_release_ccb(ccb); - free(mode_buffer, M_TEMP); + free(mode_buffer, M_SCSISA); return (error); } @@ -2754,7 +2754,7 @@ sasetparams(struct cam_periph *periph, sa_params params_to_set, softc = (struct sa_softc *)periph->softc; - ccomp = malloc(sizeof (sa_comp_t), M_TEMP, M_WAITOK); + ccomp = malloc(sizeof (sa_comp_t), M_SCSISA, M_WAITOK); /* * Since it doesn't make sense to set the number of blocks, or @@ -2769,7 +2769,7 @@ sasetparams(struct cam_periph *periph, sa_params params_to_set, ¤t_calg, ccomp); if (error != 0) { - free(ccomp, M_TEMP); + free(ccomp, M_SCSISA); return (error); } @@ -2777,7 +2777,7 @@ sasetparams(struct cam_periph *periph, sa_params params_to_set, if (params_to_set & SA_PARAM_COMPRESSION) mode_buffer_len += sizeof (sa_comp_t); - mode_buffer = malloc(mode_buffer_len, M_TEMP, M_WAITOK | M_ZERO); + mode_buffer = malloc(mode_buffer_len, M_SCSISA, M_WAITOK | M_ZERO); mode_hdr = (struct scsi_mode_header_6 *)mode_buffer; mode_blk = (struct scsi_mode_blk_desc *)&mode_hdr[1]; @@ -2935,7 +2935,7 @@ retry: * 'operation not supported'. */ if (params_to_set == SA_PARAM_NONE) { - free(mode_buffer, M_TEMP); + free(mode_buffer, M_SCSISA); xpt_release_ccb(ccb); return (ENODEV); } @@ -3020,7 +3020,7 @@ retry: xpt_release_ccb(ccb); if (ccomp != NULL) - free(ccomp, M_TEMP); + free(ccomp, M_SCSISA); if (params_to_set & SA_PARAM_COMPRESSION) { if (error) { @@ -3039,7 +3039,7 @@ retry: } } - free(mode_buffer, M_TEMP); + free(mode_buffer, M_SCSISA); return (error); } |