From patchwork Wed Aug 26 03:48:31 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Chiu X-Patchwork-Id: 2292336 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 4hV9cp5mzgz1xxf for ; Wed, 26 Aug 2026 13:49:14 +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 1wz4dO-0002Cu-BQ; Wed, 26 Aug 2026 03:49:06 +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 1wz4dN-0002Ck-G1 for kernel-team@lists.ubuntu.com; Wed, 26 Aug 2026 03:49:05 +0000 Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.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 60AF93F72E for ; Wed, 26 Aug 2026 03:49:05 +0000 (UTC) Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-81e735bcceaso8422167b3.3 for ; Tue, 25 Aug 2026 20:49:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787716144; x=1788320944; 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=hrMdeKMz8VzHHCT4jHe9kuDuPzO6gDbQPbhhBUc8zvk=; b=rYcxAlpmij1S/Ix33ShkaD+9u0wvTh5brF75TGvVAo2io4Otd/40BPiuIjSYx72QHT ORX46Kuf0ue7NUmJCFVG4GT+Vz0s4EPZUc6NY1UbW/DIn4lFUXaUiNpo04dZLnHYHk6g 8jSRbvoha4RE3jnCzS8iIRlmzn+MeCLk9yScZeTyx2TeRNm01lX1zI3SDja/uWE3wjH2 xYtH/RqiR+JQk/QpU7mZXR1E1KjJB/CSz+OTp2ma8CUSVw09UTmWiltep+px9zb11xM+ Aqa2DsW6bQZnhOHih3hyY4QRnawjhFonfHAd8uj2bDgkKa76YXcJTWts8KSYtnXI5ATi 0sgg== X-Gm-Message-State: AFuF++mjNgsrXLCmloKuB8BaQwB9G7hoUFzVCv+MeCdwiD41BTlZZE2Q NFpF+R7hUKtjyugCq7pLucTxPLK/f3dCTH/J7ytePTh4LxkVhrh2pyzfLAaGuQ9tBIimbMtdx5c SyvgMNI3GAfhs31kbTRRll/AG+u2lBCdAKGhiVWJpKjGvkeMtlq/cKSgzjRajJFLM02dLnVg1XI qLXF1UsSxpsg2Nnzbn X-Gm-Gg: AR+sD11EY34nMlXukMtN8cRN25QXdi1bT8Ctc0gCX00Wha1M9BoBvFsbvqnrpYYukG+ oqcQSPUVtYh2GQCBUs6A2qhzbyLGHmvI03h7eC2TLeMcNdyYi79eCEp+bh65vLfKxKmfHYWRbvf q/u9s3CgmIYMDb9LjUp1aT7rtiuM2K6OOACngp/XWn3hX8Di753UVBOS0Oy3TmFjRsX5OF/9o2C P0JSm0sSrhdO/0ug7DvQDLMxo2N66xiLVjKYGvKjVh1ruHbGuA3y7prmLW+AkvGOcoMhw2t7WYB /QmSTP8+GrGQQRmxzUysHsu99D97xJMpV/v+llxZG6gQeDI7rySGptd/rflvr5KTQ5h9/DjSGaQ qZt3vrP2gFg== X-Received: by 2002:a05:690c:e681:10b0:823:2ad3:d392 with SMTP id 00721157ae682-85743367b42mr12037937b3.31.1787716144182; Tue, 25 Aug 2026 20:49:04 -0700 (PDT) X-Received: by 2002:a05:690c:e681:10b0:823:2ad3:d392 with SMTP id 00721157ae682-85743367b42mr12037857b3.31.1787716143719; Tue, 25 Aug 2026 20:49:03 -0700 (PDT) Received: from localhost.localdomain ([2001:67c:1560:8007::aac:c1a2]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8570cd697f4sm9679887b3.33.2026.08.25.20.49.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2026 20:49:03 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][R][PATCH v2 1/5] soundwire: Add a helper function to wait for device initialisation Date: Wed, 26 Aug 2026 11:48:31 +0800 Message-ID: <20260826034835.661988-2-chris.chiu@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260826034835.661988-1-chris.chiu@canonical.com> References: <20260826034835.661988-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/2164967 Add a new helper function to wait for the device to enumerate and be initialised by the SoundWire core. Most of the SoundWire drivers have very similar boiler plate code in their runtime resume, and that boiler plate tends to access various internals of the SoundWire structs which is a mild layering violation. Adding a new core helper function greatly eases both of these issues. Acked-by: Vinod Koul Signed-off-by: Charles Keepax Link: https://patch.msgid.link/20260512103022.1154645-2-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown (cherry picked from commit 3492e8b494c18028044d4a2e03db5c7331fbd789) Signed-off-by: Chris Chiu --- drivers/soundwire/bus.c | 31 +++++++++++++++++++++++++++++++ include/linux/soundwire/sdw.h | 8 ++++++++ 2 files changed, 39 insertions(+) diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index fe5316d93fef..ea3a24f805c0 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -1372,6 +1372,37 @@ int sdw_slave_get_current_bank(struct sdw_slave *slave) } EXPORT_SYMBOL_GPL(sdw_slave_get_current_bank); +/** + * sdw_slave_wait_for_init - Wait for device initialisation + * @slave: Pointer to the SoundWire peripheral. + * @timeout_ms: Timeout in milliseconds. + * + * Wait for a peripheral device to enumerate and be initialised by the + * SoundWire core. + * + * Return: Zero on success, and a negative error code on failure. + */ +int sdw_slave_wait_for_init(struct sdw_slave *slave, int timeout_ms) +{ + unsigned long time; + + if (!slave->unattach_request) + return 0; + + time = wait_for_completion_timeout(&slave->initialization_complete, + msecs_to_jiffies(timeout_ms)); + if (!time) { + dev_err(&slave->dev, "Initialization not complete\n"); + sdw_show_ping_status(slave->bus, true); + return -ETIMEDOUT; + } + + slave->unattach_request = 0; + + return 0; +} +EXPORT_SYMBOL_GPL(sdw_slave_wait_for_init); + static int sdw_slave_set_frequency(struct sdw_slave *slave) { int scale_index; diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index f462717acf20..e2180afa7f98 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -1093,6 +1093,8 @@ int sdw_slave_get_current_bank(struct sdw_slave *sdev); int sdw_slave_get_scale_index(struct sdw_slave *slave, u8 *base); +int sdw_slave_wait_for_init(struct sdw_slave *slave, int timeout_ms); + /* messaging and data APIs */ int sdw_read(struct sdw_slave *slave, u32 addr); int sdw_write(struct sdw_slave *slave, u32 addr, u8 value); @@ -1136,6 +1138,12 @@ static inline int sdw_slave_get_current_bank(struct sdw_slave *sdev) return -EINVAL; } +static inline int sdw_slave_wait_for_init(struct sdw_slave *slave, int timeout_ms) +{ + WARN_ONCE(1, "SoundWire API is disabled"); + return -EINVAL; +} + /* messaging and data APIs */ static inline int sdw_read(struct sdw_slave *slave, u32 addr) { From patchwork Wed Aug 26 03:48:32 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Chiu X-Patchwork-Id: 2292338 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 4hV9cr2Mpxz1xtN for ; Wed, 26 Aug 2026 13:49:16 +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 1wz4dR-0002F9-I9; Wed, 26 Aug 2026 03:49:09 +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 1wz4dQ-0002DU-2d for kernel-team@lists.ubuntu.com; Wed, 26 Aug 2026 03:49:08 +0000 Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.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 C2A103F72E for ; Wed, 26 Aug 2026 03:49:07 +0000 (UTC) Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-8546e211940so17158057b3.0 for ; Tue, 25 Aug 2026 20:49:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787716146; x=1788320946; 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=DCvXic3/wHzbQ2/nwwLsxusAZVz+kSGsC4pX7LpGPcI=; b=fqwScDEOWHX+gH0e9CVfEql23Rx3czg0KoTKWI9DDEeZQgZb2NXpWgQIeLAtbTz7of 95cZCQLwZ8C2fmRdbw8zQZyInEX+yuOn4AlJbD+oRmiC0s/ca34BGQ7YVSVFN4lAg2Q2 MMRfxOwo1ut4IhiQ0U83r46R7Ib3Dgdft3mqK8J/6+iIAl9TF1lvFmuVSdYM6Jdpjy5j 0e1AQMb6owa8cWQ5he+F4Y1N6KEZrvtyRZH7BAvKCj8rQ0pZzMOFCOO6Fl7L8N8whiKz j4uIKHUnsWdxTbGpXoCzlkwoKwv4mErzvvHRmIhLNpWe0bkVCDaRUGJ+he4lDfv0bu+6 41zw== X-Gm-Message-State: AFuF++lnKxfZctJjFAkN2sN3oSGjYVlVMhAv2tBnmqGwAQ/I6Ub7OuS4 6DYrnWrLyChEci5ZWlkqMU50BPalyzPngSFIfuoVLvdBfxhN9yz5MdoDhoo4vH8RqFGWuLHiVLB Br+J0tvs90jFQUcPNAA9ZQuPYNh49j4WEacCyb8Gnt6dwUj1IpnT2xpccldvDgYjZJIwQr9To4E V5XpvhMxeAiQsf6NRb X-Gm-Gg: AR+sD10cB5/cCeuE1d1ah7C2Un57gTvlb01EP4ogk++sA7eC8vfeD1ipVxAQW48lEw1 VZHEtXXDmZymO58ixLa1TgM7imtTxn2ULHUnlwyof0Ruja39O2jvKfSizxUdZ1cQApT9FWNebYj w9kKuK1HOdcGrVZymji1dnhLTFzMdBKaIyVOWg4Dk4POO/4n/AhPgdmPqevKJyS+gXbx8ibg/am goF3hblunLFG34ytC2t1vCSr+4d+uuB7Hwm90oJsTXJt8eQh13Mq5jZgradqemIJZd4SdxLd1Yr xXLLXJxrDZwtMFW6oMaVzlJ8NnLSCx71pQS9+H+zmoeoWj7webv2tMggv54OBZ+/UUwUlO/WMa/ o1ycgU6IiSg== X-Received: by 2002:a05:690c:6b11:b0:81e:fe1c:2de8 with SMTP id 00721157ae682-8573bb29a79mr17987427b3.3.1787716146624; Tue, 25 Aug 2026 20:49:06 -0700 (PDT) X-Received: by 2002:a05:690c:6b11:b0:81e:fe1c:2de8 with SMTP id 00721157ae682-8573bb29a79mr17987317b3.3.1787716146263; Tue, 25 Aug 2026 20:49:06 -0700 (PDT) Received: from localhost.localdomain ([2001:67c:1560:8007::aac:c1a2]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8570cd697f4sm9679887b3.33.2026.08.25.20.49.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2026 20:49:05 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][R][PATCH v2 2/5] ASoC: tas2783: Use new SoundWire enumeration helper Date: Wed, 26 Aug 2026 11:48:32 +0800 Message-ID: <20260826034835.661988-3-chris.chiu@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260826034835.661988-1-chris.chiu@canonical.com> References: <20260826034835.661988-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/2164967 Update the driver to use the new core helper that waits for the device to enumerate on SoundWire and be initialised by the SoundWire core. Signed-off-by: Charles Keepax Link: https://patch.msgid.link/20260512103022.1154645-19-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown (cherry picked from commit ac6d4f298160bebf6979e63c2758414af5266f28) Signed-off-by: Chris Chiu --- sound/soc/codecs/tas2783-sdw.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/sound/soc/codecs/tas2783-sdw.c b/sound/soc/codecs/tas2783-sdw.c index 90008d2d06e2..1bc6da668bdc 100644 --- a/sound/soc/codecs/tas2783-sdw.c +++ b/sound/soc/codecs/tas2783-sdw.c @@ -1082,22 +1082,12 @@ static s32 tas2783_sdca_dev_resume(struct device *dev) { struct sdw_slave *slave = dev_to_sdw_dev(dev); struct tas2783_prv *tas_dev = dev_get_drvdata(dev); - unsigned long t; - - if (!slave->unattach_request) - goto regmap_sync; - - t = wait_for_completion_timeout(&slave->initialization_complete, - msecs_to_jiffies(TAS2783_PROBE_TIMEOUT)); - if (!t) { - dev_err(&slave->dev, "resume: initialization timed out\n"); - sdw_show_ping_status(slave->bus, true); - return -ETIMEDOUT; - } + int ret; - slave->unattach_request = 0; + ret = sdw_slave_wait_for_init(slave, TAS2783_PROBE_TIMEOUT); + if (ret) + return ret; -regmap_sync: regcache_cache_only(tas_dev->regmap, false); regcache_sync(tas_dev->regmap); return 0; From patchwork Wed Aug 26 03:48:33 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Chiu X-Patchwork-Id: 2292339 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 4hV9cv5k4Xz1xtN for ; Wed, 26 Aug 2026 13:49:19 +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 1wz4dV-0002Hb-6Q; Wed, 26 Aug 2026 03:49:13 +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 1wz4dS-0002Fx-GU for kernel-team@lists.ubuntu.com; Wed, 26 Aug 2026 03:49:10 +0000 Received: from mail-yw1-f200.google.com (mail-yw1-f200.google.com [209.85.128.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 553103F72E for ; Wed, 26 Aug 2026 03:49:10 +0000 (UTC) Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-845f687dfa2so16275547b3.2 for ; Tue, 25 Aug 2026 20:49:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787716149; x=1788320949; 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=vhXYq1pqC96VypRtQmXzqq/nmyBm4K/kmpy+dVzhZl4=; b=D4xk0aqU4ZWRd2fYmcsrkrP55VVzxPIU5PKAHQtJ6iPB3Te3AEOv7NUTrZ1UH9ntaS FgD28TJ/sN53cXBB/QFD4hkOCl3sN0IVl5qpi7BrXJ7a2KNSrxTzdKPB+2j19dIzKSnZ zD5K48RpxnGBfIK38fHNUXp8MxM/n6G0LrRPGzEPg6ho1meLFCj07yOXmu4ABtev0qxo 8zpzVMDac9o+gbTgGp0mW4NY9JMdwDRk4hxFSqDpWR8DMPtSRZpTPSXB7wq6REzlx8Qj HOB8q5BzTLGi8bpIegJ1/VRIJLjoyVw8g9VwWXsf6097dj/cnFYHk6S7Lr3neq2BDOHZ hEfQ== X-Gm-Message-State: AFuF++l54UYonT6qtdBXbS2V9dGww1wDVWgRdjifIacpnfiMCaGQftjR uiUfckeHarQ4UfbTEITLKlxVydZTbc3RxyNUTz2iewmZ5tOAzOdNs2g1HNaU0lDMnzV7ZGUwYOX 8Nj8JNPJvC54/fZFP8siec/ScMWgpjgY2VtNWSwUe9v3/+DO5nE+1RszXNrQtOlz3wYdoW3t2ql VcjOMeFZrfukhuLySJ X-Gm-Gg: AR+sD13VgKIztU7qlcdO+VtCCrZx4uJXO+zQjtzEwE6nRXXauLBV06z7Hkc7zkGkilA E8MJVLrsXlmymNutqr019Jktf7GwdSB46ph5LRHNXZW2uurkoNtj+NJlBe20BBAI33SSntn1sYP N/VKCbYSc+KDO83M4SjBYvSuA0Kj9y8NJzCuKKryvX+VOPr0mN0T1EvMZdnKxpQe+XhV8BHcGpY nQUX99mrm7s2ksuTNShc3IaQSwIM4ks8lftqX4c5vWRng312tf9NYE6J+Sh4vPwFHDWEcFJQ3jy Vkt8wQ21oJbDPS7N2S7up69Dq39KPPN1cfRkk/+O7Wlce7ziNpLQl2riP7hJ0Dsk6lez7Omle0T idMhJsvjcmg== X-Received: by 2002:a05:690c:e68f:10b0:833:968e:c223 with SMTP id 00721157ae682-8573f3ef2fcmr14627387b3.21.1787716149107; Tue, 25 Aug 2026 20:49:09 -0700 (PDT) X-Received: by 2002:a05:690c:e68f:10b0:833:968e:c223 with SMTP id 00721157ae682-8573f3ef2fcmr14627297b3.21.1787716148638; Tue, 25 Aug 2026 20:49:08 -0700 (PDT) Received: from localhost.localdomain ([2001:67c:1560:8007::aac:c1a2]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8570cd697f4sm9679887b3.33.2026.08.25.20.49.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2026 20:49:08 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][R][PATCH v2 3/5] soundwire: Move wait for initialisation helper to header Date: Wed, 26 Aug 2026 11:48:33 +0800 Message-ID: <20260826034835.661988-4-chris.chiu@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260826034835.661988-1-chris.chiu@canonical.com> References: <20260826034835.661988-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/2164967 As SoundWire devices tend to enumerate on the bus after probe, drivers frequently need to wait for the device to initialise from common driver code. The common system is to split drivers into a core module and then a module for each communication bus. These two facts tend to cause Kconfig issues, the issue tends to be when SOUNDWIRE=m and DRIVER_I2C=y, this usually selects DRIVER=y. The driver code then wants to call sdw_slave_wait_for_init(), but this results in calling a module function from built in code. A depends on SOUNDWIRE | !SOUNDWIRE could be added to the end driver but this seems slightly off as it adds a lot of counter intuitive depends. A simpler solution is to make sdw_slave_wait_for_init() a static inline function. As part of doing this add a check for the slave device being NULL acknowledging that this is likely called from code that is shared between control buses. It does require dropping the call to sdw_show_ping_status() but this can be added back in end drivers that used it originally. Currently this is causing rand config issues on RT5682 and will soon also cause similar problems on cs42l43. Acked-by: Vinod Koul Acked-by: Arnd Bergmann Signed-off-by: Charles Keepax Link: https://patch.msgid.link/20260623101814.24044-2-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown (cherry picked from commit 5714c8359f4fc171ab8e0bd0dfc4c61fb36e1db6) Signed-off-by: Chris Chiu --- drivers/soundwire/bus.c | 30 --------------------------- include/linux/soundwire/sdw.h | 38 +++++++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 38 deletions(-) diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index ea3a24f805c0..e6029a4b6c6f 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -1372,36 +1372,6 @@ int sdw_slave_get_current_bank(struct sdw_slave *slave) } EXPORT_SYMBOL_GPL(sdw_slave_get_current_bank); -/** - * sdw_slave_wait_for_init - Wait for device initialisation - * @slave: Pointer to the SoundWire peripheral. - * @timeout_ms: Timeout in milliseconds. - * - * Wait for a peripheral device to enumerate and be initialised by the - * SoundWire core. - * - * Return: Zero on success, and a negative error code on failure. - */ -int sdw_slave_wait_for_init(struct sdw_slave *slave, int timeout_ms) -{ - unsigned long time; - - if (!slave->unattach_request) - return 0; - - time = wait_for_completion_timeout(&slave->initialization_complete, - msecs_to_jiffies(timeout_ms)); - if (!time) { - dev_err(&slave->dev, "Initialization not complete\n"); - sdw_show_ping_status(slave->bus, true); - return -ETIMEDOUT; - } - - slave->unattach_request = 0; - - return 0; -} -EXPORT_SYMBOL_GPL(sdw_slave_wait_for_init); static int sdw_slave_set_frequency(struct sdw_slave *slave) { diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index e2180afa7f98..ef0d983fc492 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -1093,8 +1094,6 @@ int sdw_slave_get_current_bank(struct sdw_slave *sdev); int sdw_slave_get_scale_index(struct sdw_slave *slave, u8 *base); -int sdw_slave_wait_for_init(struct sdw_slave *slave, int timeout_ms); - /* messaging and data APIs */ int sdw_read(struct sdw_slave *slave, u32 addr); int sdw_write(struct sdw_slave *slave, u32 addr, u8 value); @@ -1138,12 +1137,6 @@ static inline int sdw_slave_get_current_bank(struct sdw_slave *sdev) return -EINVAL; } -static inline int sdw_slave_wait_for_init(struct sdw_slave *slave, int timeout_ms) -{ - WARN_ONCE(1, "SoundWire API is disabled"); - return -EINVAL; -} - /* messaging and data APIs */ static inline int sdw_read(struct sdw_slave *slave, u32 addr) { @@ -1207,4 +1200,33 @@ static inline int sdw_update_no_pm(struct sdw_slave *slave, u32 addr, u8 mask, u #endif /* CONFIG_SOUNDWIRE */ +/** + * sdw_slave_wait_for_init - Wait for device initialisation + * @slave: Pointer to the SoundWire peripheral. + * @timeout_ms: Timeout in milliseconds. + * + * Wait for a peripheral device to enumerate and be initialised by the + * SoundWire core. + * + * Return: Zero on success, and a negative error code on failure. + */ +static inline int sdw_slave_wait_for_init(struct sdw_slave *slave, int timeout_ms) +{ + unsigned long time; + + if (!slave) + return 0; + + time = wait_for_completion_timeout(&slave->initialization_complete, + msecs_to_jiffies(timeout_ms)); + if (!time) { + dev_err(&slave->dev, "Initialization not complete\n"); + return -ETIMEDOUT; + } + + slave->unattach_request = 0; + + return 0; +} + #endif /* __SOUNDWIRE_H */ From patchwork Wed Aug 26 03:48:34 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Chiu X-Patchwork-Id: 2292340 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 4hV9d02R3lz1xtN for ; Wed, 26 Aug 2026 13:49:24 +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 1wz4da-0002Nt-0O; Wed, 26 Aug 2026 03:49:18 +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 1wz4dU-0002HC-GD for kernel-team@lists.ubuntu.com; Wed, 26 Aug 2026 03:49:12 +0000 Received: from mail-yw1-f197.google.com (mail-yw1-f197.google.com [209.85.128.197]) (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 59E0E3F342 for ; Wed, 26 Aug 2026 03:49:12 +0000 (UTC) Received: by mail-yw1-f197.google.com with SMTP id 00721157ae682-836c8fc03a4so15937437b3.1 for ; Tue, 25 Aug 2026 20:49:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787716151; x=1788320951; 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=6xS2FQ5W+WzKSP3E8oehWILyw6hcu5hxvQfxtqISlE8=; b=OACplHrQHRf+gFe1Ry2hvJdosDn6u3tvayJVItnRp7ND4jaLvPGnVDxeyvu1klfkyi 86jlIB9vgjclKiAYv3UOW+wCYg7xzHX44qqO5ZZNdBRbjG1le9MNAGp2O4rCOqRB0wyB 1rkTQaxcmLF8IHRNon72W9lmvjEZcRLV9KWasNv8I04ytEbcMo9GYJ07HsxhNuV7D3JR bg3fFItqF6//3sULHfirn4QT2dUe0mNykveKqde/uod39i3eqhTl1+4DcBpzfzZGPujJ d2zg6EBIQdhsBXUMxMAMmnvVZ/hn/yKbRtXGOwl0veacFx1S0omdlVZGfKJA/ParOgr2 Y46Q== X-Gm-Message-State: AFuF++mlk2Q4oHIiErNUgsV8o9FG86E914MX6/v3VQFh+KTvogOEPwAU GdXMl1/mJ/bgaPQD2RCIlHhjF0yC1N+JyTY08NJ1vAqoyPEIblVD6721+9yd55QhjZvB69BSr+U m4+V/kI4ywd4xybWqQ+FdAu1oPJJYtG+7y/9sVKyeC0Nzi9IbTID6cF+ouHKFGwMmnPbOQ0yY/k XSIWL5W5Jjo1okicJG X-Gm-Gg: AR+sD12EWslkQcBHYdUF4bg443gJbpqsWRwhfv1l4EzNmI4vQ8ostrIdr6NO8mFdh0B keVRRvqMuMW282T0u35rM8wXLuV2AYXSvQD3VLw0ad4OoFyTeevYMn2L2eIDm2OwZnqRVrwes42 J+DuOrkSx/OAjwlnURMN5ZUmLqk31huRndTgHY4+2FYqGLJXvL63uoejKCzIZ1fjHf/wb2su6fc /2Tu7fWQoMaMhXKJWycJpahbaNLRbIPvIyAy8yt4P7EMDP8GFl87gIrZ++fZskzSHxt2EjDUsuk Ng6z1x7FCaAmypbjRXUE3Os4OAdk/eLz0tsl9sSPMHu5m1uydC+tz8lZiP5WyZPVquZuhSfY+P6 CzR6a/K5UGg== X-Received: by 2002:a05:690c:6209:b0:81c:b834:47de with SMTP id 00721157ae682-8573f8d3ee0mr19529157b3.18.1787716151244; Tue, 25 Aug 2026 20:49:11 -0700 (PDT) X-Received: by 2002:a05:690c:6209:b0:81c:b834:47de with SMTP id 00721157ae682-8573f8d3ee0mr19528997b3.18.1787716150914; Tue, 25 Aug 2026 20:49:10 -0700 (PDT) Received: from localhost.localdomain ([2001:67c:1560:8007::aac:c1a2]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8570cd697f4sm9679887b3.33.2026.08.25.20.49.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2026 20:49:10 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][R][PATCH v2 4/5] ASoC: codecs: tas2783-sdw: Propagate regcache_sync() errors Date: Wed, 26 Aug 2026 11:48:34 +0800 Message-ID: <20260826034835.661988-5-chris.chiu@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260826034835.661988-1-chris.chiu@canonical.com> References: <20260826034835.661988-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: Pengpeng Hou BugLink: https://bugs.launchpad.net/bugs/2164967 regcache_sync() can fail while replaying cached register state after SoundWire resume or attach handling. tas2783 currently ignores that failure. Propagate the error and restore cache-only/dirty state on failure. Signed-off-by: Pengpeng Hou Link: https://patch.msgid.link/20260704035746.82560-1-pengpeng@iscas.ac.cn Signed-off-by: Mark Brown (cherry picked from commit 0d6b2d6f93a6715827a9b3c027cd8448d76e0e47) Signed-off-by: Chris Chiu --- sound/soc/codecs/tas2783-sdw.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/tas2783-sdw.c b/sound/soc/codecs/tas2783-sdw.c index 1bc6da668bdc..5c6866f3d3b5 100644 --- a/sound/soc/codecs/tas2783-sdw.c +++ b/sound/soc/codecs/tas2783-sdw.c @@ -1089,7 +1089,13 @@ static s32 tas2783_sdca_dev_resume(struct device *dev) return ret; regcache_cache_only(tas_dev->regmap, false); - regcache_sync(tas_dev->regmap); + ret = regcache_sync(tas_dev->regmap); + if (ret) { + regcache_cache_only(tas_dev->regmap, true); + regcache_mark_dirty(tas_dev->regmap); + return ret; + } + return 0; } @@ -1183,6 +1189,7 @@ static s32 tas_update_status(struct sdw_slave *slave, { struct tas2783_prv *tas_dev = dev_get_drvdata(&slave->dev); struct device *dev = &slave->dev; + int ret; dev_dbg(dev, "Peripheral status = %s", status == SDW_SLAVE_UNATTACHED ? "unattached" : @@ -1200,7 +1207,12 @@ static s32 tas_update_status(struct sdw_slave *slave, /* updated the cache data to device */ regcache_cache_only(tas_dev->regmap, false); - regcache_sync(tas_dev->regmap); + ret = regcache_sync(tas_dev->regmap); + if (ret) { + regcache_cache_only(tas_dev->regmap, true); + regcache_mark_dirty(tas_dev->regmap); + return ret; + } /* perform I/O transfers required for Slave initialization */ return tas_io_init(&slave->dev, slave); From patchwork Wed Aug 26 03:48:35 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Chiu X-Patchwork-Id: 2292341 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 4hV9d05L42z1xxf for ; Wed, 26 Aug 2026 13:49:24 +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 1wz4da-0002OV-88; Wed, 26 Aug 2026 03:49:18 +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 1wz4dX-0002K9-1D for kernel-team@lists.ubuntu.com; Wed, 26 Aug 2026 03:49:15 +0000 Received: from mail-yw1-f200.google.com (mail-yw1-f200.google.com [209.85.128.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-0.canonical.com (Postfix) with ESMTPS id DCD913F342 for ; Wed, 26 Aug 2026 03:49:14 +0000 (UTC) Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-822ce245c5aso15644867b3.1 for ; Tue, 25 Aug 2026 20:49:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787716154; x=1788320954; 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=FN/uqs2xoEzfJHSj1G1XfJmP7xAvluF/gYs0O5NVIeg=; b=hploFJqfIZ/lib/4Ht2fi6SyAVppVwUPmPwW/QO6bwDq8z4H6mB8OehzQAegL3KlXL /fKjOVxh4HD6+EDTANq3itgxONR+ZutuNGAGtShj758nEwN00eEFI37RorbAGoaajqBc hrEm8YzYKQbWUAnRLIPjtjN8of3V6IxPD3aVGUykOWhFiAnfv1yJ48PgnTbnvRWV8XpK BGG6UVmvMEaqvPuH7UxhPqZjjEGwxgLUfkXz/QrYf/7gg1dNsr+lOefC2E1+y7h/6GgV ulzhFioDMzeonu3L9Jqu4/DWegx/rLiaxPncD46xV2z6qW0Mevlke/JnFgMfTToaCvt6 3fbA== X-Gm-Message-State: AFuF++m/P5U5ph+gORph+WYo63K5BMzpbTKf9Js4nvv0VpATJRLCPDvV Zymxkv95uazvuJPb3F4/1yViXmGNyDuZgqcJjuIZr/0pYDvQ9vEyGZeC9c3fbUPzKy4XkvTt+aH 2sV4vXO50vng4GHUHG2I9etGReynm/Faihh9164iVxtnh33sCvKqd8oDL8IzE6s/151qQz92Dc4 X81BDs3fe/wW0ELYk/ X-Gm-Gg: AR+sD11lKscAKeHhQAFdkWVPt5F6Ul7zMYnXwmIxbMn++paU0agiOGYuW1mOO9pDSG7 xzb38hE0HjsDFyE5Bt+RdQ5W45HnnPzjAxWBpZe5ZKVreqHwyYOOqAGtJ2fkYzQeiaiAV2BT9AN eU9qLx4nwMB2JrRugMBEDYokqz6KmofpjljmpH8ijfv+RSOv/xmdD0zOVfn8RLJneW87eoPcP5+ Y5MWLdtTem54GQNyhkUPZTok7Gl6qOXxnYev9iOGILM+eWUPxEOfkENJrN+oZ70A4A/taZ2f2/v 62d+e1zd7diDg93qD0g9cc6TFLROypAsIeRz2Rv43t8InPBwL62g4joal7QaLdIwyoVDv5eGmyA Bqm7oCheClg== X-Received: by 2002:a05:690c:6e83:b0:854:4ed4:c1b4 with SMTP id 00721157ae682-857477a3744mr16806557b3.18.1787716153708; Tue, 25 Aug 2026 20:49:13 -0700 (PDT) X-Received: by 2002:a05:690c:6e83:b0:854:4ed4:c1b4 with SMTP id 00721157ae682-857477a3744mr16806417b3.18.1787716153224; Tue, 25 Aug 2026 20:49:13 -0700 (PDT) Received: from localhost.localdomain ([2001:67c:1560:8007::aac:c1a2]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8570cd697f4sm9679887b3.33.2026.08.25.20.49.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2026 20:49:12 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][R][PATCH v2 5/5] ASoC: tas2783-sdw: drop stale regcache on uninitialized re-attach Date: Wed, 26 Aug 2026 11:48:35 +0800 Message-ID: <20260826034835.661988-6-chris.chiu@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260826034835.661988-1-chris.chiu@canonical.com> References: <20260826034835.661988-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: Andrey Golovko BugLink: https://bugs.launchpad.net/bugs/2164967 When the peripheral re-attaches after the SoundWire controller was power-gated during system suspend (s2idle reaching S0i3 on AMD ACP), the amplifier has lost all of its register and DSP state. tas_update_status() handles that by re-running tas_io_init(), which writes the device's TAS2783_SW_RESET register - a vendor register write that clears the device's register file and DSP state, not a SoundWire reset, so no re-enumeration is involved - and re-downloads the firmware. Before doing any of that, it syncs back a register cache that still holds the pre-suspend values. That sync is useless, since the reset immediately wipes whatever it wrote, and it leaves the cache claiming that the amplifier is already powered up and unmuted. Subsequent read-modify-write updates - DAPM amplifier power-up, SDCA PDE transitions at stream start - then see "no change" and skip the hardware write. Playback runs without a single error while the speakers stay silent. Unbinding and rebinding the driver restores audio, since probe starts from a fresh cache. Drop the cache instead of syncing it when an uninitialized device attaches, so that later accesses see the real hardware state. Reordering the sync after tas_io_init() and marking the cache dirty is not a workable alternative here: tas_regmap has no .writeable_reg, so the cache accepts every register up to .max_register, including ones for which tas2783_sdca_mbq_size() returns 0. regmap_sdw_mbq_size() rejects those with -EINVAL, so the replay fails on the first such register and takes initialization down with it. Cached user settings fall back to hardware defaults across such a power loss, which seems clearly preferable to a silent amplifier - the device is being reset and its firmware reloaded at this point anyway. Tested on an ASUS ProArt PX13 HN7306EAC (AMD Strix Halo, ACP7.0, two TAS2783 amplifiers plus RT721 on SoundWire link 1): the speakers work after an s2idle resume with ~51 s of S0i3 residency, where previously they stayed silent despite a complete firmware re-download. Fixes: 4cc9bd8d7b32 ("ASoc: tas2783A: Add soundwire based codec driver") Reported-by: Antoine Monnet Closes: https://lore.kernel.org/all/c66ae00a-e878-4af0-a05a-272e9574eaa5@montane.tech/ Signed-off-by: Andrey Golovko Link: https://patch.msgid.link/3e2751d1fb027bed0f09c88e5e56da8f@gmail.com Signed-off-by: Mark Brown (cherry picked from commit b627da43035744ca4d691fbf56eef60268319873 linux-next) Signed-off-by: Chris Chiu --- sound/soc/codecs/tas2783-sdw.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/sound/soc/codecs/tas2783-sdw.c b/sound/soc/codecs/tas2783-sdw.c index 5c6866f3d3b5..adeb01ac805e 100644 --- a/sound/soc/codecs/tas2783-sdw.c +++ b/sound/soc/codecs/tas2783-sdw.c @@ -1189,7 +1189,6 @@ static s32 tas_update_status(struct sdw_slave *slave, { struct tas2783_prv *tas_dev = dev_get_drvdata(&slave->dev); struct device *dev = &slave->dev; - int ret; dev_dbg(dev, "Peripheral status = %s", status == SDW_SLAVE_UNATTACHED ? "unattached" : @@ -1205,14 +1204,23 @@ static s32 tas_update_status(struct sdw_slave *slave, if (tas_dev->hw_init || tas_dev->status != SDW_SLAVE_ATTACHED) return 0; - /* updated the cache data to device */ regcache_cache_only(tas_dev->regmap, false); - ret = regcache_sync(tas_dev->regmap); - if (ret) { - regcache_cache_only(tas_dev->regmap, true); - regcache_mark_dirty(tas_dev->regmap); - return ret; - } + + /* + * The device is attaching uninitialized: either this is the first + * attach, or it lost power (and with it all register and DSP state) + * while the controller was power-gated during system suspend. The + * cache still holds the pre-suspend values, and tas_io_init() below + * resets the device via TAS2783_SW_RESET anyway, so syncing it back + * is both useless and harmful: later read-modify-write updates would + * compare against stale data and skip the hardware write. + * + * Drop the cache instead, so that subsequent accesses see the real + * hardware state. Syncing after the reset is not an option either: + * the cache accepts registers for which tas2783_sdca_mbq_size() + * returns 0, and writing those back fails with -EINVAL. + */ + regcache_drop_region(tas_dev->regmap, 0, UINT_MAX); /* perform I/O transfers required for Slave initialization */ return tas_io_init(&slave->dev, slave);