Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1603751ybc; Wed, 13 Nov 2019 01:12:01 -0800 (PST) X-Google-Smtp-Source: APXvYqzinjWRKpcdiCOSbYFBhMdkD+/0CxOpXpm1UnMuPwZqB4ueO5s0lxvGdFFggo57j7C8SkVE X-Received: by 2002:a17:906:1cd8:: with SMTP id i24mr1667498ejh.149.1573636321555; Wed, 13 Nov 2019 01:12:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573636321; cv=none; d=google.com; s=arc-20160816; b=j9vaxIiRyv3r9A/DC78XBPv7zklfI9Spyfw9Vf8VSOSt7W4dw8gpTzI1mGFgubhI02 h3sVTxa/d3JSX5d2iUxf5osNvYpjMDIMoklKYLdqMQS2w0R+beRtnexY0i8ayzUrkC9V y/AhkOs1Uw2QKSBCysC3UN1xM6s/413oEldsAyUGLln/Eu+tZySMiVgbBbbUXu7Yz/3i EKGvbDRuTiXEpo9knSOt3rhqrHeS1KgTIQQOiKeRaz+XUFgUDD5Wj1PecxNzTdzFaHNX kPd4iSMX3F/oHJoqj6TpV9A1ey0YS1w3lNpSo4LBH1DQloz8YEwU6SytbRhmChOuGQBz TCSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=PSPmVrDzo534RrRdZAwtuFYisc9SkubauqDX1jqAkTo=; b=J3IbwIG+j6SdJoAnPnSOsiDLWtSQJGZ34me0zVQqZ8hzwdhdI38bkxpqlpHiQ9id50 8jzVx3XnD7aYpfoYIy2f6tL1aQOPNb6PTGoBgb2Kbef658WgIqBhga+Bma/XTuU7Doxe +E+EAqi1jgX69qHjkdk9Jf+pxPi2BjoARgBa4i1zgeUz5WwkNn7PRrZvUz0SSc/vrfB6 qYxox9Z6bDm33mVVl/ZykyLh0mz+a7gN+3G0cPqmsDJaQ54IIwcoEB/sz8XGYHxWu4X3 Vry8Lr+JJIRD2YiRxtRkHCiAvN71/7m5Qg95mZn9fXdDV3QJsIInQoAUFbppm5lRPFmZ +ssA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=IilP7tjY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r18si706095eja.211.2019.11.13.01.11.36; Wed, 13 Nov 2019 01:12:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=IilP7tjY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727402AbfKMJJX (ORCPT + 99 others); Wed, 13 Nov 2019 04:09:23 -0500 Received: from hqemgate14.nvidia.com ([216.228.121.143]:14445 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727386AbfKMJJW (ORCPT ); Wed, 13 Nov 2019 04:09:22 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 13 Nov 2019 01:09:24 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 13 Nov 2019 01:09:21 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 13 Nov 2019 01:09:21 -0800 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 13 Nov 2019 09:09:20 +0000 Received: from hqnvemgw03.nvidia.com (10.124.88.68) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Wed, 13 Nov 2019 09:09:21 +0000 Received: from vidyas-desktop.nvidia.com (Not Verified[10.24.37.38]) by hqnvemgw03.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Wed, 13 Nov 2019 01:09:20 -0800 From: Vidya Sagar To: , , , , , , CC: , , , , , , , Subject: [PATCH 4/4] PCI: pci-epf-test: Add support to defer core initialization Date: Wed, 13 Nov 2019 14:38:51 +0530 Message-ID: <20191113090851.26345-5-vidyas@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191113090851.26345-1-vidyas@nvidia.com> References: <20191113090851.26345-1-vidyas@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1573636164; bh=PSPmVrDzo534RrRdZAwtuFYisc9SkubauqDX1jqAkTo=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=IilP7tjYxaAC3IAGSi55w6t3nfGSZ6YQZSW8vLSXh3Z+8n/bcr71jBv3N7nl42XOp sjeKzUGcC18/rNTvBt2log8FpY1Lpnj9IXxaZP9w8jY+Gj9sZdnzm7k8vM8VqqJRQo WiPpG2rG5PPTnX2kkjgRFmEJwnuUL59a0tH1Ihc73duMVX1pamVEYJxZjrJAGDIk9x m8Vqw0yuioPTqmyyRJbvHum/MMN2TjuqRlmAtQNKotbuhhJyJWDLSQx4MCpXVBoZdh uQ7mJ2zxqMyqxeaUWF1YSi9e6NK/oYleyIGAGd1cHV85wvvxvr6Ugwhi/L/KRu1Mpk ta+OskhxJYU+Q== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support to defer core initialization and to receive a notifier when core is ready to accommodate platforms where core is not for initialization untile reference clock from host is available. Signed-off-by: Vidya Sagar --- drivers/pci/endpoint/functions/pci-epf-test.c | 114 ++++++++++++------ 1 file changed, 77 insertions(+), 37 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index bddff15052cc..068024fab544 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -360,18 +360,6 @@ static void pci_epf_test_cmd_handler(struct work_struct *work) msecs_to_jiffies(1)); } -static int pci_epf_test_notifier(struct notifier_block *nb, unsigned long val, - void *data) -{ - struct pci_epf *epf = container_of(nb, struct pci_epf, nb); - struct pci_epf_test *epf_test = epf_get_drvdata(epf); - - queue_delayed_work(kpcitest_workqueue, &epf_test->cmd_handler, - msecs_to_jiffies(1)); - - return NOTIFY_OK; -} - static void pci_epf_test_unbind(struct pci_epf *epf) { struct pci_epf_test *epf_test = epf_get_drvdata(epf); @@ -428,6 +416,78 @@ static int pci_epf_test_set_bar(struct pci_epf *epf) return 0; } +static int pci_epf_test_core_init(struct pci_epf *epf) +{ + struct pci_epf_header *header = epf->header; + const struct pci_epc_features *epc_features; + struct pci_epc *epc = epf->epc; + struct device *dev = &epf->dev; + bool msix_capable = false; + bool msi_capable = true; + int ret; + + epc_features = pci_epc_get_features(epc, epf->func_no); + if (epc_features) { + msix_capable = epc_features->msix_capable; + msi_capable = epc_features->msi_capable; + } + + ret = pci_epc_write_header(epc, epf->func_no, header); + if (ret) { + dev_err(dev, "Configuration header write failed\n"); + return ret; + } + + ret = pci_epf_test_set_bar(epf); + if (ret) + return ret; + + if (msi_capable) { + ret = pci_epc_set_msi(epc, epf->func_no, epf->msi_interrupts); + if (ret) { + dev_err(dev, "MSI configuration failed\n"); + return ret; + } + } + + if (msix_capable) { + ret = pci_epc_set_msix(epc, epf->func_no, epf->msix_interrupts); + if (ret) { + dev_err(dev, "MSI-X configuration failed\n"); + return ret; + } + } + + return 0; +} + +static int pci_epf_test_notifier(struct notifier_block *nb, unsigned long val, + void *data) +{ + struct pci_epf *epf = container_of(nb, struct pci_epf, nb); + struct pci_epf_test *epf_test = epf_get_drvdata(epf); + int ret; + + switch (val) { + case CORE_INIT: + ret = pci_epf_test_core_init(epf); + if (ret) + return NOTIFY_BAD; + break; + + case LINK_UP: + queue_delayed_work(kpcitest_workqueue, &epf_test->cmd_handler, + msecs_to_jiffies(1)); + break; + + default: + dev_err(&epf->dev, "Invalid EPF test notifier event\n"); + return NOTIFY_BAD; + } + + return NOTIFY_OK; +} + static int pci_epf_test_alloc_space(struct pci_epf *epf) { struct pci_epf_test *epf_test = epf_get_drvdata(epf); @@ -496,12 +556,11 @@ static int pci_epf_test_bind(struct pci_epf *epf) { int ret; struct pci_epf_test *epf_test = epf_get_drvdata(epf); - struct pci_epf_header *header = epf->header; const struct pci_epc_features *epc_features; enum pci_barno test_reg_bar = BAR_0; struct pci_epc *epc = epf->epc; - struct device *dev = &epf->dev; bool linkup_notifier = false; + bool skip_core_init = false; bool msix_capable = false; bool msi_capable = true; @@ -511,6 +570,7 @@ static int pci_epf_test_bind(struct pci_epf *epf) epc_features = pci_epc_get_features(epc, epf->func_no); if (epc_features) { linkup_notifier = epc_features->linkup_notifier; + skip_core_init = epc_features->skip_core_init; msix_capable = epc_features->msix_capable; msi_capable = epc_features->msi_capable; test_reg_bar = pci_epc_get_first_free_bar(epc_features); @@ -520,34 +580,14 @@ static int pci_epf_test_bind(struct pci_epf *epf) epf_test->test_reg_bar = test_reg_bar; epf_test->epc_features = epc_features; - ret = pci_epc_write_header(epc, epf->func_no, header); - if (ret) { - dev_err(dev, "Configuration header write failed\n"); - return ret; - } - ret = pci_epf_test_alloc_space(epf); if (ret) return ret; - ret = pci_epf_test_set_bar(epf); - if (ret) - return ret; - - if (msi_capable) { - ret = pci_epc_set_msi(epc, epf->func_no, epf->msi_interrupts); - if (ret) { - dev_err(dev, "MSI configuration failed\n"); - return ret; - } - } - - if (msix_capable) { - ret = pci_epc_set_msix(epc, epf->func_no, epf->msix_interrupts); - if (ret) { - dev_err(dev, "MSI-X configuration failed\n"); + if (!skip_core_init) { + ret = pci_epf_test_core_init(epf); + if (ret) return ret; - } } if (linkup_notifier) { -- 2.17.1