Use a unique malloc type rather than M_DEVBUF.
This commit is contained in:
parent
f3ff3c1aef
commit
2eab4ae579
@ -37,6 +37,8 @@ static d_open_t ips_open;
|
||||
static d_close_t ips_close;
|
||||
static d_ioctl_t ips_ioctl;
|
||||
|
||||
MALLOC_DEFINE(M_IPSBUF, "ipsbuf","IPS driver buffer");
|
||||
|
||||
static struct cdevsw ips_cdevsw = {
|
||||
.d_version = D_VERSION,
|
||||
.d_flags = D_NEEDGIANT,
|
||||
@ -170,13 +172,13 @@ static int ips_add_waiting_command(ips_softc_t *sc, int (*callback)(ips_command_
|
||||
unsigned long memflags = 0;
|
||||
if(IPS_NOWAIT_FLAG & flags)
|
||||
memflags = M_NOWAIT;
|
||||
waiter = malloc(sizeof(ips_wait_list_t), M_DEVBUF, memflags);
|
||||
waiter = malloc(sizeof(ips_wait_list_t), M_IPSBUF, memflags);
|
||||
if(!waiter)
|
||||
return ENOMEM;
|
||||
mask = splbio();
|
||||
if(sc->state & IPS_OFFLINE){
|
||||
splx(mask);
|
||||
free(waiter, M_DEVBUF);
|
||||
free(waiter, M_IPSBUF);
|
||||
return EIO;
|
||||
}
|
||||
command = SLIST_FIRST(&sc->free_cmd_list);
|
||||
@ -186,7 +188,7 @@ static int ips_add_waiting_command(ips_softc_t *sc, int (*callback)(ips_command_
|
||||
splx(mask);
|
||||
clear_ips_command(command);
|
||||
bzero(command->command_buffer, IPS_COMMAND_LEN);
|
||||
free(waiter, M_DEVBUF);
|
||||
free(waiter, M_IPSBUF);
|
||||
command->arg = data;
|
||||
return callback(command);
|
||||
}
|
||||
@ -221,7 +223,7 @@ static void ips_run_waiting_command(ips_softc_t *sc)
|
||||
bzero(command->command_buffer, IPS_COMMAND_LEN);
|
||||
command->arg = waiter->data;
|
||||
callback = waiter->callback;
|
||||
free(waiter, M_DEVBUF);
|
||||
free(waiter, M_IPSBUF);
|
||||
callback(command);
|
||||
return;
|
||||
}
|
||||
|
@ -50,6 +50,8 @@
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
|
||||
MALLOC_DECLARE(M_IPSBUF);
|
||||
|
||||
/*
|
||||
* IPS CONSTANTS
|
||||
*/
|
||||
|
@ -272,19 +272,19 @@ int ips_get_adapter_info(ips_softc_t *sc)
|
||||
{
|
||||
int error = 0;
|
||||
ips_cmd_status_t *status;
|
||||
status = malloc(sizeof(ips_cmd_status_t), M_DEVBUF, M_NOWAIT|M_ZERO);
|
||||
status = malloc(sizeof(ips_cmd_status_t), M_IPSBUF, M_NOWAIT|M_ZERO);
|
||||
if(!status)
|
||||
return ENOMEM;
|
||||
if(ips_get_free_cmd(sc, ips_send_adapter_info_cmd, status,
|
||||
IPS_NOWAIT_FLAG) > 0){
|
||||
device_printf(sc->dev, "unable to get adapter configuration\n");
|
||||
free(status, M_DEVBUF);
|
||||
free(status, M_IPSBUF);
|
||||
return ENXIO;
|
||||
}
|
||||
if (COMMAND_ERROR(status)){
|
||||
error = ENXIO;
|
||||
}
|
||||
free(status, M_DEVBUF);
|
||||
free(status, M_IPSBUF);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -378,19 +378,19 @@ int ips_get_drive_info(ips_softc_t *sc)
|
||||
{
|
||||
int error = 0;
|
||||
ips_cmd_status_t *status;
|
||||
status = malloc(sizeof(ips_cmd_status_t), M_DEVBUF, M_NOWAIT|M_ZERO);
|
||||
status = malloc(sizeof(ips_cmd_status_t), M_IPSBUF, M_NOWAIT|M_ZERO);
|
||||
if(!status)
|
||||
return ENOMEM;
|
||||
if(ips_get_free_cmd(sc, ips_send_drive_info_cmd, status,
|
||||
IPS_NOWAIT_FLAG) > 0){
|
||||
free(status, M_DEVBUF);
|
||||
free(status, M_IPSBUF);
|
||||
device_printf(sc->dev, "unable to get drive configuration\n");
|
||||
return ENXIO;
|
||||
}
|
||||
if(COMMAND_ERROR(status)){
|
||||
error = ENXIO;
|
||||
}
|
||||
free(status, M_DEVBUF);
|
||||
free(status, M_IPSBUF);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -419,19 +419,19 @@ static int ips_send_flush_cache_cmd(ips_command_t *command)
|
||||
int ips_flush_cache(ips_softc_t *sc)
|
||||
{
|
||||
ips_cmd_status_t *status;
|
||||
status = malloc(sizeof(ips_cmd_status_t), M_DEVBUF, M_NOWAIT|M_ZERO);
|
||||
status = malloc(sizeof(ips_cmd_status_t), M_IPSBUF, M_NOWAIT|M_ZERO);
|
||||
if(!status)
|
||||
return ENOMEM;
|
||||
device_printf(sc->dev, "flushing cache\n");
|
||||
if(ips_get_free_cmd(sc, ips_send_flush_cache_cmd, status,
|
||||
IPS_NOWAIT_FLAG)){
|
||||
free(status, M_DEVBUF);
|
||||
free(status, M_IPSBUF);
|
||||
device_printf(sc->dev, "ERROR: unable to get a command! can't flush cache!\n");
|
||||
}
|
||||
if(COMMAND_ERROR(status)){
|
||||
device_printf(sc->dev, "ERROR: cache flush command failed!\n");
|
||||
}
|
||||
free(status, M_DEVBUF);
|
||||
free(status, M_IPSBUF);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -505,18 +505,18 @@ static int ips_send_ffdc_reset_cmd(ips_command_t *command)
|
||||
int ips_ffdc_reset(ips_softc_t *sc)
|
||||
{
|
||||
ips_cmd_status_t *status;
|
||||
status = malloc(sizeof(ips_cmd_status_t), M_DEVBUF, M_NOWAIT|M_ZERO);
|
||||
status = malloc(sizeof(ips_cmd_status_t), M_IPSBUF, M_NOWAIT|M_ZERO);
|
||||
if(!status)
|
||||
return ENOMEM;
|
||||
if(ips_get_free_cmd(sc, ips_send_ffdc_reset_cmd, status,
|
||||
IPS_NOWAIT_FLAG)){
|
||||
free(status, M_DEVBUF);
|
||||
free(status, M_IPSBUF);
|
||||
device_printf(sc->dev, "ERROR: unable to get a command! can't send ffdc reset!\n");
|
||||
}
|
||||
if(COMMAND_ERROR(status)){
|
||||
device_printf(sc->dev, "ERROR: ffdc reset command failed!\n");
|
||||
}
|
||||
free(status, M_DEVBUF);
|
||||
free(status, M_IPSBUF);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -626,18 +626,18 @@ static int ips_read_nvram(ips_command_t *command){
|
||||
int ips_update_nvram(ips_softc_t *sc)
|
||||
{
|
||||
ips_cmd_status_t *status;
|
||||
status = malloc(sizeof(ips_cmd_status_t), M_DEVBUF, M_NOWAIT|M_ZERO);
|
||||
status = malloc(sizeof(ips_cmd_status_t), M_IPSBUF, M_NOWAIT|M_ZERO);
|
||||
if(!status)
|
||||
return ENOMEM;
|
||||
if(ips_get_free_cmd(sc, ips_read_nvram, status, IPS_NOWAIT_FLAG)){
|
||||
free(status, M_DEVBUF);
|
||||
free(status, M_IPSBUF);
|
||||
device_printf(sc->dev, "ERROR: unable to get a command! can't update nvram\n");
|
||||
return 1;
|
||||
}
|
||||
if(COMMAND_ERROR(status)){
|
||||
device_printf(sc->dev, "ERROR: nvram update command failed!\n");
|
||||
}
|
||||
free(status, M_DEVBUF);
|
||||
free(status, M_IPSBUF);
|
||||
return 0;
|
||||
|
||||
|
||||
@ -690,18 +690,18 @@ static int ips_send_error_table_cmd(ips_command_t *command)
|
||||
int ips_clear_adapter(ips_softc_t *sc)
|
||||
{
|
||||
ips_cmd_status_t *status;
|
||||
status = malloc(sizeof(ips_cmd_status_t), M_DEVBUF, M_NOWAIT|M_ZERO);
|
||||
status = malloc(sizeof(ips_cmd_status_t), M_IPSBUF, M_NOWAIT|M_ZERO);
|
||||
if(!status)
|
||||
return ENOMEM;
|
||||
device_printf(sc->dev, "syncing config\n");
|
||||
if(ips_get_free_cmd(sc, ips_send_config_sync_cmd, status,
|
||||
IPS_NOWAIT_FLAG)){
|
||||
free(status, M_DEVBUF);
|
||||
free(status, M_IPSBUF);
|
||||
device_printf(sc->dev, "ERROR: unable to get a command! can't sync cache!\n");
|
||||
return 1;
|
||||
}
|
||||
if(COMMAND_ERROR(status)){
|
||||
free(status, M_DEVBUF);
|
||||
free(status, M_IPSBUF);
|
||||
device_printf(sc->dev, "ERROR: cache sync command failed!\n");
|
||||
return 1;
|
||||
}
|
||||
@ -709,16 +709,16 @@ int ips_clear_adapter(ips_softc_t *sc)
|
||||
device_printf(sc->dev, "clearing error table\n");
|
||||
if(ips_get_free_cmd(sc, ips_send_error_table_cmd, status,
|
||||
IPS_NOWAIT_FLAG)){
|
||||
free(status, M_DEVBUF);
|
||||
free(status, M_IPSBUF);
|
||||
device_printf(sc->dev, "ERROR: unable to get a command! can't sync cache!\n");
|
||||
return 1;
|
||||
}
|
||||
if(COMMAND_ERROR(status)){
|
||||
device_printf(sc->dev, "ERROR: etable command failed!\n");
|
||||
free(status, M_DEVBUF);
|
||||
free(status, M_IPSBUF);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free(status, M_DEVBUF);
|
||||
free(status, M_IPSBUF);
|
||||
return 0;
|
||||
}
|
||||
|
@ -139,20 +139,20 @@ int ips_ioctl_request(ips_softc_t *sc, u_long ioctl_request, caddr_t addr, int32
|
||||
switch(ioctl_request){
|
||||
case IPS_USER_CMD:
|
||||
user_request = (ips_user_request *)addr;
|
||||
ioctl_cmd = malloc(sizeof(ips_ioctl_t), M_DEVBUF, M_WAITOK);
|
||||
ioctl_cmd = malloc(sizeof(ips_ioctl_t), M_IPSBUF, M_WAITOK);
|
||||
ioctl_cmd->command_buffer = malloc(sizeof(ips_generic_cmd),
|
||||
M_DEVBUF, M_WAITOK);
|
||||
M_IPSBUF, M_WAITOK);
|
||||
if(copyin(user_request->command_buffer,
|
||||
ioctl_cmd->command_buffer, sizeof(ips_generic_cmd))){
|
||||
free(ioctl_cmd->command_buffer, M_DEVBUF);
|
||||
free(ioctl_cmd, M_DEVBUF);
|
||||
free(ioctl_cmd->command_buffer, M_IPSBUF);
|
||||
free(ioctl_cmd, M_IPSBUF);
|
||||
break;
|
||||
}
|
||||
ioctl_cmd->readwrite = IPS_IOCTL_READ | IPS_IOCTL_WRITE;
|
||||
ioctl_cmd->datasize = IPS_IOCTL_BUFFER_SIZE;
|
||||
error = ips_ioctl_cmd(sc, ioctl_cmd, user_request);
|
||||
free(ioctl_cmd->command_buffer, M_DEVBUF);
|
||||
free(ioctl_cmd, M_DEVBUF);
|
||||
free(ioctl_cmd->command_buffer, M_IPSBUF);
|
||||
free(ioctl_cmd, M_IPSBUF);
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user