Commit 6963d6c1 authored by Alex Deucher's avatar Alex Deucher
Browse files

drm/amdgpu: add a mutex for the smu11 i2c bus (v2)



So we lock software as well as hardware access to the bus.

v2: fix mutex handling.

Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Reviewed-by: default avatarLuben Tuikov <luben.tuikov@amd.com>
parent 93c5bcd4
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
@@ -584,11 +584,10 @@ static void lock_bus(struct i2c_adapter *i2c, unsigned int flags)
{
	struct amdgpu_device *adev = to_amdgpu_device(i2c);

	if (!smu_v11_0_i2c_bus_lock(i2c)) {
	mutex_lock(&adev->pm.smu_i2c_mutex);
	if (!smu_v11_0_i2c_bus_lock(i2c))
		DRM_ERROR("Failed to lock the bus from SMU");
		return;
	}

	else
		adev->pm.bus_locked = true;
}

@@ -602,12 +601,11 @@ static void unlock_bus(struct i2c_adapter *i2c, unsigned int flags)
{
	struct amdgpu_device *adev = to_amdgpu_device(i2c);

	if (!smu_v11_0_i2c_bus_unlock(i2c)) {
	if (!smu_v11_0_i2c_bus_unlock(i2c))
		DRM_ERROR("Failed to unlock the bus from SMU");
		return;
	}

	else
		adev->pm.bus_locked = false;
	mutex_unlock(&adev->pm.smu_i2c_mutex);
}

static const struct i2c_lock_operations smu_v11_0_i2c_i2c_lock_ops = {
@@ -665,6 +663,7 @@ int smu_v11_0_i2c_control_init(struct i2c_adapter *control)
	struct amdgpu_device *adev = to_amdgpu_device(control);
	int res;

	mutex_init(&adev->pm.smu_i2c_mutex);
	control->owner = THIS_MODULE;
	control->class = I2C_CLASS_SPD;
	control->dev.parent = &adev->pdev->dev;
+1 −0
Original line number Diff line number Diff line
@@ -450,6 +450,7 @@ struct amdgpu_pm {

	/* Used for I2C access to various EEPROMs on relevant ASICs */
	struct i2c_adapter smu_i2c;
	struct mutex		smu_i2c_mutex;
	struct list_head	pm_attr_list;
};