Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1398256rdb; Mon, 2 Oct 2023 08:22:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHuPCnuNu9r5PUjX/7ofl7CKhtqR0MTxA8S8YjOkrb5Qku8db3dChff7A2Zr8cXDZ98nzta X-Received: by 2002:a17:902:dacd:b0:1bb:2020:be0d with SMTP id q13-20020a170902dacd00b001bb2020be0dmr16379460plx.14.1696260170365; Mon, 02 Oct 2023 08:22:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696260170; cv=none; d=google.com; s=arc-20160816; b=1JMAIvcrlu0WKmvzhKevNsCh1GsKo2rTHWTc4qU6GdVnmd2mr+0K1JI+NiHLNX/Otu 0baHVFdetYdH7fOAGEDPP+K0KKQpyLyq/rbR70qWweYp4ug73XPoF8BfaYwWUIQrmw6J C8dr1MRNUAvo6o9JR+j/drBh9OOPZ3xTBFwAh/N54UXUhMWOX0vujmEZjEN5UhIpKlTl FRlk1svKNtmH2Z2x4pHhRXrt8Vnlq+ikKViMP31s7QBZK5dasYZLyx7SOV5AstXfrT9/ 0fff6ZZtlciYCBoH1cL2Rmm4xMOXL5M7G9SxPLy43gcfDSmIzYpljYB3qL85eGvzD9sR BdqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=eCS5/0JhDvhNqy2/iklj8pNBjiiRPW6UaYAbc0hNiWQ=; fh=6T4zZ8HeN4FNvjm5k4DIT/y7+At3BG9x6FXMDOBhu9c=; b=ajHM3JcCfFFL9Dhbbr4uF/pKL8ryBplrjoi2E/qmaZNSzsU78v+5cZae4bT4QLnmR5 ZjqA2BA924ped12OddYTpgi5iQjdVGcVShmqZOOPOvMclprj49Bx1LigxFmOuZoDmoGv pjP8prJiKoCLDhAUPVe9Kja7suT5FF37zOwmW720hzKDS5Suha75cqkOFlpCJomP5rLK jMosJunsyWKHaSuP6OrAvs3TZ3rwPaFN3ARval8APb6atJdy53TPP7/qzlHnU3cbcyOh 5C3YcK4WpW9gk8cmzWuvrgpzAU5XQf2KajwxKqUDeUAOxc51g3IoSIzKAF+Ef993jgXY H5/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id t14-20020a170902e84e00b001b84f9263e7si29253084plg.325.2023.10.02.08.22.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 08:22:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id DD6A88074CAE; Mon, 2 Oct 2023 07:57:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237909AbjJBO5I (ORCPT + 99 others); Mon, 2 Oct 2023 10:57:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237911AbjJBO5H (ORCPT ); Mon, 2 Oct 2023 10:57:07 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52382B3; Mon, 2 Oct 2023 07:57:02 -0700 (PDT) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4RzkW23kZgz6HJX9; Mon, 2 Oct 2023 22:54:22 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Mon, 2 Oct 2023 15:56:59 +0100 Date: Mon, 2 Oct 2023 15:56:58 +0100 From: Jonathan Cameron To: Robert Richter CC: Alison Schofield , Vishal Verma , Ira Weiny , Ben Widawsky , Dan Williams , "Davidlohr Bueso" , Dave Jiang , , , Bjorn Helgaas , Terry Bowman Subject: Re: [PATCH v11 14/20] cxl/pci: Map RCH downstream AER registers for logging protocol errors Message-ID: <20231002155658.00004ac0@Huawei.com> In-Reply-To: <20230927154339.1600738-15-rrichter@amd.com> References: <20230927154339.1600738-1-rrichter@amd.com> <20230927154339.1600738-15-rrichter@amd.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml100002.china.huawei.com (7.191.160.241) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=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 pete.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 (pete.vger.email [0.0.0.0]); Mon, 02 Oct 2023 07:57:22 -0700 (PDT) On Wed, 27 Sep 2023 17:43:33 +0200 Robert Richter wrote: > From: Terry Bowman > > The restricted CXL host (RCH) error handler will log protocol errors > using AER and RAS status registers. The AER and RAS registers need to > be virtually memory mapped before enabling interrupts. Create the > initializer function devm_cxl_setup_parent_dport() for this when the > endpoint is connected with the dport. The initialization sets up the > RCH RAS and AER mappings. > > Add 'struct cxl_regs' to 'struct cxl_dport' for saving a pointer to > the RCH downstream port's AER and RAS registers. > > Co-developed-by: Robert Richter > Signed-off-by: Terry Bowman As before. Co-dev just before SoB. https://elixir.bootlin.com/linux/latest/source/Documentation/process/submitting-patches.rst#L521 This example looks like what you have here. > Signed-off-by: Robert Richter Otherwise, LGTM Reviewed-by: Jonathan Cameron > --- > drivers/cxl/core/pci.c | 36 ++++++++++++++++++++++++++++++++++++ > drivers/cxl/cxl.h | 10 ++++++++++ > 2 files changed, 46 insertions(+) > > diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c > index 2b8883288539..2af7ad77b273 100644 > --- a/drivers/cxl/core/pci.c > +++ b/drivers/cxl/core/pci.c > @@ -5,6 +5,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -730,6 +731,38 @@ static bool cxl_handle_endpoint_ras(struct cxl_dev_state *cxlds) > > #ifdef CONFIG_PCIEAER_CXL > > +static void cxl_dport_map_rch_aer(struct cxl_dport *dport) > +{ > + struct cxl_rcrb_info *ri = &dport->rcrb; > + void __iomem *dport_aer = NULL; > + resource_size_t aer_phys; > + struct device *host; > + > + if (dport->rch && ri->aer_cap) { > + host = dport->reg_map.host; > + aer_phys = ri->aer_cap + ri->base; > + dport_aer = devm_cxl_iomap_block(host, aer_phys, > + sizeof(struct aer_capability_regs)); > + } > + > + dport->regs.dport_aer = dport_aer; > +} > + > +static void cxl_dport_map_regs(struct cxl_dport *dport) > +{ > + struct cxl_register_map *map = &dport->reg_map; > + struct device *dev = dport->dport_dev; > + > + if (!map->component_map.ras.valid) > + dev_dbg(dev, "RAS registers not found\n"); > + else if (cxl_map_component_regs(map, &dport->regs.component, > + BIT(CXL_CM_CAP_CAP_ID_RAS))) > + dev_dbg(dev, "Failed to map RAS capability.\n"); > + > + if (dport->rch) > + cxl_dport_map_rch_aer(dport); > +} > + > void devm_cxl_setup_parent_dport(struct device *host, struct cxl_dport *dport) > { > struct device *dport_dev = dport->dport_dev; > @@ -738,6 +771,9 @@ void devm_cxl_setup_parent_dport(struct device *host, struct cxl_dport *dport) > host_bridge = to_pci_host_bridge(dport_dev); > if (host_bridge->native_cxl_error) > dport->rcrb.aer_cap = cxl_rcrb_to_aer(dport_dev, dport->rcrb.base); > + > + dport->reg_map.host = host; > + cxl_dport_map_regs(dport); > } > EXPORT_SYMBOL_NS_GPL(devm_cxl_setup_parent_dport, CXL); > > diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h > index cfa2f6bede41..7c2c195592d6 100644 > --- a/drivers/cxl/cxl.h > +++ b/drivers/cxl/cxl.h > @@ -221,6 +221,14 @@ struct cxl_regs { > struct_group_tagged(cxl_pmu_regs, pmu_regs, > void __iomem *pmu; > ); > + > + /* > + * RCH downstream port specific RAS register > + * @aer: CXL 3.0 8.2.1.1 RCH Downstream Port RCRB > + */ > + struct_group_tagged(cxl_rch_regs, rch_regs, > + void __iomem *dport_aer; > + ); > }; > > struct cxl_reg_map { > @@ -623,6 +631,7 @@ struct cxl_rcrb_info { > * @rcrb: Data about the Root Complex Register Block layout > * @rch: Indicate whether this dport was enumerated in RCH or VH mode > * @port: reference to cxl_port that contains this downstream port > + * @regs: Dport parsed register blocks > */ > struct cxl_dport { > struct device *dport_dev; > @@ -631,6 +640,7 @@ struct cxl_dport { > struct cxl_rcrb_info rcrb; > bool rch; > struct cxl_port *port; > + struct cxl_regs regs; > }; > > /**