int nv_gvi_kern_resume( struct pci_dev *dev ) { nv_state_t *nv; nv_linux_state_t *lnv = NULL; nv_stack_t *sp = NULL; int status = RM_OK; nv_printf(NV_DBG_INFO, "NVGVI: Begin resuming GVI device!\n"); lnv = pci_get_drvdata(dev); if ((!lnv) || (lnv->dev != dev)) { nv_printf(NV_DBG_WARNINGS, "NVGVI: PM: invalid device!\n"); return -1; } NV_KMEM_CACHE_ALLOC_STACK(sp); if (sp == NULL) { nv_printf(NV_DBG_ERRORS, "NVGVI: failed to allocate stack!\n"); return -1; } nv = NV_STATE_PTR(lnv); status = rm_gvi_resume(sp, nv); if (status == RM_OK) nv->flags &= ~NV_FLAG_GVI_IN_SUSPEND; NV_KMEM_CACHE_FREE_STACK(sp); return status; }
RM_STATUS NV_API_CALL os_registry_init(void) { nv_parm_t *entry; unsigned int i; nv_stack_t *sp = NULL; NV_KMEM_CACHE_ALLOC_STACK(sp); if (sp == NULL) { nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate stack!\n"); return RM_ERR_NO_FREE_MEM; } if (NVreg_RmMsg != NULL) { rm_write_registry_string(sp, NULL, "NVreg", "RmMsg", NVreg_RmMsg, strlen(NVreg_RmMsg)); } parse_option_string(sp); for (i = 0; (entry = &nv_parms[i])->name != NULL; i++) { rm_write_registry_dword(sp, NULL, entry->node, entry->name, *entry->data); } NV_KMEM_CACHE_FREE_STACK(sp); return RM_OK; }
int nv_gvi_kern_suspend( struct pci_dev *dev, pm_message_t state ) { nv_state_t *nv; nv_linux_state_t *lnv = NULL; int status = RM_OK; nv_stack_t *sp = NULL; nv_printf(NV_DBG_INFO, "NVGVI: Begin suspending GVI device!\n"); lnv = pci_get_drvdata(dev); if ((!lnv) || (lnv->dev != dev)) { nv_printf(NV_DBG_WARNINGS, "NVGVI: PM: invalid device!\n"); return -1; } NV_KMEM_CACHE_ALLOC_STACK(sp); if (sp == NULL) { nv_printf(NV_DBG_ERRORS, "NVGVI: failed to allocate stack!\n"); return -1; } nv = NV_STATE_PTR(lnv); status = rm_shutdown_gvi_device(sp, nv); if (status != 0) { nv_printf(NV_DBG_ERRORS, "NVGVI: failed to stop gvi!\n"); goto failed; } nv->flags |= NV_FLAG_GVI_IN_SUSPEND; NV_TASKQUEUE_FLUSH(); status = rm_gvi_suspend(sp, nv); if (status != 0) { nv->flags &= ~NV_FLAG_GVI_IN_SUSPEND; nv_printf(NV_DBG_ERRORS, "NVGVI: failed to suspend gvi!\n"); goto failed; } nv_printf(NV_DBG_INFO, "NVGVI: End suspending GVI device!\n"); failed: NV_KMEM_CACHE_FREE_STACK(sp); return status; }
static int nv_i2c_algo_master_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) { nv_state_t *nv = (nv_state_t *)adap->algo_data; unsigned int i = 0; int rc = -EIO; RM_STATUS rmStatus = RM_OK; nv_stack_t *sp = NULL; NV_KMEM_CACHE_ALLOC_STACK(sp); if (sp == NULL) { nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate stack!\n"); return -ENOMEM; } for (i = 0; ((i < (unsigned int)num) && (rmStatus == RM_OK)); i++) { if (msgs[i].flags & ~I2C_M_RD) { /* we don't support I2C_FUNC_10BIT_ADDR, I2C_FUNC_PROTOCOL_MANGLING */ rc = -EINVAL; rmStatus = RM_ERR_INVALID_ARGUMENT; } else if (msgs[i].flags & I2C_M_RD) { rmStatus = rm_i2c_read_buffer(sp, nv, (void *)adap, (NvU8)(msgs[i].addr & 0x7f), (NvU32)(msgs[i].len & 0xffffUL), (NvU8 *)msgs[i].buf); } else { rmStatus = rm_i2c_write_buffer(sp, nv, (void *)adap, (NvU8)(msgs[i].addr & 0x7f), (NvU32)(msgs[i].len & 0xffffUL), (NvU8 *)msgs[i].buf); } } NV_KMEM_CACHE_FREE_STACK(sp); return (rmStatus != RM_OK) ? rc : num; }
RM_STATUS NV_API_CALL os_registry_init(void) { nv_parm_t *entry; unsigned int i; nv_stack_t *sp = NULL; NV_KMEM_CACHE_ALLOC_STACK(sp); if (sp == NULL) { nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate stack!\n"); return RM_ERR_NO_MEMORY; } if (NVreg_RmMsg != NULL) { rm_write_registry_string(sp, NULL, "NVreg", "RmMsg", NVreg_RmMsg, strlen(NVreg_RmMsg)); } memset(&nv_assign_gpu_pci_info, 0, sizeof(nv_assign_gpu_pci_info)); #if !defined(NV_VMWARE) if (parse_assign_gpus_string()) { rm_write_registry_string(sp, NULL, "NVreg", NV_REG_ASSIGN_GPUS, NVreg_AssignGpus, strlen(NVreg_AssignGpus)); } #endif parse_option_string(sp); detect_virtualization_and_apply_defaults(sp); for (i = 0; (entry = &nv_parms[i])->name != NULL; i++) { rm_write_registry_dword(sp, NULL, entry->node, entry->name, *entry->data); } NV_KMEM_CACHE_FREE_STACK(sp); return RM_OK; }
static int nv_i2c_algo_smbus_xfer( struct i2c_adapter *adap, u16 addr, unsigned short flags, char read_write, u8 command, int size, union i2c_smbus_data *data ) { nv_state_t *nv = (nv_state_t *)adap->algo_data; int rc = -EIO; RM_STATUS rmStatus = RM_OK; nv_stack_t *sp = NULL; NV_KMEM_CACHE_ALLOC_STACK(sp); if (sp == NULL) { nv_printf(NV_DBG_ERRORS, "NVRM: failed to allocate stack!\n"); return -ENOMEM; } switch (size) { case I2C_SMBUS_QUICK: rmStatus = rm_i2c_smbus_write_quick(sp, nv, (void *)adap, (NvU8)(addr & 0x7f), (read_write == I2C_SMBUS_READ)); break; case I2C_SMBUS_BYTE: if (read_write == I2C_SMBUS_READ) { rmStatus = rm_i2c_read_buffer(sp, nv, (void *)adap, (NvU8)(addr & 0x7f), 1, /* single byte transfer */ (NvU8 *)&data->byte); } else { u8 data = command; rmStatus = rm_i2c_write_buffer(sp, nv, (void *)adap, (NvU8)(addr & 0x7f), 1, /* single byte transfer */ (NvU8 *)&data); } break; case I2C_SMBUS_BYTE_DATA: if (read_write == I2C_SMBUS_READ) { rmStatus = rm_i2c_smbus_read_buffer(sp, nv, (void *)adap, (NvU8)(addr & 0x7f), (NvU8)command, 1, /* single byte transfer */ (NvU8 *)&data->byte); } else { rmStatus = rm_i2c_smbus_write_buffer(sp, nv, (void *)adap, (NvU8)(addr & 0x7f), (NvU8)command, 1, /* single byte transfer */ (NvU8 *)&data->byte); } break; case I2C_SMBUS_WORD_DATA: if (read_write == I2C_SMBUS_READ) { rmStatus = rm_i2c_smbus_read_buffer(sp, nv, (void *)adap, (NvU8)(addr & 0x7f), (NvU8)command, 2, /* single word transfer */ (NvU8 *)&data->block[1]); data->word = ((NvU16)data->block[1]) | ((NvU16)data->block[2] << 8); } else { u16 word = data->word; data->block[1] = (word & 0xff); data->block[2] = (word >> 8); rmStatus = rm_i2c_smbus_write_buffer(sp, nv, (void *)adap, (NvU8)(addr & 0x7f), (NvU8)command, 2, /* single word transfer */ (NvU8 *)&data->block[1]); } break; default: rc = -EINVAL; rmStatus = RM_ERR_INVALID_ARGUMENT; } NV_KMEM_CACHE_FREE_STACK(sp); return (rmStatus != RM_OK) ? rc : 0; }