radeon_cp: use request_firmware
Subsystems (2)
PATCH 1/1 radeon_cp: use request_firmware
Moved datah before datal because datah is required before datal.
Firmware blob looks like this...
__be32 datah __be32 datal
Thanks to Ben for help and testing.
--- drivers/gpu/drm/radeon/radeon_cp.c | 123 ++- drivers/gpu/drm/radeon/radeon_drv.h | 5 + drivers/gpu/drm/radeon/radeon_microcode.h | 1844 ----------------------------- firmware/Makefile | 4 + firmware/WHENCE | 40 + firmware/radeon/R100_cp.bin.ihex | 130 ++ firmware/radeon/R200_cp.bin.ihex | 130 ++ firmware/radeon/R300_cp.bin.ihex | 130 ++ firmware/radeon/R420_cp.bin.ihex | 130 ++ firmware/radeon/R520_cp.bin.ihex | 130 ++ firmware/radeon/RS600_cp.bin.ihex | 130 ++ firmware/radeon/RS690_cp.bin.ihex | 130 ++ 12 files changed, 1037 insertions(+), 1889 deletions(-) delete mode 100644 drivers/gpu/drm/radeon/radeon_microcode.h create mode 100644 firmware/radeon/R100_cp.bin.ihex create mode 100644 firmware/radeon/R200_cp.bin.ihex create mode 100644 firmware/radeon/R300_cp.bin.ihex create mode 100644 firmware/radeon/R420_cp.bin.ihex create mode 100644 firmware/radeon/R520_cp.bin.ihex create mode 100644 firmware/radeon/RS600_cp.bin.ihex create mode 100644 firmware/radeon/RS690_cp.bin.ihex
drivers/gpu/drm/radeon/radeon_cp.c +78 -45
@@ -36,10 +36,25 @@#include "radeon_drv.h" #include "r300_reg.h" -#include "radeon_microcode.h" -#define RADEON_FIFO_DEBUG 0 +/* Firmware Name */ +#define FIRMWARE_R100 "radeon/R100_cp.bin" +#define FIRMWARE_R200 "radeon/R200_cp.bin" +#define FIRMWARE_R300 "radeon/R300_cp.bin" +#define FIRMWARE_R420 "radeon/R420_cp.bin" +#define FIRMWARE_RS600 "radeon/RS600_cp.bin" +#define FIRMWARE_RS690 "radeon/RS690_cp.bin" +#define FIRMWARE_R520 "radeon/R520_cp.bin" + +MODULE_FIRMWARE (FIRMWARE_R100 ); +MODULE_FIRMWARE (FIRMWARE_R200 ); +MODULE_FIRMWARE (FIRMWARE_R300 ); +MODULE_FIRMWARE (FIRMWARE_R420 ); +MODULE_FIRMWARE (FIRMWARE_RS600 ); +MODULE_FIRMWARE (FIRMWARE_RS690 ); +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);
@@ -451,12 +466,19 @@ static void radeon_init_pipes(drm_radeon_private_t *dev_priv)*/ /* Load the microcode for the CP */ -static void radeon_cp_load_microcode (drm_radeon_private_t * dev_priv) +static int radeon_cp_init_microcode (drm_radeon_private_t *dev_priv) { -int i; -DRM_DEBUG ("\n" ); +struct platform_device *pdev; +const char *fw_name =NULL ; +int err; -radeon_do_wait_for_idle (dev_priv); +DRM_DEBUG ("\n" ); + pdev =platform_device_register_simple ("radeon_cp" ,0 ,NULL ,0 ); + err =IS_ERR (pdev); +if (err) { +DRM_ERROR ("radeon_cp: Failed to register firmware\n" ); +return -EINVAL ; + }RADEON_WRITE (RADEON_CP_ME_RAM_ADDR ,0 ); if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_R100) ||
@@ -465,23 +487,13 @@ static void radeon_cp_load_microcode(drm_radeon_private_t * dev_priv) ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS100) || ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS200)) {DRM_INFO ("Loading R100 Microcode\n" ); -for (i =0 ; i <256 ; i++) { -RADEON_WRITE (RADEON_CP_ME_RAM_DATAH , - R100_cp_microcode[i][1 ]); -RADEON_WRITE (RADEON_CP_ME_RAM_DATAL , - R100_cp_microcode[i][0 ]); - } + fw_name =FIRMWARE_R100 ; } else if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_R200) || ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV250) || ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV280) || ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS300)) {DRM_INFO ("Loading R200 Microcode\n" ); -for (i =0 ; i <256 ; i++) { -RADEON_WRITE (RADEON_CP_ME_RAM_DATAH , - R200_cp_microcode[i][1 ]); -RADEON_WRITE (RADEON_CP_ME_RAM_DATAL , - R200_cp_microcode[i][0 ]); - } + fw_name =FIRMWARE_R200 ; } else if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_R300) || ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_R350) || ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV350) ||
@@ -489,39 +501,19 @@ static void radeon_cp_load_microcode(drm_radeon_private_t * dev_priv) ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS400) || ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS480)) {DRM_INFO ("Loading R300 Microcode\n" ); -for (i =0 ; i <256 ; i++) { -RADEON_WRITE (RADEON_CP_ME_RAM_DATAH , - R300_cp_microcode[i][1 ]); -RADEON_WRITE (RADEON_CP_ME_RAM_DATAL , - R300_cp_microcode[i][0 ]); - } + fw_name =FIRMWARE_R300 ; } else if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_R420) || ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_R423) || ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV410)) {DRM_INFO ("Loading R400 Microcode\n" ); -for (i =0 ; i <256 ; i++) { -RADEON_WRITE (RADEON_CP_ME_RAM_DATAH , - R420_cp_microcode[i][1 ]); -RADEON_WRITE (RADEON_CP_ME_RAM_DATAL , - R420_cp_microcode[i][0 ]); - } + fw_name =FIRMWARE_R420 ; } else if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) || ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740)) {DRM_INFO ("Loading RS690/RS740 Microcode\n" ); -for (i =0 ; i <256 ; i++) { -RADEON_WRITE (RADEON_CP_ME_RAM_DATAH , - RS690_cp_microcode[i][1 ]); -RADEON_WRITE (RADEON_CP_ME_RAM_DATAL , - RS690_cp_microcode[i][0 ]); - } + fw_name =FIRMWARE_RS690 ; } else if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS600) {DRM_INFO ("Loading RS600 Microcode\n" ); -for (i =0 ; i <256 ; i++) { -RADEON_WRITE (RADEON_CP_ME_RAM_DATAH , - RS600_cp_microcode[i][1 ]); -RADEON_WRITE (RADEON_CP_ME_RAM_DATAL , - RS600_cp_microcode[i][0 ]); - } + fw_name =FIRMWARE_RS600 ; } else if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV515) || ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_R520) || ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV530) ||
@@ -529,11 +521,39 @@ static void radeon_cp_load_microcode(drm_radeon_private_t * dev_priv) ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV560) || ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV570)) {DRM_INFO ("Loading R500 Microcode\n" ); -for (i =0 ; i <256 ; i++) { + fw_name =FIRMWARE_R520 ; + } + + err =request_firmware (&dev_priv->fw, fw_name, &pdev->dev); +platform_device_unregister (pdev); +if (err) +pr_err ("radeon_cp: Failed to load firmware \"%s\"\n" , fw_name); +else if (dev_priv->fw->size %8 ) { +pr_err ("radeon_cp: Bogus length %zu in firmware \"%s\"\n" , + dev_priv->fw->size, fw_name); + err = -EINVAL ; +release_firmware (dev_priv->fw); + dev_priv->fw =NULL ; + } +return err; +} + +static void radeon_cp_load_microcode (drm_radeon_private_t *dev_priv) +{ +const __be32 *fw_data; +int i, size; + +radeon_do_wait_for_idle (dev_priv); + +if (dev_priv->fw) { + size = dev_priv->fw->size /4 ; + fw_data = (const __be32 *)&dev_priv->fw->data[0 ]; +RADEON_WRITE (RADEON_CP_ME_RAM_ADDR ,0 ); +for (i =0 ; i < size; i +=2 ) {RADEON_WRITE (RADEON_CP_ME_RAM_DATAH , - R520_cp_microcode[i][1 ]); +be32_to_cpup (&fw_data[i]));RADEON_WRITE (RADEON_CP_ME_RAM_DATAL , - R520_cp_microcode[i][0 ]); +be32_to_cpup (&fw_data[i +1 ])); } } }
@@ -1486,6 +1506,14 @@ static int radeon_do_init_cp(struct drm_device *dev, drm_radeon_init_t *init,radeon_set_pcigart (dev_priv,1 ); } +if (!dev_priv->fw) { +int err =radeon_cp_init_microcode (dev_priv); +if (err) { +DRM_ERROR ("Failed to load firmware!\n" ); +radeon_do_cleanup_cp (dev); +return err; + } + }radeon_cp_load_microcode (dev_priv);radeon_cp_init_ring_buffer (dev, dev_priv, file_priv);
@@ -1755,6 +1783,11 @@ void radeon_do_release(struct drm_device * dev)r600_do_cleanup_cp (dev); elseradeon_do_cleanup_cp (dev ); + +if (dev_priv->fw) { +release_firmware (dev_priv->fw); + dev_priv->fw =NULL ; + } } }
drivers/gpu/drm/radeon/radeon_drv.h +5 -0
@@ -31,6 +31,9 @@#ifndef __RADEON_DRV_H__#define __RADEON_DRV_H__ +#include <linux/firmware.h> +#include <linux/platform_device.h> +/* General customization: */
@@ -348,6 +351,8 @@ typedef struct drm_radeon_private {int r700_sc_hiz_tile_fifo_size;int r700_sc_earlyz_tile_fifo_fize; +/* firmware */ +const struct firmware *fw; } drm_radeon_private_t; typedef struct drm_radeon_buf_priv {
drivers/gpu/drm/radeon/radeon_microcode.h deleted +0 -1844
1,844 lines not on this page · raw message
firmware/Makefile +4 -0
@@ -41,6 +41,10 @@ fw-shipped-$(CONFIG_COMPUTONE) += intelliport2.bin fw-shipped-$(CONFIG_CHELSIO_T3) += cxgb3/t3b_psram-1.1.0.bin \ cxgb3/t3c_psram-1.1.0.bin \ cxgb3/t3fw-7.1.0.bin +fw-shipped-$(CONFIG_DRM_RADEON) += radeon/R100_cp.bin radeon/R200_cp.bin \ + radeon/R300_cp.bin radeon/R420_cp.bin \ + radeon/RS600_cp.bin radeon/RS690_cp.bin \ + radeon/R520_cp.bin fw-shipped-$(CONFIG_DVB_AV7110) += av7110/bootcode.bin fw-shipped-$(CONFIG_DVB_TTUSB_BUDGET) += ttusb-budget/dspbootcode.bin fw-shipped-$(CONFIG_E100) += e100/d101m_ucode.bin e100/d101s_ucode.bin \
firmware/WHENCE +40 -0
@@ -648,3 +648,43 @@ Found in hex form in kernel source, with the following comment: Copyright (c) 1998-2002 by Paul Davis <[email protected]> -------------------------------------------------------------------------- + +Driver: DRM_RADEON - ATI Radeon + +File: radeon/R100_cp.bin +File: radeon/R200_cp.bin +File: radeon/R300_cp.bin +File: radeon/R420_cp.bin +File: radeon/RS600_cp.bin +File: radeon/RS690_cp.bin +File: radeon/R520_cp.bin + +Licence: +/* + * Copyright 2007 Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +Found in hex form in kernel source. + +--------------------------------------------------------------------------
firmware/radeon/R100_cp.bin.ihex new file +130 -0
130 lines not on this page · raw message
firmware/radeon/R200_cp.bin.ihex new file +130 -0
130 lines not on this page · raw message
firmware/radeon/R300_cp.bin.ihex new file +130 -0
130 lines not on this page · raw message
firmware/radeon/R420_cp.bin.ihex new file +130 -0
130 lines not on this page · raw message
firmware/radeon/R520_cp.bin.ihex new file +130 -0
130 lines not on this page · raw message
firmware/radeon/RS600_cp.bin.ihex new file +130 -0
130 lines not on this page · raw message
firmware/radeon/RS690_cp.bin.ihex new file +130 -0
121 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.6.0.6
Part of the diff is not shown here. View the raw message.
Please use <[email protected]> for all mail related to my work on firmware separation, which has nothing to do with my employment.
Quoted 7 lines · Jaswinder Singh Rajput
Moved datah before datal because datah is required before datal.
Firmware blob looks like this...
__be32 datah __be32 datalThanks to Ben for help and testing.
[...]
This is out of date as there are now an r600_microcode.h and r600_cp.c.
My latest patch (not posted anywhere yet) is at
<http://womble.decadent.org.uk/tmp/fw-patch/0003-radeon-Use-request_firmware.patch> (patches 0001-0003 should be applicable in order to drm-2.6/drm-linus). But I don't have any R600/R700 hardware to test it on.
Ben.
Quoted 10 lines · Ben Hutchings
Please use <[email protected]> for all mail related to my work on firmware separation, which has nothing to do with my employment.
Quoted 6 lines · Jaswinder Singh Rajput
Moved datah before datal because datah is required before datal.
Firmware blob looks like this...
__be32 datah __be32 datal
Quoted 7 lines
Quoted 1 line
Thanks to Ben for help and testing.
[...]
This is out of date as there are now an
r600_microcode.handr600_cp.c.
My latest patch (not posted anywhere yet) is at
<http://womble.decadent.org.uk/tmp/fw-patch/0003-radeon-Use-request_firmware.patch> (patches 0001-0003 should be applicable in order to drm-2.6/drm-linus). But I don't have any R600/R700 hardware to test it on.
I am very surprise you take my patches and post them without CC to me ?
Please use my signed-off in my patches in first place:
Or prepare incremental patch to my patch.
Here are other stolen patches without CC and my Signed-off:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=06e1f9ffa023c030bc87491e75f625f5da4e7d97
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b775a750c3afacbfac884537d466d34d50b1023b
Why you do this ?
--
JSR
Quoted 12 lines · Jaswinder Singh Rajput
Quoted 11 lines · Ben Hutchings
Please use <[email protected]> for all mail related to my work on firmware separation, which has nothing to do with my employment.
Quoted 7 lines · Jaswinder Singh Rajput
Moved datah before datal because datah is required before datal.
Firmware blob looks like this...
__be32 datah __be32 datalThanks to Ben for help and testing.
Quoted 8 lines
Quoted 6 lines
[...]
This is out of date as there are now an
r600_microcode.handr600_cp.c.
My latest patch (not posted anywhere yet) is at
<http://womble.decadent.org.uk/tmp/fw-patch/0003-radeon-Use-request_firmware.patch> (patches 0001-0003 should be applicable in order to drm-2.6/drm-linus). But I don't have any R600/R700 hardware to test it on.I am very surprise you take my patches and post them without CC to me ?
As I said, I haven't posted those yet.
Quoted 8 lines
Please use my signed-off in my patches in first place:
Signed-off-by Jaswinder Singh Rajput <[email protected]>Or prepare incremental patch to my patch.
Here are other stolen patches without CC and my Signed-off:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=06e1f9ffa023c030bc87491e75f625f5da4e7d97
So far as I can remember (I haven't checked) your patch was defective and I considered that to be a complete rewrite.
Quoted 1 line
That was credited and cc'd to <[email protected]> which maybe isn't the best address to use. Well, now that I look again, it appears that I forgot to cc you on the final version which was accepted. I'm sorry about that.
Quoted 1 line
Why you do this ?
I don't copy Signed-off-by if I make significant changes as the original author should not be held responsible for any errors. I'll be happy to ask for your S-o-b before submitting a patch based on your work in future.
Ben.
Signature · 3 lines
Ben Hutchings
Experience is directly proportional to the value of equipment destroyed.
- Carolyn ScheppnerQuoted 3 lines · Ben Hutchings
I don't copy Signed-off-by if I make significant changes as the original author should not be held responsible for any errors. I'll be happy to ask for your S-o-b before submitting a patch based on your work in future.
I think we should never include the original SOB if there was _any_ change. SOB is not credits, it's a signature. If someone takes my patch and changes it, I want my SOB line removed unless I re-sign the modified patch.
We may invent some other Based-on-patch-by: etc. tag if really necessary, but the signature is a different thing.
Signature · 1 line
Krzysztof Halasa
Quoted 6 lines · Krzysztof Halasa
Quoted 3 lines · Ben Hutchings
I don't copy Signed-off-by if I make significant changes as the original author should not be held responsible for any errors. I'll be happy to ask for your S-o-b before submitting a patch based on your work in future.
Quoted 7 lines
I think we should never include the original SOB if there was _any_ change. SOB is not credits, it's a signature. If someone takes my patch and changes it, I want my SOB line removed unless I re-sign the modified patch.
We may invent some other Based-on-patch-by: etc. tag if really necessary, but the signature is a different thing.
Given that this is the 2nd or 3rd instance of someone feeling that their code has been used without credit, that may be a good idea. I certainly can see the point, having had a significant effort of mine lightly patched and then given to FSF without my name on it.
Signature · 3 lines
Bill Davidsen <[email protected]> "We have more to fear from the bungling of the incompetent than from the machinations of the wicked." - from Slashdot