From patchwork Tue Jan 24 09:09:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 13113673 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 4F820C38142 for ; Tue, 24 Jan 2023 09:09:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233119AbjAXJJI (ORCPT ); Tue, 24 Jan 2023 04:09:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232827AbjAXJJG (ORCPT ); Tue, 24 Jan 2023 04:09:06 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6FE33A85A for ; Tue, 24 Jan 2023 01:09:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674551345; x=1706087345; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=LEHelsAi7XkgV18EkkVKHefJtHLvN2IdJSffJIEWRbk=; b=ebEKDC8GjvxtXsPttcXBOQYJPepdJdANzIoR/pz/YKpWcM73KNo2E+Hz BsN+6qxoeikG4/f3tihs5X2EbNM/4ZQQqJUM9GzS/jDxA8y/zVo3gPKsA UyKrQHp6sty3qDfRbbhxLPOpzSXaEiD6xZSeaV/omHBL6ZL3YS+7TuS3M o4DVLSAEhL3MB7KMYVISj01Y47VqtjqwZufwAnoDFfh9Dn+Snt1QM9iMN aXya32k4VY+0kzwAmto4wfXv1Jt5pcKnaRWfVD9oVlDGSifrpsrnEXuWD d2kz7qVaNHl/20wNqckWLM/8xMlMu/18SrjjK8aA4yJlpw8/nZpBYvMmW A==; X-IronPort-AV: E=McAfee;i="6500,9779,10599"; a="327511725" X-IronPort-AV: E=Sophos;i="5.97,242,1669104000"; d="scan'208";a="327511725" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2023 01:09:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10599"; a="639510354" X-IronPort-AV: E=Sophos;i="5.97,242,1669104000"; d="scan'208";a="639510354" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 24 Jan 2023 01:09:03 -0800 Received: by black.fi.intel.com (Postfix, from userid 1001) id 44FE0154; Tue, 24 Jan 2023 11:09:39 +0200 (EET) From: Mika Westerberg To: linux-usb@vger.kernel.org Cc: Yehezkel Bernat , Michael Jamet , Lukas Wunner , Andreas Noever , Mika Westerberg Subject: [PATCH 1/2] thunderbolt: Handle bandwidth allocation mode enablement notification Date: Tue, 24 Jan 2023 11:09:37 +0200 Message-Id: <20230124090938.58825-1-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org When the graphics side enables bandwidth allocation mode the DP IN adapter sends notification to the connection manager about this. Currently the handler misses this and tries to allocate 0 Mb/s that then makes the graphics side to think the request failed. Fix this by properly handling the enablement notification. Fixes: 6ce3563520be ("thunderbolt: Add support for DisplayPort bandwidth allocation mode") Signed-off-by: Mika Westerberg --- drivers/thunderbolt/tb.c | 10 +++++++--- drivers/thunderbolt/usb4.c | 7 ++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c index 0b891d749a96..7bfbc9ca9ba4 100644 --- a/drivers/thunderbolt/tb.c +++ b/drivers/thunderbolt/tb.c @@ -1756,11 +1756,15 @@ static void tb_handle_dp_bandwidth_request(struct work_struct *work) goto unlock; } - requested_bw = usb4_dp_port_requested_bw(in); - if (requested_bw < 0) { - tb_port_dbg(in, "no bandwidth request active\n"); + ret = usb4_dp_port_requested_bw(in); + if (ret < 0) { + if (ret == -ENODATA) + tb_port_dbg(in, "no bandwidth request active\n"); + else + tb_port_warn(in, "failed to read requested bandwidth\n"); goto unlock; } + requested_bw = ret; tb_port_dbg(in, "requested bandwidth %d Mb/s\n", requested_bw); diff --git a/drivers/thunderbolt/usb4.c b/drivers/thunderbolt/usb4.c index 2a9266fb5c0f..1e5e9c147a31 100644 --- a/drivers/thunderbolt/usb4.c +++ b/drivers/thunderbolt/usb4.c @@ -2732,7 +2732,8 @@ int usb4_dp_port_allocate_bw(struct tb_port *port, int bw) * Reads the DPCD (graphics driver) requested bandwidth and returns it * in Mb/s. Takes the programmed granularity into account. In case of * error returns negative errno. Specifically returns %-EOPNOTSUPP if - * the adapter does not support bandwidth allocation mode. + * the adapter does not support bandwidth allocation mode, and %ENODATA + * if there is no active bandwidth request from the graphics driver. */ int usb4_dp_port_requested_bw(struct tb_port *port) { @@ -2750,10 +2751,10 @@ int usb4_dp_port_requested_bw(struct tb_port *port) ret = tb_port_read(port, &val, TB_CFG_PORT, port->cap_adap + ADP_DP_CS_8, 1); if (ret) - return 0; + return ret; if (!(val & ADP_DP_CS_8_DR)) - return 0; + return -ENODATA; return (val & ADP_DP_CS_8_REQUESTED_BW_MASK) * granularity; } From patchwork Tue Jan 24 09:09:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 13113672 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 B9A8CC25B4E for ; Tue, 24 Jan 2023 09:09:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233072AbjAXJJI (ORCPT ); Tue, 24 Jan 2023 04:09:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbjAXJJG (ORCPT ); Tue, 24 Jan 2023 04:09:06 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6F593A58C for ; Tue, 24 Jan 2023 01:09:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674551345; x=1706087345; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sR/UIsgyhorIod1gaBRPoonyQRpHm9pr3tdaMep3yjs=; b=PZbQeCN55cu1tWjeVQXxLQWFDZDTzMKT3X/NjDmo3eC7pMnHGCgJDta7 s+4mS8LMTP1zYowRmIX3ggVYNuEKiq15sQjcbr2WObrRXuDBIqdZpkEbu o8j4rGSA1SHVnRaNcoRVsWsSwYf6cyvIhLplHtA7v2wR9pjzrAGKsfnzY fj/4xxreSeXYSHJYClphKlW65y6oehWCXCLNg0G3+yBs0vLInXJouuRdU bSACnBN3CJzQPJKENtNwn9GfVzhHyOaLe1yXkyYmNTe7zvLG52/0M5IlG 3EjwKhslRuWK/D01Aa5ynsxwVLILYxyiQgsicU0NRVsV6nhZTVcp2c3An A==; X-IronPort-AV: E=McAfee;i="6500,9779,10599"; a="306608118" X-IronPort-AV: E=Sophos;i="5.97,242,1669104000"; d="scan'208";a="306608118" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2023 01:09:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10599"; a="692521277" X-IronPort-AV: E=Sophos;i="5.97,242,1669104000"; d="scan'208";a="692521277" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 24 Jan 2023 01:09:03 -0800 Received: by black.fi.intel.com (Postfix, from userid 1001) id 4E6A5144; Tue, 24 Jan 2023 11:09:39 +0200 (EET) From: Mika Westerberg To: linux-usb@vger.kernel.org Cc: Yehezkel Bernat , Michael Jamet , Lukas Wunner , Andreas Noever , Mika Westerberg Subject: [PATCH 2/2] thunderbolt: Add missing kernel-doc comment to tb_tunnel_maximum_bandwidth() Date: Tue, 24 Jan 2023 11:09:38 +0200 Message-Id: <20230124090938.58825-2-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124090938.58825-1-mika.westerberg@linux.intel.com> References: <20230124090938.58825-1-mika.westerberg@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org These were missing from the original commit so add them now. No functional changes. Signed-off-by: Mika Westerberg --- drivers/thunderbolt/tunnel.c | 10 ++++++++++ drivers/thunderbolt/tunnel.h | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/thunderbolt/tunnel.c b/drivers/thunderbolt/tunnel.c index c406675a8966..8af9397f272e 100644 --- a/drivers/thunderbolt/tunnel.c +++ b/drivers/thunderbolt/tunnel.c @@ -2081,6 +2081,16 @@ static bool tb_tunnel_is_active(const struct tb_tunnel *tunnel) return true; } +/** + * tb_tunnel_maximum_bandwidth() - Return maximum possible bandwidth + * @tunnel: Tunnel to check + * @max_up: Maximum upstream bandwidth in Mb/s + * @max_down: Maximum upstream bandwidth in Mb/s + * + * Returns maximum possible bandwidth this tunnel can go if not limited + * by other bandwidth clients. If the tunnel does not support this + * returns %-EOPNOTSUPP. + */ int tb_tunnel_maximum_bandwidth(struct tb_tunnel *tunnel, int *max_up, int *max_down) { diff --git a/drivers/thunderbolt/tunnel.h b/drivers/thunderbolt/tunnel.h index d7bbdf8c8186..bf690f7beeee 100644 --- a/drivers/thunderbolt/tunnel.h +++ b/drivers/thunderbolt/tunnel.h @@ -29,7 +29,7 @@ enum tb_tunnel_type { * @init: Optional tunnel specific initialization * @deinit: Optional tunnel specific de-initialization * @activate: Optional tunnel specific activation/deactivation - * @maximum_bandwidth: + * @maximum_bandwidth: Returns maximum possible bandwidth for this tunnel * @allocated_bandwidth: Return how much bandwidth is allocated for the tunnel * @alloc_bandwidth: Change tunnel bandwidth allocation * @consumed_bandwidth: Return how much bandwidth the tunnel consumes