Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp932155rwd; Thu, 1 Jun 2023 08:19:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4iZnfmhshp9c769bVw0JOV+1y101fbvFBIajc6LTRc46foNHsnSGtgVWPhcdYWNktk0eAL X-Received: by 2002:a05:6a20:a10d:b0:110:f65a:13fb with SMTP id q13-20020a056a20a10d00b00110f65a13fbmr8768051pzk.15.1685632765957; Thu, 01 Jun 2023 08:19:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685632765; cv=none; d=google.com; s=arc-20160816; b=X3UortyKdXWXXJ0jaIY05hu/QN8zhp91gWRhbwORxwLMF+Y4S4M+6+vkYNX+Wpjc6c Kglei9mxz0JunXVsqp2PlqdNSA7RSinzuVfT7Vwv9pAfdO34e1oZAqtvqRL00YGhpauM ICJ3Gwcer07veW6hIz0rRVK2a3A3EqNrp0LB3zEDDjdtEtt5Vs1MrsZlnpyOeQmskQgy yNwDyNw0Eql0Ycf5L/umH2HJwCfJuzR1TFi/JlsrGizlSTBCq1QaGH8hrluhWJS9Bao0 6MrfkU8FnWNNS9/WxIE7DMPjOHoIF/9NP2WkuP5LFvh8z3Wwdda7Tt0LYkSQxf4VeULC fOkA== 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=cwXI2MDftw2Rb8IrxQ8Wa3XnLpiqiT4qkX9vMeeuaOg=; b=GHrJyYzYWL+kDqsfA4uQTELv14wu+QT2FOlntFX6S8DZ3EDPBFF9osRNh5g24tntBY pjkwLJxfl7c3O08m2Z4EjWTZtwVrbuNO1U9ZyI9aRqAlMVXjACK8NMRFfAiE6PzlYldH AiCUqnzqtXCHVu1qZMO8U84IoLE1cwy8E/Ndjy14G96U6Q7iaumKHtLZUweNkigeiZSe BOxKSz4NwIr9Zx5wn59l6qLEbdTTaiOpylmSUUdLI3FAbmhIvFbx3MxrkZiVA9/eg5MF 7Pzy1sbuZ6Ezlkz+7w7/s2qX1yWAWRqBMHiHru1g1blDnZXWlVeO6dSTbU4TDLHAOjNZ wqiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qCxSGlDh; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e9-20020a636909000000b0053ef518d804si2879886pgc.855.2023.06.01.08.19.11; Thu, 01 Jun 2023 08:19:25 -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=qCxSGlDh; 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 S232246AbjFAO5x (ORCPT + 99 others); Thu, 1 Jun 2023 10:57:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234597AbjFAO5t (ORCPT ); Thu, 1 Jun 2023 10:57:49 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D945123 for ; Thu, 1 Jun 2023 07:57:47 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-53482b44007so485178a12.2 for ; Thu, 01 Jun 2023 07:57:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685631466; x=1688223466; 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=cwXI2MDftw2Rb8IrxQ8Wa3XnLpiqiT4qkX9vMeeuaOg=; b=qCxSGlDhKuHPMocONEKYKTJVyvkw81O0E8n/J4bcpGCfvmcgsCGJ6K7dgziu6h/VRR kyaY/LxcFPfl8iJJ/kxBnHho5Ute1QpVMqpRXbvoqgWs+uShqv4UYIpunxQVORQ5sazl B+08nHBM6vSQH36UaUuScoPnWNhZHBHY0+1A5GtRwSkBEzJCw3O9eX08LG/86DwzVXrQ Cm9tl0gZYu7ek9j9TS/EdHLMNiwFJqb7NutuJl0om4Pfw56d9Whruvbf5CLwdFv/IVJ4 6wAGGt9a6nfOtUPmXZWk/FZtoYhTeLtsYBx/qJGl475eWpm5N4a3AUeHmwKHZ4vWtvHb XxHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685631466; x=1688223466; 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=cwXI2MDftw2Rb8IrxQ8Wa3XnLpiqiT4qkX9vMeeuaOg=; b=cezb0f6HQuKTXajNYnxL2NxZZw/DVhIfzMOaBRlaFDOAlMoSHYIZQ//o+A+JNdWvlT 1NIfsO5QV2zA60UXni5gjm9wPL4AqqN09z+Up0A2tsRyhf5yAXvWxuTNZWBLI2/jNQza i6XA7uRuLwkYt6yBzKfi0NpeXXCL5drGP85hSIhgvYv2tUE/62SOQG8I52gFcKQYfZ1u V+V17JR0n4j1Qnu0YGq8e5YzdPnLRN0GUWB3YEVyhPvvrfdO2He7lcJn4/CPyj/maNwD HZw8uloP53fjznk9OR9BB8JM3ICzdJKkqNKlPukkcqrCd4NojuJUdgK7SmvD1DfO4Gw5 ihjg== X-Gm-Message-State: AC+VfDzOzhHILLRlyKmT7rRS9RjXb1BvdW6ZtMO/GE2FUkK7luLuaaPA NSNQrTgWFb0TO/Hxv4F9ft6j X-Received: by 2002:a17:902:a417:b0:1b0:6c3:e851 with SMTP id p23-20020a170902a41700b001b006c3e851mr5755992plq.18.1685631466681; Thu, 01 Jun 2023 07:57:46 -0700 (PDT) Received: from localhost.localdomain ([117.217.186.123]) by smtp.gmail.com with ESMTPSA id o17-20020a170902d4d100b001b0603829a0sm3577826plg.199.2023.06.01.07.57.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 07:57:46 -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 v5 3/9] PCI: endpoint: Pass EPF device ID to the probe function Date: Thu, 1 Jun 2023 20:27:12 +0530 Message-Id: <20230601145718.12204-4-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230601145718.12204-1-manivannan.sadhasivam@linaro.org> References: <20230601145718.12204-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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,T_SCC_BODY_TEXT_LINE 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 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. This is achieved by modifying the pci_epf_match_id() function to return the match ID pointer and passing it to the driver's probe function. pci_epf_device_match() function can return bool based on the return value of pci_epf_match_id(). Reviewed-by: Kishon Vijay Abraham I 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 | 20 ++++++++++++------- include/linux/pci-epf.h | 4 +++- 5 files changed, 20 insertions(+), 11 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..7307e052136f 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -493,16 +493,16 @@ static const struct device_type pci_epf_type = { .release = pci_epf_dev_release, }; -static int -pci_epf_match_id(const struct pci_epf_device_id *id, const struct pci_epf *epf) +static const struct pci_epf_device_id +*pci_epf_match_id(const struct pci_epf_device_id *id, const struct pci_epf *epf) { while (id->name[0]) { if (strcmp(epf->name, id->name) == 0) - return true; + return id; id++; } - return false; + return NULL; } static int pci_epf_device_match(struct device *dev, struct device_driver *drv) @@ -510,8 +510,12 @@ static int pci_epf_device_match(struct device *dev, struct device_driver *drv) struct pci_epf *epf = to_pci_epf(dev); struct pci_epf_driver *driver = to_pci_epf_driver(drv); - if (driver->id_table) - return pci_epf_match_id(driver->id_table, epf); + if (driver->id_table) { + if (pci_epf_match_id(driver->id_table, epf)) + return true; + else + return false; + } return !strcmp(epf->name, drv->name); } @@ -520,13 +524,15 @@ static int pci_epf_device_probe(struct device *dev) { struct pci_epf *epf = to_pci_epf(dev); struct pci_epf_driver *driver = to_pci_epf_driver(dev->driver); + const struct pci_epf_device_id *id; if (!driver->probe) return -ENODEV; epf->driver = driver; + id = pci_epf_match_id(driver->id_table, epf); - return driver->probe(epf); + return driver->probe(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; -- 2.25.1