Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp4069343rdb; Wed, 30 Aug 2023 14:48:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFm4AzWAxSPrGRVgyZFgwt8Y804sHfI4qc2bPiUv+LAR2bdouNolTGZ07MQ+q7M3cQT8vXQ X-Received: by 2002:a17:90b:1b0f:b0:271:9a75:6cda with SMTP id nu15-20020a17090b1b0f00b002719a756cdamr3180967pjb.14.1693432091043; Wed, 30 Aug 2023 14:48:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693432091; cv=none; d=google.com; s=arc-20160816; b=kDVewB5ixgSMBiCcr8y+aCue8clwuVQ26T5ldJS5YicKi3A1PWQyipS0ZkBf11Plxb PDokW/T8kitajm5Ckks86qJIcazZ0PQtN16wAosOZMbwcH+QnCFhUZa5OSjjBqRhItJN NHDd+/0ZBQWNwggdqry5sv/ckkVGH8msIcEoAruUzmzE30LzqA7eZ2xdVy0y3pDrvqWf eB7jWxc3LHQtRGqeOs2mpKmzYgk0+rgrcTokkM9nnqer90ZUeHgPg/XvCocLrZ5IHo63 /LSgDqd7JBcxGHNmTnnT9My7dz9Iq6JMGGrXejRnW+L4fnYtnPnN4TZzWgg6KOCvUsbk bUFA== 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=dgcyuYQ/SL4nBseP/QRgdQlzwlk1hY55WbkwPJ94Tgs=; fh=gSlqDyTAaX4sD5o7lNdgN6GT1mkO6Z4/Ye0T8jAhwnM=; b=Qg1CI9STuF4WwqaxxaNX4kWlBKQBHxqJbGDyvd6w9E4nqgsCKFJ1ntdqZ99a7amafO yfTiLE4COqeIW0Sxdq7d8Bxcp3Cd3vOjkochW9EvGqUqQlrRAdAczTW9nDLCvwAjMzE9 /muoeHJvFM4JDNc+5BAbRE9FOIL8t0XYDHVj30+7s9JDUgU2DSe/l/J3Zio1iOMyk+d4 BkEpB0Wgf6EJ8uMQLp3kOiv8SWT2mpxt6Pf8piKNWH8aMfglbrrxgE0WKtpRS69NrPKa K8uqWksZ73wdihfI+u9mKvoSQnuYG/mvXF1zwQBTja3+WsHhXQVHip6b0zx1Depsyfzj 2Duw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mq12-20020a17090b380c00b0026359a2e980si2894336pjb.21.2023.08.30.14.47.55; Wed, 30 Aug 2023 14:48:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230166AbjH3S56 (ORCPT + 99 others); Wed, 30 Aug 2023 14:57:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245571AbjH3PhL (ORCPT ); Wed, 30 Aug 2023 11:37:11 -0400 Received: from mblankhorst.nl (lankhorst.se [IPv6:2a02:2308:0:7ec:e79c:4e97:b6c4:f0ae]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 679EC122 for ; Wed, 30 Aug 2023 08:37:07 -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 v4 01/11] ASoC: SOF: core: add 'no_wq' probe and remove callbacks Date: Wed, 30 Aug 2023 17:36:42 +0200 Message-Id: <20230830153652.217855-2-maarten.lankhorst@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230830153652.217855-1-maarten.lankhorst@linux.intel.com> References: <20230830153652.217855-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 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. Note that instead of probe_no_wq/probe we could have use a more self-explanatory naming such as probe/probe_wq_allowed, but that would have been a very intrusive change. Signed-off-by: Pierre-Louis Bossart Signed-off-by: Maarten Lankhorst --- sound/soc/sof/core.c | 11 +++++++++-- sound/soc/sof/ops.h | 16 ++++++++++++++++ sound/soc/sof/sof-priv.h | 2 ++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 30db685cc5f4b..54c384a5d6140 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -327,8 +327,6 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) dsp_err: snd_sof_remove(sdev); probe_err: - sof_ops_free(sdev); - /* all resources freed, update state to match */ sof_set_fw_state(sdev, SOF_FW_BOOT_NOT_STARTED); sdev->first_boot = true; @@ -436,6 +434,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_no_wq(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,6 +493,7 @@ int snd_sof_device_remove(struct device *dev) snd_sof_free_debug(sdev); snd_sof_remove(sdev); } + snd_sof_remove_no_wq(sdev); sof_ops_free(sdev); diff --git a/sound/soc/sof/ops.h b/sound/soc/sof/ops.h index 9ab7b9be765bc..2a03b152e9313 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_no_wq(struct snd_sof_dev *sdev) +{ + if (sof_ops(sdev)->probe_no_wq) + return sof_ops(sdev)->probe_no_wq(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_no_wq(struct snd_sof_dev *sdev) +{ + if (sof_ops(sdev)->remove_no_wq) + return sof_ops(sdev)->remove_no_wq(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..addaef282ee92 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -165,6 +165,8 @@ struct sof_firmware { struct snd_sof_dsp_ops { /* probe/remove/shutdown */ + int (*probe_no_wq)(struct snd_sof_dev *sof_dev); /* optional */ + int (*remove_no_wq)(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 (*shutdown)(struct snd_sof_dev *sof_dev); /* optional */ -- 2.39.2