diff mbox series

[21/21] drm/nouveau/nvkm: s/nouveau/nvkm/ over code moved from drm

Message ID 20240613170046.88687-22-bskeggs@nvidia.com (mailing list archive)
State New
Headers show
Series drm/nouveau: insert auxiliary device between nvkm and drm | expand

Commit Message

Ben Skeggs June 13, 2024, 5 p.m. UTC
The move and renames were kept separate for cleaner diffs.

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
---
 drivers/gpu/drm/nouveau/nvkm/device/acpi.c  | 113 ++++++++++----------
 drivers/gpu/drm/nouveau/nvkm/device/acpi.h  |   4 +-
 drivers/gpu/drm/nouveau/nvkm/device/pci.c   |   8 +-
 drivers/gpu/drm/nouveau/nvkm/device/tegra.c |   6 +-
 4 files changed, 64 insertions(+), 67 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/nouveau/nvkm/device/acpi.c b/drivers/gpu/drm/nouveau/nvkm/device/acpi.c
index c4cbdf172499..ff8a3027c1bc 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/acpi.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/acpi.c
@@ -32,9 +32,9 @@ 
 #include <linux/vga_switcheroo.h>
 
 #ifdef CONFIG_VGA_SWITCHEROO
-struct nouveau_dsm_priv nouveau_dsm_priv = {};
+struct nvkm_dsm_priv nvkm_dsm_priv = {};
 
-static const guid_t nouveau_op_dsm_muid =
+static const guid_t nvkm_op_dsm_muid =
 	GUID_INIT(0xA486D8F8, 0x0BDA, 0x471B,
 		  0xA7, 0x2B, 0x60, 0x42, 0xA6, 0xB5, 0xBE, 0xE0);
 
@@ -60,7 +60,7 @@  static const guid_t nouveau_op_dsm_muid =
 #define OPTIMUS_AUDIO_CAPS_MASK (3 << 27)
 #define OPTIMUS_HDA_CODEC_MASK (2 << 27) /* hda bios control */
 
-static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t *result)
+static int nvkm_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t *result)
 {
 	int i;
 	union acpi_object *obj;
@@ -76,7 +76,7 @@  static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t *
 		args_buff[i] = (arg >> i * 8) & 0xFF;
 
 	*result = 0;
-	obj = acpi_evaluate_dsm_typed(handle, &nouveau_op_dsm_muid, 0x00000100,
+	obj = acpi_evaluate_dsm_typed(handle, &nvkm_op_dsm_muid, 0x00000100,
 				      func, &argv4, ACPI_TYPE_BUFFER);
 	if (!obj) {
 		acpi_handle_info(handle, "failed to evaluate _DSM\n");
@@ -98,24 +98,24 @@  static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t *
 void nvkm_acpi_switcheroo_set_powerdown(void)
 {
 	u32 result = 0;
-	if (!nouveau_dsm_priv.optimus_detected || nouveau_dsm_priv.optimus_skip_dsm)
+	if (!nvkm_dsm_priv.optimus_detected || nvkm_dsm_priv.optimus_skip_dsm)
 		return;
 
-	if (nouveau_dsm_priv.optimus_flags_detected)
-		nouveau_optimus_dsm(nouveau_dsm_priv.dhandle, NOUVEAU_DSM_OPTIMUS_FLAGS,
-				    0x3, &result);
+	if (nvkm_dsm_priv.optimus_flags_detected)
+		nvkm_optimus_dsm(nvkm_dsm_priv.dhandle, NOUVEAU_DSM_OPTIMUS_FLAGS,
+				 0x3, &result);
 
-	nouveau_optimus_dsm(nouveau_dsm_priv.dhandle, NOUVEAU_DSM_OPTIMUS_CAPS,
-		NOUVEAU_DSM_OPTIMUS_SET_POWERDOWN, &result);
+	nvkm_optimus_dsm(nvkm_dsm_priv.dhandle, NOUVEAU_DSM_OPTIMUS_CAPS,
+			 NOUVEAU_DSM_OPTIMUS_SET_POWERDOWN, &result);
 
 }
 
 /*
- * On some platforms, _DSM(nouveau_op_dsm_muid, func0) has special
+ * On some platforms, _DSM(nvkm_op_dsm_muid, func0) has special
  * requirements on the fourth parameter, so a private implementation
  * instead of using acpi_check_dsm().
  */
-static int nouveau_dsm_get_optimus_functions(acpi_handle handle)
+static int nvkm_dsm_get_optimus_functions(acpi_handle handle)
 {
 	int result;
 
@@ -123,7 +123,7 @@  static int nouveau_dsm_get_optimus_functions(acpi_handle handle)
 	 * Function 0 returns a Buffer containing available functions.
 	 * The args parameter is ignored for function 0, so just put 0 in it
 	 */
-	if (nouveau_optimus_dsm(handle, 0, 0, &result))
+	if (nvkm_optimus_dsm(handle, 0, 0, &result))
 		return 0;
 
 	/*
@@ -135,7 +135,7 @@  static int nouveau_dsm_get_optimus_functions(acpi_handle handle)
 	return 0;
 }
 
-static const guid_t nouveau_dsm_muid =
+static const guid_t nvkm_dsm_muid =
 	GUID_INIT(0x9D95A0A0, 0x0060, 0x4D48,
 		  0xB3, 0x4D, 0x7E, 0x5F, 0xEA, 0x12, 0x9F, 0xD4);
 
@@ -150,7 +150,7 @@  static const guid_t nouveau_dsm_muid =
 #define NOUVEAU_DSM_POWER_SPEED 0x01
 #define NOUVEAU_DSM_POWER_STAMINA 0x02
 
-static int nouveau_dsm(acpi_handle handle, int func, int arg)
+static int nvkm_dsm(acpi_handle handle, int func, int arg)
 {
 	int ret = 0;
 	union acpi_object *obj;
@@ -159,7 +159,7 @@  static int nouveau_dsm(acpi_handle handle, int func, int arg)
 		.integer.value = arg,
 	};
 
-	obj = acpi_evaluate_dsm_typed(handle, &nouveau_dsm_muid, 0x00000102,
+	obj = acpi_evaluate_dsm_typed(handle, &nvkm_dsm_muid, 0x00000102,
 				      func, &argv4, ACPI_TYPE_INTEGER);
 	if (!obj) {
 		acpi_handle_info(handle, "failed to evaluate _DSM\n");
@@ -173,21 +173,21 @@  static int nouveau_dsm(acpi_handle handle, int func, int arg)
 	return ret;
 }
 
-static int nouveau_dsm_switch_mux(acpi_handle handle, int mux_id)
+static int nvkm_dsm_switch_mux(acpi_handle handle, int mux_id)
 {
 	mxm_wmi_call_mxmx(mux_id == NOUVEAU_DSM_LED_STAMINA ? MXM_MXDS_ADAPTER_IGD : MXM_MXDS_ADAPTER_0);
 	mxm_wmi_call_mxds(mux_id == NOUVEAU_DSM_LED_STAMINA ? MXM_MXDS_ADAPTER_IGD : MXM_MXDS_ADAPTER_0);
-	return nouveau_dsm(handle, NOUVEAU_DSM_LED, mux_id);
+	return nvkm_dsm(handle, NOUVEAU_DSM_LED, mux_id);
 }
 
-static int nouveau_dsm_set_discrete_state(acpi_handle handle, enum vga_switcheroo_state state)
+static int nvkm_dsm_set_discrete_state(acpi_handle handle, enum vga_switcheroo_state state)
 {
 	int arg;
 	if (state == VGA_SWITCHEROO_ON)
 		arg = NOUVEAU_DSM_POWER_SPEED;
 	else
 		arg = NOUVEAU_DSM_POWER_STAMINA;
-	nouveau_dsm(handle, NOUVEAU_DSM_POWER, arg);
+	nvkm_dsm(handle, NOUVEAU_DSM_POWER, arg);
 	return 0;
 }
 
@@ -206,7 +206,7 @@  nvkm_acpi_switcheroo_set_state(struct pci_dev *pdev,
 	struct nvkm_device *device = pci_get_drvdata(pdev);
 
 	if (state == VGA_SWITCHEROO_OFF) {
-		if (nouveau_dsm_priv.dsm_detected || nouveau_dsm_priv.optimus_detected)
+		if (nvkm_dsm_priv.dsm_detected || nvkm_dsm_priv.optimus_detected)
 			return;
 
 		nvkm_acpi_switcheroo_set_powerdown();
@@ -230,31 +230,31 @@  nvkm_acpi_switcheroo_ops = {
 	.reprobe = nvkm_acpi_switcheroo_reprobe,
 };
 
-static int nouveau_dsm_switchto(enum vga_switcheroo_client_id id)
+static int nvkm_dsm_switchto(enum vga_switcheroo_client_id id)
 {
-	if (!nouveau_dsm_priv.dsm_detected)
+	if (!nvkm_dsm_priv.dsm_detected)
 		return 0;
 	if (id == VGA_SWITCHEROO_IGD)
-		return nouveau_dsm_switch_mux(nouveau_dsm_priv.dhandle, NOUVEAU_DSM_LED_STAMINA);
+		return nvkm_dsm_switch_mux(nvkm_dsm_priv.dhandle, NOUVEAU_DSM_LED_STAMINA);
 	else
-		return nouveau_dsm_switch_mux(nouveau_dsm_priv.dhandle, NOUVEAU_DSM_LED_SPEED);
+		return nvkm_dsm_switch_mux(nvkm_dsm_priv.dhandle, NOUVEAU_DSM_LED_SPEED);
 }
 
-static int nouveau_dsm_power_state(enum vga_switcheroo_client_id id,
+static int nvkm_dsm_power_state(enum vga_switcheroo_client_id id,
 				   enum vga_switcheroo_state state)
 {
 	if (id == VGA_SWITCHEROO_IGD)
 		return 0;
 
 	/* Optimus laptops have the card already disabled in
-	 * nouveau_switcheroo_set_state */
-	if (!nouveau_dsm_priv.dsm_detected)
+	 * nvkm_switcheroo_set_state */
+	if (!nvkm_dsm_priv.dsm_detected)
 		return 0;
 
-	return nouveau_dsm_set_discrete_state(nouveau_dsm_priv.dhandle, state);
+	return nvkm_dsm_set_discrete_state(nvkm_dsm_priv.dhandle, state);
 }
 
-static enum vga_switcheroo_client_id nouveau_dsm_get_client_id(struct pci_dev *pdev)
+static enum vga_switcheroo_client_id nvkm_dsm_get_client_id(struct pci_dev *pdev)
 {
 	/* easy option one - intel vendor ID means Integrated */
 	if (pdev->vendor == PCI_VENDOR_ID_INTEL)
@@ -267,15 +267,15 @@  static enum vga_switcheroo_client_id nouveau_dsm_get_client_id(struct pci_dev *p
 	return VGA_SWITCHEROO_DIS;
 }
 
-static const struct vga_switcheroo_handler nouveau_dsm_handler = {
-	.switchto = nouveau_dsm_switchto,
-	.power_state = nouveau_dsm_power_state,
-	.get_client_id = nouveau_dsm_get_client_id,
+static const struct vga_switcheroo_handler nvkm_dsm_handler = {
+	.switchto = nvkm_dsm_switchto,
+	.power_state = nvkm_dsm_power_state,
+	.get_client_id = nvkm_dsm_get_client_id,
 };
 
-static void nouveau_dsm_pci_probe(struct pci_dev *pdev, acpi_handle *dhandle_out,
-				  bool *has_mux, bool *has_opt,
-				  bool *has_opt_flags, bool *has_pr3)
+static void nvkm_dsm_pci_probe(struct pci_dev *pdev, acpi_handle *dhandle_out,
+			       bool *has_mux, bool *has_opt,
+			       bool *has_opt_flags, bool *has_pr3)
 {
 	acpi_handle dhandle;
 	bool supports_mux;
@@ -301,9 +301,9 @@  static void nouveau_dsm_pci_probe(struct pci_dev *pdev, acpi_handle *dhandle_out
 	if (!acpi_has_method(dhandle, "_DSM"))
 		return;
 
-	supports_mux = acpi_check_dsm(dhandle, &nouveau_dsm_muid, 0x00000102,
+	supports_mux = acpi_check_dsm(dhandle, &nvkm_dsm_muid, 0x00000102,
 				      1 << NOUVEAU_DSM_POWER);
-	optimus_funcs = nouveau_dsm_get_optimus_functions(dhandle);
+	optimus_funcs = nvkm_dsm_get_optimus_functions(dhandle);
 
 	/* Does not look like a Nvidia device. */
 	if (!supports_mux && !optimus_funcs)
@@ -316,8 +316,7 @@  static void nouveau_dsm_pci_probe(struct pci_dev *pdev, acpi_handle *dhandle_out
 
 	if (optimus_funcs) {
 		uint32_t result;
-		nouveau_optimus_dsm(dhandle, NOUVEAU_DSM_OPTIMUS_CAPS, 0,
-				    &result);
+		nvkm_optimus_dsm(dhandle, NOUVEAU_DSM_OPTIMUS_CAPS, 0, &result);
 		dev_info(&pdev->dev, "optimus capabilities: %s, status %s%s\n",
 			 (result & OPTIMUS_ENABLED) ? "enabled" : "disabled",
 			 (result & OPTIMUS_DYNAMIC_PWR_CAP) ? "dynamic power, " : "",
@@ -325,7 +324,7 @@  static void nouveau_dsm_pci_probe(struct pci_dev *pdev, acpi_handle *dhandle_out
 	}
 }
 
-static bool nouveau_dsm_detect(void)
+static bool nvkm_dsm_detect(void)
 {
 	char acpi_method_name[255] = { 0 };
 	struct acpi_buffer buffer = {sizeof(acpi_method_name), acpi_method_name};
@@ -353,30 +352,28 @@  static bool nouveau_dsm_detect(void)
 
 		vga_count++;
 
-		nouveau_dsm_pci_probe(pdev, &dhandle, &has_mux, &has_optimus,
-				      &has_optimus_flags, &has_power_resources);
+		nvkm_dsm_pci_probe(pdev, &dhandle, &has_mux, &has_optimus,
+				   &has_optimus_flags, &has_power_resources);
 	}
 
 	/* find the optimus DSM or the old v1 DSM */
 	if (has_optimus) {
-		nouveau_dsm_priv.dhandle = dhandle;
-		acpi_get_name(nouveau_dsm_priv.dhandle, ACPI_FULL_PATHNAME,
-			&buffer);
+		nvkm_dsm_priv.dhandle = dhandle;
+		acpi_get_name(nvkm_dsm_priv.dhandle, ACPI_FULL_PATHNAME, &buffer);
 		pr_info("VGA switcheroo: detected Optimus DSM method %s handle\n",
 			acpi_method_name);
 		if (has_power_resources)
-			pr_info("nouveau: detected PR support, will not use DSM\n");
-		nouveau_dsm_priv.optimus_detected = true;
-		nouveau_dsm_priv.optimus_flags_detected = has_optimus_flags;
-		nouveau_dsm_priv.optimus_skip_dsm = has_power_resources;
+			pr_info("nvkm: detected PR support, will not use DSM\n");
+		nvkm_dsm_priv.optimus_detected = true;
+		nvkm_dsm_priv.optimus_flags_detected = has_optimus_flags;
+		nvkm_dsm_priv.optimus_skip_dsm = has_power_resources;
 		ret = true;
 	} else if (vga_count == 2 && has_mux && guid_valid) {
-		nouveau_dsm_priv.dhandle = dhandle;
-		acpi_get_name(nouveau_dsm_priv.dhandle, ACPI_FULL_PATHNAME,
-			&buffer);
+		nvkm_dsm_priv.dhandle = dhandle;
+		acpi_get_name(nvkm_dsm_priv.dhandle, ACPI_FULL_PATHNAME, &buffer);
 		pr_info("VGA switcheroo: detected DSM switching method %s handle\n",
 			acpi_method_name);
-		nouveau_dsm_priv.dsm_detected = true;
+		nvkm_dsm_priv.dsm_detected = true;
 		ret = true;
 	}
 
@@ -387,7 +384,7 @@  static bool nouveau_dsm_detect(void)
 void
 nvkm_acpi_switcheroo_fini(void)
 {
-	if (nouveau_dsm_priv.optimus_detected || nouveau_dsm_priv.dsm_detected)
+	if (nvkm_dsm_priv.optimus_detected || nvkm_dsm_priv.dsm_detected)
 		vga_switcheroo_unregister_handler();
 }
 
@@ -396,11 +393,11 @@  nvkm_acpi_switcheroo_init(void)
 {
 	bool r;
 
-	r = nouveau_dsm_detect();
+	r = nvkm_dsm_detect();
 	if (!r)
 		return;
 
-	vga_switcheroo_register_handler(&nouveau_dsm_handler, 0);
+	vga_switcheroo_register_handler(&nvkm_dsm_handler, 0);
 }
 #endif
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/acpi.h b/drivers/gpu/drm/nouveau/nvkm/device/acpi.h
index 34854d10026d..2dd8a3029b55 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/acpi.h
+++ b/drivers/gpu/drm/nouveau/nvkm/device/acpi.h
@@ -8,13 +8,13 @@  void nvkm_acpi_init(struct nvkm_device *);
 void nvkm_acpi_fini(struct nvkm_device *);
 
 #ifdef CONFIG_VGA_SWITCHEROO
-extern struct nouveau_dsm_priv {
+extern struct nvkm_dsm_priv {
 	bool dsm_detected;
 	bool optimus_detected;
 	bool optimus_flags_detected;
 	bool optimus_skip_dsm;
 	acpi_handle dhandle;
-} nouveau_dsm_priv;
+} nvkm_dsm_priv;
 
 void nvkm_acpi_switcheroo_init(void);
 void nvkm_acpi_switcheroo_fini(void);
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/pci.c b/drivers/gpu/drm/nouveau/nvkm/device/pci.c
index 735bf0a9931d..8eb3a66f53d6 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/pci.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/pci.c
@@ -1720,8 +1720,8 @@  nvkm_device_pci_remove(struct pci_dev *dev)
  *    to handle well enough.
  *
  * In all cases dmesg will contain at least one line like this:
- * 'nouveau 0000:01:00.0: Refused to change power state, currently in D3'
- * followed by a lot of nouveau timeouts.
+ * 'nvkm 0000:01:00.0: Refused to change power state, currently in D3'
+ * followed by a lot of nvkm timeouts.
  *
  * In the \_SB.PCI0.PEG0.PG00._OFF code deeper down writes bit 0x80 to the not
  * documented PCI config space register 0x248 of the Intel PCIe bridge
@@ -1849,8 +1849,8 @@  nvkm_device_pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
 	pci_set_drvdata(pci_dev, &pdev->device);
 
 	if (nvkm_runpm) {
-		if (!nouveau_dsm_priv.optimus_detected) {
-			if (nouveau_dsm_priv.dsm_detected)
+		if (!nvkm_dsm_priv.optimus_detected) {
+			if (nvkm_dsm_priv.dsm_detected)
 				device->runpm = NVKM_DEVICE_RUNPM_V1;
 		} else {
 			device->runpm = NVKM_DEVICE_RUNPM_OPTIMUS;
diff --git a/drivers/gpu/drm/nouveau/nvkm/device/tegra.c b/drivers/gpu/drm/nouveau/nvkm/device/tegra.c
index 743a781586c0..75ce47f25e19 100644
--- a/drivers/gpu/drm/nouveau/nvkm/device/tegra.c
+++ b/drivers/gpu/drm/nouveau/nvkm/device/tegra.c
@@ -351,7 +351,7 @@  static const struct nvkm_device_tegra_func gp10b_platform_data = {
 	.require_vdd = false,
 };
 
-static const struct of_device_id nouveau_platform_match[] = {
+static const struct of_device_id nvkm_platform_match[] = {
 	{
 		.compatible = "nvidia,gk20a",
 		.data = &gk20a_platform_data,
@@ -371,13 +371,13 @@  struct platform_driver
 nvkm_device_tegra = {
 	.driver = {
 		.name = "nvkm",
-		.of_match_table = of_match_ptr(nouveau_platform_match),
+		.of_match_table = of_match_ptr(nvkm_platform_match),
 	},
 	.probe = nvkm_device_tegra_probe,
 	.remove_new = nvkm_device_tegra_remove,
 };
 
-MODULE_DEVICE_TABLE(of, nouveau_platform_match);
+MODULE_DEVICE_TABLE(of, nvkm_platform_match);
 #else
 struct platform_driver
 nvkm_device_tegra = {