static int kgsl_last_release_locked(void) { BUG_ON(kgsl_driver.grp_clk == NULL); BUG_ON(kgsl_driver.imem_clk == NULL); disable_irq(kgsl_driver.interrupt_num); kgsl_yamato_stop(&kgsl_driver.yamato_device); /* close devices */ kgsl_yamato_close(&kgsl_driver.yamato_device); /* shutdown memory apertures */ kgsl_sharedmem_close(&kgsl_driver.shmem); if (kgsl_driver.grp_pclk) clk_disable(kgsl_driver.grp_pclk); clk_disable(kgsl_driver.grp_clk); clk_disable(kgsl_driver.imem_clk); max_axi_freq_set = 0; pm_qos_update_requirement(PM_QOS_SYSTEM_BUS_FREQ, DRIVER_NAME, PM_QOS_DEFAULT_VALUE); return 0; }
int kgsl_sharedmem_init(gsl_sharedmem_t *shmem) { int i; int status; gsl_shmemconfig_t config; int mmu_virtualized; gsl_apertureid_t aperture_id; gsl_channelid_t channel_id; unsigned int hostbaseaddr; gpuaddr_t gpubaseaddr; int sizebytes; kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "--> int kgsl_sharedmem_init(gsl_sharedmem_t *shmem=0x%08x)\n", shmem ); if (shmem->flags & GSL_FLAGS_INITIALIZED) { kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_sharedmem_init. Return value %B\n", GSL_SUCCESS ); return (GSL_SUCCESS); } status = kgsl_hal_getshmemconfig(&config); if (status != GSL_SUCCESS) { kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_ERROR, "ERROR: Unable to get sharedmem config.\n" ); kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_sharedmem_init. Return value %B\n", status ); return (status); } shmem->numapertures = config.numapertures; for (i = 0; i < shmem->numapertures; i++) { aperture_id = config.apertures[i].id; channel_id = config.apertures[i].channel; hostbaseaddr = config.apertures[i].hostbase; gpubaseaddr = config.apertures[i].gpubase; sizebytes = config.apertures[i].sizebytes; mmu_virtualized = 0; // handle mmu virtualized aperture if (aperture_id == GSL_APERTURE_MMU) { mmu_virtualized = 1; aperture_id = GSL_APERTURE_EMEM; } // make sure aligned to page size DEBUG_ASSERT((gpubaseaddr & ((1 << GSL_PAGESIZE_SHIFT) - 1)) == 0); // make a multiple of page size sizebytes = (sizebytes & ~((1 << GSL_PAGESIZE_SHIFT) - 1)); if (sizebytes > 0) { shmem->apertures[i].memarena = kgsl_memarena_create(aperture_id, mmu_virtualized, hostbaseaddr, gpubaseaddr, sizebytes); if (!shmem->apertures[i].memarena) { kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_ERROR, "ERROR: Unable to allocate memarena.\n" ); kgsl_sharedmem_close(shmem); kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_sharedmem_init. Return value %B\n", GSL_FAILURE ); return (GSL_FAILURE); } shmem->apertures[i].id = aperture_id; shmem->apertures[i].channel = channel_id; shmem->apertures[i].numbanks = 1; // create aperture lookup table if (GSL_SHMEM_APERTURE_ISMARKED(aperture_id)) { // update "current aperture_id"/"current channel_id" index shmem->aperturelookup[aperture_id][channel_id] = i; } else { // initialize "current aperture_id"/"channel_id" indexes for (channel_id = GSL_CHANNEL_1; channel_id < GSL_CHANNEL_MAX; channel_id++) { shmem->aperturelookup[aperture_id][channel_id] = i; } GSL_SHMEM_APERTURE_MARK(aperture_id); } } } shmem->flags |= GSL_FLAGS_INITIALIZED; kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_sharedmem_init. Return value %B\n", GSL_SUCCESS ); return (GSL_SUCCESS); }