drm/hyperv: Use "hv_drm_" as symbol name prefix
Subsystems (5)
PATCH v3 1/1 drm/hyperv: Use "hv_drm_" as symbol name prefix
From: Michael Kelley <[email protected]>
Function and structure names in the Hyper-V DRM driver currently use "hyperv_" as the prefix. This conflicts with usage in core Hyper-V and VMBus code, and incorrectly implies that functions and structures in this driver apply generically to Hyper-V. A specific conflict arises for "hyperv_init", which is an initcall for generic Hyper-V initialization on arm64. The conflict prevents the use of initcall_blacklist on the kernel boot line to skip loading this driver.
Fix this by substituting "hv_drm_" as the prefix for all functions and structures in this driver. In most places, this is replacing "hyperv_" with "hv_drm_". In a few places, the substitution results in "hv_drm_drm_", which has been collapsed to just "hv_drm_". In two cases, the existing prefix is a bare "hv" (including in the to_hv() macro), which has been replaced with "hv_drm" for consistency.
The changes are all mechanical text substitution in symbol names. There are no other code or functional changes.
---
This patch is built against linux-next20260526.
Changes in v3:
* Also s/to_hv/to_hv_drm/ since the to_hv() macro is essentially referencing the prefix. [Dexuan Cui]
Changes in v2:
* Use "hv_drm_" as the new prefix instead of "hvdrm_". [Hamza Mahfooz]
* After the new prefix is applied, collapse occurrences of "hv_drm_drm_" to just "hv_drm_", such as with hv_drm_device. [Hamza Mahfooz]
* Don't change comments referring to source code filenames. [Dexuan Cui]
* Change hv_fops to hv_drm_fops for consistency.
drivers/gpu/drm/hyperv/hyperv_drm.h | 16 +-- drivers/gpu/drm/hyperv/hyperv_drm_drv.c | 92 ++++++++-------- drivers/gpu/drm/hyperv/hyperv_drm_modeset.c | 110 ++++++++++---------- drivers/gpu/drm/hyperv/hyperv_drm_proto.c | 70 ++++++------- 4 files changed, 144 insertions(+), 144 deletions(-)
drivers/gpu/drm/hyperv/hyperv_drm.h +8 -8
@@ -8,7 +8,7 @@#define VMBUS_MAX_PACKET_SIZE 0x4000 -struct hyperv_drm_device { +struct hv_drm_device {/* drm */ struct drm_device dev;struct drm_plane plane;
@@ -39,17 +39,17 @@ struct hyperv_drm_device { struct hv_device *hdev; }; -#define to_hv (_dev) container_of(_dev, struct hyperv_drm_device, dev) +#define to_hv_drm (_dev) container_of(_dev, struct hv_drm_device, dev)/* hyperv_drm_modeset */ -int hyperv_mode_config_init (struct hyperv_drm_device *hv); +int hv_drm_mode_config_init (struct hv_drm_device *hv);/* hyperv_drm_proto */ -int hyperv_update_vram_location (struct hv_device *hdev,phys_addr_t vram_pp); -int hyperv_update_situation (struct hv_device *hdev,u8 active,u32 bpp, +int hv_drm_update_vram_location (struct hv_device *hdev,phys_addr_t vram_pp); +int hv_drm_update_situation (struct hv_device *hdev,u8 active,u32 bpp,u32 w,u32 h,u32 pitch); -int hyperv_hide_hw_ptr (struct hv_device *hdev); -int hyperv_update_dirt (struct hv_device *hdev,struct drm_rect *rect); -int hyperv_connect_vsp (struct hv_device *hdev); +int hv_drm_hide_hw_ptr (struct hv_device *hdev); +int hv_drm_update_dirt (struct hv_device *hdev,struct drm_rect *rect); +int hv_drm_connect_vsp (struct hv_device *hdev);#endif
drivers/gpu/drm/hyperv/hyperv_drm_drv.c +46 -46
221 lines not on this page · raw message
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c +55 -55
280 lines not on this page · raw message
drivers/gpu/drm/hyperv/hyperv_drm_proto.c +35 -35
220 lines not on this page · raw message
Signature · 1 line
2.25.1
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing cleanup of PCI driver on VMBus registration failure in module init.
- [High] Flawed synchronous VMBus message handling: missing reinit_completion() and ignored send errors. --
commit a50bc353055fe2753b3f284aeec394019513c888
Author: Michael Kelley <[email protected]>
Subject: drm/hyperv: Use "hv_drm_" as symbol name prefix
This commit mechanically substitutes the "hyperv_" prefix with "hv_drm_" for all functions and structures in the Hyper-V DRM driver. This avoids namespace conflicts with generic Hyper-V initialization code.
Quoted 4 lines
drivers/gpu/drm/hyperv/hyperv_drm_drv.c +0
-0
[ ... ]
Quoted 6 lines
drivers/gpu/drm/hyperv/hyperv_drm_drv.c +1
-1-static int __init hyperv_init (void ) +static int __init hv_drm_init (void ) {int ret;if (drm_firmware_drivers_only ())
drivers/gpu/drm/hyperv/hyperv_drm_drv.c static int hyperv_vmbus_suspend(struct hv_device *hdev) · line 253
Quoted 10 lines
drivers/gpu/drm/hyperv/hyperv_drm_drv.c +2
-2return -ENODEV ; - ret =pci_register_driver (&hyperv_pci_driver); + ret =pci_register_driver (&hv_drm_pci_driver);if (ret !=0 )return ret; -return vmbus_driver_register (&hyperv_hv_driver); +return vmbus_driver_register (&hv_drm_hv_driver); }
[Severity: High]
This is a pre-existing issue, but if vmbus_driver_register() fails, does this leave the PCI driver registered while the module initialization fails?
If the module initialization returns an error and the kernel frees the module's memory, the PCI subsystem might retain a dangling pointer to the freed hv_drm_pci_driver structure. Could this lead to a kernel panic or use-after-free if the PCI driver list is traversed later?
Quoted 4 lines
drivers/gpu/drm/hyperv/hyperv_drm_proto.c +0
-0
[ ... ]
Quoted 9 lines
drivers/gpu/drm/hyperv/hyperv_drm_proto.c +2
-2-static int hyperv_negotiate_version (struct hv_device *hdev,u32 ver) +static int hv_drm_negotiate_version (struct hv_device *hdev,u32 ver) { -struct hyperv_drm_device *hv =hv_get_drvdata (hdev); +struct hv_drm_device *hv =hv_get_drvdata (hdev);struct synthvid_msg *msg = (struct synthvid_msg *)hv->init_buf;struct drm_device *dev = &hv->dev;unsigned long t;
drivers/gpu/drm/hyperv/hyperv_drm_proto.c static int hyperv_negotiate_version(struct hv_device *hdev, u32 ver) · line 228
Quoted 7 lines
drivers/gpu/drm/hyperv/hyperv_drm_proto.c +1
-1@@ -223,7 +223,7 @@ static int hyperv_negotiate_version(struct hv_device *hdev, u32 ver) msg->vid_hdr.size =sizeof (struct synthvid_msg_hdr ) +sizeof (struct synthvid_version_req ); msg->ver_req.version = ver; -hyperv_sendpacket (hdev, msg); +hv_drm_sendpacket (hdev, msg); t =wait_for_completion_timeout (&hv->wait,VMBUS_VSP_TIMEOUT );
[Severity: High]
This isn't a bug introduced by this patch, but since the driver only initializes the completion once during probe, is it possible for it to become stale here?
If a previous request timed out and the host responds later, the completion could remain signaled. This would cause a subsequent request to immediately return from wait_for_completion_timeout() and process incorrect or stale data.
Should there be a call to reinit_completion() before sending the packet?
Additionally, since hv_drm_sendpacket() errors are ignored, does the driver unnecessarily hang in wait_for_completion_timeout() for the full timeout duration if the packet completely failed to send?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Hamza Mahfooz
AppliedQuoted 17 lines · Michael Kelley
From: Michael Kelley <[email protected]>
Function and structure names in the Hyper-V DRM driver currently use "
hyperv_" as the prefix. This conflicts with usage in core Hyper-V and VMBus code, and incorrectly implies that functions and structures in this driver apply generically to Hyper-V. A specific conflict arises for "hyperv_init", which is an initcall for generic Hyper-V initialization on arm64. The conflict prevents the use ofinitcall_blackliston the kernel boot line to skip loading this driver.Fix this by substituting "
hv_drm_" as the prefix for all functions and structures in this driver. In most places, this is replacing "hyperv_" with "hv_drm_". In a few places, the substitution results in "hv_drm_drm_", which has been collapsed to just "hv_drm_". In two cases, the existing prefix is a bare "hv" (including in theto_hv()macro), which has been replaced with "hv_drm" for consistency.
Quoted 5 lines
The changes are all mechanical text substitution in symbol names. There are no other code or functional changes.
Signed-off-by Michael Kelley <[email protected]>Reviewed-by Dexuan Cui <[email protected]>
Applied, thanks!