Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp1195594rdb; Fri, 20 Oct 2023 11:01:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELnjW5Kz9VjRiywSdY7Uz8hdl+0Tozip4ZfIY6WaBJ6mitJQlby0GZUouZQsWhcza5k0It X-Received: by 2002:a17:902:eccb:b0:1c9:ba18:785c with SMTP id a11-20020a170902eccb00b001c9ba18785cmr3477995plh.25.1697824898350; Fri, 20 Oct 2023 11:01:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697824898; cv=pass; d=google.com; s=arc-20160816; b=I6JqTp9EqjN2vPD2d20lsDA3o17SKgp17aIwXGnxTpPGstN9n+Tb+79fENjf0iN+Z6 bPHVJJfYJ/HMsmqJJWn5KNmvIE8l8Ns7UDrlUH8f4kc6kJG8h/fjljEci0HBDxF2Y9V/ UpICC3YAZItzVoQZ4g8+4C5Cbbe5lr3j44WY02KMqKLmdUEzvhB2Nc+PT/BtmHhzVYGV crBgSr6UnWuOAituJFwt3nNRRsxQUyv8wyyVqW7LEuFy4x47lkNisd8SZFUqeaE+RWUJ XWwqzjGn29WoPr3Dg9eyS1NqoSTh3uWK09BgkHNAjyfz3vE4z4btRtBT98w2nFa2DkiA +uDw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to :content-transfer-encoding:content-disposition:references:message-id :subject:cc:to:from:date:dkim-signature; bh=vDAkyi+VlMeJxFIoletHt4xEHdGZAAM22wWAwFiTqd8=; fh=ZySeTaIrMyF6o4OK5WvkpaqpDN44KQbM5y8VOWnMxx4=; b=bzWWj6BAkdXJAbY9cyCpqaYOGTw2i9e5DzZ4MBGBA7DhGe55RZg3FzGP/RFvf9pmcY E/IGVhmV5Az+U51V63Kj1sr3x2vhfdhG9qR7dpnoSTBW5JudyBwXmzDFGSZFOpbqaVUL qMhvGgen9EiR1FX5pkjlaZv5clwRiLZkfcWIpOoILSjx9anpNfOMPsF1rRzJVSUJmMVy rsy2DgmefQ90o4L/ZlYN9ZFoI6bqvSr6q5/mQybzoNY2YEZ/v0H/XxmUtFPDcNC0X11k X1saQBj7Gjw2Hy/XOSVSqvKWYFd7Q6IhN4/lOLcB6U7rdNVW90bX2pe9PhOTsN1mikia emWw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=dk2eEK1q; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id p3-20020a170902a40300b001bdf6eb05f2si2147028plq.227.2023.10.20.11.01.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 11:01:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=dk2eEK1q; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id D749E805A5FB; Fri, 20 Oct 2023 11:01:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230084AbjJTSAb (ORCPT + 99 others); Fri, 20 Oct 2023 14:00:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjJTSA1 (ORCPT ); Fri, 20 Oct 2023 14:00:27 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2085.outbound.protection.outlook.com [40.107.21.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B0F4D55; Fri, 20 Oct 2023 11:00:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I9NWcNXPN7Q0kKpvsPKDCEJ5D1CxeDvp4SDXzDrxa+FKjAI5rJxBuoc6sosnhbaQYF4gmQNnF0t2Wpe4Fr2NDXPSl+ZDIKKnGLyFNKXntM+kzMm+HdauPRuUxT9YilYTZas14WRLkk1vH4J99sIReTwQZCiHr1IjsV7jQPTARMzD2fekfid8QtJ8E2s+3LBdHE3f88/A3bFKEmSueR5HdjyYm4iccKAko/8uPn19w5WuA1WEUi+e/OqLVbDHIr843jMA/pq+lirF/w9HiygzpwXdDIw0i0I33WKuqp2dFMtT1aOb7k8ct1D+vmhrmefKoTOkvH/0d+8mEjBiwY5Gpw== 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=vDAkyi+VlMeJxFIoletHt4xEHdGZAAM22wWAwFiTqd8=; b=mbUGCHIQMbThXZiTfr2rPTVtx4gZ0SgFoJp6Zz/Mrked8Rmx2grz62qgzYq4IF3sTixK4ISbDfw1s8BSzdpNougjSR6zQ512aZe9hIpCKSaBfrdPVJfEvt3G9/wF/xnOcRA/CMcoXjzaGwseOZPS/oEWAeREptCjiLO59GQ7G9BrLg0i2WUspBX2aBf1nqnSWO8C0DTiCWTTaiHDc1VH/lxBRtz1dY11W3hZXewhDVZ1K/ZcHHfOCxmoeqhOTW8YEz/7IC97zAkVFtGYpdk4+DU02Ct5awH3AgI3t9RAbB8l3H7aZ7tnoif/Pg4gL/zsM800gZtIA6oi6TXkqCtCaw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vDAkyi+VlMeJxFIoletHt4xEHdGZAAM22wWAwFiTqd8=; b=dk2eEK1qZaDi+MMS1Obqk8f7YJrfCO8TfgiJRktjgPcrtgaZaTDU/uReJ4u76dMphMltGxS/4ILpuUC8mLAJW14HBb0KczS9p5E4sM3Y6pXOnDogLUa6Vz+8NZd2My/uyy6Bnv5WwYokzHiOxtNybB4h/Z0Z3grwBBTTfGAbsHQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by AS8PR04MB7816.eurprd04.prod.outlook.com (2603:10a6:20b:2a3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.8; Fri, 20 Oct 2023 18:00:15 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::1774:e25f:f99:aca2]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::1774:e25f:f99:aca2%4]) with mapi id 15.20.6907.022; Fri, 20 Oct 2023 18:00:15 +0000 Date: Fri, 20 Oct 2023 14:00:06 -0400 From: Frank Li To: Manivannan Sadhasivam Cc: Manivannan Sadhasivam , aisheng.dong@nxp.com, bhelgaas@google.com, devicetree@vger.kernel.org, festevam@gmail.com, imx@lists.linux.dev, jdmason@kudzu.us, kernel@pengutronix.de, kishon@kernel.org, kw@linux.com, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lorenzo.pieralisi@arm.com, lpieralisi@kernel.org, maz@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org, tglx@linutronix.de Subject: Re: [PATCH v2 1/5] PCI: endpoint: Add RC-to-EP doorbell support using platform MSI controllery Message-ID: References: <20230911220920.1817033-1-Frank.Li@nxp.com> <20230911220920.1817033-2-Frank.Li@nxp.com> <20231017183722.GB137137@thinkpad> <20231019150441.GA7254@thinkpad> <20231019172347.GC7254@thinkpad> <20231020171215.GA46191@thinkpad> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231020171215.GA46191@thinkpad> X-ClientProxiedBy: SJ0PR13CA0144.namprd13.prod.outlook.com (2603:10b6:a03:2c6::29) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|AS8PR04MB7816:EE_ X-MS-Office365-Filtering-Correlation-Id: 5544cac5-58da-46ba-505c-08dbd19669d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gAFBgs4+NX7OVcHZ0BW873Ap3WSYNYEmNKIDPNuMJJoOEy/gzm7VQjGdyO+fOu7dJBfMUl35VQBmSzgSvX90vWX97KDvl3Ja7oRktR+bjovOom0NzNWx6Ozak5r2Z1uBdmdeik/kJ8+tGJHBdcdFlUl+KOW6tgTaxB2bomZ07OQ0BhFsR6xqPzpWKX53CPzb3BZ+Zci2egFhv5uooLEV2UJU5635TpoyHZLe4CS3+IHiPs2HJmMBCe2t9I9M5JYgKh7G6KOJIDooZb3HyqXa8jsFdYWCIV24YlCOMIPJSvlu+TY/gkY+DQQtczaNb6rooDLNoqkDilvUPEAz7Le51oEzFyGKKYv9NPc0M9CgdtUnoAYfrenmlToPL2SHdvz+dqpBbnbPZHCUVqFDrXWe4UORgAVshuQ8GsKwZ6DFZqxZ3geuBfaWD14wtR/SzzUms1rUnHsE9h1EiuafcnPYicCqCIKvwTZNrRRGFnq7bee7quSrAA7ocNDFRZcifZoOhuZmoZnwTbr5JcdDN+VGIPiHeu6Pa/H9A9Pjgakitus26W26dE46r7Nx4W4Xy3PImoOKZtxtkx8Wzl0gQN1kX9t4DYzW42omZM7C+FDgTTg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB4838.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7916004)(39860400002)(346002)(376002)(366004)(396003)(136003)(230922051799003)(451199024)(64100799003)(1800799009)(186009)(83380400001)(26005)(2906002)(7416002)(8676002)(30864003)(4326008)(38350700005)(5660300002)(8936002)(86362001)(33716001)(52116002)(6666004)(9686003)(6506007)(6486002)(966005)(41300700001)(66556008)(66946007)(316002)(6916009)(6512007)(66476007)(478600001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dS9WNUJYaXlOL2dKYVhhK3p0WitaSnZ5Z0l4VGJjUmJrMGQrR0hiU2RTaW52?= =?utf-8?B?UGMzNm5GSHR2V0tzdCtHSUNndGpaRFg3ZTBMRDUvMDRKQWltc3pPUHNScDhr?= =?utf-8?B?VWVEV0htR3I1d0R2b0ZEVDRZNHIzSyt1OTk5dTZNVlJLMXFvT3Z5aC9BT0dq?= =?utf-8?B?aVA2ekVBa2hQelgyY1VPRzZYQWk4R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B?YjhBelRRQzMyd2poRmRrQVlDQWNmU1JKazR6RFhPeDJUeFFZSkJpbjZuTkkr?= =?utf-8?B?SG9sNTc4M082ZEJERUhoQmMwVnMxK2hIbWZzTzRIbGRGSTJTQU1oR1JXSjNN?= =?utf-8?Q?CwaA=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5544cac5-58da-46ba-505c-08dbd19669d4 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2023 18:00:15.5439 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CCrGt6kXEA1zviMXc2Wy0af6huv6mCrcnU3RaQsEtmXMzoClBp2MZX/GNMxPOD66/tK94aNkgHz3pYtYuJ+Zjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7816 X-Spam-Status: No, score=-0.8 required=5.0 tests=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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 20 Oct 2023 11:01:02 -0700 (PDT) On Fri, Oct 20, 2023 at 10:42:15PM +0530, Manivannan Sadhasivam wrote: > On Thu, Oct 19, 2023 at 02:11:22PM -0400, Frank Li wrote: > > On Thu, Oct 19, 2023 at 10:53:47PM +0530, Manivannan Sadhasivam wrote: > > > On Thu, Oct 19, 2023 at 12:00:22PM -0400, Frank Li wrote: > > > > On Thu, Oct 19, 2023 at 08:34:41PM +0530, Manivannan Sadhasivam wrote: > > > > > On Tue, Oct 17, 2023 at 02:55:57PM -0400, Frank Li wrote: > > > > > > On Wed, Oct 18, 2023 at 12:07:22AM +0530, Manivannan Sadhasivam wrote: > > > > > > > On Mon, Sep 11, 2023 at 06:09:16PM -0400, Frank Li wrote: > > > > > > > > This commit introduces a common method for sending messages from the Root > > > > > > > > Complex (RC) to the Endpoint (EP) by utilizing the platform MSI interrupt > > > > > > > > controller, such as ARM GIC, as an EP doorbell. Maps the memory assigned > > > > > > > > for the BAR region by the PCI host to the message address of the platform > > > > > > > > MSI interrupt controller in the PCI EP. As a result, when the PCI RC writes > > > > > > > > > > > > > > "Doorbell feature is implemented by mapping the EP's MSI interrupt controller > > > > > > > message address to a dedicated BAR in the EPC core. It is the responsibility > > > > > > > of the EPF driver to pass the actual message data to be written by the host to > > > > > > > the doorbell BAR region through its own logic." > > > > > > > > > > > > > > > to the BAR region, it triggers an IRQ at the EP. This implementation serves > > > > > > > > as a common method for all endpoint function drivers. > > > > > > > > > > > > > > > > However, it currently supports only one EP physical function due to > > > > > > > > limitations in ARM MSI/IMS readiness. > > > > > > > > > > > > > > > > Signed-off-by: Frank Li > > > > > > > > --- > > > > > > > > drivers/pci/endpoint/pci-epc-core.c | 192 ++++++++++++++++++++++++++++ > > > > > > > > drivers/pci/endpoint/pci-epf-core.c | 44 +++++++ > > > > > > > > include/linux/pci-epc.h | 6 + > > > > > > > > include/linux/pci-epf.h | 7 + > > > > > > > > 4 files changed, 249 insertions(+) > > > > > > > > > > > > > > > > diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c > > > > > > > > index 5a4a8b0be6262..d336a99c6a94f 100644 > > > > > > > > --- a/drivers/pci/endpoint/pci-epc-core.c > > > > > > > > +++ b/drivers/pci/endpoint/pci-epc-core.c > > > > > > > > @@ -10,6 +10,7 @@ > > > > > > > > #include > > > > > > > > #include > > > > > > > > > > > > > > > > +#include > > > > > > > > #include > > > > > > > > #include > > > > > > > > #include > > > > > > > > @@ -783,6 +784,197 @@ void pci_epc_bme_notify(struct pci_epc *epc) > > > > > > > > } > > > > > > > > EXPORT_SYMBOL_GPL(pci_epc_bme_notify); > > > > > > > > > > > > > > > > +/** > > > > > > > > + * pci_epc_alloc_doorbell() - alloc an address space to let RC trigger EP side IRQ by write data to > > > > > > > > + * the space. > > > > > > > > > > > > > > "Allocate platform specific doorbell IRQs to be used by the host to trigger > > > > > > > doorbells on EP." > > > > > > > > > > > > > > > + * > > > > > > > > + * @epc: the EPC device that need doorbell address and data from RC. > > > > > > > > > > > > > > EPC device for which the doorbell needs to be allocated > > > > > > > > > > > > > > > + * @func_no: the physical endpoint function number in the EPC device. > > > > > > > > + * @vfunc_no: the virtual endpoint function number in the physical function. > > > > > > > > + * @num_msgs: the total number of doorbell messages > > > > > > > > > > > > > > s/num_msgs/num_db > > > > > > > > > > > > > > > + * > > > > > > > > + * Return: 0 success, other is failure > > > > > > > > + */ > > > > > > > > +int pci_epc_alloc_doorbell(struct pci_epc *epc, u8 func_no, u8 vfunc_no, int num_msgs) > > > > > > > > +{ > > > > > > > > + int ret; > > > > > > > > + > > > > > > > > + if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions) > > > > > > > > + return -EINVAL; > > > > > > > > + > > > > > > > > + if (vfunc_no > 0 && (!epc->max_vfs || vfunc_no > epc->max_vfs[func_no])) > > > > > > > > + return -EINVAL; > > > > > > > > + > > > > > > > > + if (!epc->ops->alloc_doorbell) > > > > > > > > + return 0; > > > > > > > > > > > > > > You mentioned 0 is a success. So if there is no callback, you want to return > > > > > > > success? > > > > > > > > > > > > > > > + > > > > > > > > + mutex_lock(&epc->lock); > > > > > > > > + ret = epc->ops->alloc_doorbell(epc, func_no, vfunc_no, num_msgs); > > > > > > > > > > > > > > Why can't you just call the generic function here and in other places instead of > > > > > > > implementing callbacks? I do not see a necessity for EPC specific callbacks. If > > > > > > > there is one, please specify. > > > > > > > > > > > > 1. Refer v1 your comments. > > > > > > https://lore.kernel.org/imx/20230906145227.GC5930@thinkpad/ > > > > > > > > > > I do not find where I suggested the callback approach. > > > > > > > > > > > If that, Each EPF driver need do duplicate work. > > > > > > > > > > > > > > > > > > > Yes, and that's how it should be. EPF core has no job in supplying the of_node. > > > > > > It is the responsibility of the EPF drivers as they depend on OF for platform > > > > > > support. > > > > > > > > > > EPF driver still not depend on OF. such pci-epf-test, which was probed by > > > > > configfs. > > > > > > > > > > > > > Hmm, yeah. Then it should be part of the EPC driver. > > > > > > > > Sorry for the confusion. > > > > > > > > Here, all "EPF" should be "EPC". The key problem is of_node. EPC core have > > > > not of_node, EPC core's parent driver (like dwc-ep driver) have of_node. > > > > > > > > pci_epc_generic_alloc_doorbell(dev), dev is probed by platform driver, such > > > > as dwc-ep, which have of_node, EPC core will create child device. > > > > > > > > dwc-ep device > > > > |- epc core device > > > > > > > > we can direct call pci_epc_generic_alloc_doorbell(epc->parent) here. > > > > > > > > I may miss understand what your means. I think you want to dwc-ep > > > > (with of_node) handle these alloc functions. > > > > > > > > > > My comment was to have just one function definition. But looking at it again, I > > > think it is better to move all the (alloc, free, write_msg) definitions to > > > dwc-ep, since the contents of those functions are not EPC core specific. > > > > There are still problem. (alloc, free, write_msg) is quite common for all > > controller and the system with MSI. > > > > If move these into dwc-ep, cdns or other controller have to duplicate > > these codes. > > > > If you think it is not EPC core specific, how about create new help files? > > > > Hmm, that sounds good to me. I think the best place would be: > drivers/pci/endpoint/pci-ep-msi.c How about header file? int pci_epc_generic_alloc_doorbell(struct pci_epc *epc, u8 func_no, u8 vfunc_no, int num_msgs); void pci_epc_generic_free_doorbell(struct pci_epc *epc, u8 func_no, u8 vfunc_no); Is it in include/linux/pci-epc.h, just 2 lines. Frank > > Reason is, we cannot have this generic code under drivers/pci/controller/ as it > is not a standalone PCI controller but a platform MSI controller. So having it > under pci/endpoint/ makes much sense to me. > > And this is not specific to EPF drivers as well, so we cannot have it under > pci/endpoint/functions/. > > - Mani > > > Frank > > > > > > > > In the EPC core, you can still have the callbacks specific to each EPC. This > > > also solves your of_node problem. > > > > > > - Mani > > > > > > > > > > > > > > 2. Maybe some ep controller have built-in doorbell support. Write to some > > > > > > address to trigger doorbell irq. > > > > > > > > > > > > > > > > We will handle it whenever such EP controllers arrive. Until then, let's keep it > > > > > simple. > > > > > > > > > > - Mani > > > > > > > > > > > Frank > > > > > > > > > > > > > > > > > > > > > + mutex_unlock(&epc->lock); > > > > > > > > + > > > > > > > > + return ret; > > > > > > > > +} > > > > > > > > +EXPORT_SYMBOL_GPL(pci_epc_alloc_doorbell); > > > > > > > > + > > > > > > > > +/** > > > > > > > > + * pci_epc_free_doorbell() - free resource allocated by pci_epc_alloc_doorbell() > > > > > > > > + * > > > > > > > > + * @epc: the EPC device that need doorbell address and data from RC. > > > > > > > > > > > > > > Same as above. > > > > > > > > > > > > > > > + * @func_no: the physical endpoint function number in the EPC device. > > > > > > > > + * @vfunc_no: the virtual endpoint function number in the physical function. > > > > > > > > + * > > > > > > > > + * Return: 0 success, other is failure > > > > > > > > + */ > > > > > > > > +void pci_epc_free_doorbell(struct pci_epc *epc, u8 func_no, u8 vfunc_no) > > > > > > > > +{ > > > > > > > > + if (IS_ERR_OR_NULL(epc) || func_no >= epc->max_functions) > > > > > > > > + return; > > > > > > > > + > > > > > > > > + if (vfunc_no > 0 && (!epc->max_vfs || vfunc_no > epc->max_vfs[func_no])) > > > > > > > > + return; > > > > > > > > + > > > > > > > > + if (!epc->ops->free_doorbell) > > > > > > > > + return; > > > > > > > > + > > > > > > > > + mutex_lock(&epc->lock); > > > > > > > > + epc->ops->free_doorbell(epc, func_no, vfunc_no); > > > > > > > > > > > > > > Same as suggested above. > > > > > > > > > > > > > > > + mutex_unlock(&epc->lock); > > > > > > > > +} > > > > > > > > +EXPORT_SYMBOL_GPL(pci_epc_free_doorbell); > > > > > > > > + > > > > > > > > +static irqreturn_t pci_epf_generic_doorbell_handler(int irq, void *data) > > > > > > > > +{ > > > > > > > > + struct pci_epf *epf = data; > > > > > > > > + > > > > > > > > + if (epf->event_ops && epf->event_ops->doorbell) > > > > > > > > + epf->event_ops->doorbell(epf, irq - epf->virq_base); > > > > > > > > > > > > > > Same as suggested above. > > > > > > > > > > > > > > > + > > > > > > > > + return IRQ_HANDLED; > > > > > > > > +} > > > > > > > > + > > > > > > > > +static void pci_epc_generic_write_msi_msg(struct msi_desc *desc, struct msi_msg *msg) > > > > > > > > +{ > > > > > > > > + struct pci_epc *epc = NULL; > > > > > > > > + struct class_dev_iter iter; > > > > > > > > + struct pci_epf *epf; > > > > > > > > + struct device *dev; > > > > > > > > + > > > > > > > > + class_dev_iter_init(&iter, pci_epc_class, NULL, NULL); > > > > > > > > + while ((dev = class_dev_iter_next(&iter))) { > > > > > > > > + if (dev->parent != desc->dev) > > > > > > > > + continue; > > > > > > > > + > > > > > > > > + epc = to_pci_epc(dev); > > > > > > > > + > > > > > > > > + class_dev_iter_exit(&iter); > > > > > > > > + break; > > > > > > > > + } > > > > > > > > + > > > > > > > > + if (!epc) > > > > > > > > + return; > > > > > > > > + > > > > > > > > + /* Only support one EPF for doorbell */ > > > > > > > > + epf = list_first_entry_or_null(&epc->pci_epf, struct pci_epf, list); > > > > > > > > + > > > > > > > > > > > > > > No need of this newline > > > > > > > > > > > > > > > + if (!epf) > > > > > > > > + return; > > > > > > > > + > > > > > > > > + if (epf->msg && desc->msi_index < epf->num_msgs) > > > > > > > > + epf->msg[desc->msi_index] = *msg; > > > > > > > > +} > > > > > > > > + > > > > > > > > + > > > > > > > > > > > > > > Remove extra newline > > > > > > > > > > > > > > > +/** > > > > > > > > + * pci_epc_generic_alloc_doorbell() - Common help function. Allocate address space from MSI > > > > > > > > + * controller > > > > > > > > + * > > > > > > > > + * @epc: the EPC device that need doorbell address and data from RC. > > > > > > > > + * @func_no: the physical endpoint function number in the EPC device. > > > > > > > > + * @vfunc_no: the virtual endpoint function number in the physical function. > > > > > > > > + * @num_msgs: the total number of doorbell messages > > > > > > > > + * > > > > > > > > > > > > > > Same comment as for pci_epc_alloc_doorbell() > > > > > > > > > > > > > > > + * Remark: use this function only if EPC driver just register one EPC device. > > > > > > > > + * > > > > > > > > + * Return: 0 success, other is failure > > > > > > > > + */ > > > > > > > > +int pci_epc_generic_alloc_doorbell(struct pci_epc *epc, u8 func_no, u8 vfunc_no, int num_msgs) > > > > > > > > +{ > > > > > > > > + struct pci_epf *epf; > > > > > > > > + struct device *dev; > > > > > > > > + int virq, last; > > > > > > > > + int ret; > > > > > > > > + int i; > > > > > > > > + > > > > > > > > + if (IS_ERR_OR_NULL(epc)) > > > > > > > > + return -EINVAL; > > > > > > > > + > > > > > > > > + /* Currently only support one func and one vfunc for doorbell */ > > > > > > > > + if (func_no || vfunc_no) > > > > > > > > + return -EINVAL; > > > > > > > > + > > > > > > > > + epf = list_first_entry_or_null(&epc->pci_epf, struct pci_epf, list); > > > > > > > > + if (!epf) > > > > > > > > + return -EINVAL; > > > > > > > > + > > > > > > > > + dev = epc->dev.parent; > > > > > > > > + ret = platform_msi_domain_alloc_irqs(dev, num_msgs, pci_epc_generic_write_msi_msg); > > > > > > > > + if (ret) { > > > > > > > > + dev_err(dev, "Failed to allocate MSI\n"); > > > > > > > > + return -ENOMEM; > > > > > > > > + } > > > > > > > > + > > > > > > > > + last = -1; > > > > > > > > + for (i = 0; i < num_msgs; i++) { > > > > > > > > > > > > > > You should iterate over msi_desc as below: > > > > > > > > > > > > > > msi_lock_descs(dev); > > > > > > > msi_for_each_desc(desc, dev, MSI_DESC_ALL) { > > > > > > > ... > > > > > > > } > > > > > > > msi_unlock_descs(dev); > > > > > > > > > > > > > > > + virq = msi_get_virq(dev, i); > > > > > > > > + if (i == 0) > > > > > > > > + epf->virq_base = virq; > > > > > > > > + > > > > > > > > + ret = request_irq(virq, pci_epf_generic_doorbell_handler, 0, > > > > > > > > > > > > > > request_irq(desc->irq, ...) > > > > > > > > > > > > > > > + kasprintf(GFP_KERNEL, "pci-epc-doorbell%d", i), epf); > > > > > > > > + > > > > > > > > + if (ret) { > > > > > > > > + dev_err(dev, "Failed to request doorbell\n"); > > > > > > > > + goto err_free_irq; > > > > > > > > + } > > > > > > > > + last = i; > > > > > > > > + } > > > > > > > > + > > > > > > > > + return 0; > > > > > > > > + > > > > > > > > +err_free_irq: > > > > > > > > + for (i = 0; i < last; i++) > > > > > > > > + kfree(free_irq(epf->virq_base + i, epf)); > > > > > > > > + platform_msi_domain_free_irqs(dev); > > > > > > > > + > > > > > > > > + return -EINVAL; > > > > > > > > > > > > > > return ret; > > > > > > > > > > > > > > > +} > > > > > > > > +EXPORT_SYMBOL_GPL(pci_epc_generic_alloc_doorbell); > > > > > > > > + > > > > > > > > > > > > > > [...] > > > > > > > > > > > > > > > diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h > > > > > > > > index 3f44b6aec4770..485c146a5efe2 100644 > > > > > > > > --- a/include/linux/pci-epf.h > > > > > > > > +++ b/include/linux/pci-epf.h > > > > > > > > @@ -79,6 +79,7 @@ struct pci_epc_event_ops { > > > > > > > > int (*link_up)(struct pci_epf *epf); > > > > > > > > int (*link_down)(struct pci_epf *epf); > > > > > > > > int (*bme)(struct pci_epf *epf); > > > > > > > > + int (*doorbell)(struct pci_epf *epf, int index); > > > > > > > > > > > > > > kdoc missing. > > > > > > > > > > > > > > > }; > > > > > > > > > > > > > > > > /** > > > > > > > > @@ -180,6 +181,9 @@ struct pci_epf { > > > > > > > > unsigned long vfunction_num_map; > > > > > > > > struct list_head pci_vepf; > > > > > > > > const struct pci_epc_event_ops *event_ops; > > > > > > > > + struct msi_msg *msg; > > > > > > > > + u16 num_msgs; > > > > > > > > > > > > > > num_db > > > > > > > > > > > > > > You also need to add kdoc for each new member. > > > > > > > > > > > > > > - Mani > > > > > > > > > > > > > > -- > > > > > > > மணிவண்ணன் சதாசிவம் > > > > > > > > > > -- > > > > > மணிவண்ணன் சதாசிவம் > > > > > > -- > > > மணிவண்ணன் சதாசிவம் > > -- > மணிவண்ணன் சதாசிவம்