Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp7116049rwl; Wed, 22 Mar 2023 22:33:36 -0700 (PDT) X-Google-Smtp-Source: AK7set+xFiZ+84ytDIIlIm/W5BMoJ/AHoxGS5wv2qfTKDvqSTXGuUnzpXduZk8ifSjZaVf40SegE X-Received: by 2002:a05:6a21:3381:b0:db:5e69:c97d with SMTP id yy1-20020a056a21338100b000db5e69c97dmr1692290pzb.25.1679549616578; Wed, 22 Mar 2023 22:33:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679549616; cv=none; d=google.com; s=arc-20160816; b=efcEBj3Z53RgwaBIhgrkrUeQcwVQVRwv8vXeccLYp1wRMiGTPBM1hXF/Wubfju/Hjm 1/7NnoTX32RQ2G1BSRdNLFyoKdEXQ+zB0BEpIPPwFq9UStZwF10iDEgDcIjxBsaE2HyV a08aFpe43/m092hIKhl8niCHmXPN8ob9mWIrCwW5GBpWg2PEGJblFs1LpJG5GGjVbQ8c 55ZSqHkX7dGeye0GJChE0KLNE2P7ZeFVx7+DtJRBDnZV3EN5GF+PKOFU2gQUXifoSdub MtGBzYBFooYxx8DNzcx+JN7G3sbw1KIudwz4lX++o/SrI9nhvYatiKVWKBTID1r8d4DF AnQA== 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=0akb/ucbsR6EOpM6ZL9plcwCYNPuCK/NKNlDLF1TEiU=; b=bmudHi6AeZuwVDvTWTch+5O2CymD39Kz2lO3vFCma+Xc3jE+oNdmATav5oaV+i6Bv8 0G+nJUlJzPzs2+7I6Y0sLHK6f1GL+guEP86I8sHILVmiAVQs8lsv9Rw0sQiZ+ouQ+Khv mfmrmksM0Ce+yYTUyIbpdRLhVWfpntaKJaN/p7UMofUkjKnYiK6EonAEpEaMLeqnC0Us kuqwWoKXRd7joZM1D0ftzLrswq201MrAvKZFF8RDTOrMjIefgPQ511QzJdWHqqblkL39 ECGTwBUTC8hWB6eLrlUX+T1f55nerDamCCSeJwXuz3vTU3B0cTOT/wILK53XVaKbDElu dG8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="F/vVsqcs"; 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 l1-20020a654481000000b004786f5e24f9si17490444pgq.94.2023.03.22.22.33.25; Wed, 22 Mar 2023 22:33:36 -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="F/vVsqcs"; 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 S231182AbjCWFcy (ORCPT + 99 others); Thu, 23 Mar 2023 01:32:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230487AbjCWFcZ (ORCPT ); Thu, 23 Mar 2023 01:32:25 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFAB631BE4 for ; Wed, 22 Mar 2023 22:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679549489; x=1711085489; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gtkWDGGprYUCa/NujUo+nrfpqYowlmMRMlh2EJAtBoc=; b=F/vVsqcsOIYBCZKC6fYc8SSuRNavVLDZn3teRJJo0U/O33x9Zy5wUys8 8wuJw5krE2kzNjKp/Zwq1h/ple0yW27Uo2LnNvtlJivK3tRrZqSemXi6u 09SoSDW89ifsN6xMNfzaYwIa1Mg85ZL4V9CdFj66Qw/SNaJhzGkpM+4Hc +lrPxkdPn+cq+0W76XeMR3lVYIOCFSbaZ3dMGozCa4Ol0SrXHBkqGjCKy ggpYXoalXngkuh12PIOev4FR2chefy5BP6QxU8xDgR1vnsy8M2uo7Puy6 DwxFXStkxI1cd1SreB7zOTCGPWd/70gu23Fvc4bPB7ztsOjfjMaoBcWFQ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="327779505" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="327779505" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 22:30:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="675567269" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="675567269" 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; 22 Mar 2023 22:30:36 -0700 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org, broonie@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, tiwai@suse.de Subject: [PATCH 19/20] soundwire: bus: add new manager callback to deal with peripheral enumeration Date: Thu, 23 Mar 2023 13:44:51 +0800 Message-Id: <20230323054452.1543233-20-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230323054452.1543233-1-yung-chuan.liao@linux.intel.com> References: <20230323054452.1543233-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=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 b6aca59c3130..35f49bcc53e5 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -716,6 +716,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