Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1839582rdb; Mon, 9 Oct 2023 04:57:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFd8t3jppuv9zGkvhs6fl/GY0xbJtKZdm4Yil+EcTzZH1l1nz00ztcfLK3GT8cytWfduG88 X-Received: by 2002:a17:90a:94c8:b0:274:bdcc:85b1 with SMTP id j8-20020a17090a94c800b00274bdcc85b1mr16966186pjw.12.1696852620092; Mon, 09 Oct 2023 04:57:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696852620; cv=none; d=google.com; s=arc-20160816; b=i3xYVX0hUO2S0ZQ9JN5HDaM0xstCSFhYAAxdQQo0EJKd08YF6lzxIYiIkgo3uZGgla 8Po9B0WIkJ2oVyBFpowcRcczceaj03uejynhTmb46wIe8ALvrOxbBZurNmzeqvjy5Kw/ Tm338XOybHrLXOY8sR8jtdLjWtL33LFvXIFZkD+237MYe/aQE48vtyJ4mQJE7bXPRxKO O7E67WUd9DjrArLFjk7bKbsPv74+04G/NGfoBvlrmt3+bIcgRGdw/nO3vfvCoWrSkWAE muvQ8Kh4W07bCsGr7pdngSlaPDYb94eVZx5HrrgGTWZsWjK0KZiBG5659qDupW1GyVFi BKIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=zTJ25hZ/1QfYA1oC1Yig9/JAgza+UinNvASqI/EbiYU=; fh=gSlqDyTAaX4sD5o7lNdgN6GT1mkO6Z4/Ye0T8jAhwnM=; b=Ei+mcyTXgQNrJtIwXGA8ObJYKjYSUF2tNyaFebZa/6RnbHnZRzY6Hw6pesb+0GDJTp y45STw0k8AMdk2YLfkjQOmrZnSKUO9IEE0FqppvKcgGfqQrPZ19YhRCdnX5J5BgPvi0f xriRp3hdsGlFmPz5xcAfsFCJpOU70K5Yv0KqyfGOmPPoTfyNr56TU9kjMhw7IQe2gzCb iSnkBNkcR6qyc5JKspVn3lVwHrwu7NLNxPxE++Pe3Qd44OyPhfX6GCzKRp0ptQ88eyoZ LGUo3IwtNr00FDDMAMF4/LMzH6Dlw9oUy55CchM8ks5LQFP5lcduFmhEDfO2za8i1OhE eW0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id q141-20020a632a93000000b00578e2b20624si9426855pgq.72.2023.10.09.04.56.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 04:57:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id D2EE3807CF78; Mon, 9 Oct 2023 04:55:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346372AbjJILyt (ORCPT + 99 others); Mon, 9 Oct 2023 07:54:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346354AbjJILyr (ORCPT ); Mon, 9 Oct 2023 07:54:47 -0400 Received: from mblankhorst.nl (lankhorst.se [IPv6:2a02:2308:0:7ec:e79c:4e97:b6c4:f0ae]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD71DAF for ; Mon, 9 Oct 2023 04:54:45 -0700 (PDT) From: Maarten Lankhorst To: alsa-devel@alsa-project.org Cc: Maarten Lankhorst , Jaroslav Kysela , Takashi Iwai , Cezary Rojewski , Pierre-Louis Bossart , Liam Girdwood , Peter Ujfalusi , Bard Liao , Ranjani Sridharan , Kai Vehmanen , Mark Brown , Daniel Baluta , linux-kernel@vger.kernel.org, sound-open-firmware@alsa-project.org Subject: [PATCH v7 02/13] ASoC: SOF: core: Add probe_early and remove_late callbacks Date: Mon, 9 Oct 2023 13:54:26 +0200 Message-Id: <20231009115437.99976-3-maarten.lankhorst@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231009115437.99976-1-maarten.lankhorst@linux.intel.com> References: <20231009115437.99976-1-maarten.lankhorst@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 09 Oct 2023 04:55:34 -0700 (PDT) X-Spam-Level: ** From: Pierre-Louis Bossart The existing DSP probe may be handled in a workqueue to allow for extra time, typically for the i915 request_module and HDAudio codec handling. With the upcoming changes for i915/Xe driver relying on the -EPROBE_DEFER mechanism, we need to have a first pass of the probe which cannot be pushed to a workqueue. Introduce 2 new optional callbacks. probe_early is called before the workqueue runs. remove_late may be called from the workqueue if load is unsuccesful, but will otherwise be called on module unload. Signed-off-by: Pierre-Louis Bossart Signed-off-by: Maarten Lankhorst Acked-by: Mark Brown --- sound/soc/sof/core.c | 11 +++++++++++ sound/soc/sof/ops.h | 16 ++++++++++++++++ sound/soc/sof/sof-priv.h | 2 ++ 3 files changed, 29 insertions(+) diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 0938b259f7034..d7b090224f1b9 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -327,6 +327,7 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) dsp_err: snd_sof_remove(sdev); probe_err: + snd_sof_remove_late(sdev); sof_ops_free(sdev); /* all resources freed, update state to match */ @@ -436,6 +437,14 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data) sof_set_fw_state(sdev, SOF_FW_BOOT_NOT_STARTED); + /* + * first pass of probe which isn't allowed to run in a work-queue, + * typically to rely on -EPROBE_DEFER dependencies + */ + ret = snd_sof_probe_early(sdev); + if (ret < 0) + return ret; + if (IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE)) { INIT_WORK(&sdev->probe_work, sof_probe_work); schedule_work(&sdev->probe_work); @@ -487,9 +496,11 @@ int snd_sof_device_remove(struct device *dev) snd_sof_ipc_free(sdev); snd_sof_free_debug(sdev); snd_sof_remove(sdev); + snd_sof_remove_late(sdev); sof_ops_free(sdev); } else if (aborted) { /* probe_work never ran */ + snd_sof_remove_late(sdev); sof_ops_free(sdev); } diff --git a/sound/soc/sof/ops.h b/sound/soc/sof/ops.h index 9ab7b9be765bc..3ebcfc2373854 100644 --- a/sound/soc/sof/ops.h +++ b/sound/soc/sof/ops.h @@ -38,6 +38,14 @@ static inline void sof_ops_free(struct snd_sof_dev *sdev) /* Mandatory operations are verified during probing */ /* init */ +static inline int snd_sof_probe_early(struct snd_sof_dev *sdev) +{ + if (sof_ops(sdev)->probe_early) + return sof_ops(sdev)->probe_early(sdev); + + return 0; +} + static inline int snd_sof_probe(struct snd_sof_dev *sdev) { return sof_ops(sdev)->probe(sdev); @@ -51,6 +59,14 @@ static inline int snd_sof_remove(struct snd_sof_dev *sdev) return 0; } +static inline int snd_sof_remove_late(struct snd_sof_dev *sdev) +{ + if (sof_ops(sdev)->remove_late) + return sof_ops(sdev)->remove_late(sdev); + + return 0; +} + static inline int snd_sof_shutdown(struct snd_sof_dev *sdev) { if (sof_ops(sdev)->shutdown) diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index d4f6702e93dcb..e73a92189fe1f 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -165,8 +165,10 @@ struct sof_firmware { struct snd_sof_dsp_ops { /* probe/remove/shutdown */ + int (*probe_early)(struct snd_sof_dev *sof_dev); /* optional */ int (*probe)(struct snd_sof_dev *sof_dev); /* mandatory */ int (*remove)(struct snd_sof_dev *sof_dev); /* optional */ + int (*remove_late)(struct snd_sof_dev *sof_dev); /* optional */ int (*shutdown)(struct snd_sof_dev *sof_dev); /* optional */ /* DSP core boot / reset */ -- 2.39.2