From patchwork Tue Mar 14 04:46:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 69287 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1568297wrd; Mon, 13 Mar 2023 22:03:12 -0700 (PDT) X-Google-Smtp-Source: AK7set9RqUEbYDIJ4S6AeUp8YV/Wwh24nUvfZgk6LBoVJ1WipymCVKoOBx0t8JmryOOEz5hR9kIn X-Received: by 2002:a05:6122:1687:b0:405:a08a:fa4f with SMTP id 7-20020a056122168700b00405a08afa4fmr24673396vkl.8.1678770192274; Mon, 13 Mar 2023 22:03:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678770192; cv=none; d=google.com; s=arc-20160816; b=ync+MqCLw2GAQRK4eDA6LpOlnuzfEQSMa/y61Zra1opmNtVYONo7okw34puopvsp75 /MctiHdF3XBJSoVu3uSCfyoFsa+IwijqciAWZY+TYzOqVaXUSbVWYpWV19pKsac4midU FgbIse6OlNs0AQqX0kKz8qWyOR2QKSelWzyZLIZ0jCooTdXkTI6lxXZIi3DUn1diuph5 AAnz9l9D5V6CPHJvNFBdPsCThZTDWqh8vFTbKShHsw2/0LssfSUfilsvMHOCAG7TbICT /IA/hK7fsuy2Va9+CrMsVtwmT2QiuHd18Urs0TJh2a9JMuiNUVSjOeGsR4AvCD/wXP4Q EFaw== 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=YmBMpLwO4qRSgpNN2zu2wmSlV0dO5yPKMRqsInWvopM=; b=wT/xXnIvrrH8JGoLqh/zul0MyvuRaqqj0/E9aIPN4o0DEXHPsnoG88NnnxcKRS8GEw mBjDyqLNenskLM4poMIpzSH6pQLk9XyKbpi58MNn/7bR2E+mUQgZKHqjX4zIeKUmD5gg l0MmZzLBiFwBP1dK9zTH3zZqqvmAzCNEEB28NDXLDnkvophlXn4FtFY8S4p/SXlwB0E7 S4/EPZqpRTZox2ZLvav3mWNZGjHNOX8ugeA61hjsHp3dyBIeu/yoDpF4oBBSADr7tniJ cGxaMJUhmyTbAuNibQk0Zkig2QjhbOE44mMMvWYFsiCd5chHVd6XrFNtUrqrzqGKDewl BkrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cpsSqBec; 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 189-20020a1f00c6000000b0042d4d95d5absi900788vka.111.2023.03.13.22.02.57; Mon, 13 Mar 2023 22:03:12 -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=@linaro.org header.s=google header.b=cpsSqBec; 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 S229441AbjCNEqn (ORCPT + 99 others); Tue, 14 Mar 2023 00:46:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbjCNEqj (ORCPT ); Tue, 14 Mar 2023 00:46:39 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CC93A5CD for ; Mon, 13 Mar 2023 21:46:37 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id h11-20020a17090a2ecb00b00237c740335cso13911075pjs.3 for ; Mon, 13 Mar 2023 21:46:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678769197; 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=YmBMpLwO4qRSgpNN2zu2wmSlV0dO5yPKMRqsInWvopM=; b=cpsSqBecUtfR1YL08VzHXQKb+5jn+ts3gGNqf9sEp9Rf5VGxRyOXC4Ol/rGAWvxEp7 /zoNai5d3a+ptbhU5WJaTefpNmC+dOd1hF4WinSIoYbHUcU8AuSlflHuZbgkP4IbdM7m hV1Lo0CYP5maFSPBjqpIJmhUuTuz7Lj77/beCz1Ayn5sIuKhIV706ouoDUgmRUL1UXJD APLp0ZYjmD0vj3BxneLS7t1xISFq2dikx3/VSZLJaTyGtNSp2M23YBDIfMpokj4lc3RS Qoi9yvC782Y/rTo0k0RSJzml+kMvcnum3NoJmYZfr3FQ6W/fSFc0lGeF1OjOafkN4GkP lrKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678769197; 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=YmBMpLwO4qRSgpNN2zu2wmSlV0dO5yPKMRqsInWvopM=; b=bajOaub2lShyEfsa/5uzoaO30lu2lrNtY/qiIOgt3TN5nVZHI2W10GmMm2p8aXis2B kMawZfj2K02LhYVj+RAQfBeT+4rCwUuKmqfX++dVUso8nysWMKslJ7nbutT0PIuVX5Jl rg1oTt+a5Oz00jtwEMh9KSwyniAfgIjhdj2pppKTMHj6wcMHToArOae247XSz3AcnIQ4 vOgo4O7M0SwEKOv1t11caTC+osVuLYYFmpIDSc/Zg/p7n576wHXZJwY07gzAqsvDW3dh WYMPZFYjuOWRhEajORnhu+yOahmGLbin6LE6thCIzbwZ2QZ1zfFimuGBhtyN5RPKIdZq aMMg== X-Gm-Message-State: AO0yUKVkjhnGVJ/4fDSaT4rONgF2hUf7Q4wbYIRqpd5oE/Q2S05njP02 90f1xszOyH0zuOL6IqOsMRDR X-Received: by 2002:a17:902:c404:b0:19f:e9e7:4cb with SMTP id k4-20020a170902c40400b0019fe9e704cbmr8615091plk.45.1678769196675; Mon, 13 Mar 2023 21:46:36 -0700 (PDT) Received: from localhost.localdomain ([117.217.177.49]) by smtp.gmail.com with ESMTPSA id lh13-20020a170903290d00b0019c2b1c4ad4sm690125plb.6.2023.03.13.21.46.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Mar 2023 21:46:36 -0700 (PDT) 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 v3 1/7] PCI: endpoint: Pass EPF device ID to the probe function Date: Tue, 14 Mar 2023 10:16:17 +0530 Message-Id: <20230314044623.10254-2-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230314044623.10254-1-manivannan.sadhasivam@linaro.org> References: <20230314044623.10254-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=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?1760318133248965606?= X-GMAIL-MSGID: =?utf-8?q?1760318133248965606?= 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/functions/pci-epf-vntb.c | 2 +- drivers/pci/endpoint/pci-epf-core.c | 8 +++++--- include/linux/pci-epf.h | 4 +++- 5 files changed, 12 insertions(+), 7 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/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c index b7c7a8af99f4..122eb7a12028 100644 --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c @@ -1401,7 +1401,7 @@ static struct pci_epf_ops epf_ntb_ops = { * * Returns: Zero for success, or an error code in case of failure */ -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/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;