From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71D89C43331 for ; Sun, 10 Nov 2019 02:51:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3DABA206BB for ; Sun, 10 Nov 2019 02:51:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573354313; bh=b3iUeq6i7vf0R43JzFyu9ugI+yVa/N6wfBFwjYHU+Vg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=jSKaPRX6X0IxOjvj4+vtHBqlt+C+LDt+YJbLwVNA1SMMb2xE4XT2/d5WsU3H3HtxG 26PzgAmtyKUTh1WzdLH0f0QiYcXDGRwWR1hOOD7jAqOsmEf+9l0wzJ6HfHZNeMFVAl WwgJd0FFowhLVeDPupHVVGUhdon9UK00FxFbPiAo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730077AbfKJCvw (ORCPT ); Sat, 9 Nov 2019 21:51:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:36666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730034AbfKJCvn (ORCPT ); Sat, 9 Nov 2019 21:51:43 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C9F1222790; Sun, 10 Nov 2019 02:51:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573354302; bh=b3iUeq6i7vf0R43JzFyu9ugI+yVa/N6wfBFwjYHU+Vg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FBkhy/mwLAv9FHh2PXgKDi5Fpjk/XCnh1qFJOPCHUtEtcsSaahx33lhQjVLonsPIs 2n/vhMuJ0X112NCcX00r+jrMLGEZ1yiv4uJO/p/OoQYsx2UWb8f2c7mX5+DWdat3fo by0APut8sNs2vsw3PQFfmSuBfZSNpqnLFDPc6iqw= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Luiz Augusto von Dentz , Marcel Holtmann , Sasha Levin , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.4 38/40] Bluetooth: L2CAP: Detect if remote is not able to use the whole MPS Date: Sat, 9 Nov 2019 21:50:30 -0500 Message-Id: <20191110025032.827-38-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191110025032.827-1-sashal@kernel.org> References: <20191110025032.827-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luiz Augusto von Dentz [ Upstream commit a5c3021bb62b970713550db3f7fd08aa70665d7e ] If the remote is not able to fully utilize the MPS choosen recalculate the credits based on the actual amount it is sending that way it can still send packets of MTU size without credits dropping to 0. Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- net/bluetooth/l2cap_core.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index c25f1e4846cde..302c3bacb0247 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -6795,6 +6795,16 @@ static int l2cap_le_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb) chan->sdu_len = sdu_len; chan->sdu_last_frag = skb; + /* Detect if remote is not able to use the selected MPS */ + if (skb->len + L2CAP_SDULEN_SIZE < chan->mps) { + u16 mps_len = skb->len + L2CAP_SDULEN_SIZE; + + /* Adjust the number of credits */ + BT_DBG("chan->mps %u -> %u", chan->mps, mps_len); + chan->mps = mps_len; + l2cap_chan_le_send_credits(chan); + } + return 0; } -- 2.20.1