Skip to content

Commit 918bd78

Browse files
bnilawarlucasdemarchi
authored andcommitted
drm/xe/xe_late_bind_fw: Introduce xe_late_bind_fw
Introduce xe_late_bind_fw to enable firmware loading for the devices, such as the fan controller, during the driver probe. Typically, firmware for such devices are part of IFWI flash image but can be replaced at probe after OEM tuning. This patch binds mei late binding component to enable firmware loading. v2: - Add devm_add_action_or_reset to remove the component (Daniele) - Add INTEL_MEI_GSC check in xe_late_bind_init() (Daniele) v3: - Fail driver probe if late bind initialization fails, add has_late_bind flag (Daniele) v4: - %s/I915_COMPONENT_LATE_BIND/INTEL_COMPONENT_LATE_BIND/ v6: - rebased v7: - rebased - In xe_late_bind_init, use drm_err when returning an error to stop the probe (Lucas) - Use imperative mode in commit message (Lucas) Signed-off-by: Badal Nilawar <[email protected]> Reviewed-by: Daniele Ceraolo Spurio <[email protected]> Signed-off-by: Rodrigo Vivi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lucas De Marchi <[email protected]>
1 parent 741eeab commit 918bd78

File tree

8 files changed

+147
-0
lines changed

8 files changed

+147
-0
lines changed

drivers/gpu/drm/xe/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ xe-y += xe_bb.o \
8484
xe_hw_error.o \
8585
xe_hw_fence.o \
8686
xe_irq.o \
87+
xe_late_bind_fw.o \
8788
xe_lrc.o \
8889
xe_migrate.o \
8990
xe_mmio.o \

drivers/gpu/drm/xe/xe_device.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "xe_hwmon.h"
4646
#include "xe_i2c.h"
4747
#include "xe_irq.h"
48+
#include "xe_late_bind_fw.h"
4849
#include "xe_mmio.h"
4950
#include "xe_module.h"
5051
#include "xe_nvm.h"
@@ -903,6 +904,10 @@ int xe_device_probe(struct xe_device *xe)
903904
if (err)
904905
return err;
905906

907+
err = xe_late_bind_init(&xe->late_bind);
908+
if (err)
909+
return err;
910+
906911
err = xe_oa_init(xe);
907912
if (err)
908913
return err;

drivers/gpu/drm/xe/xe_device_types.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "xe_devcoredump_types.h"
1616
#include "xe_heci_gsc.h"
17+
#include "xe_late_bind_fw_types.h"
1718
#include "xe_lmtt_types.h"
1819
#include "xe_memirq_types.h"
1920
#include "xe_oa_types.h"
@@ -280,6 +281,8 @@ struct xe_device {
280281
u8 has_heci_cscfi:1;
281282
/** @info.has_heci_gscfi: device has heci gscfi */
282283
u8 has_heci_gscfi:1;
284+
/** @info.has_late_bind: Device has firmware late binding support */
285+
u8 has_late_bind:1;
283286
/** @info.has_llc: Device has a shared CPU+GPU last level cache */
284287
u8 has_llc:1;
285288
/** @info.has_mbx_power_limits: Device has support to manage power limits using
@@ -533,6 +536,9 @@ struct xe_device {
533536
/** @nvm: discrete graphics non-volatile memory */
534537
struct intel_dg_nvm_dev *nvm;
535538

539+
/** @late_bind: xe mei late bind interface */
540+
struct xe_late_bind late_bind;
541+
536542
/** @oa: oa observation subsystem */
537543
struct xe_oa oa;
538544

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// SPDX-License-Identifier: MIT
2+
/*
3+
* Copyright © 2025 Intel Corporation
4+
*/
5+
6+
#include <linux/component.h>
7+
#include <linux/delay.h>
8+
9+
#include <drm/drm_managed.h>
10+
#include <drm/intel/i915_component.h>
11+
#include <drm/intel/intel_lb_mei_interface.h>
12+
#include <drm/drm_print.h>
13+
14+
#include "xe_device.h"
15+
#include "xe_late_bind_fw.h"
16+
17+
static struct xe_device *
18+
late_bind_to_xe(struct xe_late_bind *late_bind)
19+
{
20+
return container_of(late_bind, struct xe_device, late_bind);
21+
}
22+
23+
static int xe_late_bind_component_bind(struct device *xe_kdev,
24+
struct device *mei_kdev, void *data)
25+
{
26+
struct xe_device *xe = kdev_to_xe_device(xe_kdev);
27+
struct xe_late_bind *late_bind = &xe->late_bind;
28+
29+
late_bind->component.ops = data;
30+
late_bind->component.mei_dev = mei_kdev;
31+
32+
return 0;
33+
}
34+
35+
static void xe_late_bind_component_unbind(struct device *xe_kdev,
36+
struct device *mei_kdev, void *data)
37+
{
38+
struct xe_device *xe = kdev_to_xe_device(xe_kdev);
39+
struct xe_late_bind *late_bind = &xe->late_bind;
40+
41+
late_bind->component.ops = NULL;
42+
}
43+
44+
static const struct component_ops xe_late_bind_component_ops = {
45+
.bind = xe_late_bind_component_bind,
46+
.unbind = xe_late_bind_component_unbind,
47+
};
48+
49+
static void xe_late_bind_remove(void *arg)
50+
{
51+
struct xe_late_bind *late_bind = arg;
52+
struct xe_device *xe = late_bind_to_xe(late_bind);
53+
54+
component_del(xe->drm.dev, &xe_late_bind_component_ops);
55+
}
56+
57+
/**
58+
* xe_late_bind_init() - add xe mei late binding component
59+
* @late_bind: pointer to late bind structure.
60+
*
61+
* Return: 0 if the initialization was successful, a negative errno otherwise.
62+
*/
63+
int xe_late_bind_init(struct xe_late_bind *late_bind)
64+
{
65+
struct xe_device *xe = late_bind_to_xe(late_bind);
66+
int err;
67+
68+
if (!xe->info.has_late_bind)
69+
return 0;
70+
71+
if (!IS_ENABLED(CONFIG_INTEL_MEI_LB) || !IS_ENABLED(CONFIG_INTEL_MEI_GSC)) {
72+
drm_info(&xe->drm, "Can't init xe mei late bind missing mei component\n");
73+
return 0;
74+
}
75+
76+
err = component_add_typed(xe->drm.dev, &xe_late_bind_component_ops,
77+
INTEL_COMPONENT_LB);
78+
if (err < 0) {
79+
drm_err(&xe->drm, "Failed to add mei late bind component (%pe)\n", ERR_PTR(err));
80+
return err;
81+
}
82+
83+
return devm_add_action_or_reset(xe->drm.dev, xe_late_bind_remove, late_bind);
84+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* SPDX-License-Identifier: MIT */
2+
/*
3+
* Copyright © 2025 Intel Corporation
4+
*/
5+
6+
#ifndef _XE_LATE_BIND_FW_H_
7+
#define _XE_LATE_BIND_FW_H_
8+
9+
#include <linux/types.h>
10+
11+
struct xe_late_bind;
12+
13+
int xe_late_bind_init(struct xe_late_bind *late_bind);
14+
15+
#endif
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* SPDX-License-Identifier: MIT */
2+
/*
3+
* Copyright © 2025 Intel Corporation
4+
*/
5+
6+
#ifndef _XE_LATE_BIND_TYPES_H_
7+
#define _XE_LATE_BIND_TYPES_H_
8+
9+
#include <linux/iosys-map.h>
10+
#include <linux/mutex.h>
11+
#include <linux/types.h>
12+
13+
/**
14+
* struct xe_late_bind_component - Late Binding services component
15+
* @mei_dev: device that provide Late Binding service.
16+
* @ops: Ops implemented by Late Binding driver, used by Xe driver.
17+
*
18+
* Communication between Xe and MEI drivers for Late Binding services
19+
*/
20+
struct xe_late_bind_component {
21+
struct device *mei_dev;
22+
const struct late_bind_component_ops *ops;
23+
};
24+
25+
/**
26+
* struct xe_late_bind
27+
*/
28+
struct xe_late_bind {
29+
/** @component: struct for communication with mei component */
30+
struct xe_late_bind_component component;
31+
};
32+
33+
#endif

drivers/gpu/drm/xe/xe_pci.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ static const struct xe_device_desc bmg_desc = {
334334
.has_mbx_power_limits = true,
335335
.has_gsc_nvm = 1,
336336
.has_heci_cscfi = 1,
337+
.has_late_bind = true,
337338
.has_sriov = true,
338339
.max_gt_per_tile = 2,
339340
.needs_scratch = true,
@@ -587,6 +588,7 @@ static int xe_info_init_early(struct xe_device *xe,
587588
xe->info.has_gsc_nvm = desc->has_gsc_nvm;
588589
xe->info.has_heci_gscfi = desc->has_heci_gscfi;
589590
xe->info.has_heci_cscfi = desc->has_heci_cscfi;
591+
xe->info.has_late_bind = desc->has_late_bind;
590592
xe->info.has_llc = desc->has_llc;
591593
xe->info.has_pxp = desc->has_pxp;
592594
xe->info.has_sriov = desc->has_sriov;

drivers/gpu/drm/xe/xe_pci_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct xe_device_desc {
3939
u8 has_gsc_nvm:1;
4040
u8 has_heci_gscfi:1;
4141
u8 has_heci_cscfi:1;
42+
u8 has_late_bind:1;
4243
u8 has_llc:1;
4344
u8 has_mbx_power_limits:1;
4445
u8 has_pxp:1;

0 commit comments

Comments
 (0)