Bug 80331

Summary: [BISECTED]Radeon driver broken in kernel 3.12.15 onwards for ATI Radeon HD4770 Card
Product: Drivers Reporter: Colin (colin.bruce)
Component: Video(DRI - non Intel)Assignee: drivers_video-dri
Status: RESOLVED INVALID    
Severity: normal CC: alan, alexdeucher
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.12.15+ Subsystem:
Regression: No Bisected commit-id:
Attachments: Patch which causes the problem
Log files

Description Colin 2014-07-16 03:48:45 UTC
Created attachment 143191 [details]
Patch which causes the problem

Kernel version 3.12.15 upto and including 3.15.4 has a bug that prevents ATI Radeon HD4770 cards from working in anything other than VGA mode. For example, X does not start and in text mode setfont -v ter-228n.psf.gz will fail with the error "Putfont: KDFONTOP: Invalid argument"

Kernels prior to 3.12.15 work somewhat better although there are other problems which may be related, I'll submit a separate bug report about this.

The cause seems to be the patch introduced in 3.12.15 to the file drivers/gpu/drm/radeon/rv770.c. The patch is attached. If this patch is undone then the errors are nor present.


Best wishes....
Colin Bruce
Comment 1 Colin 2014-07-19 18:52:54 UTC
Tried compiling as a module and driver works correctly without undoing the patch mentioned in the report. It only seems to be a problem when the driver is statically linked in the kernel.
Comment 2 Alex Deucher 2014-07-29 16:06:33 UTC
You need to have the firmware installed to use the driver.  We don't support the driver without firmware loaded.
Comment 3 Colin 2014-07-29 16:15:19 UTC
(In reply to Alex Deucher from comment #2)
> You need to have the firmware installed to use the driver.  We don't support
> the driver without firmware loaded.

Sorry, I didn't explain very well. The firmware is installed; it just doesn't load when the patch I attached is applied and the driver is statically linked. If the patch is undone with no other changes the firmware seems to load and the card works. Equally if I leave the patch in but make the driver a module instead of being statically linked then it also works.

The reason I suggested the firmware is failing to load with the patch present is that I inserted printk statements at various places and found that the function to load the firmware returns an error even though when it is using the correct path to the firmware file.

Best wishes.....
Colin
Comment 4 Alex Deucher 2014-07-29 16:55:23 UTC
If the driver is built into the kernel, you need to built the firmware into the kernel as well.
Comment 5 Colin 2014-07-29 16:58:56 UTC
(In reply to Alex Deucher from comment #4)
> If the driver is built into the kernel, you need to built the firmware into
> the kernel as well.

I am just using the standard build system e.g. make bzImage. As I said if I remove the patch I mentioned in the original post everything works fine. If the patch is applied it doesn't work. I don't know if that has anything to do with building the firmware.
Comment 6 Alex Deucher 2014-07-29 17:13:15 UTC
(In reply to Colin from comment #5)
> (In reply to Alex Deucher from comment #4)
> > If the driver is built into the kernel, you need to built the firmware into
> > the kernel as well.
> 
> I am just using the standard build system e.g. make bzImage. As I said if I
> remove the patch I mentioned in the original post everything works fine. If
> the patch is applied it doesn't work. I don't know if that has anything to
> do with building the firmware.

The firmware still fails to load, it just fails later and the driver does not fail to load because of it.
Comment 7 Colin 2014-07-29 17:23:12 UTC
(In reply to Alex Deucher from comment #6)
> (In reply to Colin from comment #5)
> > (In reply to Alex Deucher from comment #4)
> > > If the driver is built into the kernel, you need to built the firmware
> into
> > > the kernel as well.
> > 
> > I am just using the standard build system e.g. make bzImage. As I said if I
> > remove the patch I mentioned in the original post everything works fine. If
> > the patch is applied it doesn't work. I don't know if that has anything to
> > do with building the firmware.
> 
> The firmware still fails to load, it just fails later and the driver does
> not fail to load because of it.

Oh. I hadn't realised. Anyway, with the patch removed the card supports XV in X windows and with the patch installed it doesn't. If the firmware always fails to load what does it do?
Comment 8 Alex Deucher 2014-07-29 17:26:49 UTC
(In reply to Colin from comment #7)
> 
> Oh. I hadn't realised. Anyway, with the patch removed the card supports XV
> in X windows and with the patch installed it doesn't. If the firmware always
> fails to load what does it do?

The firmware doesn't always fail to load; it loads fine.  Something is wrong with yourt setup.  Attach your xorg log and dmesg output for both cases.
Comment 9 Colin 2014-07-29 17:36:24 UTC
(In reply to Alex Deucher from comment #8)
> (In reply to Colin from comment #7)
> > 
> > Oh. I hadn't realised. Anyway, with the patch removed the card supports XV
> > in X windows and with the patch installed it doesn't. If the firmware
> always
> > fails to load what does it do?
> 
> The firmware doesn't always fail to load; it loads fine.  Something is wrong
> with yourt setup.  Attach your xorg log and dmesg output for both cases.

but it was you that said it always failed to load so I am getting confused now.

It is not to do with X  because the problem shows up in plain text mode as well before X is ever loaded. With the patch installed it won't load any fonts other than the default one when it is booting. With the patch removed it will with no other changes.

If I undo the patch and make no other changes what so ever it works correctly

If I compile the driver as a module it with no other changes what so ever it works correctly.

If I apply the patch and compile the kernel with the driver statically linked but no other changes what so ever it works correctly.

I don't see how it can be my setup when the only change to make it work or break is that patch.

I am not at home just now so I can't create a dmesg or xorg file but I'll send them later.
Comment 10 Alex Deucher 2014-07-29 17:53:32 UTC
(In reply to Colin from comment #9)
> but it was you that said it always failed to load so I am getting confused
> now.
> 
> It is not to do with X  because the problem shows up in plain text mode as
> well before X is ever loaded. With the patch installed it won't load any
> fonts other than the default one when it is booting. With the patch removed
> it will with no other changes.
> 
> If I undo the patch and make no other changes what so ever it works correctly
> 
> If I compile the driver as a module it with no other changes what so ever it
> works correctly.
> 
> If I apply the patch and compile the kernel with the driver statically
> linked but no other changes what so ever it works correctly.
> 
> I don't see how it can be my setup when the only change to make it work or
> break is that patch.

I was referring to your setup.  All the patch does it move the firmware loading earlier in the driver init process.  So if the firmware loading fails with the patch applied, it should also fail without it asuming everything else is the same in your setup.  Something is wrong with your local configuration such that the firmware is not availabl at driver load in some cases.  The firmware is required to use acceleration in the driver.
Comment 11 Colin 2014-07-29 23:11:32 UTC
(In reply to Alex Deucher from comment #10)
> (In reply to Colin from comment #9)
> > but it was you that said it always failed to load so I am getting confused
> > now.
> > 
> > It is not to do with X  because the problem shows up in plain text mode as
> > well before X is ever loaded. With the patch installed it won't load any
> > fonts other than the default one when it is booting. With the patch removed
> > it will with no other changes.
> > 
> > If I undo the patch and make no other changes what so ever it works
> correctly
> > 
> > If I compile the driver as a module it with no other changes what so ever
> it
> > works correctly.
> > 
> > If I apply the patch and compile the kernel with the driver statically
> > linked but no other changes what so ever it works correctly.
> > 
> > I don't see how it can be my setup when the only change to make it work or
> > break is that patch.
> 
> I was referring to your setup.  All the patch does it move the firmware
> loading earlier in the driver init process.  So if the firmware loading
> fails with the patch applied, it should also fail without it asuming
> everything else is the same in your setup.  Something is wrong with your
> local configuration such that the firmware is not availabl at driver load in
> some cases.  The firmware is required to use acceleration in the driver.

I've built three versions of the same kernel 3.15.4. The first is the standard kernel including the patch with the radeon driver built as a module. The second is the kernel with the radeon driver statically linked and the third is also statically linked but this time with that patch removed. I've booted from each kernel and made copies of the output from dmesg, the output of setfont and the Xorg log file. I've put the 9 files in a zip file and attached it. The names of each file will tell you what they are.

I think your suggestion is correct. With the patch applied something is not ready that prevents the firmware from being loaded. Without the patch or with the driver loaded as a module the firmware loads every time. Loading as a module will presumably mean that it tries to access the firmware file later in the boot process.
Comment 12 Colin 2014-07-29 23:13:04 UTC
Created attachment 144641 [details]
Log files

9 Log files demonstrating the problem
Comment 13 Alex Deucher 2014-07-30 13:39:09 UTC
You need to compile the firmware into your kernel when you build the driver into the kernel.  In both of your static builds, the firmware fails to load:

static-with-patch:
[    0.263616] r600_cp: Failed to load firmware "radeon/RV730_pfp.bin"
[    0.263668] [drm:rv770_init] *ERROR* Failed to load firmware!
[    0.263721] radeon 0000:01:00.0: Fatal error during GPU init

static-without-patch:
[    0.269288] [drm] Loading RV730 Microcode
[    0.269354] r600_cp: Failed to load firmware "radeon/RV730_pfp.bin"
[    0.269403] [drm:rv770_startup] *ERROR* Failed to load firmware!

You need to specify CONFIG_EXTRA_FIRMWARE in your kernel configuration and point it to the firmware files required by the driver.  E.g.,

CONFIG_FIRMWARE_IN_KERNEL=y
CONFIG_EXTRA_FIRMWARE_DIR="/lib/firmware"
CONFIG_EXTRA_FIRMWARE="radeon/RV730_me.bin radeon/RV730_pfp.bin radeon/R700_rlc.bin RV740_smc.bin"
Comment 14 Colin 2014-07-30 14:15:37 UTC
(In reply to Alex Deucher from comment #13)
> You need to compile the firmware into your kernel when you build the driver
> into the kernel.  In both of your static builds, the firmware fails to load:
> 
> static-with-patch:
> [    0.263616] r600_cp: Failed to load firmware "radeon/RV730_pfp.bin"
> [    0.263668] [drm:rv770_init] *ERROR* Failed to load firmware!
> [    0.263721] radeon 0000:01:00.0: Fatal error during GPU init
> 
> static-without-patch:
> [    0.269288] [drm] Loading RV730 Microcode
> [    0.269354] r600_cp: Failed to load firmware "radeon/RV730_pfp.bin"
> [    0.269403] [drm:rv770_startup] *ERROR* Failed to load firmware!
> 
> You need to specify CONFIG_EXTRA_FIRMWARE in your kernel configuration and
> point it to the firmware files required by the driver.  E.g.,
> 
> CONFIG_FIRMWARE_IN_KERNEL=y
> CONFIG_EXTRA_FIRMWARE_DIR="/lib/firmware"
> CONFIG_EXTRA_FIRMWARE="radeon/RV730_me.bin radeon/RV730_pfp.bin
> radeon/R700_rlc.bin RV740_smc.bin"

Thanks I'll give it a go when I home from work tonight. I am sure that will be the solution. Strange thing is that even with the firmware not loaded the card works fine when the patch is not present.
Comment 15 Alex Deucher 2014-07-30 14:47:05 UTC
(In reply to Colin from comment #14)
> 
> Thanks I'll give it a go when I home from work tonight. I am sure that will
> be the solution. Strange thing is that even with the firmware not loaded the
> card works fine when the patch is not present.

The patch changes when the firmware loads during driver init.  With the patch the failure happens earlier so the error is fatal and the driver doesn't load.  Without the patch, the driver still loads but all acceleration, interrupts, and most other features are disabled so it's not exactly working.
Comment 16 Colin 2014-07-31 09:57:48 UTC
(In reply to Alex Deucher from comment #15)
> (In reply to Colin from comment #14)
> > 
> > Thanks I'll give it a go when I home from work tonight. I am sure that will
> > be the solution. Strange thing is that even with the firmware not loaded
> the
> > card works fine when the patch is not present.
> 
> The patch changes when the firmware loads during driver init.  With the
> patch the failure happens earlier so the error is fatal and the driver
> doesn't load.  Without the patch, the driver still loads but all
> acceleration, interrupts, and most other features are disabled so it's not
> exactly working.

That explains it. I guess when it is a module it loads the firmware when the module loads and initializes. I had a look at the request_firmware() function and I think it will read the firmware if it is not already in memory. I suspect that can't work when it is static as the driver is initialized before the disk drivers are loaded. Anyway the so called "bug" turns out to be my stupidity:-( Such is life.

In any event thanks for all your help and the explanation.

Best wishes.....
Colin

PS I'm not sure what the correct code from the list is. There isn't a "Stupid User" one so I picked Invalid. I hope that's ok.