Skip to content

Commit 5c1a781

Browse files
Timur Kristófalexdeucher
authored andcommitted
drm/radeon: Refactor how SI and CIK support is determined
Move the determination into a separate function. Change radeon.si_support and radeon.cik_support so that their default value is -1 (default). This prepares the code for changing the default driver based on the chip. Signed-off-by: Timur Kristóf <timur.kristof@gmail.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 43d0822 commit 5c1a781

1 file changed

Lines changed: 50 additions & 28 deletions

File tree

drivers/gpu/drm/radeon/radeon_drv.c

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,12 @@ module_param_named(uvd, radeon_uvd, int, 0444);
241241
MODULE_PARM_DESC(vce, "vce enable/disable vce support (1 = enable, 0 = disable)");
242242
module_param_named(vce, radeon_vce, int, 0444);
243243

244-
int radeon_si_support = 1;
245-
MODULE_PARM_DESC(si_support, "SI support (1 = enabled (default), 0 = disabled)");
244+
int radeon_si_support = -1;
245+
MODULE_PARM_DESC(si_support, "SI support (1 = enabled, 0 = disabled, -1 = default)");
246246
module_param_named(si_support, radeon_si_support, int, 0444);
247247

248-
int radeon_cik_support = 1;
249-
MODULE_PARM_DESC(cik_support, "CIK support (1 = enabled (default), 0 = disabled)");
248+
int radeon_cik_support = -1;
249+
MODULE_PARM_DESC(cik_support, "CIK support (1 = enabled, 0 = disabled, -1 = default)");
250250
module_param_named(cik_support, radeon_cik_support, int, 0444);
251251

252252
static const struct pci_device_id pciidlist[] = {
@@ -256,6 +256,50 @@ MODULE_DEVICE_TABLE(pci, pciidlist);
256256

257257
static const struct drm_driver kms_driver;
258258

259+
static bool radeon_support_enabled(struct device *dev,
260+
const enum radeon_family family)
261+
{
262+
const char *gen;
263+
int module_param = -1;
264+
bool amdgpu_support_built = IS_ENABLED(CONFIG_DRM_AMDGPU);
265+
bool support_by_default = true;
266+
267+
switch (family) {
268+
case CHIP_TAHITI:
269+
case CHIP_PITCAIRN:
270+
case CHIP_VERDE:
271+
case CHIP_OLAND:
272+
case CHIP_HAINAN:
273+
gen = "SI";
274+
module_param = radeon_si_support;
275+
amdgpu_support_built &= IS_ENABLED(CONFIG_DRM_AMDGPU_SI);
276+
break;
277+
278+
case CHIP_BONAIRE:
279+
case CHIP_HAWAII:
280+
case CHIP_KAVERI:
281+
case CHIP_KABINI:
282+
case CHIP_MULLINS:
283+
gen = "CIK";
284+
module_param = radeon_cik_support;
285+
amdgpu_support_built &= IS_ENABLED(CONFIG_DRM_AMDGPU_CIK);
286+
break;
287+
288+
default:
289+
/* All other chips are supported by radeon only */
290+
return true;
291+
}
292+
293+
if ((module_param == -1 && (support_by_default || !amdgpu_support_built)) ||
294+
module_param == 1)
295+
return true;
296+
297+
if (!module_param)
298+
dev_info(dev, "%s support disabled by module param\n", gen);
299+
300+
return false;
301+
}
302+
259303
static int radeon_pci_probe(struct pci_dev *pdev,
260304
const struct pci_device_id *ent)
261305
{
@@ -271,30 +315,8 @@ static int radeon_pci_probe(struct pci_dev *pdev,
271315

272316
flags = ent->driver_data;
273317

274-
if (!radeon_si_support) {
275-
switch (flags & RADEON_FAMILY_MASK) {
276-
case CHIP_TAHITI:
277-
case CHIP_PITCAIRN:
278-
case CHIP_VERDE:
279-
case CHIP_OLAND:
280-
case CHIP_HAINAN:
281-
dev_info(dev,
282-
"SI support disabled by module param\n");
283-
return -ENODEV;
284-
}
285-
}
286-
if (!radeon_cik_support) {
287-
switch (flags & RADEON_FAMILY_MASK) {
288-
case CHIP_KAVERI:
289-
case CHIP_BONAIRE:
290-
case CHIP_HAWAII:
291-
case CHIP_KABINI:
292-
case CHIP_MULLINS:
293-
dev_info(dev,
294-
"CIK support disabled by module param\n");
295-
return -ENODEV;
296-
}
297-
}
318+
if (!radeon_support_enabled(dev, flags & RADEON_FAMILY_MASK))
319+
return -ENODEV;
298320

299321
if (vga_switcheroo_client_probe_defer(pdev))
300322
return -EPROBE_DEFER;

0 commit comments

Comments
 (0)