From patchwork Tue Oct 18 13:23:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 4167 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1962328wrs; Tue, 18 Oct 2022 06:32:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5EudkjHaRSvywlv7q3uWsronfqBsWGFuwBjZSYkjucXkCn7+696YJix2wZ0lfW7JUHJD0O X-Received: by 2002:a17:902:ef51:b0:180:7922:ce40 with SMTP id e17-20020a170902ef5100b001807922ce40mr3023633plx.8.1666099941445; Tue, 18 Oct 2022 06:32:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666099941; cv=pass; d=google.com; s=arc-20160816; b=z+m3Q7FhOqPs0r25bMeB/90CH1uYDFuxPURHz5QKovAGg7GiYbX4inMFWdRRafMvBY go3rKWTEOa2BYhe3JMBl8s7L4qo1R/jyovk0sSNqjBY4KHigMR8OipAwfJSSpV1NL/30 NlJuE4XnP+bNPR45kNliOsZRh9LcpAG/zuUz2NyIzP7Raahl/cpFudpWRG7gc51ISdmW HDw23S7kAWm6EkC8v26lg9XwFt3VlqqzHCR6RnbHHvSRugzXmMGluo7TvNgE4D3cZCbz fn4TVTB7PxGLbSmgP0BYKlAkHOQ6Zr8/Hm7nfnyFrw5Wc/SVvQ140jNUvqraGGy6RKiU buWA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=f/a9B99D9lL5e4OLFYu9Rds+YYIxrhyEH/lIibAjCuc=; b=AdP3Ufk+MmD02EB0UiWytGZhzR98/BgZNDFcfKN8CjjaF7TWD+yNYNfE3wgWLcHQtZ shjekW3kw1tXYvW22urSI5mu4jz9ZeJukHcwSWjskgiDUYN2p6ASWMl0p93tE/itHSNf N1BsF58NUAALHeyGp6QgRyBS3L89lQV7QYuwnvw+hoDUQaJQzNoKttRS1CrfwJ8Bzoqk XmzIJYy4oCDCamzdEbstHZLJfcptBR2azLil2icqCdtad7HhFNtQxbi9aYCWc0cZjDUA 3ppAFQYmmirnvTnvMwMYHs++IfAJrMUbZiezYjQ78T5REAsOVzesrdH/cuy0T3YQssYF HRnw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=gsuadDpu; 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 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n13-20020a170902d2cd00b001751d0ac52asi17984496plc.435.2022.10.18.06.32.08; Tue, 18 Oct 2022 06:32:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=gsuadDpu; 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 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230394AbiJRNYQ (ORCPT + 99 others); Tue, 18 Oct 2022 09:24:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229731AbiJRNYN (ORCPT ); Tue, 18 Oct 2022 09:24:13 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2079.outbound.protection.outlook.com [40.107.94.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 563C6C90DC; Tue, 18 Oct 2022 06:24:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f4m6zYIVdFVTkQag0r1wcRHykMFLI+EC+1oxOgXVJqmGCmV7KXUHWNXl0hwBV3ZqWLha5nMP/wf5dQsi99i4jfViKLxlNdJzc9NgDuHmpEmryeimE8p3cmHw5FgAt7gzlyZIb3m/m/cG5vTpYdpp2UREXGqGZK85fg1iEv6QmRFdWZYQo4RHn4dc6TAs9KAXE+ZGfm39l9mBQsH4PyAmIQITq3LPfZSaRMTIaGS4kwOMDExo0wpbzb7Dc0NdWQEEeu35Byp0PdTwidgDrR0yQ3Erdr/YWEA8+jcPhS2gISSI11z8PPkZN2YwfW2DJF1POQwIPydWb8UTDIHVrVdvsw== 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=f/a9B99D9lL5e4OLFYu9Rds+YYIxrhyEH/lIibAjCuc=; b=Jd1G3itwddBUPSmh3CD6OFAfvUAocMdM6pX8GpfnSh3XlwDcn8k70y2RX1zhqAy3HBl6DcVlt3Ruz1Z4/bKeCvjVXtGefUskq189pqgI3Ft/BE46JBdLxF45Jf2cgbyLBkqXdA6R2Q0iwproJfqZveNp2DsttudKpMgAkVijXXPwOCqqQgzJCP+zFiOLkNh5yiN8vGNy2KjBy4C8KGdG8waCMI2dLw+QV4ie+N6Kji8+7jaDP+AbA/Ld6lq49PHZLub3vfQIX7M/Hoh3fzT+tQ3BRzHSqOPwt8poj9/Fa6slLm1hash+5cIiL3LDA5sHE22j1mU+5K4eaOXdaG1tdQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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 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=f/a9B99D9lL5e4OLFYu9Rds+YYIxrhyEH/lIibAjCuc=; b=gsuadDpu/BBZL7lgDFf3kZlGQolagQCYIC+tjf/GTu2PXxl6EtWXlxx3rspCQ3O8UAHpkn6R8OfR8gIlrfcaRKihipwJyy1RUlDsSoV4qHUef7+e0LrN08KZliNHFhYMYL4EEtJasYsdK5J+gtT2TUxl+42Y9/dw0Pq7KHf+b68= Received: from BN9PR03CA0982.namprd03.prod.outlook.com (2603:10b6:408:109::27) by DS7PR12MB6214.namprd12.prod.outlook.com (2603:10b6:8:96::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.33; Tue, 18 Oct 2022 13:24:08 +0000 Received: from BN8NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:408:109:cafe::b2) by BN9PR03CA0982.outlook.office365.com (2603:10b6:408:109::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30 via Frontend Transport; Tue, 18 Oct 2022 13:24:08 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT033.mail.protection.outlook.com (10.13.177.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:24:08 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 08:24:05 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter , "kernel test robot" Subject: [PATCH v2 01/12] cxl/core: Remove duplicate declaration of devm_cxl_iomap_block() Date: Tue, 18 Oct 2022 15:23:29 +0200 Message-ID: <20221018132341.76259-2-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT033:EE_|DS7PR12MB6214:EE_ X-MS-Office365-Filtering-Correlation-Id: df98865c-7bc1-41b2-50aa-08dab10c0978 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +QjmsPqXIgcFQ1yCSlA1XCmF5MhTj6JvfvMQHVUHRBDNk18wz2qR+mxRELEcaROu6t02d9EVeQVqjkkiymfsJp2u/JGJUA1VAXKrFdbo11mDwQ2/UlM8ZiHuECg5H+qa685YU2HxerQsuKfM5KrdkyIZR85ExGrWjT2wtcQFem8F7EAhwKyekCe2EMxmMIWjRLrFriUJnbQLDRPNpr5TorQRlPPiusujpnIGJPR3mraTz8HFbJSLu241j+DaFFfsUoMjlYusqViEvDuXq5Xuly0B0Lk8tVoSkW+Ro1Zyrx1VOcLJqKYBUqP8V2ZnINmGyMoIwIYIJZgw4QZcT0W1FFDEp8epXTQ/ISscBCGYZd0a16CmfeHODVNXNyiw5GVq9a/Vr7V4nSulPh2hPZx6qDGeRLTUwPBgZ1KXRb1HpXWIBX8SoJg8lmGuzQAu/W1Rl67w6aMSeHiBat57tXtUR86t93ijnQAif99W1q5/mjHetNePf66n8PRTZsdDzgYg/yJDRcr30k8IP05GkFvRY1z30ORhoc8RnuMMBni7NXJ5q6QnrM6ibXPT4H45HNxtBct+UzRSC2NOwEIcPkw1KtbA7HXmgb83o72nEzAisCQxz4ACDKBLqZFadnouCQ0a9Tau3JuGl3NzhUnieyeQZFrMGidrvbS9s4qIWhfxG+6a2q/vJ5jkcGRyqvNSZez6URDj8loHdnZ+NlAacj/qLcgZSi8k2exDTALaV9RDkWUKARabCd37Rc2ZJwn2vM6FNOTJQOqxBr2DblwjkuGUrXNPn4KbosKx3rYxOj+NawNxMgK8A4QwN4K/X24btSK5 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(136003)(376002)(396003)(346002)(451199015)(46966006)(36840700001)(40470700004)(40480700001)(54906003)(316002)(110136005)(478600001)(6666004)(41300700001)(26005)(8676002)(4326008)(8936002)(2616005)(36756003)(5660300002)(70586007)(70206006)(2906002)(186003)(1076003)(16526019)(7416002)(83380400001)(81166007)(356005)(40460700003)(36860700001)(47076005)(426003)(336012)(82740400003)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:24:08.2481 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df98865c-7bc1-41b2-50aa-08dab10c0978 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6214 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747032412592344607?= X-GMAIL-MSGID: =?utf-8?q?1747032412592344607?= The function devm_cxl_iomap_block() is only used in the core code. There are two declarations in header files of it, in drivers/cxl/core/core.h and drivers/cxl/cxl.h. Remove its unused declaration in drivers/cxl/cxl.h. Fixing build error in regs.c found by kernel test robot by including "core.h" there. Signed-off-by: Robert Richter Reported-by: kernel test robot Reviewed-by: Jonathan Cameron Reviewed-by: Davidlohr Bueso Reviewed-by: Dan Williams --- drivers/cxl/core/regs.c | 2 ++ drivers/cxl/cxl.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index 39a129c57d40..6522931df3f7 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -7,6 +7,8 @@ #include #include +#include "core.h" + /** * DOC: cxl registers * diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h index f680450f0b16..ac8998b627b5 100644 --- a/drivers/cxl/cxl.h +++ b/drivers/cxl/cxl.h @@ -218,8 +218,6 @@ int cxl_map_device_regs(struct pci_dev *pdev, enum cxl_regloc_type; int cxl_find_regblock(struct pci_dev *pdev, enum cxl_regloc_type type, struct cxl_register_map *map); -void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr, - resource_size_t length); #define CXL_RESOURCE_NONE ((resource_size_t) -1) #define CXL_TARGET_STRLEN 20 From patchwork Tue Oct 18 13:23:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 4165 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1962258wrs; Tue, 18 Oct 2022 06:32:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4GKlkuZ5LPiX8+8Dd48nToNjNvkTItx8a6Y6cRAFPOx3dgh+2XmqyD5NXI9BF8O+1cTPiX X-Received: by 2002:a17:903:1112:b0:178:a030:5f72 with SMTP id n18-20020a170903111200b00178a0305f72mr3289886plh.12.1666099944574; Tue, 18 Oct 2022 06:32:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666099944; cv=pass; d=google.com; s=arc-20160816; b=H1bdeMcRaibIT5obWFn6oTsW3M9S8euPh4lqNszmFN4O3VtQnEs0T2bl/geaPruPAD kOexpn1kVrVdrPoIsJ6fA6nBk6i3d6xsaNthdoRcf8VT2sG2Ym93Zmb6RyVxZHNVvoXi AToNRoTG9jjGe8+SAv9tQzTY43Hb4jiqpp/PqhtHxKtRdvlHmNcM/jf6a2Eg6BlHA70X KB+Th3AlwiaBxWWg27+nMnBLhoE4UbMW/gVPJuYpxLi0Lz8JpWGtLF4IixitlRmTsFF0 SBeN+j3II6GfgvszEhjT+FV6vK5glDAbn9RPipxZ5jIRbo6JM8GcWV+2we2goO8SHa4o 7Rpw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=47+f61TpEsMFiD0B0ONpB5IacOSc5hZ2xFu1rQIZLYA=; b=HixgGTC/sZdvm/l/7GygsdgJ4UGTIsfyAxW7YItAMF0NjcN9i3FQv5uqv13J0v9593 /7LWNcBciPxTadaIRoLN1yDKt1bnfekWg+xyP3zDyK2AWjVrhe0qqo+D2P+KIbutpNMc paGYZ/2lGOf0pnVlU6GAZv4+Cfdw75jBrP+G1HVCnJjUqJ8MYEiEa+Wr9Dcvt0JzazTa 8AlejWSb0g0/Nr9vXLaFZk780tSZ/VT0aOO1m5Jl85e0LrMrVMT1Csc9Qp+ep16j1G82 f6DHAnlxZSfIKTa6yYbbIeKDm7IxImOB8Kg2mTDvZgALX7qSTl91rAgI/ZRhJkCHHspc VciA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=fwjihMT4; 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 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s1-20020a62e701000000b0056196446366si13633652pfh.226.2022.10.18.06.32.12; Tue, 18 Oct 2022 06:32:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=fwjihMT4; 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 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230400AbiJRNYS (ORCPT + 99 others); Tue, 18 Oct 2022 09:24:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230388AbiJRNYO (ORCPT ); Tue, 18 Oct 2022 09:24:14 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2055.outbound.protection.outlook.com [40.107.93.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 468BEC90F6; Tue, 18 Oct 2022 06:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZrIT8Au7mHz0qvqVAt9uqAD2Cen8qmaxCm6NcI8cU9qGijxLOOTCs2OXplI50m4z+WqhRxnW19jq8FgrbCGN99XYrSPwoutzk4SNgh/DCo4ni50dAqmyWQv0rLuqBRtOjef0Pa3kt5uDvKcaPIFoQZC8OWQUKmCiUPc07FDtAbNsVOuWajjUQAwiAkaHdjuw1eRT2ZIMTqa9T6r5eD650jUD94t7vw81SroMrspJO1Y5VwxXz2GsrE3eakvkYsv1Otlo29NUVPo1Od/cdePvNEhxUCIKHaUiH7g1I8kk4UnuJpO5sEFOKpw/6T/UhBrzCBSlUvLZ5y1x6j173j/P/w== 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=47+f61TpEsMFiD0B0ONpB5IacOSc5hZ2xFu1rQIZLYA=; b=QDVoRboyd2nwcvNeEq4Yu0NGn07/FrWVDoqDrTpE7EYjO5o0mCo5vC5jb3X3jW+/+en5YfCNbRiaWM5zRPBN0r4RG9jeo/UDy4b8AAx9R/2KXuCsHGJG/8oVL+7Dpqmqr3DlMqItjR74M1HPT20q02SkBoUNo0L05Qz/VXiJbrWUVhIsc17pXbR0gMNCqN6zuDjXg/Pg5wiZMlFFJVZo+abvYWzI8LYCRY3y1QrmShQazDWESQKDpKdaUVFhzx/JRncmPafta/bbNrl1YN65q101QXQIxVRCHMg5J8J5uBjsHv9H0KBhQvGKN+nnKo0exvU2+oi5VK/cmU0g7IyAfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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 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=47+f61TpEsMFiD0B0ONpB5IacOSc5hZ2xFu1rQIZLYA=; b=fwjihMT4m0+pRbjS8TES0P4QVj6WTUyAfGDsJRUlItlJQD+NYw84OuMXxDglTRQF3+q1gWNfM1OUQS/YkS1EoJoAZR5bfbCsUY82sfRytNfj7diPWUvvvzaAIOeTj7tPlyxIYbqmnCM2eJ1oRLYlHThSaorHC5TP9Xaujeck+qA= Received: from BN7PR06CA0040.namprd06.prod.outlook.com (2603:10b6:408:34::17) by CY5PR12MB6407.namprd12.prod.outlook.com (2603:10b6:930:3c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.29; Tue, 18 Oct 2022 13:24:11 +0000 Received: from BN8NAM11FT098.eop-nam11.prod.protection.outlook.com (2603:10b6:408:34:cafe::60) by BN7PR06CA0040.outlook.office365.com (2603:10b6:408:34::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.31 via Frontend Transport; Tue, 18 Oct 2022 13:24:10 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT098.mail.protection.outlook.com (10.13.177.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:24:10 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 08:24:08 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter Subject: [PATCH v2 02/12] cxl/core: Check physical address before mapping it in devm_cxl_iomap_block() Date: Tue, 18 Oct 2022 15:23:30 +0200 Message-ID: <20221018132341.76259-3-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT098:EE_|CY5PR12MB6407:EE_ X-MS-Office365-Filtering-Correlation-Id: 7d7d4f90-a23d-4aa2-f163-08dab10c0af3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bqzvaQFEHaOv71jBntGsTaO8EChuJlLpUVPyofvD9jsMVwV/ZgsQYqiS3QGYm79P1q9FL41c0YjIcyO/Kwh9QUJNYlbeghDDnEbnR2RXi9gBz/iwGD7Q1M8qvNAlPuZhtJI5dFHPngn1AYvnR4FLL3BYQwIH+vLpY0pzABPMUbA7sqmFAVDnz5ck59hZ9/yFlV0FmGgG2F+7/E0t6sk6TvjCewUKTLXGRJ9GPkMymQMu06yqc5MY+abWYUYvMCYV6utrbaBIt3Y5WDDEDoLlpWY7I9hA4wn6R+GrqLqfNcFzJVFl0AdN84/uI15sTxaUBv64LvH9m8HAlEfwtL2x51+GMszQEa0mwFthS4hVz1xPX1UxlBvAGb3QfTc6+dhIiulZtKGuwb38D2rdr7ouC0uI8+AlgYnGdrJcicIys6xgX4YqJnwrBF82LWoIHHfgI6FbsllkkVV38eXrgfMwzX+DzrIOQzBf74637BWrwkf3XnSFRmH8+Fh6E9c4qiaMScWyPgoN+9vxAcf1qZH0yq4MoodGv6Snq18tAV1nW1SlIrJXcblRy+L7b3mDDRDuzb7Uva2Kwz2Uxq8IgaijDkCqjxD6Kx6mQhOtr1SZSghCyCMnzOqngoE+FB6Rv0riDqJXIi601YbUnLe/ktfSvF8f7u0NUWx9Rs1HHGxQIURa/R4ituumpjt3/RGVOEuhdZ9X8MbXd7vXH3y0k783yTqwdl7vz4e1NbNgSW7Xo78itZqWlvqXaJ8PsUEdExw1DOQgXpPxYcUeQbMdMBfZq7t/BJPqRlOmTz0H1N0udq7H8j69csjaXIMuEgvQFte7 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(346002)(396003)(136003)(376002)(451199015)(46966006)(40470700004)(36840700001)(82740400003)(6666004)(41300700001)(110136005)(82310400005)(316002)(26005)(5660300002)(54906003)(8936002)(40460700003)(40480700001)(81166007)(356005)(4326008)(478600001)(36756003)(70586007)(8676002)(83380400001)(7416002)(70206006)(47076005)(186003)(16526019)(1076003)(2616005)(2906002)(336012)(36860700001)(426003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:24:10.7360 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7d7d4f90-a23d-4aa2-f163-08dab10c0af3 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT098.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6407 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747032415451430807?= X-GMAIL-MSGID: =?utf-8?q?1747032415451430807?= The physical base address of a CXL range can be invalid and is then set to CXL_RESOURCE_NONE. In general software shall prevent such situations, but it is hard to proof this may never happen. E.g. in add_port_attach_ep() there this the following: component_reg_phys = find_component_registers(uport_dev); port = devm_cxl_add_port(&parent_port->dev, uport_dev, component_reg_phys, parent_dport); find_component_registers() and subsequent functions (e.g. cxl_regmap_to_base()) may return CXL_RESOURCE_NONE. But it is written to port without any further check in cxl_port_alloc(): port->component_reg_phys = component_reg_phys; It is then later directly used in devm_cxl_setup_hdm() to map io ranges with devm_cxl_iomap_block(). Just an example... Check this condition. Also do not fail silently like an ioremap() failure, use a WARN_ON_ONCE() for it. Signed-off-by: Robert Richter --- drivers/cxl/core/regs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index 6522931df3f7..ec178e69b18f 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -167,6 +167,9 @@ void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr, void __iomem *ret_val; struct resource *res; + if (WARN_ON_ONCE(addr == CXL_RESOURCE_NONE)) + return NULL; + res = devm_request_mem_region(dev, addr, length, dev_name(dev)); if (!res) { resource_size_t end = addr + length - 1; From patchwork Tue Oct 18 13:23:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 4166 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1962280wrs; Tue, 18 Oct 2022 06:32:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7aTm0+i9Yc2F3GApNjBwu8lhFhzu78qLK83CtSZAlwGulmnmbWsoAK0mklZfXvCJfhPFcJ X-Received: by 2002:a17:902:d506:b0:184:987e:3cf2 with SMTP id b6-20020a170902d50600b00184987e3cf2mr2962102plg.67.1666099946899; Tue, 18 Oct 2022 06:32:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666099946; cv=pass; d=google.com; s=arc-20160816; b=xn/VuRgRaxqU5DTwgQaihEB9B29gKXymndwUGyCocGRvXI0QSijaBjbY8ZAS2i1YTu vHAgMZDn99QNihiQM6C+feomxT5InPgLAuaQ7GxkjJteI+LJLz9/KGB8Yep3mV6IIQ2x hvH+IwRnS+ujvzpjUWOfWhw5WFkFGm4KcCnyyYEvJV3pcVMAbE00BmeZL0RvCVOMn/0l Fp2hJQlRgPIU1rFtu+z/QWDhyaeo/19CJSdgziXYCqmENAC3gmUP/tu0NPzZSLncFhzO R8FHb9LREMlv+6po/idVIs02KSayHzuUJ9oTb2bFDvYtl5VSctY47gnnZBGGKX/3TnXd ZIxA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7VI7/Md+lydGPyjBUrpWJnTZAnscxR9jQx0xHAMMwxI=; b=kUfILwzmkYb5qeON+T9X7wfdc2PMhsxhcoT+ZLBEwwJQIowUxB2wBgtl9u3kfGMC3p B0noALqoFWF/YQlHpXWocZG8B8s6vF3oCjoZvDcZ+gNYcxOCoynOvzO1a/He1LkEytf6 6z/CRklYw3Lih6bCYrEe6rimqsLzxgI1wAFV3RncsCWFQJFBvVNkeGUoQ3Uo/w7X1jA2 z4NGXB0GlD7m6/jTfhoXSV+hJzP18T+P2njc/f3LhyYCyTD1rwdfYEduQGwiYvZH3br4 +ZVyGPwYyBtuWp4Zy26pTeOfrM7KRqpQNBsre6P9nTxt7xLimOZjeJtlMyCj1qt0FQZG 3CeA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="pN/g8q4e"; 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 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i9-20020a17090a65c900b00202618f0dedsi19742498pjs.106.2022.10.18.06.32.13; Tue, 18 Oct 2022 06:32:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="pN/g8q4e"; 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 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230382AbiJRNYb (ORCPT + 99 others); Tue, 18 Oct 2022 09:24:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230401AbiJRNYS (ORCPT ); Tue, 18 Oct 2022 09:24:18 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2084.outbound.protection.outlook.com [40.107.244.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3BD8C90E9; Tue, 18 Oct 2022 06:24:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TvekJYqY1nNyuoyTQGmXABUzUe6OhqankkHNa8g30SUqgDEz9ejrXE8wScXg+mIls43TvFLgI9fyDAfG0VVtIMNaMRuR6rW2ICu4d01KB2ihpq5S7XePL+MjXfgTyDo7IGSkoSFOwtQAlxB2SKWDMo8PL3cyHN1UyXQXptBFl6bCIriksPEAUFlPSdSCKAgwUkHqR1zbkreVQNwgj9MQOCWWNuLHWT9xo23h+elfndjOYEQERmy/CL57Q5zbrawziOPSnMXBDIL4L/jhMrIJ86CnNznpH/pZlCzD19wNgk70g1vJRg1+m+AxgifWpv+vwQM4SbH5+mxuI+Bv7DwAqg== 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=7VI7/Md+lydGPyjBUrpWJnTZAnscxR9jQx0xHAMMwxI=; b=Fl+8k6XU/tg/2mni+CT3zORfaiR4Ry4hPe1jkhFTU511f0EjfascWBWjca990sJAEbwwKJFK3EhjcGR6VzIZQecNEL8ksDet1hMENVMs15Nv1oSSpz1lXO5/aI9u2xYAcomzD+vO9wGDC8yrpiizHRAu7GOakjscqQJAbfB7/NzHxlEGbHO+/v+q2EWVxxRhv4na/m4O8aEPwnoaJn7wxsGA5LgWBFOfvo6c5FKmgjHkIatwgBZ9XJH2/d9SLtweooqlnuEmXpWUgymNqSp3P5YtoEa9dTVSW/QXiBN+KJHfr3KUwD3TCWlFWqIPzua7RS2blG2giuNpIF3GO5ZcVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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 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=7VI7/Md+lydGPyjBUrpWJnTZAnscxR9jQx0xHAMMwxI=; b=pN/g8q4eqKMlqriLXADB+RqxMCeGRzS6yNyAy/z48f72vgLnzCDIwIb2dp9CIDtIU94urW8NFAhoa1DiUisVPVPPC27/8XELdB76tg+IuTGzDCASFuN/59RL8v5Bg6OkdqfKgvhjigSb2K6+UpBSwJVcBA77q4+Ki3ybP1ZldPE= Received: from BN8PR16CA0032.namprd16.prod.outlook.com (2603:10b6:408:4c::45) by SA0PR12MB4493.namprd12.prod.outlook.com (2603:10b6:806:72::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32; Tue, 18 Oct 2022 13:24:14 +0000 Received: from BN8NAM11FT009.eop-nam11.prod.protection.outlook.com (2603:10b6:408:4c:cafe::b0) by BN8PR16CA0032.outlook.office365.com (2603:10b6:408:4c::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.26 via Frontend Transport; Tue, 18 Oct 2022 13:24:14 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT009.mail.protection.outlook.com (10.13.176.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:24:13 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 08:24:11 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter Subject: [PATCH v2 03/12] cxl: Unify debug messages when calling devm_cxl_add_port() Date: Tue, 18 Oct 2022 15:23:31 +0200 Message-ID: <20221018132341.76259-4-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT009:EE_|SA0PR12MB4493:EE_ X-MS-Office365-Filtering-Correlation-Id: 55624dd2-140a-4275-3dbd-08dab10c0cbe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dwj/PHQH/F/b3AErb47P9wTmU3v34TiZDF7Pc7BtLrkrsu9GmhWRyaKeaity82Qd0bBn+XW6pq0Tbn03JGZBLXaESP5dDUn0tLQrPVlFl4NEqbXR3k7wSPX/dtgdKsddOKe+JMsX8/5GsMpegf49t/Q+8mtuVUqANBooUnCpRkdHmszbLYiF0qgAp316WjQpdxfvkWiB4X7xmECT8vv5zUHu9lTnFXcmIrtQOx38QnPrPSpE27cLJLY85LSxLRIKCJ0rvaLw7Nq0ygCR+1ec5iKGnEO4dWMEwQJMjnwEfp4b2N9zYimMe29SjwgBdAP1otGfppudBKO74waNEp6b1i44cjv5UhqTxL3x6iJVroWp50QFFl7F60v5P4JUqkf7PaSopGXD9gre1tfM1IWqeJ/wKJ8mXR6v1Jas66Kg8AF3KIFTlMVHdt0XG1lUtav50Ya7crzMTIWClW9NT5q2UHzc3kMTpft3kiTLHudzVmtox28kPyVDmVPg2Y3w683Ew4ge8L0Ci7TG9igzjMdHAZpwVVedyaQTJynpHwSH3tkGW+9rhKXcqHFrPnUYNiuohkl/+fK+8pd9CNBqe7hhWFNI2wpJuo4YZ00ZR6cg2FYBM2GJkOfW2Fa25zCf6uoALxfTrj1p9qay2sHpLMUjzyBDRQYDB8dqZY2WOuEQQgdtiLQIEydbKXLlrEZA2rMQbZowuyGLw6hpta30LOIAaGP1ZhtsuzIi7NpltEFqncxGBowWRFdpXTcvZMZT0SNTdxnbvZHSHQCirR+Y7WZarnOb8eWE+CvNyBNi3S2V3X800xnKC/7FED3AGt9O3ipW X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(376002)(39860400002)(346002)(451199015)(36840700001)(46966006)(40470700004)(2906002)(15650500001)(7416002)(8676002)(54906003)(70206006)(4326008)(110136005)(70586007)(36756003)(36860700001)(478600001)(5660300002)(6666004)(8936002)(41300700001)(26005)(83380400001)(316002)(47076005)(426003)(40480700001)(40460700003)(81166007)(356005)(336012)(186003)(1076003)(16526019)(82740400003)(82310400005)(2616005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:24:13.7395 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 55624dd2-140a-4275-3dbd-08dab10c0cbe 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT009.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4493 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747032417532095772?= X-GMAIL-MSGID: =?utf-8?q?1747032417532095772?= CXL ports are added in a couple of code paths using devm_cxl_add_ port(). Debug messages are individually generated, but are incomplete and inconsistent. Change this by moving its generation to devm_cxl_ add_port(). This unifies the messages and reduces code duplication. Also, generate messages on failure. Use a __devm_cxl_add_port() wrapper to keep the readability of the error exits. Signed-off-by: Robert Richter --- drivers/cxl/acpi.c | 2 -- drivers/cxl/core/port.c | 51 +++++++++++++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index fb649683dd3a..767a91f44221 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -220,7 +220,6 @@ static int add_host_bridge_uport(struct device *match, void *arg) port = devm_cxl_add_port(host, match, dport->component_reg_phys, dport); if (IS_ERR(port)) return PTR_ERR(port); - dev_dbg(host, "%s: add: %s\n", dev_name(match), dev_name(&port->dev)); return 0; } @@ -466,7 +465,6 @@ static int cxl_acpi_probe(struct platform_device *pdev) root_port = devm_cxl_add_port(host, host, CXL_RESOURCE_NONE, NULL); if (IS_ERR(root_port)) return PTR_ERR(root_port); - dev_dbg(host, "add: %s\n", dev_name(&root_port->dev)); rc = bus_for_each_dev(adev->dev.bus, NULL, root_port, add_host_bridge_dport); diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index bffde862de0b..9bfd01b4e5b5 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -655,16 +655,10 @@ static struct cxl_port *cxl_port_alloc(struct device *uport, return ERR_PTR(rc); } -/** - * devm_cxl_add_port - register a cxl_port in CXL memory decode hierarchy - * @host: host device for devm operations - * @uport: "physical" device implementing this upstream port - * @component_reg_phys: (optional) for configurable cxl_port instances - * @parent_dport: next hop up in the CXL memory decode hierarchy - */ -struct cxl_port *devm_cxl_add_port(struct device *host, struct device *uport, - resource_size_t component_reg_phys, - struct cxl_dport *parent_dport) +static struct cxl_port *__devm_cxl_add_port(struct device *host, + struct device *uport, + resource_size_t component_reg_phys, + struct cxl_dport *parent_dport) { struct cxl_port *port; struct device *dev; @@ -702,6 +696,41 @@ struct cxl_port *devm_cxl_add_port(struct device *host, struct device *uport, put_device(dev); return ERR_PTR(rc); } + +/** + * devm_cxl_add_port - register a cxl_port in CXL memory decode hierarchy + * @host: host device for devm operations + * @uport: "physical" device implementing this upstream port + * @component_reg_phys: (optional) for configurable cxl_port instances + * @parent_dport: next hop up in the CXL memory decode hierarchy + */ +struct cxl_port *devm_cxl_add_port(struct device *host, struct device *uport, + resource_size_t component_reg_phys, + struct cxl_dport *parent_dport) +{ + struct cxl_port *port, *parent_port; + + port = __devm_cxl_add_port(host, uport, component_reg_phys, + parent_dport); + + parent_port = parent_dport ? parent_dport->port : NULL; + if (IS_ERR(port)) { + dev_dbg(uport, "Failed to add %s%s%s%s: %ld\n", + dev_name(&port->dev), + parent_port ? " to " : "", + parent_port ? dev_name(&parent_port->dev) : "", + parent_port ? "" : " (root port)", + PTR_ERR(port)); + } else { + dev_dbg(uport, "%s added%s%s%s\n", + dev_name(&port->dev), + parent_port ? " to " : "", + parent_port ? dev_name(&parent_port->dev) : "", + parent_port ? "" : " (root port)"); + } + + return port; +} EXPORT_SYMBOL_NS_GPL(devm_cxl_add_port, CXL); struct pci_bus *cxl_port_to_pci_bus(struct cxl_port *port) @@ -1140,8 +1169,6 @@ int devm_cxl_add_endpoint(struct cxl_memdev *cxlmd, if (IS_ERR(endpoint)) return PTR_ERR(endpoint); - dev_dbg(&cxlmd->dev, "add: %s\n", dev_name(&endpoint->dev)); - rc = cxl_endpoint_autoremove(cxlmd, endpoint); if (rc) return rc; From patchwork Tue Oct 18 13:23:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 4168 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1962368wrs; Tue, 18 Oct 2022 06:32:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7i1s/ky1FjgD3cExBrFQuo48lRw1+UqCLGEhfP2Jd2J1jRurJFO0/JzI86+3o/vDTUHb3h X-Received: by 2002:a17:90b:4a90:b0:20d:5c5e:1622 with SMTP id lp16-20020a17090b4a9000b0020d5c5e1622mr39722122pjb.50.1666099955837; Tue, 18 Oct 2022 06:32:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666099955; cv=pass; d=google.com; s=arc-20160816; b=bqo0jcivV/GslzDG12NzK9ih2CgZF9zL4wj9tZ1O5Wsu441hWLPTS9AfGaZxceoa7T RMTPi53vjfr7ptcsZVs93a90woeV4MXFrOdfhCCgyqW73P1Fvtc1shIrrBJ1ougjGn89 H8846FHtcPOLDxZjNbxudRQkwGM+fUppTKvgJ26dIfu7crSeDbq8NT/apnEWWfqSNXEd 8jOq0NL6J8ab2RfQ5T0MJ9Z8U/ygK7MSqutp47lBDyhkDGcrHaJdkeRxm3MfByK9Bo8q MENnQf6gPC8BJ9rzozrTMxHkVqELP5IEsGr1Re9AZ3FCvhCaGIN4ZI+46cdPbVyfeI5q psbQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ecXAcyzW+KTrtytwxsF6pUH5ze1HJh2cUj2l01F0pU4=; b=KYAPi1HmH+mcGTjjmstfWmZ9ZH51U/eCEJOV5JiK2bUh6y5/gt5ss5MOcgCWMwfqKI 0lZm/kGy+wX+2xbEZcB0qVSRtg9j1LCvANwGbY9Ku/MQ8CIylw/I3Dm5R/dtjkhY9QHE SsI1jg3ErC+5K9nSgRB4jxXNTTPsZPx590GhqNhDR8EnhMPu/BCEsGr01MCKjzD5Y3sI Ks1a3mfl/9rH+G7lJeNUq3q7f3SSJi76+DG00j8eiAKJ1p8psOszlhygV5hTjnE5okiX afRPcgVBkuQ1iEJ0r67DukN0+MRTk4t5KjnqvUlVqGdvYOtUh2f2q7Ik3A1gUF+qFemu H8DA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=fU9JuQnj; 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 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j14-20020a170903024e00b0018280f67482si17695763plh.113.2022.10.18.06.32.18; Tue, 18 Oct 2022 06:32:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=fU9JuQnj; 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 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230431AbiJRNYg (ORCPT + 99 others); Tue, 18 Oct 2022 09:24:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230406AbiJRNYb (ORCPT ); Tue, 18 Oct 2022 09:24:31 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2063.outbound.protection.outlook.com [40.107.93.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49700100C; Tue, 18 Oct 2022 06:24:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jfhQNpFw96RsM5zs4c995JcvRmRkgwW3Cs+CkNqkljkwv90nxEz696GjEa3493fx+1bau3ngtaBH4dW4AnejCVXHGRK/sfdmaLuOWTw45tjTiO4BTPrFZvbpb/6wIB81NsRuNiIz/Km0dYiY83Gs/xc5tw+kwSMh5HN45ulQDrh/GMON6H/uqpiiGEsBwiE9leKs5MmR6rlYCRRsMMWkrf2IRLMH77+F4rA3Vd2Lz4IfpnV0aR15FcGKk1BYAp8Ry55ESs8w437frtcLcWj2Rab9egc1lle62MOoLfcyuzC4dLrP81G9CxzHLcEAwUIi2uUNJeKDxCjtLbhu7PEZaA== 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=ecXAcyzW+KTrtytwxsF6pUH5ze1HJh2cUj2l01F0pU4=; b=OGSKUtYLPffNE1AyZXJsm1+JpevptvDjtytvfQvS4STOpVYAgyGI6hNqGZ0pH/kbf2MP43Lt/nRDV7mbrLz2jpcC05eMgd4jRBfZ6Raz7prd84xWqfLfzOaILM1x+wGEZh3mKv1B16oicyIamcErEbwCKo9f3ZeU+Uu+NbHAeRsp61zNl2jR4rLw5Aa+T5EepavWybPw6aF7l5cscUvV5XEbuYm0sYFv02dnwReBAd7dktgXl+gZ7Bs83JSGLyyYBjLyIdGnM3MrYwpx62UXqS8+wjvtS4K62TkpAtBjSa7rHEppKsP2k+Uuq8Qx/2/QQ31afrFnuXPEP1Ptrk685g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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 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=ecXAcyzW+KTrtytwxsF6pUH5ze1HJh2cUj2l01F0pU4=; b=fU9JuQnjllBRmtBRJ6OIJZrkcvrgv7zsL/ifEqoNCWIxufR9De8QxtA8PcxX2caD9S3mBNzoG+d4XmHf9AwD6loh2XA5cSE7D8LynfZBdmnzrvafks3HIbCjOQIS+ZkuhzeQr3+o1QGnWJxYrEMsJIiBthk8/RvExuoZC0szFKU= Received: from BN9PR03CA0360.namprd03.prod.outlook.com (2603:10b6:408:f6::35) by BL1PR12MB5062.namprd12.prod.outlook.com (2603:10b6:208:313::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30; Tue, 18 Oct 2022 13:24:17 +0000 Received: from BN8NAM11FT115.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f6:cafe::79) by BN9PR03CA0360.outlook.office365.com (2603:10b6:408:f6::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30 via Frontend Transport; Tue, 18 Oct 2022 13:24:17 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT115.mail.protection.outlook.com (10.13.177.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:24:17 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 08:24:14 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter Subject: [PATCH v2 04/12] cxl: Unify debug messages when calling devm_cxl_add_dport() Date: Tue, 18 Oct 2022 15:23:32 +0200 Message-ID: <20221018132341.76259-5-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT115:EE_|BL1PR12MB5062:EE_ X-MS-Office365-Filtering-Correlation-Id: a1662cbd-af51-484c-6b37-08dab10c0ec0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kglsqrHRe4x/9r3HZ92F/D4Mu1v8BioDytlvKDW5Ndzd6/X4cl8j2PKeXEPP9K/ajPdKeadZIJ/Mm8rHhl1tgMzF5QhcyuVZFlVM0o/46+abWtFYaoVH2nOru2HU8gZwuMx2WcbcGK607QBRz5KdeECHrveOJ/f4xGZDlrtsaJAENCqZuVTEGAsjX+lv/q105So3HeYkzSxIiGAaHJnvZozoHLkx4T4Qhbj0M0x+xubOPevjRlGGdu06r6b9wkb3/AZEystWLntePwDqKf8QoYz7HHbSazAME8wqwfyw4c9aTpBhh9kO+DE0W8jhuMHKDX/m/BbS5e9t1eiYW/Ydb9jQx6VVgvxCRkKuReqqcukZ61McAS9gAulGmWUGk4m4HTuAFONWcz6WKRLUQP2wMSFcgEDeX/w2KQKBwRgzvtMCkJTl2aOcytNVaJlJpuGlajR/598yHenZSZ/mF/bXeqod6vXAdeY7s1e4D2OkqoBm/0tWXvQtnEvPkASacUYBOpEsYaBPt0Xnm40Rxuq7NgVBiIDBsLSkGov3bYAwCuVa4uNmrDHw0Ntf4vbTyXP3hvQuLsAcngKpwVxTpx/kWBW1DqiJ2oUSQgI8sKl6VPy3uTrGODtCPCZQVermYui66CrcTNkBGR1A7MJisMIG/BizqjhqOn74gx60FXC6eQLWhAVvkf2z43vlPG89q1VZc/F4xH++/Uul2hx99mMp/XbfrBTq6lMQj0TejxW3VGkwmZcMhFHOO9qnWRcH6xV0mJQOhbvxGM1YkF0maEu9WssvEx4+M43onX3E7eoxUkQ= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(376002)(136003)(396003)(39860400002)(346002)(451199015)(36840700001)(46966006)(40470700004)(26005)(41300700001)(40460700003)(186003)(6666004)(1076003)(16526019)(336012)(478600001)(2616005)(82310400005)(36756003)(2906002)(7416002)(5660300002)(4326008)(8936002)(36860700001)(110136005)(54906003)(82740400003)(40480700001)(316002)(426003)(47076005)(8676002)(70586007)(83380400001)(356005)(81166007)(70206006)(15650500001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:24:17.1249 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a1662cbd-af51-484c-6b37-08dab10c0ec0 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT115.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5062 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747032427484529491?= X-GMAIL-MSGID: =?utf-8?q?1747032427484529491?= CXL dports are added in a couple of code paths using devm_cxl_add_ dport(). Debug messages are individually generated, but are incomplete and inconsistent. Change this by moving its generation to devm_cxl_ add_dport(). This unifies the messages and reduces code duplication. Also, generate messages on failure. Use a __devm_cxl_add_dport() wrapper to keep the readability of the error exits. Signed-off-by: Robert Richter --- drivers/cxl/acpi.c | 7 ++---- drivers/cxl/core/pci.c | 2 -- drivers/cxl/core/port.c | 48 +++++++++++++++++++++++++----------- tools/testing/cxl/test/cxl.c | 8 +----- 4 files changed, 37 insertions(+), 28 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 767a91f44221..31e104f0210f 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -282,12 +282,9 @@ static int add_host_bridge_dport(struct device *match, void *arg) } dport = devm_cxl_add_dport(root_port, match, uid, ctx.chbcr); - if (IS_ERR(dport)) { - dev_err(host, "failed to add downstream port: %s\n", - dev_name(match)); + if (IS_ERR(dport)) return PTR_ERR(dport); - } - dev_dbg(host, "add dport%llu: %s\n", uid, dev_name(match)); + return 0; } diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 9240df53ed87..0dbbe8d39b07 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -62,8 +62,6 @@ static int match_add_dports(struct pci_dev *pdev, void *data) } ctx->count++; - dev_dbg(&port->dev, "add dport%d: %s\n", port_num, dev_name(&pdev->dev)); - return 0; } diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 9bfd01b4e5b5..0431ed860d8e 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -892,20 +892,10 @@ static void cxl_dport_unlink(void *data) sysfs_remove_link(&port->dev.kobj, link_name); } -/** - * devm_cxl_add_dport - append downstream port data to a cxl_port - * @port: the cxl_port that references this dport - * @dport_dev: firmware or PCI device representing the dport - * @port_id: identifier for this dport in a decoder's target list - * @component_reg_phys: optional location of CXL component registers - * - * Note that dports are appended to the devm release action's of the - * either the port's host (for root ports), or the port itself (for - * switch ports) - */ -struct cxl_dport *devm_cxl_add_dport(struct cxl_port *port, - struct device *dport_dev, int port_id, - resource_size_t component_reg_phys) +static struct cxl_dport *__devm_cxl_add_dport(struct cxl_port *port, + struct device *dport_dev, + int port_id, + resource_size_t component_reg_phys) { char link_name[CXL_TARGET_STRLEN]; struct cxl_dport *dport; @@ -957,6 +947,36 @@ struct cxl_dport *devm_cxl_add_dport(struct cxl_port *port, return dport; } + +/** + * devm_cxl_add_dport - append downstream port data to a cxl_port + * @port: the cxl_port that references this dport + * @dport_dev: firmware or PCI device representing the dport + * @port_id: identifier for this dport in a decoder's target list + * @component_reg_phys: optional location of CXL component registers + * + * Note that dports are appended to the devm release action's of the + * either the port's host (for root ports), or the port itself (for + * switch ports) + */ +struct cxl_dport *devm_cxl_add_dport(struct cxl_port *port, + struct device *dport_dev, int port_id, + resource_size_t component_reg_phys) +{ + struct cxl_dport *dport; + + dport = __devm_cxl_add_dport(port, dport_dev, port_id, + component_reg_phys); + if (IS_ERR(dport)) { + dev_dbg(dport_dev, "failed to add dport to %s: %ld\n", + dev_name(&port->dev), PTR_ERR(dport)); + } else { + dev_dbg(dport_dev, "dport added to %s\n", + dev_name(&port->dev)); + } + + return dport; +} EXPORT_SYMBOL_NS_GPL(devm_cxl_add_dport, CXL); static int add_ep(struct cxl_ep *new) diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c index a072b2d3e726..c610625e8261 100644 --- a/tools/testing/cxl/test/cxl.c +++ b/tools/testing/cxl/test/cxl.c @@ -582,14 +582,8 @@ static int mock_cxl_port_enumerate_dports(struct cxl_port *port) dport = devm_cxl_add_dport(port, &pdev->dev, pdev->id, CXL_RESOURCE_NONE); - if (IS_ERR(dport)) { - dev_err(dev, "failed to add dport: %s (%ld)\n", - dev_name(&pdev->dev), PTR_ERR(dport)); + if (IS_ERR(dport)) return PTR_ERR(dport); - } - - dev_dbg(dev, "add dport%d: %s\n", pdev->id, - dev_name(&pdev->dev)); } return 0; From patchwork Tue Oct 18 13:23:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 4169 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1962495wrs; Tue, 18 Oct 2022 06:32:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7YMH4nTLmIyCnITc6kajlCwrjygorRI2CLufJXvf9g4wJurPIzJnfwEfPceHVRj8/07uLl X-Received: by 2002:a17:906:db07:b0:77b:82cf:54af with SMTP id xj7-20020a170906db0700b0077b82cf54afmr2531226ejb.666.1666099972799; Tue, 18 Oct 2022 06:32:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666099972; cv=pass; d=google.com; s=arc-20160816; b=vqmoSfWQkOqbsb3SLOut9rAgLHeBRkTI5NBdyVj5H7YxAXLkOYHzBWW/IflZwCqdFJ Vx/lDG8Smu7baH9XMOROHNE6Yl1WrPpvCfsLA+tI6Ul0/+SzFRz0R6le6CzcF3bywF24 YwZSP5c46Ca5B6UBKi6KA/qyvko6FstAeyEUFNGllhr6ylyQgqsYfk8CkUBoX43Jn6NA CLX9WLBC8Y1+9NI5dqY4m6Rt87qMtUkT5xkiAb12hRO+cbQkkj9h1U40U7q46HZe6Nr7 8ar4vwS1nmeJTWFgXdq3oBxGewTM3hnPosbFPsfPsua8V3Eg/SpPuTAd/Sdx4eXGdXsq iPdA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WHNFlrO4qrQBm018055H1tLywEzE/PzkskChRQ3S8nk=; b=OG00jVk4QswGUV5ydgSOygsUwtHocT3DlOft1rSqpEV6d2LNT8gZnhotYtUhf+7oQd 2iOFdaHM+ILunRZ9LAWv6nJgwEtsLwuDlvAFPsZyVa0K6x3seL6LrlPKIUIyyJulrW33 XxDh9wW6kGHlVrqHwDgEbAjU0+EPIil4cthFgSw5uannYFEa0K1gOwZwI85bMOh5zIWy gUS+dgtQhslFadhszvydv33uhGp78NpTGW/aV+zFAf6MiSry8JgY7n5FdN3APMPQqU3y J8DcMyfLlBc6ZK0KUlgsqkjjmeM2+NQzlIFa0Y/jw33QQuArobrkDNUUMlvX8jM7Q/V1 OAqg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=sO1XXoav; 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 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id du17-20020a17090772d100b0078239e3174bsi10612093ejc.660.2022.10.18.06.32.26; Tue, 18 Oct 2022 06:32:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=sO1XXoav; 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 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229769AbiJRNYq (ORCPT + 99 others); Tue, 18 Oct 2022 09:24:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230420AbiJRNYe (ORCPT ); Tue, 18 Oct 2022 09:24:34 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2087.outbound.protection.outlook.com [40.107.237.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF31BBF74; Tue, 18 Oct 2022 06:24:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XT/kY6E5q/unoJElgXcUx3CGdZE6vB95W79++5nRCFJeq73HgOa08VySFcYzj5ii2zb/T+/LtqchNQIpNokW4KAkvjzs9OLpKXR7hSeO8MtRhwmVs0cGMkjAdbeVfHvAgizviXk2y7krCUEMbJbMtUnac30rvOcVkEwE7+zSZ9SUvWgTZaeZ0FSbMi2fv0ZAB3VkIAeOPZXLoRbUhP7iBX5NqCIwoQ1X6ZukB78AW9EfoJ41mcfkzhxpfGHbQjqWjKLN01tteeBMVinXW1ltjQHlMxSgURdj32z4wdPRv7tnN1S5qiCYzG3MV1S0I6MphHj69WXNJB/FZkMFMJaEKA== 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=WHNFlrO4qrQBm018055H1tLywEzE/PzkskChRQ3S8nk=; b=iUKMzpMNjgjj44CX6YRPqoR4AYZ71qrrcxEM88QakZEh/qyVSWof4x1eaPaSDqRasMSex1TJl5Oj5K5Ec2hvT6Q5hDmzwYXF3DGSaKHXlKNpOiERJ/erBVEH9hrAgC2NzYGkgJLOJkpmaTu8F1tWrfJswTl3eLfltsfNC3q3mM6q/O5NPyIiyrZBt9WXoYik8JaCoy9oNZvHiIuNcLEcuOUMH+wPDAF2pYk6QdqCNoiYDQw2z1Ta2SP8ceA8+OV15NQnOMlFVBikq5HhGZ1wk74F533lrE3GPsWQGZFZHgFfiu11bto594saHOO9wAhuLMvEFFGB/Um8Ls4IZAa6pA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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 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=WHNFlrO4qrQBm018055H1tLywEzE/PzkskChRQ3S8nk=; b=sO1XXoavW+7LMQM/p7ksixE9AeKEi8Iz8/FPkL9ENw+vn8TKBkWwlMLT6cidD5Dr1PmUnbq9I3cRjlEiRcp6IetspdjviOL6UblPRMGfGcfJmnmDRzI9X3iA1ZB7PAvVyc/zD1p0K1nGVTPDnVFB1H2F2q9TMraqHcTmZw7zxRE= Received: from BN7PR02CA0005.namprd02.prod.outlook.com (2603:10b6:408:20::18) by LV2PR12MB5896.namprd12.prod.outlook.com (2603:10b6:408:172::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.29; Tue, 18 Oct 2022 13:24:20 +0000 Received: from BN8NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:408:20:cafe::95) by BN7PR02CA0005.outlook.office365.com (2603:10b6:408:20::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.33 via Frontend Transport; Tue, 18 Oct 2022 13:24:20 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT050.mail.protection.outlook.com (10.13.177.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:24:19 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 08:24:17 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter Subject: [PATCH v2 05/12] cxl/acpi: Improve debug messages in cxl_acpi_probe() Date: Tue, 18 Oct 2022 15:23:33 +0200 Message-ID: <20221018132341.76259-6-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT050:EE_|LV2PR12MB5896:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e1d0c91-bca4-4b02-4d2c-08dab10c1076 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XhWQCfsP4w/GCtNoFXqXkXguiAV1vVxLeNBh9bALY+XLZa+pg3Udd8m8wWPi+8rg+dqVxHNvLkcx5pCTXHCSKwQOgSJrdJMMyVDMUqN2pFjnud8vdMz/h8zFrpYlO83ZHf8YKOA+dYke6QRf7yCFz6bIkePQjOoBG9HsMgPbszr8RucLD3cbf1aYTPiv0sC9qBKVXTUJam0tGRCEDehIihtNMqnDBA09W8r1Nk2UoAMXzeGlMgtsMTwKk5oXTfco7T8tkIDC18iCQzfLWcYwlFINjlsQBrcGnkcJ8gmAqGz5d12SummXWXYDfyS5GsbwsXDDbguApf6yUlrJ/LeuACNNvGLhmDSMMWKymVUOpkapS99a0CjOrePWbtsvDBsl0VCqyPnw+xnQFLuFQwZKko7zH1NrdlEeQFLNFt4bAf+6hU7QygoNqTguT0bxKx/YnzdImkla2BFnPNhZv5XXimqwNCkYqdSQ71W2tp962RdCQ0w/Mj4caISR995oNISDGIdZb+ssPPL+FWsRWhgxH1PTUhfqCVputOBV7ckkZKSHvv1io8kPpY/r3UNiXARcKk5wuQOiF7+Z7xugbmNw9NTREz7/C/FCXZPeXy6jlac5e/rF7w4brfM8r0oN+S79zC/el4URRPeLfjtYzhCJ4NOhayIS31Ln1X/GUq5pF1FTyXfpuh5PW1TFtY77iTn0xU5AGlYcYgIE507AERkCVwBPXFrM9PgDdCY3m+oD0O63MD1cl/En8Foy9xhCQ08lSyOwXxtcBmu+llRpjS4huMriDEBZcb6qwAGvm/2jbJDtjVUVeTpE3PsdZPIwzN5q X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(136003)(376002)(396003)(346002)(451199015)(40470700004)(36840700001)(46966006)(83380400001)(8676002)(36860700001)(316002)(70206006)(6666004)(186003)(16526019)(81166007)(356005)(1076003)(110136005)(54906003)(5660300002)(47076005)(70586007)(426003)(7416002)(40480700001)(8936002)(40460700003)(82740400003)(336012)(36756003)(15650500001)(4326008)(478600001)(2616005)(26005)(82310400005)(41300700001)(2906002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:24:19.9790 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e1d0c91-bca4-4b02-4d2c-08dab10c1076 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5896 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747032445318544930?= X-GMAIL-MSGID: =?utf-8?q?1747032445318544930?= In cxl_acpi_probe() the iterator bus_for_each_dev() walks through all CXL hosts. Since all dev_*() debug messages point to the ACPI0017 device which is the CXL root for all hosts, the device information is pointless as it is always the same device. Change this to use the host device for this instead. Also, add additional host specific information such as CXL support, UID and CHBCR. This is an example log: acpi ACPI0016:00: UID found: 4 acpi ACPI0016:00: CHBCR found: 0x28090000000 acpi ACPI0016:00: dport added to root0 acpi ACPI0016:00: host-bridge: ACPI0016:00 pci0000:7f: host supports CXL Signed-off-by: Robert Richter --- drivers/cxl/acpi.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index 31e104f0210f..fb9f72813067 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -221,6 +221,8 @@ static int add_host_bridge_uport(struct device *match, void *arg) if (IS_ERR(port)) return PTR_ERR(port); + dev_info(pci_root->bus->bridge, "host supports CXL\n"); + return 0; } @@ -264,11 +266,12 @@ static int add_host_bridge_dport(struct device *match, void *arg) status = acpi_evaluate_integer(bridge->handle, METHOD_NAME__UID, NULL, &uid); if (status != AE_OK) { - dev_err(host, "unable to retrieve _UID of %s\n", - dev_name(match)); + dev_err(match, "unable to retrieve _UID\n"); return -ENODEV; } + dev_dbg(match, "UID found: %lld\n", uid); + ctx = (struct cxl_chbs_context) { .dev = host, .uid = uid, @@ -276,11 +279,12 @@ static int add_host_bridge_dport(struct device *match, void *arg) acpi_table_parse_cedt(ACPI_CEDT_TYPE_CHBS, cxl_get_chbcr, &ctx); if (ctx.chbcr == 0) { - dev_warn(host, "No CHBS found for Host Bridge: %s\n", - dev_name(match)); + dev_warn(match, "No CHBS found for Host Bridge (UID %lld)\n", uid); return 0; } + dev_dbg(match, "CHBCR found: 0x%08llx\n", (u64)ctx.chbcr); + dport = devm_cxl_add_dport(root_port, match, uid, ctx.chbcr); if (IS_ERR(dport)) return PTR_ERR(dport); From patchwork Tue Oct 18 13:23:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 4170 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1962613wrs; Tue, 18 Oct 2022 06:33:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6MKu0zpVhpJlBSYELmr1efOdw7lCq4nJHup+h1/ZQ9nP0MTnXyk10rgxWbJ5o161cZ6aS6 X-Received: by 2002:a05:6402:36b:b0:458:5ac2:8d56 with SMTP id s11-20020a056402036b00b004585ac28d56mr2708264edw.25.1666099983737; Tue, 18 Oct 2022 06:33:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666099983; cv=pass; d=google.com; s=arc-20160816; b=iq+7W5YBKZt+t6o7vEJJ9g8jgGOZoCivIoOqR+6uDQBngl1Mo3V/7pTYkDUB0hM8B9 2nSiLovNU4y2Gk1uVNPAI3FIUYhhGX8jtTs356gBfIE6INKeOcc5toHygT8zjDxM4m64 BxzyT6Owmjl1F8gODMNGI5ut3npxyKYBgquFO8JV1RVfD326kMboRUpFFKmGIocuG+X0 Bj9MAv97NHNwsa/1Mqv53LtBilDoZG/IuZWoimPMl0D/0fOU6lqT4vxHoz3KMHUyvhqG 4iJ8pbyvlIAwPlfSeUiCz4prebVCdR+HbVbJzCFlJmFnOv1eLkAihKsFseiK3g73DPZq 6mSQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wVjwz2jaYW2t613ACvCnJfgCx2sRIEoo1AFxWYaapRo=; b=G2UFQyg9RNdDXrWAjq+eLGXfGO6WtBB2RM6Pb2IfP989CC/dG9JY58XNde+Ct6rgsr PBnK7HSYjfsBe+buRq8P/swZmNuHUcxzCEoS5SSZQ3WNSnY8gh/SZPK7BGn2ntZiScED tTr/fjklej6sawEm5qtWiKfrPqYUamwZ6j9eq/FR8ZCMGFd4mD9usPUXR/0Iq4jHeNk1 K05ewN2NsQCrg9kziXLjUVXzB6bOD+Wc8gSXIgqTC0F4mU+vSRfExLRuAKfptGKhhxml bZAk+ALy2aK65KOviNDCeIUCx+KlD73qN1vJZeSN3Ei2V/tPtDEBUX32CA3LSaXShWyJ dN6g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=zsqzRNZA; 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 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g6-20020a1709064e4600b0077cb9bc7984si10103556ejw.181.2022.10.18.06.32.38; Tue, 18 Oct 2022 06:33:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=zsqzRNZA; 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 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230430AbiJRNYv (ORCPT + 99 others); Tue, 18 Oct 2022 09:24:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229907AbiJRNYf (ORCPT ); Tue, 18 Oct 2022 09:24:35 -0400 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2051.outbound.protection.outlook.com [40.107.101.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A314140B3; Tue, 18 Oct 2022 06:24:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ISpqoUL9RAMcB78m33fW1psXBDsSg7BxtH3ISb21lOgp2tARMrDKbSmZUXXJs4QuKrhlzbpTFTA51yg6JQlMHMbemtQK+X0lBmEKTmiQA52DW5DtmCoRl+qUDRkKnbyIOdWg5v488AQrNQ+jDvw4JIitt0NxCYCrsWkgVHPoOMZVLedICC367oFw31nf4YfsolRkUyKKdUyRG9ALgSBWZ2QqXRb8evw9TH7JiLAWWwVQ2wNZJ0O9cyyNaJ+nYxhZfzLLPmVkEdsFjXrUuygdXXrundJuj9Dg9++iwMs+hesuPj/sVQBZtVvvporj6Hj9OCBvd6gRnezzngTgotm9Yg== 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=wVjwz2jaYW2t613ACvCnJfgCx2sRIEoo1AFxWYaapRo=; b=FczGjqyc8WRRqjz6zrHWa8Por1tRmd9KodVVAW6YaqExYVJVGJbAsVcIVLqhBgCru0GPQ7R4ezOVJ4nv9IjePRQeAFn61u6JeNHjZQqhWaBe+ycMZcvm/+t1Xk964p2NbdhdBtx/W4Zwp8GWCYoltcT+2UO7a2zgAtcikojfolFsKJ1szwDKV76zYYyL5E6OXvt7g9p1c9bE+XWHgaGk8SRWUhoy261vGjsZShGFRFd8gmIE2ENYxU8N1wyegSuJIcYLe7iWHsrwKSn02zvAKRm+as7TMTFJu+wQbRzmnFQm19P/CgAxXWObLuGV4m0jmafkPDB/3325yRjoLWLWUw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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 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=wVjwz2jaYW2t613ACvCnJfgCx2sRIEoo1AFxWYaapRo=; b=zsqzRNZAt3duRSCvCuKuvw83ArjU/ZEJmW3GBaspzx8AUfq8HJjlFzWbEi9PAv6UGBxhn8WOrzLhknA6SIHsc5NMkRz44F9Pap/le4vh5cpddYv8Gr0VN5JueKhjiXnUQsDUsUZ94ZXf8KmJ7gZmVHHpIu3plFgH57EY02nkIT0= Received: from BN9P220CA0017.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::22) by BN9PR12MB5305.namprd12.prod.outlook.com (2603:10b6:408:102::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30; Tue, 18 Oct 2022 13:24:23 +0000 Received: from BN8NAM11FT107.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13e:cafe::66) by BN9P220CA0017.outlook.office365.com (2603:10b6:408:13e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.31 via Frontend Transport; Tue, 18 Oct 2022 13:24:23 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT107.mail.protection.outlook.com (10.13.176.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:24:23 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 08:24:20 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter , Terry Bowman Subject: [PATCH v2 06/12] cxl/acpi: Extract component registers of restricted hosts from RCRB Date: Tue, 18 Oct 2022 15:23:34 +0200 Message-ID: <20221018132341.76259-7-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT107:EE_|BN9PR12MB5305:EE_ X-MS-Office365-Filtering-Correlation-Id: 1d1d5869-1341-4b32-89a5-08dab10c1244 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TLrg3RxoS8c3Iw4iQmKYS7I9jn2YaPpamA1jgugsSVVINx+iyfYheycQKluMYBHkdIr4NuO/jnegWyi8ogbhMlm3MW8ZYbXSXYHtHaO25hM/MwsKCsafbtWamL2Z3Im3hP1Jl3tkIlcXq+wBKfUxwnhaUmKL/YXFTNIg3lbunMCnEsa+0MA+cCVdnmGunjazNJdAY0jOlt5l7GsJXnlRBODsn98LPNlVHCQDIYCImUbbBEzbcpedFMGTKooGEc9nRDBxjoLoJDDJaCAd4sqqRuKBPKDwrsUmMHio9SYdzM3m/Xdtu1+9F8qyg01rZAPM3eqGO2YeLMNUWIKRpMyhyEk6eFKkUnpjRE20iljHIszRVAM/jrGceNveFd4K4Oo5v2CP6d/KMreBYoFiw2MhOmDZRYUzjMMHipy5eSahdswmgofbv7XawWTcksGulSKbtBsCsI0uwb2VXZn762knaIAYWDKn+wCulEec3+2sNW8doojZwgq2hWO9HKP+C3tAPvHt/W1os9ntRYIk23J7z6WIEemtAeVWX/qHkoa+gPn4/WZWZfWNcPBmthMadKC77Kwc9QSogpYVQEJ0kNcSXOhJy+msqoxkc30sUz8ojRAL0RaLn303j0mS8PABd53CkfmY/Onj9QKGH15+3yUf8gEywgqW/JZ/ODGmNpQ8HGb8lIr/xmcOZne0TS1F0t8W/zIoe3BG4GYfSiQSwo2up8ZBOZsM+hQ81h4Nb5GTpfLcYgeG9yQ+7o6WX/NAdxCDDRfzw9RIrcNrMB5512IqC7DYRRXPwfu+F5RxA9tiiEY= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(376002)(136003)(396003)(39860400002)(346002)(451199015)(36840700001)(46966006)(40470700004)(26005)(41300700001)(40460700003)(186003)(6666004)(1076003)(16526019)(336012)(478600001)(2616005)(82310400005)(36756003)(2906002)(7416002)(5660300002)(4326008)(8936002)(36860700001)(110136005)(54906003)(82740400003)(40480700001)(316002)(426003)(47076005)(8676002)(70586007)(83380400001)(356005)(81166007)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:24:23.0083 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1d1d5869-1341-4b32-89a5-08dab10c1244 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT107.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5305 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747032456224305014?= X-GMAIL-MSGID: =?utf-8?q?1747032456224305014?= A downstream port must be connected to a component register block. For restricted hosts the base address is determined from the RCRB. The RCRB is provided by the host's CEDT CHBS entry. Rework CEDT parser to get the RCRB and add code to extract the component register block from it. RCRB's BAR[0..1] point to the component block containing CXL subsystem component registers. MEMBAR extraction follows the PCI base spec here, esp. 64 bit extraction and memory range alignment (6.0, 7.5.1.2.1). Note: Right now the component register block is used for HDM decoder capability only which is optional for RCDs. If unsupported by the RCD, the HDM init will fail. It is future work to bypass it in this case. Signed-off-by: Terry Bowman Signed-off-by: Robert Richter --- drivers/cxl/acpi.c | 79 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 69 insertions(+), 10 deletions(-) diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c index fb9f72813067..a92d5d7b7a92 100644 --- a/drivers/cxl/acpi.c +++ b/drivers/cxl/acpi.c @@ -9,6 +9,8 @@ #include "cxlpci.h" #include "cxl.h" +#define CXL_RCRB_SIZE SZ_8K + static unsigned long cfmws_to_decoder_flags(int restrictions) { unsigned long flags = CXL_DECODER_F_ENABLE; @@ -229,27 +231,82 @@ static int add_host_bridge_uport(struct device *match, void *arg) struct cxl_chbs_context { struct device *dev; unsigned long long uid; - resource_size_t chbcr; + struct acpi_cedt_chbs chbs; }; -static int cxl_get_chbcr(union acpi_subtable_headers *header, void *arg, - const unsigned long end) +static int cxl_get_chbs(union acpi_subtable_headers *header, void *arg, + const unsigned long end) { struct cxl_chbs_context *ctx = arg; struct acpi_cedt_chbs *chbs; - if (ctx->chbcr) + if (ctx->chbs.base) return 0; chbs = (struct acpi_cedt_chbs *) header; if (ctx->uid != chbs->uid) return 0; - ctx->chbcr = chbs->base; + ctx->chbs = *chbs; return 0; } +static resource_size_t cxl_get_chbcr(struct cxl_chbs_context *ctx) +{ + struct acpi_cedt_chbs *chbs = &ctx->chbs; + resource_size_t component_reg_phys, rcrb; + u32 bar0, bar1; + void *addr; + + if (!chbs->base) + return CXL_RESOURCE_NONE; + + if (chbs->cxl_version != ACPI_CEDT_CHBS_VERSION_CXL11) + return chbs->base; + + /* Extract RCRB */ + + if (chbs->length != CXL_RCRB_SIZE) + return CXL_RESOURCE_NONE; + + rcrb = chbs->base; + + dev_dbg(ctx->dev, "RCRB found for UID %lld: 0x%08llx\n", + ctx->uid, (u64)rcrb); + + /* + * RCRB's BAR[0..1] point to component block containing CXL + * subsystem component registers. MEMBAR extraction follows + * the PCI Base spec here, esp. 64 bit extraction and memory + * ranges alignment (6.0, 7.5.1.2.1). + */ + addr = ioremap(rcrb, PCI_BASE_ADDRESS_0 + SZ_8); + bar0 = readl(addr + PCI_BASE_ADDRESS_0); + bar1 = readl(addr + PCI_BASE_ADDRESS_1); + iounmap(addr); + + /* sanity check */ + if (bar0 & (PCI_BASE_ADDRESS_MEM_TYPE_1M | PCI_BASE_ADDRESS_SPACE_IO)) + return CXL_RESOURCE_NONE; + + component_reg_phys = bar0 & PCI_BASE_ADDRESS_MEM_MASK; + if (bar0 & PCI_BASE_ADDRESS_MEM_TYPE_64) + component_reg_phys |= ((u64)bar1) << 32; + + if (!component_reg_phys) + return CXL_RESOURCE_NONE; + + /* + * Must be 8k aligned (size of combined CXL 1.1 Downstream and + * Upstream Port RCRBs). + */ + if (component_reg_phys & (CXL_RCRB_SIZE - 1)) + return CXL_RESOURCE_NONE; + + return component_reg_phys; +} + static int add_host_bridge_dport(struct device *match, void *arg) { acpi_status status; @@ -259,6 +316,7 @@ static int add_host_bridge_dport(struct device *match, void *arg) struct cxl_port *root_port = arg; struct device *host = root_port->dev.parent; struct acpi_device *bridge = to_cxl_host_bridge(host, match); + resource_size_t component_reg_phys; if (!bridge) return 0; @@ -273,19 +331,20 @@ static int add_host_bridge_dport(struct device *match, void *arg) dev_dbg(match, "UID found: %lld\n", uid); ctx = (struct cxl_chbs_context) { - .dev = host, + .dev = match, .uid = uid, }; - acpi_table_parse_cedt(ACPI_CEDT_TYPE_CHBS, cxl_get_chbcr, &ctx); + acpi_table_parse_cedt(ACPI_CEDT_TYPE_CHBS, cxl_get_chbs, &ctx); - if (ctx.chbcr == 0) { + component_reg_phys = cxl_get_chbcr(&ctx); + if (component_reg_phys == CXL_RESOURCE_NONE) { dev_warn(match, "No CHBS found for Host Bridge (UID %lld)\n", uid); return 0; } - dev_dbg(match, "CHBCR found: 0x%08llx\n", (u64)ctx.chbcr); + dev_dbg(match, "CHBCR found: 0x%08llx\n", (u64)component_reg_phys); - dport = devm_cxl_add_dport(root_port, match, uid, ctx.chbcr); + dport = devm_cxl_add_dport(root_port, match, uid, component_reg_phys); if (IS_ERR(dport)) return PTR_ERR(dport); From patchwork Tue Oct 18 13:23:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 4171 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1962635wrs; Tue, 18 Oct 2022 06:33:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ucqq6qjLFSEyS60ROrQ0p/0/L7Y/nIHb7HH/3rFNwMNQXHOkCEla4IoghZ2N6SjLLdHDt X-Received: by 2002:a17:907:a052:b0:78d:8531:92b with SMTP id gz18-20020a170907a05200b0078d8531092bmr2526195ejc.37.1666099986700; Tue, 18 Oct 2022 06:33:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666099986; cv=pass; d=google.com; s=arc-20160816; b=H6ujyYvB3b4hm/Xld0OrFmmxiLcYGz0bBr5cQ8mVqeAVIgf5/YEPHRWO3a08AKjWU+ K+p0V19Bol1r/9UyX1lhptDCWpSl9r6ZgRTkV+q//5hMD9KOTf0dlOJUhYQ1owjsBNkE RoMjPX7NDvsJg5Vnt3tTiLJ/Kr45lgBZaSfIaL1PLTE08iM3R71n3fK7dsmt0X96iDvD iIE8ZnwxNcRYUTPeyKRul0M8iQDcJOcSTn6P+3WNC3G7sbU++bIn7uLYLVLZLQ31P2X5 Sn+BfrLR1itsSl0WCsx7pIIC8tGVha4x/ubUT8G96ld+ZOH5QB3k/Z99HWFfZGJyA5wc DEjA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ff1xR0YOfwo6pDKZ/aMhaDAK8y4R4QFXmkwuW0YPl/M=; b=St8kMtYXaHILlpyjacfDOOGhwHxwGCrRM1QqBK+NrhjYZ8k8PPxdFcO5O9DnL49x3g 3JfGrlqeHMnDTvpNr3xZU8UuYp9ELJnuzKkVyjl+iJ4Ebhz8d7p4ypCVoeEFFu3X3gKp guTC97xxJlfExXTMNsxnmip0mEo0bGcUDg/Gt4TgsL6BeQAQB2DrG3FE+dJd/vu19Ozj 2FoSS1XFqOFsDeDoxCQTtjDY7zjUARwy3xWREXK9o1Rs6JwZk+igbWgM2a0bZfSNZYvZ 9yuoMvzjKheKpsRQweP0QcB8mf6F0sMxC/st/ZhXRzV0qiJKaYCr4TYQk6yxyrresOGW n5qw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="PGP/jNuB"; 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 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc19-20020a170907169300b007707aab3171si13115490ejc.848.2022.10.18.06.32.41; Tue, 18 Oct 2022 06:33:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="PGP/jNuB"; 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 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230137AbiJRNZT (ORCPT + 99 others); Tue, 18 Oct 2022 09:25:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230481AbiJRNZF (ORCPT ); Tue, 18 Oct 2022 09:25:05 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2059.outbound.protection.outlook.com [40.107.244.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26168646C; Tue, 18 Oct 2022 06:24:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FqzTLk8NJ5CV8JiXMIECcc/o3yhg/hx4dcuPIi2uURd4GGC78hXb46rFCzJVF1eoQmvZcUUQSEBd1BoS6aOz7Irqel7AkkNES5tbtRngjCFK/tj7DmTwXp0yoK9+o825gwo3jws1uakAYc4I5XNFHMxMhI0iLPUsyOfxq9tOslrjyJkN97GdC1gpV3OBPxVEVuKhwilQ8XZvu/5JvVQE2XUo3iC1zIzIxHVgsO0DJrrDM4SKqIjzB/zRPX6yILP4qKu2oZyWWf4KvTe4YSN6gnPel8LSceBQBP2/f/4/I5oZ/oLTRnZQda78SjjAu1lhszrbivYCKl26dPfI6b52fA== 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=ff1xR0YOfwo6pDKZ/aMhaDAK8y4R4QFXmkwuW0YPl/M=; b=mNlfuT0ov5nRMI7L+v9uFLEBjZuTPYSUuTTvkT14DYV2g+j+WSlfH6kWtdt91hV3ILo75/QBLSqZmg53v1vnNTS8mm4pRWnLGquyXCZIIFIy9sC9jwUMrj8IJ6TAoNR+i3POTxtW7Q+bENWJ08OTfvnxHI3pNpB5k85yJFeVMTh66TTPkTkXbUrzY1uJRLH568rGXt9UBUZht67KJpUxi2h/nf4teHWAB8cAj0AKo57MTH8LGdbuFf6y0xX2qo/3bITcldXRo2WvUb9jT1fBxYquFiF7iWHBYzIBN2zko0qOgLrjPWywmWAN84XbNUqqH3ceh4rHM7cHTyaFP9G1IA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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 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=ff1xR0YOfwo6pDKZ/aMhaDAK8y4R4QFXmkwuW0YPl/M=; b=PGP/jNuBhuAScFD6/srce4AsXD4YvJTC3zcaooX5hNU9e58DDAt7tkT14K0kjsZ8fnA1/ipCOFBFu2FUGSxrLe7RN6UMDxEAVg357jxSiZzCZeGOgokjpqRDi329tpQdq+d7n7jjjbppd4VmU1AVCzszAl1JiKkx78vxd4YEOfA= Received: from BN1PR10CA0009.namprd10.prod.outlook.com (2603:10b6:408:e0::14) by CH2PR12MB5516.namprd12.prod.outlook.com (2603:10b6:610:6b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32; Tue, 18 Oct 2022 13:24:28 +0000 Received: from BN8NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e0:cafe::8e) by BN1PR10CA0009.outlook.office365.com (2603:10b6:408:e0::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32 via Frontend Transport; Tue, 18 Oct 2022 13:24:28 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT039.mail.protection.outlook.com (10.13.177.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:24:27 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 08:24:23 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter Subject: [PATCH v2 07/12] cxl: Remove dev_is_cxl_root_child() check in devm_cxl_enumerate_ports() Date: Tue, 18 Oct 2022 15:23:35 +0200 Message-ID: <20221018132341.76259-8-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT039:EE_|CH2PR12MB5516:EE_ X-MS-Office365-Filtering-Correlation-Id: 10e63684-827a-40d5-ed81-08dab10c1530 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rCCd0zjDacK8EoEH3u2Y0rQvD5Rx1x/witQi2WaZoscWOsw6xgyLhMKcngyDTQkZmi/fkTM5M+lJibieYOLSVAim5uKhi11mU6ZsPexj/CK/rZN0t2KyTjsqO7IvnxjPHcD+7lckmJygmvpWJh/U/0lrTetYgw5L5v31GvMHVTW3Sk7+aPbNnzD8jjrdpQCKT66oBbtlsLUtdo1nMEIktlzU4iNL4wh0uPoILqk8pPvKvHAFYr7hvqWrFyf1f42HTcLrDIlPfXOAJ9YXEoEkeG3g0+DOZMH2XfnbLUHj9NV154kUulphZAATxcxlT24kNl5iTl66MdURhJiZXdU/U10jeTWMQb8M4p6GhL0SZAzb7kaamTFKfRXA1S3CQPsVwco3tXmedTxYIaKZOH38r0zFhfO3nGAoDBc+VSkE5EH6JbCujQFFBT0GQTHcpLkfO4Z0cZ5HPB7aieeYn/hRNwj0Mx+JklnRmLkRQM31IYZBihzJLFo3UEdtif6KDyLYG8HIDcRWCn1NOi4qBsuLlzuCcOMNK3wAYyYjc8xBWXMZghwgF1UTtOIqnJysZA5QdGJm1RINA9+sA/J4a1khE0nNsoYrPrivCDt05hsUF4CBH18JgHCoGElRn8Xk3iIne62LWcFL9Mjd5V1OTxcivT59MpvffsFrtoAbbn30t+7wstxL4g6czR15eK+4E6IaSdDuD2CqBgQMOm8/wgqa5xearJLUHcZvT2SfFj0ITZYOX3YCb1Y2z8Dx3dKy58F3YvzSN2EIKZS8R5Bu7WxTT6E81CssIi2Q09vpnC8jPES1wC3Vx2rGCKBHeV1vdQ21 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(136003)(39860400002)(376002)(396003)(346002)(451199015)(36840700001)(46966006)(40470700004)(2616005)(26005)(6666004)(478600001)(36860700001)(83380400001)(336012)(16526019)(186003)(1076003)(40480700001)(2906002)(5660300002)(7416002)(40460700003)(54906003)(110136005)(316002)(4326008)(8676002)(41300700001)(70206006)(8936002)(82310400005)(70586007)(47076005)(426003)(36756003)(81166007)(356005)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:24:27.9285 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 10e63684-827a-40d5-ed81-08dab10c1530 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB5516 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747032459794382221?= X-GMAIL-MSGID: =?utf-8?q?1747032459794382221?= The dev_is_cxl_root_child() check adds complexity to the control flow of the iterator loop in devm_cxl_enumerate_ports(). This check is unnecessary and can safely be removed: If the port of a dport_dev is connected to the cxl root port, the grandparent of dport_dev will be null. This is checked early in the iterator loop and the function is left in this case. Drop this check to ease the control flow in devm_cxl_enumerate_ ports(). This change is a prerequisite of factoring out parts of the loop. Signed-off-by: Robert Richter --- drivers/cxl/core/port.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 0431ed860d8e..9af2d91db9bf 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -1395,6 +1395,7 @@ int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd) "found already registered port %s:%s\n", dev_name(&port->dev), dev_name(port->uport)); rc = cxl_add_ep(dport, &cxlmd->dev); + put_device(&port->dev); /* * If the endpoint already exists in the port's list, @@ -1403,19 +1404,11 @@ int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd) * the parent_port lock as the current port may be being * reaped. */ - if (rc && rc != -EBUSY) { - put_device(&port->dev); + if (rc && rc != -EBUSY) return rc; - } /* Any more ports to add between this one and the root? */ - if (!dev_is_cxl_root_child(&port->dev)) { - put_device(&port->dev); - continue; - } - - put_device(&port->dev); - return 0; + continue; } rc = add_port_attach_ep(cxlmd, uport_dev, dport_dev); From patchwork Tue Oct 18 13:23:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 4173 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1962840wrs; Tue, 18 Oct 2022 06:33:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6lgT0+1mXkSbDhujYtzNRWY8a3tRQ8fYCvobDJXf88uhG/jaMJ4qOM+H6/7f/euGJtzmOP X-Received: by 2002:a05:6402:191:b0:45c:83e8:d74a with SMTP id r17-20020a056402019100b0045c83e8d74amr2523661edv.329.1666100007046; Tue, 18 Oct 2022 06:33:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666100007; cv=pass; d=google.com; s=arc-20160816; b=aYfqJwGr+scKmeEug+5p9u0SkQacwiaBo6BwVA9RrSk86Vny9wzZlL/1bdYDgDDYXp 0qt0xUGkte3gdAyPdAWGEOC3FyQjvlwprOkfQkKpCY1fsPqmtPZVSnVYgY9r8hZUc59C +whokRuWBfVIf3B+ffsWmF/pysAx7POwqhlvPOS0D88Fn6beDfmMp2mHVYh8Ud050vUp n1WK5j3Ob7qGEhVXzc9W6XOtZIi7QDUSZYj87/fg8a53UkzMhqMWwPujoYtO0rE0VGdA p1vMFjWDD9Zp8fRa5U0o3V26urXJcbI9MhK165Q0YsNehH14eOlurPB0wchXzDgP7ISN OZ9A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Jo2Lg1CBLmLriTl/NpqSzdE8UaXgVmfhgM1KORTc794=; b=lKhxec9v1Gd/lTg/OE+lkaJwNRJb/sOg/Gf+aeqSi9/dKvdDTWUtG2tLV+bTeWyWfd WN4V3AAbfEfJEQLY97M4YaVeO7sqV3dd8SimpMjoxh4Lm0V17RGd63G34DNJfTSHZbVv SlcY6sEl0CbDZ3F3524DEDDaB1w1hQL3l6Z4u8bMLf08IINC9bBI6iSLrCLqQ8SPSeOv 4wygxHBadOJ68cXz4UEaE9GiQoMKn3VftfRsd4iZ/6QtRD1Vu1+uqqGpNYciFduK3xwK K+81mU0+0XMfe+3ZLYXAPfLbEINWytL8xctD0nZhdhLRal8ejUb3ddlTyPkc6O/pea3k UkEg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=1rOGaMUd; 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 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n16-20020aa7c690000000b00459ad2b4a4esi9962648edq.188.2022.10.18.06.33.00; Tue, 18 Oct 2022 06:33:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=1rOGaMUd; 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 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230418AbiJRNZj (ORCPT + 99 others); Tue, 18 Oct 2022 09:25:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230453AbiJRNZL (ORCPT ); Tue, 18 Oct 2022 09:25:11 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2060.outbound.protection.outlook.com [40.107.100.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B11215803; Tue, 18 Oct 2022 06:24:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gb4M5dxm1KN6Y2P4pJP6Hiv5gNvZLZ18wq4eMI+v1Kqy3UnKgdUTr7iKw/TGzhhEhGA2rOShRaP2G6cfX2BqRFlb258tVmOI3YG00kf4o4j79Is9MaMHQonU1X11P4jy8p0bmD1gJY0IgVVhuBKV7w8Vj3f20UbeKmum1vG4QC4aRkF5xLk90iNHTxjY6tPxGEP4g5U9NIh8XmTM9t0c8bYxOFV++5NK91dXJtlzFJA5aMxyCxLjYrCMs2rKYfocmDECyF9apuhDP5lomutYKG3ZsOABGokO55HtQXizw3GjJQin0nr7cP/4GvsuW1FKXCS+WrMyy9UcwX4sO8fdEQ== 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=Jo2Lg1CBLmLriTl/NpqSzdE8UaXgVmfhgM1KORTc794=; b=MgD0cXLS/eFRzmhgHvDgJraPud2J9Sps6XDFpAKw6vovaqWUA8lNbE/RMXZM04xu3Ege0huayB/KRsRNkAY2zhuLT3iskl/e2suxAgEKELf+Z6xeQB+oTJxXMWP+fy8cOeNbXLszGYfj/sbiZ8K/RBxEeiPdsjhZoP8fbPyxEYk2sykLOAEmhr0LyvngKJxlJtzosvZJRaAcoBVnVK/zazaFdMgTPv9XS2THAzrEiG3jd1tPnnqZl6K3JBshGK6Af36l06ijbB9DHIAO54x5LrCfVuSY6aHiSaDmmGJPPvVnZSI30+GEodjyD9VJqM84VCyrDja0SdbfbM8S2TBA3A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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 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=Jo2Lg1CBLmLriTl/NpqSzdE8UaXgVmfhgM1KORTc794=; b=1rOGaMUdVSkp8q4sExtcMVTRObBz3nV03WBzDnoLNc0gs01RaLp2oF1QTDNPVxd7kLmdLfdLI9CBjJ6F+M3L3ZI1o9XYv46NwS5CQKkd7TseWUZdmyInf/zcdeXhkiV+1e41BFLqG/dGfUm14DFbj4mAeOVz+nC3Ryci9IcxizU= Received: from BN9PR03CA0860.namprd03.prod.outlook.com (2603:10b6:408:13d::25) by SA1PR12MB6773.namprd12.prod.outlook.com (2603:10b6:806:258::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.33; Tue, 18 Oct 2022 13:24:28 +0000 Received: from BN8NAM11FT086.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13d:cafe::2e) by BN9PR03CA0860.outlook.office365.com (2603:10b6:408:13d::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.31 via Frontend Transport; Tue, 18 Oct 2022 13:24:28 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT086.mail.protection.outlook.com (10.13.176.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:24:28 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 08:24:26 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter Subject: [PATCH v2 08/12] cxl: Factor out code in devm_cxl_enumerate_ports() to find_port_attach_ep() Date: Tue, 18 Oct 2022 15:23:36 +0200 Message-ID: <20221018132341.76259-9-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT086:EE_|SA1PR12MB6773:EE_ X-MS-Office365-Filtering-Correlation-Id: c78db01a-9cc5-446e-4ee1-08dab10c15a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 05CNkMk0OF8A2mAbo+VxWEJOfJNQ+WHnKCRX54UjR+KpttCyOsvMKjzLFvFZIHS+5yR2tIvlvhjhSmU39GXWpDgUxsTOeP1D96xXH61pZ4BQyjcAptzAIFjZKK9gkd/LiXchPZLHB9vkL8ecK9/a7mV27wDBLqUoMeQrZO/ET29bhkL4mzq5YT+p+dxcspEqWrewpkKcs29If636NdIBYJID/OWkfN8HU+I1pa+F5BGbjoFq+Rzzxefcgybqh5vEmDqFVvUvbHeCu8AlOHjsuAZ+y2POACQ3sfg9hN6p8rqoO56bSrgrcOfjj1kpGT+FOzI/P538UHOPkQX+RJ9rEj76vo8y/tWVKdUOQxJn1hTC5tytb24G4aL8NEsAIMKF9QYauwOhB1uUOMpgjStuNiZUYmo5SIueIL0Q5dciPGkiXlBHqfVosOxPEWNe1iwu9h3nIt2bWRNQI4glGPaD0/AZD460Zq09x7fqXUYOAKV1gcRQQk/Q8Xsdrf4QzZHnykPcRmtlKsXqPXarxm/AF+ye3dTm8i+UG58wdpNRYS7bT8T8unDuyGo/2/ZLvtyy50N26iIlsv1CEQUcGGK6FOnX+tjWOolePB30qp5sLYiqE2WxPSX/6A+rL1dHmndPE+0xUa5iUgHMS8zbrImeJFEGckyOFgfmtSJqdprxstCOxChn+h+kqi6/3dzKWYSOc1m+BUsBJ+Rpdp/T8f1an82st0+zM6XFPX9b7JxNC0ABRUFts7PbYxJuOl7h+VVJt0h8w6jX5Osi0FYAEMCgg5pH57Knn4hk2jkeqdQFkFAL6WuL+GLrDxacXu4pGEuSsNJb4AdcZ1ydZRWuKtvmqA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(396003)(376002)(136003)(346002)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(41300700001)(4326008)(40480700001)(83380400001)(110136005)(54906003)(70206006)(26005)(316002)(16526019)(186003)(7416002)(1076003)(81166007)(5660300002)(356005)(2616005)(82740400003)(8936002)(36756003)(336012)(426003)(40460700003)(70586007)(2906002)(6666004)(478600001)(47076005)(8676002)(82310400005)(36860700001)(37363002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:24:28.6822 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c78db01a-9cc5-446e-4ee1-08dab10c15a6 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT086.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6773 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747032480957843013?= X-GMAIL-MSGID: =?utf-8?q?1747032480957843013?= Factor out the code to attach an EP to an existing port. It will be reused to implement RCH discovery. Signed-off-by: Robert Richter --- drivers/cxl/core/port.c | 66 +++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 9af2d91db9bf..4b15481426f7 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -1286,6 +1286,36 @@ static resource_size_t find_component_registers(struct device *dev) return cxl_regmap_to_base(pdev, &map); } +static int find_port_attach_ep(struct cxl_memdev *cxlmd, + struct device *uport_dev, + struct device *dport_dev, + struct device *origin) +{ + struct device *dev = &cxlmd->dev; + struct cxl_dport *dport; + struct cxl_port *port; + int rc; + + dev_dbg(dev, "scan: origin: %s dport_dev: %s parent: %s\n", + dev_name(origin), dev_name(dport_dev), + uport_dev ? dev_name(uport_dev) : "(null)"); + + port = find_cxl_port(dport_dev, &dport); + if (!port) + return 0; + + dev_dbg(dev, "found already registered port %s:%s\n", + dev_name(&port->dev), dev_name(port->uport)); + + rc = cxl_add_ep(dport, &cxlmd->dev); + put_device(&port->dev); + if (rc) + return rc; + + /* Continue to add more ports between this one and the root. */ + return 1; +} + static int add_port_attach_ep(struct cxl_memdev *cxlmd, struct device *uport_dev, struct device *dport_dev) @@ -1373,8 +1403,6 @@ int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd) for (iter = dev; iter; iter = grandparent(iter)) { struct device *dport_dev = grandparent(iter); struct device *uport_dev; - struct cxl_dport *dport; - struct cxl_port *port; if (!dport_dev) return 0; @@ -1386,30 +1414,18 @@ int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd) return -ENXIO; } - dev_dbg(dev, "scan: iter: %s dport_dev: %s parent: %s\n", - dev_name(iter), dev_name(dport_dev), - dev_name(uport_dev)); - port = find_cxl_port(dport_dev, &dport); - if (port) { - dev_dbg(&cxlmd->dev, - "found already registered port %s:%s\n", - dev_name(&port->dev), dev_name(port->uport)); - rc = cxl_add_ep(dport, &cxlmd->dev); - put_device(&port->dev); - - /* - * If the endpoint already exists in the port's list, - * that's ok, it was added on a previous pass. - * Otherwise, retry in add_port_attach_ep() after taking - * the parent_port lock as the current port may be being - * reaped. - */ - if (rc && rc != -EBUSY) - return rc; - - /* Any more ports to add between this one and the root? */ + rc = find_port_attach_ep(cxlmd, uport_dev, dport_dev, iter); + /* + * If the endpoint already exists in the port's list, + * that's ok, it was added on a previous pass. + * Otherwise, retry in add_port_attach_ep() after taking + * the parent_port lock as the current port may be being + * reaped. + */ + if (rc > 0 || rc == -EBUSY) continue; - } + if (rc) + return rc; rc = add_port_attach_ep(cxlmd, uport_dev, dport_dev); /* port missing, try to add parent */ From patchwork Tue Oct 18 13:23:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 4172 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1962640wrs; Tue, 18 Oct 2022 06:33:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7p/Z4bo4nFPlGopvIoWft4+klIjOV1ZyWq38TJFCO4B0Xmovh5JOX1KFUtPjnCKciFbIoU X-Received: by 2002:a17:902:f807:b0:176:e41d:b804 with SMTP id ix7-20020a170902f80700b00176e41db804mr3202149plb.111.1666099986955; Tue, 18 Oct 2022 06:33:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666099986; cv=pass; d=google.com; s=arc-20160816; b=SCctSAZKZbtWrY12CbKnCRuW8XqLkm4vGiwxrSh/XZOUNLUGFumXnzVGqzk+f71H9H LICJ+sqKznzMuKJzk1DfJipDT8eGBrBXVmB05QF5ERZJXcPoYKGkhzUr0PPpxEhaEEBS uuFHIO9gj0PPoBv1RUnLayvPO4/8stYUshzkWGq7PMlob4ZEAH7UfLiRdXHOCt20EiLC FrCD7fN3/sQgrJl9eG7Wl+w7nTqkGQ1x8ueUhGLX5Op/T1qrTxtZRZ5uZ0GJNmkU/NPz 6DGkwOelLqLxzpvXn0U3CMtGcl18OwmF+x0/UbHFcD1aS1sXirumtggbKLsX2iK+RV9/ S8iw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=h/hKkrxafFtc9IpK9px5m8cyyUbCJBZGiYZhwWSJUc8=; b=yMF1Tzw2cZ0g9ZURAKM+hTBfhXccetNHA9tYfT1WBVAqzvSod9UP4PchiMOkXOnnmk 3sfdPbHcgvYBL2A1CCUzU5tPW073vY5EKm8YOItjnHCg7aJH0/b60NyPpUaeq+jp99KY p2UhkXV4K9aemTG915da0zemKswlHL0ziHCoLrUz+J0l35ViJ83YMVrF+78QSrgoNRB4 QMRnG514Uo/yq+eNTrz3muTc6yzCegmrkuLJeFeXC+5+ZwWOcIL32djB6zdb3oKYZMrz OuU7qGIbzeuuJrisrH5NJRRPQEoERW6SBh+XHmKxiqy5ZcsgOyFfuaw0LZVoezJm0bSC ju2w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=XEs6srev; 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 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h8-20020a170902704800b001713df0c8b2si13573363plt.213.2022.10.18.06.32.53; Tue, 18 Oct 2022 06:33:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=XEs6srev; 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 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229916AbiJRNZ1 (ORCPT + 99 others); Tue, 18 Oct 2022 09:25:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230439AbiJRNZI (ORCPT ); Tue, 18 Oct 2022 09:25:08 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2076.outbound.protection.outlook.com [40.107.94.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6998522B1C; Tue, 18 Oct 2022 06:24:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N8qDgr9W5c5nuqUsGeqEl/h/OZMvFmq/BejYIkBoB3u1KgaX/CW9OKz7YVHZg3nds22/ieeGisLZ+bN3/Cx1uMz5/HGOwFYytIMqQBha2iBxII+VV8psXaxh/ho0FncFa+Lvs0uXzZTZtQgXDIbjH/dQH90kfVE4zTHH209Du6sp+RtubEoOIOAB5f9RlC6teDMnIF+b5bZEbNxb+ZpmuF1fEjOPibUUBcha3gJiZAgbb7EA5B+OrKMuIOwJAY+v7tk1UWrZ/e0e7tZqbyK0n6ALZkwA75ZOVs/jhOxEVF0nUu5a/o0961NZtOmBcLQJyqR5tL9coH4bfOqVR+drBg== 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=h/hKkrxafFtc9IpK9px5m8cyyUbCJBZGiYZhwWSJUc8=; b=MT03qCk+OCyKqaV/DE3kypo/nPcYKJnOJC/Y+o5sZNN+E3dk0iJe1uJV/cujBLPl0J1XAIq4ZPUm4nUTOg4qwkcXO5qNPmtdZ6hoRDWrpyuBhbRsia/FNU4YMS0v/bwnEV9MNeeN7DoPukRpX5Kx3Mi153VgTLqK8Onzfwo3cQyb6SutRka3NNAfP0FWzr0RUDoH5YJ8uieBGIvUNadM5GnD8ku3SyTfKVZ7le6UhfovqR3/sN3VDGCcvh7SqdTQbApuKAkgDeZRVnc3cS3QJMMZZOKGF56z4QfCONYtrgbYQWTPcE2P7cDjlrXp++K9TZol4ilMf1ouXzqwHOaNmA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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 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=h/hKkrxafFtc9IpK9px5m8cyyUbCJBZGiYZhwWSJUc8=; b=XEs6srevGB8rHWZtPIipvD/UuE/KEIuz35zAiBJgbJB+4fGwIlNGX/2TYL9fzuOkZjnV+di7UhA4wKkd7vWuS7LJ5PjxJDQPnNiNAebDxsMR5nZUmN1r3U/0qdNAVZDyzG4xEe1sP2Q34Ki1TT9cg53W08mak2o2H6HSdZZG66s= Received: from BN7PR06CA0066.namprd06.prod.outlook.com (2603:10b6:408:34::43) by PH7PR12MB6633.namprd12.prod.outlook.com (2603:10b6:510:1ff::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32; Tue, 18 Oct 2022 13:24:31 +0000 Received: from BN8NAM11FT098.eop-nam11.prod.protection.outlook.com (2603:10b6:408:34:cafe::8d) by BN7PR06CA0066.outlook.office365.com (2603:10b6:408:34::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34 via Frontend Transport; Tue, 18 Oct 2022 13:24:31 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT098.mail.protection.outlook.com (10.13.177.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:24:31 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 08:24:28 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter Subject: [PATCH v2 09/12] cxl: Extend devm_cxl_enumerate_ports() to support restricted devices (RCDs) Date: Tue, 18 Oct 2022 15:23:37 +0200 Message-ID: <20221018132341.76259-10-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT098:EE_|PH7PR12MB6633:EE_ X-MS-Office365-Filtering-Correlation-Id: 32af808b-a9af-4e45-f158-08dab10c1751 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uakOhso2KtVFaqdyH1pcMOhWGYgnpVyrvUVkbAw2bx78JfBjpXz+MNuU8GAPbJfBVYrPpBrtn14AtgGj6LPUslnVyT5HXXwi5b98OB4ErTNqIM5GDZwvND65ngFLYMHCgiTT5U8gYC9uSwa1BiI5CZYHMaORcUC6X3kWObM0tMtzSTMrHOB+lHS10J19ipes/XmzyIE6grfL2qovDkdueSZB1D+VgD2PTdlDrigkjyvhbaJHCDGM20u/V7pZ/+ky4Ac80AC9KmgIkSQ2Uwve6L1oSO0gHa5IdmPN26Y98ZJK1uiNxM2LkUKrTzKso9vHSuGtDZEWseTfjxWn6paNGc524ue3Kqz1AFW/DmGwDhRCbZtDM90dk+/5v3d86Ff1KlIi71nobrJcncaDseEqvnd2hT0eJTLoC1psPIoowC6FSjqQGYz3BTlO6oU03sfP73uAbfakIa20ZFLnHkA2ozKgxVHvjjl7cmumOxiAU6VnCa5/n8r4wccf0k/7kbcaQwK2EVJMlTlazQEHaIy3rL0UlbITMli1w+NnQZNmHmHCR3xGbmZwCQZQ6fNlxe0JEQMLlfzm5mtpvKu8wt7iMP/K7arjdAvBsSjhYYCHGI1jg2VmpJ/YS+fFXj0hif3G8O3w7TvIuHQ7u27XHzcpGksXr/xpdEwu+MND0RZzkguTf0Al5J+vS3iEJj85M6N0Kr6r/7eXdiBmdQvZpV1jaIu/TJpLgdQI5XheDR8lCzmF7cuJH0NT53BwApaYWWVmyzdiA3bpZUK5IndjJ8NgoXudPo//1AOJ510IJL1U7tVVMJZSTa3MxFcOpv1hZf8f X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(396003)(39860400002)(136003)(376002)(346002)(451199015)(40470700004)(46966006)(36840700001)(82740400003)(81166007)(2906002)(40460700003)(356005)(8936002)(5660300002)(7416002)(70586007)(41300700001)(70206006)(8676002)(4326008)(36860700001)(316002)(54906003)(83380400001)(110136005)(186003)(16526019)(40480700001)(82310400005)(426003)(36756003)(1076003)(47076005)(2616005)(336012)(6666004)(26005)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:24:31.4847 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 32af808b-a9af-4e45-f158-08dab10c1751 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT098.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6633 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747032460019087081?= X-GMAIL-MSGID: =?utf-8?q?1747032460019087081?= The PCIe Software View of an RCH and RCD is different to VH mode. An RCD is paired with an RCH and shows up as RCiEP. Its downstream and upstream ports are hidden to the PCI hierarchy. This different PCI topology requires a different handling of RCHs. Extend devm_cxl_enumerate_ports() to support restricted devices (RCDs). If an RCD is detected all to do is to search its corresponding RCH's port and attach the EP to it. Update cxl_mem_find_port() for proper removal of the EP in delete_endpoint(). Signed-off-by: Robert Richter --- drivers/cxl/core/port.c | 45 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 4b15481426f7..35f8fa98904e 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -1384,16 +1384,56 @@ static int add_port_attach_ep(struct cxl_memdev *cxlmd, return rc; } +static inline bool is_cxl_restricted(struct cxl_memdev *cxlmd) +{ + struct device *parent = cxlmd->dev.parent; + if (!dev_is_pci(parent)) + return false; + return pci_pcie_type(to_pci_dev(parent)) == PCI_EXP_TYPE_RC_END; +} + +static int restricted_host_enumerate_port(struct cxl_memdev *cxlmd) +{ + struct device *dev, *dport_dev, *uport_dev; + int count; + + if (!is_cxl_restricted(cxlmd)) + return 0; + + /* + * The cxlmd is an RCD, the dport_dev of it is the PCI device + * and the uport_dev is its host bridge which is the parent of + * the PCI device. + */ + dev = &cxlmd->dev; /* cxlmd */ + dport_dev = dev->parent; /* pci_dev */ + uport_dev = dev->parent->parent; /* pci_host_bridge */ + + count = find_port_attach_ep(cxlmd, uport_dev, dport_dev, dev); + + /* If missing the host is not yet ready. */ + if (!count) + return -EAGAIN; + + return count; +} + int devm_cxl_enumerate_ports(struct cxl_memdev *cxlmd) { struct device *dev = &cxlmd->dev; struct device *iter; - int rc; + int count, rc; rc = devm_add_action_or_reset(&cxlmd->dev, cxl_detach_ep, cxlmd); if (rc) return rc; + count = restricted_host_enumerate_port(cxlmd); + if (count < 0) + return count; + if (count) + return 0; + /* * Scan for and add all cxl_ports in this device's ancestry. * Repeat until no more ports are added. Abort if a port add @@ -1445,6 +1485,9 @@ EXPORT_SYMBOL_NS_GPL(devm_cxl_enumerate_ports, CXL); struct cxl_port *cxl_mem_find_port(struct cxl_memdev *cxlmd, struct cxl_dport **dport) { + if (is_cxl_restricted(cxlmd)) + return find_cxl_port(cxlmd->dev.parent, dport); + return find_cxl_port(grandparent(&cxlmd->dev), dport); } EXPORT_SYMBOL_NS_GPL(cxl_mem_find_port, CXL); From patchwork Tue Oct 18 13:23:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 4175 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1963191wrs; Tue, 18 Oct 2022 06:34:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM67adEHy7sYjL479ChhlrXlp7wYm2KOjlnnMiS75OaUwT/y2wM8gSFrN7UhR12KYyn3NZD/ X-Received: by 2002:a17:907:948f:b0:78d:e99f:63e3 with SMTP id dm15-20020a170907948f00b0078de99f63e3mr2432369ejc.361.1666100044614; Tue, 18 Oct 2022 06:34:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666100044; cv=pass; d=google.com; s=arc-20160816; b=ZzDUMqMGAAzPvGjpU4OAdBHkrF+G4KFb4dINqW5J5glRov/4pbxSgq0pNwRzJEx3Zd q8Azbku7jgNmBCYYJWwtP2kSh4MvPjFHLNXt/Kf8gXyMtNTxfl9Er7PM67m8hDqf1Fu4 BN85fdiUCBFWSP1FJz3jtR4Z+veTdw2sgD3AQK/RTf8tNSaVcm6AM+MbrEfUhM0a06Oz vj9YhxYPX6oxnAidYp0zZ4K/mR6CK2SA1kNFB/D3NyKdLooa1d/hVXqZ8XFSAxm3ZSxc 0Nabpe7VWYBDqEX5Pg6EG6vGrw5HR9vIFe2yLdKB35dsLr2Gpkj5ef/33xuiw1xMxjSj M9mA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=165J/0jl3YniOXsSGugeLHpDY9z5jKXw9zLnBFsDvys=; b=RB3/W47nbBk7oaGxzlkcIfGO1EDey/arjA5Y8x7tQtzDRARbSetlBMquu//HEbs17q Cbz+P62Dm4r8uUkccTKG8SgwAzf2RZWKb6k4na60DsPMkkhhSgF451iWFOVDD6ZeVbTv GUeZH+NIJ1V1La5AHAoTyc92dhSIIBFKFwH+l0+TLoxjWhEAakw5+MT6y3+xP2TYYamY oKeWrmcttlB+qzmnMSLRqbBBbynDcQURXXBvqPBDxnlWtWBhEotUqjfcNq83SZVcUAdk nsS2AErLSaPNvTSuMVmZaFlC/MdsXklKiXXoPP6Dq/QthLzPZ1s779lkrQ8k2gzgdc+J IDWA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Q4FotHxS; 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 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xg11-20020a170907320b00b00741a0c28f07si8641130ejb.943.2022.10.18.06.33.37; Tue, 18 Oct 2022 06:34:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Q4FotHxS; 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 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229907AbiJRN0E (ORCPT + 99 others); Tue, 18 Oct 2022 09:26:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230512AbiJRNZk (ORCPT ); Tue, 18 Oct 2022 09:25:40 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2064.outbound.protection.outlook.com [40.107.220.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25A8BC58A5; Tue, 18 Oct 2022 06:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QYzbO3ndLtkhbyTZNwPXLuK1JJyHDMcz9u0GiYRr2F97ePRlSBtUU8ZNIuZlwhlFGZerxtdtjUVKLb8+Y/7bAOTNvfyi33Mg9u3gLxgKkHlXxzuDgtDXwRbeaO1RAePBmWhN5G9pCbvUTNyeleI67hT+ALWruAeLrd2bOQjpoIHIUWVH/jblObEw53M6Tjbh51KO95SNa9hRyVKULwk5nWhUCe7+BBtCHMbPKN+rxZJrB9cWq+u3305tuU3rR+quFLx3p5QzIZ/8AbKEXyEnyzihsifGLmW0oU6lsOJQrj9tlau1ZXYGFDm0/ATf2atxOYTHib1nU2OV6EzipPmfpQ== 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=165J/0jl3YniOXsSGugeLHpDY9z5jKXw9zLnBFsDvys=; b=VXLiGJWadu4wGvN269dSRAYiwYoBv6cy6WzT7yLiZ86l/E19XKzkdMrrtVSxCTwvFpGYS5c6hoU1ME2coteDo9CbQVNc9tGvpUe1TbMPWq5aBIT3jq1vEe1W4FRLOxipll7+pQeQSxO3HjtR41DMGqxWkZDsxsR/DsqoHJTJRSBXR9qpC1rekWhpo7Ur2fE8B0E67ZHJsDWTrmzFSCjofxFk5W1u4zaPYucaA+sk0nPnWjYg2EkpLAcp8KM9ugTieLn3ZEAT0tJC1Fv7TbrIDqGvFcjoH9ERcEN6+2ZmkACWfo36mkQL8kUKUkGo4ev9TKKA7gq0TwBIZvc64jZe/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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 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=165J/0jl3YniOXsSGugeLHpDY9z5jKXw9zLnBFsDvys=; b=Q4FotHxSQAj+0WyqGqBou+zLC3uVczELIcdQfwDo7LYv8lBsIaIfx/DbcKNSbRbqAqql3Xt5FvPMcRugL5eS2tUd6RtTZYzAe9QMmbQBBRIyRRygVzfiNWy4PMKuGzjOnNgfld+u/h42zTPlBTPnmpMFFQqf/u2wp3ynevZQI5c= Received: from BN9PR03CA0590.namprd03.prod.outlook.com (2603:10b6:408:10d::25) by DM4PR12MB7696.namprd12.prod.outlook.com (2603:10b6:8:100::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.29; Tue, 18 Oct 2022 13:25:00 +0000 Received: from BN8NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10d:cafe::f4) by BN9PR03CA0590.outlook.office365.com (2603:10b6:408:10d::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32 via Frontend Transport; Tue, 18 Oct 2022 13:25:00 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT028.mail.protection.outlook.com (10.13.176.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:25:00 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 08:24:31 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter Subject: [PATCH v2 10/12] cxl: Do not ignore PCI config read errors in match_add_dports() Date: Tue, 18 Oct 2022 15:23:38 +0200 Message-ID: <20221018132341.76259-11-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT028:EE_|DM4PR12MB7696:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a992286-763e-4550-d5a8-08dab10c2887 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h1Lbfk/ShqNgnXB3bi5ZoTgpkClfgdf0DJt/h3M/RWecx7h1t7vhr4GGiDYVwUEeA+nVT6PBOgWxPqd7k1C0S2DsNSmvpIvdAsOWfhK8dYi08UcNH5LrYtGx0Acs0yI4H41lSzXbsz5qwHpVBMz53BYHvgtpvEFGm0+SqGE34gkSGEMR4WThl7Msj0EP2fm48srlvM9vwpJbHLJ4t7qKxZoj8Fki6u9QquAkUwVZGu655qJfAgf/AmSfVxFxuBZSOcF1CT4F0r2tB+vuo0r1OGGRp4C9j3EsMoKpHMlHBgC2PvYKqv/jsLvWzs28DbbOiw/zHshsJzbQqqVC/TJh0mLEpwCUFiTKU/m/Cpe8ftvoAvk/l76/Zn7fY/YtAPqVdEeBZ/dukaNeDVSGU0nVD+5Dt1d7PrE/zOYibtwPjlHBHjXXLR5sEXEuQSSKpw7gNsjFeXa0tim6GQ+iHSFP7cfTh1nDxpVqOz1C12Bu5dIzy5zu2qTigy5Z5m/fNa/kBYLuQV97+hoYXp8BQvcJCjz0fIdT1EL6Lt0i2fTPyBPb3t6w4BUWIQVVRp02HKIUbt2WSs7fp9Ls/tLO17nGiPYItHDatxPCLUS95L/OCCdOarJyiTYPrleDVbyORHMXclUQxO+8rAF7vZ1UippOZ2ZbEAIvUFjagPpmTz8DrQMwNxTjZF7fJhtEfG8AloqVHWtekfln2GklKqkfBZyVhuiwLpTFnpx7Yh85+M6VTovlHEQkCOu+6jH4dE+Yx/9hjHsbmmvPTUou+TWwZzDfmQqchUMj9FSQnM6n/8ofhtI= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(376002)(346002)(39860400002)(396003)(136003)(451199015)(40470700004)(46966006)(36840700001)(478600001)(41300700001)(8936002)(4326008)(316002)(110136005)(54906003)(8676002)(36756003)(36860700001)(81166007)(356005)(40480700001)(40460700003)(186003)(82740400003)(2616005)(336012)(1076003)(16526019)(82310400005)(26005)(70206006)(83380400001)(47076005)(426003)(2906002)(70586007)(5660300002)(7416002)(4744005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:25:00.3592 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a992286-763e-4550-d5a8-08dab10c2887 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7696 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747032520356828588?= X-GMAIL-MSGID: =?utf-8?q?1747032520356828588?= The link capabilities of a PCI device are read when enumerating its dports. This is done by reading the PCI config space. If that fails port enumeration ignores that error. However, reading the PCI config space should reliably work. To reduce some complexity to the code flow when factoring out parts of the code in match_add_dports() for later reuse, change this to throw an error. Signed-off-by: Robert Richter --- drivers/cxl/core/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 0dbbe8d39b07..8271b8abde7a 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -47,7 +47,7 @@ static int match_add_dports(struct pci_dev *pdev, void *data) return 0; if (pci_read_config_dword(pdev, pci_pcie_cap(pdev) + PCI_EXP_LNKCAP, &lnkcap)) - return 0; + return -ENXIO; rc = cxl_find_regblock(pdev, CXL_REGLOC_RBI_COMPONENT, &map); if (rc) From patchwork Tue Oct 18 13:23:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 4176 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1963635wrs; Tue, 18 Oct 2022 06:34:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7aipeRNKf10eIZLFm4ru0fvPSnRffs5dmF1iv2zuGmPvMwlsQB+JI6AEUnhJzue0qTic2G X-Received: by 2002:a17:906:5dce:b0:78d:e71a:6e0 with SMTP id p14-20020a1709065dce00b0078de71a06e0mr2460335ejv.360.1666100099549; Tue, 18 Oct 2022 06:34:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666100099; cv=pass; d=google.com; s=arc-20160816; b=mvWgxeYJgZNky8NEUcc8f0NDynqgTo9kjC/mdsbgE36G8PLyKG6QS1hiv9RCPoFMo2 3I9xQwVDhO189IJD3Auujs/uItjPzvvPx45EP47oXHBXFsCmsZfSaL88MuM32Ul+xY5a +dYt2PcB81FE/3TsD+i25dglHC59O69t/HukvZ5n6va75JrwqJ5e5SrJYV3eQXsnYqOJ upY9uQacr02N80QmXbWPBbb3SnLPEbqjLPKHybkJ4hoY8VcrJk/D/lR88QPNjzJdSpf+ kL0e5ATi/W9ZT2ca/Jmb+IhOR9fz2bwyRaXv1i/15h4pu6oxYe37IKfWPBNDcfscAtQR ngyw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fKDHc51d7FEG0Lu5nY4eByWXC99jgX1kSwZm+TRGAHw=; b=LuAUP2/CwbG4zwrWP/Yv2NKuTxC1XRBUXdzNq+zhJi74vHCM/a+0duaB2eKhKFcecx ypjG1OGODLzJNdv/ykWE2bNxQnK1XObyonNc8lFJASUpy0/AVdOBfOY3hMpZX6KStm6b Yu06yK3FYPiZyImiMPewQTRE6E6m2VTlY4c2yHVFq64klDZvTpF2pnHfKmrjKCX1GdBj Nvq4mkoCoDs+0ajaWgcyGJFIH6wicCDYwyLPy4tlX+GeZPZbOwwzI+r+txgrmHui+pLe g875KW9f8duUNF143CPUKOR320OFYi/0O0JYtKdhgbANdQv/EkHoq3QKGjXvdF1n+KmR CTIA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=ta3A3Emr; 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 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eb8-20020a0564020d0800b0045028bed6e7si13819877edb.600.2022.10.18.06.34.34; Tue, 18 Oct 2022 06:34:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=ta3A3Emr; 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 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230406AbiJRN0H (ORCPT + 99 others); Tue, 18 Oct 2022 09:26:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230099AbiJRNZs (ORCPT ); Tue, 18 Oct 2022 09:25:48 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2082.outbound.protection.outlook.com [40.107.223.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A765DC8216; Tue, 18 Oct 2022 06:25:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OOTqOrtnZ2s8gkBg8G3jT5kND5/0oFbFZ6EQpXbNtDvHwmqp7CEXJ1dFxTvsHnXCfuQUl7wRmr4JIa1uaL02ERFNZLrfO+drnq3FER5KHq5eki9x0R8usUZd2k23e713vQ8Go32i8chDVCpBl5ikG+6KJ1ABtu0OpmwFoMOqYnsN4mu47SDTWd9rPg3OjUQwjDUZ1fIgSQ9BbImzw610qryTRddJ+tv10/7GVpyLjQ/s8RDHVSHvynSY/OjMkuUfjSPTKB2cxEO9AdyotqcKenoz30Jy8+IY0wsi/CejnRz+JTQliAVEDO8B9BTHOq5oCKSRyO6mVieoWhgpbE9yiQ== 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=fKDHc51d7FEG0Lu5nY4eByWXC99jgX1kSwZm+TRGAHw=; b=WZV7qBjQD/42f8dN6RbGANVi4Sryz2j362pCr6Kv+lX8KB64lWKPknnj2q+gIFmfPqi1B2SnBjSxiMJsF5UVoDwdl9gXWxpJrnsT5gzAzzONleujJIhJiVMqcARzLDPqx+wn0nT4KX7Iq2qUGlJYdv606JaTDlJUaZakrJKfgXPADrCGocaazzwcXZBLddk0TBhzz3BIcZ4/GRuoatkhH1Z5F/sIHNwMFVwBHSx7Yk67BWoOtH1xJqEvj1+K5znSwYX/+GBlIEqWTVm7K3Fjm4YCxbjv4QAYM1xglOHbnFRSyu9K6L5z0op79isbN7hYbvVo+qDB7HsjPXqePr4A9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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 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=fKDHc51d7FEG0Lu5nY4eByWXC99jgX1kSwZm+TRGAHw=; b=ta3A3EmrRY72kYcFuny5f8FyfNICnbuXjIutvm2SUZm07eLpBMWlTWksO46tucKn3KYiuTJt9aFFF2eObybwvS7BT//Gk9w61gumS81632Twrz+ZHzZWKiz93o3Sj58SgNEsZoxZuojTDECWI8+jg8dfDw8tsjyKCxxDH7Wvyj8= Received: from BN9PR03CA0581.namprd03.prod.outlook.com (2603:10b6:408:10d::16) by CH0PR12MB5266.namprd12.prod.outlook.com (2603:10b6:610:d1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.33; Tue, 18 Oct 2022 13:25:01 +0000 Received: from BN8NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10d:cafe::94) by BN9PR03CA0581.outlook.office365.com (2603:10b6:408:10d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30 via Frontend Transport; Tue, 18 Oct 2022 13:25:00 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT028.mail.protection.outlook.com (10.13.176.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:25:00 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 08:24:56 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter Subject: [PATCH v2 11/12] cxl: Factor out code in match_add_dports() to pci_dev_add_dport() Date: Tue, 18 Oct 2022 15:23:39 +0200 Message-ID: <20221018132341.76259-12-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT028:EE_|CH0PR12MB5266:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f9f280b-fa20-4503-465a-08dab10c28db X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nGWAmxUBc5wQVTyVa10/bDMqRGlfRFQRZNB+5Y1WJa5CTt+8urbdwRDM+Ml3Rl4B2NV/rOMYJFzquRoCTvF7zyNy/eVV8GqYD8IVRUP/pwhkhrjJuQq+RwlvLZVSYv1RiCWA6qERINYMueD9s7Wt3rp2LESC2Pbqscbth4V7uAQbrYPOR1JtCSA989JXp/VMKol5UysUl/FoXM6W/a44fboMjFA32vZsVrx/PJ186djf+hdUxULSoz14QmdWeqzPkJ2ximfYN7Fb9I6l4jCd9xgFSY0a9WHN2ulGHibJgME/A20D6AGml/cDHKUmziEXgXlTDV8CuOR3XAeVfqsA6PXVQpV2w3J8cNwh/1Ykx7xzQNBdxYfEnGTlSTy9Fpoaba1OnAkG0WR9WjJ4BkPoO/v+V8RvOJ94l8REr28bjBH4OtI6IA2cJpBlTmCgZKWrn7Xo9zK76qQLr7nPzjpgxx22uWKgnybZhkHQhdJAbsqPjrXSBod6oXq0a5/uCxTSpLFEmhD65TVL08m9R27Cgpwj0reoPCS1Mhx4avOucBG6YV2V3y0ifBD6Bwf5j7YoAL6PtcgjcHcZkEorJqyB/wN0nlwCdd+aAEFT6Luyg/TSQIvMJohuGbquHd40uX+42jeE8pUB16wmfhxUtuc7C7hR1Uhvlzz2t+5eqXbVlrleR9wa/RRWQWm0esmOoA+fc2b31wd04Gz7LS+WcPWWejEeVMqPslg8uC5bpElPL3jqGYKMSi6KVZnlYzOQXpjIzOqZCx11l7Xr0rjd2Zg5jZy7phDKqOhx2qg/EWgjR5o= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(346002)(396003)(136003)(376002)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(110136005)(54906003)(4326008)(8676002)(7416002)(5660300002)(316002)(40460700003)(70586007)(70206006)(36860700001)(6666004)(478600001)(82310400005)(2906002)(41300700001)(36756003)(8936002)(83380400001)(186003)(1076003)(336012)(16526019)(426003)(47076005)(82740400003)(40480700001)(356005)(26005)(2616005)(81166007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:25:00.9216 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f9f280b-fa20-4503-465a-08dab10c28db 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5266 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747032577557861122?= X-GMAIL-MSGID: =?utf-8?q?1747032577557861122?= Factor out the code to register a PCI device's dport to a port. It will be reused to implement RCD mode. Signed-off-by: Robert Richter --- drivers/cxl/core/pci.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 8271b8abde7a..667de4f125f6 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -29,14 +29,32 @@ struct cxl_walk_context { int count; }; +static int pci_dev_add_dport(struct pci_dev *pdev, struct cxl_port *port, + resource_size_t component_reg_phys) +{ + struct cxl_dport *dport; + u32 lnkcap, port_num; + + if (pci_read_config_dword(pdev, pci_pcie_cap(pdev) + PCI_EXP_LNKCAP, + &lnkcap)) + return -ENXIO; + + port_num = FIELD_GET(PCI_EXP_LNKCAP_PN, lnkcap); + dport = devm_cxl_add_dport(port, &pdev->dev, port_num, + component_reg_phys); + if (IS_ERR(dport)) + return PTR_ERR(dport); + + return 0; +} + static int match_add_dports(struct pci_dev *pdev, void *data) { struct cxl_walk_context *ctx = data; struct cxl_port *port = ctx->port; int type = pci_pcie_type(pdev); struct cxl_register_map map; - struct cxl_dport *dport; - u32 lnkcap, port_num; + resource_size_t component_reg_phys; int rc; if (pdev->bus != ctx->bus) @@ -45,21 +63,18 @@ static int match_add_dports(struct pci_dev *pdev, void *data) return 0; if (type != ctx->type) return 0; - if (pci_read_config_dword(pdev, pci_pcie_cap(pdev) + PCI_EXP_LNKCAP, - &lnkcap)) - return -ENXIO; rc = cxl_find_regblock(pdev, CXL_REGLOC_RBI_COMPONENT, &map); if (rc) dev_dbg(&port->dev, "failed to find component registers\n"); - port_num = FIELD_GET(PCI_EXP_LNKCAP_PN, lnkcap); - dport = devm_cxl_add_dport(port, &pdev->dev, port_num, - cxl_regmap_to_base(pdev, &map)); - if (IS_ERR(dport)) { - ctx->error = PTR_ERR(dport); - return PTR_ERR(dport); + component_reg_phys = cxl_regmap_to_base(pdev, &map); + rc = pci_dev_add_dport(pdev, port, component_reg_phys); + if (rc) { + ctx->error = rc; + return rc; } + ctx->count++; return 0; From patchwork Tue Oct 18 13:23:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 4174 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1963135wrs; Tue, 18 Oct 2022 06:33:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6T9ttOaacM0YBgWE2TmzoAjdL2DNdcZWPzlivOwahyOnTmh+kO4RwffojGWKaL2qccDD/D X-Received: by 2002:a17:906:6791:b0:78d:4051:fcf0 with SMTP id q17-20020a170906679100b0078d4051fcf0mr2368796ejp.591.1666100039470; Tue, 18 Oct 2022 06:33:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666100039; cv=pass; d=google.com; s=arc-20160816; b=j7U1+fC84n1AP8ioj61jqP4ksWGtrWXdp/DzYkJLYK9XvNuqu64hGy9bCv9kptuxzr l8702ZmA0Tv6qtkYP2DM0at8z7XfwpSJutziTTJaTQmvYjmOere06z6zS/jrISHdy57V sxA5CaeE08EewfwKjPw/B0o5LU36hWzxn87QPArEud+A7Of+P+p1dDcn8ABG1c6ZC0Xc Zb1PWMCdQutvGVhbrlxfp6lHUHW3yp/25Nf0DcvXFckSKRSd+cY+aaaklraurPo9U+xL LYu3FP3KBwASWqELrz9cXyD/cEhF0Y01SXWYYmjFGo/Pij89ESx8i7xDXbLqRjR01ze3 YooA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WSlDXWGvidoCnzrNcuYQ6HS9PF/UoFr07bBjgjNrfXs=; b=R34LmWwK3DYy3x/OHjEU5TP3ix1+Q5Ffj0z/qh9FzYnd+pAOhpFWSSBBt3Ukk/0cZz l+OqqUgrgAOIUituHJmiiQXCTrlEnCaWEefjvWqEO3w9sPMNenrEPlAIsRhVTnjxPlzO GH0GojKh2YNcbUmeROvAUDCFCzSGyOb3Edta+quFBGtYAAY2otlFIwOGTBEVyGgz29Bm OlcvUaoUXc61U/r2mPaoqneWGRtFakR0aWuQzP7RDTNu/cMVFbWL/MG3AjqIoMZeRtSa nE+L7S65vr7nlYJHhIDiSLkBL5iIjH8AZ4V11q0J5AEKhVc4u+bCpnw1FH7rVvpmNHVw RKiw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=HA5fncxa; 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 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w19-20020a1709062f9300b007803b5893f2si10630824eji.672.2022.10.18.06.33.34; Tue, 18 Oct 2022 06:33:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=HA5fncxa; 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 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230099AbiJRN0M (ORCPT + 99 others); Tue, 18 Oct 2022 09:26:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230517AbiJRNZu (ORCPT ); Tue, 18 Oct 2022 09:25:50 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2070.outbound.protection.outlook.com [40.107.92.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4364220F4A; Tue, 18 Oct 2022 06:25:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g5XVzVLTsDyXNLRszvyUfBUaj3/9H1O1jVus0TTgns8q1lHNcLh4n+lkBzs1IQKwo0A8qTS5LPie60e8ea+PkX9dBDcsW4GZiRbRRlohX33i2p5SPU6xTra87J21DOIbp3S7ZpZTRyGNt9hVJpeHTcpm0JH3JBx0zm0wYsawqty4m2c8sT443FQnxTTozvW8szTBWVPoonGQIg4vUt2bXBB7/WKeZ9K8Q3pV2b6pWKWBEbndZAXWvrmN6MhQiiMyx1Sbit9IWXM2iH+9hlTfHLSYC93mU88AsBzdE5j7Q/3+moC8/kRgBfcpjCAt11cDYzvupEwgJf3BgLBI5QhKGA== 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=WSlDXWGvidoCnzrNcuYQ6HS9PF/UoFr07bBjgjNrfXs=; b=CeiUuGeX0xJahZOuAXfr2viorXXlbK9wm1mfPj27enWlkd0/YYlgPyxmoWxR7K8ESMmVmmKmkxUWnOeBPEpauw5TBA3Ny4BMAFrdW2OaVRov+j2rFFx8AMFLnFpp0mk18X4wCzN67vUOHiwsB10nvg2XVPq1kl4Ot5l0erlHYOK8XyzXFpAxn/hsuqP/FQjHpQ/EVXHDM7fyEuPMdtJEwg+Fe/sjY0fWnSwUUm/Vx1pu3Fdh/V+153t9RKMmeVQvJi0iisY3bojB1KDeuUY8fos0ZFhy62APzfuiPrCiVlk75U8NKYysLdp5oA8dlHkFEaE8az4NTQhBpQCMggrmhg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com 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 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=WSlDXWGvidoCnzrNcuYQ6HS9PF/UoFr07bBjgjNrfXs=; b=HA5fncxaNr90T1rxQ7CupP3lGQPVX+1QqR6y9J6ob2vepKWNEAG4Pmk9bKl7YUdqobE647jvuQkLNCxL3GMR7HWveGmqUPc/ZA10im3wZd/mCy2jdZriCmzradSqfTBWwS5OY2zFfFB6MgnVGY7RdgQFLo+XkqNhlyqs4hnguAk= Received: from BN9PR03CA0666.namprd03.prod.outlook.com (2603:10b6:408:10e::11) by BY5PR12MB4113.namprd12.prod.outlook.com (2603:10b6:a03:207::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32; Tue, 18 Oct 2022 13:25:02 +0000 Received: from BN8NAM11FT078.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10e:cafe::e2) by BN9PR03CA0666.outlook.office365.com (2603:10b6:408:10e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.33 via Frontend Transport; Tue, 18 Oct 2022 13:25:02 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT078.mail.protection.outlook.com (10.13.176.251) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 13:25:02 +0000 Received: from rric.localdomain (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 18 Oct 2022 08:24:59 -0500 From: Robert Richter To: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams CC: , , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , Jonathan Cameron , "Davidlohr Bueso" , Robert Richter Subject: [PATCH v2 12/12] cxl: Extend devm_cxl_port_enumerate_dports() to support restricted hosts (RCH) Date: Tue, 18 Oct 2022 15:23:40 +0200 Message-ID: <20221018132341.76259-13-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221018132341.76259-1-rrichter@amd.com> References: <20221018132341.76259-1-rrichter@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT078:EE_|BY5PR12MB4113:EE_ X-MS-Office365-Filtering-Correlation-Id: 54cd921f-b359-4d0c-667b-08dab10c298d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Es/Uqk0Pq4ACISn1odl+Wc75MKbuifwqpeiQv7f2PfsVWoPS0DFN3RU0doKYobmR5aeQKHti871q2gJDbe5vKqu0AteWKYqzC9Tdjwj+aL6nJC2H6GYHkNbQpU1uJvjnS/O1QcKBhfNw9IPDzjIKELCUf/VmTW5NpZIoynpFa9VypY2PEpiTJSRxWr+6brJG9ybtn8Hu+fpbU1L59ETvOTCeiC3NoCDnlQCgqwt+QfOMduTqnrsjeqRksbM78AFtskbF3xSSKPeYGwV9FKfZYgeiKO3j+LXL+v1Dp40dNuS0cVbxQkuiBubdyYM0flTzyWaUrfHOdXQb/MUglmdT9f2CfTYHlGHStvpo+Nh6Hu92rDEavrQBEOJLtMMSgNvokeFdTWQbZiU5rUEqB9FDi/78s6xErfcyivMGToUc5kXJqtPUwbs9s/deE/JjzeTFuqxkS2Uv+fLD0nzjyxiSynnarL9Fmi/Y6DiTzUgHhvHR8kkTKeVvyYOWLO72ZUuSFxXi1xASuO8fHVZaQfe3B/L4uQEEZo7lxheq7t39oxPQcWjd3qFFLOXbPTCskVsKfPzmuEjxek8G3+hnL1he6UWlCHe6VUSR4mvYDvvYqelyeii5SbKfM3nKDFzw04m190S/617BIw4LnynkSip/5EUfmeUmqITbXLVAHsqNvPmSLU+iHl1fbq9GyaBFbgkfD60fqCY3oS11DNfm3bIOS90DGTCxyIAAflnJ+aWbzee613qmFsDSOTVVSsy1X14GdFeiZqWdBOKXaeKOR5AtJscv8rlIUMJOwtdXt8uduIeLk+YpD2ISI8tKXpE3kqsM X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(376002)(136003)(346002)(39860400002)(396003)(451199015)(40470700004)(36840700001)(46966006)(336012)(83380400001)(81166007)(426003)(8936002)(356005)(36860700001)(47076005)(82740400003)(5660300002)(70206006)(41300700001)(8676002)(4326008)(82310400005)(70586007)(2906002)(7416002)(186003)(2616005)(1076003)(110136005)(26005)(54906003)(6666004)(40480700001)(316002)(478600001)(16526019)(40460700003)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 13:25:02.0734 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 54cd921f-b359-4d0c-667b-08dab10c298d 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT078.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4113 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747032515039307010?= X-GMAIL-MSGID: =?utf-8?q?1747032515039307010?= The PCIe Software View of an RCH and RCD is different to VH mode. An RCD is paired with an RCH and shows up as RCiEP. Its downstream and upstream ports are hidden to the PCI hierarchy. This different PCI topology requires a different handling of RCHs. Extend devm_cxl_port_enumerate_dports() to support restricted hosts (RCH). If an RCH is detected, register its port as dport to the device. An RCH is found if the host's dev 0 func 0 devices is an RCiEP with an existing PCIe DVSEC for CXL Devices (ID 0000h). Signed-off-by: Robert Richter --- drivers/cxl/core/pci.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index 667de4f125f6..a6b1a1501db3 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -48,6 +48,37 @@ static int pci_dev_add_dport(struct pci_dev *pdev, struct cxl_port *port, return 0; } +static int restricted_host_enumerate_dport(struct cxl_port *port, + struct pci_bus *bus) +{ + struct pci_dev *pdev; + bool is_restricted_host; + int rc; + + /* Check CXL DVSEC of dev 0 func 0 */ + pdev = pci_get_slot(bus, PCI_DEVFN(0, 0)); + + is_restricted_host = pdev + && (pci_pcie_type(pdev) == PCI_EXP_TYPE_RC_END) + && pci_find_dvsec_capability(pdev, + PCI_DVSEC_VENDOR_ID_CXL, + CXL_DVSEC_PCIE_DEVICE); + if (is_restricted_host) + rc = pci_dev_add_dport(pdev, port, CXL_RESOURCE_NONE); + + pci_dev_put(pdev); + + if (!is_restricted_host) + return 0; + + dev_dbg(bus->bridge, "CXL restricted host found\n"); + + if (rc) + return rc; + + return 1; +} + static int match_add_dports(struct pci_dev *pdev, void *data) { struct cxl_walk_context *ctx = data; @@ -91,11 +122,15 @@ int devm_cxl_port_enumerate_dports(struct cxl_port *port) { struct pci_bus *bus = cxl_port_to_pci_bus(port); struct cxl_walk_context ctx; - int type; + int type, count; if (!bus) return -ENXIO; + count = restricted_host_enumerate_dport(port, bus); + if (count) + return count; + if (pci_is_root_bus(bus)) type = PCI_EXP_TYPE_ROOT_PORT; else