Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2619666lqo; Tue, 14 May 2024 04:36:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWn0e9ijHSyFP6l74Avsbdqn+ykSU1uzsNrbBm1RExSU5S5KJ6WxFNhJ3RAPyQ0dwmQh8UqinPVMeyir5b4jT0g59oF1PL74nWC/olQmw== X-Google-Smtp-Source: AGHT+IGa9qdO282tOVRiY+ywPW+JUd3gOoqiigNupok8zR5WTcL0s39/BuH2aquCXFkRDNflOb6f X-Received: by 2002:a25:1e08:0:b0:de5:f0ef:788e with SMTP id 3f1490d57ef6-dee4f1a61e0mr10021591276.20.1715686614854; Tue, 14 May 2024 04:36:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715686614; cv=pass; d=google.com; s=arc-20160816; b=EhCRirXFtovq/DXFE0YBcccfdK+2Xsuui3OEy7hoY0Q6p2efQav4tMODv05xFRpfw8 xOhIzQ3N0/OMgPhacxzAidMjmXuSZ0WwD1vxN/iO5+C3LdPTCvL2V0F1a7ALG/t+wMfk FPbaFj48yvfQMSMainpOjqGRDOPoIoUD4CMYTMKA6Ne4Y7c5cM5J3HxMDXfzdgtEaWVx r/eGCaUjaJkFMcPuywMJ85SSG/Nbkxnnm0N7KF+y9zG/UHkwdnB2KbAbACArHMG8orbA X5+Cjs995W3Mc3d4VxGxPyGrGK5Gh9YA9ibyv4Qx2C5KP7iqGJ8DoDrjVkYM8XIL9huk fEEg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=+LhI0jT3YS/VFJQvYdTWFhZgvhVB9tSYh2YfU/vKios=; fh=y7qAdPKS3iMGmKw6ccx5o0y7IXeuagY928rNRyHbf+s=; b=PYpWtEnU4acAeLR60kqRYQ6IJRUCI278zkXMl+cp3H+uNjmg2AWOwueQxf/C8DCAkW s1/EHV6O8+5/gQCZ+KAVww0oK5n68f5Kb4y5D91fprG2R0cHcsSNA2bna1CP+1IhsG+P g/VmqQgRFuZEYyKoFc8ubHIAi7iR5OwUmSjtNUdEp3GODEB1z9kT+IxVpmAfs0whF5n/ LR9GKEPeedv/s/av5V3FrMW5A7skVohY+7UccX5l+/Tu+D9iCj482zaZ50JvdL4/fFc6 qSkkkec++bPo220jXusEKu81/iRpSF/cygcyW67RlqGDxamHYXqzZrb6t+PH0OWuaWfN oI4A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A12suBtl; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-178593-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178593-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6a15f1d77a6si117846886d6.31.2024.05.14.04.36.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 04:36:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178593-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A12suBtl; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-178593-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178593-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2C04C1C2176E for ; Tue, 14 May 2024 11:36:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A72D13D28D; Tue, 14 May 2024 11:24:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="A12suBtl" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AE476311D; Tue, 14 May 2024 11:24:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715685887; cv=none; b=Kg5mrSPcsVmIL5IFnWo/7kMivs55IsHaZ0nEJjGeN1/6mcEyP7UMxreWIyhB+dOWLHkn8w9nW5dl6oDhm7I4srKy/aKSD1v5TLgUmLGGE1613KnJU/MMYf0uSm+r1pLw0mmdVlfqyTzyqaVtixv1TDpT/LIG/k8BMdi618H4+E8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715685887; c=relaxed/simple; bh=LXV+ZjnuDjyDDleo0LoYyUv1WccqMEPwcst/tiipykM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sxRcOq7skZLep//GTP1VXR7Mt8oePyxA0IWsB88u7BkSiY1caCAIf9QcS03x6Rjk+LLl1QW5gV4gsoF/NNABj18mTFjb8kcS1iBK2VIh0WU6UG/pz2IbaaIt/Tzhn+9XYjVvdWqa8qByZmkvPrfyAO4+PcfitKwioAwFOkHVCMU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=A12suBtl; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4BDEC2BD10; Tue, 14 May 2024 11:24:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1715685887; bh=LXV+ZjnuDjyDDleo0LoYyUv1WccqMEPwcst/tiipykM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A12suBtlmZTpHrD5Azhe/DLDCkKtPsgttPoXSRecc/ZB5xfAEnZL2NCO/eXdddrXz iWTdBvQA6ulwZ07uIT01j5FkOSypdzbB8l5ZdT9Lo8FBvPATfVFXG+aYdIlxXFR8vL bZtWRnS9XqmE31pl9FX++BB2SSupZv6j4kjWF+po= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Brown , Amit Sunil Dhamne , Heikki Krogerus Subject: [PATCH 6.6 237/301] usb: typec: tcpm: unregister existing source caps before re-registration Date: Tue, 14 May 2024 12:18:28 +0200 Message-ID: <20240514101041.202661931@linuxfoundation.org> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240514101032.219857983@linuxfoundation.org> References: <20240514101032.219857983@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Amit Sunil Dhamne commit 230ecdf71a644c9c73e0e6735b33173074ae3f94 upstream. Check and unregister existing source caps in tcpm_register_source_caps function before registering new ones. This change fixes following warning when port partner resends source caps after negotiating PD contract for the purpose of re-negotiation. [ 343.135030][ T151] sysfs: cannot create duplicate filename '/devices/virtual/usb_power_delivery/pd1/source-capabilities' [ 343.135071][ T151] Call trace: [ 343.135076][ T151] dump_backtrace+0xe8/0x108 [ 343.135099][ T151] show_stack+0x18/0x24 [ 343.135106][ T151] dump_stack_lvl+0x50/0x6c [ 343.135119][ T151] dump_stack+0x18/0x24 [ 343.135126][ T151] sysfs_create_dir_ns+0xe0/0x140 [ 343.135137][ T151] kobject_add_internal+0x228/0x424 [ 343.135146][ T151] kobject_add+0x94/0x10c [ 343.135152][ T151] device_add+0x1b0/0x4c0 [ 343.135187][ T151] device_register+0x20/0x34 [ 343.135195][ T151] usb_power_delivery_register_capabilities+0x90/0x20c [ 343.135209][ T151] tcpm_pd_rx_handler+0x9f0/0x15b8 [ 343.135216][ T151] kthread_worker_fn+0x11c/0x260 [ 343.135227][ T151] kthread+0x114/0x1bc [ 343.135235][ T151] ret_from_fork+0x10/0x20 [ 343.135265][ T151] kobject: kobject_add_internal failed for source-capabilities with -EEXIST, don't try to register things with the same name in the same directory. Fixes: 8203d26905ee ("usb: typec: tcpm: Register USB Power Delivery Capabilities") Cc: linux-usb@vger.kernel.org Cc: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: Mark Brown Signed-off-by: Amit Sunil Dhamne Reviewed-by: Heikki Krogerus Link: https://lore.kernel.org/r/20240424223227.1807844-1-amitsd@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tcpm/tcpm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -2422,7 +2422,7 @@ static int tcpm_register_sink_caps(struc { struct usb_power_delivery_desc desc = { port->negotiated_rev }; struct usb_power_delivery_capabilities_desc caps = { }; - struct usb_power_delivery_capabilities *cap; + struct usb_power_delivery_capabilities *cap = port->partner_source_caps; if (!port->partner_pd) port->partner_pd = usb_power_delivery_register(NULL, &desc); @@ -2432,6 +2432,9 @@ static int tcpm_register_sink_caps(struc memcpy(caps.pdo, port->sink_caps, sizeof(u32) * port->nr_sink_caps); caps.role = TYPEC_SINK; + if (cap) + usb_power_delivery_unregister_capabilities(cap); + cap = usb_power_delivery_register_capabilities(port->partner_pd, &caps); if (IS_ERR(cap)) return PTR_ERR(cap);