diff options
author | 2024-04-10 19:03:34 +0200 | |
---|---|---|
committer | 2024-04-12 16:23:26 +0200 | |
commit | 0bdd5b16ba0444f41d538f5927cb9b995d684594 (patch) | |
tree | 74d86aea98256cb83d0d5f4f07ed86eb00caeb62 | |
parent | Merge drm/drm-next into drm-xe-next (diff) | |
download | wireguard-linux-0bdd5b16ba0444f41d538f5927cb9b995d684594.tar.xz wireguard-linux-0bdd5b16ba0444f41d538f5927cb9b995d684594.zip |
drm/xe/pf: Introduce mutex to protect VFs configurations
PF driver will maintain configurations and resources for every VF
and this data could span multiple tiles and/or GTs. Prepare mutex
to protect data that we will add in upcoming patches.
Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240410170338.1199-2-michal.wajdeczko@intel.com
-rw-r--r-- | drivers/gpu/drm/xe/xe_sriov.c | 7 | ||||
-rw-r--r-- | drivers/gpu/drm/xe/xe_sriov_pf.c | 15 | ||||
-rw-r--r-- | drivers/gpu/drm/xe/xe_sriov_pf.h | 6 | ||||
-rw-r--r-- | drivers/gpu/drm/xe/xe_sriov_types.h | 4 |
4 files changed, 32 insertions, 0 deletions
diff --git a/drivers/gpu/drm/xe/xe_sriov.c b/drivers/gpu/drm/xe/xe_sriov.c index d324f131e3da..1b40f5de9ef5 100644 --- a/drivers/gpu/drm/xe/xe_sriov.c +++ b/drivers/gpu/drm/xe/xe_sriov.c @@ -94,6 +94,13 @@ int xe_sriov_init(struct xe_device *xe) if (!IS_SRIOV(xe)) return 0; + if (IS_SRIOV_PF(xe)) { + int err = xe_sriov_pf_init_early(xe); + + if (err) + return err; + } + xe_assert(xe, !xe->sriov.wq); xe->sriov.wq = alloc_workqueue("xe-sriov-wq", 0, 0); if (!xe->sriov.wq) diff --git a/drivers/gpu/drm/xe/xe_sriov_pf.c b/drivers/gpu/drm/xe/xe_sriov_pf.c index 030c2b69ecc4..0f721ae17b26 100644 --- a/drivers/gpu/drm/xe/xe_sriov_pf.c +++ b/drivers/gpu/drm/xe/xe_sriov_pf.c @@ -3,6 +3,8 @@ * Copyright © 2023-2024 Intel Corporation */ +#include <drm/drm_managed.h> + #include "xe_assert.h" #include "xe_device.h" #include "xe_module.h" @@ -71,6 +73,19 @@ bool xe_sriov_pf_readiness(struct xe_device *xe) } /** + * xe_sriov_pf_init_early - Initialize SR-IOV PF specific data. + * @xe: the &xe_device to initialize + * + * Return: 0 on success or a negative error code on failure. + */ +int xe_sriov_pf_init_early(struct xe_device *xe) +{ + xe_assert(xe, IS_SRIOV_PF(xe)); + + return drmm_mutex_init(&xe->drm, &xe->sriov.pf.master_lock); +} + +/** * xe_sriov_pf_print_vfs_summary - Print SR-IOV PF information. * @xe: the &xe_device to print info from * @p: the &drm_printer diff --git a/drivers/gpu/drm/xe/xe_sriov_pf.h b/drivers/gpu/drm/xe/xe_sriov_pf.h index ebef2e01838a..d1220e70e1c0 100644 --- a/drivers/gpu/drm/xe/xe_sriov_pf.h +++ b/drivers/gpu/drm/xe/xe_sriov_pf.h @@ -13,12 +13,18 @@ struct xe_device; #ifdef CONFIG_PCI_IOV bool xe_sriov_pf_readiness(struct xe_device *xe); +int xe_sriov_pf_init_early(struct xe_device *xe); void xe_sriov_pf_print_vfs_summary(struct xe_device *xe, struct drm_printer *p); #else static inline bool xe_sriov_pf_readiness(struct xe_device *xe) { return false; } + +static inline int xe_sriov_pf_init_early(struct xe_device *xe) +{ + return 0; +} #endif #endif diff --git a/drivers/gpu/drm/xe/xe_sriov_types.h b/drivers/gpu/drm/xe/xe_sriov_types.h index fa583e8fa0c2..c7b7ad4af5c8 100644 --- a/drivers/gpu/drm/xe/xe_sriov_types.h +++ b/drivers/gpu/drm/xe/xe_sriov_types.h @@ -7,6 +7,7 @@ #define _XE_SRIOV_TYPES_H_ #include <linux/build_bug.h> +#include <linux/mutex.h> #include <linux/types.h> /** @@ -50,6 +51,9 @@ struct xe_device_pf { /** @driver_max_vfs: Maximum number of VFs supported by the driver. */ u16 driver_max_vfs; + + /** @master_lock: protects all VFs configurations across GTs */ + struct mutex master_lock; }; #endif |