Bug 46451

Summary: [patch] sound: EMU8000 DRAM sized 512 KiB too small (most of the time)
Product: Drivers Reporter: David Flater (dave)
Component: Sound(ALSA)Assignee: Jaroslav Kysela (perex)
Status: RESOLVED CODE_FIX    
Severity: normal CC: alan, florian, tiwai
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.5.2 Subsystem:
Regression: No Bisected commit-id:
Attachments: patch emu8000.c to fix size_dram
[PATCHv2] sound: fix emu8000 DRAM sized 512 KiB too small

Description David Flater 2012-08-26 02:11:16 UTC
Created attachment 78501 [details]
patch emu8000.c to fix size_dram

In emu8000.c, size_dram determines the amount of memory on the sound card by doing write/readback tests starting at 0 and incrementing by 512 KiB.  On success, detected_size is updated to the successful address and testing continues.  On failure, the loop is immediately exited.  The resulting detected_size is 512 KiB too small except in two special cases:

1. If there is no memory, the initial 0 value of detected_size is used, which is correct.
2. If the address space wraps around, detected_size is updated before the bailout, so the result is correct.

Patch to correct all cases is attached and tested with AWE64 Gold.  Before:

EMU8000 [0x620]: 3584 Kb on-board memory detected
asfxload 4GMGSMT.SF2 (4174814 B) fails.

After:

EMU8000 [0x620]: 4096 Kb on-board memory detected
asfxload 4GMGSMT.SF2 succeeds.
Comment 1 Alan 2012-08-27 11:02:25 UTC
Please see SubmittingPatches in the kernel documentation. Patches need a Signed-off-by: line and should really go via email to the list as well.

Thanks
Comment 2 David Flater 2012-08-28 02:30:40 UTC
Created attachment 78611 [details]
[PATCHv2] sound: fix emu8000 DRAM sized 512 KiB too small

v2:  Fixed result still wrong in the case of 512 KiB DRAM.  Oops.

I do not have a card with 512 KiB to test with, but by forcibly enabling the
added conditional I verified on the AWE64 Gold that it detects 512 KiB
(successfully reading from the first memory location) and does not hang the
card.
Comment 3 Takashi Iwai 2012-08-28 17:33:43 UTC
Could you give the fixed patch in the proper style described in SubmittingPatches?
As Alan pointed, your sign-off is inevitably necessary for upstreaming.
Comment 4 Alan 2012-08-28 17:43:54 UTC
He did .....
From: David Flater <vger@flaterco.com>
To: Alsa Devel <alsa-devel@vger.kernel.org>, Linux Kernel <linux-kernel@vger.kernel.org>
Subject: [PATCHv2] sound: fix emu8000 DRAM sized 512 KiB too small
Comment 5 Takashi Iwai 2012-08-28 17:54:55 UTC
Ah, OK, so he submitted to ML.  I'll check that.  Thanks.
Comment 6 Florian Mickler 2012-10-15 21:18:58 UTC
A patch referencing this bug report has been merged in Linux v3.7-rc1:

commit 1338fc97d07a04e74a7b75ff28b7751061f4cf38
Author: David Flater <dave@flaterco.com>
Date:   Mon Aug 27 22:25:21 2012 -0400

    ALSA: emu8000: fix emu8000 DRAM sized 512 KiB too small