Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1631050rwd; Mon, 15 May 2023 00:15:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6t1w8bR66Bk6Sh57gb2r4myOtR13X85+tCAx0Ed5f0N1uAb7/WtwYoW21XtggcMQud7FWa X-Received: by 2002:a05:6a20:3d95:b0:106:57b9:6da1 with SMTP id s21-20020a056a203d9500b0010657b96da1mr1230060pzi.20.1684134942542; Mon, 15 May 2023 00:15:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684134942; cv=none; d=google.com; s=arc-20160816; b=KjAQah0a1JTYyKV/fHGJPt2ZLzQexKLXAsTwjUHWUD8vObSSO/oO/zc4QU+e80FJzP brpR8pLJxFA8fKJgLuI7dwJiRXtpXU239PygngoYrSEq+oaddypbNo8J7eCgsP0/uTDZ +YNaAYGPXQfuHV7AQSk88ujA50ZizxSs+eY633z8rgSmjgEQYmextop1W62HXahq2zlr rB7HBK7QH2kX7XilIG2jPnuzd4EBcDexrOaLccwBJWmsMsfF+xtD/qJJRc6kC5e8/CAx 6ID2IHc/8Cd/F/XfZah1alTI9lpscn30s+PsGK1GDj9uPRyA0jYII3r4N90qoCeMLJen +mNw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g126-20020a636b84000000b0050ac7d1b32asi14370747pgc.603.2023.05.15.00.15.30; Mon, 15 May 2023 00:15:42 -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 S238273AbjEOGwx (ORCPT + 99 others); Mon, 15 May 2023 02:52:53 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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); }; /** -- 2.25.1