Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp119234rdb; Wed, 18 Oct 2023 21:40:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH5yNXtnn/BjA5zoEUTZgMH0FPUIXF29BUAPA34X6fLOVMBpS47eW7rMQwOKVq2IFBN8Qoz X-Received: by 2002:a17:90a:4888:b0:27c:f8d4:a4ca with SMTP id b8-20020a17090a488800b0027cf8d4a4camr1126129pjh.44.1697690445151; Wed, 18 Oct 2023 21:40:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697690445; cv=pass; d=google.com; s=arc-20160816; b=t1Nj0Q1NeWdwcpdQ0ghmdKbw1Tq5sh6CnGQpujgSHAg0WNQCG6sTQUzqcGXGdHSaN9 DKR/D2Xx/ChdkqICA4ZZZaChXy17BNS5oojHWT18JKYroyc8atmxcQkjiRZ96YJBmPg0 fMfidltHYtXElVTTF9xSJkDK9UCplGLecHKCLKFldW6D9fqIG7Gj+xBtXXvBLInltEI7 MOVHo9k/aw1lVCHSZ3di6QR9Of/6VJVwTCxLzRNOyOdGcgfGV2g0ZVDRV9UHvfom8P8Y BfKawXPopwNrIh0YYnutirUhwXNfZx3U484o07F+mn9EBhTcb4fzg2y8n+CM2X+qW8xa 2KUg== 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=+mpbMDvyRqMdfoxvXeGGWdCuDclZXRANG1e6m6hVK+I=; fh=LArJOppjV7nsPq5fkdf1BD06bwWkrwXghH/Izt0gFjg=; b=Mk4zZz7D20hvhBtarZIJGtLWwzB9R4p8xe8uZJuAkmfCCK5WGzbpqj/hVQpUNog1L1 4R4bZg+GdTYO11pS/vtpZhk0evERjS6URTDakP8at4XXSse3DFp55bvZ91Iurw0Do1qD pfNEu5Rl2AX6LCV/y/B9GEWX7eh1BpsPmMf05Xdm71++MKRejJZBIn7IQepip36oU/QB /2H2irNLozMJR4VuRmlCyTa+SwMR6BtvDRaTw30/uwzq0ERrYdbiycH5CMUp9KnDpKu/ bvsidVspmB/n8++6IeS2wUyWSgVopnfnrTR1I2ZD4Mik6gCczQgHyvOXNQjA+CrwJ/rO gGDQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="VwKB/JYT"; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id i14-20020a17090acf8e00b00268e32e99f0si1260927pju.28.2023.10.18.21.40.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 21:40:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="VwKB/JYT"; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 5F7D480FCE49; Wed, 18 Oct 2023 10:31:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231222AbjJRRaq (ORCPT + 99 others); Wed, 18 Oct 2023 13:30:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231824AbjJRR3z (ORCPT ); Wed, 18 Oct 2023 13:29:55 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2064.outbound.protection.outlook.com [40.107.96.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6054AD41; Wed, 18 Oct 2023 10:18:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jEsSpy46ZNWUdIDd6Z3gvYEhF5HtkHjKe5SRjJSm4JaB3KO4d9A9GMk7S7MUHt4HR4bXvXY+keSMhq3iYOVYz2d7cqhuoo8viu30iSO17AOjExAIe9kFgeIfEErhgcgMzARbBaRpXuiEZci4evQEDlgzv5tiZwBcW0XYHWrecRNvmTqOjqvoJKH1TLINzjnPfuSk6esXWHWOkg5a+hAcZQo1MfzPALL2Z07HFirH7Dit7RNMQwLI324YixXi2bvH/Y+UQHT8Maa2M+//U1JZgbulEnQqCmJLVJYN7LVFVYI5Nj6psbLdMMJsHL4NDofedSF1/hjRzqz/kx8TZOuOdw== 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=+mpbMDvyRqMdfoxvXeGGWdCuDclZXRANG1e6m6hVK+I=; b=aNxxyV1K8gl1IgT9g1RsNZH1gRaJBSNTxf61Qo+Lov+8bmYeImZSYOKyoxZAGcn6zu0xHeJER0oABPVk3hxDzVm1UL0e6tkCSKXJfru88tFr5UbtEb86Vm0D7W7kLibkMS8EtdnThsdTri2wMhzd/jqqT5BkK2/8P4K574aXt3WE6m2oYQIOUsbBVT86ZeEUP4WLBh5jCv2Ue/bQbvY1AlQUDwn9oSjNCNEFs2yVUpCRelG8IEqnz0FFN8ol2/iRlcXsOfatk91DF6sK5RVSnFxylXn8gv2XLUytC/pS3LKz/2nQvsMS6cJwrQw2nBZ9RtVtq1i9RHDWQ91fufcHCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 165.204.84.17) smtp.rcpttodomain=stgolabs.net smtp.mailfrom=amd.com; dmarc=temperror 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=+mpbMDvyRqMdfoxvXeGGWdCuDclZXRANG1e6m6hVK+I=; b=VwKB/JYTvyrdwyubj7h3P4GFGF/ybASE3Rywa37eGh6OjfUb/m5BbdFzzR4owM9LZ7WzF1ro0tbD9oYWhmbGdQkPM/ROqNwnt9r/41XdHmeb0MtGoCubO2t7hxl5JOS9gh1JicaULLC8lDxjd8Fy4pQsR3aABDk10FMRfOOUqNw= Received: from PR1P264CA0040.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:2cb::19) by DM6PR12MB4354.namprd12.prod.outlook.com (2603:10b6:5:28f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Wed, 18 Oct 2023 17:18:18 +0000 Received: from SN1PEPF0002529E.namprd05.prod.outlook.com (2603:10a6:102:2cb:cafe::94) by PR1P264CA0040.outlook.office365.com (2603:10a6:102:2cb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.22 via Frontend Transport; Wed, 18 Oct 2023 17:18:17 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=amd.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of amd.com: DNS Timeout) Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF0002529E.mail.protection.outlook.com (10.167.242.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.20 via Frontend Transport; Wed, 18 Oct 2023 17:18:15 +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.2507.27; Wed, 18 Oct 2023 12:18:11 -0500 From: Robert Richter To: Davidlohr Bueso , Jonathan Cameron , Dave Jiang , "Alison Schofield" , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams , Terry Bowman , Robert Richter CC: , , Bjorn Helgaas , Jonathan Cameron Subject: [PATCH v12 03/20] cxl/port: Fix @host confusion in cxl_dport_setup_regs() Date: Wed, 18 Oct 2023 19:16:56 +0200 Message-ID: <20231018171713.1883517-4-rrichter@amd.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231018171713.1883517-1-rrichter@amd.com> References: <20231018171713.1883517-1-rrichter@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: SN1PEPF0002529E:EE_|DM6PR12MB4354:EE_ X-MS-Office365-Filtering-Correlation-Id: 386cad41-ed44-46be-93e2-08dbcffe376b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gBPSwPm18cX/JugJH7sgL6Hzt+8iujRzg2usXq5QIY5GVeGw/TQyUQ1MdBLVa25Os5+ZFMBnIFFukaDCUuJADUSBb+BB3NoM8HNLeYoSnRUyzL6lRPZKWXLK6Jdc1LlmEqbvg3tZMfPXHb9QfWT7VV1aFtb7x6foiDBujH8FdkvpcrDeTlndpmAuEd26qevkjLSoqFdjrpjAAZz011Sa9YkHj+Ak0gWJzu+w8WPXnA28ZCUbG3FUuYaHs8qbji30LF2X7+qn+01sHgvJNGVZiOrV+jebeJV7YqjRmSATvB3gdGPWu9wyVJMYyHfmSKomr2A47kxFLsYNQWvRNTFxCjOifn1CgFYYArGzUClglHupEEWM62iMsu5qRD5qz4+VE7wKOetdkL2bawjVfcZ+nxxV4NROkatJfyNhy9WKO7tK5MCJeFjaxOasRRQzxP9bHlwhfZSQx2Hv2P04PtbBGoFhVAYp2u+vxPuQKIQmEUXPIUrDTzfE6z5lQiLgg65I3Q/fRnh9vaK+O3Psd19ilMMjzsopX7k4KsR0K5FNPLF3sR6R4KL9IZUlWr/8dj4lD1X6liUCRzVTzmvFe0v63y7cWaXatK05uDPRw4iE/6j9ewrgFQF1ztOu66jIhLyqjPS3GLXQqAoZEOy+UKBQY9Ko22fq7SB5yfyQxgVQ88ndev7zr/Or55uDsSXSjAbcSk/M5XCkBpQUE4/FsYkC1XdM+gvf0DGVCIWJqJrnwiq6sthhLLI1HR3gJTpO4EBzz13qwmx/0kELWQhAuRPwJ6FMxQp/UzWOr+07fLlIeDc= 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:(13230031)(4636009)(346002)(136003)(39860400002)(396003)(376002)(230922051799003)(82310400011)(1800799009)(64100799003)(451199024)(186009)(40470700004)(36840700001)(46966006)(7416002)(2906002)(63370400001)(356005)(63350400001)(921005)(110136005)(40480700001)(478600001)(81166007)(41300700001)(36756003)(54906003)(70206006)(70586007)(36860700001)(7049001)(6666004)(316002)(8676002)(1076003)(2616005)(26005)(16526019)(336012)(426003)(82740400003)(40460700003)(83380400001)(4326008)(47076005)(8936002)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 17:18:15.5872 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 386cad41-ed44-46be-93e2-08dbcffe376b 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: SN1PEPF0002529E.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4354 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 18 Oct 2023 10:31:13 -0700 (PDT) From: Dan Williams commit 5d2ffbe4b81a ("cxl/port: Store the downstream port's Component Register mappings in struct cxl_dport") ...moved the dport component registers from a raw component_reg_phys passed in at dport instantiation time to a 'struct cxl_register_map' populated with both the component register data *and* the "host" device for mapping operations. While typical CXL switch dports are mapped by their associated 'struct cxl_port', an RCH host bridge dport registered by cxl_acpi needs to wait until the cxl_mem driver makes the attachment to map the registers. This is because there are no intervening 'struct cxl_port' instances between the root cxl_port and the endpoint port in an RCH topology. For now just mark the host as NULL in the RCH dport case until code that needs to map the dport registers arrives. This patch is not flagged for -stable since nothing in the current driver uses the dport->comp_map. Now, I am slightly uneasy that cxl_setup_comp_regs() sets map->host to a wrong value and then cxl_dport_setup_regs() fixes it up, but the alternatives I came up with are more messy. For example, adding an @logdev to 'struct cxl_register_map' that the dev_printk()s can fall back to when @host is NULL. I settled on "post-fixup+comment" since it is only RCH dports that have this special case where register probing is split between a host-bridge RCRB lookup and when cxl_mem_probe() does the association of the cxl_memdev and endpoint port. Fixes: 5d2ffbe4b81a ("cxl/port: Store the downstream port's Component Register mappings in struct cxl_dport") Signed-off-by: Dan Williams [kept dev_dbg() message] [moved rename of @comp_map to @reg_map into next patch] Signed-off-by: Robert Richter Reviewed-by: Jonathan Cameron --- drivers/cxl/core/port.c | 43 +++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c index 033651a5da30..9b1136018f18 100644 --- a/drivers/cxl/core/port.c +++ b/drivers/cxl/core/port.c @@ -716,13 +716,23 @@ static int cxl_port_setup_regs(struct cxl_port *port, component_reg_phys); } -static int cxl_dport_setup_regs(struct cxl_dport *dport, +static int cxl_dport_setup_regs(struct device *host, struct cxl_dport *dport, resource_size_t component_reg_phys) { + int rc; + if (dev_is_platform(dport->dport_dev)) return 0; - return cxl_setup_comp_regs(dport->dport_dev, &dport->comp_map, - component_reg_phys); + + /* + * use @dport->dport_dev for the context for error messages during + * register probing, and fixup @host after the fact, since @host may be + * NULL. + */ + rc = cxl_setup_comp_regs(dport->dport_dev, &dport->comp_map, + component_reg_phys); + dport->comp_map.host = host; + return rc; } static struct cxl_port *__devm_cxl_add_port(struct device *host, @@ -983,7 +993,16 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, if (!dport) return ERR_PTR(-ENOMEM); - if (rcrb != CXL_RESOURCE_NONE) { + dport->dport_dev = dport_dev; + dport->port_id = port_id; + dport->port = port; + + if (rcrb == CXL_RESOURCE_NONE) { + rc = cxl_dport_setup_regs(&port->dev, dport, + component_reg_phys); + if (rc) + return ERR_PTR(rc); + } else { dport->rcrb.base = rcrb; component_reg_phys = __rcrb_to_component(dport_dev, &dport->rcrb, CXL_RCRB_DOWNSTREAM); @@ -992,6 +1011,14 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, return ERR_PTR(-ENXIO); } + /* + * RCH @dport is not ready to map until associated with its + * memdev + */ + rc = cxl_dport_setup_regs(NULL, dport, component_reg_phys); + if (rc) + return ERR_PTR(rc); + dport->rch = true; } @@ -999,14 +1026,6 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev, dev_dbg(dport_dev, "Component Registers found for dport: %pa\n", &component_reg_phys); - dport->dport_dev = dport_dev; - dport->port_id = port_id; - dport->port = port; - - rc = cxl_dport_setup_regs(dport, component_reg_phys); - if (rc) - return ERR_PTR(rc); - cond_cxl_root_lock(port); rc = add_dport(port, dport); cond_cxl_root_unlock(port); -- 2.30.2