From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796487516; b=EhvHBfS9OvXZY06DZdA4IV5r1BiTIqpDe1SBg0mhq61Qeg8rAx9IeMgKiScPKkuOJ5fk qpscBrD6hIzBXriV1owL3GieGJzF/c27jEK9YtPja9TJdAQRB+E8MmIab3dVi4UJLOdCT srPje+n3nUF+/nCqYohFeJuyBgagpthrYC5vHwrVE6Jl0ISLJ1J/XH6BJ34wWb0r1Y0Q1 czVatNl3ItnQbEzSu54scSW5PmbCPrVVb+JjlwZJjprYmYhAmuhb4J3eBj9v3qBw1HQb2 3XvK1MWxUbaPUVgQKSXKMwP3/1JT08rUaJF3aGNh4wwTnSZiqngMANpTXPcEuKu9iTQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796487516; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=io9xnzHyfnP1igFe5wqgihpEtdle6v2e3Sprg/ldoVw=; b=uTZ9TKwXKQyeP0jRfWM3bZxk1tox9uLUJR6QI7ouehqGpmVv4+8D4KFTK4WtafEpkcYV kc/KD0VyDpIHho5Y43Yx640JgmhkDFo+hR8zkdAvZrIwNiE/OiPijdyUsih3YDNIwfhBd rR9eibwiqMR9YYNNfxon99HjhXwDRkRx9GXj5sN7I7J6jLmhyHlYpGDZCWfWqjQOeuf3s f3iZPMli/yzTa1g3Xge/9wOQiwGVFjR31HnjNA6vGHPX8aht3BpnYaOjR/d1H0ylUsx8D mPqVhDBDLnZyROgN8HpbBoUysnqmoGzk1pJsCWOKmPvh9w/VJ72IzNV//KvHgjmQmrA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=c0s1WJMx; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCB26606A31F for ; Sat, 5 Dec 2026 16:18:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=c0s1WJMx Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CB2F1F00936; Sat, 5 Dec 2026 16:18:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796487516; bh=io9xnzHyfnP1igFe5wqgihpEtdle6v2e3Sprg/ldoVw=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=c0s1WJMxE0qPjpeNBPYBISOW1JfV5VKqg6G6Q5BvYO2XD4bWFbyfnLeIYh58lgtuz fv7KdiWIW+Jf+9BsqWjn9RnmqiYXlui1Ktcb2M86ojUQi8VcTQrG77cMwawSyw3n2M KR4aHRoM9l05Xl4XeBhBUULkbb4hsERNxhtQJg78u1xi8RAFmROeg9b21bVZQNcM0k HElLNn3kYwXdkX4P4AQjcu907FdVo6U5S4QeSywHj6oayjRJl5DeL1//J6lOynBOHj RK57nFdZXbuTa2XJpt7pYdnVgjCo0kbPYCLh5SQM4WjQKqA6CYxv3dRMAuBGYA4D+R GOQcoEyLpxu6g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 1/2] ASoC: SDCA: add jack ops hooks Reply-To: sashiko-reviews@lists.linux.dev To: "Gopi Chandra Sekhar Reddy Kanala" Cc: linux-sound@vger.kernel.org In-Reply-To: <20261205-b4-sdca-wcd9378-jack-v1-1-60ec9bff39ea@oss.qualcomm.com> References: <20261205-b4-sdca-wcd9378-jack-v1-0-60ec9bff39ea@oss.qualcomm.com> <20261205-b4-sdca-wcd9378-jack-v1-1-60ec9bff39ea@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 16:18:35 +0000 X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [High] ASoC: SDCA: set_jack() hardware enable is not restored after system resume - [Medium] ASoC: SDCA: class_function_set_jack() enables jack HW even when jack is NULL - [Medium] ASoC: SDCA: race between set_jack() and post_jack_irq_process() hooks - [Low] ASoC: SDCA: core jack layer couples to sdca_class_drv and omits lock docs - [Low] ASoC: SDCA: inaccurate set_jack() doc claim on initial hardware state read -- commit 44baabaeaf479d2ea44b8b468dfe123bdbd091ca Author: Gopi Chandra Sekhar Reddy Kanala ASoC: SDCA: add jack ops hooks This commit adds optional set_jack and post_jack_irq_process callbacks to struct sdca_class_ops and wires a back-pointer from sdca_interrupt_info to sdca_class_drv so sdca_jack_process() can invoke the post-IRQ hook. > diff --git a/include/sound/sdca_class.h b/include/sound/sdca_class.h > index 794a756472cd6..073f122633e24 100644 > --- a/include/sound/sdca_class.h > +++ b/include/sound/sdca_class.h > @@ -26,10 +26,23 @@ struct sdca_function_data; > * DT/non-DisCo platforms. Called once per SDCA function with > * @dev pointing at that function's device. Pure data source; > * performs no bus I/O. Return 0 on success or a negative err= no. > + * @set_jack: called from the class function driver's ASoC .set_jack, ju= st > + * before the jack is registered with sdca_jack_set_jack(). U= se > + * to enable detection hardware that must not be active any > + * earlier. Enabling here means the initial state reported by > + * sdca_jack_set_jack() already reflects the hardware. May be > + * NULL. [Severity: Low] Is this comment (and the commit message) accurate about the initial state reported by sdca_jack_set_jack()? sdca_jack_set_jack() calls sdca_jack_report(), which reads the cached SDCA_CTL_GE_SELECTED_MODE register rather than volatile SDCA_CTL_GE_DETECTED_MODE. During snd_soc_card_bind(), machine drivers call snd_soc_component_set_jack() from dai_link->init or card->late_probe before snd_soc_component_fixup_controls() invokes sdca_irq_populate() to request detected_mode_handler(). Because sdca_jack_process() has not run yet, sdca_jack_set_jack() only reports the cached default value rather than live hardware state. [ ... ] > diff --git a/include/sound/sdca_interrupts.h b/include/sound/sdca_interru= pts.h > index 3b30146e21db5..fa53ccf27b798 100644 > --- a/include/sound/sdca_interrupts.h > +++ b/include/sound/sdca_interrupts.h > @@ -60,6 +63,9 @@ struct sdca_interrupt { > * struct sdca_interrupt_info - contains top-level SDCA interrupt inform= ation > * @irq_chip: regmap irq chip structure. > * @irq_data: regmap irq chip data structure. > + * @core: Optional pointer to the device-level SDCA class driver owning > + * this interrupt information, letting Function-level handlers reach the > + * device's ops. Left NULL by drivers that do not use sdca_class_drv. > * @irqs: Array of data for each individual IRQ. > * @irq_lock: Protects access to the list of sdca_interrupt structures. > */ > @@ -67,6 +73,8 @@ struct sdca_interrupt_info { > struct regmap_irq_chip irq_chip; > struct regmap_irq_chip_data *irq_data; > =20 > + struct sdca_class_drv *core; > + > struct sdca_interrupt irqs[SDCA_MAX_INTERRUPTS]; [Severity: Low] Should struct sdca_interrupt_info carry a direct pointer to struct sdca_class_drv? This couples the reusable core snd-soc-sdca library (sdca_interrupts.h and sdca_jack.c) to the upper-layer class driver instead of using a generic jack or interrupt callback or wrapping the IRQ handler via sdca_irq_request(). Separately, sdca_jack_process() calls post_jack_irq_process() while holding card->snd_card->controls_rwsem for writing, and runs it before updating SELECTED_MODE via snd_soc_dapm_put_enum_double() and calling sdca_jack_report(). The struct sdca_class_ops kernel-doc does not mention the held controls_rwsem lock or the sleepable and runtime PM expectations for these callbacks. [ ... ] > diff --git a/sound/soc/sdca/sdca_class_function.c b/sound/soc/sdca/sdca_c= lass_function.c > index 1f0b5954a948c..7f05336712639 100644 > --- a/sound/soc/sdca/sdca_class_function.c > +++ b/sound/soc/sdca/sdca_class_function.c > @@ -214,6 +214,14 @@ static int class_function_set_jack(struct snd_soc_co= mponent *component, > { > struct class_function_drv *drv =3D snd_soc_component_get_drvdata(compon= ent); > struct sdca_class_drv *core =3D drv->core; > + int ret; > + > + if (core->ops && core->ops->set_jack) { > + ret =3D core->ops->set_jack(core->sdw, core->dev_regmap); > + if (ret) > + dev_warn(component->dev, > + "failed to enable hardware jack detection: %d\n", ret); > + } > =20 > return sdca_jack_set_jack(core->irq_info, jack); > } [Severity: Medium] Should core->ops->set_jack() be called when jack is NULL? ASoC machine drivers call snd_soc_component_set_jack(component, NULL, NULL) to detach the jack on card teardown or probe-deferral rollback, for example in qcom_snd_headset_jack_cleanup(). Because set_jack() takes neither jack nor an enable flag and is called unconditionally here, teardown re-enables hardware jack detection with no attached jack and gives codec drivers no way to disable it. Passing jack (or an enable boolean) to the callback would let drivers distinguish attach from detach. [Severity: High] How is hardware jack detection restored after system suspend and resume? Machine drivers invoke snd_soc_component_set_jack() once during dai_link->init, not on system resume. During system resume, class_function_runtime_resume() resets the function and replays init_table (which no longer enables jack detection), while class_dev_regmap_volatile() marks every register in core->dev_regmap except SDW_SCP_SDCA_INTMASK1..4 as volatile so regcache_sync(drv->dev_regmap) does not restore vendor jack-detection registers written by core->ops->set_jack(). Without tracking whether a jack is attached and re-invoking set_jack() on resume after class_function_init_device(), hardware jack detection stays disabled after the first system suspend/resume cycle. [ ... ] > diff --git a/sound/soc/sdca/sdca_jack.c b/sound/soc/sdca/sdca_jack.c > index 73f8067906a90..8c9ca3b51d272 100644 > --- a/sound/soc/sdca/sdca_jack.c > +++ b/sound/soc/sdca/sdca_jack.c > @@ -82,6 +84,14 @@ int sdca_jack_process(struct sdca_interrupt *interrupt) > =20 > dev_dbg(dev, "%s: %#x\n", interrupt->name, val); > =20 > + /* core is unset on devices that are not sdca_class_drv users */ > + if (core && core->ops && core->ops->post_jack_irq_process) { > + ret =3D core->ops->post_jack_irq_process(core->sdw, > + core->dev_regmap); > + if (ret) > + dev_warn(dev, "jack post-process failed: %d\n", ret); > + } > + > ucontrol =3D kzalloc_obj(*ucontrol); > if (!ucontrol) > return -ENOMEM; [Severity: Medium] Can core->ops->post_jack_irq_process() race with core->ops->set_jack()? During card teardown, snd_soc_card_cleanup_resources() runs snd_soc_link_exit() before snd_soc_card_link_components_remove() frees the jack IRQ via sdca_irq_cleanup(): CPU0 CPU1 (threaded IRQ) snd_soc_card_cleanup_resources() snd_soc_link_exit() class_function_set_jack() ops->set_jack(...) detected_mode_handler() sdca_jack_process() guard(rwsem_write)(rwsem) ops->post_jack_irq_process(...) <-- concurrent regmap writes snd_soc_card_link_components_remove() sdca_irq_cleanup() class_function_set_jack() holds neither controls_rwsem nor irq_lock, so multi-register sequences and read-modify-write updates in set_jack() and post_jack_irq_process() can interleave on core->dev_regmap and corrupt the hardware jack-detection state. Serializing both hooks under a common lock (or disabling the jack IRQ around set_jack()) would prevent the race. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205-b4-sdca-wc= d9378-jack-v1-0-60ec9bff39ea@oss.qualcomm.com?part=3D1