drm/amdgpu: save/restore part of xcp drm_device fields
Subsystems (3)
PATCH 1/3 drm/amdgpu: save/restore part of xcp drm_device fields
Redirect xcp allocated drm_device::rdev/pdev/driver with amdgpu pci_device/drm_device setting. They need be saved before redirect and restored after unregister xcp drm_device.
Signed-off-by James Zhu <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 16 ++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h | 4 ++++ 2 files changed, 18 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +14 -2
@@ -240,9 +240,14 @@ static int amdgpu_xcp_dev_alloc(struct amdgpu_device *adev)return PTR_ERR (p_ddev);/* Redirect all IOCTLs to the primary device */ + adev->xcp_mgr->xcp[i].rdev = p_ddev->render->dev; + adev->xcp_mgr->xcp[i].pdev = p_ddev->primary->dev; + adev->xcp_mgr->xcp[i].driver = p_ddev->driver; + adev->xcp_mgr->xcp[i].vma_offset_manager = p_ddev->vma_offset_manager; p_ddev->render->dev = ddev; p_ddev->primary->dev = ddev; p_ddev->vma_offset_manager = ddev->vma_offset_manager; + p_ddev->driver = &amdgpu_partition_driver; adev->xcp_mgr->xcp[i].ddev = p_ddev; }
@@ -330,13 +335,20 @@ int amdgpu_xcp_dev_register(struct amdgpu_device *adev,void amdgpu_xcp_dev_unplug (struct amdgpu_device *adev) { +struct drm_device *p_ddev;int i;if (!adev->xcp_mgr)return ; -for (i =0 ; i <MAX_XCP ; i++) -drm_dev_unplug (adev->xcp_mgr->xcp[i].ddev); +for (i =0 ; i <MAX_XCP ; i++) { + p_ddev = adev->xcp_mgr->xcp[i].ddev; +drm_dev_unplug (p_ddev); + p_ddev->render->dev = adev->xcp_mgr->xcp[i].rdev; + p_ddev->primary->dev = adev->xcp_mgr->xcp[i].pdev; + p_ddev->driver = adev->xcp_mgr->xcp[i].driver; + p_ddev->vma_offset_manager = adev->xcp_mgr->xcp[i].vma_offset_manager; + } } int amdgpu_xcp_open_device(struct amdgpu_device *adev,
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.h +4 -0
@@ -77,6 +77,10 @@ struct amdgpu_xcp {bool valid;atomic_t ref_cnt;struct drm_device *ddev; +struct drm_device *rdev; +struct drm_device *pdev; +struct drm_driver *driver; +struct drm_vma_offset_manager *vma_offset_manager;struct amdgpu_sched gpu_sched[AMDGPU_HW_IP_NUM ][AMDGPU_RING_PRIO_MAX ]; };
Signature · 1 line
2.34.1
PATCH 2/3 drm/amdxcp: add platform device driver for amdxcp
Add platform device driver for amdxcp to support
amdgpu spatial partition.
Signed-off-by James Zhu <[email protected]>
--- drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/amd/amdxcp/Makefile | 25 +++++ drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c | 108 ++++++++++++++++++++ drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.h | 29 ++++++ 4 files changed, 163 insertions(+) create mode 100644 drivers/gpu/drm/amd/amdxcp/Makefile create mode 100644 drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c create mode 100644 drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.h
drivers/gpu/drm/Makefile +1 -0
@@ -138,6 +138,7 @@ obj-$(CONFIG_DRM_TDFX) += tdfx/ obj-$(CONFIG_DRM_R128) += r128/ obj-$(CONFIG_DRM_RADEON)+= radeon/ obj-$(CONFIG_DRM_AMDGPU)+= amd/amdgpu/ +obj-$(CONFIG_DRM_AMDGPU)+= amd/amdxcp/ obj-$(CONFIG_DRM_MGA) += mga/ obj-$(CONFIG_DRM_I810) += i810/ obj-$(CONFIG_DRM_I915) += i915/
drivers/gpu/drm/amd/amdxcp/Makefile new file +25 -0
@@ -0,0 +1,25 @@ +# +# Copyright 2023 Advanced Micro Devices, Inc. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. +# + +amdgpu-y := amdgpu_xcp_drv.o + +obj-$(CONFIG_DRM_AMDGPU) += amdgpu_xcp_drv.o
drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c new file +108 -0
108 lines not on this page · raw message
drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Copyright 2023 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ + +#ifndef _AMDGPU_XCP_DRV_H_ +#define _AMDGPU_XCP_DRV_H_ + +int amdgpu_xcp_drm_dev_alloc (struct drm_device **ddev); +void amdgpu_xcp_drv_release (void ); +#endif /* _AMDGPU_XCP_DRV_H_ */
Signature · 1 line
2.34.1
PATCH 3/3 drm/amdgpu: use amdxcp platform device as spatial partition
In reply to James ZhuUse amdxcp platform device as spatial partition device.
Signed-off-by James Zhu <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -0
@@ -51,6 +51,7 @@#include "amdgpu_ras.h" #include "amdgpu_xgmi.h" #include "amdgpu_reset.h" +#include "../amdxcp/amdgpu_xcp_drv.h" /* * KMS wrapper.
@@ -2944,6 +2945,7 @@ static void __exit amdgpu_exit(void)amdgpu_sync_fini ();amdgpu_fence_slab_fini ();mmu_notifier_synchronize (); +amdgpu_xcp_drv_release (); }module_init (amdgpu_init);
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +6 -6
@@ -25,6 +25,7 @@#include "amdgpu_drv.h" #include <drm/drm_drv.h> +#include "../amdxcp/amdgpu_xcp_drv.h" static int __amdgpu_xcp_run (struct amdgpu_xcp_mgr *xcp_mgr,struct amdgpu_xcp_ip *xcp_ip,int xcp_state)
@@ -228,21 +229,20 @@ static int amdgpu_xcp_dev_alloc(struct amdgpu_device *adev)struct drm_device *p_ddev;struct pci_dev *pdev;struct drm_device *ddev; -int i; +int i, ret; pdev = adev->pdev; ddev =adev_to_drm (adev);for (i =0 ; i <MAX_XCP ; i++) { - p_ddev =drm_dev_alloc (&amdgpu_partition_driver, - &pci_upstream_bridge (pdev)->dev); -if (IS_ERR (p_ddev)) -return PTR_ERR (p_ddev); + ret =amdgpu_xcp_drm_dev_alloc (&p_ddev); +if (ret) +return ret;/* Redirect all IOCTLs to the primary device */ adev->xcp_mgr->xcp[i].rdev = p_ddev->render->dev; adev->xcp_mgr->xcp[i].pdev = p_ddev->primary->dev; - adev->xcp_mgr->xcp[i].driver = p_ddev->driver; + adev->xcp_mgr->xcp[i].driver = (struct drm_driver *)p_ddev->driver; adev->xcp_mgr->xcp[i].vma_offset_manager = p_ddev->vma_offset_manager; p_ddev->render->dev = ddev; p_ddev->primary->dev = ddev;
Signature · 1 line
2.34.1
Re: [PATCH 3/3] drm/amdgpu: use amdxcp platform device as spatial partition
Series is:
Acked-by Alex Deucher <[email protected]>
Quoted 71 lines · James Zhu
Use amdxcp platform device as spatial partition device.
Signed-off-by James Zhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-0@@ -51,6 +51,7 @@#include "amdgpu_ras.h" #include "amdgpu_xgmi.h" #include "amdgpu_reset.h" +#include "../amdxcp/amdgpu_xcp_drv.h" /* * KMS wrapper. @@ -2944,6 +2945,7 @@ static void __exit amdgpu_exit(void)amdgpu_sync_fini ();amdgpu_fence_slab_fini ();mmu_notifier_synchronize (); +amdgpu_xcp_drv_release (); }module_init (amdgpu_init);drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +6
-7@@ -25,6 +25,7 @@#include "amdgpu_drv.h" #include <drm/drm_drv.h> +#include "../amdxcp/amdgpu_xcp_drv.h" static int __amdgpu_xcp_run (struct amdgpu_xcp_mgr *xcp_mgr,struct amdgpu_xcp_ip *xcp_ip,int xcp_state)@@ -228,21 +229,20 @@ static int amdgpu_xcp_dev_alloc(struct amdgpu_device *adev)struct drm_device *p_ddev;struct pci_dev *pdev;struct drm_device *ddev; -int i; +int i, ret; pdev = adev->pdev; ddev =adev_to_drm (adev);for (i =0 ; i <MAX_XCP ; i++) { - p_ddev =drm_dev_alloc (&amdgpu_partition_driver, - &pci_upstream_bridge (pdev)->dev); -if (IS_ERR (p_ddev)) -return PTR_ERR (p_ddev); + ret =amdgpu_xcp_drm_dev_alloc (&p_ddev); +if (ret) +return ret;/* Redirect all IOCTLs to the primary device */ adev->xcp_mgr->xcp[i].rdev = p_ddev->render->dev; adev->xcp_mgr->xcp[i].pdev = p_ddev->primary->dev; - adev->xcp_mgr->xcp[i].driver = p_ddev->driver; + adev->xcp_mgr->xcp[i].driver = (struct drm_driver *)p_ddev->driver; adev->xcp_mgr->xcp[i].vma_offset_manager = p_ddev->vma_offset_manager; p_ddev->render->dev = ddev; p_ddev->primary->dev = ddev; --2.34.1