From patchwork Tue Sep 12 11:32:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13381498 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 55327CA0ECA for ; Tue, 12 Sep 2023 11:35:11 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B93D1EB1; Tue, 12 Sep 2023 13:34:13 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B93D1EB1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694518503; bh=yAMrwWynjfRyQdGNHoOG57VnP9b0MEIbt8EPmc/BpU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=vVPRY4U55poSRf+gEiKtdjehluokv+f/o4XWqVKpOdcAhVyVtIlKKTKDrFRWoJhzR s80O97wDQSNC45vk5IaPFi7CCPVs4zpK0FG7DNPRGjf84BKRGwe6DyvCT0rwBy1j1J xspAws1Z4SqH82FI4uWjtmtEd8QmIi02PqP7XG3M= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 617ADF80563; Tue, 12 Sep 2023 13:33:22 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 6867EF80564; Tue, 12 Sep 2023 13:33:21 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 09897F80551; Tue, 12 Sep 2023 13:33:14 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 843AFF800AA for ; Tue, 12 Sep 2023 13:33:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 843AFF800AA Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=c/p1eZqT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694518382; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QdS97yqzYLELFF8D5WQtucMikkwzHgKzlzLISdy1jwc=; b=c/p1eZqT3xoQ7jAjkxXW5xO8begrOb48hIdE/zomnQlHGw3/X1dOFvQawZROT1q1wc4I+J E0f7tVo31AXuNBlsKu9dDzV4oMM2mE9Tdr56d0KKVzILl5yMSbdIycofCC3kl8NsNLN/11 W+58naCQCWLALatANXmxreG1QhWBmGU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-635-hGeQBe63O_mDIVKYArn3pQ-1; Tue, 12 Sep 2023 07:32:58 -0400 X-MC-Unique: hGeQBe63O_mDIVKYArn3pQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A4ACD181A6E0; Tue, 12 Sep 2023 11:32:57 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.194.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B5052026D4B; Tue, 12 Sep 2023 11:32:56 +0000 (UTC) From: Hans de Goede To: Oder Chiou , Liam Girdwood , Mark Brown Cc: Hans de Goede , Sameer Pujar , Cezary Rojewski , Pierre-Louis Bossart , alsa-devel@alsa-project.org Subject: [PATCH 1/6] ASoC: rt5640: Revert "Fix sleep in atomic context" Date: Tue, 12 Sep 2023 13:32:40 +0200 Message-ID: <20230912113245.320159-2-hdegoede@redhat.com> In-Reply-To: <20230912113245.320159-1-hdegoede@redhat.com> References: <20230912113245.320159-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: T3OTJ7SCNBLX2STOQ5B2Q2OCNCKW6OCQ X-Message-ID-Hash: T3OTJ7SCNBLX2STOQ5B2Q2OCNCKW6OCQ X-MailFrom: hdegoede@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Commit 70a6404ff610 ("ASoC: rt5640: Fix sleep in atomic context") not only switched from request_irq() to request_threaded_irq(), to fix the sleep in atomic context issue, but it also added devm management of the IRQ by actually switching to devm_request_threaded_irq() (without any explanation in the commit message for this change). This is wrong since the IRQ was already explicitly managed by the driver. On unbind the ASoC core will call rt5640_set_jack(NULL) which in turn will call rt5640_disable_jack_detect() which frees the IRQ already. So now we have a double free. Besides the unexplained switch to devm being wrong, the actual fix for the sleep in atomic context issue also is not the best solution. The only thing which rt5640_irq() does is cancel + (re-)queue the jack_work delayed_work. This can be done in a single non sleeping call by replacing queue_delayed_work() with mod_delayed_work(), which does not sleep. Using mod_delayed_work() is a much better fix then adding a thread which does nothing other then queuing a work-item. This patch is a straight revert of the troublesome changes, the switch to mod_delayed_work() is done in a separate follow-up patch. Fixes: 70a6404ff610 ("ASoC: rt5640: Fix sleep in atomic context") Cc: Sameer Pujar Cc: Oder Chiou Signed-off-by: Hans de Goede --- sound/soc/codecs/rt5640.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 15e1a62b9e57..05ff8066171b 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -2565,10 +2565,9 @@ static void rt5640_enable_jack_detect(struct snd_soc_component *component, if (jack_data && jack_data->use_platform_clock) rt5640->use_platform_clock = jack_data->use_platform_clock; - ret = devm_request_threaded_irq(component->dev, rt5640->irq, - NULL, rt5640_irq, - IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, - "rt5640", rt5640); + ret = request_irq(rt5640->irq, rt5640_irq, + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + "rt5640", rt5640); if (ret) { dev_warn(component->dev, "Failed to request IRQ %d: %d\n", rt5640->irq, ret); rt5640_disable_jack_detect(component); @@ -2621,9 +2620,8 @@ static void rt5640_enable_hda_jack_detect( rt5640->jack = jack; - ret = devm_request_threaded_irq(component->dev, rt5640->irq, - NULL, rt5640_irq, IRQF_TRIGGER_RISING | IRQF_ONESHOT, - "rt5640", rt5640); + ret = request_irq(rt5640->irq, rt5640_irq, + IRQF_TRIGGER_RISING | IRQF_ONESHOT, "rt5640", rt5640); if (ret) { dev_warn(component->dev, "Failed to request IRQ %d: %d\n", rt5640->irq, ret); rt5640->irq = -ENXIO; From patchwork Tue Sep 12 11:32:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13381500 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4849CA0EC3 for ; Tue, 12 Sep 2023 11:35:36 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9AC29ECF; Tue, 12 Sep 2023 13:34:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9AC29ECF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694518534; bh=JojRkQvL3sOnfU959DH4BZUrxNIsWcTsqGHa4lHLz/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=sw4yMfn3pbFY3Vxw7YtkOOVABfoiCSXd1k1ZbAylQgOmWUBY24SbPdf6tZhM0puSh gEKWkQ93nSGP+FZeD18RKobEsLoPc+FBXo8ERWmhfszOp3pOqtEjLRojkJIan+n4nO BCHm0zrdWrWiAX0oEItCx5xU4Iwj9ecK5960q59k= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6DFC6F8059F; Tue, 12 Sep 2023 13:33:31 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 7FA78F80589; Tue, 12 Sep 2023 13:33:30 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BA397F80246; Tue, 12 Sep 2023 13:33:19 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9141CF80425 for ; Tue, 12 Sep 2023 13:33:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9141CF80425 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TCFhfY6E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694518385; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FWrSVRpgYkqccnYBX+WyvN45IVRYPGYlajzOCq8cYXA=; b=TCFhfY6EqrYE4jxMmh2Kub1WGHGyd4sQN8Hyg2yqfPt9TeTnKNeh2UQ0esfp7pCDadu6zu 66EFg0mJQwfo7fWJaC+jAmng684pXD7RQMqeeOmbo0ToGJ0YINS8tl9f6kwkODVJLJeKTH OwRW7zmccTK2ONjEFvMzKziolt4G2gk= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-615-jloJgXNzONGu21hslitwGQ-1; Tue, 12 Sep 2023 07:32:59 -0400 X-MC-Unique: jloJgXNzONGu21hslitwGQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F1AA13806707; Tue, 12 Sep 2023 11:32:58 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.194.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id D6F4C2026D4B; Tue, 12 Sep 2023 11:32:57 +0000 (UTC) From: Hans de Goede To: Oder Chiou , Liam Girdwood , Mark Brown Cc: Hans de Goede , Sameer Pujar , Cezary Rojewski , Pierre-Louis Bossart , alsa-devel@alsa-project.org Subject: [PATCH 2/6] ASoC: rt5640: Fix sleep in atomic context Date: Tue, 12 Sep 2023 13:32:41 +0200 Message-ID: <20230912113245.320159-3-hdegoede@redhat.com> In-Reply-To: <20230912113245.320159-1-hdegoede@redhat.com> References: <20230912113245.320159-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: RFOUDE2QUXM4SRGNTZWOMAHF6HUC6GDM X-Message-ID-Hash: RFOUDE2QUXM4SRGNTZWOMAHF6HUC6GDM X-MailFrom: hdegoede@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Following prints are observed while testing audio on Jetson AGX Orin which has onboard RT5640 audio codec: BUG: sleeping function called from invalid context at kernel/workqueue.c:3027 in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 0, name: swapper/0 preempt_count: 10001, expected: 0 RCU nest depth: 0, expected: 0 ------------[ cut here ]------------ WARNING: CPU: 0 PID: 0 at kernel/irq/handle.c:159 __handle_irq_event_percpu+0x1e0/0x270 ---[ end trace ad1c64905aac14a6 ]- The IRQ handler rt5640_irq() runs in interrupt context and can sleep during cancel_delayed_work_sync(). The only thing which rt5640_irq() does is cancel + (re-)queue the jack_work delayed_work. This can be done in a single non sleeping call by replacing queue_delayed_work() with mod_delayed_work(), avoiding the sleep in atomic context. Fixes: 051dade34695 ("ASoC: rt5640: Fix the wrong state of JD1 and JD2") Reported-by: Sameer Pujar Closes: https://lore.kernel.org/r/1688015537-31682-4-git-send-email-spujar@nvidia.com Cc: Oder Chiou Signed-off-by: Hans de Goede --- sound/soc/codecs/rt5640.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 05ff8066171b..5c34c045d396 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -2403,13 +2403,11 @@ static irqreturn_t rt5640_irq(int irq, void *data) struct rt5640_priv *rt5640 = data; int delay = 0; - if (rt5640->jd_src == RT5640_JD_SRC_HDA_HEADER) { - cancel_delayed_work_sync(&rt5640->jack_work); + if (rt5640->jd_src == RT5640_JD_SRC_HDA_HEADER) delay = 100; - } if (rt5640->jack) - queue_delayed_work(system_long_wq, &rt5640->jack_work, delay); + mod_delayed_work(system_long_wq, &rt5640->jack_work, delay); return IRQ_HANDLED; } From patchwork Tue Sep 12 11:32:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13381501 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E60DCCA0EC3 for ; Tue, 12 Sep 2023 11:36:01 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 07EABEDB; Tue, 12 Sep 2023 13:35:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 07EABEDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694518560; bh=9n8UZzvryLuk2vZJC8M3V8alIAZcil2o5hNupvZ7T8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=oBRsQaY3pE8w+WdYbG5u2ZGfl4gt4qMiWh1jUIV/WqzF0Kf6Qr2Hmy1trnpz8fZFU czC4URFOJjUaagayUVVBRMptclwfzjM2eIPnka9tozeZkkb4pAwrWN+yd4klssAz/l +KhWikOxvwxHY/k1bPPW9IoMk4zOh7e+v4RGNBdQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 93FC5F805AC; Tue, 12 Sep 2023 13:33:33 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id EA4ECF805AB; Tue, 12 Sep 2023 13:33:31 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 04DCAF80425; Tue, 12 Sep 2023 13:33:23 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2464CF80431 for ; Tue, 12 Sep 2023 13:33:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2464CF80431 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hrpg9sUE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694518384; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TaVFcExhlXRJGgXNUHcGuf/ioS9jysk1K5nXiR2tMGQ=; b=hrpg9sUEs2PTQMW4xpIv2VGZPSv3JcL75GN8CaUV5C7pvUFPek+zXHdqJ7CuBHCmqSOR8P kEflQT9O4WnhrEfBGBWT0bQYpEjxdiQH/ZMO8fkjWE2WLMKg4y7fJHMD1QKqy2Nii5KpJg UGsYJCe8eaO1GlJbU9iCfNnXvetYu+c= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-680-uHvsWEhpPFGELt6YFKgF9A-1; Tue, 12 Sep 2023 07:33:00 -0400 X-MC-Unique: uHvsWEhpPFGELt6YFKgF9A-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 47916101FAA0; Tue, 12 Sep 2023 11:33:00 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.194.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E9D22026D68; Tue, 12 Sep 2023 11:32:59 +0000 (UTC) From: Hans de Goede To: Oder Chiou , Liam Girdwood , Mark Brown Cc: Hans de Goede , Sameer Pujar , Cezary Rojewski , Pierre-Louis Bossart , alsa-devel@alsa-project.org Subject: [PATCH 3/6] ASoC: rt5640: Do not disable/enable IRQ twice on suspend/resume Date: Tue, 12 Sep 2023 13:32:42 +0200 Message-ID: <20230912113245.320159-4-hdegoede@redhat.com> In-Reply-To: <20230912113245.320159-1-hdegoede@redhat.com> References: <20230912113245.320159-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 3AXI4VJPO3BZ5QIUEBBA4KXZTT3H7HCJ X-Message-ID-Hash: 3AXI4VJPO3BZ5QIUEBBA4KXZTT3H7HCJ X-MailFrom: hdegoede@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: When jack-detect was originally added disabling the IRQ during suspend was done by the sound/soc/intel/boards/bytcr_rt5640.c driver calling snd_soc_component_set_jack(NULL) on suspend, which calls rt5640_disable_jack_detect(), which calls free_irq() which also disables it. Commit 5fabcc90e79b ("ASoC: rt5640: Fix Jack work after system suspend") added disable_irq() / enable_irq() calls on suspend/resume for machine drivers which do not call snd_soc_component_set_jack(NULL) on suspend. The new disable_irq() / enable_irq() are made conditional by "if (rt5640->irq)" statements, but this is true for the machine drivers which do call snd_soc_component_set_jack(NULL) on suspend too, causing a disable_irq() call there on the already free-ed IRQ. Change the "if (rt5640->irq)" condition to "if (rt5640->jack)" to fix this, rt5640->jack is only set if the jack-detect IRQ handler is still active when rt5640_suspend() runs. And adjust rt5640_enable_hda_jack_detect()'s request_irq() error handling to set rt5640->jack to NULL to match (note that the old setting of irq to -ENOXIO still resulted in disable_irq(-ENOXIO) calls on suspend). Fixes: 5fabcc90e79b ("ASoC: rt5640: Fix Jack work after system suspend") Cc: Oder Chiou Signed-off-by: Hans de Goede --- sound/soc/codecs/rt5640.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 5c34c045d396..1bc281d42ca8 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -2622,7 +2622,7 @@ static void rt5640_enable_hda_jack_detect( IRQF_TRIGGER_RISING | IRQF_ONESHOT, "rt5640", rt5640); if (ret) { dev_warn(component->dev, "Failed to request IRQ %d: %d\n", rt5640->irq, ret); - rt5640->irq = -ENXIO; + rt5640->jack = NULL; return; } @@ -2797,7 +2797,7 @@ static int rt5640_suspend(struct snd_soc_component *component) { struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); - if (rt5640->irq) { + if (rt5640->jack) { /* disable jack interrupts during system suspend */ disable_irq(rt5640->irq); } @@ -2825,10 +2825,9 @@ static int rt5640_resume(struct snd_soc_component *component) regcache_cache_only(rt5640->regmap, false); regcache_sync(rt5640->regmap); - if (rt5640->irq) + if (rt5640->jack) { enable_irq(rt5640->irq); - if (rt5640->jack) { if (rt5640->jd_src == RT5640_JD_SRC_HDA_HEADER) { snd_soc_component_update_bits(component, RT5640_DUMMY2, 0x1100, 0x1100); From patchwork Tue Sep 12 11:32:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13381499 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7CF0FCA0EC3 for ; Tue, 12 Sep 2023 11:35:13 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 54C09EBF; Tue, 12 Sep 2023 13:34:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 54C09EBF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694518511; bh=7yTkh3ebVYdyzO1U+EraGih6l6IEJsbp0ozt/60y+C4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=bK6e6hdf2N4lHbYzOZgs3owAHQaM0gvNAni2QOjehHtvy7Rf0fo0WPmodiaMK4bta CXruUBv2GT+rZuFshbfJPsfH0A7vTMqFh32LQZwAv2SfLXn6LG2x5S69jVT7KMSz51 pjbT/f1j3NodlUvjhXSNXXNhIxeoxkFSUYOPoHwc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 69A05F8057D; Tue, 12 Sep 2023 13:33:29 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id DED86F80431; Tue, 12 Sep 2023 13:33:28 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id EDD58F80549; Tue, 12 Sep 2023 13:33:15 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 58D56F80246 for ; Tue, 12 Sep 2023 13:33:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 58D56F80246 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bItbEFis DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694518383; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4IHAT93166r3YKheS9ZK6jqsBVwI86DIWmMXhcuCcSI=; b=bItbEFis+Kr4NiHFK2FgKQJ+juMhUO9I6oNr56HAEjHiRSic6XkMtsrHrR8C7vbnxHIwpF cquc5l+HWsrrtbK9nppEHAkjHaHbsEOrWb5mW6IvYhvJ0NNZ+8wAeUH+MYlCzTdi4DBZZ/ HXBa1cZN2fec3tdjsOGo66vkfgoWcJw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-683-ZDTvCL1aOZO2eQX-VjM5cw-1; Tue, 12 Sep 2023 07:33:02 -0400 X-MC-Unique: ZDTvCL1aOZO2eQX-VjM5cw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 927E780C908; Tue, 12 Sep 2023 11:33:01 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.194.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id 795332026D4B; Tue, 12 Sep 2023 11:33:00 +0000 (UTC) From: Hans de Goede To: Oder Chiou , Liam Girdwood , Mark Brown Cc: Hans de Goede , Sameer Pujar , Cezary Rojewski , Pierre-Louis Bossart , alsa-devel@alsa-project.org Subject: [PATCH 4/6] ASoC: rt5640: Enable the IRQ on resume after configuring jack-detect Date: Tue, 12 Sep 2023 13:32:43 +0200 Message-ID: <20230912113245.320159-5-hdegoede@redhat.com> In-Reply-To: <20230912113245.320159-1-hdegoede@redhat.com> References: <20230912113245.320159-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 2UD3TSMZKZAVCZDHBY3LQEGUXPBVP5KB X-Message-ID-Hash: 2UD3TSMZKZAVCZDHBY3LQEGUXPBVP5KB X-MailFrom: hdegoede@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The jack-detect IRQ should be enabled *after* the jack-detect related configuration registers have been programmed. Move the enable_irq() call for this to after the register setup. Fixes: 5fabcc90e79b ("ASoC: rt5640: Fix Jack work after system suspend") Cc: Oder Chiou Signed-off-by: Hans de Goede --- sound/soc/codecs/rt5640.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 1bc281d42ca8..03c866c04c7a 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -2826,8 +2826,6 @@ static int rt5640_resume(struct snd_soc_component *component) regcache_sync(rt5640->regmap); if (rt5640->jack) { - enable_irq(rt5640->irq); - if (rt5640->jd_src == RT5640_JD_SRC_HDA_HEADER) { snd_soc_component_update_bits(component, RT5640_DUMMY2, 0x1100, 0x1100); @@ -2854,6 +2852,7 @@ static int rt5640_resume(struct snd_soc_component *component) } } + enable_irq(rt5640->irq); queue_delayed_work(system_long_wq, &rt5640->jack_work, 0); } From patchwork Tue Sep 12 11:32:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13381502 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F3578CA0ECA for ; Tue, 12 Sep 2023 11:36:25 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id BDAEDEDA; Tue, 12 Sep 2023 13:35:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BDAEDEDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694518583; bh=fOzd19SFoDA6V+OtNqVNBoF5s8o2viZR0sRSugOrvoU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=l4aEQ0/duacjr5jWODfgvXUt6djKVLYHgAmJSseRriDG8pIz0TA4uUDT80ZB5LmQD F5/fRfVDPEUIzfwqII8Sk3MUwA9hsawZDXSyNetYkawxuKNkL95anTzAzywjkcUUzd YWoEsdLuafCf9IhufD6xWDl2YO4K6fIDvAHxhjlQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7EBC0F80549; Tue, 12 Sep 2023 13:35:33 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id C88C6F80537; Tue, 12 Sep 2023 13:35:32 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9562BF80425; Tue, 12 Sep 2023 13:35:28 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5E616F8047D for ; Tue, 12 Sep 2023 13:33:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5E616F8047D Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TK7xtGH0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694518387; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tuC69j0YIzIMoK9TblIhKHZnBd1HQmMce3XinY+c08g=; b=TK7xtGH0QFYTPT1avk9ujsoEa9r+VfjZfE9BbuEowOBQpMZP3V8Azo97F4PFGjzVoyPTcX fRfh7wACg7VNe/mv9mqj7aUNAOWwjLB1bMix1rgQgOjN+PtzBzO6dLiykvQ3OWAO1hHhuu zqFRzt2/rBKX+i4ZAnJP/3q6TqAjI0s= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-402-b47a7doIPNinJTxORLK0Fg-1; Tue, 12 Sep 2023 07:33:03 -0400 X-MC-Unique: b47a7doIPNinJTxORLK0Fg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DBDD0181A6E3; Tue, 12 Sep 2023 11:33:02 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.194.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id C39912026D4B; Tue, 12 Sep 2023 11:33:01 +0000 (UTC) From: Hans de Goede To: Oder Chiou , Liam Girdwood , Mark Brown Cc: Hans de Goede , Sameer Pujar , Cezary Rojewski , Pierre-Louis Bossart , alsa-devel@alsa-project.org Subject: [PATCH 5/6] ASoC: rt5640: Fix IRQ not being free-ed for HDA jack detect mode Date: Tue, 12 Sep 2023 13:32:44 +0200 Message-ID: <20230912113245.320159-6-hdegoede@redhat.com> In-Reply-To: <20230912113245.320159-1-hdegoede@redhat.com> References: <20230912113245.320159-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: LZXGQ2MYZZ6R3WNVJLUJF2LDE3VD6DD5 X-Message-ID-Hash: LZXGQ2MYZZ6R3WNVJLUJF2LDE3VD6DD5 X-MailFrom: hdegoede@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Set "rt5640->irq_requested = true" after a successful request_irq() in rt5640_enable_hda_jack_detect(), so that rt5640_disable_jack_detect() properly frees the IRQ. This fixes the IRQ not being freed on rmmod / driver unbind. Fixes: 2b9c8d2b3c89 ("ASoC: rt5640: Add the HDA header support") Cc: Oder Chiou Signed-off-by: Hans de Goede --- sound/soc/codecs/rt5640.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 03c866c04c7a..a4a11407ab10 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -2625,6 +2625,7 @@ static void rt5640_enable_hda_jack_detect( rt5640->jack = NULL; return; } + rt5640->irq_requested = true; /* sync initial jack state */ queue_delayed_work(system_long_wq, &rt5640->jack_work, 0); From patchwork Tue Sep 12 11:32:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13381503 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E063FCA0EC3 for ; Tue, 12 Sep 2023 11:36:32 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E5126EEB; Tue, 12 Sep 2023 13:35:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E5126EEB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694518591; bh=W+ZoDz3IVISlr8l4dEX1tQJJy20XDM5riBwBaLAy7KI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=FmaT9y3njjkors59V52VcWPIJuLMq37LwfNWmdJLMy7s6LJAw3u0t3ToBaPby/XDy ZdLJteo0hIhSHlAODgnY6GDa5+lcSh6pFimpx1cc6phmMzB112uh+6PTPsUNHjpfia /H9VrXrh+sLquMjDnbz5IoI0krrJjTWaKSrk4fg0= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9C4B3F80568; Tue, 12 Sep 2023 13:35:34 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 34CBCF80567; Tue, 12 Sep 2023 13:35:34 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 41EE6F80425; Tue, 12 Sep 2023 13:35:30 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9A0BAF80537 for ; Tue, 12 Sep 2023 13:33:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9A0BAF80537 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZcBHjplw DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694518389; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wziPrUTQEZ53r7QLkQqii7GVp1XqsmQR7RJXjoCnR8I=; b=ZcBHjplwGhHKeEYXI7GcxoWZB3CFDQ/RqDkMC1hCx1Q+KgYNtewK5bRPd9aZy73HLKMGvS pRD2N/usOQ/KzK9ZjLsGzU17oR4dAmwOvqzjAtz+iqoDbVdLYrh9ZOvWVuCfaAaPFS9/9L h0ENm1OGwnvhfMBg+IeR43nRvWu418A= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-494-TB-xh3yLM16MJkfKUay23A-1; Tue, 12 Sep 2023 07:33:04 -0400 X-MC-Unique: TB-xh3yLM16MJkfKUay23A-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 33CB929AB3E3; Tue, 12 Sep 2023 11:33:04 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.194.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18FE82026D4B; Tue, 12 Sep 2023 11:33:02 +0000 (UTC) From: Hans de Goede To: Oder Chiou , Liam Girdwood , Mark Brown Cc: Hans de Goede , Sameer Pujar , Cezary Rojewski , Pierre-Louis Bossart , alsa-devel@alsa-project.org Subject: [PATCH 6/6] ASoC: rt5640: Only cancel jack-detect work on suspend if active Date: Tue, 12 Sep 2023 13:32:45 +0200 Message-ID: <20230912113245.320159-7-hdegoede@redhat.com> In-Reply-To: <20230912113245.320159-1-hdegoede@redhat.com> References: <20230912113245.320159-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: CQNEOO7G2RF4W5LJ4QUTWCBX3MPHQIJS X-Message-ID-Hash: CQNEOO7G2RF4W5LJ4QUTWCBX3MPHQIJS X-MailFrom: hdegoede@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: If jack-detection is not used; or has already been disabled then there is no need to call rt5640_cancel_work(). Move the rt5640_cancel_work() inside the "if (rt5640->jack) {}" block, grouping it together with the disabling of the IRQ which queues the work in the first place. This also makes suspend() symetrical with resume() which re-queues the work in an "if (rt5640->jack) {}" block. Cc: Oder Chiou Signed-off-by: Hans de Goede --- sound/soc/codecs/rt5640.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index a4a11407ab10..e8cdc166bdaa 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -2801,9 +2801,9 @@ static int rt5640_suspend(struct snd_soc_component *component) if (rt5640->jack) { /* disable jack interrupts during system suspend */ disable_irq(rt5640->irq); + rt5640_cancel_work(rt5640); } - rt5640_cancel_work(rt5640); snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); rt5640_reset(component); regcache_cache_only(rt5640->regmap, true);