Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp237647lqb; Tue, 28 May 2024 14:11:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX7zNgm4KCLWTRq/ESzybusvJSNXsojczx62c1DVXnbv3Gh+5X24q1E8mMaylayg9S++TQ0AxdtTEPRqZiXEiUguRtYMFazESPS5fjx0w== X-Google-Smtp-Source: AGHT+IGBp0qnWLJOqolw61P8ij3633XUqUMyPKUSkbqPUDrLWOBbRhvj1HsvWyDwkIcW3pPwvq9j X-Received: by 2002:a05:6a20:1593:b0:1af:a5b1:2907 with SMTP id adf61e73a8af0-1b212ce1dbdmr17126958637.3.1716930684216; Tue, 28 May 2024 14:11:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716930684; cv=pass; d=google.com; s=arc-20160816; b=iGQs1Q/gARSr4+kUK/TlifRcFD/bF62H+b3xoWQ/OIGQhVx5lDFB5X8iMygtgNcMmJ 9CvzCaYDqWxj35iLhlDFNkvQPqLgPKsT6dD7tGEe+q7PRI576Re6vnw6iY3J79tHvSIb 5gmIVYjeMd+Y1RU6NY4JSG9DKnLRJ4DIhGItT6xGXhfHleO2XVeDDkVwJXhjNgOuWfsr /0PM51+xmGnrfGuXW1vV2gWZ7yzu+IFGTa+m4DJr+31W+jL3ZucIYKe/jBoSaB7EsabK URBdq20HTnPxDLSV0l3eLsD2gEvemVpQTKtvVvvswEElgLS7y4cqwC5KXRrWOIZvkGU7 kycg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=pOio7KxeuelYGQGCOPUzhDxltxXo0iSvEqTPnlEwle4=; fh=P7YgLFPeAvcWLcLF7/zMfFrYKAz7pK2y8gGpeT0RdS8=; b=xb/JvwbwoqGbAhdyOfOIiZbXZVe0RS43IJNjNHDTXYsNt4h5W7EUjOfs+iL92FpHTf BiDxzWXuVylnMkltBMtTrMB10Ns5rAzL+Wm5HtUD9JY9jqQfS6lz5c2wydtg8NZ7PIO5 8170ER1mviQdS2B0D8nROysBPDsFvypE6ypZMpzVzl8JMT0zkX9UZfGLYn0+nJ/cg+qS 3OLC/yrSTMqQBJoyVvQwUZ2Ny65M98/zu7cyY73L7S3bhbomXoX9RbBdufUBWA1pfXee 6oy74kYA8FVQQAFOCz5zWtl1n5Cj7NamDvptWeU4MDyO4C8vicZ/IO67C7uRj1jpCFbE pmww==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=LT2tnmYU; arc=pass (i=1 dkim=pass dkdomain=bgdev-pl.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-wireless+bounces-8230-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8230-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-68221c69f94si8937855a12.160.2024.05.28.14.11.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 14:11:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-8230-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=LT2tnmYU; arc=pass (i=1 dkim=pass dkdomain=bgdev-pl.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-wireless+bounces-8230-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8230-linux.lists.archive=gmail.com@vger.kernel.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id DD17E2892FB for ; Tue, 28 May 2024 19:10:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B0C4181CF7; Tue, 28 May 2024 19:04:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="LT2tnmYU" X-Original-To: linux-wireless@vger.kernel.org Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 B58C6181306 for ; Tue, 28 May 2024 19:04:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716923052; cv=none; b=dKzTPYbinhacUT4/M09EG5/weYvMl7E6JIvI9KE/Y3v8cj0/sVB6H0OLLbstu/nRw3q793ONc6w1V5ME0FGucQdy+7Ge4GA1j8+/u2ezznvyiOpo7yBlddd4iq7uP3LTjUrrQeDjpd5HZRruq9SltqwhO1bqJ30EMSRGQfBiQRo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716923052; c=relaxed/simple; bh=Ktt2chxHVmf/NT6RXlWvzdDGnqCPL5KmvxHVj506Psw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Pd9sHeDuRX+ZLXYL9dbzxWMG2aElb+LGrJoXYnwHwwy1jTtBbt04Y3R/evrb95KYtuuhGYT2Pr1y8p+gn6Bmp1q79rBhL5t8lPncNxFbMwBlyZrSZTKxaD61NW2hq2A40SsK4L9Dbhj/bzu+u6zppWC6AYezwwT5vfV8b1IuvUM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=LT2tnmYU; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4211249fdf4so10758485e9.3 for ; Tue, 28 May 2024 12:04:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1716923045; x=1717527845; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=pOio7KxeuelYGQGCOPUzhDxltxXo0iSvEqTPnlEwle4=; b=LT2tnmYU1LjtbLLv3LhJ6SFo7GIzIlndHf/MbMlmv/nGD50FKiK5AeyKzy6/2Qrn6D FIKgdHQGOvmTLK3t7mHOAFRqI63X9Ud37VkflWpJuosYWEK4s5A9avriOEFF+bD3K5/A TZZq1W9Tf83a2Y7OeWeUqQzfbtCChjbbSBkkt1h16psY6HcsJnzoVBqV4/YtqFVQzveu uCBdYiZR8sOs1Y/sh8GvSdnhqcMYB3XS0ahDEcNxny76PnOAAljleOqWFHX/vV+uj6UY Wetf3agv4/qKLZC8BwW0fLwL5LwNTY3CFA59zORfkecpV6+wqqUtmDaiRGMUV4/SCUml kgEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716923045; x=1717527845; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pOio7KxeuelYGQGCOPUzhDxltxXo0iSvEqTPnlEwle4=; b=qjKGyzGPlpQ8APDo+O0fjOvG7oj4XY1PC3YBhaVp+ph21y4rdPqhtuJ50g8AHk1kw8 jJevx/euBMJ+t17ahMI3KJ6bg/sfgNJ2sfYhOEYYakshgsY2+XwNYkpNdqqCBh1oei6h h9e3uzoX6hbHijQRs9yEQb3n534sK8br0HMWoOzn8rmzX8UOdwKHZ7lphdOUpJx6cusn AVSgAlB4I9jYfI9XN7CEy1OrEdw/NxrL6mXTdHplIBoL+Gsgmuhfx3YPTXC3AM8bx2Ba tfUsnSfhDNeJk8mvyyV/PsuUpd/FKGJ95myhOfZdJEl541qcanrzkFXkPoS50AElel0H bJGw== X-Forwarded-Encrypted: i=1; AJvYcCXT9wK+zC5INyqbylNcp0Qaa7HY9PLnOezTazgutmmd5J7Xd7tSOTuJVv7P2JivBNQXUTgQoTg5xW33l1Cs7Svqg1mWLSsoIfl/FYYfWMc= X-Gm-Message-State: AOJu0YzZXGpOjo2Q1mKffb65x0fJEB8llfzh/qIGSv+xc2Pq1LOZ3khe 5x7CvTUDzWi4f3UCHXTLaNYHyZbEJyjUjJRF3u1EEzYrRjEwaKPIbA68eWaFFtk= X-Received: by 2002:a05:600c:63d5:b0:417:fbc2:caf8 with SMTP id 5b1f17b1804b1-42108a7a3c0mr101292595e9.23.1716923045541; Tue, 28 May 2024 12:04:05 -0700 (PDT) Received: from [127.0.1.1] ([2a01:cb1d:75a:e000:93eb:927a:e851:8a2f]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42100ee954bsm183895415e9.4.2024.05.28.12.04.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 12:04:05 -0700 (PDT) From: Bartosz Golaszewski Date: Tue, 28 May 2024 21:03:21 +0200 Subject: [PATCH v8 13/17] PCI/pwrctl: reuse the OF node for power controlled devices Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240528-pwrseq-v8-13-d354d52b763c@linaro.org> References: <20240528-pwrseq-v8-0-d354d52b763c@linaro.org> In-Reply-To: <20240528-pwrseq-v8-0-d354d52b763c@linaro.org> To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Marcel Holtmann , Luiz Augusto von Dentz , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Balakrishna Godavarthi , Rocky Liao , Kalle Valo , Jeff Johnson , Bjorn Andersson , Konrad Dybcio , Bartosz Golaszewski , Bjorn Helgaas , Srini Kandagatla , Elliot Berman , Caleb Connolly , Neil Armstrong , Dmitry Baryshkov , Alex Elder Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, ath11k@lists.infradead.org, Jeff Johnson , ath12k@lists.infradead.org, linux-pm@vger.kernel.org, linux-pci@vger.kernel.org, Bartosz Golaszewski , kernel@quicinc.com, Amit Pundir X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1806; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=Y7OeFprz/Vcrv+LqGfLVY2kADqOCusmg0pTxdfuWyrw=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBmViqQlowqris4OXk74HDsTXkEu2fb7ceXtIZ3t /1F4SawtlqJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZlYqkAAKCRARpy6gFHHX ciu+D/9gNcUh7shLnVNjWY/dgJjWjWqDorXUw/wX6sJBNrxubSO/gyKc9jr+AWug2lgBqlQOp+k CdVkl6SrVCko/z9s5SrcQrVFUBVrWq1hC8w/GWKtZSHuzDKHab8s3sdzs3Y5pnLrak0kn25osA9 D1JYD3NDkY803OYw0RHiGx+GCXTuPj9I7Ld2/eYTJXL8rfJxhX5Yo7Iectb5BNvRaMhrveN0kJx 52sOrp6To2YqkPkRo5zcBVdcs0gt2d2/yL7LcFe0z7hSzDDgYlae6zUPC4eDqPEoSdWimDfp5pe kA9A5ci2MG7VwRP86OiKpcO8jcMX4+1Fz610EvQ8M7Z2adXIvzF1xrN9Qk0Cp+sQuD+w7WxWheC lY0eFf9MpFqLS+lJIDGAvclGtlhP1fCT69UwRrY/Qo7ijTsj/R0eMwHWnKOxaLwtgvplTWT16sX nZ3/83iFmyg4unCn8iYVrq650oBohZgiKMp8JePv/KInST3DHQ6HiCfgBcodc3GbX9P+Ja8OCVp 8fM829/xJlqWbti0o9rRzYslm7y/ZvEH0VH0MxaN7giPt1WAxcMtSifoKQwdzcyNxuvHi3Btsim e66eK6rvw6UD6V/avQlxkr+wgJ/DLZhAi0Zofr+BPGpvxgz9AEEMCZm5KQaxZj6S3mbgMlMBIl+ h5eAPbGFHqC6OQw== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski With PCI power control we deal with two struct device objects bound to two different drivers but consuming the same OF node. We must not bind the pinctrl twice. To that end: before setting the OF node of the newly instantiated PCI device, check if a platform device consuming the same OF node doesn't already exist on the platform bus and - if so - mark the PCI device as reusing the OF node. Tested-by: Amit Pundir Signed-off-by: Bartosz Golaszewski --- drivers/pci/of.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index 51e3dd0ea5ab..b908fe1ae951 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -6,6 +6,7 @@ */ #define pr_fmt(fmt) "PCI: OF: " fmt +#include #include #include #include @@ -13,6 +14,7 @@ #include #include #include +#include #include "pci.h" #ifdef CONFIG_PCI @@ -25,16 +27,20 @@ */ int pci_set_of_node(struct pci_dev *dev) { - struct device_node *node; - if (!dev->bus->dev.of_node) return 0; - node = of_pci_find_child_device(dev->bus->dev.of_node, dev->devfn); + struct device_node *node __free(device_node) = + of_pci_find_child_device(dev->bus->dev.of_node, dev->devfn); if (!node) return 0; - device_set_node(&dev->dev, of_fwnode_handle(node)); + struct device *pdev __free(put_device) = + bus_find_device_by_of_node(&platform_bus_type, node); + if (pdev) + dev->bus->dev.of_node_reused = true; + + device_set_node(&dev->dev, of_fwnode_handle(no_free_ptr(node))); return 0; } -- 2.43.0