struct msm_gpu *adreno_load_gpu(struct drm_device *dev) { struct msm_drm_private *priv = dev->dev_private; struct platform_device *pdev = priv->gpu_pdev; struct msm_gpu *gpu = NULL; int ret; if (pdev) gpu = platform_get_drvdata(pdev); if (!gpu) { dev_err_once(dev->dev, "no GPU device was found\n"); return NULL; } pm_runtime_get_sync(&pdev->dev); mutex_lock(&dev->struct_mutex); ret = msm_gpu_hw_init(gpu); mutex_unlock(&dev->struct_mutex); pm_runtime_put_sync(&pdev->dev); if (ret) { dev_err(dev->dev, "gpu hw init failed: %d\n", ret); return NULL; } return gpu; }
struct msm_gpu *adreno_load_gpu(struct drm_device *dev) { struct msm_drm_private *priv = dev->dev_private; struct platform_device *pdev = priv->gpu_pdev; struct adreno_platform_config *config; struct adreno_rev rev; const struct adreno_info *info; struct msm_gpu *gpu = NULL; if (!pdev) { dev_err(dev->dev, "no adreno device\n"); return NULL; } config = pdev->dev.platform_data; rev = config->rev; info = adreno_info(config->rev); if (!info) { dev_warn(dev->dev, "Unknown GPU revision: %u.%u.%u.%u\n", rev.core, rev.major, rev.minor, rev.patchid); return NULL; } DBG("Found GPU: %u.%u.%u.%u", rev.core, rev.major, rev.minor, rev.patchid); gpu = info->init(dev); if (IS_ERR(gpu)) { dev_warn(dev->dev, "failed to load adreno gpu\n"); gpu = NULL; /* not fatal */ } if (gpu) { int ret; pm_runtime_get_sync(&pdev->dev); mutex_lock(&dev->struct_mutex); ret = msm_gpu_hw_init(gpu); mutex_unlock(&dev->struct_mutex); pm_runtime_put_sync(&pdev->dev); if (ret) { dev_err(dev->dev, "gpu hw init failed: %d\n", ret); gpu->funcs->destroy(gpu); gpu = NULL; } } return gpu; }
void adreno_recover(struct msm_gpu *gpu) { struct drm_device *dev = gpu->dev; int ret; // XXX pm-runtime?? we *need* the device to be off after this // so maybe continuing to call ->pm_suspend/resume() is better? gpu->funcs->pm_suspend(gpu); gpu->funcs->pm_resume(gpu); ret = msm_gpu_hw_init(gpu); if (ret) { dev_err(dev->dev, "gpu hw init failed: %d\n", ret); /* hmm, oh well? */ } }