From patchwork Sun Apr 21 20:46:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 13637535 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B76EF3D978 for ; Sun, 21 Apr 2024 20:47:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713732442; cv=none; b=SQAb61qpXWPWd1ZnnXdElDXQ4BqJ5CswvcbB2PGmiWTErBPa11Br/5niLwdCz7iZ3Vm/Zw7KeoNk3h1by0PpvyNLeH4NS8zaFAFaDWLUbojCUs5XG9goraZHV2Unq/nSWa9hYGW8WlmxOzg0u6wCSB/6BNKnFky0znZkyUltv6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713732442; c=relaxed/simple; bh=4RkRE9rzJMG18/5jzqZ+XaQG83hPlcjC9s4hIXGnsV8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eZPg81wQnaCVs0zXmdA6EmIO35Aa6eAsEYRoEV9PFe8U/ssKZrL+cR7rQOpBXzIpG6DxODM5unXx8U3RZM4ipmYTtvkkhfsfSV3R9Jnbt+tKa19yWNVRRjgKpnUkNLtZDAzog9CfoI/ryFTxZT1G9QjnSQGRiT1ilZXHyoAL8Jo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b=uZI63p53; arc=none smtp.client-ip=212.227.15.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b="uZI63p53" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1713732428; x=1714337228; i=oswald.buddenhagen@gmx.de; bh=9H0nQdNyd4uDsmIBqCh/lsoqusbudeEOWxCPrdNSiaU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=uZI63p53+dcArrO6i/8Cg9rkPES+aZI2AHdKvEdEvVYkr1c07vuPmiCz1AOiSen3 vnjQpc878p00RXQPg+H3HDs9umm27pGpUUdfRUMKragzoGlRXKg3YcCZU9GbzAnRa oukNI2q3kHyyoy9TbD8IuhwvH4XlBsvvAlbZ6+vKqfzWbTeP7f7JY4DAwth60muXn NNiPJc5jDdS5p5Mxsw9Ag7kHe7KSiHXwdjVcotGaEcCujTnuygQGGxHt+YvqpxVlV IJtpc9lpbu5gFEh8/+2Nis1le5oDh/dqQTi7myLRRieq9UX92aMHHQ/mMF3bJSPRn OEufLfQzmzIxcu+Vbw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.112]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MHoRA-1rte9q1nxm-00Es4q; Sun, 21 Apr 2024 22:47:08 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rye5b-RAM-00; Sun, 21 Apr 2024 22:47:07 +0200 From: Oswald Buddenhagen To: linux-sound@vger.kernel.org Cc: Takashi Iwai , Jaroslav Kysela , Pietro Caruso Subject: [PATCH 01/10] ALSA: emu10k1: fix E-MU card dock presence monitoring Date: Sun, 21 Apr 2024 22:46:58 +0200 Message-ID: <20240421204707.2487686-2-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240421204707.2487686-1-oswald.buddenhagen@gmx.de> References: <20240421204707.2487686-1-oswald.buddenhagen@gmx.de> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:VUfx5T+p0cEDdCIaccEL1g7O3zbsF+EGnETnhazoQNqv86xA0qd aXvRZAKcH0A2VC9UrRWrysGy30V5VUo5BGANYALATja715WRkO7VBJmxZ/bCY8x6obrp0Bb /mzHu9vFVK/d/nV3cOl8SNAO15EbhcPoicRKuAwq7XDhvZHeoyh7UcOMGSzRMA1oQknwyEl 8IHnykdN9z7v//ajv+NJQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:eDGA7FxfjVE=;1AYpDczmVUvOsIEtp8z6ArRhaRk 3ez0zzaDbE6jw/QzNc8WXlvb7dFO5N/xWVgy2TiSHecGtSrSFUtmYVm2EasL3FmXgr0OOdaZg A9gzi/E/P/Yv6RxQt7SwOFuPSLuUx3E8JhA4WSz0yAz/bFwDYIv1ak+1U9hYe/blEvG6BRJUR WSPxV0wiAzRpCmGgWayqZSJNxP1NioK9P8lOKykCBbgQfL8o8yhZTzmkbs+qu8IJYHkdos51k tZaJCCJP9DmwaEb/iN2XVQIUyC1W2LKqVXptVm6J850XsCRz5sll81l6LOs+jVE9RZOIUJFX7 tGZFunrKeA5iROTHnt6m2Fk/xo8Fz41Et27GkBkRHnraM2b7Y6ZotfHbW7OI0emC4Z3wGDhml JwbxOND5j5xvgyCrrlW2PWIJUp2YBft4UNMbQfPFjQnIARcRTnavJBCJocT8Y3ZDFiCOMjVXg JkHhfYIe+OiJcU5EC+pMxzYkk+bolu6Rd2TjRGeaqqxW4cmiJARB0R9hbrXKmu80Vg6qCjNL3 wP0mEkPdNQSonX1M0PByB0WK9HSjCC+cniEU4gjv7b3AS1bSKixrQT2zGtmiz7X/k9SuCpfNP amoLDz2VPxX9X5etRGHAOf7H7bT0JMJtIN5sVyuW8C6TSYh/YCHWaUAZScE2gW/ZXSufcZ7SV pLjPGAvcdD9KkFhHrTEWjrYtkm/fvgSu92ukXOeu4RaIwxO/JRGggUxlz1BHiZU92ggQczPIb nqGYYsAl0OHpWJTWHJJAqBLO5qtR9Srf3s0LROljjarKELP3su6abB+QaWMIFq0fa1wXP+u1e CQUzdaY/wZY9W2vmRnnaQRINK1wIlqUnprk556b2f2uYU= While there are two separate IRQ status bits for dock attach and detach, the hardware appears to mix them up more or less randomly, making them useless for tracking what actually happened. It is much safer to check the dock status separately and proceed based on that, as the old polling code did. Note that the code assumes that only the dock can be hot-plugged - if other option card bits changed, the logic would break. Fixes: fbb64eedf5a3 (ALSA: emu10k1: make E-MU dock monitoring interrupt-driven) Link: https://bugzilla.kernel.org/show_bug.cgi?id=218584 Signed-off-by: Oswald Buddenhagen --- sound/pci/emu10k1/emu10k1_main.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index de5c41e578e1..85f70368a27d 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -778,6 +778,11 @@ static void emu1010_firmware_work(struct work_struct *work) msleep(10); /* Unmute all. Default is muted after a firmware load */ snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE); + } else if (!(reg & EMU_HANA_OPTION_DOCK_ONLINE)) { + /* Audio Dock removed */ + dev_info(emu->card->dev, "emu1010: Audio Dock detached\n"); + /* The hardware auto-mutes all, so we unmute again */ + snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE); } } @@ -810,14 +815,12 @@ static void emu1010_interrupt(struct snd_emu10k1 *emu) u32 sts; snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &sts); - if (sts & EMU_HANA_IRQ_DOCK_LOST) { - /* Audio Dock removed */ - dev_info(emu->card->dev, "emu1010: Audio Dock detached\n"); - /* The hardware auto-mutes all, so we unmute again */ - snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE); - } else if (sts & EMU_HANA_IRQ_DOCK) { + + // The distinction of the IRQ status bits is unreliable, + // so we dispatch later based on option card status. + if (sts & (EMU_HANA_IRQ_DOCK | EMU_HANA_IRQ_DOCK_LOST)) schedule_work(&emu->emu1010.firmware_work); - } + if (sts & EMU_HANA_IRQ_WCLK_CHANGED) schedule_work(&emu->emu1010.clock_work); } From patchwork Sun Apr 21 20:46:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 13637534 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 477BD28DDF for ; Sun, 21 Apr 2024 20:47:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713732442; cv=none; b=LU9qnSTvL+YXrK7XG//kJy2CpzC34lQsI2mMfE6ri0OP/kbtJFcEnuTTb3Wq7rDujxiX2kfyu66RAPjpq2cIHj9PuRoW20SiaA4hMoGNokrsOVHD6XArf4R99Gm27ExunACxQXwHdvkMjOEB4LxsWobFwQykO0qVGoVAH+grWBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713732442; c=relaxed/simple; bh=Wzv4gj0mV9Z58lx920WEk0lWIzjM971IT7wlVNeuh88=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E5aD830TVgRN+C6iJPqTlRPCMLBqa804JKOjuPdnNrTHFzuvUxC91dwAkX2cCjHh7f6Ax/aGF/AWgml8q1ChveBTJdbmp6L2g5fot3Dwlu0l21a9JQMKDKxymTHZCrWxnvlwflskW5aZQ9pkSl0RqqEiqiHixJUaWTI1ETcxFps= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b=K//kvURR; arc=none smtp.client-ip=212.227.15.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b="K//kvURR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1713732428; x=1714337228; i=oswald.buddenhagen@gmx.de; bh=fGHERi1PjWp+/PQ5g1r8VQ2KTJJr7IvUwf0ttM0VbIE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=K//kvURRx94QHacYtWcHRzDaIMtFwUP6JPlBoIieTMILWJMBBlxLHWEWeTK3dTWy eHCbzf+Yl63RTBzvs/HO66U6YQzO8z52FtnzX1DvlrDv9O8wxUb4dOVHrIsW3Qpct zS3S09pT6JSlcRa+FN0nWuOcgH/LDDg3qdGtqoJLPtwjxhUmkKumyftNkdmbm/NaJ rJXkSih8/QQiswL7JlcPJjI0rdJJ1JHXQeVGiyYKQIArRIbN4qCLdWkoTnWHr48Ob r+yyix3LaXWsUqccFj1mQH2KlMygkRNF8FB/53zYJ0Oj6z5j55OrGGqrVXxPZor6l /0OxCFg690tTfUMA4g== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.112]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MVeMA-1s6FK41gW4-00RZEe; Sun, 21 Apr 2024 22:47:08 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rye5b-RAR-00; Sun, 21 Apr 2024 22:47:07 +0200 From: Oswald Buddenhagen To: linux-sound@vger.kernel.org Cc: Takashi Iwai , Jaroslav Kysela , Pietro Caruso Subject: [PATCH 02/10] ALSA: emu10k1: factor out snd_emu1010_load_dock_firmware() Date: Sun, 21 Apr 2024 22:46:59 +0200 Message-ID: <20240421204707.2487686-3-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240421204707.2487686-1-oswald.buddenhagen@gmx.de> References: <20240421204707.2487686-1-oswald.buddenhagen@gmx.de> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:lzRmMXKvuAPxzy7yK/00zyx9iZDYPP/0dRUDDVgK8kR7pVeEyO3 k9zQjUX/O/IAi5qCfr/ePTxpNDQ+oVnO38BzDWsl45cnU/h7SkJri1CK5tDn6Fm4g3svVVb LgA+scE3nY1x9qU3lhraUzKh+KUor53aOWzuAdo9JgDf6j/a6LijTx4Xdf8l8Zwwp5dF1IS ViWhiuzxKcHjaRNez+NLw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:JWYWFZmZNd0=;L7aaOFHLjIw8Wdd0FuCixcZS1r9 zbW7cxjmD2aakfbqPIkVcqNYD/AlX32TpeVGQOh/RntyW/1092AgU5hzTDGKa13JbpgwDpSSi Ue1C/cL83RrXAo6CY8pHBTCh19N79OCdnJ1Rq3P05iitcGDmaCfaL0dwtnFw/7p3RrRmOmcE6 GNjDoSwvLCzo657t3IJ/EPylW/sqB9mx3yc4w3H5mHuXUlmSCrgmtbar97BQUxfoefh0Pji9X rOYFEmfxylCvbmujQsUWgXbxcdWOjNRL7UPfrMpalN96p9LSxW/31ng3XUzQp0CXsHkFQtbRg lRwj8SdEKtsU7cDh7WUetIliFWdukjbTp0emXMn4LDtUazdEugRvqI8lZluRY9oIs7IFTSMWM b6/Y6mOf/rPkHlom7Wrk4JUb3B5hPHnoog7WUz0xl3s0Rd1tD0IQdYus8FhN9VjsiDnLTVUWL TgJSxDMwrEW2h+gLp1e88Wn7Y79xVANkO6RzKIko3BxipONCx5VK5JeKSCc8YHKtTFazYeTuV BeJV/WkxlVdPhTbxw6k/E3EiMeJntmRhXxUuEPDPxIJtUJSGI+/lSYAP27ujTKlgdzCreGH2d C5daHC3ugD3GWphX3/CPYNFOd6GorhST7ljIIG1yAAPambQ9HHjjgRprhGzKuOh3U4UhKOaVr dD2ruAQ3XhrGlAuar7kjjLLiZPBJUyX3ldkXQB43+0IPqJ/zRSxgRuo07098rMywtAArSF7Ja LygrpHSrv9CXjBAGMJ6ryaeBNYxkPxJQBTgFLQkqfxvgwKJItFSpLGgaK0wbKU+vnxS61nngi tmcGf9TzePlx/YGQoLIeYHRuYADxVs7v7nYJe+ydsiAPU= Pulled out of the next patch to improve its legibility. As the function is now available, call it directly from snd_emu10k1_emu1010_init(), thus making the MicroDock firmware loading synchronous - there isn't really a reason not to. Note that this does not affect the AudioDocks of rev1 cards, as these have no independent power supplies, and thus come up only a while after the main card is initialized. As a drive-by, adjust the priorities of two messages to better reflect their impact. Signed-off-by: Oswald Buddenhagen --- sound/pci/emu10k1/emu10k1_main.c | 66 +++++++++++++++++--------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 85f70368a27d..6265fc9ae260 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -732,11 +732,43 @@ static int snd_emu1010_load_firmware(struct snd_emu10k1 *emu, int dock, return snd_emu1010_load_firmware_entry(emu, *fw); } +static void snd_emu1010_load_dock_firmware(struct snd_emu10k1 *emu) +{ + u32 tmp, tmp2; + int err; + + dev_info(emu->card->dev, "emu1010: Loading Audio Dock Firmware\n"); + /* Return to Audio Dock programming mode */ + snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, + EMU_HANA_FPGA_CONFIG_AUDIODOCK); + err = snd_emu1010_load_firmware(emu, 1, &emu->dock_fw); + if (err < 0) + return; + snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0); + + snd_emu1010_fpga_read(emu, EMU_HANA_ID, &tmp); + dev_dbg(emu->card->dev, "emu1010: EMU_HANA+DOCK_ID = 0x%x\n", tmp); + if ((tmp & 0x1f) != 0x15) { + /* FPGA failed to be programmed */ + dev_err(emu->card->dev, + "emu1010: Loading Audio Dock Firmware failed, reg = 0x%x\n", + tmp); + return; + } + dev_info(emu->card->dev, "emu1010: Audio Dock Firmware loaded\n"); + + snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp); + snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2); + dev_info(emu->card->dev, "Audio Dock ver: %u.%u\n", tmp, tmp2); + + /* Allow DLL to settle, to sync clocking between 1010 and Dock */ + msleep(10); +} + static void emu1010_firmware_work(struct work_struct *work) { struct snd_emu10k1 *emu; - u32 tmp, tmp2, reg; - int err; + u32 reg; emu = container_of(work, struct snd_emu10k1, emu1010.firmware_work); @@ -749,33 +781,7 @@ static void emu1010_firmware_work(struct work_struct *work) snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ®); /* OPTIONS: Which cards are attached to the EMU */ if (reg & EMU_HANA_OPTION_DOCK_OFFLINE) { /* Audio Dock attached */ - /* Return to Audio Dock programming mode */ - dev_info(emu->card->dev, - "emu1010: Loading Audio Dock Firmware\n"); - snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, - EMU_HANA_FPGA_CONFIG_AUDIODOCK); - err = snd_emu1010_load_firmware(emu, 1, &emu->dock_fw); - if (err < 0) - return; - snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0); - snd_emu1010_fpga_read(emu, EMU_HANA_ID, &tmp); - dev_info(emu->card->dev, - "emu1010: EMU_HANA+DOCK_ID = 0x%x\n", tmp); - if ((tmp & 0x1f) != 0x15) { - /* FPGA failed to be programmed */ - dev_info(emu->card->dev, - "emu1010: Loading Audio Dock Firmware file failed, reg = 0x%x\n", - tmp); - return; - } - dev_info(emu->card->dev, - "emu1010: Audio Dock Firmware loaded\n"); - snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp); - snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2); - dev_info(emu->card->dev, "Audio Dock ver: %u.%u\n", tmp, tmp2); - /* Sync clocking between 1010 and Dock */ - /* Allow DLL to settle */ - msleep(10); + snd_emu1010_load_dock_firmware(emu); /* Unmute all. Default is muted after a firmware load */ snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE); } else if (!(reg & EMU_HANA_OPTION_DOCK_ONLINE)) { @@ -892,7 +898,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu) snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ®); dev_info(emu->card->dev, "emu1010: Card options = 0x%x\n", reg); if (reg & EMU_HANA_OPTION_DOCK_OFFLINE) - schedule_work(&emu->emu1010.firmware_work); + snd_emu1010_load_dock_firmware(emu); if (emu->card_capabilities->no_adat) { emu->emu1010.optical_in = 0; /* IN_SPDIF */ emu->emu1010.optical_out = 0; /* OUT_SPDIF */ From patchwork Sun Apr 21 20:47:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 13637542 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B170F41C71 for ; Sun, 21 Apr 2024 20:47:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713732444; cv=none; b=tM1AH3wPN4iXla0Mhrzno5KTunTBsyjmqL0xDG/rNEtlp4byQACucJEDOdel6/721CT0htbJ8TVW0WXgAXbiwySiEQ44/wJ+LHej6TWw4w1d1LkLWDNDRHunRYVT7MBkCht2HJWkONFNHWEhG83ewM5WAWPdW6ltLtEvtUukOHk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713732444; c=relaxed/simple; bh=AJTRBnj3SHqkEJM909LJx+7ebLtPffFbRjhPQyu5UTM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kPn72BnoKe8H9RwajSGDSqp1lWTEsimXiJv0xby51NaN9qB+aCc2R5BV5tdMYgeDUKZAjgoKgI9Q8pzbTP4QYk1SFOC21vOGglmlqfuQq6utu7san5bF9rraC3NDeAvZy4hV2RP6AzoAyEy6DohF32uLiVih4EzTJM3k/k21RfQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b=TIdiypPK; arc=none smtp.client-ip=212.227.15.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b="TIdiypPK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1713732428; x=1714337228; i=oswald.buddenhagen@gmx.de; bh=/bcfFFddJNUxyIxBNr8PNsUUSGoTthii7Kiyh2IDbHI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=TIdiypPK+sLdcGpWYkKPxEi89A0ylET+XNd2ne5eMQ2j8K4JBqAXBPShafAHCtC9 sNMqSmNcI7B1DGgRi/WTetgPqZZI9Tt/PixYSVnpQj6gxCrcrEFQbbOH60ssNMyzH 0JbNd14CjP/Pah4ZlmQQlrTk72bfBfKgADZrCRs7f7iIWurBiMChfiWigtXfTAm7/ v8rB+VCLSRelDpLIwMvUbZqQwQs8EDGKHi8G3jjkxJfMDiC8t5cWBUe6dXF9Ludqn +vgUywUbxi3I+P+oBq3aH6XWUPUnBGgZrSXGlojRgvthWuYKYDkLtlWHAIYXhkCPw xeEPNdx4ZGz353jDMw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.112]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MAOJV-1rsH6l1iV1-00Bpyi; Sun, 21 Apr 2024 22:47:08 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rye5b-RAW-00; Sun, 21 Apr 2024 22:47:07 +0200 From: Oswald Buddenhagen To: linux-sound@vger.kernel.org Cc: Takashi Iwai , Jaroslav Kysela , Pietro Caruso Subject: [PATCH 03/10] ALSA: emu10k1: move the whole GPIO event handling to the workqueue Date: Sun, 21 Apr 2024 22:47:00 +0200 Message-ID: <20240421204707.2487686-4-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240421204707.2487686-1-oswald.buddenhagen@gmx.de> References: <20240421204707.2487686-1-oswald.buddenhagen@gmx.de> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:C4566ARuBKDdwHjrJk9H25/VTw9oK8PONuoJ7nC2rq31ruX7Mh4 NKFoaCFgYL9yrYcfEAhtmY9JfybXuURO9M1QNvFfo8CmG1D+Dg6tepmoW4xW6an4bWsVBE/ REr8DjwllIz0rCx0MiDmZLnGWRbUt2D7FhKn4TtyFfqedoct8ZZmNG3ZXRo/N1bdF8dtdPp 4VP4q+b+oEegE7dCU9Oww== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:nkgtoaj8rr0=;MfWBB5EY4laMYatkiNXaY9ZZvae AqiGt1xlCde2kHgeJQS+EN/USK1EMhb++j5ZCso73BvS30BB9ECI62Wa2ZLV1i/qVPx78Czns 8jSKIu/WdSTEuMx1BZ/UlPbBILXipTGnlkE7XTF04j6q9TWseoyEndeUKjd+8E9W9tvNInY7f aG8E1dXUjOH5SqCFWwuj1Cdnwo8HozxiLWq264npbQVHv0zo2OFsu8sJzLF1DroE6MrSaQ729 6Q9aT68DX7BTCVRYZ3ektxz1L8IrjDy+yPnXrFf3K0ysdRWT92mDlMqQMAdcSrVS+s9EUmFrm OOpp9bHZZRaJ1dB7M6yW7CIH7w8OA7OYWdxyKWmW+jPswbfDqlW+ZNfh5qgr2+xoLZxXTuAuU sqqoFXqUxLqR7T3P3Y5A5Ackj7F8jOO8zqzo/E4rIi/J7seq/i34iKaKgGc4PbgahwFgebJEg nDUXYHVbE0ADqV+h4FlpVxCWeiYtPARFv8LDXNiGGugAy5wxScFNyQvjl61qB3p60s04GcEPl fLxJkxalRaBSPP/2lS9dOcwRczQGJZius6+AlQdoJHTtD+DcCP9XkEFRvBFu+WddXJuspsCgq LiRFPA4C18O6GtzfgRTV12TJy4XK1LSNDkadIyEqO3SZAYOWY9QrrJ1msCi6xrcV+BnGgBLTh M5+ymFkmT9OCHi10eS40u/T7A+lmnqxcCT933w/5Es0hO5Y8VBgn2zL8n2WxWwD4A7/FEWJyl /Qb9tJO2aZzSi+3DIsnGSoybuW/wIzuyEo9QLMoX+rbANqb1d9rZUyMhW7+PsG23qHCig3YcL dhdRIrUT+rhgBW4rUSP9fGXgG1aHIsCdK+9NfvzOIKlVo= The actual event processing was already done by workqueue items. We can move the event dispatching there as well, rather than doing it already in the interrupt handler callback. This change has a rather profound "side effect" on the reliability of the FPGA programming: once we enter programming mode, we must not issue any snd_emu1010_fpga_{read,write}() calls until we're done, as these would badly mess up the programming protocol. But exactly that would happen when trying to program the dock, as that triggers GPIO interrupts as a side effect. This is mitigated by deferring the actual interrupt handling, as workqueue items are not re-entrant. To avoid scheduling the dispatcher on non-events, we now explicitly ignore GPIO IRQs triggered by "uninteresting" pins, which happens a lot as a side effect of calling snd_emu1010_fpga_{read,write}(). Fixes: fbb64eedf5a3 (ALSA: emu10k1: make E-MU dock monitoring interrupt-driven) Link: https://bugzilla.kernel.org/show_bug.cgi?id=218584 Signed-off-by: Oswald Buddenhagen --- include/sound/emu10k1.h | 3 +- sound/pci/emu10k1/emu10k1.c | 3 +- sound/pci/emu10k1/emu10k1_main.c | 56 ++++++++++++++++---------------- 3 files changed, 30 insertions(+), 32 deletions(-) diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h index 1af9e6819392..9cc10fab01a8 100644 --- a/include/sound/emu10k1.h +++ b/include/sound/emu10k1.h @@ -1684,8 +1684,7 @@ struct snd_emu1010 { unsigned int clock_fallback; unsigned int optical_in; /* 0:SPDIF, 1:ADAT */ unsigned int optical_out; /* 0:SPDIF, 1:ADAT */ - struct work_struct firmware_work; - struct work_struct clock_work; + struct work_struct work; }; struct snd_emu10k1 { diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c index fe72e7d77241..dadeda7758ce 100644 --- a/sound/pci/emu10k1/emu10k1.c +++ b/sound/pci/emu10k1/emu10k1.c @@ -189,8 +189,7 @@ static int snd_emu10k1_suspend(struct device *dev) emu->suspend = 1; - cancel_work_sync(&emu->emu1010.firmware_work); - cancel_work_sync(&emu->emu1010.clock_work); + cancel_work_sync(&emu->emu1010.work); snd_ac97_suspend(emu->ac97); diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 6265fc9ae260..86eaf5963502 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -765,19 +765,10 @@ static void snd_emu1010_load_dock_firmware(struct snd_emu10k1 *emu) msleep(10); } -static void emu1010_firmware_work(struct work_struct *work) +static void emu1010_dock_event(struct snd_emu10k1 *emu) { - struct snd_emu10k1 *emu; u32 reg; - emu = container_of(work, struct snd_emu10k1, - emu1010.firmware_work); - if (emu->card->shutdown) - return; -#ifdef CONFIG_PM_SLEEP - if (emu->suspend) - return; -#endif snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ®); /* OPTIONS: Which cards are attached to the EMU */ if (reg & EMU_HANA_OPTION_DOCK_OFFLINE) { /* Audio Dock attached */ @@ -792,43 +783,54 @@ static void emu1010_firmware_work(struct work_struct *work) } } -static void emu1010_clock_work(struct work_struct *work) +static void emu1010_clock_event(struct snd_emu10k1 *emu) { - struct snd_emu10k1 *emu; struct snd_ctl_elem_id id; - emu = container_of(work, struct snd_emu10k1, - emu1010.clock_work); - if (emu->card->shutdown) - return; -#ifdef CONFIG_PM_SLEEP - if (emu->suspend) - return; -#endif - spin_lock_irq(&emu->reg_lock); // This is the only thing that can actually happen. emu->emu1010.clock_source = emu->emu1010.clock_fallback; emu->emu1010.wclock = 1 - emu->emu1010.clock_source; snd_emu1010_update_clock(emu); spin_unlock_irq(&emu->reg_lock); snd_ctl_build_ioff(&id, emu->ctl_clock_source, 0); snd_ctl_notify(emu->card, SNDRV_CTL_EVENT_MASK_VALUE, &id); } -static void emu1010_interrupt(struct snd_emu10k1 *emu) +static void emu1010_work(struct work_struct *work) { + struct snd_emu10k1 *emu; u32 sts; + emu = container_of(work, struct snd_emu10k1, emu1010.work); + if (emu->card->shutdown) + return; +#ifdef CONFIG_PM_SLEEP + if (emu->suspend) + return; +#endif + snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &sts); // The distinction of the IRQ status bits is unreliable, // so we dispatch later based on option card status. if (sts & (EMU_HANA_IRQ_DOCK | EMU_HANA_IRQ_DOCK_LOST)) - schedule_work(&emu->emu1010.firmware_work); + emu1010_dock_event(emu); if (sts & EMU_HANA_IRQ_WCLK_CHANGED) - schedule_work(&emu->emu1010.clock_work); + emu1010_clock_event(emu); +} + +static void emu1010_interrupt(struct snd_emu10k1 *emu) +{ + // We get an interrupt on each GPIO input pin change, but we + // care only about the ones triggered by the dedicated pin. + u16 sts = inw(emu->port + A_GPIO); + u16 bit = emu->card_capabilities->ca0108_chip ? 0x2000 : 0x8000; + if (!(sts & bit)) + return; + + schedule_work(&emu->emu1010.work); } /* @@ -969,8 +971,7 @@ static void snd_emu10k1_free(struct snd_card *card) /* Disable 48Volt power to Audio Dock */ snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0); } - cancel_work_sync(&emu->emu1010.firmware_work); - cancel_work_sync(&emu->emu1010.clock_work); + cancel_work_sync(&emu->emu1010.work); release_firmware(emu->firmware); release_firmware(emu->dock_fw); snd_util_memhdr_free(emu->memhdr); @@ -1549,8 +1550,7 @@ int snd_emu10k1_create(struct snd_card *card, emu->irq = -1; emu->synth = NULL; emu->get_synth_voice = NULL; - INIT_WORK(&emu->emu1010.firmware_work, emu1010_firmware_work); - INIT_WORK(&emu->emu1010.clock_work, emu1010_clock_work); + INIT_WORK(&emu->emu1010.work, emu1010_work); /* read revision & serial */ emu->revision = pci->revision; pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial); From patchwork Sun Apr 21 20:47:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 13637539 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FAAD3FBA4 for ; Sun, 21 Apr 2024 20:47:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713732443; cv=none; b=W2VC2wRuvpaOzvoIn2s/VUHFC2S2KJs/acqZS3KGIWJiaGkqbJXzd8Aw7wOr7/paiK6K+BqVNyMCViIQ8R3HKkVPapCGykvVC/OaCUq1M3r8f/le6M5B2M4HQqQHfy9QRX5VwfK1q/lcmc3+l+wIROAsQSstSpRyptjYWTP371U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713732443; c=relaxed/simple; bh=6Whqz2ZCi/Ix53tWYVXjN7jsXzfFy3B7urkt8bRKw2A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nfb50qNB8Gc7jWo2E1LNDzVs7u83GEcb3HlLelMNssdtXaTM7UosP3VhmLkN63UYz3oPwAwBEKwC1BN0tFPoOE9cEvbhtd/yIfJ/xDgl+36CL5w+8z2z8E0qBVkZZry+GVQSYOgrdiq4chYlnr2E9Wd9jiAVKYhpXdf+I8lekIc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b=djwogqDN; arc=none smtp.client-ip=212.227.15.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b="djwogqDN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1713732428; x=1714337228; i=oswald.buddenhagen@gmx.de; bh=3uuDPCjnGjcfwNPYols0Uc2AljpaqiCPqPtNjipgA5Y=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=djwogqDNT4A5h7rAj/1rOPQ77dlsRcGeT6zyPynOHqcrV3zqs/pUgFINcFg6xmrp WWnO9lNZ+XrspA4v2II5iyBTnd5KEXX2GMEss014INyn0MesJXS72hzHswnAPzoAX R2T4ihkj9j3lGxEQRJIRbO32BDrbFsoWQHLnjWU2IxoRXdiJ1diKas5vaKZUVy0AX CI2qLN54JV1dfex5GGHG9FTl49xEdtJRxDokPs7ivE2xVIgH1jD9uMqyeg/ef2J2I IC/aluD2y4GBdZFC2lST9uIJeo4T/5LXEat09kAC2MOW7XQEXbZT6YkjA9KATid8E mvEDiYUgR0KRLWAzNA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.112]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MhD6W-1scuas1pNy-00eLF6; Sun, 21 Apr 2024 22:47:08 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rye5b-RAb-00; Sun, 21 Apr 2024 22:47:07 +0200 From: Oswald Buddenhagen To: linux-sound@vger.kernel.org Cc: Takashi Iwai , Jaroslav Kysela , Pietro Caruso Subject: [PATCH 04/10] ALSA: emu10k1: use mutex for E-MU FPGA access locking Date: Sun, 21 Apr 2024 22:47:01 +0200 Message-ID: <20240421204707.2487686-5-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240421204707.2487686-1-oswald.buddenhagen@gmx.de> References: <20240421204707.2487686-1-oswald.buddenhagen@gmx.de> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:UFstLwnbmHKfj/phvzzriFbs3jEJFZEs7oCY9KUqRTNeSs4wR7y 5nXbDPBmHJZEsJpXg1x7EqwfCTUYSCHon44AN0OOtCzjmHH/DQaLczBm9KiuOHz/Ri8cDhj Xw/kqSYfY9lQhVG7HeVuc3FPA0kuPNK/+n0jQGI0YOXIPCZxga0vIILah9LpbF3zHizYJpW sw4RV3UtxnnKtMioSKrXQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:JI1PEVlgxtY=;LdVBGtfLzEHJshv6AE8Yb5olYrm gIqXqozQVD39BUC8wgcLy9RnhgqEoRZaLp5hjinCPxYyOoLMULQtzRO4bHKr344a9OFizQO/7 rn2pLISoFL/8sRhjvL88Ea6+4P01NqUtP75Z6UX+gJ2jN15BgW0r/GiMAnJDY+kCiYWYq8iyr upNEvG9DfGCCux9EWcbeCgf0v/nq2Dfq24bwaGS3aEEp2EoI0FlgQeBOjMQZmmL1HsurbTMxg NdMeX3m1a1qoE709B0X13HrrkqLKk8VTVlXg3MHHxOTRq6v5dr6+p87eWxc+fqOe3oOEJQ9r0 iUHDCuUedlwgw+wys/J2FMPIkCaYIKqgkR7w7n3H8AbRBJOMoGUcrvlbsd+9Vo0tXMKPhfJZt PfiwpoNQPZJLRNk6vfeOoLtmhA6LWhme88jaTBAl2IMtNKVQvR3UoHD4zDgEGiiREnFMtnLb5 Ee6SPdlTU9WEs5vyPCsrJcRjdTQrIxC2K2VIeiuQ4n2MGDxSg1wUwcey3b5RL+UnbAZ0XMCHo HZGzCUAhtFSlDg2t++KvDOLEBeETEE2MptwQNLfqZRXiiP4jVgq4GPaZS6cWV41yp1CpDM5Xx 9mXCwZCOiC6v71f8bm5aldWz4jCwXM5zy1y2SuGSC3Yw7Tk2eU3ZXnDx6czwqIAdVBz4hiYkx oKCjbir6AOPKKA2UWtGB2cce+2hD4QcAtL3Sp5BBjS1grFHq3YbhpD82ca3CsS4zWHOPqjssp gm2jmVi1TxQJ7lUzxBAJby6Y+xyb8csUaEKH5YuJK3Hs1f9cvJ2vGT3cxMByoFAhFTmx0eVbX XPjfUi6yZs6OEtLAYEdnZd5CN7wI0dSTH/rJQGez+qnaw= The FPGA access through the GPIO port does not interfere with other sound processor register access, so there is no need to subject it to emu_lock. And after moving all FPGA access out of the interrupt handler, it does not need to be IRQ-safe, either. What's more, attaching the dock causes a firmware upload, which takes several seconds. We really don't want to disable IRQs for this long, and even less also have someone else spin with IRQs disabled waiting for us. Therefore, use a mutex for FPGA access locking. This makes the code somewhat more noisy, as we need to wrap bigger sections into the mutex, as it needs to enclose the spinlocks. The latter has the "side effect" of fixing dock FPGA programming in a corner case: a really badly timed mixer access right between entering FPGA programming mode and uploading the netlist would mess up the protocol. Signed-off-by: Oswald Buddenhagen --- include/sound/emu10k1.h | 4 +++ sound/pci/emu10k1/emu10k1_main.c | 19 +++++++++--- sound/pci/emu10k1/emumixer.c | 18 ++++++++---- sound/pci/emu10k1/emuproc.c | 9 ++++++ sound/pci/emu10k1/io.c | 50 ++++++++++++++------------------ 5 files changed, 62 insertions(+), 38 deletions(-) diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h index 9cc10fab01a8..234b5baea69c 100644 --- a/include/sound/emu10k1.h +++ b/include/sound/emu10k1.h @@ -1685,6 +1685,7 @@ struct snd_emu1010 { unsigned int optical_in; /* 0:SPDIF, 1:ADAT */ unsigned int optical_out; /* 0:SPDIF, 1:ADAT */ struct work_struct work; + struct mutex lock; }; struct snd_emu10k1 { @@ -1833,6 +1834,9 @@ unsigned int snd_emu10k1_ptr20_read(struct snd_emu10k1 * emu, unsigned int reg, void snd_emu10k1_ptr20_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned int chn, unsigned int data); int snd_emu10k1_spi_write(struct snd_emu10k1 * emu, unsigned int data); int snd_emu10k1_i2c_write(struct snd_emu10k1 *emu, u32 reg, u32 value); +static inline void snd_emu1010_fpga_lock(struct snd_emu10k1 *emu) { mutex_lock(&emu->emu1010.lock); }; +static inline void snd_emu1010_fpga_unlock(struct snd_emu10k1 *emu) { mutex_unlock(&emu->emu1010.lock); }; +void snd_emu1010_fpga_write_lock(struct snd_emu10k1 *emu, u32 reg, u32 value); void snd_emu1010_fpga_write(struct snd_emu10k1 *emu, u32 reg, u32 value); void snd_emu1010_fpga_read(struct snd_emu10k1 *emu, u32 reg, u32 *value); void snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 *emu, u32 dst, u32 src); diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 86eaf5963502..1a2905e8672b 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -810,15 +810,19 @@ static void emu1010_work(struct work_struct *work) return; #endif + snd_emu1010_fpga_lock(emu); + snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &sts); // The distinction of the IRQ status bits is unreliable, // so we dispatch later based on option card status. if (sts & (EMU_HANA_IRQ_DOCK | EMU_HANA_IRQ_DOCK_LOST)) emu1010_dock_event(emu); if (sts & EMU_HANA_IRQ_WCLK_CHANGED) emu1010_clock_event(emu); + + snd_emu1010_fpga_unlock(emu); } static void emu1010_interrupt(struct snd_emu10k1 *emu) @@ -852,6 +856,8 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu) * Proper init follows in snd_emu10k1_init(). */ outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK, emu->port + HCFG); + snd_emu1010_fpga_lock(emu); + /* Disable 48Volt power to Audio Dock */ snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0); @@ -877,17 +883,18 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu) err = snd_emu1010_load_firmware(emu, 0, &emu->firmware); if (err < 0) { dev_info(emu->card->dev, "emu1010: Loading Firmware failed\n"); - return err; + goto fail; } /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ snd_emu1010_fpga_read(emu, EMU_HANA_ID, ®); if ((reg & 0x3f) != 0x15) { /* FPGA failed to be programmed */ dev_info(emu->card->dev, "emu1010: Loading Hana Firmware file failed, reg = 0x%x\n", reg); - return -ENODEV; + err = -ENODEV; + goto fail; } dev_info(emu->card->dev, "emu1010: Hana Firmware loaded\n"); @@ -947,7 +954,9 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu) // so it is safe to simply enable the outputs. snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE); - return 0; +fail: + snd_emu1010_fpga_unlock(emu); + return err; } /* * Create the EMU10K1 instance @@ -969,9 +978,10 @@ static void snd_emu10k1_free(struct snd_card *card) } if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1010) { /* Disable 48Volt power to Audio Dock */ - snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0); + snd_emu1010_fpga_write_lock(emu, EMU_HANA_DOCK_PWR, 0); } cancel_work_sync(&emu->emu1010.work); + mutex_destroy(&emu->emu1010.lock); release_firmware(emu->firmware); release_firmware(emu->dock_fw); snd_util_memhdr_free(emu->memhdr); @@ -1551,6 +1561,7 @@ int snd_emu10k1_create(struct snd_card *card, emu->synth = NULL; emu->get_synth_voice = NULL; INIT_WORK(&emu->emu1010.work, emu1010_work); + mutex_init(&emu->emu1010.lock); /* read revision & serial */ emu->revision = pci->revision; pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial); diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c index 0a32ea53d8c6..05b98d9b547b 100644 --- a/sound/pci/emu10k1/emumixer.c +++ b/sound/pci/emu10k1/emumixer.c @@ -661,7 +661,9 @@ static int snd_emu1010_output_source_put(struct snd_kcontrol *kcontrol, change = (emu->emu1010.output_source[channel] != val); if (change) { emu->emu1010.output_source[channel] = val; + snd_emu1010_fpga_lock(emu); snd_emu1010_output_source_apply(emu, channel, val); + snd_emu1010_fpga_unlock(emu); } return change; } @@ -705,7 +707,9 @@ static int snd_emu1010_input_source_put(struct snd_kcontrol *kcontrol, change = (emu->emu1010.input_source[channel] != val); if (change) { emu->emu1010.input_source[channel] = val; + snd_emu1010_fpga_lock(emu); snd_emu1010_input_source_apply(emu, channel, val); + snd_emu1010_fpga_unlock(emu); } return change; } @@ -774,7 +778,7 @@ static int snd_emu1010_adc_pads_put(struct snd_kcontrol *kcontrol, struct snd_ct cache = cache & ~mask; change = (cache != emu->emu1010.adc_pads); if (change) { - snd_emu1010_fpga_write(emu, EMU_HANA_ADC_PADS, cache ); + snd_emu1010_fpga_write_lock(emu, EMU_HANA_ADC_PADS, cache ); emu->emu1010.adc_pads = cache; } @@ -832,7 +836,7 @@ static int snd_emu1010_dac_pads_put(struct snd_kcontrol *kcontrol, struct snd_ct cache = cache & ~mask; change = (cache != emu->emu1010.dac_pads); if (change) { - snd_emu1010_fpga_write(emu, EMU_HANA_DAC_PADS, cache ); + snd_emu1010_fpga_write_lock(emu, EMU_HANA_DAC_PADS, cache ); emu->emu1010.dac_pads = cache; } @@ -980,6 +984,7 @@ static int snd_emu1010_clock_source_put(struct snd_kcontrol *kcontrol, val = ucontrol->value.enumerated.item[0] ; if (val >= emu_ci->num) return -EINVAL; + snd_emu1010_fpga_lock(emu); spin_lock_irq(&emu->reg_lock); change = (emu->emu1010.clock_source != val); if (change) { @@ -996,6 +1001,7 @@ static int snd_emu1010_clock_source_put(struct snd_kcontrol *kcontrol, } else { spin_unlock_irq(&emu->reg_lock); } + snd_emu1010_fpga_unlock(emu); return change; } @@ -1041,7 +1047,7 @@ static int snd_emu1010_clock_fallback_put(struct snd_kcontrol *kcontrol, change = (emu->emu1010.clock_fallback != val); if (change) { emu->emu1010.clock_fallback = val; - snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 1 - val); + snd_emu1010_fpga_write_lock(emu, EMU_HANA_DEFCLOCK, 1 - val); } return change; } @@ -1093,7 +1099,7 @@ static int snd_emu1010_optical_out_put(struct snd_kcontrol *kcontrol, emu->emu1010.optical_out = val; tmp = (emu->emu1010.optical_in ? EMU_HANA_OPTICAL_IN_ADAT : EMU_HANA_OPTICAL_IN_SPDIF) | (emu->emu1010.optical_out ? EMU_HANA_OPTICAL_OUT_ADAT : EMU_HANA_OPTICAL_OUT_SPDIF); - snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, tmp); + snd_emu1010_fpga_write_lock(emu, EMU_HANA_OPTICAL_TYPE, tmp); } return change; } @@ -1144,7 +1150,7 @@ static int snd_emu1010_optical_in_put(struct snd_kcontrol *kcontrol, emu->emu1010.optical_in = val; tmp = (emu->emu1010.optical_in ? EMU_HANA_OPTICAL_IN_ADAT : EMU_HANA_OPTICAL_IN_SPDIF) | (emu->emu1010.optical_out ? EMU_HANA_OPTICAL_OUT_ADAT : EMU_HANA_OPTICAL_OUT_SPDIF); - snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, tmp); + snd_emu1010_fpga_write_lock(emu, EMU_HANA_OPTICAL_TYPE, tmp); } return change; } @@ -2323,7 +2329,9 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu, for (i = 0; i < emu_ri->n_outs; i++) emu->emu1010.output_source[i] = emu1010_map_source(emu_ri, emu_ri->out_dflts[i]); + snd_emu1010_fpga_lock(emu); snd_emu1010_apply_sources(emu); + snd_emu1010_fpga_unlock(emu); kctl = emu->ctl_clock_source = snd_ctl_new1(&snd_emu1010_clock_source, emu); err = snd_ctl_add(card, kctl); diff --git a/sound/pci/emu10k1/emuproc.c b/sound/pci/emu10k1/emuproc.c index 2f80fd91017c..737c28d31b41 100644 --- a/sound/pci/emu10k1/emuproc.c +++ b/sound/pci/emu10k1/emuproc.c @@ -165,6 +165,8 @@ static void snd_emu10k1_proc_spdif_read(struct snd_info_entry *entry, u32 value2; if (emu->card_capabilities->emu_model) { + snd_emu1010_fpga_lock(emu); + // This represents the S/PDIF lock status on 0404b, which is // kinda weird and unhelpful, because monitoring it via IRQ is // impractical (one gets an IRQ flood as long as it is desynced). @@ -197,6 +199,8 @@ static void snd_emu10k1_proc_spdif_read(struct snd_info_entry *entry, snd_iprintf(buffer, "\nS/PDIF mode: %s%s\n", value & EMU_HANA_SPDIF_MODE_RX_PRO ? "professional" : "consumer", value & EMU_HANA_SPDIF_MODE_RX_NOCOPY ? ", no copy" : ""); + + snd_emu1010_fpga_unlock(emu); } else { snd_emu10k1_proc_spdif_status(emu, buffer, "CD-ROM S/PDIF In", CDCS, CDSRCS); snd_emu10k1_proc_spdif_status(emu, buffer, "Optical or Coax S/PDIF In", GPSCS, GPSRCS); @@ -458,6 +462,9 @@ static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry, struct snd_emu10k1 *emu = entry->private_data; u32 value; int i; + + snd_emu1010_fpga_lock(emu); + snd_iprintf(buffer, "EMU1010 Registers:\n\n"); for(i = 0; i < 0x40; i+=1) { @@ -496,6 +503,8 @@ static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry, snd_emu_proc_emu1010_link_read(emu, buffer, 0x701); } } + + snd_emu1010_fpga_unlock(emu); } static void snd_emu_proc_io_reg_read(struct snd_info_entry *entry, diff --git a/sound/pci/emu10k1/io.c b/sound/pci/emu10k1/io.c index 74df2330015f..f3260a81e47b 100644 --- a/sound/pci/emu10k1/io.c +++ b/sound/pci/emu10k1/io.c @@ -289,71 +289,63 @@ static void snd_emu1010_fpga_write_locked(struct snd_emu10k1 *emu, u32 reg, u32 void snd_emu1010_fpga_write(struct snd_emu10k1 *emu, u32 reg, u32 value) { - unsigned long flags; - - spin_lock_irqsave(&emu->emu_lock, flags); + if (snd_BUG_ON(!mutex_is_locked(&emu->emu1010.lock))) + return; snd_emu1010_fpga_write_locked(emu, reg, value); - spin_unlock_irqrestore(&emu->emu_lock, flags); } -static void snd_emu1010_fpga_read_locked(struct snd_emu10k1 *emu, u32 reg, u32 *value) +void snd_emu1010_fpga_write_lock(struct snd_emu10k1 *emu, u32 reg, u32 value) +{ + snd_emu1010_fpga_lock(emu); + snd_emu1010_fpga_write_locked(emu, reg, value); + snd_emu1010_fpga_unlock(emu); +} + +void snd_emu1010_fpga_read(struct snd_emu10k1 *emu, u32 reg, u32 *value) { // The higest input pin is used as the designated interrupt trigger, // so it needs to be masked out. // But note that any other input pin change will also cause an IRQ, // so using this function often causes an IRQ as a side effect. u32 mask = emu->card_capabilities->ca0108_chip ? 0x1f : 0x7f; + + if (snd_BUG_ON(!mutex_is_locked(&emu->emu1010.lock))) + return; if (snd_BUG_ON(reg > 0x3f)) return; reg += 0x40; /* 0x40 upwards are registers. */ outw(reg, emu->port + A_GPIO); udelay(10); outw(reg | 0x80, emu->port + A_GPIO); /* High bit clocks the value into the fpga. */ udelay(10); *value = ((inw(emu->port + A_GPIO) >> 8) & mask); } -void snd_emu1010_fpga_read(struct snd_emu10k1 *emu, u32 reg, u32 *value) -{ - unsigned long flags; - - spin_lock_irqsave(&emu->emu_lock, flags); - snd_emu1010_fpga_read_locked(emu, reg, value); - spin_unlock_irqrestore(&emu->emu_lock, flags); -} - /* Each Destination has one and only one Source, * but one Source can feed any number of Destinations simultaneously. */ void snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 *emu, u32 dst, u32 src) { - unsigned long flags; - if (snd_BUG_ON(dst & ~0x71f)) return; if (snd_BUG_ON(src & ~0x71f)) return; - spin_lock_irqsave(&emu->emu_lock, flags); - snd_emu1010_fpga_write_locked(emu, EMU_HANA_DESTHI, dst >> 8); - snd_emu1010_fpga_write_locked(emu, EMU_HANA_DESTLO, dst & 0x1f); - snd_emu1010_fpga_write_locked(emu, EMU_HANA_SRCHI, src >> 8); - snd_emu1010_fpga_write_locked(emu, EMU_HANA_SRCLO, src & 0x1f); - spin_unlock_irqrestore(&emu->emu_lock, flags); + snd_emu1010_fpga_write(emu, EMU_HANA_DESTHI, dst >> 8); + snd_emu1010_fpga_write(emu, EMU_HANA_DESTLO, dst & 0x1f); + snd_emu1010_fpga_write(emu, EMU_HANA_SRCHI, src >> 8); + snd_emu1010_fpga_write(emu, EMU_HANA_SRCLO, src & 0x1f); } u32 snd_emu1010_fpga_link_dst_src_read(struct snd_emu10k1 *emu, u32 dst) { - unsigned long flags; u32 hi, lo; if (snd_BUG_ON(dst & ~0x71f)) return 0; - spin_lock_irqsave(&emu->emu_lock, flags); - snd_emu1010_fpga_write_locked(emu, EMU_HANA_DESTHI, dst >> 8); - snd_emu1010_fpga_write_locked(emu, EMU_HANA_DESTLO, dst & 0x1f); - snd_emu1010_fpga_read_locked(emu, EMU_HANA_SRCHI, &hi); - snd_emu1010_fpga_read_locked(emu, EMU_HANA_SRCLO, &lo); - spin_unlock_irqrestore(&emu->emu_lock, flags); + snd_emu1010_fpga_write(emu, EMU_HANA_DESTHI, dst >> 8); + snd_emu1010_fpga_write(emu, EMU_HANA_DESTLO, dst & 0x1f); + snd_emu1010_fpga_read(emu, EMU_HANA_SRCHI, &hi); + snd_emu1010_fpga_read(emu, EMU_HANA_SRCLO, &lo); return (hi << 8) | lo; } From patchwork Sun Apr 21 20:47:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 13637536 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC7A43EA72 for ; Sun, 21 Apr 2024 20:47:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713732442; cv=none; b=NQb8PHRu6fuWP99gRoKcmaWDEc4F3hzcUX3zFyrxinXrFQBZGPVOHl2+1QR9R5/FCSD39pUb6ofhNASUlRt8kX2CVOudAq4OXSe0lrlaIGHxkdt/gN6RC8lhivhxsCBraGSAkVVq2Rj7tsTVUs6RcLcaLbX4Dl/n5wn6tKXVQ7A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713732442; c=relaxed/simple; bh=78Fo3fps6tFZDtZx1H+3hVGIXOii+0x/VVl7hHPcOmM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lF/0D8Gwbx1Lz74joIRp1YGNU7qbTFuGPEVxoUFT2GjzAEdJNvW5aMssoX3DTeL8hs+JjeMTcfQoFahev97ITHOdljNc8bD1yXkIWGOcJ68gp8T+WJjVEoXHFjS8ESFf8jemrrDr0FAL3FXvsCf4Qzpyt+1p9GrXnvZasmYGIJQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b=ny+/c0KQ; arc=none smtp.client-ip=212.227.15.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b="ny+/c0KQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1713732428; x=1714337228; i=oswald.buddenhagen@gmx.de; bh=+RUa41z5QJ03GNkAhmdIDdGi/8CIrDQo1L3m3Pqu4G0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=ny+/c0KQaiFUR3nhCa73NsR7PSvXw3vZfuSvfs+10Df3XS6dVbQC+fsR0v5/jczM SOpCe3jjcefGXeLV40ftaZEsYjA3Zbw3DyF3/rwL+yytvuLIImnXi03btRgQ5PTKn 8PbViLLJRSfP7YyL2g2PjftrmAGawyzAayWsdBSdK0Q//GHt2r4MgnvW58GmU2KLd Iux4q2tsJXWJYddwh6tfuP9s0hp5MmUbkHJ6PAeRUiGA2ZNaXx7VZRBIvVkSzAQAz I2D0RiyxNnxit2quOq2NOoGcqcgFR5bA2mvvwNS/aa33ePROSog6fwIB1MWKLAU2F /rjfuOp6gceVh01Vkg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.112]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M5QJD-1rxH2n22fV-001OCW; Sun, 21 Apr 2024 22:47:08 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rye5b-RAg-00; Sun, 21 Apr 2024 22:47:07 +0200 From: Oswald Buddenhagen To: linux-sound@vger.kernel.org Cc: Takashi Iwai , Jaroslav Kysela , Pietro Caruso Subject: [PATCH 05/10] ALSA: emu10k1: fix E-MU dock initialization Date: Sun, 21 Apr 2024 22:47:02 +0200 Message-ID: <20240421204707.2487686-6-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240421204707.2487686-1-oswald.buddenhagen@gmx.de> References: <20240421204707.2487686-1-oswald.buddenhagen@gmx.de> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:f2s1ncojF1wXTPHYRKqZCXEhiITacqRcMgwmLRpDVn4mVpyJuh+ ZONS61ZRLXM36Pf73DzuE+pSePpHoNGfLcgbfOY492fDPH4am1QlE9bijANqoQUoafxKDi2 KNBw8zR+8Oz+QgkUL/rO41aygW2bExfmkOUhREf7/qPVyt1MSZqslX/fJjNtbAf2xKb1Ckn GH6Y8g8YxJtABfRV9xNZQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:gDgcPifxjjM=;Q3EdkolKjaX0D/nFbKBq5lkyKH0 LRTx/f3nfM1tHMLsb2exLwuitAIlGpMX+OAnOM7KxG/0qwLi48ozXy1TSVYb3ipEIhXfMge38 Pels81XEHfx5bNX3sk10crPk8xRYywjzJD4WPayhxgDC04WjHpz0hM2ytmMgioTdROCF9Btsr K7PZCkQmv5/HRplQ0ItRRBnQiUMtQEvRO5rmyZdM7KYdfqLcfWksMxaQ1AACKKPRpZg7pEhU+ h5RaOu4NzCYj0Ep/JVyeLGG+Nd6nC3rSoSTpPI28kBI6ujIf65uE/uuVM//DDot4QGbUDlsrt KxArQwzZYBuGNauWFYFG+g62sTNSgBDUAId4qNqD+OtoA6Vxr/pAZnAJYDM76AqDnjCHG8Bjh Uy/W72N/0qc8MTh7Gw7aK7iBDdwb0KuTRU3yOcf/xg9q1Sn6JGd4iFVWRVDbz7x1bM/QFzKf3 pxXoY3Cv1kkq0+euiH2yMY3DwUCMDMjX7LarAhCWztW268jYZ39MvNSCgyPgeR5B63F7ux+ps 7cokBhpCM+tchZINu/CysJgO5F9wZyXqQqn1XcQ0+L+k7U0EaNvcHdPYRG/jWMFrQKtBPZeDq fcerH3/NIeo5hn2GHXPH8DI5uvHY5WfyLcFa0K0S3zmavE1PACniNzvGrrNU2gDJYNq2W4wcM 8eL9OfP1x9qFOE2wHsI0fdAKwnPGSPWIDozgMSFAhcHWrmspczGqG/gMbhKNedTF/JWZtUCgG 2Z5NwPWts+uXTPzsCYqje1D96TRq6HDfndANTzPnt1qXrRGN49EDDgDg0C1wMU/icWhhak/I7 NLtg60Y0pBvnyHw7xxtFocuAuF7lHpYmM1e2u4CE9w7eM= A side effect of making the dock monitoring interrupt-driven was that we'd be very quick to program a freshly connected dock. However, for unclear reasons, the dock does not work when we do that - despite the FPGA netlist upload going just fine. We work around this by adding a delay before programming the dock; for safety, the value is several times as much as was determined empirically. Note that a badly timed dock hot-plug would have triggered the problem even before the referenced commit - but now it would happen 100% instead of about 3% of the time, thus making it impossible to work around by re-plugging. Fixes: fbb64eedf5a3 (ALSA: emu10k1: make E-MU dock monitoring interrupt-driven) Link: https://bugzilla.kernel.org/show_bug.cgi?id=218584 Signed-off-by: Oswald Buddenhagen --- sound/pci/emu10k1/emu10k1_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 1a2905e8672b..8ccc0178360c 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -737,6 +737,12 @@ static void snd_emu1010_load_dock_firmware(struct snd_emu10k1 *emu) u32 tmp, tmp2; int err; + // The docking events clearly arrive prematurely - while the + // Dock's FPGA seems to be successfully programmed, the Dock + // fails to initialize subsequently if we don't give it some + // time to "warm up" here. + msleep(200); + dev_info(emu->card->dev, "emu1010: Loading Audio Dock Firmware\n"); /* Return to Audio Dock programming mode */ snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, From patchwork Sun Apr 21 20:47:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 13637538 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75E6F3FBB2 for ; Sun, 21 Apr 2024 20:47:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713732443; cv=none; b=s2Hxb1nUl6GvXx3Zcioai2WI/oJ9Kk2O7ookQWHN6FSDag2v6WjLboldSxrbvJ6sPaOK2tE/urg6VXT3YOl+db0PBFqpegavxNmUgOjfYS1sX0VnX1wGchjxYvM+QnruSCY1sgWLd+SKTQ7iSeM0wrPe3NltApjD2cqs+sGsqgM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713732443; c=relaxed/simple; bh=nColKKzV0soArb61v4X9w8QJe/4erO6BS6uJMMwIgVk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gT+nkDfqr1CSpaaPqo2RgsA9+odCzIrUu/JdzZQOVWGs4pEZSBgTwYTqRmPMiiL0aNxH69x+X/MQnwjrf43Rke/s1eCBDH77AeCnP6Viu+C7wTbl9TWLC3mqn/lTL2o4QQAVAod+MvJHjBrzcfuuYwMhBEDXQLrXAcY59oVayGA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b=RPiyGBId; arc=none smtp.client-ip=212.227.15.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b="RPiyGBId" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1713732428; x=1714337228; i=oswald.buddenhagen@gmx.de; bh=1ZmXywRbewDSRLH05bIq+ZhQEmKuuatpJW1xITotxsU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=RPiyGBIdmrbGq0Fzn6ohFXu2vNYbI1UGrLOiVEDOhso+9sty+BUGmnN0J/W5bIC4 jhkE3H7mMG1AmIncOfOxdHIrQgr2C5AAF0yA0J9s9GnUcSS8VVuEqeXVglLGIwldC XDpYaA3MK/dueuLwkw0vTNwzUU1zsXIHJfkh1FpNM8OPORHmI1R8IO9SlgixT6h6z 7kk7ENfLLqf5N6yjk4Mzs3yxWE/1Q5hPz9CYrw56pVTEZj1Poprie1Ku7IplpNeDz GRoEZXOIi8wbnVduXQbpGoScLHZgcvFfVSV9V6FWkTLVbCaHLVthGIzDHsOYqCree t46hkYhEkiIzVvxwRA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.112]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MjS5A-1sRt2c20ug-00kvRg; Sun, 21 Apr 2024 22:47:08 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rye5b-RAl-00; Sun, 21 Apr 2024 22:47:07 +0200 From: Oswald Buddenhagen To: linux-sound@vger.kernel.org Cc: Takashi Iwai , Jaroslav Kysela , Pietro Caruso Subject: [PATCH 06/10] ALSA: emu10k1: simplify E-MU card FPGA reset sequence Date: Sun, 21 Apr 2024 22:47:03 +0200 Message-ID: <20240421204707.2487686-7-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240421204707.2487686-1-oswald.buddenhagen@gmx.de> References: <20240421204707.2487686-1-oswald.buddenhagen@gmx.de> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:WkY8KSUUE/FO7WAAn2uk/KI66pw5EWuG2l+2bL0XJhA9UBtB0FN hpSiNV8VfgI8di7Jry0PRzeJWEWlQQBr90Ake1vQk9ex9rHJPd3PpmN3opgx7Bhg0ZY9P/C SSFYyjGnUlDjVOgkFBICpiykmSsgzwF8mb+5eP76mNyVW+A9MFLoj/rIR6r5Wy1vEGf/WR2 UjCEaTcxMyNcArBqQh52w== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:Qs8OENc7/uM=;OeKdXyLQVu07XgCHCNnOtthojz/ lxHrzphhD3zkV+MMjDg1lV/ldVvhJ3LTuCZ5wt8xx0TU5Lpbq5Z1oqAqvl7plPGW+IMW8j3E8 IbW7uJN+JRYOF6N7ZGx2gpEZZ7tQO7KOPGTbUnfntapbBP/A54us5yBXCrs3et3KiGhWThisl VjOR/nCLYPSzy5CT7pHSXcEEVFefxq+SiWUFZ06FoLqGEyRLVUr0uYeG/wxZs1y/UqD+6qUpo g2hjK4qvWOfV/DEvy/w2gxtWHI3OzpHJQyj5Oa/Abt9oubehqQsAHvzrRRicU803D0oH+zdlr gy2VzhKkjnP6G3FVmy5jZAoj7ohnLIWkmjHsrgx62avDM5cTowtcq8vvRlTDImsaaflgXF8gl wMj1IXOXRimlpIwY+8trvkqXlb8OurxTskxchqoUzbqzvB/mQY5IU1xyvfeETam3b5j8WdScI ROfBvKy5x2ZAyjOhvJXOP+MZZi0iYTbnLRs/gxdyZ/wGmaY8yjFxEP/5h2xXdYM+434wgLRUE FyeFEo24I9pk7OAqiSndDl46esMc2DgxmymtatGGEsYQY30Au8xQ9Zt9VeiH+5OP8GIL2A/xp ZWvieK92ez1Lb6kn0F3G/uuOX1YlGMOtEMU9RKOwZAfOGHHXx/3g8Cx01pedc+2iw9f59ztkh rleLqH3IlM9iaMYp96cUH5FJDCpXlyhi9iUQW/gkuunsmxIUkuQnQW1vt/53PRX1chKl4W8VI KN2GnkQQNzFdcQB43x6mZZa1hTh0AGOyodLhqqUsjAp/2joNRWivdzU5uYRvKdtS16F+d87C0 831uij89ovV+wi+PQiV6kWSLO0qWXdsSotpIAf/ewRWuY= Firstly, it is pointless to explicitly disable the power to the dock prior to resetting the FPGA, as the latter will do the former anyway. Secondly, it doesn't make much sense to check whether the FPGA is already programmed. It's much simpler to just presume it is, and issue the self-reset command. If it isn't, the effect isn't worse than the checks themselves. As a side effect, we lose the info if the reset fails, but there is no plausible way how that could happen unless the card burns out while operating, and in that case we'll detect a firmware upload failure a bit later anyway. Signed-off-by: Oswald Buddenhagen --- sound/pci/emu10k1/emu10k1_main.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 8ccc0178360c..353dd3b61c61 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -864,28 +864,9 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu) snd_emu1010_fpga_lock(emu); - /* Disable 48Volt power to Audio Dock */ - snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0); - - /* ID, should read & 0x7f = 0x55. (Bit 7 is the IRQ bit) */ - snd_emu1010_fpga_read(emu, EMU_HANA_ID, ®); - dev_dbg(emu->card->dev, "reg1 = 0x%x\n", reg); - if ((reg & 0x3f) == 0x15) { - /* FPGA netlist already present so clear it */ - /* Return to programming mode */ - - snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_HANA); - } - snd_emu1010_fpga_read(emu, EMU_HANA_ID, ®); - dev_dbg(emu->card->dev, "reg2 = 0x%x\n", reg); - if ((reg & 0x3f) == 0x15) { - /* FPGA failed to return to programming mode */ - dev_info(emu->card->dev, - "emu1010: FPGA failed to return to programming mode\n"); - return -ENODEV; - } - dev_info(emu->card->dev, "emu1010: EMU_HANA_ID = 0x%x\n", reg); - + dev_info(emu->card->dev, "emu1010: Loading Hana Firmware\n"); + snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, + EMU_HANA_FPGA_CONFIG_HANA); err = snd_emu1010_load_firmware(emu, 0, &emu->firmware); if (err < 0) { dev_info(emu->card->dev, "emu1010: Loading Firmware failed\n"); From patchwork Sun Apr 21 20:47:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 13637533 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E0B63D3B3 for ; Sun, 21 Apr 2024 20:47:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713732442; cv=none; b=YN1ypC0jngJEELwTMHnXxpxnTZO+gbl2gPNi/IXPItWS2ysost+rHMK9BAraT2b5Olpgn9LDuSaS6TOGRGqhWdmABNU3v+eSQs9wP04uCDumdfaPlK4qKU8LAnpQg1xB58E19/0fKlksGKrjTv/ZL5fRT/PDpeXLUwVEd6atd1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713732442; c=relaxed/simple; bh=FZlUkxsA3h9RSUCax5XbxtSOrOZFere+WoEZUnYq60g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JDFSIFI/8Xt35JeP6EDoN2HyYu6FtC2yqm4E5XaPDqZDg4Fv/spXtohq2Toub5nlgG/my7/raboLTnY1S/Fk5Y/TCKle14fPhuEj7UZ3QwwRTkfF6KKQxhf4jgfJ4DH+yViCrmpg51CSjvaOSontMEFjfwWTXllNjg7gqioS7QA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b=bcoLUhD2; arc=none smtp.client-ip=212.227.15.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b="bcoLUhD2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1713732428; x=1714337228; i=oswald.buddenhagen@gmx.de; bh=oZeTDnMRPB8enV0FVGxnayR+kaCJpbjx5s1efV04cw8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=bcoLUhD2qeLcAzWAPGv0YwrM/2oZnUOE30Qmw18Vcge0favI7xnqVKBajG5RFZVb SY8AXfkjpjK8xcmt9umFl/GWGv990YhK6UYxnaU5nTLX+83O7uYODbE99QVvVlqJN ay+VEgbyWiGHMZ5XwcTKuZRgMMt8Qy6HHeBwgVcZIfjZveX4KJK+VqI60thrmDfnb ywQB8ynBkqGvAfBRYZZu8l+PkbjI5mx3Mos4a0/49LksKLXM3Mg+QXz9hHGiCSP7K eDRDh6ixcNyxHA699EVvXAXMJzh8CViaxXwggfbI/LN91sJfsvX4kuKRjcnerTLo2 syzm4YWHyU4VJf2/BA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.112]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MD9X9-1rpXHp23wP-0097Vq; Sun, 21 Apr 2024 22:47:08 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rye5b-RAq-00; Sun, 21 Apr 2024 22:47:07 +0200 From: Oswald Buddenhagen To: linux-sound@vger.kernel.org Cc: Takashi Iwai , Jaroslav Kysela , Pietro Caruso Subject: [PATCH 07/10] ALSA: emu10k1: make snd_emu1010_load_firmware_entry() void Date: Sun, 21 Apr 2024 22:47:04 +0200 Message-ID: <20240421204707.2487686-8-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240421204707.2487686-1-oswald.buddenhagen@gmx.de> References: <20240421204707.2487686-1-oswald.buddenhagen@gmx.de> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:NLJVrrWZr7uYsGMh5YdyEp67iqZioYRCOiXGoil1QtqCMoBN55D ZkuJ/Ejo46rn/5IXaY8sMPyOTqkm76D31uT6vb5YZhkF1heFSDiyPwM/rKEjMEdEIZdVbND innf9NU0DEy3pk1HydjuBbA86EcaM56ZSB/Pjx8AdbOATc96Py4zLloLxF3dB4ZxvUint8H TP6BuUyxUwEAJepcJ+5CA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:TCepPdW9v1g=;AtUl5Vv+/TFIf8oVel57dAdvw5C M70YhLkqi36pVxA1Z5+TUlFw6eIt3u5Am7uFN9YVxeOa2HGbPkFIGli2tyDuq9dfsAyw/5SC7 1Wlq/8bWYxok3BawqZzDaos+NcIoY4TyPQ/adG4HlCUKBNAWyAvTIMobe/K0wzqeMOxkB250q Utjkz3uk9aD6BwJHMaLtlI/n1NY/JJ9+O6u3OVZzCWZrbzkcaX3OUGb6lTOtGt3hqnb8SdIwK LW141sz390BRdHduR+snsakiV4wqPz7cPM4+tuRmi/G3A1jewGq7fcoaD5YnSnS2h14MVgY4j a+o6ajbCDQ36Otghxq6uNyhzbS1PiIh4UHCwKXgM0A9bn1qv+5BhnlDJFcyWQ8CuFTR2QAxok NHec6/wl/pNl2LUV5cx8JNkyViPK20isR9WJAZmtmApR6no97iXSuGQdXDiQEHFzRdz0SwXDi SCLiD3wh67MeKsriVUl4TwLbXLYsHgmR9mL308/QGSITPpFUC3KdbbMh+VZBjpA44K+pfCsTR OFgrpd7DANi8eQlsjU7B7V5IqN4rYmPmJ0JpfdSnM5sTFEhh/q8GBGjYmh0za3HyFuDXKbc/i Yeaf2S7/AHF3+28uWsP9SxIcfJ09RbyYGty+5Dmo3ltAYCdN/xQnP5VWeHO3gG+sy0gQOX3Pa PV9JTuNV2NzTTEp8hVgS9V+7hTUV4GEHcboDdU62ZXKDbJk/thlAgmnjH+O8nHWTh8xQG/xlb gkE6OWgM5dnu7R1izdnWmrqcMAicG4ZJWpHyZASrkX0guq75qf5pg3a9FkLRDVP5j2N+vb04g PCN6uT+SA2f7eh+UWOqskVYBA/TYEh/+vBVWxVAso6WTo= There is only one call site, and there we already know that we actually have a firmware. Signed-off-by: Oswald Buddenhagen --- sound/pci/emu10k1/emu10k1_main.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 353dd3b61c61..ec010971a220 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -652,17 +652,14 @@ static int snd_emu10k1_cardbus_init(struct snd_emu10k1 *emu) return 0; } -static int snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, +static void snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, const struct firmware *fw_entry) { int n, i; u16 reg; u8 value; __always_unused u16 write_post; - if (!fw_entry) - return -EIO; - /* The FPGA is a Xilinx Spartan IIE XC2S50E */ /* On E-MU 0404b it is a Xilinx Spartan III XC3S50 */ /* GPIO7 -> FPGA PGMN @@ -694,8 +691,6 @@ static int snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, outw(0x10, emu->port + A_GPIO); write_post = inw(emu->port + A_GPIO); spin_unlock_irq(&emu->emu_lock); - - return 0; } /* firmware file names, per model, init-fw and dock-fw (optional) */ @@ -729,7 +724,8 @@ static int snd_emu1010_load_firmware(struct snd_emu10k1 *emu, int dock, return err; } - return snd_emu1010_load_firmware_entry(emu, *fw); + snd_emu1010_load_firmware_entry(emu, *fw); + return 0; } static void snd_emu1010_load_dock_firmware(struct snd_emu10k1 *emu) From patchwork Sun Apr 21 20:47:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 13637540 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44EE6249E4 for ; Sun, 21 Apr 2024 20:47:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713732443; cv=none; b=rZjdMo8ecb16A/5e/BKtAeVWTxUoV4vLua0btuCugVF+qtxtgbib4wGa+lmWgZyX2+mzETtWe4zm9/OK1o8shpfv+Q2ijOGBWgqEGgA7an9HCohltpRHCYvkmjuCagLiIZXw838NFm9KcXxXTU3zCws+EbwF9drO/j/N9spn6Hw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713732443; c=relaxed/simple; bh=EQRqDlCxQ5XPdfzGKh932goby9IZfr0XWHHbWqNAbEU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OM+I0niXW+dtvb4LqJu7SLYHMj18sFpj16zqbtCOO1XXy7ZLmkgXNlEKZxx0aE294JApdpvxKsdWXm81GSlQwKgm1atJOlpG8DdBWP8Chq8N+aRVbvRR9BeWJJewMVgymSxor/CgtDojT5PxYTmBN2zsH1BhV+k79MIJJOzaoE8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b=lDYEejRw; arc=none smtp.client-ip=212.227.15.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b="lDYEejRw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1713732428; x=1714337228; i=oswald.buddenhagen@gmx.de; bh=UhZF5H2rg6othVx24q0JPaDd7zyQVBKcHLPbZFsPOyA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=lDYEejRwW5eGe8t79PzTD2qUiD+LZ3ad+pL3CNcqHzLHTadmzdkTORTFoehWz6bU KA1lovJokqS9zbSQhNV7V9k/n8o/PUpS2utfa3HiMAdgTfPAeZnfucMv/5SW0lc0X YbNEiBQ+C3uD18lvRWj6QoATIUxHrx7UxV7cSkp7w7/JrtYyQUw+WR0FWA9bbi70O qRZ4tpi871g//GQvzVIe07xDiybKMn0Zg89TyAMQYgtuFKbIKRxIIAEGXeYDJIEEz dGU5Ff0+2Zr8HqhLK1K2QkugKcUfkYYA/p7aSPY2vNEBW/bRMapEUv4daqYhRwR+N YlFjPgVXbiYeZToUJw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.112]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N95iH-1skEiB283j-016ATN; Sun, 21 Apr 2024 22:47:08 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rye5b-RAv-00; Sun, 21 Apr 2024 22:47:07 +0200 From: Oswald Buddenhagen To: linux-sound@vger.kernel.org Cc: Takashi Iwai , Jaroslav Kysela , Pietro Caruso Subject: [PATCH 08/10] ALSA: emu10k1: move entering E-MU card FPGA programming mode Date: Sun, 21 Apr 2024 22:47:05 +0200 Message-ID: <20240421204707.2487686-9-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240421204707.2487686-1-oswald.buddenhagen@gmx.de> References: <20240421204707.2487686-1-oswald.buddenhagen@gmx.de> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:qd2tTN/WloAZANcxHlWldpwsmo9IumSryon7OJMNOq6NUKXszeY cnmwz+tiDH37qfl1W8TQKJfA8TStrzU3Wqiod6pXupQNeV87JVYkFHzFC9h/lfkCqK6Uieh Ttuk7u+G6Zk1S+5jJkO2oON5k1UJ/hx2T8+QY1b+6PB92GxZHOiteXdnNlXr5gd6PqKgQCT dXw8v25wNOxiO6SIS+lOg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:ik2ZeiP/G3o=;+CKdBEcJs3lB7CZzDN4Wr5rgwEv PVSAuz0C6BvtPwCNZa25x1Gu7JnNRUPE8BgCBkow/W5nydSrxwfp8sd1XBJ4RCxGsdQyweFGp 7onrbCuwynyLINRQp9XW1xK6fAIb4uykLxXGW5uX9iO8anN/N0JdZIxQnEVRc8XDllprFodU5 XsQ7hCpUDhv1nOy7274Gh3M/skag9TCyrjXhxef1R9oW2svZTsft7izAsLdVhG7EBsCdn+9Sn 1dYprULTZQQ81Apgky19ydmSvBb6mPF8LBTPvOnFJjF8ASyrEknPSwcuCW9DOeDuYU0QOdGZZ bRiJeOQEqrnE/dQ9WDzwdJbeHORcjNMCxxU7jHkzyo6cBVlTWbk1zZ8GQcgTPnI79k110GNr5 8le/x5Vv1qOlKU/ov1JAuWKx/Cx+lPFGHCn0TuBCqXsfFkw6+E1/wQ3J6eLILz0tKM7wu1xyT YNAorGEceNMXmAWymrOwrGQFFHQRerJiZ82MN7UIKa3UeQeic9GGaAlHA/nayXaueFw+fQcta 91GREH12AdPFPnFyWP1hq09Q8y0YG5vFDXAlN4duPupMA6PKXDnnTomvyox51zT4D3o77kSc5 TSkZkbxLgoobQ/0ACOp2EM9sXWweZrIucWUFsHZlEX65ZqJuFwXbxl1RoA3yaJwZSjh2spQZF 2TzuueNGfCUI62iPOga6GzugdW9+94lsjZvjhKm4vtJ6/m9+Ba0fxVOkvs1ogwhJd8k47z7Xu FDMJSZ5pzsoua91dxFjf9b0Yymdh+wg7YeOAU98hhLjvAy2znUaZ4FOB7dHqXu9Mskq/X1qGr 9UnMFcrVYQHB99Mp9nik9RnSuda7RSCzCAcTMLa9KKpsk= ... into snd_emu1010_load_firmware_entry(). This makes it clearer that these steps belong together tightly, as explained in a prior commit. Signed-off-by: Oswald Buddenhagen --- sound/pci/emu10k1/emu10k1_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index ec010971a220..d0f35d346765 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -652,14 +652,19 @@ static int snd_emu10k1_cardbus_init(struct snd_emu10k1 *emu) return 0; } -static void snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, +static void snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, int dock, const struct firmware *fw_entry) { int n, i; u16 reg; u8 value; __always_unused u16 write_post; + // If the FPGA is already programmed, return it to programming mode + snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, + dock ? EMU_HANA_FPGA_CONFIG_AUDIODOCK : + EMU_HANA_FPGA_CONFIG_HANA); + /* The FPGA is a Xilinx Spartan IIE XC2S50E */ /* On E-MU 0404b it is a Xilinx Spartan III XC3S50 */ /* GPIO7 -> FPGA PGMN @@ -724,7 +729,7 @@ static int snd_emu1010_load_firmware(struct snd_emu10k1 *emu, int dock, return err; } - snd_emu1010_load_firmware_entry(emu, *fw); + snd_emu1010_load_firmware_entry(emu, dock, *fw); return 0; } @@ -740,9 +745,6 @@ static void snd_emu1010_load_dock_firmware(struct snd_emu10k1 *emu) msleep(200); dev_info(emu->card->dev, "emu1010: Loading Audio Dock Firmware\n"); - /* Return to Audio Dock programming mode */ - snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, - EMU_HANA_FPGA_CONFIG_AUDIODOCK); err = snd_emu1010_load_firmware(emu, 1, &emu->dock_fw); if (err < 0) return; @@ -861,8 +863,6 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu) snd_emu1010_fpga_lock(emu); dev_info(emu->card->dev, "emu1010: Loading Hana Firmware\n"); - snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, - EMU_HANA_FPGA_CONFIG_HANA); err = snd_emu1010_load_firmware(emu, 0, &emu->firmware); if (err < 0) { dev_info(emu->card->dev, "emu1010: Loading Firmware failed\n"); From patchwork Sun Apr 21 20:47:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 13637541 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6172843AB4 for ; Sun, 21 Apr 2024 20:47:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713732444; cv=none; b=o7LULL23npxC84ZiZ8tna2ys8Gam4TMuXmPd9psh3sUvw4aLdwhfzYtF7bHruWOC6o0uC+I6w6loGYpX7IAfbIPglyatYD1d+iHiMrnMImfc5/11OPhS9C4poX+xuo8Ci9DBjBXKKl4s9rGnjS6dAUBuwAYxxDa4Ygg2YnEHWus= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713732444; c=relaxed/simple; bh=IU+PG+RneOji5EdZoWu+0RZx0GbMnwVjSzeMJZf9M+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BeVbltqUCgcrHmEd3kg7HKtCu5M1/pcJP7P6wuGKI5Rv/edXw8bPiYZ7WQErPc35nuy6QYwhU0FSYdNMSZ1KUddp8XH9wrCWHmm3DHB0KMSUOZc/IQQTuTmgZUks3FSssMr2lYooHyv/99JgMbbG1vYKiO6NXT2Z3/3RoSniWBo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b=hQz4eXbQ; arc=none smtp.client-ip=212.227.15.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b="hQz4eXbQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1713732428; x=1714337228; i=oswald.buddenhagen@gmx.de; bh=du77jfe12I26LGTMoaW86jR8Inmqk5T5FAh6IKVv1yE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=hQz4eXbQJP/mKC68SHzC/tQvfi9gkklMQT3XN+CYXqf143O5JjemwbkR3I5QZ8jA NdsbBJnP1ARCZOLounIr6pyiJ4lCAT9d46LwM+PKyELMRWoCzRFgK22iGh3gGWoTr V9quezyYYQ1ETCFCbXvR17owFIhmy8trtAVS/mFKeVZCtXs+XTzRQUdFsKNxJVCdp vJEqDdAGSH1EzoOVG+g4kusJm3y7ElmX7MxmLp5abFufliWfVFqstCsA9WdSAaeHd jiHSXcCFyDzK6+lRCffWePVxRGJQDi2mGFPJudWuYAJuo+B0f/10CHGdDkyEl0XEf AMSfgK16N4fP9RuW6A== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.112]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mk0JW-1sRL4m282S-00kNHQ; Sun, 21 Apr 2024 22:47:08 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rye5b-RB0-00; Sun, 21 Apr 2024 22:47:07 +0200 From: Oswald Buddenhagen To: linux-sound@vger.kernel.org Cc: Takashi Iwai , Jaroslav Kysela , Pietro Caruso Subject: [PATCH 09/10] ALSA: emu10k1: move snd_emu1010_load_firmware_entry() to io.c Date: Sun, 21 Apr 2024 22:47:06 +0200 Message-ID: <20240421204707.2487686-10-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240421204707.2487686-1-oswald.buddenhagen@gmx.de> References: <20240421204707.2487686-1-oswald.buddenhagen@gmx.de> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:yGaAKr4wQ4l4bLwrpddI3gfkli5bniOaEDmX6Zj0cd+O6+OXPYJ Vbm/jpQZWrufKToFwnZ5gIeHNUk3eptWvVCOX/ktL1ZslDBjLBWvpgnqxfYfTyyI7imkxPm S8rItMImeeXufgEQKXWjb5J2c5K6/8y8fTm4kMwDFqj1cjDm316x+nU98vp1EPJq8Xv49N6 6hcJ1o/8spsU9L/5oBvgA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:fUr+8MYiXsE=;DWzp47uhy4zQLLZEQeiDoM+kFh5 B9SpK60EjjH9kVt9YzjKCysfqC03EbqroCVGEdpEGDS9TgoQ4fHOR4iqKgUyx7lrzdYDmh9t0 5fLJxrXM3hrgwhCkyVYQYHPTJR0aPbye3O6ZUoDzl+0PRrQ+oaEhpcUAPHmIimEELmQB1njIH 0wbR3t9/3PuJz5TCS9Xyg1ijJBzxnI1+dm3JuZLOkKpAB73+8LkYXRQqFLh0GaE1ACfu+DQxi zHH7Y2agyYp0rJ1R9un0/Gui0NQhyPV6u+MNiOgKdBBB92KtmrpLqilOAJc4rZoDhbYWocU4E Chk68uNWrPqRXQTQhdJo7Rk9DMSZibYmJK3DPrKJFtVdh+WXgIb8JRsBzU+HvcNIrhGvH2ABp WeIfViVAvs5v5emjDffxjzMJoR0z9qFzcNjlC1Tj+yV4oWK3qMO7kGX/FmGgPMeCga5YgUnzJ /hvujgfAO7SQMSX9DUCUIk3W9G+3yj4zK2aivYIhOEpRoJrv9l32tv9U8naFwARXxXIBQ2c+v QsjDoefixOvv6g3VzHkU+mpduLvwC+QiD2IKpLOJr9gRVvk6yEnsfO5Hm4Fq+ui96FOcctoPh r2pBc4inlST4Y6H0Fi5sGUAb9Agbu6TGslMEAkavKsWG3zd+ieBIYxO3lQc3lZ++vczQysi68 C3zfWwNT4wCd0Y0bpuK77XuipxBEFU+DULKpG99X48at9XSi2uIu9Vwreisa9OhvVsMfCesSB up3rZQ8z53dwpMm7k37aMXTqwIrvqioFdebR9re2T6madS62zhSNcgRC5Ppul+cm+gLohE0pQ LnI1X9TVf9DcdT0VDsl6EfSKaxlNQZdLZbcwoYgy3aoSU= It is a low-level I/O access function, so io.c is the natural place for it. While we're moving the code, reduce the scope of some variables, use compound assignment operators, and add/adjust some comments. Signed-off-by: Oswald Buddenhagen --- include/sound/emu10k1.h | 1 + sound/pci/emu10k1/emu10k1_main.c | 46 --------------------------- sound/pci/emu10k1/io.c | 53 ++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 46 deletions(-) diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h index 234b5baea69c..b83862259eec 100644 --- a/include/sound/emu10k1.h +++ b/include/sound/emu10k1.h @@ -1843,6 +1843,7 @@ void snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 *emu, u32 dst, u32 s u32 snd_emu1010_fpga_link_dst_src_read(struct snd_emu10k1 *emu, u32 dst); int snd_emu1010_get_raw_rate(struct snd_emu10k1 *emu, u8 src); void snd_emu1010_update_clock(struct snd_emu10k1 *emu); +void snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, int dock, const struct firmware *fw_entry); unsigned int snd_emu10k1_efx_read(struct snd_emu10k1 *emu, unsigned int pc); void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb); void snd_emu10k1_intr_disable(struct snd_emu10k1 *emu, unsigned int intrenb); diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index d0f35d346765..5b8a5ba825bd 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -652,52 +652,6 @@ static int snd_emu10k1_cardbus_init(struct snd_emu10k1 *emu) return 0; } -static void snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, int dock, - const struct firmware *fw_entry) -{ - int n, i; - u16 reg; - u8 value; - __always_unused u16 write_post; - - // If the FPGA is already programmed, return it to programming mode - snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, - dock ? EMU_HANA_FPGA_CONFIG_AUDIODOCK : - EMU_HANA_FPGA_CONFIG_HANA); - - /* The FPGA is a Xilinx Spartan IIE XC2S50E */ - /* On E-MU 0404b it is a Xilinx Spartan III XC3S50 */ - /* GPIO7 -> FPGA PGMN - * GPIO6 -> FPGA CCLK - * GPIO5 -> FPGA DIN - * FPGA CONFIG OFF -> FPGA PGMN - */ - spin_lock_irq(&emu->emu_lock); - outw(0x00, emu->port + A_GPIO); /* Set PGMN low for 100uS. */ - write_post = inw(emu->port + A_GPIO); - udelay(100); - outw(0x80, emu->port + A_GPIO); /* Leave bit 7 set during netlist setup. */ - write_post = inw(emu->port + A_GPIO); - udelay(100); /* Allow FPGA memory to clean */ - for (n = 0; n < fw_entry->size; n++) { - value = fw_entry->data[n]; - for (i = 0; i < 8; i++) { - reg = 0x80; - if (value & 0x1) - reg = reg | 0x20; - value = value >> 1; - outw(reg, emu->port + A_GPIO); - write_post = inw(emu->port + A_GPIO); - outw(reg | 0x40, emu->port + A_GPIO); - write_post = inw(emu->port + A_GPIO); - } - } - /* After programming, set GPIO bit 4 high again. */ - outw(0x10, emu->port + A_GPIO); - write_post = inw(emu->port + A_GPIO); - spin_unlock_irq(&emu->emu_lock); -} - /* firmware file names, per model, init-fw and dock-fw (optional) */ static const char * const firmware_names[5][2] = { [EMU_MODEL_EMU1010] = { diff --git a/sound/pci/emu10k1/io.c b/sound/pci/emu10k1/io.c index f3260a81e47b..9b1b25d5ba74 100644 --- a/sound/pci/emu10k1/io.c +++ b/sound/pci/emu10k1/io.c @@ -421,6 +421,59 @@ void snd_emu1010_update_clock(struct snd_emu10k1 *emu) snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, leds); } +void snd_emu1010_load_firmware_entry(struct snd_emu10k1 *emu, int dock, + const struct firmware *fw_entry) +{ + __always_unused u16 write_post; + + // On E-MU 1010 rev1 the FPGA is a Xilinx Spartan IIE XC2S50E. + // On E-MU 0404b it is a Xilinx Spartan III XC3S50. + // The wiring is as follows: + // GPO7 -> FPGA input & 1K resistor -> FPGA /PGMN <- FPGA output + // In normal operation, the active low reset line is held up by + // an FPGA output, while the GPO pin performs its duty as control + // register access strobe signal. Writing the respective bit to + // EMU_HANA_FPGA_CONFIG puts the FPGA output into high-Z mode, at + // which point the GPO pin can control the reset line through the + // resistor. + // GPO6 -> FPGA CCLK & FPGA input + // GPO5 -> FPGA DIN (dual function) + + // If the FPGA is already programmed, return it to programming mode + snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, + dock ? EMU_HANA_FPGA_CONFIG_AUDIODOCK : + EMU_HANA_FPGA_CONFIG_HANA); + + // Assert reset line for 100uS + outw(0x00, emu->port + A_GPIO); + write_post = inw(emu->port + A_GPIO); + udelay(100); + outw(0x80, emu->port + A_GPIO); + write_post = inw(emu->port + A_GPIO); + udelay(100); // Allow FPGA memory to clean + + // Upload the netlist. Keep reset line high! + for (int n = 0; n < fw_entry->size; n++) { + u8 value = fw_entry->data[n]; + for (int i = 0; i < 8; i++) { + u16 reg = 0x80; + if (value & 1) + reg |= 0x20; + value >>= 1; + outw(reg, emu->port + A_GPIO); + write_post = inw(emu->port + A_GPIO); + outw(reg | 0x40, emu->port + A_GPIO); + write_post = inw(emu->port + A_GPIO); + } + } + + // After programming, set GPIO bit 4 high again. + // This appears to be a config word that the rev1 Hana + // firmware reads; weird things happen without this. + outw(0x10, emu->port + A_GPIO); + write_post = inw(emu->port + A_GPIO); +} + void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb) { unsigned long flags; From patchwork Sun Apr 21 20:47:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oswald Buddenhagen X-Patchwork-Id: 13637544 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A82A4383BD for ; Sun, 21 Apr 2024 21:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713734041; cv=none; b=jGr657D8MJjpp4y2Gk7FDo7r28VzyQfl8Kjz0xhxc1tsIQdxAIpf6Gkbo1b+RP6r2G4Pp8uE4JlxRmbGDFJlVG1/x33ftl3OlLAnjL0Xcofkk8OX9hhtgnJUbZQNokQuqaHXqyBbS0sGBtp5J2GGl+vXQvzgIKiucYcRBsVm1J8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713734041; c=relaxed/simple; bh=F105mw880ou8WKiy5NvsZCUx1gHLmtNI0orNl9em4IM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sQtwBkkGtb0FpQT1e9TcNd+bVG894Y3JDPXKmTEu6Hl2M4GRBNswiw0gYSJF0GjR0ilcIn1RFO0MvpUKVfdVtseLyxfXsPj7umrbU6dqO+AT6dli4/zOUpXdIUb4mpXKFHWPKCKnOpQk0nIbTDdenMR9aKsvVhlfOvbUHA7ilfQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b=KH6NCCa6; arc=none smtp.client-ip=212.227.15.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=oswald.buddenhagen@gmx.de header.b="KH6NCCa6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1713734032; x=1714338832; i=oswald.buddenhagen@gmx.de; bh=m/WuiDcKf/6MlTX1l2uolQPTYDYtyq4mW5INjw2TlHg=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=KH6NCCa6uQMQxpnbHkNWxZciO++CX9/3y8Rn7+4KLS73Q7LYgCHKURRpbcJVgb4k WyEi5ks16czPeNvZrtfitVC3UGiWlfKurD+cPL+E8S5r2JjVmhlhtX9UrKgc6Bbju GekZIS0e8wv07D0hDkqPhk0rnHTAnsi86f44DQmO+t0nwwY3n8w4ap54Bphjpxmp2 zRVme/C5OYBAr3nmtmInKl/+DBVahUPpruSEfNcA1HfsrKWczXKXKfkqODe5cUaqS HzJ03qKFs47DRY2U+YUmxlP7FkOk+j9PO06G5jmwbUZ9NKpQznUVamtZMj8wGwgsw vgqgIhjXO47CQuGldQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from ugly.fritz.box ([89.247.162.112]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M4JqV-1ryNOL3DOL-000I5H; Sun, 21 Apr 2024 23:13:52 +0200 Received: by ugly.fritz.box (masqmail 0.3.6-dev, from userid 1000) id 1rye5c-RB5-00; Sun, 21 Apr 2024 22:47:08 +0200 From: Oswald Buddenhagen To: linux-sound@vger.kernel.org Cc: Takashi Iwai , Jaroslav Kysela , Pietro Caruso Subject: [PATCH 10/10] ALSA: emu10k1: make E-MU FPGA writes potentially more reliable Date: Sun, 21 Apr 2024 22:47:07 +0200 Message-ID: <20240421204707.2487686-11-oswald.buddenhagen@gmx.de> X-Mailer: git-send-email 2.44.0.701.g2cf7baacf3.dirty In-Reply-To: <20240421204707.2487686-1-oswald.buddenhagen@gmx.de> References: <20240421204707.2487686-1-oswald.buddenhagen@gmx.de> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:AdoOZH5ECZIRaqvv9HB5ZKu1KI7U2XVe7wHrzOX1tR1bP93+3K+ r2msnbwoA5IqaGgkPTttzsLxcAlfsrsMxtxMaSnmZbqGOD/2IkkLu9uE81/8+0tEkCx5GWZ 4zzCTmovyx2lEehZ6mgiu0Pvj+h9XZKaL1Lh2jJ+soUyYc77JcMtGr+3tvLe1gTxQWnG0vp OSRlQx4vz8w7AL7RUkGtg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:rmSPnCxIYuo=;R3wTnoyu7TFz88qs9TeGEm0bAxv zSGMH4de6RvQc49pC0AHJm2iIA5gYE0pE9vKC60sYjfusi1YDOENJalx8C/FEEfmsQwxLwmgS PQu5M5ibajrAsQ6TzZujMdT9SC20KKswHRPMtfU/E1RffCVwt0JFH2wO0TJ/tf95yNu0ZVAAH ncL/N3EyPTBeisPw2VDqkUBuF7nIhxn6WeI7N8Ak9SkwrKM1+P2akoU8mdT4s56CAB63CS3CI UwjdxTDgnEys9NkjGTwWmc1niMrS7ZSONElc/g6dgmhFhKZD5TsSIrAGaKkTO2nEUcBwRtfXR 64UtTnShbTi26w/2XQmy7wa3zgyiDkCaFAYp9pGY4bK0YraiOc3wjG/QdoQrdM78jOYPV6wrE DbOJrnEy/wzzIociAYhIEXOnxsBC5YzGTHsIqOIUi8gDhhtZA2XYBRJSocyvQCTFG6QR05bdB 6ZQ1q2/GLptoeXmDeSmkzMZzgUZ3ErbSLPZ1rzYPmNjKM3wZkn9oYNoL4tM7c19ojVrlkjcfw uzWEYNNjFBykMcMdepHZA3Of4UnA2x6GNb9I1iFJ4yvpSd85W2hPQ7wdpqT9eBmRRbT5RAQDT R4t0l7fpM0fgP/G9FLknXmUSZzxrBsi/3Zf1vCkhcJxZtcLPyOAy1sdH5k67qAtSicuoeLQSM Hft1I36MGkZl59zWU5Zi0m7w9TJlO2zlTTVvqGH8BC436iMkXtC/Eg/hAUPlUKLRoHXdUHkde ES8z5uXZvAZGUlsAk68xRDp7cnaeun7tTBcJXY+dTumSzas6yPW/0Zd5zr802UbmP4Da4yDK6 8tul5hbdYtmUJkkzbwKiUZ3iL7mGoKWCkDgYgn/vaYF8E= We did not delay after the second strobe signal, so another immediately following access could potentially corrupt the written value. Signed-off-by: Oswald Buddenhagen --- sound/pci/emu10k1/io.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/emu10k1/io.c b/sound/pci/emu10k1/io.c index 9b1b25d5ba74..b60ab5671e00 100644 --- a/sound/pci/emu10k1/io.c +++ b/sound/pci/emu10k1/io.c @@ -285,6 +285,7 @@ static void snd_emu1010_fpga_write_locked(struct snd_emu10k1 *emu, u32 reg, u32 outw(value, emu->port + A_GPIO); udelay(10); outw(value | 0x80 , emu->port + A_GPIO); /* High bit clocks the value into the fpga. */ + udelay(10); } void snd_emu1010_fpga_write(struct snd_emu10k1 *emu, u32 reg, u32 value)