From: Michael Neuling <mikey@neuling.org>
To: mpe@ellerman.id.au, benh@kernel.crashing.org
Cc: mikey@neuling.org, "Matthew R. Ochs" <mrochs@linux.vnet.ibm.com>,
imunsie@au.ibm.com, linuxppc-dev@ozlabs.org,
"Manoj N. Kumar" <manoj@linux.vnet.ibm.com>,
brking@linux.vnet.ibm.com, Daniel Axtens <dja@axtens.net>
Subject: [PATCH 07/19] cxl: Re-order card init to check the VSEC earlier
Date: Tue, 19 May 2015 21:22:24 +1000 [thread overview]
Message-ID: <1432034556-32400-8-git-send-email-mikey@neuling.org> (raw)
In-Reply-To: <1432034556-32400-1-git-send-email-mikey@neuling.org>
When we expose AFUs as virtual PCI devices, they may look like the physical
CAPI PCI card. ie they may have the same vendor/device IDs.
We want to avoid these AFUs binding to this driver and any init this driver may
do.
Re-order card init to check the VSEC earlier before assigning BARs or
activating CXL. Also change the dev used in early prints as the adapter struct
may not be inited at this earlier stage.
Signed-off-by: Michael Neuling <mikey@neuling.org>
---
drivers/misc/cxl/pci.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index a9c90d2..1ac2ecf 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -884,13 +884,13 @@ static int cxl_read_vsec(struct cxl *adapter, struct pci_dev *dev)
u16 vseclen;
if (!(vsec = find_cxl_vsec(dev))) {
- dev_err(&adapter->dev, "ABORTING: CXL VSEC not found!\n");
+ dev_err(&dev->dev, "ABORTING: CXL VSEC not found!\n");
return -ENODEV;
}
CXL_READ_VSEC_LENGTH(dev, vsec, &vseclen);
if (vseclen < CXL_VSEC_MIN_SIZE) {
- pr_err("ABORTING: CXL VSEC too short\n");
+ dev_err(&dev->dev, "ABORTING: CXL VSEC too short\n");
return -EINVAL;
}
@@ -927,24 +927,24 @@ static int cxl_vsec_looks_ok(struct cxl *adapter, struct pci_dev *dev)
return -EBUSY;
if (adapter->vsec_status & CXL_UNSUPPORTED_FEATURES) {
- dev_err(&adapter->dev, "ABORTING: CXL requires unsupported features\n");
+ dev_err(&dev->dev, "ABORTING: CXL requires unsupported features\n");
return -EINVAL;
}
if (!adapter->slices) {
/* Once we support dynamic reprogramming we can use the card if
* it supports loadable AFUs */
- dev_err(&adapter->dev, "ABORTING: Device has no AFUs\n");
+ dev_err(&dev->dev, "ABORTING: Device has no AFUs\n");
return -EINVAL;
}
if (!adapter->afu_desc_off || !adapter->afu_desc_size) {
- dev_err(&adapter->dev, "ABORTING: VSEC shows no AFU descriptors\n");
+ dev_err(&dev->dev, "ABORTING: VSEC shows no AFU descriptors\n");
return -EINVAL;
}
if (adapter->ps_size > p2_size(dev) - adapter->ps_off) {
- dev_err(&adapter->dev, "ABORTING: Problem state size larger than "
+ dev_err(&dev->dev, "ABORTING: Problem state size larger than "
"available in BAR2: 0x%llx > 0x%llx\n",
adapter->ps_size, p2_size(dev) - adapter->ps_off);
return -EINVAL;
@@ -993,6 +993,15 @@ static struct cxl *cxl_init_adapter(struct pci_dev *dev)
if (!(adapter = cxl_alloc_adapter(dev)))
return ERR_PTR(-ENOMEM);
+ if ((rc = cxl_read_vsec(adapter, dev)))
+ goto err1;
+
+ if ((rc = cxl_vsec_looks_ok(adapter, dev)))
+ goto err1;
+
+ if ((rc = setup_cxl_bars(dev)))
+ goto err1;
+
if ((rc = switch_card_to_cxl(dev)))
goto err1;
@@ -1002,12 +1011,6 @@ static struct cxl *cxl_init_adapter(struct pci_dev *dev)
if ((rc = dev_set_name(&adapter->dev, "card%i", adapter->adapter_num)))
goto err2;
- if ((rc = cxl_read_vsec(adapter, dev)))
- goto err2;
-
- if ((rc = cxl_vsec_looks_ok(adapter, dev)))
- goto err2;
-
if ((rc = cxl_update_image_control(adapter)))
goto err2;
@@ -1092,9 +1095,6 @@ static int cxl_probe(struct pci_dev *dev, const struct pci_device_id *id)
if (cxl_verbose)
dump_cxl_config_space(dev);
- if ((rc = setup_cxl_bars(dev)))
- return rc;
-
if ((rc = pci_enable_device(dev))) {
dev_err(&dev->dev, "pci_enable_device failed: %i\n", rc);
return rc;
--
2.1.0
next prev parent reply other threads:[~2015-05-19 11:23 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-19 11:22 [PATCH 00/19] cxl: Add AFU virtual PHB and in kernel API Michael Neuling
2015-05-19 11:22 ` [PATCH 01/19] powerpc/copro: Fix faulting kernel segments Michael Neuling
2015-05-21 8:59 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 02/19] powerpc/pci: Export symbols for CXL Michael Neuling
2015-05-19 11:22 ` [PATCH 03/19] powerpc/pci: Add release_device() hook to phb ops Michael Neuling
2015-05-19 11:22 ` [PATCH 04/19] powerpc: Add cxl context to device archdata Michael Neuling
2015-05-19 11:22 ` [PATCH 05/19] cxl: Document external user of existing API Michael Neuling
2015-05-21 9:01 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 06/19] cxl: Add shutdown hook Michael Neuling
2015-05-21 9:06 ` Ian Munsie
2015-05-19 11:22 ` Michael Neuling [this message]
2015-05-21 9:09 ` [PATCH 07/19] cxl: Re-order card init to check the VSEC earlier Ian Munsie
2015-05-22 5:26 ` Michael Neuling
2015-05-19 11:22 ` [PATCH 08/19] cxl: Dump debug info on the AFU configuration record Michael Neuling
2015-05-21 9:10 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 09/19] cxl: Add cookie parameter to afu_release_irqs() Michael Neuling
2015-05-21 9:10 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 10/19] cxl: Rework detach context functions Michael Neuling
2015-05-21 9:13 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 11/19] cxl: cxl_afu_reset() -> __cxl_afu_reset() Michael Neuling
2015-05-21 9:14 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 12/19] cxl: Export some symbols Michael Neuling
2015-05-21 9:16 ` Ian Munsie
2015-05-26 1:22 ` Michael Neuling
2015-05-19 11:22 ` [PATCH 13/19] cxl: Only check pid for userspace contexts Michael Neuling
2015-05-21 9:16 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 14/19] cxl: Split afu_register_irqs() function Michael Neuling
2015-05-21 9:17 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 15/19] cxl: Configure PSL for kernel contexts Michael Neuling
2015-05-21 9:32 ` Ian Munsie
2015-05-22 5:28 ` Michael Neuling
2015-05-19 11:22 ` [PATCH 16/19] cxl: Cleanup Makefile Michael Neuling
2015-05-21 9:32 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 17/19] cxl: Move include file cxl.h -> cxl-base.h Michael Neuling
2015-05-21 9:33 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 18/19] cxl: Export file ops for use by API Michael Neuling
2015-05-21 9:37 ` Ian Munsie
2015-05-19 11:22 ` [PATCH 19/19] cxl: Add AFU virtual PHB and kernel API Michael Neuling
2015-05-21 8:58 ` Ian Munsie
2015-05-25 4:12 ` Michael Neuling
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1432034556-32400-8-git-send-email-mikey@neuling.org \
--to=mikey@neuling.org \
--cc=benh@kernel.crashing.org \
--cc=brking@linux.vnet.ibm.com \
--cc=dja@axtens.net \
--cc=imunsie@au.ibm.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=manoj@linux.vnet.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=mrochs@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).