From patchwork Wed Sep 2 05:19:05 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Chiu X-Patchwork-Id: 2296361 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hZWHs3Rz3z1yB2 for ; Wed, 02 Sep 2026 15:19:36 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1x1dNZ-0006SH-B5; Wed, 02 Sep 2026 05:19:21 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1x1dNX-0006Ry-UX for kernel-team@lists.ubuntu.com; Wed, 02 Sep 2026 05:19:20 +0000 Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id B3BE83F1DA for ; Wed, 2 Sep 2026 05:19:19 +0000 (UTC) Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-cc1b8088202so627140a12.3 for ; Tue, 01 Sep 2026 22:19:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788326358; x=1788931158; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=KxXY4ZiNousVV7aStTi0nRl04jTX1Klj7H1tH2xpZV8=; b=KsBBcwz2XU8gEJu76yBkl6Zo6k5OeZNSWTD599t7rY7TZ8KGAlVl8WZ5P7pulBRUZe mg8hsC0nJ9x9uKnczqKEb75xHTNGhKiamhSczzXv5LtifALF9fdJAFCVkPng24fhP4/T VIo87X2BcKAUJXIWYXMfBpxULa/8fgU0PpjpqgamhEXG9lt0JqwJEsdjU3E+YihlqZcI CvGbIU6lEefPPEDWpQjCKW2i2+QsCTM/3yL0w6fcLbBTgcAJ5/sWXM+bYt3NXhjDXDOI 9BexCUAFz0XXSmgJp75pP7OfzsqgdrY213OKdtWXCDwIFB1SsZ5Bu0TaxS+UDhAGC/IJ oHvg== X-Gm-Message-State: AFuF++mhA71+5rOO3KI+nN/iLm7FPkl7nZ+gGEaEXLb5GFeAR7Lu521i ofCUgAUauw1z6vIB8aqQ7HPUTWr0lkYpeT4zF6hLH6Mxfx07JRrPmj8mU/kovoRbGnY4Eu00wgP tNcIyXNhXz7jtxixPl7gNPKKVTVKulh55fwQkmUx7gK7mNV5vXarKysTIO9Q8aebdeVv2OgraPW cRL6M9XbSCZE8f/w== X-Gm-Gg: AYBFou3125bf6+FU6S0e8fMJjEsxg/evRn8imK9j/ZfXHa+CX0nQYPrE6vLyRIEiNnF v6fhYMYCM33ybgsxrMfTWP7BbLETkmmuX/xQ3KhoQGe95r893VSYUp9ctPd+XWzbm4x6dWRQnHS VU3CrbzLZEKaSop33+sztpyoqiqng43NYrpAWpHoI3HyG75gpg3hXfKjZlGtAOTrPLsk4t11RkM +O9ZsqyTZuXyTguuvzc4mpRzQHkQJDsXcQ7hBo7iwCDPRnMjHx/pb4hcyWAXEg4P6urYHi5au9V htLxbLIJAVEt2tCNbN10CwgWVsCmlBrlYifj/BwArPpKT88dliizvDRp2M39wzlPQARKiFhu3y5 t9YA7/4KWx1IBP8W/+gVR3MBoXQgflIUQM2PqskDevQ== X-Received: by 2002:a17:903:fa6:b0:2d3:7c58:b0e1 with SMTP id d9443c01a7336-2daec43fd56mr38155555ad.0.1788326357879; Tue, 01 Sep 2026 22:19:17 -0700 (PDT) X-Received: by 2002:a17:903:fa6:b0:2d3:7c58:b0e1 with SMTP id d9443c01a7336-2daec43fd56mr38153335ad.0.1788326356136; Tue, 01 Sep 2026 22:19:16 -0700 (PDT) Received: from localhost.. (118-163-61-247.hinet-ip.hinet.net. [118.163.61.247]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2dadd4a794bsm6882215ad.64.2026.09.01.22.19.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 22:19:15 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][R][PATCH v3 1/7] ASoC: SDCA: Rename sdca_irq_allocate() to include devm Date: Wed, 2 Sep 2026 13:19:05 +0800 Message-ID: <20260902051911.3542655-2-chris.chiu@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260902051911.3542655-1-chris.chiu@canonical.com> References: <20260902051911.3542655-1-chris.chiu@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Chiu via kernel-team From: Chris Chiu Reply-To: Chris Chiu Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Charles Keepax BugLink: https://bugs.launchpad.net/bugs/2163215 Make it more clear sdca_irq_allocate() uses devm allocations by adding it into the name. Signed-off-by: Charles Keepax Link: https://patch.msgid.link/20260721143636.361814-2-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown (backported from commit 4ecef577d1ceddaa906720c71c06672433aba318) [ChrisChiu: Conflict in sdca_class.c due to missing regcache_cache_only() line in our branch. Resolved by keeping our context and applying the function rename from sdca_irq_allocate() to devm_sdca_irq_allocate().] Signed-off-by: Chris Chiu --- include/sound/sdca_interrupts.h | 5 +++-- sound/soc/sdca/sdca_class.c | 4 ++-- sound/soc/sdca/sdca_interrupts.c | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/sound/sdca_interrupts.h b/include/sound/sdca_interrupts.h index a515cc3df097..28fd44eb9334 100644 --- a/include/sound/sdca_interrupts.h +++ b/include/sound/sdca_interrupts.h @@ -86,8 +86,9 @@ int sdca_irq_populate(struct sdca_function_data *function, void sdca_irq_cleanup(struct device *dev, struct sdca_function_data *function, struct sdca_interrupt_info *info); -struct sdca_interrupt_info *sdca_irq_allocate(struct device *dev, - struct regmap *regmap, int irq); + +struct sdca_interrupt_info *devm_sdca_irq_allocate(struct device *dev, + struct regmap *regmap, int irq); void sdca_irq_enable_early(struct sdca_function_data *function, struct sdca_interrupt_info *info); diff --git a/sound/soc/sdca/sdca_class.c b/sound/soc/sdca/sdca_class.c index 5def6ae2d99f..3048885ffe3f 100644 --- a/sound/soc/sdca/sdca_class.c +++ b/sound/soc/sdca/sdca_class.c @@ -155,8 +155,8 @@ static void class_boot_work(struct work_struct *work) if (ret) goto err; - drv->irq_info = sdca_irq_allocate(drv->dev, drv->dev_regmap, - drv->sdw->irq); + drv->irq_info = devm_sdca_irq_allocate(drv->dev, drv->dev_regmap, + drv->sdw->irq); if (IS_ERR(drv->irq_info)) goto err; diff --git a/sound/soc/sdca/sdca_interrupts.c b/sound/soc/sdca/sdca_interrupts.c index 5cdabf8ae9da..8a8d0c061053 100644 --- a/sound/soc/sdca/sdca_interrupts.c +++ b/sound/soc/sdca/sdca_interrupts.c @@ -583,7 +583,7 @@ void sdca_irq_cleanup(struct device *dev, EXPORT_SYMBOL_NS_GPL(sdca_irq_cleanup, "SND_SOC_SDCA"); /** - * sdca_irq_allocate - allocate an SDCA interrupt structure for a device + * devm_sdca_irq_allocate - allocate an SDCA interrupt structure for a device * @sdev: Device pointer against which things should be allocated. * @regmap: regmap to be used for accessing the SDCA IRQ registers. * @irq: The interrupt number. @@ -595,8 +595,8 @@ EXPORT_SYMBOL_NS_GPL(sdca_irq_cleanup, "SND_SOC_SDCA"); * Return: A pointer to the allocated sdca_interrupt_info struct, or an * error code. */ -struct sdca_interrupt_info *sdca_irq_allocate(struct device *sdev, - struct regmap *regmap, int irq) +struct sdca_interrupt_info *devm_sdca_irq_allocate(struct device *sdev, + struct regmap *regmap, int irq) { struct sdca_interrupt_info *info; int ret, i; @@ -625,7 +625,7 @@ struct sdca_interrupt_info *sdca_irq_allocate(struct device *sdev, return info; } -EXPORT_SYMBOL_NS_GPL(sdca_irq_allocate, "SND_SOC_SDCA"); +EXPORT_SYMBOL_NS_GPL(devm_sdca_irq_allocate, "SND_SOC_SDCA"); static void irq_enable_flags(struct sdca_function_data *function, struct sdca_interrupt_info *info, bool early) From patchwork Wed Sep 2 05:19:06 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Chiu X-Patchwork-Id: 2296359 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hZWHs3PcLz1y9l for ; Wed, 02 Sep 2026 15:19:36 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1x1dNb-0006UC-Mk; Wed, 02 Sep 2026 05:19:23 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1x1dNZ-0006SD-8m for kernel-team@lists.ubuntu.com; Wed, 02 Sep 2026 05:19:21 +0000 Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 0B3363F1DA for ; Wed, 2 Sep 2026 05:19:21 +0000 (UTC) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-396638f9a18so1193894a91.2 for ; Tue, 01 Sep 2026 22:19:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788326359; x=1788931159; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=fux/ofuOyokb5JTbQNtyMAi3B7zaxgX/reHPq8nnNl8=; b=sopcpKJTcfpLTDcUwi+/WLBdxCAkBh5rV6Eh5/7CRDrwl4Cpb/DSUxiYOfvef6dv13 ZnAWpQjARW8ODTIJVbMvyN7h5dI3OLT0uNISY8dRNvnJBM+0fKYGmQwVvD/V2dakY1rv 3xdkTUMeBhN7R8XK28KUg4vcaI09tUenX6IOA2+9jg+Nu9dzbaiA84EIiMomf0MamEdy uFAtmAnnTNPdygmJ2IOP83WBVnFFpOqqI4vQJINgtLT+/ZS7+sbvjKSsJtMal+Tcj4Fq k9px7mS4+pyF0nmSNMZB8d/eg9bWSCjH9vapRamBTpWqIx8j9YOs2yp5BnRhhg5UFH9w mH8w== X-Gm-Message-State: AFuF++kpyA7CbL+bwHHL9JUVy2FN7BaSrX1FZC5bUAn7c0xw6r1Ep7mz hr7OSoVxGPVAX+9Bi8/MdOPfdcTIBi7fO8q1eTMJqEQLyKa7UXmWri0kNmk5dJAz9yeEQ46+fAh j4U2nlwiuerYBDzGylMFIfASKhA2RnoNjQbAZXHjkM/+QOJP5Z8ey74cf3CiA5njDTqS1sCyHPn JAvVQtg0llSUCivQ== X-Gm-Gg: AYBFou1x2LIhYxnRqAl1ncQVU/YmUVesbNASVZyFQxFnDyTykffHnXhObtjeML0u50s NGCQisQDaRLOUOaANy22soJpqGyWbCkd3zp7U57xsmiM7I2JiZSkeTrjMWF1cB9HaQUlHf722PH GjMWZo4vz/ZGgsQU6c2HyNKBd2xRir/YuV7GK0PmqvEMaSWuPDmuuKXnAzQc8N5uDDlf7p7EYYm dwFPDrfA+NVK5TlJddP1AYrpnxS499uof+8OpOef1NpkxAsAQVB0WNu4feEoDMfV822NYQ0hFT2 QJ6DCPmRf8y6s9PsxvkyEkhYOAb0R2FT+kHCEYP+PaQOFOpiBOjay91WmaGlYTQMrbjVCXc4nwk mFc92Hf3DZ7llkb1FDPBTY2VecErz88/3JdyeTsODGQ== X-Received: by 2002:a17:90a:da8f:b0:398:c8ef:3644 with SMTP id 98e67ed59e1d1-39aee156f4amr3359813a91.15.1788326359222; Tue, 01 Sep 2026 22:19:19 -0700 (PDT) X-Received: by 2002:a17:90a:da8f:b0:398:c8ef:3644 with SMTP id 98e67ed59e1d1-39aee156f4amr3359717a91.15.1788326358617; Tue, 01 Sep 2026 22:19:18 -0700 (PDT) Received: from localhost.. (118-163-61-247.hinet-ip.hinet.net. [118.163.61.247]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2dadd4a794bsm6882215ad.64.2026.09.01.22.19.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 22:19:18 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][R][PATCH v3 2/7] ASoC: SDCA: Add sdca_irq_cleanup_late() Date: Wed, 2 Sep 2026 13:19:06 +0800 Message-ID: <20260902051911.3542655-3-chris.chiu@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260902051911.3542655-1-chris.chiu@canonical.com> References: <20260902051911.3542655-1-chris.chiu@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Chiu via kernel-team From: Chris Chiu Reply-To: Chris Chiu Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Charles Keepax BugLink: https://bugs.launchpad.net/bugs/2163215 The SDCA IRQs are split into two groups, those registered at bus probe time (basically just FDL) and those registered at component time. There currently exists only a single cleanup function, if the FDL IRQ is freed at component time, then nothing would re-register it if the component is probed again. But the IRQs depending on a component need to be freed if the card is destroyed so they can't use stale components. Split the clean up into two functions one for the component level and one for the bus level. Signed-off-by: Charles Keepax Link: https://patch.msgid.link/20260721143636.361814-3-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown (backported from commit f18e97fa7f125e0e7da130b4d0ff1edd48d7510a) [ChrisChiu: Conflict in sdca_interrupts.c due to different doc comment (@sdev vs @dev) and the old sdca_irq_cleanup() function declaration. Resolved by taking the upstream version which replaces the old function with the new static sdca_irq_cleanup_flags() helper. The rest of the changes (early_request flag, new cleanup functions) were already applied.] Signed-off-by: Chris Chiu --- include/sound/sdca_interrupts.h | 5 +++ sound/soc/sdca/sdca_class_function.c | 2 +- sound/soc/sdca/sdca_interrupts.c | 53 ++++++++++++++++++++++------ 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/include/sound/sdca_interrupts.h b/include/sound/sdca_interrupts.h index 28fd44eb9334..38c6c58c2cc7 100644 --- a/include/sound/sdca_interrupts.h +++ b/include/sound/sdca_interrupts.h @@ -33,6 +33,7 @@ struct sdca_function_data; * @priv: Pointer to private data for use by the handler. * @irq: IRQ number allocated to this interrupt, also used internally to track * the IRQ being assigned. + * @early_request: Flag to indicate this IRQ was requested at bus probe time. */ struct sdca_interrupt { const char *name; @@ -48,6 +49,7 @@ struct sdca_interrupt { void *priv; int irq; + bool early_request; }; /** @@ -86,6 +88,9 @@ int sdca_irq_populate(struct sdca_function_data *function, void sdca_irq_cleanup(struct device *dev, struct sdca_function_data *function, struct sdca_interrupt_info *info); +void sdca_irq_cleanup_late(struct device *dev, + struct sdca_function_data *function, + struct sdca_interrupt_info *info); struct sdca_interrupt_info *devm_sdca_irq_allocate(struct device *dev, struct regmap *regmap, int irq); diff --git a/sound/soc/sdca/sdca_class_function.c b/sound/soc/sdca/sdca_class_function.c index 730103120514..2f9bbe6a9b51 100644 --- a/sound/soc/sdca/sdca_class_function.c +++ b/sound/soc/sdca/sdca_class_function.c @@ -415,7 +415,7 @@ static void class_function_remove(struct auxiliary_device *auxdev) { struct class_function_drv *drv = auxiliary_get_drvdata(auxdev); - sdca_irq_cleanup(drv->dev, drv->function, drv->core->irq_info); + sdca_irq_cleanup_late(drv->dev, drv->function, drv->core->irq_info); } static int class_function_runtime_suspend(struct device *dev) diff --git a/sound/soc/sdca/sdca_interrupts.c b/sound/soc/sdca/sdca_interrupts.c index 8a8d0c061053..6ff0a0a12755 100644 --- a/sound/soc/sdca/sdca_interrupts.c +++ b/sound/soc/sdca/sdca_interrupts.c @@ -447,6 +447,8 @@ int sdca_irq_populate_early(struct device *dev, struct regmap *regmap, if (ret) return ret; + interrupt->early_request = true; + ret = sdca_fdl_alloc_state(interrupt); if (ret) return ret; @@ -553,17 +555,10 @@ int sdca_irq_populate(struct sdca_function_data *function, } EXPORT_SYMBOL_NS_GPL(sdca_irq_populate, "SND_SOC_SDCA"); -/** - * sdca_irq_cleanup - Free all the individual IRQs for an SDCA Function - * @sdev: Device pointer against which the sdca_interrupt_info was allocated. - * @function: Pointer to the SDCA Function. - * @info: Pointer to the SDCA interrupt info for this device. - * - * Typically this would be called from the driver for a single SDCA Function. - */ -void sdca_irq_cleanup(struct device *dev, - struct sdca_function_data *function, - struct sdca_interrupt_info *info) +static void sdca_irq_cleanup_flags(struct device *dev, + struct sdca_function_data *function, + struct sdca_interrupt_info *info, + bool late_cleanup) { int i; @@ -575,13 +570,49 @@ void sdca_irq_cleanup(struct device *dev, if (interrupt->function != function || !interrupt->irq) continue; + if (interrupt->early_request && !late_cleanup) + continue; + sdca_irq_free_locked(dev, info, i, interrupt->name, interrupt); kfree(interrupt->name); } } + +/** + * sdca_irq_cleanup - Free the regular IRQs for an SDCA Function + * @dev: Device pointer against which the sdca_interrupt_info was allocated. + * @function: Pointer to the SDCA Function. + * @info: Pointer to the SDCA interrupt info for this device. + * + * Typically this would be called from the driver for a single SDCA Function + * from component remove. + */ +void sdca_irq_cleanup(struct device *dev, + struct sdca_function_data *function, + struct sdca_interrupt_info *info) +{ + sdca_irq_cleanup_flags(dev, function, info, false); +} EXPORT_SYMBOL_NS_GPL(sdca_irq_cleanup, "SND_SOC_SDCA"); +/** + * sdca_irq_cleanup_late - Free the early IRQs for an SDCA Function + * @dev: Device pointer against which the sdca_interrupt_info was allocated. + * @function: Pointer to the SDCA Function. + * @info: Pointer to the SDCA interrupt info for this device. + * + * Typically this would be called from the driver for a single SDCA Function + * from bus remove. + */ +void sdca_irq_cleanup_late(struct device *dev, + struct sdca_function_data *function, + struct sdca_interrupt_info *info) +{ + sdca_irq_cleanup_flags(dev, function, info, true); +} +EXPORT_SYMBOL_NS_GPL(sdca_irq_cleanup_late, "SND_SOC_SDCA"); + /** * devm_sdca_irq_allocate - allocate an SDCA interrupt structure for a device * @sdev: Device pointer against which things should be allocated. From patchwork Wed Sep 2 05:19:07 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Chiu X-Patchwork-Id: 2296362 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hZWHs2GYKz1xy9 for ; Wed, 02 Sep 2026 15:19:36 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1x1dNc-0006UR-2P; Wed, 02 Sep 2026 05:19:24 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1x1dNa-0006Sc-8o for kernel-team@lists.ubuntu.com; Wed, 02 Sep 2026 05:19:22 +0000 Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 10E463F1DA for ; Wed, 2 Sep 2026 05:19:22 +0000 (UTC) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2cfca8558d2so8436145ad.2 for ; Tue, 01 Sep 2026 22:19:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788326360; x=1788931160; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=RLNTRlMcrT3opGkTWzy0F2+0f22eLDsusiS8hS/xHcs=; b=bG/A7GOyG/B3JcPmwrb2DDx3hqhTCpIJ+tL64LQBlUxeffHpBRHrIyz4CfGsYtHXVj HT3sIveC+OjVd15LMfcU+Cs2F2wmH7mK/UgclDFcMrd3A5b4sPH+qwkU17j9tG5Ijnhi zF9Rx7GR/3ASQk53yiuyjcaN4rI6UaZgTIxV4rFx4yayLSSxkZNWAWR8GFcCh1m5CH6S WHP0uP0UkG4BSW5F7WRA64iRvrkQmm3ZW1bGyGcrzrnRsZOpE8OxaQakW7kYwwBMf0Le W3FIzLcHcjXSGm64zrR6hSX2jYAW8Jq1583hn14T41H4QDZwfswQRgy2UwaqwO+MsR9M ElYQ== X-Gm-Message-State: AFuF++nnbWyB8H2K1uTT/z2gHkf3+9tzuWG2JbJa9DDtgd7F65yPlm0d jRrJxbP+nXfcvE1ZfwAhbEoUNl90ERX1VQRjarh/eW7auECJ2nZ7yhdsUnzPCbVoci8GSW6aRS6 1FFXi+pZHW+JK9VUkpvJTSpTJqdCTlFh60UFKfJj7xRjL1yiBef7UdQis/UXyNBuK8yHIdoBs1v sW4+Om1HV7ygObzg== X-Gm-Gg: AYBFou3F9gFghodRaHeuupFkunokKxzgrWKoykqUlzwUtbpH6NsY7CJoebZ3xmhuKr+ J/UBIQHyY1joGItbrQvVKXu+Z46V1Dt6xhHl0gIs9EUKM4zIlhgQFbFF3ijFSno/oSRQdZ2sOfz MA9ELREz9JLOG56tRPtRe8WIwN1tR3mS69uyaoJtgM6VJn/B+jm/OAEEbxRI+2dHlWWFHGrhOZj 8uNO7xGqH0ONBpvSy8dYa5RYl8QwTNwQ2WxDh72ul3hmaIT/AQDlMs5X830gcqxRPhFtCLn2Sa1 JYPMGug2zZRWX9+TQDyA/z38QTsbhOOM/kQ/jxcCkfywZiPSmOVxANzDY1wSOUSqzPK0Fabk9iX FFo3AbOXlKawItldvfycKGtr4oc9M1cHI/65uRsu9Dg== X-Received: by 2002:a17:903:9cc:b0:2da:ef81:37e7 with SMTP id d9443c01a7336-2daef813b09mr19978195ad.21.1788326360378; Tue, 01 Sep 2026 22:19:20 -0700 (PDT) X-Received: by 2002:a17:903:9cc:b0:2da:ef81:37e7 with SMTP id d9443c01a7336-2daef813b09mr19977825ad.21.1788326359865; Tue, 01 Sep 2026 22:19:19 -0700 (PDT) Received: from localhost.. (118-163-61-247.hinet-ip.hinet.net. [118.163.61.247]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2dadd4a794bsm6882215ad.64.2026.09.01.22.19.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 22:19:19 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][R][PATCH v3 3/7] ASoC: SDCA: Remove devm from primary IRQ cleanup Date: Wed, 2 Sep 2026 13:19:07 +0800 Message-ID: <20260902051911.3542655-4-chris.chiu@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260902051911.3542655-1-chris.chiu@canonical.com> References: <20260902051911.3542655-1-chris.chiu@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Chiu via kernel-team From: Chris Chiu Reply-To: Chris Chiu Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Charles Keepax BugLink: https://bugs.launchpad.net/bugs/2163215 To provide greater flexibility on when the IRQs are requested for client drivers don't use devm for the primary IRQ request/cleanup helper functions. Signed-off-by: Charles Keepax Link: https://patch.msgid.link/20260721143636.361814-4-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown (backported from commit 0880082c27b6251cc3fea307dffa6899ad163e8b) [ChrisChiu: Conflict in sdca_jack.c due to missing sdca_jack_free_state() function in our branch. Resolved by adding the new sdca_jack_free_state() function before the type_get_mask() function as the upstream intended.] Signed-off-by: Chris Chiu --- include/sound/sdca_fdl.h | 2 ++ include/sound/sdca_interrupts.h | 2 ++ include/sound/sdca_jack.h | 2 ++ sound/soc/sdca/sdca_fdl.c | 13 +++++++++-- sound/soc/sdca/sdca_interrupts.c | 8 +++++++ sound/soc/sdca/sdca_jack.c | 39 ++++++++++++++++++++++++++++++-- 6 files changed, 62 insertions(+), 4 deletions(-) diff --git a/include/sound/sdca_fdl.h b/include/sound/sdca_fdl.h index fbaf4b384c8a..dc33927b82bd 100644 --- a/include/sound/sdca_fdl.h +++ b/include/sound/sdca_fdl.h @@ -67,6 +67,8 @@ struct fdl_state { #if IS_ENABLED(CONFIG_SND_SOC_SDCA_FDL) int sdca_fdl_alloc_state(struct sdca_interrupt *interrupt); +void sdca_fdl_free_state(struct sdca_interrupt *interrupt); + int sdca_fdl_process(struct sdca_interrupt *interrupt); int sdca_fdl_sync(struct device *dev, struct sdca_function_data *function, struct sdca_interrupt_info *info); diff --git a/include/sound/sdca_interrupts.h b/include/sound/sdca_interrupts.h index 38c6c58c2cc7..8a44c19e917c 100644 --- a/include/sound/sdca_interrupts.h +++ b/include/sound/sdca_interrupts.h @@ -31,6 +31,7 @@ struct sdca_function_data; * @entity: Pointer to the Entity that the interrupt is associated with. * @control: Pointer to the Control that the interrupt is associated with. * @priv: Pointer to private data for use by the handler. + * @free_priv: Pointer to a function that can be used to free the priv data. * @irq: IRQ number allocated to this interrupt, also used internally to track * the IRQ being assigned. * @early_request: Flag to indicate this IRQ was requested at bus probe time. @@ -47,6 +48,7 @@ struct sdca_interrupt { struct sdca_control *control; void *priv; + void (*free_priv)(struct sdca_interrupt *interrupt); int irq; bool early_request; diff --git a/include/sound/sdca_jack.h b/include/sound/sdca_jack.h index 3ec22046d3eb..8624c51eea26 100644 --- a/include/sound/sdca_jack.h +++ b/include/sound/sdca_jack.h @@ -25,6 +25,8 @@ struct jack_state { }; int sdca_jack_alloc_state(struct sdca_interrupt *interrupt); +void sdca_jack_free_state(struct sdca_interrupt *interrupt); + int sdca_jack_process(struct sdca_interrupt *interrupt); int sdca_jack_set_jack(struct sdca_interrupt_info *info, struct snd_soc_jack *jack); int sdca_jack_report(struct sdca_interrupt *interrupt); diff --git a/sound/soc/sdca/sdca_fdl.c b/sound/soc/sdca/sdca_fdl.c index 994821a6df61..82e09d960c12 100644 --- a/sound/soc/sdca/sdca_fdl.c +++ b/sound/soc/sdca/sdca_fdl.c @@ -481,10 +481,9 @@ EXPORT_SYMBOL_NS_GPL(sdca_fdl_process, "SND_SOC_SDCA"); */ int sdca_fdl_alloc_state(struct sdca_interrupt *interrupt) { - struct device *dev = interrupt->dev; struct fdl_state *fdl_state; - fdl_state = devm_kzalloc(dev, sizeof(*fdl_state), GFP_KERNEL); + fdl_state = kzalloc_obj(*fdl_state); if (!fdl_state) return -ENOMEM; @@ -499,3 +498,13 @@ int sdca_fdl_alloc_state(struct sdca_interrupt *interrupt) return 0; } EXPORT_SYMBOL_NS_GPL(sdca_fdl_alloc_state, "SND_SOC_SDCA"); + +/** + * sdca_fdl_free_state - free state for an FDL interrupt + * @interrupt: SDCA interrupt structure. + */ +void sdca_fdl_free_state(struct sdca_interrupt *interrupt) +{ + kfree(interrupt->priv); +} +EXPORT_SYMBOL_NS_GPL(sdca_fdl_free_state, "SND_SOC_SDCA"); diff --git a/sound/soc/sdca/sdca_interrupts.c b/sound/soc/sdca/sdca_interrupts.c index 6ff0a0a12755..0e721306f3cf 100644 --- a/sound/soc/sdca/sdca_interrupts.c +++ b/sound/soc/sdca/sdca_interrupts.c @@ -448,6 +448,7 @@ int sdca_irq_populate_early(struct device *dev, struct regmap *regmap, return ret; interrupt->early_request = true; + interrupt->free_priv = sdca_fdl_free_state; ret = sdca_fdl_alloc_state(interrupt); if (ret) @@ -521,6 +522,8 @@ int sdca_irq_populate(struct sdca_function_data *function, handler = function_status_handler; break; case SDCA_CTL_TYPE_S(GE, DETECTED_MODE): + interrupt->free_priv = sdca_jack_free_state; + ret = sdca_jack_alloc_state(interrupt); if (ret) return ret; @@ -528,6 +531,8 @@ int sdca_irq_populate(struct sdca_function_data *function, handler = detected_mode_handler; break; case SDCA_CTL_TYPE_S(XU, FDL_CURRENTOWNER): + interrupt->free_priv = sdca_fdl_free_state; + ret = sdca_fdl_alloc_state(interrupt); if (ret) return ret; @@ -575,6 +580,9 @@ static void sdca_irq_cleanup_flags(struct device *dev, sdca_irq_free_locked(dev, info, i, interrupt->name, interrupt); + if (interrupt->free_priv) + interrupt->free_priv(interrupt); + kfree(interrupt->name); } } diff --git a/sound/soc/sdca/sdca_jack.c b/sound/soc/sdca/sdca_jack.c index 49d317d3b8c8..f2494c94ca33 100644 --- a/sound/soc/sdca/sdca_jack.c +++ b/sound/soc/sdca/sdca_jack.c @@ -132,10 +132,9 @@ EXPORT_SYMBOL_NS_GPL(sdca_jack_process, "SND_SOC_SDCA"); */ int sdca_jack_alloc_state(struct sdca_interrupt *interrupt) { - struct device *dev = interrupt->dev; struct jack_state *jack_state; - jack_state = devm_kzalloc(dev, sizeof(*jack_state), GFP_KERNEL); + jack_state = kzalloc_obj(*jack_state); if (!jack_state) return -ENOMEM; @@ -145,6 +144,42 @@ int sdca_jack_alloc_state(struct sdca_interrupt *interrupt) } EXPORT_SYMBOL_NS_GPL(sdca_jack_alloc_state, "SND_SOC_SDCA"); +/** + * sdca_jack_free_state - free state for a jack interrupt + * @interrupt: SDCA interrupt structure. + */ +void sdca_jack_free_state(struct sdca_interrupt *interrupt) +{ + kfree(interrupt->priv); +} +EXPORT_SYMBOL_NS_GPL(sdca_jack_free_state, "SND_SOC_SDCA"); + +static int type_get_mask(enum sdca_terminal_type type) +{ + switch (type) { + case SDCA_TERM_TYPE_LINEIN_STEREO: + case SDCA_TERM_TYPE_LINEIN_FRONT_LR: + case SDCA_TERM_TYPE_LINEIN_CENTER_LFE: + case SDCA_TERM_TYPE_LINEIN_SURROUND_LR: + case SDCA_TERM_TYPE_LINEIN_REAR_LR: + return SND_JACK_LINEIN; + case SDCA_TERM_TYPE_LINEOUT_STEREO: + case SDCA_TERM_TYPE_LINEOUT_FRONT_LR: + case SDCA_TERM_TYPE_LINEOUT_CENTER_LFE: + case SDCA_TERM_TYPE_LINEOUT_SURROUND_LR: + case SDCA_TERM_TYPE_LINEOUT_REAR_LR: + return SND_JACK_LINEOUT; + case SDCA_TERM_TYPE_MIC_JACK: + return SND_JACK_MICROPHONE; + case SDCA_TERM_TYPE_HEADPHONE_JACK: + return SND_JACK_HEADPHONE; + case SDCA_TERM_TYPE_HEADSET_JACK: + return SND_JACK_HEADSET; + default: + return 0; + } +} + /** * sdca_jack_set_jack - attach an ASoC jack to SDCA * @info: SDCA interrupt information. From patchwork Wed Sep 2 05:19:08 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Chiu X-Patchwork-Id: 2296364 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hZWHs6dLmz1yb9 for ; Wed, 02 Sep 2026 15:19:37 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1x1dNc-0006Uh-FG; Wed, 02 Sep 2026 05:19:24 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1x1dNb-0006Tx-8R for kernel-team@lists.ubuntu.com; Wed, 02 Sep 2026 05:19:23 +0000 Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 1814E3F1DA for ; Wed, 2 Sep 2026 05:19:23 +0000 (UTC) Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-cc1cade6b71so647870a12.0 for ; Tue, 01 Sep 2026 22:19:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788326361; x=1788931161; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=UbWd+csa40v1dN32UIJarCEihHE5cYM4K4O7XZk3Wp4=; b=g9Az8GaySf5faAl7Pm44CwuawCCdBhhp5Uvw2DCdvEl3wUlm9zfCNV9qHGIwulUSRY yXwldEuIEzWc59j2knfw9PCDeKG3kFUYVqdKT7g0Bye3JXzOehZL6T6HCBXeJROIMjNA O28KroPyExoDRfoStjOJYoZlbq9HWIP5CAkQIAcqtVrhtdyaO3jRehk9gK6SRviChL9W rtwxGLTCvykEJ3NPO3aW6e2+5OY0pDZYvx4kEOPZfijXo0R7m19vArh0Fd4QzTBQ07IJ 4M1/HD5L47ZH440SERSA8CxNkjyFWpsmoIR1Tbuuvfc/YpmdDE8BNbBIRPzcXjkRqATZ 8rRw== X-Gm-Message-State: AFuF++lEpEdzYaR+6GyAchVnMGU9ksB7cSg/s6JCTO41ekuAGIXZqDMm T5U0u9kF0ejakf0iOnA0tsHNckDKZf2uKY/EU5mFTYBuC5B71U433/O5igEXlVrbgv5uovHpiqB jQZ6i8v4PjI2M994h+9GzjyC4cwhPT0h33y1uQcrm2P7eF9paAcs1hbkuwMYY6CPkY6qmpTccIU vxw1LAvGqa6kSh/g== X-Gm-Gg: AR+sD11XtSCfjYl3SzqMY4yAE3FDAkYxqr5Dnc3yxgaO5mJvN3YZfjkFQISM4VaDpXH iXg4Bm4P5POFl0ozCpqLZekc2UuPnMd/LYX/qEREYCC95lwRzqppldL+Yxj5Fg9z5wsv2twFYt9 Nr6geA2q7BrYLTqIa9zvq51iLegUskuTzZ5PiTWnS/ADw86lKCiPvSUYBxg/TntdfHctN3JzAgj Uk87KDwlPaKA5R4YVqD1UMXgdcgR9CzZSCDVPBogv9su2zbo6PB/QSQtbHsqm+X0jOC8CcsaRQx H3JSg0sqcBMKFG4tMr0n5GOhH7WO8OifHjfoJwCd+2+GRjueusXOzYhYItxSI74S0SulwW34UZR vmYqWcOUVXlc9la3SKwqLNnxW4CVN8MkEjIx9q/pBCw== X-Received: by 2002:a17:903:948:b0:2ca:12aa:a390 with SMTP id d9443c01a7336-2daf1100c52mr6006485ad.0.1788326361517; Tue, 01 Sep 2026 22:19:21 -0700 (PDT) X-Received: by 2002:a17:903:948:b0:2ca:12aa:a390 with SMTP id d9443c01a7336-2daf1100c52mr6006185ad.0.1788326361130; Tue, 01 Sep 2026 22:19:21 -0700 (PDT) Received: from localhost.. (118-163-61-247.hinet-ip.hinet.net. [118.163.61.247]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2dadd4a794bsm6882215ad.64.2026.09.01.22.19.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 22:19:20 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][R][PATCH v3 4/7] ASoC: SDCA: Populate IRQ data earlier Date: Wed, 2 Sep 2026 13:19:08 +0800 Message-ID: <20260902051911.3542655-5-chris.chiu@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260902051911.3542655-1-chris.chiu@canonical.com> References: <20260902051911.3542655-1-chris.chiu@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Chiu via kernel-team From: Chris Chiu Reply-To: Chris Chiu Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Charles Keepax BugLink: https://bugs.launchpad.net/bugs/2163215 Currently, the IRQ data (attached Entity/Control/etc) is populated as the IRQ is requested. However, this can cause issues as occasionally the setup process wants to access specifics of an IRQ before the IRQ is actually enabled. To facilitate this cache all the IRQ data during sdca_irq_populate_early() and make sdca_irq_populate() simply request the outstanding IRQs. This also has the advantage that sdca_irq_populate() can now just iterate through the IRQ array which is much smaller/faster than going through every Entity in the Function for Controls. Signed-off-by: Charles Keepax Link: https://patch.msgid.link/20260721143636.361814-5-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown (cherry picked from commit 050406cbd676615ba71081bce69df710754d27e4) Signed-off-by: Chris Chiu --- include/sound/sdca_interrupts.h | 2 + sound/soc/sdca/sdca_interrupts.c | 115 ++++++++++++------------------- 2 files changed, 47 insertions(+), 70 deletions(-) diff --git a/include/sound/sdca_interrupts.h b/include/sound/sdca_interrupts.h index 8a44c19e917c..3b30146e21db 100644 --- a/include/sound/sdca_interrupts.h +++ b/include/sound/sdca_interrupts.h @@ -30,6 +30,7 @@ struct sdca_function_data; * @function: Pointer to the Function that the interrupt is associated with. * @entity: Pointer to the Entity that the interrupt is associated with. * @control: Pointer to the Control that the interrupt is associated with. + * @handler: Handler function to be called for the IRQ. * @priv: Pointer to private data for use by the handler. * @free_priv: Pointer to a function that can be used to free the priv data. * @irq: IRQ number allocated to this interrupt, also used internally to track @@ -46,6 +47,7 @@ struct sdca_interrupt { struct sdca_function_data *function; struct sdca_entity *entity; struct sdca_control *control; + irq_handler_t handler; void *priv; void (*free_priv)(struct sdca_interrupt *interrupt); diff --git a/sound/soc/sdca/sdca_interrupts.c b/sound/soc/sdca/sdca_interrupts.c index 0e721306f3cf..79a17d827f99 100644 --- a/sound/soc/sdca/sdca_interrupts.c +++ b/sound/soc/sdca/sdca_interrupts.c @@ -412,7 +412,8 @@ static struct sdca_interrupt *get_interrupt_data(struct device *dev, int irq, * * This is intended to be used as part of the Function boot process. It * can be called before the soundcard is registered (ie. doesn't depend - * on component) and will register the FDL interrupts. + * on component) and will populate all the required IRQ data, as well as + * registering the FDL interrupts to start booting the device. * * Return: Zero on success, and a negative error code on failure. */ @@ -439,24 +440,36 @@ int sdca_irq_populate_early(struct device *dev, struct regmap *regmap, else if (!interrupt) continue; + ret = sdca_irq_data_populate(dev, regmap, NULL, function, + entity, control, interrupt); + if (ret) + return ret; + switch (SDCA_CTL_TYPE(entity->type, control->sel)) { - case SDCA_CTL_TYPE_S(XU, FDL_CURRENTOWNER): - ret = sdca_irq_data_populate(dev, regmap, NULL, - function, entity, - control, interrupt); + case SDCA_CTL_TYPE_S(ENTITY_0, FUNCTION_STATUS): + interrupt->handler = function_status_handler; + break; + case SDCA_CTL_TYPE_S(GE, DETECTED_MODE): + interrupt->handler = detected_mode_handler; + interrupt->free_priv = sdca_jack_free_state; + + ret = sdca_jack_alloc_state(interrupt); if (ret) return ret; - - interrupt->early_request = true; + break; + case SDCA_CTL_TYPE_S(XU, FDL_CURRENTOWNER): + interrupt->handler = fdl_owner_handler; interrupt->free_priv = sdca_fdl_free_state; ret = sdca_fdl_alloc_state(interrupt); if (ret) return ret; + interrupt->early_request = true; + ret = sdca_irq_request_locked(dev, info, irq, interrupt->name, - fdl_owner_handler, + interrupt->handler, interrupt); if (ret) { dev_err(dev, "failed to request irq %s: %d\n", @@ -464,7 +477,11 @@ int sdca_irq_populate_early(struct device *dev, struct regmap *regmap, return ret; } break; + case SDCA_CTL_TYPE_S(HIDE, HIDTX_CURRENTOWNER): + interrupt->handler = hid_handler; + break; default: + interrupt->handler = base_handler; break; } } @@ -489,70 +506,26 @@ int sdca_irq_populate(struct sdca_function_data *function, struct sdca_interrupt_info *info) { struct device *dev = component->dev; - int i, j; + int i, ret; guard(mutex)(&info->irq_lock); - for (i = 0; i < function->num_entities; i++) { - struct sdca_entity *entity = &function->entities[i]; - - for (j = 0; j < entity->num_controls; j++) { - struct sdca_control *control = &entity->controls[j]; - int irq = control->interrupt_position; - struct sdca_interrupt *interrupt; - irq_handler_t handler; - int ret; - - interrupt = get_interrupt_data(dev, irq, info); - if (IS_ERR(interrupt)) - return PTR_ERR(interrupt); - else if (!interrupt) - continue; - - ret = sdca_irq_data_populate(dev, NULL, component, - function, entity, control, - interrupt); - if (ret) - return ret; - - handler = base_handler; - - switch (SDCA_CTL_TYPE(entity->type, control->sel)) { - case SDCA_CTL_TYPE_S(ENTITY_0, FUNCTION_STATUS): - handler = function_status_handler; - break; - case SDCA_CTL_TYPE_S(GE, DETECTED_MODE): - interrupt->free_priv = sdca_jack_free_state; - - ret = sdca_jack_alloc_state(interrupt); - if (ret) - return ret; - - handler = detected_mode_handler; - break; - case SDCA_CTL_TYPE_S(XU, FDL_CURRENTOWNER): - interrupt->free_priv = sdca_fdl_free_state; + for (i = 0; i < SDCA_MAX_INTERRUPTS; i++) { + struct sdca_interrupt *interrupt = &info->irqs[i]; + int irq; - ret = sdca_fdl_alloc_state(interrupt); - if (ret) - return ret; + if (interrupt->function != function || interrupt->irq) + continue; - handler = fdl_owner_handler; - break; - case SDCA_CTL_TYPE_S(HIDE, HIDTX_CURRENTOWNER): - handler = hid_handler; - break; - default: - break; - } + interrupt->component = component; - ret = sdca_irq_request_locked(dev, info, irq, interrupt->name, - handler, interrupt); - if (ret) { - dev_err(dev, "failed to request irq %s: %d\n", - interrupt->name, ret); - return ret; - } + irq = interrupt->control->interrupt_position; + ret = sdca_irq_request_locked(dev, info, irq, interrupt->name, + interrupt->handler, interrupt); + if (ret) { + dev_err(dev, "failed to request irq %s: %d\n", + interrupt->name, ret); + return ret; } } @@ -572,13 +545,15 @@ static void sdca_irq_cleanup_flags(struct device *dev, for (i = 0; i < SDCA_MAX_INTERRUPTS; i++) { struct sdca_interrupt *interrupt = &info->irqs[i]; - if (interrupt->function != function || !interrupt->irq) + if (interrupt->function != function || + (interrupt->early_request && !late_cleanup)) continue; - if (interrupt->early_request && !late_cleanup) - continue; + if (interrupt->irq) + sdca_irq_free_locked(dev, info, i, interrupt->name, interrupt); - sdca_irq_free_locked(dev, info, i, interrupt->name, interrupt); + if (!late_cleanup) + continue; if (interrupt->free_priv) interrupt->free_priv(interrupt); From patchwork Wed Sep 2 05:19:09 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Chiu X-Patchwork-Id: 2296357 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hZWHs2KDfz1y1C for ; Wed, 02 Sep 2026 15:19:36 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1x1dNf-0006Xt-5P; Wed, 02 Sep 2026 05:19:27 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1x1dNc-0006Uo-Hn for kernel-team@lists.ubuntu.com; Wed, 02 Sep 2026 05:19:24 +0000 Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 6010D3F1DA for ; Wed, 2 Sep 2026 05:19:24 +0000 (UTC) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2d94f086fedso8225245ad.1 for ; Tue, 01 Sep 2026 22:19:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788326363; x=1788931163; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=MHsxF+pJVW9LTnadfClcxpO69G8/wnKh0iT0F82Tusw=; b=mvDbJ9qD4b3FM3Cy8fcOqJSdJc2mRbHBtXXc40kePWfW8LoVvBBOm/leN9yE/GSQKN XrwjoYAN5NxRSx2PN2mJCO/Cdi8MHpbg20NICb4zk47KfQq18ybzj0YGRKsymSAvsXoj Sy6wpeTDFg1mr5RdaP9AL7jGtQbZVJI6/twVdQ3ajlfWjbeGQl8C2HIX2MOpRVLYiOgv CTymiXLKSesFsryiZrtAJYbd8mzAzIQY0daZmd+43bebAQzfOzGh8/1HPYM9NsS0FKdU 0dAEI+WeSTWno2pyNKgrHNtWsa/9ms9bdhSoiKsFwGV77GSDNSmEP8L2ALyH2BtX06Jg H8Xg== X-Gm-Message-State: AFuF++k937g9lfFA/+QuEupX4urSseLDJ4nE9l4oX5B1THBbkN5oVv7A EPGdeGrxrxnzxeHcSKktTxc91AKrhdmweOgUkuxKnsvZcjGxhilcW4iqG4CHx1pPQ7XOzoWUdm8 BQ7M7Q3TpEfMlruKlVokpNcqJu8fiEvpkIO6m9resagJNPQ9lBGmuvMpc9agY+OrDzd1LECJJLh +clkskEf6vpr5HTA== X-Gm-Gg: AYBFou1iMxrnyfxzFECpvkyFkzB0Bq0X/qvPbzVUQkuJ+3x+f1CQv5Z07sK+A5g9/Vy LdfLiWeEsn78n7G84Le0+4xU0hIYY+HmikX67MkRYlcfEVYKtomYc6fF2GnUgd/JwIm6ZLmpFuz 2JWzaBoQ9k3E0vaFSbP9VY5sm1U9N4lJeIRcElfZONGGx6ORqO3u15blQEpavqK2gYs1mJFuQSV YzSlLLwGWPbkfqrooHpmwv3KdvnaK4PEKegsVju4cZO/c/9d6DCL3mIASVP8IByPoTw/dt77eyj iPLx2eMdlhuRfdXFA+ZStKO5LNgluTl6DRrBh2fZjemN3B8qQXW9qxOmjGyDCfehCeDW9v7gtUq kBB6E5ZE0wUsulqZH4Wgg3pXvJNzx2BLg5nbS2T+Uxg== X-Received: by 2002:a17:903:1b0b:b0:2da:e67a:87d4 with SMTP id d9443c01a7336-2daec771bfcmr34683905ad.19.1788326362826; Tue, 01 Sep 2026 22:19:22 -0700 (PDT) X-Received: by 2002:a17:903:1b0b:b0:2da:e67a:87d4 with SMTP id d9443c01a7336-2daec771bfcmr34683355ad.19.1788326362288; Tue, 01 Sep 2026 22:19:22 -0700 (PDT) Received: from localhost.. (118-163-61-247.hinet-ip.hinet.net. [118.163.61.247]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2dadd4a794bsm6882215ad.64.2026.09.01.22.19.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 22:19:21 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][R][PATCH v3 5/7] ASoC: Add a component fixup_controls callback Date: Wed, 2 Sep 2026 13:19:09 +0800 Message-ID: <20260902051911.3542655-6-chris.chiu@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260902051911.3542655-1-chris.chiu@canonical.com> References: <20260902051911.3542655-1-chris.chiu@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Chiu via kernel-team From: Chris Chiu Reply-To: Chris Chiu Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Charles Keepax BugLink: https://bugs.launchpad.net/bugs/2163215 A card level fixup_controls callback was added in: commit df4d27b19b89 ("ASoC: Introduce 'fixup_controls' card method") This allowed the machine driver to take actions after all the card controls have been added. However, there are times when a codec driver would also want to do things like obtain references to controls for later use, which require all the controls to be present. Add a component level fixup_controls callback, echoing the card level option. Signed-off-by: Charles Keepax Link: https://patch.msgid.link/20260721143636.361814-6-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown (cherry picked from commit 3e81e2fb216327a73510a7aa5318023c379d479a) Signed-off-by: Chris Chiu --- include/sound/soc-component.h | 2 ++ sound/soc/soc-component.c | 10 ++++++++++ sound/soc/soc-core.c | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 0435ba376369..972d0475b355 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -76,6 +76,7 @@ struct snd_soc_component_driver { unsigned int num_dapm_routes; int (*probe)(struct snd_soc_component *component); + int (*fixup_controls)(struct snd_soc_component *component); void (*remove)(struct snd_soc_component *component); int (*suspend)(struct snd_soc_component *component); int (*resume)(struct snd_soc_component *component); @@ -384,6 +385,7 @@ void snd_soc_component_suspend(struct snd_soc_component *component); void snd_soc_component_resume(struct snd_soc_component *component); int snd_soc_component_is_suspended(struct snd_soc_component *component); int snd_soc_component_probe(struct snd_soc_component *component); +int snd_soc_component_fixup_controls(struct snd_soc_component *component); void snd_soc_component_remove(struct snd_soc_component *component); int snd_soc_component_of_xlate_dai_id(struct snd_soc_component *component, struct device_node *ep); diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 77ad33383974..7fa4b1bc10ed 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -310,6 +310,16 @@ int snd_soc_component_probe(struct snd_soc_component *component) return soc_component_ret(component, ret); } +int snd_soc_component_fixup_controls(struct snd_soc_component *component) +{ + int ret = 0; + + if (component->driver->fixup_controls) + ret = component->driver->fixup_controls(component); + + return soc_component_ret(component, ret); +} + void snd_soc_component_remove(struct snd_soc_component *component) { if (component->driver->remove) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 054bdd642ac5..21ddd7540864 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2306,6 +2306,11 @@ static int snd_soc_bind_card(struct snd_soc_card *card) goto probe_end; snd_soc_dapm_new_widgets(card); + for_each_card_components(card, component) { + ret = snd_soc_component_fixup_controls(component); + if (ret < 0) + goto probe_end; + } snd_soc_card_fixup_controls(card); ret = snd_card_register(card->snd_card); From patchwork Wed Sep 2 05:19:10 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Chiu X-Patchwork-Id: 2296360 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hZWHs3MPVz1y1M for ; Wed, 02 Sep 2026 15:19:36 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1x1dNf-0006Y6-Cu; Wed, 02 Sep 2026 05:19:27 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1x1dNd-0006Vx-N5 for kernel-team@lists.ubuntu.com; Wed, 02 Sep 2026 05:19:25 +0000 Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 7EFC03F167 for ; Wed, 2 Sep 2026 05:19:25 +0000 (UTC) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2d6f73d0f89so8603665ad.0 for ; Tue, 01 Sep 2026 22:19:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788326364; x=1788931164; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=1hMY8rc9jzzd4lOB++zJKzTMXm7S/UwCuTNZdWgHglU=; b=kVEsz16axo9TYLnZKB2965fUkmP+q9s9iI1OS8+I1rhr4FnaR28ZHnvqtRMbTx+P7d 0Peq8nE/C+36+RsBNU7TyFH3trHVUjMpb9UdFr+rLTydWosVT8YMQOrzJW9BSRliU+/b wVgCc0klz0JQUBhJKWaDIdWKgxyXiRXE+f7kXe6Q+UZwNza1f911M873/mlvGr9p3Lgx O16BBySET36aN8zWDGrikGM8IksT8hmCogP2wUlmjn4oKk3Erd1FZii484eG4CefU3qw OaieQqqNHT0S3QGSatxqx3M43hR92D/C0UCD6A87yQETbGImDEm5cIV/nGe+svQrLd/2 G59Q== X-Gm-Message-State: AFuF++kC1MqhxvRoW0ANVy9lzMf/bwwMQFHfE3FW1ZJlzo1gG7ejzm/y jxm6R7sx21w4JKCUKDs5BNSzWdUO0OiQK+u/HQ6kGlCYQ2SWDUn/AQH3bkYdKvcxNaDv1fuPHyb A51UpPSjFWZk78NGC5OaJxAjJHBcUglS/4+2OjsUfqiDnrqjYN1rQAs0ilC8K4KDd6mJsRmhrgK njJtenFkvzRhRzvw== X-Gm-Gg: AYBFou0t4yWg4XHdcB8Qs9q3tXkL5TamdRTuRuC8Fpkdsd9qtAyew3nHQ8KEfRupLOu cEIhga/0naahcv3em3fe1MkpLZLwn+REIW0AhvLZYAcWRiPl0Qp1Hx671U4G0XgCvvGfkz5XFiV xU5QCLarssL6MXMBQLSiSQsLXh60g1vKDXFmyKpgeS5/v8X2/RP3k0gqXLHMSFkKhD7wXAY+KXH Loz9a136KaJgP3gC2241LgO+bOZ3yXUHv6Q/YkMBmhOa/mU8LDCu3OIbfs6xHSFmqy+J7lfYGkO LZ5zMos7HyRttJpSAiZkjtv0gxFRUpeGqPSHqELga+BrSSRMzb0TmsotJKMPc+6R3/zkSB3HDZ4 Hw46+JNNqenN/rckJLSUpBNAsMqPMzHb1SfZ1JZrfFw== X-Received: by 2002:a17:902:e54d:b0:2d8:d4ce:9f32 with SMTP id d9443c01a7336-2daec73210emr28641625ad.16.1788326363929; Tue, 01 Sep 2026 22:19:23 -0700 (PDT) X-Received: by 2002:a17:902:e54d:b0:2d8:d4ce:9f32 with SMTP id d9443c01a7336-2daec73210emr28641145ad.16.1788326363455; Tue, 01 Sep 2026 22:19:23 -0700 (PDT) Received: from localhost.. (118-163-61-247.hinet-ip.hinet.net. [118.163.61.247]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2dadd4a794bsm6882215ad.64.2026.09.01.22.19.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 22:19:23 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][R][PATCH v3 6/7] ASoC: SDCA: Switch to fixup_controls callback for IRQ registration Date: Wed, 2 Sep 2026 13:19:10 +0800 Message-ID: <20260902051911.3542655-7-chris.chiu@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260902051911.3542655-1-chris.chiu@canonical.com> References: <20260902051911.3542655-1-chris.chiu@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Chiu via kernel-team From: Chris Chiu Reply-To: Chris Chiu Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Charles Keepax BugLink: https://bugs.launchpad.net/bugs/2163215 Currently there are some race conditions around the boot of SDCA jack detection. The core creates DAPM widgets/routes quite a long time before it creates the associated ALSA control, and the jack detection IRQ is currently registered in component probe. At the time of component probe, the DAPM widgets exist, shortly after this the DAPM routes are added. At the time the DAPM routes are added the register value for the control is checked and the appropriate path is connected. The existing handling in the SDCA jack IRQ handles the case the control doesn't exist and updates the registers directly, which works until the DAPM routes are added. After the routes are added the DAPM graph has already set connected on a particular DAPM path, which will not be updated until an IRQ is received when the control is present. Thus those updates are usually not reflected in the resulting DAPM graph which can lead to the audio path being erroneously powered on/off. Switch to the new fixup_controls callback to register the IRQs, this is guaranteed to run after all the controls have been created. Which means we can avoid the aforementioned race condition and as a bonus no longer need to concern ourselves with a case where the IRQ handler runs and the ALSA control is unavailable. Signed-off-by: Charles Keepax Link: https://patch.msgid.link/20260721143636.361814-7-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown (cherry picked from commit b8f71f16134fadc287fbb14be2a42b707efb7a30) Signed-off-by: Chris Chiu --- sound/soc/sdca/sdca_class_function.c | 4 +-- sound/soc/sdca/sdca_jack.c | 44 ++++++++++++---------------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/sound/soc/sdca/sdca_class_function.c b/sound/soc/sdca/sdca_class_function.c index 2f9bbe6a9b51..c12f60f30ad9 100644 --- a/sound/soc/sdca/sdca_class_function.c +++ b/sound/soc/sdca/sdca_class_function.c @@ -190,7 +190,7 @@ static const struct snd_soc_dai_ops class_function_sdw_ops = { .hw_free = class_function_sdw_remove_peripheral, }; -static int class_function_component_probe(struct snd_soc_component *component) +static int class_function_component_fixup_controls(struct snd_soc_component *component) { struct class_function_drv *drv = snd_soc_component_get_drvdata(component); struct sdca_class_drv *core = drv->core; @@ -216,7 +216,7 @@ static int class_function_set_jack(struct snd_soc_component *component, } static const struct snd_soc_component_driver class_function_component_drv = { - .probe = class_function_component_probe, + .fixup_controls = class_function_component_fixup_controls, .remove = class_function_component_remove, .endianness = 1, }; diff --git a/sound/soc/sdca/sdca_jack.c b/sound/soc/sdca/sdca_jack.c index f2494c94ca33..4497134cd32f 100644 --- a/sound/soc/sdca/sdca_jack.c +++ b/sound/soc/sdca/sdca_jack.c @@ -41,6 +41,7 @@ int sdca_jack_process(struct sdca_interrupt *interrupt) struct jack_state *state = interrupt->priv; struct snd_kcontrol *kctl = state->kctl; struct snd_ctl_elem_value *ucontrol __free(kfree) = NULL; + struct soc_enum *soc_enum; unsigned int reg, val; int ret; @@ -55,10 +56,12 @@ int sdca_jack_process(struct sdca_interrupt *interrupt) return -ENOMEM; kctl = snd_soc_component_get_kcontrol(component, name); - if (!kctl) - dev_dbg(dev, "control not found: %s\n", name); - else - state->kctl = kctl; + if (!kctl) { + dev_err(dev, "control not found: %s\n", name); + return -ENODEV; + } + + state->kctl = kctl; } reg = SDW_SDCA_CTL(interrupt->function->desc->adr, interrupt->entity->id, @@ -96,30 +99,21 @@ int sdca_jack_process(struct sdca_interrupt *interrupt) dev_dbg(dev, "%s: %#x\n", interrupt->name, val); - if (kctl) { - struct soc_enum *soc_enum = (struct soc_enum *)kctl->private_value; - - ucontrol = kzalloc_obj(*ucontrol); - if (!ucontrol) - return -ENOMEM; - - ucontrol->value.enumerated.item[0] = snd_soc_enum_val_to_item(soc_enum, val); + ucontrol = kzalloc_obj(*ucontrol); + if (!ucontrol) + return -ENOMEM; - ret = snd_soc_dapm_put_enum_double(kctl, ucontrol); - if (ret < 0) { - dev_err(dev, "failed to update selected mode: %d\n", ret); - return ret; - } + soc_enum = (struct soc_enum *)kctl->private_value; + ucontrol->value.enumerated.item[0] = snd_soc_enum_val_to_item(soc_enum, val); - snd_ctl_notify(card->snd_card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); - } else { - ret = regmap_write(interrupt->function_regmap, reg, val); - if (ret) { - dev_err(dev, "failed to write selected mode: %d\n", ret); - return ret; - } + ret = snd_soc_dapm_put_enum_double(kctl, ucontrol); + if (ret < 0) { + dev_err(dev, "failed to update selected mode: %d\n", ret); + return ret; } + snd_ctl_notify(card->snd_card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); + return sdca_jack_report(interrupt); } EXPORT_SYMBOL_NS_GPL(sdca_jack_process, "SND_SOC_SDCA"); @@ -199,7 +193,7 @@ int sdca_jack_set_jack(struct sdca_interrupt_info *info, struct snd_soc_jack *ja struct sdca_entity *entity = interrupt->entity; struct jack_state *jack_state; - if (!interrupt->irq) + if (!interrupt->dev) continue; switch (SDCA_CTL_TYPE(entity->type, control->sel)) { From patchwork Wed Sep 2 05:19:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Chiu X-Patchwork-Id: 2296363 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hZWHt10Yqz1ybC for ; Wed, 02 Sep 2026 15:19:38 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1x1dNg-0006b9-JP; Wed, 02 Sep 2026 05:19:28 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1x1dNe-0006XD-NQ for kernel-team@lists.ubuntu.com; Wed, 02 Sep 2026 05:19:26 +0000 Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 921053F167 for ; Wed, 2 Sep 2026 05:19:26 +0000 (UTC) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2d54187d8b0so16711175ad.0 for ; Tue, 01 Sep 2026 22:19:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788326365; x=1788931165; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=TmfwIIMbB1PITlCEVaSFq36rLRoqBeu8jaUdvLEq3ls=; b=TsgV9hjuDmvvq6AclsRgeaJx0VL2Qk8NkKGl+baAnwlNhAESswskfYrAVktG0u95NN HtxGKr6+wTgIWsvtHjA985D58fXBHCQFc9FsEsm1QfLpRAicep4tTygBBlRQcR5FZRiq eSNjmwUoO27zIc6K9qoMesTuhsrdEle4EABYeJiH4NeXGy8EAbbKAZQ6eBHkXBnA3yA4 4kZmzfHrdQvgz7LLyAfBeEnxQfeuX4Mb3OMZnYTDWeQ4KzIZHy7qGW7L2EQ9PoZqilCM Qw4VhfklTLDojiZp8IxjmMf2sVHFDgOMPnh6XFrBU/LU9srT4zluQITD0Qe1yhmN7pVR vBCA== X-Gm-Message-State: AFuF++k3shqcE578X7Lr4PMnRarv4YNSduQdEDpOMN5qWUoo+5JCY9gk QNxUwSKw1RcHg1jZFHSlgUf/y3IBhb5fSbPEl5FApcNUNyPSYzRVxW/7ZXXPUB3WX23a6dUega0 GA/EXUZY3aeAX7cr0EJCMqs5vLUZ8z2BUrGYNFxpX/ivFdB/gz7Vv3wWrxu93H74aq1lG2JVKta 7oTuswLu3CMMHW2g== X-Gm-Gg: AYBFou2nVI/zPmPP44xI0Ah0LVPFqNtJYbkRdG0HuLrrUOKxx0t9EGQpbYi+zFDjMdO Wm+w0iLXp4aMPdUNMe7vpCxnJ22yoG/NUf7DFcv3F9qG/niqoUNuYv/mxi2tqdEK04GYh+klGrb 6TWIfPP6IXzWP/mM37KKyInQq0fZGJrZxNiSs+1qH01+QsKtx2sMFq1qDD9XMsn+uVCmsspvYE4 xN1hX/jvQJjs+EnCKRRPbFzCpps2aKD7gJN6WdcErIOGVqWVYgiCYnzQa9joFMT0YzWQF6Ch3Sh KV53t+V9/FBCYVhnujLSl5+Q7VartfpX6xPyJhObi/HptCYw2EBeMnLWwuWUl1X6v+l7lRNNbhN FF08BUVzvW+h5LGgLEzXqrOWBuemUUkByXRPwB2SFwQ== X-Received: by 2002:a17:903:3846:b0:2d6:f961:994f with SMTP id d9443c01a7336-2daec62cc08mr34974305ad.8.1788326365026; Tue, 01 Sep 2026 22:19:25 -0700 (PDT) X-Received: by 2002:a17:903:3846:b0:2d6:f961:994f with SMTP id d9443c01a7336-2daec62cc08mr34973905ad.8.1788326364604; Tue, 01 Sep 2026 22:19:24 -0700 (PDT) Received: from localhost.. (118-163-61-247.hinet-ip.hinet.net. [118.163.61.247]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2dadd4a794bsm6882215ad.64.2026.09.01.22.19.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 22:19:24 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][R][PATCH v3 7/7] ASoC: SDCA: Move kcontrol search out of IRQ Date: Wed, 2 Sep 2026 13:19:11 +0800 Message-ID: <20260902051911.3542655-8-chris.chiu@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260902051911.3542655-1-chris.chiu@canonical.com> References: <20260902051911.3542655-1-chris.chiu@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Chiu via kernel-team From: Chris Chiu Reply-To: Chris Chiu Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Charles Keepax BugLink: https://bugs.launchpad.net/bugs/2163215 Now that the IRQs are always registered after all the ALSA controls are created it is possible to search for the control at the point the IRQ is requested. Move the control search out of the IRQ handler and do it at IRQ request time. This also fixes a potential issue when the card was torn down and reprobed without destroying the codec device, the kctl pointer stored by the IRQ handler would not be updated to the new control on the second probe. Signed-off-by: Charles Keepax Link: https://patch.msgid.link/20260721143636.361814-8-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown (cherry picked from commit bf1b7821f85383a8804441f8fd5165be148f3ec8) Signed-off-by: Chris Chiu --- include/sound/sdca_jack.h | 1 + sound/soc/sdca/sdca_interrupts.c | 12 +++++++++ sound/soc/sdca/sdca_jack.c | 43 +++++++++++++++++++------------- 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/include/sound/sdca_jack.h b/include/sound/sdca_jack.h index 8624c51eea26..bdde096141c3 100644 --- a/include/sound/sdca_jack.h +++ b/include/sound/sdca_jack.h @@ -25,6 +25,7 @@ struct jack_state { }; int sdca_jack_alloc_state(struct sdca_interrupt *interrupt); +int sdca_jack_init_state(struct sdca_interrupt *interrupt); void sdca_jack_free_state(struct sdca_interrupt *interrupt); int sdca_jack_process(struct sdca_interrupt *interrupt); diff --git a/sound/soc/sdca/sdca_interrupts.c b/sound/soc/sdca/sdca_interrupts.c index 79a17d827f99..15da7c2aea50 100644 --- a/sound/soc/sdca/sdca_interrupts.c +++ b/sound/soc/sdca/sdca_interrupts.c @@ -512,6 +512,8 @@ int sdca_irq_populate(struct sdca_function_data *function, for (i = 0; i < SDCA_MAX_INTERRUPTS; i++) { struct sdca_interrupt *interrupt = &info->irqs[i]; + struct sdca_control *control = interrupt->control; + struct sdca_entity *entity = interrupt->entity; int irq; if (interrupt->function != function || interrupt->irq) @@ -519,6 +521,16 @@ int sdca_irq_populate(struct sdca_function_data *function, interrupt->component = component; + switch (SDCA_CTL_TYPE(entity->type, control->sel)) { + case SDCA_CTL_TYPE_S(GE, DETECTED_MODE): + ret = sdca_jack_init_state(interrupt); + if (ret) + return ret; + break; + default: + break; + } + irq = interrupt->control->interrupt_position; ret = sdca_irq_request_locked(dev, info, irq, interrupt->name, interrupt->handler, interrupt); diff --git a/sound/soc/sdca/sdca_jack.c b/sound/soc/sdca/sdca_jack.c index 4497134cd32f..8d4f89dc416e 100644 --- a/sound/soc/sdca/sdca_jack.c +++ b/sound/soc/sdca/sdca_jack.c @@ -47,23 +47,6 @@ int sdca_jack_process(struct sdca_interrupt *interrupt) guard(rwsem_write)(rwsem); - if (!kctl) { - const char *name __free(kfree) = kasprintf(GFP_KERNEL, "%s %s", - interrupt->entity->label, - SDCA_CTL_SELECTED_MODE_NAME); - - if (!name) - return -ENOMEM; - - kctl = snd_soc_component_get_kcontrol(component, name); - if (!kctl) { - dev_err(dev, "control not found: %s\n", name); - return -ENODEV; - } - - state->kctl = kctl; - } - reg = SDW_SDCA_CTL(interrupt->function->desc->adr, interrupt->entity->id, interrupt->control->sel, 0); @@ -148,6 +131,32 @@ void sdca_jack_free_state(struct sdca_interrupt *interrupt) } EXPORT_SYMBOL_NS_GPL(sdca_jack_free_state, "SND_SOC_SDCA"); +/** + * sdca_jack_init_state - Initialise transient state for a jack interrupt + * @interrupt: SDCA interrupt structure. + * + * Return: Zero on success or a negative error code. + */ +int sdca_jack_init_state(struct sdca_interrupt *interrupt) +{ + struct jack_state *jack_state = interrupt->priv; + const char *name __free(kfree) = kasprintf(GFP_KERNEL, "%s %s", + interrupt->entity->label, + SDCA_CTL_SELECTED_MODE_NAME); + + if (!name) + return -ENOMEM; + + jack_state->kctl = snd_soc_component_get_kcontrol(interrupt->component, name); + if (!jack_state->kctl) { + dev_err(interrupt->dev, "control not found: %s\n", name); + return -ENODEV; + } + + return 0; +} +EXPORT_SYMBOL_NS_GPL(sdca_jack_init_state, "SND_SOC_SDCA"); + static int type_get_mask(enum sdca_terminal_type type) { switch (type) {