Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp494491rdb; Tue, 5 Dec 2023 10:54:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IFHAkztG23bKaULaU9lX2SONMnFMrTPJQ4DYZwBRRzw8M1TRkbvfbFRoxI1UzzTCHMJCyEc X-Received: by 2002:a05:6a20:1448:b0:18c:374c:6e64 with SMTP id a8-20020a056a20144800b0018c374c6e64mr29510619pzi.36.1701802450196; Tue, 05 Dec 2023 10:54:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701802450; cv=pass; d=google.com; s=arc-20160816; b=KR8L8VUULqh6eHEctA4XznuqmKTeL3eHM0eUhCHsHR2rY1DlvO3AhwV3zkbo2E7k8Z GpS95Xm+8eZifgXVsR128niENudA94lpt8uHyHM5ikc9q8GuDdB0V5G1Kxd5QoKJVBl3 YOq/fYrO/eSLaeBbRSY7FskIl3EF7WUmVCnghAhVXc+zs+GshBzvqMbgq0O1zfnVKJ7a uXQMbxwKxE6aqze7DeigUKSt14L+mN/YjRPkKTob4bCfZ7SxpPvEfoWgGySu2FOwiwiK 9EGtpGFTr8Or4vy/L4wKOsK9kSgzkeatECPrKMQENytNmp5/CjoM4bfsNF9ko8IR64Xo 5WsA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=k/CzHMItTCPARyJCyDd4G8chxipuR3RmnjsiLeSi8Lk=; fh=BaREg8TRPOcvnc5gFJtslmAnIkynmF3E0mUv+udGsl4=; b=GdnuGxuRo4QRnAdlPmZSqunwlOZeni2xfgNZemZWxjRYEAlv/QDDvHFQi8OHNbHJBF fNic47UrMjeDMEECWl4tRQkM6QvtvIHHXB/XgakSBk2FdQE2wg7FrCoJRA7fvogSCdCZ fJnQQ/XRNuU4hakF9NrJ5KfB1D3+BsVkG5f3QyNNhnhYD75Jumi2pV1Skl8gd3n5t+6e fEJGna8vp+T3y8eAdO96fXyGUVmLEQR5lZvJq9veoioLxnGmoBPDSwDfd4Tg2lnJTTwE RH/ikoIvtVwyLGRxzDZ5XhOC11N1qfuJ8V/TMjxF6WhvNTQzG+JwL5klPEXkJYEw+S6e Kgdg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=yUEWlaMu; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id a72-20020a63904b000000b005c65bfc76b7si6310809pge.570.2023.12.05.10.54.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 10:54:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=yUEWlaMu; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 2F80580ABF35; Tue, 5 Dec 2023 10:54:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230460AbjLESxv (ORCPT + 99 others); Tue, 5 Dec 2023 13:53:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229569AbjLESxt (ORCPT ); Tue, 5 Dec 2023 13:53:49 -0500 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2058.outbound.protection.outlook.com [40.107.102.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1861BCA; Tue, 5 Dec 2023 10:53:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HDsbhbs9+Ca4/xjBWasIiskP5l6mJeps5fvRQX+BPRYttnx4jFyVrmJhtyXcqeBl2GFuWBd15YfBWrdKIxMrDsZUKjW9eEqMSi7RL3XdINqbukzTYZpeVVcjw99RcnU/wRSW0iJ/3vnxv9a9hidYNxYdDBnrCsUuOoSlvhbIXBe6+bLEPcFeVrJ0Aj12BMr2TweHLlT4tIeoMnZHcspL4g4CBuDysRE89boIzAL58TTN+KFX3LrFUSFlUT3hoS3Glkcta+kC2VQlt/JpH2xmjRd/ZtlNq8Svq3AcF8UKyBI11wRgVnPEqtZZnm+McXpjn90dRm66RIzGjp8erwO5hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=k/CzHMItTCPARyJCyDd4G8chxipuR3RmnjsiLeSi8Lk=; b=Rmon5d9WJs65ctbekn98xTYJN+ZEZ6F9pbj/nn95ljRmX4fUJ/qCQwi+CuezNBkaxGj/Mm4fOKrViKpmt+VmzVoAZVeZ1B7MrBy1mgdPfhbSXbUDs/FceAsDSd5K/xENMPeVhZJf8tEtBKLStgj6Q4XvK/xUB03v/13w76o/gE+/dJH0+8O5OOs3ICTzxDuOpL78pan11hWTKnbZUTBW9j2ymujr7m9AwiJ+dXuimeDCCbDxjyKUeyIENA/wbPxPtZJ2fq17PH8oY9utSWxAIsrJGtOe1V9mm40zZWfZgCxUBveTUArYeoUaqoINyJudHR8kR6J5/qKRomLwd60c5w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k/CzHMItTCPARyJCyDd4G8chxipuR3RmnjsiLeSi8Lk=; b=yUEWlaMui8R5RpC2lh6VXb6jg2GqaR29+rt2r/lymzCoaj3unmg9b2bB7i2jQDknn4hBqI5/2jgkRJPU1RRvPbHQkifAChQ9Kzs56qD5Drb0s6UZFyOW2Cp9Fj9rXXcMszpElY0VibWR8k2gay0JrrNSagMLa0hMflBEptxappc= Received: from MW4P222CA0016.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::21) by BN9PR12MB5067.namprd12.prod.outlook.com (2603:10b6:408:134::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Tue, 5 Dec 2023 18:53:50 +0000 Received: from CO1PEPF000044F3.namprd05.prod.outlook.com (2603:10b6:303:114:cafe::14) by MW4P222CA0016.outlook.office365.com (2603:10b6:303:114::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Tue, 5 Dec 2023 18:53:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1PEPF000044F3.mail.protection.outlook.com (10.167.241.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Tue, 5 Dec 2023 18:53:50 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 5 Dec 2023 12:53:49 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Tue, 5 Dec 2023 10:53:49 -0800 Received: from [172.19.74.144] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.34 via Frontend Transport; Tue, 5 Dec 2023 12:53:47 -0600 Message-ID: <0cd5fe3b-8039-e534-03ac-aa6fd8f9c7c0@amd.com> Date: Tue, 5 Dec 2023 10:53:47 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v2 0/2] Attach DT nodes to existing PCI devices Content-Language: en-US To: Rob Herring , Herve Codina CC: Greg Kroah-Hartman , "Rafael J. Wysocki" , Bjorn Helgaas , Max Zhen , Sonal Santan , Stefano Stabellini , Jonathan Cameron , "linux-kernel@vger.kernel.org" , PCI , "Allan Nielsen" , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni References: <20231130165700.685764-1-herve.codina@bootlin.com> <20231204134335.3ded3d46@bootlin.com> <20231204163014.4da383f2@bootlin.com> From: Lizhi Hou In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F3:EE_|BN9PR12MB5067:EE_ X-MS-Office365-Filtering-Correlation-Id: 8165f3c9-9886-44d9-3115-08dbf5c3850c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nCnRbcd+bc1jZynQl/N4vciCSfIO0qbHM6GchWrOxUequzvbF9lVlWBgpaXvfDjDfyHbKB4bMaO9zcudiqNdJyj4hPXrQUNMpbm1iN0FczhfJ9enH4fiCN076ikfk2vh9seXuoPIeGIbENS5C7xuYBIgWi2R7DDCAvFe09RiLVWvScjKGqWvaKros7+Qaypiw83z2OCy3aIyYdi875ZK97lyvClzpDAg0MARW4rl29T9lKUMeJ+yOyKe3VIu+tLQO7RXumDSwU1h0epH+mJ9sEa6tTQLwoVXr4ItGhDhN3XBQvsk8OfT7sFQqKPmQUJKqh4an5O8/pRSo8i2ada04pCWHy06gqQ5R6UBhHKjOahb5vSxJR3KhtxT1GZ2jEwpkw/swn2NQ3+sIsuUhr9Jyrh4I/TFA6Dxsvu+hZRC3OdkzWiqdRghgZx6qMj61qdWrwc9jjpI+SMBScMV2Aiy9k4cjdP5bp1VXTKsmo4I6qBRaE9yVWzjufBtM2oUGEllPJAYOhdLPL+ws0eNF88fhULZZCvDIn2em3x0c+5c9Pbt/MxgFvblOptWfYfxbb8C+Xbrbwgy8yesiyeGfinkIUlkeEj8BFg5xxDJPP3EXhtMfOdsA24CgmUcQr/CgPXGO57YXC0EHuFZJUL1jxbdjjXrhYdg8vjE4V7oz0tm8QTmvW9w8tgO8jULWTBf6thxN4sHD7THbtyVqLOCxjErL6uIDj4guFYo1DXj+BHGZJoI4YuMjxrE4DMYx4KdwnUMnkZvo1Y9pLhexVRGmteNmLf9aNWLAAUn3Od50UbUJwNY0GbdPKRRi8ofZNW+YT3jgHVcPyNhcABDuHNzpfBxRg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(136003)(396003)(346002)(376002)(39860400002)(230922051799003)(230173577357003)(230273577357003)(64100799003)(451199024)(1800799012)(82310400011)(186009)(46966006)(40470700004)(36840700001)(31696002)(40460700003)(44832011)(82740400003)(2906002)(5660300002)(7416002)(36756003)(86362001)(41300700001)(478600001)(966005)(40480700001)(53546011)(36860700001)(83380400001)(26005)(2616005)(47076005)(426003)(336012)(31686004)(8676002)(4326008)(8936002)(81166007)(70586007)(70206006)(356005)(110136005)(54906003)(16576012)(316002)(43740500002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2023 18:53:50.0778 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8165f3c9-9886-44d9-3115-08dbf5c3850c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F3.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5067 X-Spam-Status: No, score=-4.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 05 Dec 2023 10:54:07 -0800 (PST) On 12/4/23 15:03, Rob Herring wrote: > On Mon, Dec 4, 2023 at 9:30 AM Herve Codina wrote: >> Hi Rob, >> >> On Mon, 4 Dec 2023 07:59:09 -0600 >> Rob Herring wrote: >> >> [...] >> >>>>> diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c >>>>> index 9c2137dae429..46b252bbe500 100644 >>>>> --- a/drivers/pci/bus.c >>>>> +++ b/drivers/pci/bus.c >>>>> @@ -342,8 +342,6 @@ void pci_bus_add_device(struct pci_dev *dev) >>>>> */ >>>>> pcibios_bus_add_device(dev); >>>>> pci_fixup_device(pci_fixup_final, dev); >>>>> - if (pci_is_bridge(dev)) >>>>> - of_pci_make_dev_node(dev); >>>>> pci_create_sysfs_dev_files(dev); >>>>> pci_proc_attach_device(dev); >>>>> pci_bridge_d3_update(dev); >>>>> diff --git a/drivers/pci/of.c b/drivers/pci/of.c >>>>> index 51e3dd0ea5ab..e15eaf0127fc 100644 >>>>> --- a/drivers/pci/of.c >>>>> +++ b/drivers/pci/of.c >>>>> @@ -31,6 +31,8 @@ int pci_set_of_node(struct pci_dev *dev) >>>>> return 0; >>>>> >>>>> node = of_pci_find_child_device(dev->bus->dev.of_node, dev->devfn); >>>>> + if (!node && pci_is_bridge(dev)) >>>>> + of_pci_make_dev_node(dev); >>>>> if (!node) >>>>> return 0; >>>> Maybe it is too early. >>>> of_pci_make_dev_node() creates a node and fills some properties based on >>>> some already set values available in the PCI device such as its struct resource >>>> values. >>>> We need to have some values set by the PCI infra in order to create our DT node >>>> with correct values. >>> Indeed, that's probably the issue I'm having. In that case, >>> DECLARE_PCI_FIXUP_HEADER should work. That's later, but still before >>> device_add(). >>> >>> I think modifying sysfs after device_add() is going to race with >>> userspace. Userspace is notified of a new device, and then the of_node >>> link may or may not be there when it reads sysfs. Also, not sure if >>> we'll need DT modaliases with PCI devices, but they won't work if the >>> DT node is not set before device_add(). >> Ok, we can try using DECLARE_PCI_FIXUP_HEADER. >> On your side, is moving from DECLARE_PCI_FIXUP_EARLY to DECLARE_PCI_FIXUP_HEADER >> fix your QEMU unittest ? > No... > > And testing the bridge part crashes. That's because there's a > dependency on the bridge->subordinate to write out bus-range and > interrupt-map. I think the fix there is we should just not write those > properties. The bus range isn't needed because the kernel does its own > assignments. For interrupt-map, it is only needed if "interrupts" is Without 'bus-range', dtc will output a warning while compiling the generated node. > present in the child devices. If not present, then the standard PCI > swizzling is used. Alternatively, I think the interrupt mapping could > be simplified to just implement the standard swizzling at each level > which isn't dependent on any of the devices on the bus. I gave that a > go where each interrupt-map just points to the parent bridge, but ran > into an issue that the bridge nodes don't have a phandle. That should > be fixable, but I'd rather go with the first option. I suppose that Do you mean it might be something similar with I posted in V12? https://lore.kernel.org/lkml/97ae2eda-f712-0b83-dc90-0f29edd5db8b@amd.com/ Thanks, Lizhi > depends on how the interrupts downstream of the PCI device need to get > resolved. It could be that the PCI device serves as the interrupt > controller and can resolve the parent interrupt on its own (which may > be needed for ACPI host anyways). > >> We have to note that between the pci_fixup_device(pci_fixup_header, dev) call >> and the device_add() call, the call to pci_set_msi_domain() is present. >> MSIs are not supported currently but in the future ... > MSI's aren't ever described in PCI nodes. Only the host bridge. So I > don't think we should have problems there. > >> Related to DT modaliases, I don't think they are needed. >> All drivers related to PCI device should be declared as pci_driver. >> Correct me if I am wrong but I think that the core PCI will load the correct >> module without any DT modalias. > Yes, you are probably right. > > Rob