From patchwork Fri Feb 2 09:56:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 195762 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp318808dyc; Fri, 2 Feb 2024 01:57:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IGBGig81oAAlp28ELJO2ps71iaveJhAfSwWwOJtK3KGlHYuF6mC8VCT7/6zEgB3QDPLLmxc X-Received: by 2002:a05:622a:4c9:b0:42b:ef48:23f with SMTP id q9-20020a05622a04c900b0042bef48023fmr2662162qtx.4.1706867853646; Fri, 02 Feb 2024 01:57:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706867853; cv=pass; d=google.com; s=arc-20160816; b=ay6P+HLSAaI+eCNPz9uiMHIxBByeUvQRlI0+p4JulgJ2UutTmRVxKghvbAMynCjv9h NYDLkTaLqnLbUxNYH3qzhlywmXnlIf+nMx2F8W+hxYx1uXKqgIvEqvymItoFCiOEVScX h6hLXnc1OaUay61A8WWeZYD2jloFAkP3Yrctiq/1URqa46bAGlVinH5Yfuj7vkm8iafH CJ10jXYEWyOhkHPIV+jmLnbDOmYy/N+RIryEkhvAdQRoSbMhskjUiu/9p6YAcrqYmklw BNj5xHyX4NzhxqkMHIFsNh7NC57rgt9EsC3oqX9VjMtY8fNKNrfmkPHOQxpgKo2Pcse/ dSxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=in2Ntwtloha/e+ZMm1Ao4y84QzaZLhLUFFn+wIIPR3U=; fh=+ppQAKEoqHIztm9xcEkzp1zz6k6MG6ykd/lzLOkAqz8=; b=R9bk3BIXFNQH8nGCAoEDuLiLnnF8GoCJDx9qxeqsjg30w7bRpFiwR3CjI00aPaCg8r //6dY65YrVjx1I8GqqAKriTMdHwxivSSanwWsc4UFDvefP6X9dGfMaUTOYWeUrui+ndx w29n3yxQ4eCUVzB9XgWnC/Gnxag1gxSojgkEEEZNEIpv9hEAA+20miLcYEiE2j4kfSb2 GTRZxE3QIp47HE1vsPt6mD5wnZy1wms+ojivE+AyxakDsXDc1WjmxDcfilFf3GmmT6dK 7AoTF6HczZAW6lHVG7LMCZ5w6F0K7nsnivl7YvhtwcZEWfLww9VFvg5qlLhSrMhXJior sp/w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=UCHawdzG; arc=pass (i=1 spf=pass spfdomain=flex--saravanak.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-49624-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49624-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCXIVY/RXeURYx5ydmy2Yd8Ivl7HMVZNQJeUK8p8IxbNEEsvL6W7VmuzL3rQw94mhaRqPhUeK3QgtCX26FPyj+d4eZEkuA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id m12-20020a05622a054c00b0042aaa58fd44si1565322qtx.261.2024.02.02.01.57.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 01:57:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49624-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=UCHawdzG; arc=pass (i=1 spf=pass spfdomain=flex--saravanak.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-49624-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49624-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 542DB1C2464F for ; Fri, 2 Feb 2024 09:57:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AC0917C0B2; Fri, 2 Feb 2024 09:56:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="UCHawdzG" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9539377F3E for ; Fri, 2 Feb 2024 09:56:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706867805; cv=none; b=Dng3jsrFqI2YXG7kJ+yr3nvkjfYHdDy3ZgltdxOpMKWK9qDeEi4dGYJByzb/UCfLvngngloB2MBfzOM6uHJO5w2P7H1opNVLc4c5NGNk3jg3RBm0GDC9bdqnUuoVfsZKIwLAwJNMRnmlUYqkH0Nqv2l10T8v1Ew4+d/Qoh259Kk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706867805; c=relaxed/simple; bh=DPOMrDg4rKNH1QTC6aQIG7HRKerQiIwxkdnyzWqM6hg=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=cnwo6EYcZ7tvbGLQE7EIpKX5KtQdtLWP5ri4SuNWit48UNXZORt07/1ycZdyYtOWoDhubg3I060DxDyWnK0n8BVUvA6oNmM5h0V/nG15UQABoNWhh7SGJK0yFumKeOE1vq3jU/ixXXHxu7PvBO2OiyOaT3H0xlVpgzY8DjwNe2A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--saravanak.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=UCHawdzG; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--saravanak.bounces.google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6040f058d3fso41224887b3.3 for ; Fri, 02 Feb 2024 01:56:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706867802; x=1707472602; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=in2Ntwtloha/e+ZMm1Ao4y84QzaZLhLUFFn+wIIPR3U=; b=UCHawdzGbDfYJi+G5OUFfFOrGC4H4lD3CsT4/RiN1VY/my2gkK4crhCtHFCgTcNTCe iJ08cEkzyAqF4p97AAVxjeP2kNcLLge6Jl3m0IMtlM0/DO2oCM2ayjj94D3oacTqxmUH LUZJWnRMu9eRVeCaRvZYqHUf6o+weWeFerjFzOVoFLAE3cki+/HcAjhUu8vpBlcu/sHk GsSn2DejuJLgPfb7M6T7Ugqb+C+kDDsUt4vLnCEvwvsoM+5Ujzbi0SizfAUySOx2emch 0+8pkrkUTw+XTF8y1lD5T4iP4QmwlQ09bbl65prOh2GvpS9aOE+GT5LXJRTZi4kuKnQU TmPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706867802; x=1707472602; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=in2Ntwtloha/e+ZMm1Ao4y84QzaZLhLUFFn+wIIPR3U=; b=qdySg4vAlznN1eNmmZ7T9gBv7HEk/WVo3K5DRSyawPdeTM9EfWdnLbyLfMEyfFzD4b oWuzGvhFYyzWlYayPVeQvMv6jLMcKe3OpY1ElblUugkFkYmsYun9gf5+37hWwHQet9Z4 hEYimk88vhb+XnktftGjl1ABZYG89eptNJvfR+bLePGVoWrMytsPUVjcHM59s49gRw0E kedmUeSh/3lneOhg1QR2PXO6DpOKvZdT0JC/HqbuzjmkWAS9KR6UnePa64BACGUl/nNl k++UxX+Oe220HbXIEWVMsRry8Uq+Z6ZlrMMj3z9/N8pEdPKXGOlrOzgsUaSh7DN7j4Fj H4kg== X-Gm-Message-State: AOJu0YyIPtk+Ze6zANvt6e7jlxhj1eDvAMBl3j+PVHioWWGqVLjp/En0 fSvjzrO+/U6DTmy1uG2Nu8q5ccBg3+Enq1txdiARSQ0Yv9VpaTKzhWgD2dqp8nYHU7GxrQTy1OJ unkjVO2qwy+ZdDw== X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:6f0:da10:9cb3:5b3]) (user=saravanak job=sendgmr) by 2002:a05:6902:218f:b0:dc6:1a1c:6a12 with SMTP id dl15-20020a056902218f00b00dc61a1c6a12mr460305ybb.5.1706867802529; Fri, 02 Feb 2024 01:56:42 -0800 (PST) Date: Fri, 2 Feb 2024 01:56:33 -0800 In-Reply-To: <20240202095636.868578-1-saravanak@google.com> Message-Id: <20240202095636.868578-2-saravanak@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240202095636.868578-1-saravanak@google.com> X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog Subject: [PATCH v2 1/3] driver core: Fix device_link_flag_is_sync_state_only() From: Saravana Kannan To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Saravana Kannan Cc: Xu Yang , kernel-team@android.com, linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789780666418069250 X-GMAIL-MSGID: 1789780666418069250 device_link_flag_is_sync_state_only() correctly returns true on the flags of an existing device link that only implements sync_state() functionality. However, it incorrectly and confusingly returns false if it's called with DL_FLAG_SYNC_STATE_ONLY. This bug doesn't manifest in any of the existing calls to this function, but fix this confusing behavior to avoid future bugs. Fixes: 67cad5c67019 ("driver core: fw_devlink: Add DL_FLAG_CYCLE support to device links") Signed-off-by: Saravana Kannan --- drivers/base/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 14d46af40f9a..52215c4c7209 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -284,10 +284,12 @@ static bool device_is_ancestor(struct device *dev, struct device *target) return false; } +#define DL_MARKER_FLAGS (DL_FLAG_INFERRED | \ + DL_FLAG_CYCLE | \ + DL_FLAG_MANAGED) static inline bool device_link_flag_is_sync_state_only(u32 flags) { - return (flags & ~(DL_FLAG_INFERRED | DL_FLAG_CYCLE)) == - (DL_FLAG_SYNC_STATE_ONLY | DL_FLAG_MANAGED); + return (flags & ~DL_MARKER_FLAGS) == DL_FLAG_SYNC_STATE_ONLY; } /** From patchwork Fri Feb 2 09:56:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 195763 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp318958dyc; Fri, 2 Feb 2024 01:57:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IGZWylAC4DN7b5F3VRYhbb5zM2lL1G1WpZPzbv8mkxdMzfO9kvH4Ib7OE0VizdBkqmBlD8B X-Received: by 2002:a0c:aa98:0:b0:68c:81d1:cc76 with SMTP id f24-20020a0caa98000000b0068c81d1cc76mr2983966qvb.19.1706867878822; Fri, 02 Feb 2024 01:57:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706867878; cv=pass; d=google.com; s=arc-20160816; b=kRkJqlOpQ9UKj1/MJp5bPAiED5cyaqP3gdBgX0Vct1/upoLzIEKWPEPCCuixoHihOK 8/k0O/O6v3ffwus2aocb1N9f+9qkJwKrbwf4akn8hNwMtXc19WLvTj4bJR9cAx53cxFx RIcAgJUmMgMF+7D4hwyP6RNGguEQBRYoAAeJuk7TTlwEhmcLzU94mAAjEg5R/HAD3SSw ukaH8Wev43AWOkfinnQECexd/mbKEgjI8/9AWL5+GNHVzHF/RbxAuBp+0U06yhpvTpLx jBWN32efCeSAHYuDxLhRA6Tn7jeRIvNPUPVAwGvi7gSL2ZVWlJawjD3mG12BK2WDA5BL Ibww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=r5YNJyMo7T6ZuM5rJpTOCCSH+s00uoF+8fpfMCUPszE=; fh=HNQh2fOKzuAqWNKFcTQYXXg09+N+urRt+kYQhla4m8w=; b=iJTN09ZnVH+d1UMgIBXkfm5ReaOqhjGl/C4ccEdHcishNKrwqemMSHVd7EBGRPZ3Oh eMerquENvMd7USsAzX04a9B0Sb1CTP/5mUdeqrsNmxuIwE3Do/P0KombocOO7wx1WL8U Phu3bm64oPKfVfuRRo0OVhUHSZtPTY9/WNjhFzTDHOKJyfeuy8naF79ZU8l+sOlO7fAs +A4RUa+4ytoeWQ2DG5JTOcaet7GlZ91X3L+gapKVHhTnuDnmOoa3nuXGmeHMHEbcHsnt AkcEbmh6p1Ixr39M5C0602J73dX/G2V+8tuZ2I+bLs8N1RsNviRJaxV/zJmdooAfLvoK ULvA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=2ZrE8+qS; arc=pass (i=1 spf=pass spfdomain=flex--saravanak.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-49625-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49625-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCUSe7yuZZ/jEIssIuQTiLH6GogsMtEgPDZMUbvlHNjwKUOePhhtO6N+QzxkhvTuEdOi3CprYCgMus1+rejIij+vgevfsw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c2-20020a0ce7c2000000b0068c3cd4b483si1614521qvo.174.2024.02.02.01.57.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 01:57:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49625-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=2ZrE8+qS; arc=pass (i=1 spf=pass spfdomain=flex--saravanak.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-49625-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49625-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 84CC61C24899 for ; Fri, 2 Feb 2024 09:57:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4936D7CF27; Fri, 2 Feb 2024 09:56:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="2ZrE8+qS" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88EA87C099 for ; Fri, 2 Feb 2024 09:56:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706867808; cv=none; b=czV9hA8M5s+WAsA/Vt1afbDMDlWd/9eH9uL7QQH/+CTlGUu4NXku6sfSEIx/L0zip0qJhRToH74Nxd8S4AUObPqcHnII639Fg3gVEt42TYJpKnwX4PaSi+PF4ObWJd+9ktd7IqBVpw3OvDVQQNeHTqYA6OFmPka859R3Z/K6L5g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706867808; c=relaxed/simple; bh=dd+eXX+dl1OWEzo7/glw3RkA/h5jaC3FxhfWglqWQKw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=cypZZ3z7odqz2+ExPA2Ne6TbOPNAwGssQq3AW0VZ9WwODd7FnCifHfe7/f7dK7MBDv5jNUlBwGJ/0xfBMEPtQw90gTo3Ea8b8xsXIvHDpzm5HdduslAvV/jmSYRTLAopG27Mqu2ZL391URKo36RMgOzfd+W1x+/tHMbbPkTBhpc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--saravanak.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=2ZrE8+qS; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--saravanak.bounces.google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-603cbb4f06dso36340457b3.3 for ; Fri, 02 Feb 2024 01:56:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706867805; x=1707472605; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=r5YNJyMo7T6ZuM5rJpTOCCSH+s00uoF+8fpfMCUPszE=; b=2ZrE8+qSkIyhdbDoG737h+0JS5YkKVsCS5Rhj0dxzoB1Rr3yzonOo1O18/T2jt4ter 1o7z6GfoL85yfkOB7dK3kHDqc2jru1hPger6V2mvFwfxTL6B2Xd5GGwDD+Tvo+4R38hp xYzygVDKrA9BfBApM3z+rd14UWEFfznx0cO1GFTURNS/RjB2/tNo3VXI4MYQk6s98oQH JY+QwmrLVIoKAERWZbsgNKGjHJTIW2JmI1XOIufcbmWqCdJKdb57VzbAnSuqx66xLXz8 o7lo1WrMK4mnelGypTssM6t2JzTljsJbs4RcG6lB/MyeYUUCDf+Np2RB8RZBY2fcceih XZlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706867805; x=1707472605; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=r5YNJyMo7T6ZuM5rJpTOCCSH+s00uoF+8fpfMCUPszE=; b=HuYQ+8JIlH9S2bIj/0c/pU9PWhXlFYwCcASPBbDcXCf2/HM31YNpKoDebu2ymoHz1P WgqIOhcbeEJi8AX2NoZ1icNOtU3F5X7JG8irkrETEzWdCEZkW35Chg2U29g9fB9eUcLH FmcfWEEGpHskRmq8kR4TzTBa8mNN36hL3UqX55DyoNYWfamVM9vfRIWzH86znUudB81i hYjFVyIwD+WxHTCmR5pRP/JMxRj+89FBNgsGzQy2+9f6v+HEUG/sDkV6PnQ+HVj6faP9 WHZ+NGmtoRRx2HuS1nQueJSCruDuTS/KTsskwo1P/oGfzYapniOpvm5OcL3gMExKUaFh wepA== X-Gm-Message-State: AOJu0YyBDMvKd0tJHeVlXv36IzqSaOolt215H6RGMlwGdCb25IMfkSch XKbn6n1UyAHX9gekWd+OuPfr0Mc75SiqqPA7luUWd8prxOw2wpbcTprM9eng25HWVohmZBRAbGg fEhr7AO97Tuj5Yg== X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:6f0:da10:9cb3:5b3]) (user=saravanak job=sendgmr) by 2002:a81:7905:0:b0:604:1dc3:122c with SMTP id u5-20020a817905000000b006041dc3122cmr954235ywc.5.1706867805547; Fri, 02 Feb 2024 01:56:45 -0800 (PST) Date: Fri, 2 Feb 2024 01:56:34 -0800 In-Reply-To: <20240202095636.868578-1-saravanak@google.com> Message-Id: <20240202095636.868578-3-saravanak@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240202095636.868578-1-saravanak@google.com> X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog Subject: [PATCH v2 2/3] driver core: fw_devlink: Improve detection of overlapping cycles From: Saravana Kannan To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Saravana Kannan Cc: Xu Yang , kernel-team@android.com, linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789780692855028043 X-GMAIL-MSGID: 1789780692855028043 fw_devlink can detect most overlapping/intersecting cycles. However it was missing a few corner cases because of an incorrect optimization logic that tries to avoid repeating cycle detection for devices that are already marked as part of a cycle. Here's an example provided by Xu Yang (edited for clarity): usb +-----+ tcpc | | +-----+ | +--| | |----------->|EP| |--+ | | +--| |EP|<-----------| | |--+ | | B | | | +-----+ | A | | +-----+ | ^ +-----+ | | | | | +-----| C |<--+ | | +-----+ usb-phy Node A (tcpc) will be populated as device 1-0050. Node B (usb) will be populated as device 38100000.usb. Node C (usb-phy) will be populated as device 381f0040.usb-phy. The description below uses the notation: consumer --> supplier child ==> parent 1. Node C is populated as device C. No cycles detected because cycle detection is only run when a fwnode link is converted to a device link. 2. Node B is populated as device B. As we convert B --> C into a device link we run cycle detection and find and mark the device link/fwnode link cycle: C--> A --> B.EP ==> B --> C 3. Node A is populated as device A. As we convert C --> A into a device link, we see it's already part of a cycle (from step 2) and don't run cycle detection. Thus we miss detecting the cycle: A --> B.EP ==> B --> A.EP ==> A Looking at it another way, A depends on B in one way: A --> B.EP ==> B But B depends on A in two ways and we only detect the first: B --> C --> A B --> A.EP ==> A To detect both of these, we remove the incorrect optimization attempt in step 3 and run cycle detection even if the fwnode link from which the device link is being created has already been marked as part of a cycle. Reported-by: Xu Yang Closes: https://lore.kernel.org/lkml/DU2PR04MB8822693748725F85DC0CB86C8C792@DU2PR04MB8822.eurprd04.prod.outlook.com/ Fixes: 3fb16866b51d ("driver core: fw_devlink: Make cycle detection more robust") Signed-off-by: Saravana Kannan --- drivers/base/core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 52215c4c7209..e3d666461835 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2060,9 +2060,14 @@ static int fw_devlink_create_devlink(struct device *con, /* * SYNC_STATE_ONLY device links don't block probing and supports cycles. - * So cycle detection isn't necessary and shouldn't be done. + * So, one might expect that cycle detection isn't necessary for them. + * However, if the device link was marked as SYNC_STATE_ONLY because + * it's part of a cycle, then we still need to do cycle detection. This + * is because the consumer and supplier might be part of multiple cycles + * and we need to detect all those cycles. */ - if (!(flags & DL_FLAG_SYNC_STATE_ONLY)) { + if (!device_link_flag_is_sync_state_only(flags) || + flags & DL_FLAG_CYCLE) { device_links_write_lock(); if (__fw_devlink_relax_cycles(con, sup_handle)) { __fwnode_link_cycle(link); From patchwork Fri Feb 2 09:56:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 195764 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp319042dyc; Fri, 2 Feb 2024 01:58:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IHEhXyh5Aew1nkUIMAAW83uLN3ey5ItrrfS0pVd0grNR6mOtpv/+jkIPsChMFxZNADPXPkv X-Received: by 2002:a05:6214:f62:b0:68c:6369:720c with SMTP id iy2-20020a0562140f6200b0068c6369720cmr10522003qvb.18.1706867893095; Fri, 02 Feb 2024 01:58:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706867893; cv=pass; d=google.com; s=arc-20160816; b=fASTuWTepy/ST5fenjRLL5bTWYqZ3VYk9Yk7uancJ7SDnRWHb9tqh9pRmY+MHXyJSa bbNrSLgRpc+GuFjDphEWJRKG4IwGoL2vA56gcVMq03z+K1+cK/rkARlCHHeTCHRZwSok DrPa/EUrCcOcYnyQo7tP7d0DXf73CxnmgTWuDOyY+GHltrB8ayTJBi4pypoUBOeeakfV K1Vi70IqZb9ovr9tzwA3paZw5jb3HPNcPppzVEHbvUY2KPRps64NF2v1GZXMBlPM44wA YD3AzIsUKDaEEPBqz7jwo21NE0gCzCWrf2LQ33TkhLjvHGJ7Zm/GmPlNbsdA1oAO8MKX 8gEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=Ba2yXh5DewPcQ6DrcZcbJKuvXFjQcRv+6+4rV8JAEgE=; fh=sQYq9jPen8BC38aC4LOlfJbzYA50+eNg7nZGr4FthZo=; b=DjTynRSonpKs5XTRLXisQWru8uRnsUStluAL95h4MSg5Z2QUnCBwKDJCu+8LJhmrn1 Dmwnstr5O455z0GAnOqLcA58bG8aLAGoafJYR/q3ZKG0xY4Rzt5XTrtJOusXkSIBPt+m kePv8gVlPxr+k9ht82SicE2p5N54/CZKE31eKSMoZ9ONhUnXsSSVj/gq9E0d0LklK16S 8eZYWimYxclhVNiAQ1PUyjKoCa9AqPzFAuxUMWbwYhHrEVj3rTYn+cyhxQXwiwoNxFag SoCajxS8S/bhsT6cqcuC74EzpdRPNCXS4X+RIJUir0fNYYlmxckoFKkB7OziIV45T/NJ Qlyg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=lqqk6dyP; arc=pass (i=1 spf=pass spfdomain=flex--saravanak.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-49626-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49626-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCUJ0RkrsKuvzxfiUL+LlgEtGORKKH9pLtqVFpxTeekkVURdObZ1JmFTP5LZVjQWoG8J8le/luy36WSdwVMwV+ZRPaUfUA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id n3-20020a05620a222300b0078403334a55si1576519qkh.133.2024.02.02.01.58.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 01:58:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49626-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=lqqk6dyP; arc=pass (i=1 spf=pass spfdomain=flex--saravanak.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-49626-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49626-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 DD2DB1C253AB for ; Fri, 2 Feb 2024 09:58:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A3937E56A; Fri, 2 Feb 2024 09:56:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lqqk6dyP" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5470B7CF00 for ; Fri, 2 Feb 2024 09:56:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706867810; cv=none; b=JPRx3ZBIGvHLEGevd9VPVoS6+pgQGb8JFfoFv5C/tXgWbVBA9bzs3AfoiE7UOOys2cBvb4DhR2SiA6FVF1yxMOa3eSI9mm7ypEMpqxSugiJ5ci9WrIM6CGkAr9RuzFrs+8RAeM3x1NTzw7RJ1i0hekSUOrw7S5R6FnzFAQA9W3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706867810; c=relaxed/simple; bh=PUyaVOGSZrND1vU/Y/HUwXG66UDPip9IiA9OmTvHwRg=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=D/lN0i5Iui4sqLEyW8/rGs/plYiVlWhjxjPvV+F97fZ4uWMuHRkN7V8UDSOoVl4cd3/1fbgow4GxdZKp6coVCnD5MN1EqcsRvSwwq/475QBH3TEXRX1p0mKagzku8/Xn/TYxhogHNeFeYaZnXs6PwgsJW9IUaAeyNcdpIU3lVIo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--saravanak.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=lqqk6dyP; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--saravanak.bounces.google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6041e5b4367so26879837b3.3 for ; Fri, 02 Feb 2024 01:56:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706867808; x=1707472608; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Ba2yXh5DewPcQ6DrcZcbJKuvXFjQcRv+6+4rV8JAEgE=; b=lqqk6dyPh6MBo7rPnlvLGhhf4J124KWEJUkmhXShy8UGFWh7t/0oaSiJRNGimqRpp0 95+tMzms/m6mSS+qpRZ61474vBIuoeedDsqOHvopA6KF+vmzSMBINTFJqhbqMTKNVqGj 85hgTI7tMukc4vHfQGJLgJvvAqWLQOT5pAnVevm+7r+KlOT6W4fSNRxEwZ41LvlCmaWv SLGZgOkDB0Ll47r/6Qulc7DHKSqz5HIjxGAIebTHYCtruDXcQ5xKFynn6l1jL7B1yro6 IejLngtRw/2nmLD6TPzVSkUSCU3kp4nt8YKReeE2JbSC13W7GI+IiMww/1nqt6vbzL/b U7rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706867808; x=1707472608; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ba2yXh5DewPcQ6DrcZcbJKuvXFjQcRv+6+4rV8JAEgE=; b=BCWkoTWrFuut/1VmLpw/SPhYDbQE/MQPr6JP93juV9wUjk0O4a2k//1HDLFbxjchdk QQaffJSrzJeGYvR1ZrOpSf4FfepSNK7ZLQjiejOufinNdf3WOs8TMXV5VXfwZi1p1DDn 8ABrZi4bGJ4WZN5fdDjrcCIMl69Yd1Ni61+aV6XinX6FiQyvKoLiskah0wmsUjUrzftd hVwjLOBSJQMQf29MHCiyzmm5pHBeOoli9CZnjHS0DLLweOAEBLCpFnl6s3/egyZGNUIB AlEUPPHjTT6AYzr3rwZYsUPp3I+4dLqDcHPeiXWldAvNe3aopJ4sX36djbv4ChDAcUyZ S7GA== X-Gm-Message-State: AOJu0YynJy/1MQTVIBBNeyFuxmtu5ijQkhqRRfSIwQNMHFA1SGy52k41 o4qrFFeoJZ6GdlvqGyS0GKVlgoQFgDD1kzlrpSTs2jYD8tVq/qxheIkYNW0Hdge09FXhFh4+lbi MG3/MSAOlcEEEmA== X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:6f0:da10:9cb3:5b3]) (user=saravanak job=sendgmr) by 2002:a81:79cd:0:b0:5fb:7e5b:b877 with SMTP id u196-20020a8179cd000000b005fb7e5bb877mr1223600ywc.7.1706867808385; Fri, 02 Feb 2024 01:56:48 -0800 (PST) Date: Fri, 2 Feb 2024 01:56:35 -0800 In-Reply-To: <20240202095636.868578-1-saravanak@google.com> Message-Id: <20240202095636.868578-4-saravanak@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240202095636.868578-1-saravanak@google.com> X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog Subject: [PATCH v2 3/3] driver core: fw_devlink: Improve logs for cycle detection From: Saravana Kannan To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Saravana Kannan Cc: Xu Yang , kernel-team@android.com, linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789780707569897488 X-GMAIL-MSGID: 1789780707569897488 The links in a cycle are not all logged in a consistent manner or not logged at all. Make them consistent by adding a "cycle:" string and log all the link in the cycles (even the child ==> parent dependency) so that it's easier to debug cycle detection code. Also, mark the start and end of a cycle so it's easy to tell when multiple cycles are logged back to back. Signed-off-by: Saravana Kannan --- drivers/base/core.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index e3d666461835..9828da9b933c 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -125,7 +125,7 @@ static void __fwnode_link_del(struct fwnode_link *link) */ static void __fwnode_link_cycle(struct fwnode_link *link) { - pr_debug("%pfwf: Relaxing link with %pfwf\n", + pr_debug("%pfwf: cycle: depends on %pfwf\n", link->consumer, link->supplier); link->flags |= FWLINK_FLAG_CYCLE; } @@ -1945,6 +1945,7 @@ static bool __fw_devlink_relax_cycles(struct device *con, /* Termination condition. */ if (sup_dev == con) { + pr_debug("----- cycle: start -----\n"); ret = true; goto out; } @@ -1976,8 +1977,11 @@ static bool __fw_devlink_relax_cycles(struct device *con, else par_dev = fwnode_get_next_parent_dev(sup_handle); - if (par_dev && __fw_devlink_relax_cycles(con, par_dev->fwnode)) + if (par_dev && __fw_devlink_relax_cycles(con, par_dev->fwnode)) { + pr_debug("%pfwf: cycle: child of %pfwf\n", sup_handle, + par_dev->fwnode); ret = true; + } if (!sup_dev) goto out; @@ -1993,6 +1997,8 @@ static bool __fw_devlink_relax_cycles(struct device *con, if (__fw_devlink_relax_cycles(con, dev_link->supplier->fwnode)) { + pr_debug("%pfwf: cycle: depends on %pfwf\n", sup_handle, + dev_link->supplier->fwnode); fw_devlink_relax_link(dev_link); dev_link->flags |= DL_FLAG_CYCLE; ret = true; @@ -2072,6 +2078,7 @@ static int fw_devlink_create_devlink(struct device *con, if (__fw_devlink_relax_cycles(con, sup_handle)) { __fwnode_link_cycle(link); flags = fw_devlink_get_flags(link->flags); + pr_debug("----- cycle: end -----\n"); dev_info(con, "Fixed dependency cycle(s) with %pfwf\n", sup_handle); }