Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2662209rdb; Wed, 4 Oct 2023 07:56:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEKc4TmUadrYdDSPZaHWsUW37ZTBZMvgPXmrOgRX06jTsX9gJK0wMWXjrERnB6I/ZjRomH4 X-Received: by 2002:a17:90b:388b:b0:274:638d:da9a with SMTP id mu11-20020a17090b388b00b00274638dda9amr2423693pjb.34.1696431398156; Wed, 04 Oct 2023 07:56:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696431398; cv=none; d=google.com; s=arc-20160816; b=F/Qr1TI5lx6ZVAX1QGkEbbjloHIVIRXu4NkQpNRczOVdWc4Em+zelYjnkP/q+hv+DI AbSh+4Gi6ANvaU5TUQUloX2QHB9RPllmCzpQcXrbUFO4r8SgpG7c9k71TvKG1hda5hzf NfbR/fn8VxbzwFR550pVeBMVChfhUHmSq8Ct2Cs1gziNHVj1g1Nzzq+c3iLxbjIq83I1 lgbK4q0xywDRTOmb3dHo8BuMX987qnqBCpejKrF45+PTLIzO7WHoGrOuvHzZQKLUdy6o jZTX682TJIaCPoKTCwi7C1mOnp9hi1mAkTxZSHZpkaEKbsiY7D/LOMbuBN8+Jvto6SOg b93w== 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=i/wyHasxaLP7s6PdtVlpQP/Z8UiU1mjXNifiHqnzSS8=; fh=0mMpxRNGS8aKy23RZ2IZ2zab2b7WVFRF3E4ptf/UEH4=; b=Q6zPDsXEJybbIkWsGiqcLS+y0tZIjT9IqFKEzZnDRVuoadlwf4inPEV/7CzbmYz9bj 0FPzZDH6jmXIEU5EJbrgGSYqrmyBHH0xsFDJUxt9S8bUVAOykfHTy5CeUwvVZsfhm49C fVV9l1tunfl4HKg12+ODBjvLUDE2w+8+LV1IA1SFK+rSEBQun96K3fjwLFTahcie4WeM myocOt9spuDdOajp71ro8Sc8k2ZqOJ0PKYlwWn98O3J6zz4+tESR+rZNMwKiq/o/a18w NqkQjUUP93fbdcpGkPIx0Cu7bFzw7MIciCJ1WDQUv0hxK7+lRNoCOQEO38SLxF4E9Zu0 4fuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id e4-20020a17090ab38400b0027652885184si1584745pjr.91.2023.10.04.07.56.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 07:56:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id D24CE820E50B; Wed, 4 Oct 2023 07:56:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243026AbjJDO4L (ORCPT + 99 others); Wed, 4 Oct 2023 10:56:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243007AbjJDO4H (ORCPT ); Wed, 4 Oct 2023 10:56:07 -0400 Received: from mblankhorst.nl (lankhorst.se [IPv6:2a02:2308:0:7ec:e79c:4e97:b6c4:f0ae]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED9D5CE for ; Wed, 4 Oct 2023 07:56:01 -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, Maarten Lankhorst Subject: [PATCH v6 02/12] ASoC: SOF: core: Add probe_early and remove_late callbacks Date: Wed, 4 Oct 2023 16:55:30 +0200 Message-Id: <20231004145540.32321-3-maarten.lankhorst@linux.intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231004145540.32321-1-maarten.lankhorst@linux.intel.com> References: <20231004145540.32321-1-maarten.lankhorst@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 04 Oct 2023 07:56:37 -0700 (PDT) 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 0938b259f703..d7b090224f1b 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 9ab7b9be765b..3ebcfc237385 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 d4f6702e93dc..e73a92189fe1 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.40.1