From patchwork Thu Dec 16 09:26:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1568992 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=Yqocfo6z; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JF6FZ2GS8z9s0r for ; Thu, 16 Dec 2021 20:26:58 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1mxn2I-000685-LE; Thu, 16 Dec 2021 09:26:50 +0000 Received: from mail-pg1-f175.google.com ([209.85.215.175]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mxn2F-000640-AS for kernel-team@lists.ubuntu.com; Thu, 16 Dec 2021 09:26:47 +0000 Received: by mail-pg1-f175.google.com with SMTP id f125so22636768pgc.0 for ; Thu, 16 Dec 2021 01:26:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xXIiydymlzmmUYrH2r0gcvngp210t/4dG59iYUTyJuk=; b=Yqocfo6zX6VpwD6wUXvCb5B2Ydo00uQIzNMVON7Y2s73nfnCbj3TwHIQi28sW9Zb/y yedf6rkl5cTineNihnObojJTbd5XRTROSroVOb9YgRsC2516ma2lDtEq9IeAkP6UXUGW Z4VeXS6dDgjTAZ8hT1ZQeIJsGU+HuQstftaM451xwFz/r5PiELwrZbhXECWxNclJTZzs 5SZ6pFsqII24J74T4HZpJ0RuT1dVS7w0YMARquPlfm6S4zdhv+oRQCLs0Kz6P2gjiuNe FjAGrgjCfvD9SxjiNjzuomSBlZNBuzGfNslijzSr2UPl1VwjVhsSAgTZhuwXrb5+Wo7k 5PbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=xXIiydymlzmmUYrH2r0gcvngp210t/4dG59iYUTyJuk=; b=qtOwTrIBW9O3iF9RxwcDTrzr+TFR98ZaZrT+nEHinq+XDJv1WpnFU6PV10zn9Asmz+ qtxXSdgaHGwa5qp2A4uZAumybz6eQPkK2ZGol6i/V0tR2L26EDxEePf6KAIdLSB8C5Yh vJVU1yxj+arF2QRvBfSYCIUT1Y/2v53t7187NjENHPODMSFPv8ZyazvngWAFEhOIQ4k7 PlY+xVNhMMmdcnLYXGZjq1WPm5QEff12ZJ5TSZ8YtSkkNfCHdaCRveBuwDa4yupUvV7K +XRkvO0r3ZmVma+fJm8YmcK2BnaTLZV0rUh6AakP7CtD17dbPsEVfD35pBa7LLuiqT47 SD8Q== X-Gm-Message-State: AOAM5310SJaTY6KLMiN62rNvKq9LKmPsAIqP/Rlr05rYGA79HseHABup BiOg54kjvo2c2ftUqx+2R9DVlnLgX64= X-Google-Smtp-Source: ABdhPJxCHXgsC4/9Riv0+Q7ONVvnb3evrWDR65CfHcISPBIkqskvqBRq8VaGQd1VaItU9Y9u8FVSkA== X-Received: by 2002:a63:5754:: with SMTP id h20mr11119012pgm.475.1639646804917; Thu, 16 Dec 2021 01:26:44 -0800 (PST) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id y8sm808696pjt.25.2021.12.16.01.26.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 01:26:44 -0800 (PST) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 4/6][SRU][J][OEM-5.14] thunderbolt: Do not allow subtracting more NFC credits than configured Date: Thu, 16 Dec 2021 17:26:31 +0800 Message-Id: <20211216092633.1079354-5-acelan.kao@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211216092633.1079354-1-acelan.kao@canonical.com> References: <20211216092633.1079354-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.215.175; envelope-from=acelan@gmail.com; helo=mail-pg1-f175.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Mika Westerberg BugLink: https://bugs.launchpad.net/bugs/1955016 This might happen if the boot firmware uses different amount of NFC credits than what the router suggests, or we are dealing with pre-USB4 device. Signed-off-by: Mika Westerberg --- drivers/thunderbolt/switch.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index 0acb2f3fe2661..f384cda76e862 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -623,6 +623,9 @@ int tb_port_add_nfc_credits(struct tb_port *port, int credits) return 0; nfc_credits = port->config.nfc_credits & ADP_CS_4_NFC_BUFFERS_MASK; + if (credits < 0) + credits = max_t(int, -nfc_credits, credits); + nfc_credits += credits; tb_port_dbg(port, "adding %d NFC credits to %lu", credits,