From patchwork Mon May 15 07:10:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 93912 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp6726765vqo; Mon, 15 May 2023 00:15:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7FWq/hgC2/FGRef3p7jQhCZ37qYhcROHT9B7JaNsjexujqRMtqHh0QHFE2Q4o23D3+q3uZ X-Received: by 2002:a05:6a00:cc8:b0:644:d220:64ac with SMTP id b8-20020a056a000cc800b00644d22064acmr42169358pfv.2.1684134941329; Mon, 15 May 2023 00:15:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684134941; cv=none; d=google.com; s=arc-20160816; b=N8+crpqhRTCqw5ClaWkNJ1F5gv8CRwDPFKacMgvC0AzJw1Q8aXpVE3xJOGOPYsDDHP xAWCXZjfS2H+Ga6FfSMjcnwxnYVnC+joDkgxjrJ/0VsQpn/8NiUaa63wxtx7zB4AEHbU wvMD0FsMQSTe94udrnpQq2d18t6OVRJoQVWXrpDCyFfNTD0dTDMBbAPGgKqkfu+d2HZC aZ06PHcTBhUUF8l3pxv1bSeV4iPUCDPpsfaHC1gLQoD4Q7Oh0eAWv2x00Mo3xKA/nkE3 D3iGa20kdmdj6Ihc/FyM9J3a5SF+vIRkP7tbayNs0XjAQ0yvDH3en1ajJlyiOSbijeFw TuPA== 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 :dkim-signature; bh=O5LJTv9kLdksObckWMBDmSQCc3NgHWN3jEsiX/4GKa4=; b=Q89wXl1mUWa6X40CE+7yUhGL+wHkRgpHrPCEzWq2w6k4XxJzko08nAeFpl1NGnHn5o JIEtCMtE38W85WM3fkV+elcudm2/eckLBzZHj7iDPponekMcXcKp1Gj89o9bIIuSfQjn 4mAvsV77c003D/YkHlZhm3JfF+KP5B06+Uzocf6ncx8Yvw/daE06dMXmd6XftxWPoAQp OxlwK0Kn18zcWFhzbdludoA6RTzAFpds13B4Q3W0//iKG8UZuENm39wxBnbKAYeikOUi LnXUSLGNMpAe/ARmFPxvX70NjgSBVs2g/g4gO8NRrqHWIfBrJZ+yR7bqh1endt1ijZ8B fV2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eVbEupJD; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l185-20020a6388c2000000b005342480fcd2si1294223pgd.282.2023.05.15.00.15.28; Mon, 15 May 2023 00:15:41 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=eVbEupJD; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240511AbjEOGwy (ORCPT + 99 others); Mon, 15 May 2023 02:52:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240155AbjEOGw0 (ORCPT ); Mon, 15 May 2023 02:52:26 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 919C7CF for ; Sun, 14 May 2023 23:52:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684133522; x=1715669522; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tzzjYf0orwaeoCq1YKwuJr6YmoUY5TgIK1ZLlpL2MUE=; b=eVbEupJDGvAFj9nZGf29U+K8mEsbKo3LQAdB5o3NKexwNHwuk6cYcGR0 1w74edPsabg7jitGmDqpZ/RVHZ/Biztw4B+MrHJf/x/JwX6JVzW215Mpw YuiY6T3HmUM6DEY4qHBgNCdWDckOg3/wNt/69D/IgsauNtdrAm/fKebT3 +RDkyBs1omgV2BNhV8emy6MBdMySndqxycw+IVIaN44/6MyU4Etyuh/rR BMZoa9nh9q6Pp2kzfBzjt4lTxQrFNdnIxLzEgbA+T4rCzZ4VcfJiT6Fhz wX/dBSADbJEWqHYsAGyUVYQifIa40iZANgW7QaqbNXnzcZaeSdxzKEbdQ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10710"; a="349966503" X-IronPort-AV: E=Sophos;i="5.99,275,1677571200"; d="scan'208";a="349966503" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2023 23:51:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10710"; a="694908767" X-IronPort-AV: E=Sophos;i="5.99,275,1677571200"; d="scan'208";a="694908767" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2023 23:51:04 -0700 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org, broonie@kernel.org, tiwai@suse.de Cc: linux-kernel@vger.kernel.org, vinod.koul@linaro.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com Subject: [PATCH v2 19/26] soundwire: bus: add new manager callback to deal with peripheral enumeration Date: Mon, 15 May 2023 15:10:35 +0800 Message-Id: <20230515071042.2038-20-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230515071042.2038-1-yung-chuan.liao@linux.intel.com> References: <20230515071042.2038-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765943480546781618?= X-GMAIL-MSGID: =?utf-8?q?1765943480546781618?= From: Pierre-Louis Bossart When a peripheral reports as ATTACHED, the manager may need to follow a programming sequence, e.g. to assign DMA resources and/or assign a command queue for that peripheral. This patch adds an optional callback, which will be invoked every time the peripheral attaches. This might be overkill in some scenarios, and one could argue that this should be invoked only on the first attachment. The bus does not however track this first attachment with any existing state-mirroring variable, and using dev_num_sticky would not work across suspend-resume cycles. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Rander Wang Reviewed-by: Péter Ujfalusi Reviewed-by: Ranjani Sridharan Signed-off-by: Bard Liao --- drivers/soundwire/bus.c | 3 +++ include/linux/soundwire/sdw.h | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index 338f4f0b5d0c..b44f8d0affa6 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -769,6 +769,9 @@ static int sdw_assign_device_num(struct sdw_slave *slave) /* After xfer of msg, restore dev_num */ slave->dev_num = slave->dev_num_sticky; + if (bus->ops && bus->ops->new_peripheral_assigned) + bus->ops->new_peripheral_assigned(bus, dev_num); + return 0; } diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index ef645de13ae9..c076a3f879b3 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -846,6 +846,7 @@ struct sdw_defer { * @post_bank_switch: Callback for post bank switch * @read_ping_status: Read status from PING frames, reported with two bits per Device. * Bits 31:24 are reserved. + * @new_peripheral_assigned: Callback to handle enumeration of new peripheral. */ struct sdw_master_ops { int (*read_prop)(struct sdw_bus *bus); @@ -860,7 +861,7 @@ 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); }; /**