adreno源码系列(五)打开kgsl

本文详细解析Adreno GPU驱动的启动过程,包括设备打开、初始化等关键步骤,并深入探讨了a6xx系列GPU特有的启动流程和技术实现。
// 接"adreno源码系列(二)kgsl driver"中第3.3节
static int kgsl_open_device(struct kgsl_device *device)
{
   
   
	int result = 0;

	mutex_lock(&device->mutex);
    // kgsl_device->open_count记录/dev/kgsl-3d0被open的次数
	if (device->open_count == 0) {
   
   
        // 如果是第一次打开, 则调用adreno_functable中定义的adreno_first_open[见第1节]
		result = device->ftbl->first_open(device);
		if (result)
			goto out;
	}
    // /dev/kgsl-3d0每被打开一次, 增加1个对应的fd
	device->open_count++;
out:
	mutex_unlock(&device->mutex);
	return result;
}

1. adreno_first_open

static int adreno_first_open(struct kgsl_device *device)
{
   
   
	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
    // adreno_a6xx_gmu_gpudev中定义adreno_power_ops为a6xx_gmu_power_ops[见第2节]
	const struct adreno_power_ops *ops = ADRENO_POWER_OPS(adreno_dev);

    // 调用a6xx_gmu_power_ops定义的a6xx_gmu_first_open[见第3节]
	return ops->first_open(adreno_dev);
}

2. a6xx_gmu_power_ops

const struct adreno_power_ops a6xx_gmu_power_ops = {
   
   
    // 第一次打开
	.first_open = a6xx_gmu_first_open,
	.last_close = a6xx_gmu_last_close,
	.active_count_get = a6xx_gmu_active_count_get,
	.active_count_put = a6xx_gmu_active_count_put,
	.pm_suspend = a6xx_gmu_pm_suspend,
	.pm_resume = a6xx_gmu_pm_resume,
	.touch_wakeup = a6xx_gmu_touch_wakeup,
	.gpu_clock_set = a6xx_gmu_clock_set,
	.gpu_bus_set = a6xx_gmu_bus_set,
};

3. a6xx_gmu_first_open

static int a6xx_gmu_first_open(struct adreno_device *adreno_dev)
{
   
   
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	int ret;

	/*
	 * Do the one time settings that need to happen when we
	 * attempt to boot the gpu the very first time
	 */
    // a6xx第一次启动[见3.1节]
	ret = a6xx_first_boot(adreno_dev);
	if (ret)
		return ret;

	/*
	 * A client that does a first_open but never closes the device
	 * may prevent us from going back to SLUMBER. So trigger the idle
	 * check by incrementing the active count and immediately releasing it.
	 */
	atomic_inc(&device->active_cnt);
	a6xx_gmu_active_count_put(adreno_dev);

	return 0;
}

3.1 a6xx_first_boot

static int a6xx_first_boot(struct adreno_device *adreno_dev)
{
   
   
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct a6xx_gmu_device *gmu = to_a6xx_gmu(adreno_dev);
	int ret;
	
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值