Преглед изворни кода

msm: cvp: Avoid racing in bw voting

when SSR is releasing core and some clients voting for bus.

Change-Id: I8575d747c17f234bbce216c346843ab07ea6b340
Signed-off-by: George Shen <[email protected]>
George Shen пре 1 година
родитељ
комит
1741a5b55c
5 измењених фајлова са 27 додато и 10 уклоњено
  1. 4 5
      msm/eva/cvp_hfi.c
  2. 1 2
      msm/eva/cvp_hfi_api.h
  3. 1 1
      msm/eva/cvp_power.c
  4. 18 1
      msm/eva/msm_cvp_clocks.c
  5. 3 1
      msm/eva/msm_cvp_clocks.h

+ 4 - 5
msm/eva/cvp_hfi.c

@@ -911,7 +911,7 @@ static int __unvote_buses(struct iris_hfi_device *device)
 	device->bus_vote.data_count = 0;
 
 	iris_hfi_for_each_bus(device, bus) {
-		rc = msm_cvp_set_bw(bus, 0);
+		rc = cvp_set_bw(bus, 0);
 		if (rc) {
 			dprintk(CVP_ERR,
 			"%s: Failed unvoting bus\n", __func__);
@@ -952,7 +952,7 @@ no_data_count:
 
 	iris_hfi_for_each_bus(device, bus) {
 		if (bus) {
-			rc = msm_cvp_set_bw(bus, bus->range[1]);
+			rc = cvp_set_bw(bus, bus->range[1]);
 			if (rc)
 				dprintk(CVP_ERR,
 				"Failed voting bus %s to ab %u\n",
@@ -964,7 +964,7 @@ err_no_mem:
 	return rc;
 }
 
-static int iris_hfi_vote_buses(void *dev, struct cvp_bus_vote_data *d, int n)
+static int iris_hfi_vote_buses(void *dev, struct bus_info *bus, unsigned long bw)
 {
 	int rc = 0;
 	struct iris_hfi_device *device = dev;
@@ -973,11 +973,10 @@ static int iris_hfi_vote_buses(void *dev, struct cvp_bus_vote_data *d, int n)
 		return -EINVAL;
 
 	mutex_lock(&device->lock);
-	rc = __vote_buses(device, d, n);
+	rc = cvp_set_bw(bus, bw);
 	mutex_unlock(&device->lock);
 
 	return rc;
-
 }
 
 static int __core_set_resource(struct iris_hfi_device *device,

+ 1 - 2
msm/eva/cvp_hfi_api.h

@@ -265,8 +265,7 @@ struct cvp_hfi_device {
 	int (*session_send)(void *sess, struct eva_kmd_hfi_packet *in_pkt);
 	int (*session_flush)(void *sess);
 	int (*scale_clocks)(void *dev, u32 freq);
-	int (*vote_bus)(void *dev, struct cvp_bus_vote_data *data,
-			int num_data);
+	int (*vote_bus)(void *dev, struct bus_info *bus, unsigned long bw);
 	int (*get_fw_info)(void *dev, struct cvp_hal_fw_info *fw_info);
 	int (*session_clean)(void *sess);
 	int (*get_core_capabilities)(void *dev);

+ 1 - 1
msm/eva/cvp_power.c

@@ -257,7 +257,7 @@ int msm_cvp_update_power(struct msm_cvp_inst *inst)
 		core->curr_freq = core->orig_core_sum;
 		goto adjust_exit;
 	}
-	rc = msm_cvp_set_bw(bus, core->bw_sum);
+	rc = msm_cvp_set_bw(core, bus, core->bw_sum);
 
 adjust_exit:
 	cvp_put_inst(s);

+ 18 - 1
msm/eva/msm_cvp_clocks.c

@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include "msm_cvp_common.h"
@@ -458,7 +459,23 @@ void msm_cvp_deinit_clocks(struct iris_hfi_device *device)
 	}
 }
 
-int msm_cvp_set_bw(struct bus_info *bus, unsigned long bw)
+int msm_cvp_set_bw(struct msm_cvp_core *core, struct bus_info *bus, unsigned long bw)
+{
+	struct cvp_hfi_device *hdev;
+	int rc;
+
+	if (!core || !core->device) {
+		dprintk(CVP_ERR, "%s Invalid args: %pK\n", __func__, core);
+		return -EINVAL;
+	}
+
+	hdev = core->device;
+	rc = call_hfi_op(hdev, vote_bus, hdev->hfi_device_data, bus, bw);
+	return rc;
+
+}
+
+int cvp_set_bw(struct bus_info *bus, unsigned long bw)
 {
 	int rc = 0;
 

+ 3 - 1
msm/eva/msm_cvp_clocks.h

@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 
@@ -22,5 +23,6 @@ int msm_cvp_disable_unprepare_clk(struct iris_hfi_device *device,
 		const char *name);
 int msm_cvp_init_clocks(struct iris_hfi_device *device);
 void msm_cvp_deinit_clocks(struct iris_hfi_device *device);
-int msm_cvp_set_bw(struct bus_info *bus, unsigned long bw);
+int msm_cvp_set_bw(struct msm_cvp_core *core, struct bus_info *bus, unsigned long bw);
+int cvp_set_bw(struct bus_info *bus, unsigned long bw);
 #endif