From patchwork Tue Mar 7 15:14:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 65625 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2491429wrd; Tue, 7 Mar 2023 07:23:26 -0800 (PST) X-Google-Smtp-Source: AK7set+GxargrBA1nJj1tSZtW3BnqDzQBDjl1co1b6nuuDjkneaMfaMQr2W8Ts8uAvceYYm6fdlr X-Received: by 2002:a17:906:e98:b0:901:33f9:a3cc with SMTP id p24-20020a1709060e9800b0090133f9a3ccmr14812153ejf.68.1678202606207; Tue, 07 Mar 2023 07:23:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678202606; cv=none; d=google.com; s=arc-20160816; b=R61Qr+YmnR8zbmqnEsBHmzDrvVPfRen54RDqoSBUfvzNO7RV9U4yUzPdFqRn/DmhKg VM3m/ZRheJo3Y3EVpziDOR+0NPWQY32Dv5YYAqKFj35fzG9OhCbG73OR0pJskyHLKHxZ u0u6arO+XqLyF3OjJAIw1iVFtH21LpYZGXOJi5czGla6znpNMdxG4a5cyQen34eHXrPK xe89l3R3NtOKapcZJGXX8eCCwWE3T+1TWP+PrrM+xsX/jrb2ljZFJ4vMDCOd58+FdSYe w2xBa5QlPjliIxOFmJMG8BGpFoSDmF2ErGeFi/PpMmf8esTt2GUM10WIn9qN4r9dcH/u tREA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=w/dZg64ztv0KUh6No53X6WHHUMATIjQWN6mhKUx2HRs=; b=Md0T41/+tY6gnAtxuBDxUcFZ8EzzFm5wewkKihEoKJGS+x528Mq75ZWaqxYQ2xTDU3 CrZFCGOQzj2KzzoOvOQ3WEaE2/gHh6lihZQWYHgQ/q17QsfNtSeGAZRWpxKm6zROFPlD o8m8IGEyS349TMuNVAt/+w5VVucgV9Wjx4u+mwAODkUQ+ndTQH+wqBk1ZD0kjmgvI5Wj IsBNBzxFWS5O8Q14yIkNsD1GbRSf4e4e7XuCRX5nu9h+48e+HWyZIQn6kCpUx1zpniyE 7tyqb4M/6qn16vwYWJeQ+dr90cwv4533OKi1GM8fmmyA1+tT9uDHR3d0AhPQIeWl+ZMW 7ruQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E2Y5I4zt; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb30-20020a170907161e00b008b85ed1bbc7si4617995ejc.366.2023.03.07.07.23.02; Tue, 07 Mar 2023 07:23:26 -0800 (PST) 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=@linaro.org header.s=google header.b=E2Y5I4zt; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231164AbjCGPRw (ORCPT + 99 others); Tue, 7 Mar 2023 10:17:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230446AbjCGPR2 (ORCPT ); Tue, 7 Mar 2023 10:17:28 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11BCD2ED53 for ; Tue, 7 Mar 2023 07:14:29 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id n6so14417557plf.5 for ; Tue, 07 Mar 2023 07:14:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678202068; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=w/dZg64ztv0KUh6No53X6WHHUMATIjQWN6mhKUx2HRs=; b=E2Y5I4zto5l5GEcCAxR00164MlKy5MTk6nbmkWw7Hc+1HAIiSRWGo//KKWSs1LCZ9W litr3y1JEEG8uC3d54SQUZ++FDzEPwxxVHf48wyBJaqwwwz8E/j/153OFpqT5WPfm/pR T45K3tqvr8NirR75ZAc3nun9MQEtGM7aoPHS2BYBYJ0k0app2h09oKvnse+BDpynhzat AFYYocF9f8/CnSfA+7iZ7fejBjTlSFgKRJGNE6oOt7blg1LluLHcjt6YTsZl2m3xuHA2 iBy2JI/8gVIwfDNANzR3tC+5azpNPH6AfL1mfjm8gt23VGoXafoIQYDWn+18TxaDfitX H4Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678202068; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w/dZg64ztv0KUh6No53X6WHHUMATIjQWN6mhKUx2HRs=; b=FSLekhaiEWg9QfpVNBcBBzHlSoE28E/fvysHuVUTEM6SLUKMtqXo4P3kSDkYHjhSzS QBAKCu36832Jp3Us59fpaCCLEspizdKTBrXNlsJhKSnygSrX9gPPl2Nz1Gemh4tQRUsb bXjXPtRywy6ok+bQSEIQMJgcIfOf+jY1MtAowSjsDq19Tx7rgaIQLh5oph2K2uERAEY1 worrBG5Y3WMQ73u3GsCGVttP1uaaR/U8DrFR0KPnuSfvkhKUFu21KhRNOPqiwqJGgkZV 7J2Tig2uHrcV+lyNIDaKO9+XJ8te0f2lap8hK0YBnP496AXArtqYawhI6P6TQmKUcwSJ 9g7w== X-Gm-Message-State: AO0yUKV8QjubYvM35MELPR+ueWniQWKJmdLrQC4L3aO3Bvr0fA424+GT BiaXH0eHP0Hyy+HUh/N/uxbBwHLfl0YVkgWUBA== X-Received: by 2002:a17:902:6a8a:b0:19e:6185:10d6 with SMTP id n10-20020a1709026a8a00b0019e618510d6mr13900523plk.40.1678202068516; Tue, 07 Mar 2023 07:14:28 -0800 (PST) Received: from localhost.localdomain ([59.97.52.140]) by smtp.gmail.com with ESMTPSA id t8-20020a17090340c800b0019c2cf12d15sm8549332pld.116.2023.03.07.07.14.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 07:14:28 -0800 (PST) From: Manivannan Sadhasivam To: lpieralisi@kernel.org, kw@linux.com Cc: kishon@kernel.org, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v2 1/7] PCI: endpoint: Pass EPF device ID to the probe function Date: Tue, 7 Mar 2023 20:44:10 +0530 Message-Id: <20230307151416.176595-2-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230307151416.176595-1-manivannan.sadhasivam@linaro.org> References: <20230307151416.176595-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 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, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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?1759722975947018363?= X-GMAIL-MSGID: =?utf-8?q?1759722975947018363?= Currently, the EPF probe function doesn't get the device ID argument needed to correctly identify the device table ID of the EPF device. When multiple entries are added to the "struct pci_epf_device_id" table, the probe function needs to identify the correct one. And the only way to do so is by storing the correct device ID in "struct pci_epf" during "pci_epf_match_id()" and passing that to probe(). Signed-off-by: Manivannan Sadhasivam --- drivers/pci/endpoint/functions/pci-epf-ntb.c | 3 ++- drivers/pci/endpoint/functions/pci-epf-test.c | 2 +- drivers/pci/endpoint/pci-epf-core.c | 8 +++++--- include/linux/pci-epf.h | 4 +++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-ntb.c b/drivers/pci/endpoint/functions/pci-epf-ntb.c index 9a00448c7e61..980b4ecf19a2 100644 --- a/drivers/pci/endpoint/functions/pci-epf-ntb.c +++ b/drivers/pci/endpoint/functions/pci-epf-ntb.c @@ -2075,11 +2075,12 @@ static struct config_group *epf_ntb_add_cfs(struct pci_epf *epf, /** * epf_ntb_probe() - Probe NTB function driver * @epf: NTB endpoint function device + * @id: NTB endpoint function device ID * * Probe NTB function driver when endpoint function bus detects a NTB * endpoint function. */ -static int epf_ntb_probe(struct pci_epf *epf) +static int epf_ntb_probe(struct pci_epf *epf, const struct pci_epf_device_id *id) { struct epf_ntb *ntb; struct device *dev; diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index 0f9d2ec822ac..d5fcc78a5b73 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -980,7 +980,7 @@ static const struct pci_epf_device_id pci_epf_test_ids[] = { {}, }; -static int pci_epf_test_probe(struct pci_epf *epf) +static int pci_epf_test_probe(struct pci_epf *epf, const struct pci_epf_device_id *id) { struct pci_epf_test *epf_test; struct device *dev = &epf->dev; diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c index 2036e38be093..924564288c9a 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -494,11 +494,13 @@ static const struct device_type pci_epf_type = { }; static int -pci_epf_match_id(const struct pci_epf_device_id *id, const struct pci_epf *epf) +pci_epf_match_id(const struct pci_epf_device_id *id, struct pci_epf *epf) { while (id->name[0]) { - if (strcmp(epf->name, id->name) == 0) + if (strcmp(epf->name, id->name) == 0) { + epf->id = id; return true; + } id++; } @@ -526,7 +528,7 @@ static int pci_epf_device_probe(struct device *dev) epf->driver = driver; - return driver->probe(epf); + return driver->probe(epf, epf->id); } static void pci_epf_device_remove(struct device *dev) diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h index a215dc8ce693..bc613f0df7e3 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -89,7 +89,7 @@ struct pci_epc_event_ops { * @id_table: identifies EPF devices for probing */ struct pci_epf_driver { - int (*probe)(struct pci_epf *epf); + int (*probe)(struct pci_epf *epf, const struct pci_epf_device_id *id); void (*remove)(struct pci_epf *epf); struct device_driver driver; @@ -131,6 +131,7 @@ struct pci_epf_bar { * @epc: the EPC device to which this EPF device is bound * @epf_pf: the physical EPF device to which this virtual EPF device is bound * @driver: the EPF driver to which this EPF device is bound + * @id: Pointer to the EPF device ID * @list: to add pci_epf as a list of PCI endpoint functions to pci_epc * @lock: mutex to protect pci_epf_ops * @sec_epc: the secondary EPC device to which this EPF device is bound @@ -158,6 +159,7 @@ struct pci_epf { struct pci_epc *epc; struct pci_epf *epf_pf; struct pci_epf_driver *driver; + const struct pci_epf_device_id *id; struct list_head list; /* mutex to protect against concurrent access of pci_epf_ops */ struct mutex lock;