Skip to content

Commit 538f111

Browse files
committed
drm/vc4: drv: Register a different driver on BCM2711
Prior to the BCM2711/RaspberryPi4, the GPU was a part of the display components of the SoC. It was thus a part of the vc4 driver. However, with the BCM2711, it got split out and thus the v3d driver was created. The vc4 driver now only handles the display part. We didn't properly split out the code when doing the BCM2711 support though, and most of the code around buffer allocations is still involved, even though it doesn't have the backing hardware anymore. Let's start the split out by creating a new drm_driver that only reports and uses what we support on the BCM2711. The ioctl were properly filtered already, but we were still exposing a .gem_create_object hook, as well as having an .open and .postclose hooks which are only relevant on older generations. Reviewed-by: Melissa Wen <mwen@igalia.com> Signed-off-by: Maxime Ripard <maxime@cerno.tech> Link: https://lore.kernel.org/r/20220610115149.964394-6-maxime@cerno.tech
1 parent 3d76374 commit 538f111

1 file changed

Lines changed: 42 additions & 9 deletions

File tree

drivers/gpu/drm/vc4/vc4_drv.c

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,19 @@ int vc4_dumb_fixup_args(struct drm_mode_create_dumb *args)
7676
return 0;
7777
}
7878

79+
static int vc5_dumb_create(struct drm_file *file_priv,
80+
struct drm_device *dev,
81+
struct drm_mode_create_dumb *args)
82+
{
83+
int ret;
84+
85+
ret = vc4_dumb_fixup_args(args);
86+
if (ret)
87+
return ret;
88+
89+
return drm_gem_cma_dumb_create_internal(file_priv, dev, args);
90+
}
91+
7992
static int vc4_get_param_ioctl(struct drm_device *dev, void *data,
8093
struct drm_file *file_priv)
8194
{
@@ -173,7 +186,7 @@ static const struct drm_ioctl_desc vc4_drm_ioctls[] = {
173186
DRM_IOCTL_DEF_DRV(VC4_PERFMON_GET_VALUES, vc4_perfmon_get_values_ioctl, DRM_RENDER_ALLOW),
174187
};
175188

176-
static struct drm_driver vc4_drm_driver = {
189+
static const struct drm_driver vc4_drm_driver = {
177190
.driver_features = (DRIVER_MODESET |
178191
DRIVER_ATOMIC |
179192
DRIVER_GEM |
@@ -202,6 +215,27 @@ static struct drm_driver vc4_drm_driver = {
202215
.patchlevel = DRIVER_PATCHLEVEL,
203216
};
204217

218+
static const struct drm_driver vc5_drm_driver = {
219+
.driver_features = (DRIVER_MODESET |
220+
DRIVER_ATOMIC |
221+
DRIVER_GEM),
222+
223+
#if defined(CONFIG_DEBUG_FS)
224+
.debugfs_init = vc4_debugfs_init,
225+
#endif
226+
227+
DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE(vc5_dumb_create),
228+
229+
.fops = &vc4_drm_fops,
230+
231+
.name = DRIVER_NAME,
232+
.desc = DRIVER_DESC,
233+
.date = DRIVER_DATE,
234+
.major = DRIVER_MAJOR,
235+
.minor = DRIVER_MINOR,
236+
.patchlevel = DRIVER_PATCHLEVEL,
237+
};
238+
205239
static void vc4_match_add_drivers(struct device *dev,
206240
struct component_match **match,
207241
struct platform_driver *const *drivers,
@@ -225,6 +259,7 @@ static void vc4_match_add_drivers(struct device *dev,
225259
static int vc4_drm_bind(struct device *dev)
226260
{
227261
struct platform_device *pdev = to_platform_device(dev);
262+
const struct drm_driver *driver;
228263
struct rpi_firmware *firmware = NULL;
229264
struct drm_device *drm;
230265
struct vc4_dev *vc4;
@@ -236,14 +271,12 @@ static int vc4_drm_bind(struct device *dev)
236271
dev->coherent_dma_mask = DMA_BIT_MASK(32);
237272

238273
is_vc5 = of_device_is_compatible(dev->of_node, "brcm,bcm2711-vc5");
274+
if (is_vc5)
275+
driver = &vc5_drm_driver;
276+
else
277+
driver = &vc4_drm_driver;
239278

240-
/* If VC4 V3D is missing, don't advertise render nodes. */
241-
node = of_find_matching_node_and_match(NULL, vc4_v3d_dt_match, NULL);
242-
if (!node || !of_device_is_available(node))
243-
vc4_drm_driver.driver_features &= ~DRIVER_RENDER;
244-
of_node_put(node);
245-
246-
vc4 = devm_drm_dev_alloc(dev, &vc4_drm_driver, struct vc4_dev, base);
279+
vc4 = devm_drm_dev_alloc(dev, driver, struct vc4_dev, base);
247280
if (IS_ERR(vc4))
248281
return PTR_ERR(vc4);
249282
vc4->is_vc5 = is_vc5;
@@ -275,7 +308,7 @@ static int vc4_drm_bind(struct device *dev)
275308
return -EPROBE_DEFER;
276309
}
277310

278-
ret = drm_aperture_remove_framebuffers(false, &vc4_drm_driver);
311+
ret = drm_aperture_remove_framebuffers(false, driver);
279312
if (ret)
280313
return ret;
281314

0 commit comments

Comments
 (0)