From patchwork Wed May 31 03:37:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 688288 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 35A43C7EE23 for ; Wed, 31 May 2023 03:17:47 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id DEE3383A; Wed, 31 May 2023 05:16:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DEE3383A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685503065; bh=GccidoCGBBrPr39HCfpwoXhpbs9LH6bwAbwZCyps1i8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=LjUlIQsZoc8KIn0HMDYI8UWE1PSYAv5NkJH62wU4vtDWdydrT7g8AOm2fWzkDf5oC qRMdyJ/EVaTt5DM/kqMNjLDN6wWupchu1CBsEFlewEbnjwOtlUkB7ulc4iw/jB9h8L Q1IiP43xwzuczNvAR+62mattyOe2KwhGB1FgZmB0= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 763FEF80558; Wed, 31 May 2023 05:16:09 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id D28C4F80564; Wed, 31 May 2023 05:16:08 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C3517F80086; Wed, 31 May 2023 05:16:02 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 119C6F80086 for ; Wed, 31 May 2023 05:15:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 119C6F80086 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=T7Pm8uTT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685502942; x=1717038942; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GccidoCGBBrPr39HCfpwoXhpbs9LH6bwAbwZCyps1i8=; b=T7Pm8uTTs+cb9ETeOqpeIG2IPSYjA5CxEPjI9G7aYvw46VO2QvB8+30P fRK84xxLe3KIRdxr5EUowEh6Yg15H90/8cU5P3wXwA6AW7JdjV7FLG+lJ T6GCt8byy+Cq1Xl8fzWG+6QXC+YYR4O6Wkr2LKr4o72L4TeLChpb+2A9w 455ej+yJb4u5jlsyBmYq/kaCiiZ2/imlxekgSLpm8L4Ej9cremZUMgKRa 58zTEJMiz3cHfiISOIIHTIas3johhomfJnOdX4rFYp8+fUFNLlQYsUMX6 qMud4cspzCCCIPybq4anqVWL0DxITXo1LmWKtd6sygWi78vCrrJ5TUddY Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="357507656" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="357507656" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2023 20:15:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="739769481" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="739769481" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2023 20:15:34 -0700 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com Subject: [PATCH 1/4] soundwire: add enum to control device number allocation Date: Wed, 31 May 2023 11:37:33 +0800 Message-Id: <20230531033736.792464-2-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230531033736.792464-1-yung-chuan.liao@linux.intel.com> References: <20230531033736.792464-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: G6QBNUJJROXTX6MFOWESUQ2MITAGCVYX X-Message-ID-Hash: G6QBNUJJROXTX6MFOWESUQ2MITAGCVYX X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Pierre-Louis Bossart Commit c60561014257 ("soundwire: bus: allow device number to be unique at system level") introduced two strategies to allocate device numbers. a) a default unconstrained allocation, where each bus can allocate Device Numbers independently. b) an ida-based allocation. In this case each Device Number will be unique at the system-level. The IDA-based allocation is useful to simplify debug, but it was also introduced as a prerequisite to deal with the Intel Lunar Lake hardware programming sequences: the wake-ups have to be handled with a system-unique SDI address at the HDaudio controller level. At the time, the restriction introduced by the IDA to 8 devices total seemed perfectly fine, but recently hardware vendors created configurations with more than 8 devices. This patch provides an iso-functionality change, with the allocation selected with an enum instead of an 'ida_min' value. Follow-up patches will add a new allocation strategy to allow for more than 8 devices using information on the type of devices, and only use the IDA-based allocation for devices capable of generating a wake. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Signed-off-by: Bard Liao --- drivers/soundwire/bus.c | 4 ++-- drivers/soundwire/intel_auxdevice.c | 1 + include/linux/soundwire/sdw.h | 16 +++++++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index b44f8d0affa6..e8c1c55a2a73 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -159,7 +159,7 @@ static int sdw_delete_slave(struct device *dev, void *data) if (slave->dev_num) { /* clear dev_num if assigned */ clear_bit(slave->dev_num, bus->assigned); - if (bus->dev_num_ida_min) + if (bus->dev_num_alloc == SDW_DEV_NUM_ALLOC_IDA) ida_free(&sdw_peripheral_ida, slave->dev_num); } list_del_init(&slave->node); @@ -701,7 +701,7 @@ static int sdw_get_device_num(struct sdw_slave *slave) { int bit; - if (slave->bus->dev_num_ida_min) { + if (slave->bus->dev_num_alloc == SDW_DEV_NUM_ALLOC_IDA) { bit = ida_alloc_range(&sdw_peripheral_ida, slave->bus->dev_num_ida_min, SDW_MAX_DEVICES, GFP_KERNEL); diff --git a/drivers/soundwire/intel_auxdevice.c b/drivers/soundwire/intel_auxdevice.c index 0daa6ca9a224..30f3d2ab80fd 100644 --- a/drivers/soundwire/intel_auxdevice.c +++ b/drivers/soundwire/intel_auxdevice.c @@ -165,6 +165,7 @@ static int intel_link_probe(struct auxiliary_device *auxdev, cdns->msg_count = 0; bus->link_id = auxdev->id; + bus->dev_num_alloc = SDW_DEV_NUM_ALLOC_IDA; bus->dev_num_ida_min = INTEL_DEV_NUM_IDA_MIN; bus->clk_stop_timeout = 1; diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index c076a3f879b3..4656d6d0f3bb 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -864,6 +864,17 @@ struct sdw_master_ops { void (*new_peripheral_assigned)(struct sdw_bus *bus, int dev_num); }; +/** + * enum sdw_dev_num_alloc - Device Number allocation strategies + * @SDW_DEV_NUM_ALLOC_DEFAULT: unconstrained first-come-first-serve allocation, + * using range [1, 11] + * @SDW_DEV_NUM_ALLOC_IDA: IDA-based allocation, using range [ida_min, 11] + */ +enum sdw_dev_num_alloc { + SDW_DEV_NUM_ALLOC_DEFAULT = 0, + SDW_DEV_NUM_ALLOC_IDA, +}; + /** * struct sdw_bus - SoundWire bus * @dev: Shortcut to &bus->md->dev to avoid changing the entire code. @@ -895,9 +906,11 @@ struct sdw_master_ops { * meaningful if multi_link is set. If set to 1, hardware-based * synchronization will be used even if a stream only uses a single * SoundWire segment. + * @dev_num_alloc: bus-specific device number allocation * @dev_num_ida_min: if set, defines the minimum values for the IDA * used to allocate system-unique device numbers. This value needs to be - * identical across all SoundWire bus in the system. + * identical across all SoundWire bus in the system. Only used if @sdw_num_alloc + * is not default. */ struct sdw_bus { struct device *dev; @@ -922,6 +935,7 @@ struct sdw_bus { u32 bank_switch_timeout; bool multi_link; int hw_sync_min_links; + enum sdw_dev_num_alloc dev_num_alloc; int dev_num_ida_min; }; From patchwork Wed May 31 03:37:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 687331 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0B055C77B7C for ; Wed, 31 May 2023 03:17:42 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id ABC63826; Wed, 31 May 2023 05:16:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz ABC63826 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685503060; bh=cDPxAfvdGUM1tm5hvXaDY204P9qt4B3UxsBRfKyYP3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=K3yQX2CuZuuCrb2Iul1xYp0oDkq/HKqPX3vJjORgl4EFpJcu+suTY0rOS7DIIU9LC bzA4AWM7UCi73wb1AkgwzAhz3LDsHR1CxxoaZblBzkFbtCi+s/eTFXnoP/pitdKTz9 pXpapbdCWisALPElXfTTAznLSPlJxN5MsSif3qEg= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 323EAF80567; Wed, 31 May 2023 05:16:03 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id DD574F80557; Wed, 31 May 2023 05:16:01 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4EB2DF80528; Wed, 31 May 2023 05:15:55 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3E546F8026A for ; Wed, 31 May 2023 05:15:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3E546F8026A Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=E8cW8vR4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685502943; x=1717038943; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cDPxAfvdGUM1tm5hvXaDY204P9qt4B3UxsBRfKyYP3M=; b=E8cW8vR4L5BAtmkJt6TAfIuxQTEPQIJ4ok5sGTKQ8m+CVpXo4/Jz8APq RrHNxhRctM3maKXMkteUcSXIL+wsSxnLdfosJlbXyOBs0zFeTUujHIeA7 4EEy/kDPUwImbSxHNSPLHp+eHeZiSc1ajnGylkiZULI3KoXrEZ8HE5lUj 1HebgK25eeDNpsTkn111f4suGPSiH62jCsHxUCWTQOBLW6AA+JHrKCoth AOAehOaa4lbiUKGuyxnpclw2qpWvem8vDBSN3WhUZvAXdd076+R9EUtyH GxcNSAkELT/Fccis/wcr/eMT1pZyHdW36BW63ffPghu9iFzhMMXEXhbsn g==; X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="357507662" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="357507662" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2023 20:15:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="739769514" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="739769514" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2023 20:15:36 -0700 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com Subject: [PATCH 2/4] soundwire: introduce SDW_DEV_NUM_ALLOC_IDA_WAKE_ONLY Date: Wed, 31 May 2023 11:37:34 +0800 Message-Id: <20230531033736.792464-3-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230531033736.792464-1-yung-chuan.liao@linux.intel.com> References: <20230531033736.792464-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: OIHP6MIO5EAQUOQR7HF4PM7KGHYF5COF X-Message-ID-Hash: OIHP6MIO5EAQUOQR7HF4PM7KGHYF5COF X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Pierre-Louis Bossart This patch adds a new Device Number allocation strategy, with the IDA used only for devices that are wake-capable. "regular" devices such as amplifiers will use Device Numbers [1..min_ida-1]. "wake-capable" devices such as jack or microphone codecs will use Device Numbers [min_ida..11]. This hybrid strategy extends the number of supported devices in a system by only constraining the allocation if required, e.g. in the case of Intel LunarLake platforms the wake-capable devices are required to have a unique address to use the HDaudio SDI and HDAudio WAKEEN/WAKESTS registers. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Signed-off-by: Bard Liao --- drivers/soundwire/bus.c | 26 +++++++++++++++++++++----- include/linux/soundwire/sdw.h | 4 ++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index e8c1c55a2a73..6f465cce8369 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -159,7 +159,9 @@ static int sdw_delete_slave(struct device *dev, void *data) if (slave->dev_num) { /* clear dev_num if assigned */ clear_bit(slave->dev_num, bus->assigned); - if (bus->dev_num_alloc == SDW_DEV_NUM_ALLOC_IDA) + if (bus->dev_num_alloc == SDW_DEV_NUM_ALLOC_IDA || + (bus->dev_num_alloc == SDW_DEV_NUM_ALLOC_IDA_WAKE_ONLY && + slave->prop.wake_capable)) ida_free(&sdw_peripheral_ida, slave->dev_num); } list_del_init(&slave->node); @@ -699,17 +701,31 @@ EXPORT_SYMBOL(sdw_compare_devid); /* called with bus_lock held */ static int sdw_get_device_num(struct sdw_slave *slave) { + struct sdw_bus *bus = slave->bus; int bit; - if (slave->bus->dev_num_alloc == SDW_DEV_NUM_ALLOC_IDA) { + if (bus->dev_num_alloc == SDW_DEV_NUM_ALLOC_IDA || + (bus->dev_num_alloc == SDW_DEV_NUM_ALLOC_IDA_WAKE_ONLY && + slave->prop.wake_capable)) { bit = ida_alloc_range(&sdw_peripheral_ida, - slave->bus->dev_num_ida_min, SDW_MAX_DEVICES, + bus->dev_num_ida_min, SDW_MAX_DEVICES, GFP_KERNEL); if (bit < 0) goto err; } else { - bit = find_first_zero_bit(slave->bus->assigned, SDW_MAX_DEVICES); - if (bit == SDW_MAX_DEVICES) { + int max_devices = SDW_MAX_DEVICES; + + if (bus->dev_num_alloc == SDW_DEV_NUM_ALLOC_IDA_WAKE_ONLY && + !slave->prop.wake_capable) { + max_devices = bus->dev_num_ida_min - 1; + + /* range check */ + if (max_devices < 1 || max_devices > SDW_MAX_DEVICES) + return -EINVAL; + } + + bit = find_first_zero_bit(bus->assigned, max_devices); + if (bit == max_devices) { bit = -ENODEV; goto err; } diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index 4656d6d0f3bb..8a7541ac735e 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -869,10 +869,14 @@ struct sdw_master_ops { * @SDW_DEV_NUM_ALLOC_DEFAULT: unconstrained first-come-first-serve allocation, * using range [1, 11] * @SDW_DEV_NUM_ALLOC_IDA: IDA-based allocation, using range [ida_min, 11] + * @SDW_DEV_NUM_ALLOC_IDA_WAKE_ONLY: Hybrid allocation where wake-capable devices rely on + * IDA-based allocation and range [ida_min, 11], while regular devices rely on default + * allocation in range [1, ida_min - 1] */ enum sdw_dev_num_alloc { SDW_DEV_NUM_ALLOC_DEFAULT = 0, SDW_DEV_NUM_ALLOC_IDA, + SDW_DEV_NUM_ALLOC_IDA_WAKE_ONLY, }; /** From patchwork Wed May 31 03:37:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 687330 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 02769C77B73 for ; Wed, 31 May 2023 03:18:09 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id CF1D2846; Wed, 31 May 2023 05:17:17 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CF1D2846 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685503087; bh=1MyuBzg/rXNODw6gij/Uy3ks1qAp9FzmB1Vw7BzGHV8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=XueYicxwF+zPA8HFa7uF4J7O0r3yc3btFFp+gZUjvo/XEkq6KAwJiI5nUk1HBk58B XF/Je77avVXbS0RWVemrz1D1SmMLOZCvSLdXvYfexxjK7ma3UKPbeWs+Yjtq6BUicN pGJOTMMJZAN/RK596Y08SJmI20/fVyJReofOmww8= Received: by alsa1.perex.cz (Postfix, from userid 50401) id F0AA6F8057D; Wed, 31 May 2023 05:16:11 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 7CAB9F8057C; Wed, 31 May 2023 05:16:11 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5CE4AF80564; Wed, 31 May 2023 05:16:05 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 1D5E4F8042F for ; Wed, 31 May 2023 05:15:42 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1D5E4F8042F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=C0FZKLxA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685502944; x=1717038944; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1MyuBzg/rXNODw6gij/Uy3ks1qAp9FzmB1Vw7BzGHV8=; b=C0FZKLxAwHTjOIQ3QMuj2C7157h0y3TXm3Am8A04PVy2eVwQjTV3pKZZ zOlJhqqHzbJIA2NK88Q2HKZ+qaAli/zoojVIc++acSDogQrbT0YDsiCAP +Z2SF/5o6Jg1uT0zp/AiDmDy5cS6SIMpgXZvwmxeEHedSbp72GIro7WIM WJnLPRcK+7J2QiipL6zMRVyauF+6hzsBQffC9NXbZT3/h7tEwjomVrheg UW3LoJlsjG/2WgRXIpflL8g64SyZFjlX5m3x6As0KrWyR+EKmmWUfuv62 uDIk80IV8YnrSovSwO6wR29iELU9BJVykk7/mxAPtKCiTR/tczRTZkH5i A==; X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="357507675" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="357507675" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2023 20:15:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="739769528" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="739769528" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2023 20:15:38 -0700 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com Subject: [PATCH 3/4] soundwire: extend parameters of new_peripheral_assigned() callback Date: Wed, 31 May 2023 11:37:35 +0800 Message-Id: <20230531033736.792464-4-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230531033736.792464-1-yung-chuan.liao@linux.intel.com> References: <20230531033736.792464-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: Z64HZGMTW3LMHQTKQ4UPKVXNRMVD4BRQ X-Message-ID-Hash: Z64HZGMTW3LMHQTKQ4UPKVXNRMVD4BRQ X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Pierre-Louis Bossart The parameters are only the bus and the device number, manager ops may need additional details on the type of peripheral connected, such as whether it is wake-capable or not. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Signed-off-by: Bard Liao --- drivers/soundwire/bus.c | 2 +- drivers/soundwire/intel_auxdevice.c | 4 +++- include/linux/soundwire/sdw.h | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index 6f465cce8369..17b9a8bdf234 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -786,7 +786,7 @@ static int sdw_assign_device_num(struct sdw_slave *slave) slave->dev_num = slave->dev_num_sticky; if (bus->ops && bus->ops->new_peripheral_assigned) - bus->ops->new_peripheral_assigned(bus, dev_num); + bus->ops->new_peripheral_assigned(bus, slave, dev_num); return 0; } diff --git a/drivers/soundwire/intel_auxdevice.c b/drivers/soundwire/intel_auxdevice.c index 30f3d2ab80fd..c1df6f014e6b 100644 --- a/drivers/soundwire/intel_auxdevice.c +++ b/drivers/soundwire/intel_auxdevice.c @@ -60,7 +60,9 @@ static int generic_post_bank_switch(struct sdw_bus *bus) return sdw->link_res->hw_ops->post_bank_switch(sdw); } -static void generic_new_peripheral_assigned(struct sdw_bus *bus, int dev_num) +static void generic_new_peripheral_assigned(struct sdw_bus *bus, + struct sdw_slave *slave, + int dev_num) { struct sdw_cdns *cdns = bus_to_cdns(bus); struct sdw_intel *sdw = cdns_to_intel(cdns); diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index 8a7541ac735e..41a856bedf1e 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -861,7 +861,9 @@ struct sdw_master_ops { int (*pre_bank_switch)(struct sdw_bus *bus); int (*post_bank_switch)(struct sdw_bus *bus); u32 (*read_ping_status)(struct sdw_bus *bus); - void (*new_peripheral_assigned)(struct sdw_bus *bus, int dev_num); + void (*new_peripheral_assigned)(struct sdw_bus *bus, + struct sdw_slave *slave, + int dev_num); }; /** From patchwork Wed May 31 03:37:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 688287 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9B45DC77B73 for ; Wed, 31 May 2023 03:18:33 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 63056206; Wed, 31 May 2023 05:17:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 63056206 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685503111; bh=ZpdxB1tn4u4OhUdxszyZlKy/CjHo5nh+Kt7t5DnOqAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=oU8wzAnnXvLM92cAsM/QCZ/5BV6Yh9rxplck+fYm/HTxAsXiV40482KrM4QTKW23e VIaM1VIYmJ/64wu+812LOEzTOxTDrVQvFTOzG5c3u22rA0XsvW6lIms017GiBiVnH7 PgY6JasVLu6CK/sIdLx1YER9TTkeVYNW2n7EyBVY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 156BDF8042F; Wed, 31 May 2023 05:17:39 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 88A98F804FC; Wed, 31 May 2023 05:17:38 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2311FF800DF; Wed, 31 May 2023 05:17:35 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 0056AF804FC for ; Wed, 31 May 2023 05:15:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0056AF804FC Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=EzUtO3cO DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685502945; x=1717038945; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZpdxB1tn4u4OhUdxszyZlKy/CjHo5nh+Kt7t5DnOqAw=; b=EzUtO3cO/PTpOEEpNFJtt8ZjQZfpuWGxmS9YYKH0jDLbA1Xx+hvZs/oW EQ3VFKUXY2RGJzxsBnT/7627pWLBEQl1LIvwLwTmvGCapdvZy1K/AHQHW 7Ohjd74TM42YChWOwYdSXeP/j0k4dOstoFCFsLAcVEaJPDDhfxxNvICnD HFUXpNp3TRaLmok6gWN8a9l4YVRX/dmKSOAI2N6CwboqLN9kJIdEI7/7C J2PYktr4gbBaS5zwiHiVvRzi/mc56tYp7WfpuABE1U4xe3HbahSiPfbcn /55hM4hqg9yGDo5G5CeCuAK6Aj+ovGubjO1d7m0o3XD2pFm4TIfqJPu9j A==; X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="357507684" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="357507684" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2023 20:15:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="739769540" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="739769540" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2023 20:15:40 -0700 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com Subject: [PATCH 4/4] soundwire: intel_auxdevice: use SDW_DEV_NUM_ALLOC_IDA_WAKE_ONLY Date: Wed, 31 May 2023 11:37:36 +0800 Message-Id: <20230531033736.792464-5-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230531033736.792464-1-yung-chuan.liao@linux.intel.com> References: <20230531033736.792464-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: YS5GAL3T2ADQ2KUGAAP5TWXKTYC7VH32 X-Message-ID-Hash: YS5GAL3T2ADQ2KUGAAP5TWXKTYC7VH32 X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Pierre-Louis Bossart Change the allocation strategy on Intel platforms to use Device Numbers [1..5]: unconstrained allocation with bus-specific Device Numbers, typically for amplifiers. [6..11]: IDA-based system-unique Device Number to be used for wake-capable devices such as jack codecs or microphone codecs. These values were chosen based on the typical maximum number of devices per link given electrical/PHY limitations. This configuration will e.g. allow for 8 amplifiers on 2 links, and additional devices on the remaining links. Example on Dell SDCA device with jack codec, two amplifiers and one microphone codec: only the jack codec relies on the IDA, others use the same Device Number 1 on separate links. rt711-sdca sdw:0:025d:0711:01: signaling enumeration completion for Slave 6 rt1316-sdca sdw:1:025d:1316:01: signaling enumeration completion for Slave 1 rt1316-sdca sdw:2:025d:1316:01: signaling enumeration completion for Slave 1 rt715-sdca sdw:3:025d:0714:01: signaling enumeration completion for Slave 1 Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Signed-off-by: Bard Liao --- drivers/soundwire/intel_auxdevice.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/soundwire/intel_auxdevice.c b/drivers/soundwire/intel_auxdevice.c index c1df6f014e6b..917edc75ddfb 100644 --- a/drivers/soundwire/intel_auxdevice.c +++ b/drivers/soundwire/intel_auxdevice.c @@ -23,8 +23,12 @@ #include "intel.h" #include "intel_auxdevice.h" -/* IDA min selected to avoid conflicts with HDaudio/iDISP SDI values */ -#define INTEL_DEV_NUM_IDA_MIN 4 +/* + * IDA min selected to allow for 5 unconstrained devices per link, + * and 6 system-unique Device Numbers for wake-capable devices. + */ + +#define INTEL_DEV_NUM_IDA_MIN 6 #define INTEL_MASTER_SUSPEND_DELAY_MS 3000 @@ -66,9 +70,20 @@ static void generic_new_peripheral_assigned(struct sdw_bus *bus, { struct sdw_cdns *cdns = bus_to_cdns(bus); struct sdw_intel *sdw = cdns_to_intel(cdns); + int min_dev = 1; + int max_dev = SDW_MAX_DEVICES; + + if (bus->dev_num_alloc == SDW_DEV_NUM_ALLOC_IDA) { + min_dev = INTEL_DEV_NUM_IDA_MIN; + } else if (bus->dev_num_alloc == SDW_DEV_NUM_ALLOC_IDA_WAKE_ONLY) { + if (slave->prop.wake_capable) + min_dev = INTEL_DEV_NUM_IDA_MIN; + else + max_dev = INTEL_DEV_NUM_IDA_MIN - 1; + } /* paranoia check, this should never happen */ - if (dev_num < INTEL_DEV_NUM_IDA_MIN || dev_num > SDW_MAX_DEVICES) { + if (dev_num < min_dev || dev_num > max_dev) { dev_err(bus->dev, "%s: invalid dev_num %d\n", __func__, dev_num); return; } @@ -167,7 +182,7 @@ static int intel_link_probe(struct auxiliary_device *auxdev, cdns->msg_count = 0; bus->link_id = auxdev->id; - bus->dev_num_alloc = SDW_DEV_NUM_ALLOC_IDA; + bus->dev_num_alloc = SDW_DEV_NUM_ALLOC_IDA_WAKE_ONLY; bus->dev_num_ida_min = INTEL_DEV_NUM_IDA_MIN; bus->clk_stop_timeout = 1;