From patchwork Thu May 26 10:59:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gil Fine X-Patchwork-Id: 577046 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 162EBC433F5 for ; Thu, 26 May 2022 10:49:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237146AbiEZKtj (ORCPT ); Thu, 26 May 2022 06:49:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232894AbiEZKtf (ORCPT ); Thu, 26 May 2022 06:49:35 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7D2DC8BF4 for ; Thu, 26 May 2022 03:49:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653562173; x=1685098173; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=BAFJ+DR2d6Bu7mqJI39cIz/ZIgjvFu/xGC4HeIIR05Q=; b=ILXemWkwirVHugD0E4dR8Bsom5NSMfH37kt6Om3EcGUB9kZYapPENKiw Wq00AXXkJVbaD7TJLUftpOmfY/b4TD7W9AUHedhBhB3KWlb9UqZCZeAAR SBVB6MzunWQ1kdLhT097wqvR2euEatn+HkdQF8Pn6l80S5peoqcKWTAM6 5BC+82AgZuw3QtEv0o+2LKNdK7Yb7RbDxZelsTPUAN/kMgzBs9nzcyysz kR+Ii/hxUPo7/JLi98eLV5vym3mVIXsfhYXDQIpCkITko0w6m53kVZxYb j6V4POBh5vEzYRZkMBMPDDDztbzhxVUQ6W+zVgeupTKcmlnIfY7X4vZSb Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10358"; a="274223367" X-IronPort-AV: E=Sophos;i="5.91,252,1647327600"; d="scan'208";a="274223367" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2022 03:49:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,252,1647327600"; d="scan'208";a="704474307" Received: from ccdjpclinux26.jer.intel.com ([10.12.48.253]) by orsmga004.jf.intel.com with ESMTP; 26 May 2022 03:49:31 -0700 From: Gil Fine To: andreas.noever@gmail.com, michael.jamet@intel.com, mika.westerberg@linux.intel.com, YehezkelShB@gmail.com Cc: gil.fine@intel.com, linux-usb@vger.kernel.org, lukas@wunner.de Subject: [PATCH v4 4/6] thunderbolt: Change downstream router's TMU rate in both TMU uni/bidir mode Date: Thu, 26 May 2022 13:59:19 +0300 Message-Id: <20220526105921.17214-5-gil.fine@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220526105921.17214-1-gil.fine@intel.com> References: <20220526105921.17214-1-gil.fine@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org In case of uni-directional time sync, TMU handshake is initiated by upstream router. In case of bi-directional time sync, TMU handshake is initiated by downstream router. In order to handle correctly the case of uni-directional mode, we avoid changing the upstream router's rate to off, because it might have another downstream router plugged that is set to uni-directional mode (and we don't want to change its mode). Instead, we always change downstream router's rate. Signed-off-by: Gil Fine --- drivers/thunderbolt/tmu.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/thunderbolt/tmu.c b/drivers/thunderbolt/tmu.c index b656659d02fb..985ca43b8f39 100644 --- a/drivers/thunderbolt/tmu.c +++ b/drivers/thunderbolt/tmu.c @@ -359,13 +359,14 @@ int tb_switch_tmu_disable(struct tb_switch *sw) * In case of uni-directional time sync, TMU handshake is * initiated by upstream router. In case of bi-directional * time sync, TMU handshake is initiated by downstream router. - * Therefore, we change the rate to off in the respective - * router. + * We change downstream router's rate to off for both uni/bidir + * cases although it is needed only for the bi-directional mode. + * We avoid changing upstream router's mode since it might + * have another downstream router plugged, that is set to + * uni-directional mode and we don't want to change it's TMU + * mode. */ - if (unidirectional) - tb_switch_tmu_rate_write(parent, TB_SWITCH_TMU_RATE_OFF); - else - tb_switch_tmu_rate_write(sw, TB_SWITCH_TMU_RATE_OFF); + tb_switch_tmu_rate_write(sw, TB_SWITCH_TMU_RATE_OFF); tb_port_tmu_time_sync_disable(up); ret = tb_port_tmu_time_sync_disable(down);