drm/radeon: Use release_firmware()/request_firmware()
authorzrj <rimvydas.jasinskas@gmail.com>
Wed, 3 Jun 2015 11:45:46 +0000 (14:45 +0300)
committerFran├žois Tigeot <ftigeot@wolfpond.org>
Sat, 6 Jun 2015 11:15:08 +0000 (13:15 +0200)
sys/dev/drm/include/linux/firmware.h
sys/dev/drm/radeon/cik.c
sys/dev/drm/radeon/ni.c
sys/dev/drm/radeon/r100.c
sys/dev/drm/radeon/r600.c
sys/dev/drm/radeon/r600_cp.c
sys/dev/drm/radeon/radeon_cp.c
sys/dev/drm/radeon/radeon_uvd.c
sys/dev/drm/radeon/si.c

index d1fc5d0..b840086 100644 (file)
@@ -38,12 +38,14 @@ request_firmware(const struct firmware **fw, const char *name, __unused device_t
        if (*fw) {
                return 0;
        }
-       return -1;
+       return -ENOENT;
 }
 
 static inline void
 release_firmware(const struct firmware *fw) {
-       firmware_put(fw, FIRMWARE_UNLOAD);
+       if (fw != NULL) {
+               firmware_put(fw, FIRMWARE_UNLOAD);
+       }
 }
 
 #endif /* _LINUX_FIRMWARE_H_ */
index deaa610..4447003 100644 (file)
@@ -21,8 +21,8 @@
  *
  * Authors: Alex Deucher
  */
-#include <linux/module.h>
 #include <linux/firmware.h>
+#include <linux/module.h>
 #include <drm/drmP.h>
 #include "radeon.h"
 #include "radeon_asic.h"
@@ -774,14 +774,11 @@ static int cik_init_microcode(struct radeon_device *rdev)
        }
 
        DRM_INFO("Loading %s Microcode\n", chip_name);
-       err = 0;
 
        ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_pfp", chip_name);
-       rdev->pfp_fw = firmware_get(fw_name);
-       if (rdev->pfp_fw == NULL) {
-               err = -ENOENT;
+       err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev);
+       if (err)
                goto out;
-       }
        if (rdev->pfp_fw->datasize != pfp_req_size) {
                printk(KERN_ERR
                       "cik_cp: Bogus length %zu in firmware \"%s\"\n",
@@ -791,11 +788,9 @@ static int cik_init_microcode(struct radeon_device *rdev)
        }
 
        ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_me", chip_name);
-       rdev->me_fw = firmware_get(fw_name);
-       if (rdev->me_fw == NULL) {
-               err = -ENOENT;
+       err = request_firmware(&rdev->me_fw, fw_name, rdev->dev);
+       if (err)
                goto out;
-       }
        if (rdev->me_fw->datasize != me_req_size) {
                printk(KERN_ERR
                       "cik_cp: Bogus length %zu in firmware \"%s\"\n",
@@ -804,11 +799,9 @@ static int cik_init_microcode(struct radeon_device *rdev)
        }
 
        ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_ce", chip_name);
-       rdev->ce_fw = firmware_get(fw_name);
-       if (rdev->ce_fw == NULL) {
-               err = -ENOENT;
+       err = request_firmware(&rdev->ce_fw, fw_name, rdev->dev);
+       if (err)
                goto out;
-       }
        if (rdev->ce_fw->datasize != ce_req_size) {
                printk(KERN_ERR
                       "cik_cp: Bogus length %zu in firmware \"%s\"\n",
@@ -817,11 +810,9 @@ static int cik_init_microcode(struct radeon_device *rdev)
        }
 
        ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_mec", chip_name);
-       rdev->mec_fw = firmware_get(fw_name);
-       if (rdev->mec_fw == NULL) {
-               err = -ENOENT;
+       err = request_firmware(&rdev->mec_fw, fw_name, rdev->dev);
+       if (err)
                goto out;
-       }
        if (rdev->mec_fw->datasize != mec_req_size) {
                printk(KERN_ERR
                       "cik_cp: Bogus length %zu in firmware \"%s\"\n",
@@ -830,11 +821,9 @@ static int cik_init_microcode(struct radeon_device *rdev)
        }
 
        ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_rlc", chip_name);
-       rdev->rlc_fw = firmware_get(fw_name);
-       if (rdev->rlc_fw == NULL) {
-               err = -ENOENT;
+       err = request_firmware(&rdev->rlc_fw, fw_name, rdev->dev);
+       if (err)
                goto out;
-       }
        if (rdev->rlc_fw->datasize != rlc_req_size) {
                printk(KERN_ERR
                       "cik_rlc: Bogus length %zu in firmware \"%s\"\n",
@@ -843,11 +832,9 @@ static int cik_init_microcode(struct radeon_device *rdev)
        }
 
        ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_sdma", chip_name);
-       rdev->sdma_fw = firmware_get(fw_name);
-       if (rdev->sdma_fw == NULL) {
-               err = -ENOENT;
+       err = request_firmware(&rdev->sdma_fw, fw_name, rdev->dev);
+       if (err)
                goto out;
-       }
        if (rdev->sdma_fw->datasize != sdma_req_size) {
                printk(KERN_ERR
                       "cik_sdma: Bogus length %zu in firmware \"%s\"\n",
@@ -858,11 +845,9 @@ static int cik_init_microcode(struct radeon_device *rdev)
        /* No MC ucode on APUs */
        if (!(rdev->flags & RADEON_IS_IGP)) {
                ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_mc", chip_name);
-               rdev->mc_fw = firmware_get(fw_name);
-               if (rdev->mc_fw == NULL) {
-                       err = -ENOENT;
+               err = request_firmware(&rdev->mc_fw, fw_name, rdev->dev);
+               if (err)
                        goto out;
-               }
                if (rdev->mc_fw->datasize != mc_req_size) {
                        printk(KERN_ERR
                               "cik_mc: Bogus length %zu in firmware \"%s\"\n",
@@ -877,34 +862,20 @@ out:
                        printk(KERN_ERR
                               "cik_cp: Failed to load firmware \"%s\"\n",
                               fw_name);
-               if (rdev->pfp_fw != NULL) {
-                       firmware_put(rdev->pfp_fw, FIRMWARE_UNLOAD);
-                       rdev->pfp_fw = NULL;
-               }
-               if (rdev->me_fw != NULL) {
-                       firmware_put(rdev->me_fw, FIRMWARE_UNLOAD);
-                       rdev->me_fw = NULL;
-               }
-               if (rdev->ce_fw != NULL) {
-                       firmware_put(rdev->ce_fw, FIRMWARE_UNLOAD);
-                       rdev->ce_fw = NULL;
-               }
-               if (rdev->mec_fw != NULL) {
-                       firmware_put(rdev->mec_fw, FIRMWARE_UNLOAD);
-                       rdev->mec_fw = NULL;
-               }
-               if (rdev->rlc_fw != NULL) {
-                       firmware_put(rdev->rlc_fw, FIRMWARE_UNLOAD);
-                       rdev->rlc_fw = NULL;
-               }
-               if (rdev->sdma_fw != NULL) {
-                       firmware_put(rdev->sdma_fw, FIRMWARE_UNLOAD);
-                       rdev->sdma_fw = NULL;
-               }
-               if (rdev->mc_fw != NULL) {
-                       firmware_put(rdev->mc_fw, FIRMWARE_UNLOAD);
-                       rdev->mc_fw = NULL;
-               }
+               release_firmware(rdev->pfp_fw);
+               rdev->pfp_fw = NULL;
+               release_firmware(rdev->me_fw);
+               rdev->me_fw = NULL;
+               release_firmware(rdev->ce_fw);
+               rdev->ce_fw = NULL;
+               release_firmware(rdev->mec_fw);
+               rdev->mec_fw = NULL;
+               release_firmware(rdev->rlc_fw);
+               rdev->rlc_fw = NULL;
+               release_firmware(rdev->sdma_fw);
+               rdev->sdma_fw = NULL;
+               release_firmware(rdev->mc_fw);
+               rdev->mc_fw = NULL;
        }
        return err;
 }
index f08ca2f..6bc4511 100644 (file)
@@ -22,9 +22,9 @@
  * Authors: Alex Deucher
  * $FreeBSD: head/sys/dev/drm2/radeon/ni.c 254885 2013-08-25 19:37:15Z dumbbell $
  */
-
-#include <drm/drmP.h>
 #include <linux/firmware.h>
+#include <linux/module.h>
+#include <drm/drmP.h>
 #include "radeon.h"
 #include "radeon_asic.h"
 #include <uapi_drm/radeon_drm.h>
@@ -731,14 +731,11 @@ int ni_init_microcode(struct radeon_device *rdev)
        }
 
        DRM_INFO("Loading %s Microcode\n", chip_name);
-       err = 0;
 
        ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_pfp", chip_name);
-       rdev->pfp_fw = firmware_get(fw_name);
-       if (rdev->pfp_fw == NULL) {
-               err = -ENOENT;
+       err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev);
+       if (err)
                goto out;
-       }
        if (rdev->pfp_fw->datasize != pfp_req_size) {
                DRM_ERROR(
                       "ni_pfp: Bogus length %zu in firmware \"%s\"\n",
@@ -748,11 +745,9 @@ int ni_init_microcode(struct radeon_device *rdev)
        }
 
        ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_me", chip_name);
-       rdev->me_fw = firmware_get(fw_name);
-       if (rdev->me_fw == NULL) {
-               err = -ENOENT;
+       err = request_firmware(&rdev->me_fw, fw_name, rdev->dev);
+       if (err)
                goto out;
-       }
        if (rdev->me_fw->datasize != me_req_size) {
                DRM_ERROR(
                       "ni_me: Bogus length %zu in firmware \"%s\"\n",
@@ -762,11 +757,9 @@ int ni_init_microcode(struct radeon_device *rdev)
 
        ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_rlc",
                  rlc_chip_name);
-       rdev->rlc_fw = firmware_get(fw_name);
-       if (rdev->rlc_fw == NULL) {
-               err = -ENOENT;
+       err = request_firmware(&rdev->rlc_fw, fw_name, rdev->dev);
+       if (err)
                goto out;
-       }
        if (rdev->rlc_fw->datasize != rlc_req_size) {
                DRM_ERROR(
                       "ni_rlc: Bogus length %zu in firmware \"%s\"\n",
@@ -776,13 +769,10 @@ int ni_init_microcode(struct radeon_device *rdev)
 
        /* no MC ucode on TN */
        if (!(rdev->flags & RADEON_IS_IGP)) {
-               ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_mc",
-                         chip_name);
-               rdev->mc_fw = firmware_get(fw_name);
-               if (rdev->mc_fw == NULL) {
-                       err = -ENOENT;
+               ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_mc", chip_name);
+               err = request_firmware(&rdev->mc_fw, fw_name, rdev->dev);
+               if (err)
                        goto out;
-               }
                if (rdev->mc_fw->datasize != mc_req_size) {
                        DRM_ERROR(
                               "ni_mc: Bogus length %zu in firmware \"%s\"\n",
@@ -814,26 +804,16 @@ out:
                        DRM_ERROR(
                               "ni_cp: Failed to load firmware \"%s\"\n",
                               fw_name);
-               if (rdev->pfp_fw != NULL) {
-                       firmware_put(rdev->pfp_fw, FIRMWARE_UNLOAD);
-                       rdev->pfp_fw = NULL;
-               }
-               if (rdev->me_fw != NULL) {
-                       firmware_put(rdev->me_fw, FIRMWARE_UNLOAD);
-                       rdev->me_fw = NULL;
-               }
-               if (rdev->rlc_fw != NULL) {
-                       firmware_put(rdev->rlc_fw, FIRMWARE_UNLOAD);
-                       rdev->rlc_fw = NULL;
-               }
-               if (rdev->mc_fw != NULL) {
-                       firmware_put(rdev->mc_fw, FIRMWARE_UNLOAD);
-                       rdev->mc_fw = NULL;
-               }
-               if (rdev->smc_fw != NULL) {
-                       firmware_put(rdev->smc_fw, FIRMWARE_UNLOAD);
-                       rdev->smc_fw = NULL;
-               }
+               release_firmware(rdev->pfp_fw);
+               rdev->pfp_fw = NULL;
+               release_firmware(rdev->me_fw);
+               rdev->me_fw = NULL;
+               release_firmware(rdev->rlc_fw);
+               rdev->rlc_fw = NULL;
+               release_firmware(rdev->mc_fw);
+               rdev->mc_fw = NULL;
+               release_firmware(rdev->smc_fw);
+               rdev->smc_fw = NULL;
        }
        return err;
 }
@@ -848,29 +828,16 @@ out:
  */
 void ni_fini_microcode(struct radeon_device *rdev)
 {
-
-       if (rdev->pfp_fw != NULL) {
-               firmware_put(rdev->pfp_fw, FIRMWARE_UNLOAD);
-               rdev->pfp_fw = NULL;
-       }
-
-       if (rdev->me_fw != NULL) {
-               firmware_put(rdev->me_fw, FIRMWARE_UNLOAD);
-               rdev->me_fw = NULL;
-       }
-
-       if (rdev->rlc_fw != NULL) {
-               firmware_put(rdev->rlc_fw, FIRMWARE_UNLOAD);
-               rdev->rlc_fw = NULL;
-       }
-
-       if (rdev->mc_fw != NULL) {
-               firmware_put(rdev->mc_fw, FIRMWARE_UNLOAD);
-               rdev->mc_fw = NULL;
-       }
+       release_firmware(rdev->pfp_fw);
+       rdev->pfp_fw = NULL;
+       release_firmware(rdev->me_fw);
+       rdev->me_fw = NULL;
+       release_firmware(rdev->rlc_fw);
+       rdev->rlc_fw = NULL;
+       release_firmware(rdev->mc_fw);
+       rdev->mc_fw = NULL;
 }
 
-
 int tn_get_temp(struct radeon_device *rdev)
 {
        u32 temp = RREG32_SMC(TN_CURRENT_GNB_TEMP) & 0x7ff;
index 50865b0..d333984 100644 (file)
@@ -39,6 +39,9 @@
 #include "rv250d.h"
 #include "atom.h"
 
+#include <linux/firmware.h>
+#include <linux/module.h>
+
 #include "r100_reg_safe.h"
 #include "rn50_reg_safe.h"
 
 #define FIRMWARE_RS600         "radeonkmsfw_RS600_cp"
 #define FIRMWARE_R520          "radeonkmsfw_R520_cp"
 
+MODULE_FIRMWARE(FIRMWARE_R100);
+MODULE_FIRMWARE(FIRMWARE_R200);
+MODULE_FIRMWARE(FIRMWARE_R300);
+MODULE_FIRMWARE(FIRMWARE_R420);
+MODULE_FIRMWARE(FIRMWARE_RS690);
+MODULE_FIRMWARE(FIRMWARE_RS600);
+MODULE_FIRMWARE(FIRMWARE_R520);
+
 #include "r100_track.h"
 
 /* This files gather functions specifics to:
@@ -1024,18 +1035,16 @@ static int r100_cp_init_microcode(struct radeon_device *rdev)
                fw_name = FIRMWARE_R520;
        }
 
-       err = 0;
-       rdev->me_fw = firmware_get(fw_name);
-       if (rdev->me_fw == NULL) {
+       err = request_firmware(&rdev->me_fw, fw_name, rdev->dev);
+       if (err) {
                DRM_ERROR("radeon_cp: Failed to load firmware \"%s\"\n",
                       fw_name);
-               err = -ENOENT;
        } else if (rdev->me_fw->datasize % 8) {
                DRM_ERROR(
                       "radeon_cp: Bogus length %zu in firmware \"%s\"\n",
                       rdev->me_fw->datasize, fw_name);
                err = -EINVAL;
-               firmware_put(rdev->me_fw, FIRMWARE_UNLOAD);
+               release_firmware(rdev->me_fw);
                rdev->me_fw = NULL;
        }
        return err;
@@ -1051,11 +1060,8 @@ static int r100_cp_init_microcode(struct radeon_device *rdev)
  */
 static void r100_cp_fini_microcode (struct radeon_device *rdev)
 {
-
-       if (rdev->me_fw != NULL) {
-               firmware_put(rdev->me_fw, FIRMWARE_UNLOAD);
-               rdev->me_fw = NULL;
-       }
+       release_firmware(rdev->me_fw);
+       rdev->me_fw = NULL;
 }
 
 static void r100_cp_load_microcode(struct radeon_device *rdev)
index bba86ec..03b8a96 100644 (file)
@@ -27,7 +27,8 @@
  *
  * $FreeBSD: head/sys/dev/drm2/radeon/r600.c 254885 2013-08-25 19:37:15Z dumbbell $
  */
-
+#include <linux/firmware.h>
+#include <linux/module.h>
 #include <drm/drmP.h>
 #include <uapi_drm/radeon_drm.h>
 #include "radeon.h"
@@ -38,7 +39,6 @@
 #include "avivod.h"
 #include "radeon_ucode.h"
 
-#ifdef DUMBBELL_WIP
 /* Firmware Names */
 MODULE_FIRMWARE("radeon/R600_pfp.bin");
 MODULE_FIRMWARE("radeon/R600_me.bin");
@@ -94,7 +94,6 @@ MODULE_FIRMWARE("radeon/OLAND_me.bin");
 MODULE_FIRMWARE("radeon/OLAND_ce.bin");
 MODULE_FIRMWARE("radeon/OLAND_mc.bin");
 MODULE_FIRMWARE("radeon/OLAND_rlc.bin");
-#endif /* DUMBBELL_WIP */
 
 static const u32 crtc_offsets[2] =
 {
@@ -2271,14 +2270,11 @@ int r600_init_microcode(struct radeon_device *rdev)
        }
 
        DRM_INFO("Loading %s Microcode\n", chip_name);
-       err = 0;
 
        ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_pfp", chip_name);
-       rdev->pfp_fw = firmware_get(fw_name);
-       if (rdev->pfp_fw == NULL) {
-               err = -ENOENT;
+       err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev);
+       if (err)
                goto out;
-       }
        if (rdev->pfp_fw->datasize != pfp_req_size) {
                DRM_ERROR(
                       "r600_cp: Bogus length %zu in firmware \"%s\"\n",
@@ -2288,11 +2284,9 @@ int r600_init_microcode(struct radeon_device *rdev)
        }
 
        ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_me", chip_name);
-       rdev->me_fw = firmware_get(fw_name);
-       if (rdev->me_fw == NULL) {
-               err = -ENOENT;
+       err = request_firmware(&rdev->me_fw, fw_name, rdev->dev);
+       if (err)
                goto out;
-       }
        if (rdev->me_fw->datasize != me_req_size) {
                DRM_ERROR(
                       "r600_cp: Bogus length %zu in firmware \"%s\"\n",
@@ -2300,13 +2294,10 @@ int r600_init_microcode(struct radeon_device *rdev)
                err = -EINVAL;
        }
 
-       ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_rlc",
-                 rlc_chip_name);
-       rdev->rlc_fw = firmware_get(fw_name);
-       if (rdev->rlc_fw == NULL) {
-               err = -ENOENT;
+       ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_rlc", rlc_chip_name);
+       err = request_firmware(&rdev->rlc_fw, fw_name, rdev->dev);
+       if (err)
                goto out;
-       }
        if (rdev->rlc_fw->datasize != rlc_req_size) {
                DRM_ERROR(
                       "r600_rlc: Bogus length %zu in firmware \"%s\"\n",
@@ -2337,18 +2328,14 @@ out:
                        DRM_ERROR(
                               "r600_cp: Failed to load firmware \"%s\"\n",
                               fw_name);
-               if (rdev->pfp_fw != NULL) {
-                       firmware_put(rdev->pfp_fw, FIRMWARE_UNLOAD);
-                       rdev->pfp_fw = NULL;
-               }
-               if (rdev->me_fw != NULL) {
-                       firmware_put(rdev->me_fw, FIRMWARE_UNLOAD);
-                       rdev->me_fw = NULL;
-               }
-               if (rdev->rlc_fw != NULL) {
-                       firmware_put(rdev->rlc_fw, FIRMWARE_UNLOAD);
-                       rdev->rlc_fw = NULL;
-               }
+               release_firmware(rdev->pfp_fw);
+               rdev->pfp_fw = NULL;
+               release_firmware(rdev->me_fw);
+               rdev->me_fw = NULL;
+               release_firmware(rdev->rlc_fw);
+               rdev->rlc_fw = NULL;
+               release_firmware(rdev->smc_fw);
+               rdev->smc_fw = NULL;
        }
        return err;
 }
@@ -2363,23 +2350,14 @@ out:
  */
 void r600_fini_microcode(struct radeon_device *rdev)
 {
-
-       if (rdev->pfp_fw != NULL) {
-               firmware_put(rdev->pfp_fw, FIRMWARE_UNLOAD);
-               rdev->pfp_fw = NULL;
-       }
-
-       if (rdev->me_fw != NULL) {
-               firmware_put(rdev->me_fw, FIRMWARE_UNLOAD);
-               rdev->me_fw = NULL;
-       }
-
-       if (rdev->rlc_fw != NULL) {
-               firmware_put(rdev->rlc_fw, FIRMWARE_UNLOAD);
-               rdev->rlc_fw = NULL;
-               firmware_put(rdev->smc_fw, FIRMWARE_UNLOAD);
-               rdev->smc_fw = NULL;
-       }
+       release_firmware(rdev->pfp_fw);
+       rdev->pfp_fw = NULL;
+       release_firmware(rdev->me_fw);
+       rdev->me_fw = NULL;
+       release_firmware(rdev->rlc_fw);
+       rdev->rlc_fw = NULL;
+       release_firmware(rdev->smc_fw);
+       rdev->smc_fw = NULL;
 }
 
 static int r600_cp_load_microcode(struct radeon_device *rdev)
index 4787091..1ce5d67 100644 (file)
@@ -34,6 +34,7 @@
 #include <sys/systm.h>
 #include <sys/linker.h>
 #include <sys/firmware.h>
+#include <linux/module.h>
 
 #include <drm/drmP.h>
 #include <uapi_drm/radeon_drm.h>
 #define R700_PFP_UCODE_SIZE 848
 #define R700_PM4_UCODE_SIZE 1360
 
+/* Firmware Names */
+MODULE_FIRMWARE("radeon/R600_pfp.bin");
+MODULE_FIRMWARE("radeon/R600_me.bin");
+MODULE_FIRMWARE("radeon/RV610_pfp.bin");
+MODULE_FIRMWARE("radeon/RV610_me.bin");
+MODULE_FIRMWARE("radeon/RV630_pfp.bin");
+MODULE_FIRMWARE("radeon/RV630_me.bin");
+MODULE_FIRMWARE("radeon/RV620_pfp.bin");
+MODULE_FIRMWARE("radeon/RV620_me.bin");
+MODULE_FIRMWARE("radeon/RV635_pfp.bin");
+MODULE_FIRMWARE("radeon/RV635_me.bin");
+MODULE_FIRMWARE("radeon/RV670_pfp.bin");
+MODULE_FIRMWARE("radeon/RV670_me.bin");
+MODULE_FIRMWARE("radeon/RS780_pfp.bin");
+MODULE_FIRMWARE("radeon/RS780_me.bin");
+MODULE_FIRMWARE("radeon/RV770_pfp.bin");
+MODULE_FIRMWARE("radeon/RV770_me.bin");
+MODULE_FIRMWARE("radeon/RV730_pfp.bin");
+MODULE_FIRMWARE("radeon/RV730_me.bin");
+MODULE_FIRMWARE("radeon/RV710_pfp.bin");
+MODULE_FIRMWARE("radeon/RV710_me.bin");
+
 # define ATI_PCIGART_PAGE_SIZE         4096    /**< PCI GART page size */
 # define ATI_PCIGART_PAGE_MASK         (~(ATI_PCIGART_PAGE_SIZE-1))
 
@@ -297,6 +320,7 @@ static void r600_vm_init(struct drm_device *dev)
 
 static int r600_cp_init_microcode(drm_radeon_private_t *dev_priv)
 {
+       struct platform_device *pdev;
        const char *chip_name;
        size_t pfp_req_size, me_req_size;
        char fw_name[30];
@@ -327,14 +351,11 @@ static int r600_cp_init_microcode(drm_radeon_private_t *dev_priv)
        }
 
        DRM_INFO("Loading %s CP Microcode\n", chip_name);
-       err = 0;
 
        ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_pfp", chip_name);
-       dev_priv->pfp_fw = firmware_get(fw_name);
-       if (dev_priv->pfp_fw == NULL) {
-               err = -ENOENT;
+       err = request_firmware(&dev_priv->pfp_fw, fw_name, &pdev->dev);
+       if (err)
                goto out;
-       }
        if (dev_priv->pfp_fw->datasize != pfp_req_size) {
                DRM_ERROR(
                       "r600_cp: Bogus length %zu in firmware \"%s\"\n",
@@ -344,11 +365,9 @@ static int r600_cp_init_microcode(drm_radeon_private_t *dev_priv)
        }
 
        ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_me", chip_name);
-       dev_priv->me_fw = firmware_get(fw_name);
-       if (dev_priv->me_fw == NULL) {
-               err = -ENOENT;
+       err = request_firmware(&dev_priv->me_fw, fw_name, &pdev->dev);
+       if (err)
                goto out;
-       }
        if (dev_priv->me_fw->datasize != me_req_size) {
                DRM_ERROR(
                       "r600_cp: Bogus length %zu in firmware \"%s\"\n",
@@ -361,14 +380,10 @@ out:
                        DRM_ERROR(
                               "r600_cp: Failed to load firmware \"%s\"\n",
                               fw_name);
-               if (dev_priv->pfp_fw != NULL) {
-                       firmware_put(dev_priv->pfp_fw, FIRMWARE_UNLOAD);
-                       dev_priv->pfp_fw = NULL;
-               }
-               if (dev_priv->me_fw != NULL) {
-                       firmware_put(dev_priv->me_fw, FIRMWARE_UNLOAD);
-                       dev_priv->me_fw = NULL;
-               }
+               release_firmware(dev_priv->pfp_fw);
+               dev_priv->pfp_fw = NULL;
+               release_firmware(dev_priv->me_fw);
+               dev_priv->me_fw = NULL;
        }
        return err;
 }
index dbc4ec8..ca08d65 100644 (file)
@@ -37,6 +37,7 @@
 #include <sys/systm.h>
 #include <sys/linker.h>
 #include <sys/firmware.h>
+#include <linux/module.h>
 
 #include <drm/drmP.h>
 #include <uapi_drm/radeon_drm.h>
 #define FIRMWARE_RS600         "radeonkmsfw_RS600_cp"
 #define FIRMWARE_R520          "radeonkmsfw_R520_cp"
 
+MODULE_FIRMWARE(FIRMWARE_R100);
+MODULE_FIRMWARE(FIRMWARE_R200);
+MODULE_FIRMWARE(FIRMWARE_R300);
+MODULE_FIRMWARE(FIRMWARE_R420);
+MODULE_FIRMWARE(FIRMWARE_RS690);
+MODULE_FIRMWARE(FIRMWARE_RS600);
+MODULE_FIRMWARE(FIRMWARE_R520);
+
 static int radeon_do_cleanup_cp(struct drm_device * dev);
 static void radeon_do_cp_start(drm_radeon_private_t * dev_priv);
 
@@ -469,6 +478,7 @@ static void radeon_init_pipes(struct drm_device *dev)
 /* Load the microcode for the CP */
 static int radeon_cp_init_microcode(drm_radeon_private_t *dev_priv)
 {
+       struct platform_device *pdev;
        const char *fw_name = NULL;
        int err;
 
@@ -517,11 +527,8 @@ static int radeon_cp_init_microcode(drm_radeon_private_t *dev_priv)
                fw_name = FIRMWARE_R520;
        }
 
-       err = 0;
-
-       dev_priv->me_fw = firmware_get(fw_name);
-       if (dev_priv->me_fw == NULL) {
-               err = -ENOENT;
+       err = request_firmware(&dev_priv->me_fw, fw_name, &pdev->dev);
+       if (err) {
                DRM_ERROR("radeon_cp: Failed to load firmware \"%s\"\n",
                       fw_name);
        } else if (dev_priv->me_fw->datasize % 8) {
@@ -529,7 +536,7 @@ static int radeon_cp_init_microcode(drm_radeon_private_t *dev_priv)
                       "radeon_cp: Bogus length %zu in firmware \"%s\"\n",
                       dev_priv->me_fw->datasize, fw_name);
                err = -EINVAL;
-               firmware_put(dev_priv->me_fw, FIRMWARE_UNLOAD);
+               release_firmware(dev_priv->me_fw);
                dev_priv->me_fw = NULL;
        }
        return err;
@@ -1805,14 +1812,10 @@ void radeon_do_release(struct drm_device * dev)
                        r600_do_cleanup_cp(dev);
                else
                        radeon_do_cleanup_cp(dev);
-               if (dev_priv->me_fw != NULL) {
-                       firmware_put(dev_priv->me_fw, FIRMWARE_UNLOAD);
-                       dev_priv->me_fw = NULL;
-               }
-               if (dev_priv->pfp_fw != NULL) {
-                       firmware_put(dev_priv->pfp_fw, FIRMWARE_UNLOAD);
-                       dev_priv->pfp_fw = NULL;
-               }
+               release_firmware(dev_priv->me_fw);
+               dev_priv->me_fw = NULL;
+               release_firmware(dev_priv->pfp_fw);
+               dev_priv->pfp_fw = NULL;
        }
 }
 
index 61b69b0..b1a2326 100644 (file)
@@ -107,7 +107,7 @@ int radeon_uvd_init(struct radeon_device *rdev)
        if (r) {
                dev_err(rdev->dev, "radeon_uvd: Can't load firmware \"%s\"\n",
                        fw_name);
-               return -EINVAL;
+               return r;
        }
 
        bo_size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->datasize + 8) +
index 7545ab9..e27cd33 100644 (file)
@@ -23,9 +23,9 @@
  *
  * $FreeBSD: head/sys/dev/drm2/radeon/si.c 254885 2013-08-25 19:37:15Z dumbbell $
  */
-
-#include <drm/drmP.h>
 #include <linux/firmware.h>
+#include <linux/module.h>
+#include <drm/drmP.h>
 #include "radeon.h"
 #include "radeon_asic.h"
 #include <uapi_drm/radeon_drm.h>
@@ -43,6 +43,8 @@
 #define PCI_EXP_DEVSTA_TRPND 0x0020
 #define PCI_EXP_LNKCAP_CLKPM 0x00040000
 
+MODULE_FIRMWARE("radeon/TAHITI_pfp.bin");
+MODULE_FIRMWARE("radeon/TAHITI_me.bin");
 MODULE_FIRMWARE("radeon/TAHITI_ce.bin");
 MODULE_FIRMWARE("radeon/TAHITI_mc.bin");
 MODULE_FIRMWARE("radeon/TAHITI_rlc.bin");
@@ -1603,14 +1605,11 @@ static int si_init_microcode(struct radeon_device *rdev)
        }
 
        DRM_INFO("Loading %s Microcode\n", chip_name);
-       err = 0;
 
        ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_pfp", chip_name);
-       rdev->pfp_fw = firmware_get(fw_name);
-       if (rdev->pfp_fw == NULL) {
-               err = -ENOENT;
+       err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev);
+       if (err)
                goto out;
-       }
        if (rdev->pfp_fw->datasize != pfp_req_size) {
                DRM_ERROR(
                       "si_cp: Bogus length %zu in firmware \"%s\"\n",
@@ -1620,11 +1619,9 @@ static int si_init_microcode(struct radeon_device *rdev)
        }
 
        ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_me", chip_name);
-       rdev->me_fw = firmware_get(fw_name);
-       if (rdev->me_fw == NULL) {
-               err = -ENOENT;
+       err = request_firmware(&rdev->me_fw, fw_name, rdev->dev);
+       if (err)
                goto out;
-       }
        if (rdev->me_fw->datasize != me_req_size) {
                DRM_ERROR(
                       "si_cp: Bogus length %zu in firmware \"%s\"\n",
@@ -1633,11 +1630,9 @@ static int si_init_microcode(struct radeon_device *rdev)
        }
 
        ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_ce", chip_name);
-       rdev->ce_fw = firmware_get(fw_name);
-       if (rdev->ce_fw == NULL) {
-               err = -ENOENT;
+       err = request_firmware(&rdev->ce_fw, fw_name, rdev->dev);
+       if (err)
                goto out;
-       }
        if (rdev->ce_fw->datasize != ce_req_size) {
                DRM_ERROR(
                       "si_cp: Bogus length %zu in firmware \"%s\"\n",
@@ -1645,13 +1640,10 @@ static int si_init_microcode(struct radeon_device *rdev)
                err = -EINVAL;
        }
 
-       ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_rlc",
-                 rlc_chip_name);
-       rdev->rlc_fw = firmware_get(fw_name);
-       if (rdev->rlc_fw == NULL) {
-               err = -ENOENT;
+       ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_rlc", rlc_chip_name);
+       err = request_firmware(&rdev->rlc_fw, fw_name, rdev->dev);
+       if (err)
                goto out;
-       }
        if (rdev->rlc_fw->datasize != rlc_req_size) {
                DRM_ERROR(
                       "si_rlc: Bogus length %zu in firmware \"%s\"\n",
@@ -1660,11 +1652,9 @@ static int si_init_microcode(struct radeon_device *rdev)
        }
 
        ksnprintf(fw_name, sizeof(fw_name), "radeonkmsfw_%s_mc", chip_name);
-       rdev->mc_fw = firmware_get(fw_name);
-       if (rdev->mc_fw == NULL) {
-               err = -ENOENT;
+       err = request_firmware(&rdev->mc_fw, fw_name, rdev->dev);
+       if (err)
                goto out;
-       }
        if (rdev->mc_fw->datasize != mc_req_size) {
                DRM_ERROR(
                       "si_mc: Bogus length %zu in firmware \"%s\"\n",
@@ -1693,30 +1683,18 @@ out:
                        DRM_ERROR(
                               "si_cp: Failed to load firmware \"%s\"\n",
                               fw_name);
-               if (rdev->pfp_fw != NULL) {
-                       firmware_put(rdev->pfp_fw, FIRMWARE_UNLOAD);
-                       rdev->pfp_fw = NULL;
-               }
-               if (rdev->me_fw != NULL) {
-                       firmware_put(rdev->me_fw, FIRMWARE_UNLOAD);
-                       rdev->me_fw = NULL;
-               }
-               if (rdev->ce_fw != NULL) {
-                       firmware_put(rdev->ce_fw, FIRMWARE_UNLOAD);
-                       rdev->ce_fw = NULL;
-               }
-               if (rdev->rlc_fw != NULL) {
-                       firmware_put(rdev->rlc_fw, FIRMWARE_UNLOAD);
-                       rdev->rlc_fw = NULL;
-               }
-               if (rdev->mc_fw != NULL) {
-                       firmware_put(rdev->mc_fw, FIRMWARE_UNLOAD);
-                       rdev->mc_fw = NULL;
-               }
-               if (rdev->smc_fw != NULL) {
-                       firmware_put(rdev->smc_fw, FIRMWARE_UNLOAD);
-                       rdev->smc_fw = NULL;
-               }
+               release_firmware(rdev->pfp_fw);
+               rdev->pfp_fw = NULL;
+               release_firmware(rdev->me_fw);
+               rdev->me_fw = NULL;
+               release_firmware(rdev->ce_fw);
+               rdev->ce_fw = NULL;
+               release_firmware(rdev->rlc_fw);
+               rdev->rlc_fw = NULL;
+               release_firmware(rdev->mc_fw);
+               rdev->mc_fw = NULL;
+               release_firmware(rdev->smc_fw);
+               rdev->smc_fw = NULL;
        }
        return err;
 }
@@ -1731,36 +1709,18 @@ out:
  */
 static void si_fini_microcode(struct radeon_device *rdev)
 {
-
-       if (rdev->pfp_fw != NULL) {
-               firmware_put(rdev->pfp_fw, FIRMWARE_UNLOAD);
-               rdev->pfp_fw = NULL;
-       }
-
-       if (rdev->me_fw != NULL) {
-               firmware_put(rdev->me_fw, FIRMWARE_UNLOAD);
-               rdev->me_fw = NULL;
-       }
-
-       if (rdev->rlc_fw != NULL) {
-               firmware_put(rdev->rlc_fw, FIRMWARE_UNLOAD);
-               rdev->rlc_fw = NULL;
-       }
-
-       if (rdev->mc_fw != NULL) {
-               firmware_put(rdev->mc_fw, FIRMWARE_UNLOAD);
-               rdev->mc_fw = NULL;
-       }
-
-       if (rdev->smc_fw != NULL) {
-               firmware_put(rdev->smc_fw, FIRMWARE_UNLOAD);
-               rdev->smc_fw = NULL;
-       }
-
-       if (rdev->ce_fw != NULL) {
-               firmware_put(rdev->ce_fw, FIRMWARE_UNLOAD);
-               rdev->ce_fw = NULL;
-       }
+       release_firmware(rdev->pfp_fw);
+       rdev->pfp_fw = NULL;
+       release_firmware(rdev->me_fw);
+       rdev->me_fw = NULL;
+       release_firmware(rdev->rlc_fw);
+       rdev->rlc_fw = NULL;
+       release_firmware(rdev->mc_fw);
+       rdev->mc_fw = NULL;
+       release_firmware(rdev->smc_fw);
+       rdev->smc_fw = NULL;
+       release_firmware(rdev->ce_fw);
+       rdev->ce_fw = NULL;
 }
 
 /* watermark setup */