Skip to content

Commit ad05ca3

Browse files
Flora Cuijfvogel
authored andcommitted
drm/amdgpu/discovery: check ip_discovery fw file available
[ Upstream commit 017fbb6690c2245b1b4ef39b66c79d2990fe63dd ] Signed-off-by: Flora Cui <[email protected]> Reviewed-by: Alex Deucher <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 98e38fe7d355765f6665013d6379b4415d56b897) Signed-off-by: Jack Vogel <[email protected]>
1 parent 00d7e72 commit ad05ca3

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@
111111
#include "amdgpu_isp.h"
112112
#endif
113113

114-
#define FIRMWARE_IP_DISCOVERY "amdgpu/ip_discovery.bin"
115-
MODULE_FIRMWARE(FIRMWARE_IP_DISCOVERY);
114+
MODULE_FIRMWARE("amdgpu/ip_discovery.bin");
116115

117116
#define mmIP_DISCOVERY_VERSION 0x16A00
118117
#define mmRCC_CONFIG_MEMSIZE 0xde3
@@ -295,21 +294,13 @@ static int amdgpu_discovery_read_binary_from_mem(struct amdgpu_device *adev,
295294
return ret;
296295
}
297296

298-
static int amdgpu_discovery_read_binary_from_file(struct amdgpu_device *adev, uint8_t *binary)
297+
static int amdgpu_discovery_read_binary_from_file(struct amdgpu_device *adev,
298+
uint8_t *binary,
299+
const char *fw_name)
299300
{
300301
const struct firmware *fw;
301-
const char *fw_name;
302302
int r;
303303

304-
switch (amdgpu_discovery) {
305-
case 2:
306-
fw_name = FIRMWARE_IP_DISCOVERY;
307-
break;
308-
default:
309-
dev_warn(adev->dev, "amdgpu_discovery is not set properly\n");
310-
return -EINVAL;
311-
}
312-
313304
r = request_firmware(&fw, fw_name, adev->dev);
314305
if (r) {
315306
dev_err(adev->dev, "can't load firmware \"%s\"\n",
@@ -402,10 +393,19 @@ static int amdgpu_discovery_verify_npsinfo(struct amdgpu_device *adev,
402393
return 0;
403394
}
404395

396+
static const char *amdgpu_discovery_get_fw_name(struct amdgpu_device *adev)
397+
{
398+
if (amdgpu_discovery == 2)
399+
return "amdgpu/ip_discovery.bin";
400+
401+
return NULL;
402+
}
403+
405404
static int amdgpu_discovery_init(struct amdgpu_device *adev)
406405
{
407406
struct table_info *info;
408407
struct binary_header *bhdr;
408+
const char *fw_name;
409409
uint16_t offset;
410410
uint16_t size;
411411
uint16_t checksum;
@@ -417,9 +417,10 @@ static int amdgpu_discovery_init(struct amdgpu_device *adev)
417417
return -ENOMEM;
418418

419419
/* Read from file if it is the preferred option */
420-
if (amdgpu_discovery == 2) {
420+
fw_name = amdgpu_discovery_get_fw_name(adev);
421+
if (fw_name != NULL) {
421422
dev_info(adev->dev, "use ip discovery information from file");
422-
r = amdgpu_discovery_read_binary_from_file(adev, adev->mman.discovery_bin);
423+
r = amdgpu_discovery_read_binary_from_file(adev, adev->mman.discovery_bin, fw_name);
423424

424425
if (r) {
425426
dev_err(adev->dev, "failed to read ip discovery binary from file\n");

0 commit comments

Comments
 (0)