From: Bjorn Helgaas <helgaas@kernel.org>
To: Vladimir Oltean <olteanv@gmail.com>
Cc: Michael Walle <michael@walle.cc>,
lorenzo.pieralisi@arm.com, kw@linux.com, heiko@sntech.de,
benh@kernel.crashing.org, shawn.lin@rock-chips.com,
paulus@samba.org, thomas.petazzoni@bootlin.com,
jonnyc@amazon.com, toan@os.amperecomputing.com, will@kernel.org,
robh@kernel.org, f.fainelli@gmail.com, mpe@ellerman.id.au,
michal.simek@xilinx.com, linux-rockchip@lists.infradead.org,
bcm-kernel-feedback-list@broadcom.com,
jonathan.derrick@intel.com, linux-pci@vger.kernel.org,
rjui@broadcom.com, linux-rpi-kernel@lists.infradead.org,
Jonathan.Cameron@huawei.com, bhelgaas@google.com,
linux-arm-kernel@lists.infradead.org, sbranden@broadcom.com,
wangzhou1@hisilicon.com, rrichter@marvell.com,
linuxppc-dev@lists.ozlabs.org, nsaenzjulienne@suse.de,
Alexandru Marginean <alexm.osslist@gmail.com>
Subject: Re: [PATCH v6 0/5] PCI: Unify ECAM constants in native PCI Express drivers
Date: Thu, 10 Dec 2020 11:38:09 -0600 [thread overview]
Message-ID: <20201210173809.GA37355@bjorn-Precision-5520> (raw)
In-Reply-To: <20201209202904.2juzokqhleusgsts@skbuf>
On Wed, Dec 09, 2020 at 10:29:04PM +0200, Vladimir Oltean wrote:
> On Wed, Dec 09, 2020 at 04:40:52PM +0100, Michael Walle wrote:
> > Hopefully my mail client won't mess up the output that much.
>
> I can reproduce on my LS1028A as well. The following fixes the bug for
> me. I did not follow the discussion and see if it is helpful for others.
> I don't understand how the bug came to be. There might be more to it
> than what I'm seeing. If it's just what I'm seeing, then the patch was
> pretty broken to begin with.
I squashed the fix below into a pci/ecam branch for v5.11, thanks!
> -----------------------------[cut here]-----------------------------
> From b184da4088c9d39d25fee2486941cdf77688a409 Mon Sep 17 00:00:00 2001
> From: Vladimir Oltean <vladimir.oltean@nxp.com>
> Date: Wed, 9 Dec 2020 22:17:32 +0200
> Subject: [PATCH] PCI: fix invalid window size for the ECAM config space
>
> The blamed commit forgot that pci_ecam_create() calculates the size of
> the window for the ECAM's config space based on the spacing between two
> buses. The drivers whose .bus_shift from struct pci_ecam_ops was changed
> to zero in this commit are now using this invalid value for bus_shift
> in calculating the window size.
>
> Before (broken):
> pci_ecam_create: remapping config space from addr 0x1f0000000, bus_range 0x1, bsz 0x1
> After (fixed/restored):
> pci_ecam_create: remapping config space from addr 0x1f0000000, bus_range 0x1, bsz 0x100000
>
> Fixes: f3c07cf6924e ("PCI: Unify ECAM constants in native PCI Express drivers")
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
> drivers/pci/ecam.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/ecam.c b/drivers/pci/ecam.c
> index 59f91d434859..9fda0d49bc93 100644
> --- a/drivers/pci/ecam.c
> +++ b/drivers/pci/ecam.c
> @@ -28,11 +28,19 @@ struct pci_config_window *pci_ecam_create(struct device *dev,
> struct resource *cfgres, struct resource *busr,
> const struct pci_ecam_ops *ops)
> {
> + unsigned int bus_shift = ops->bus_shift;
> struct pci_config_window *cfg;
> unsigned int bus_range, bus_range_max, bsz;
> struct resource *conflict;
> int i, err;
>
> + /*
> + * struct pci_ecam_ops may omit specifying bus_shift
> + * if it is as per spec
> + */
> + if (!bus_shift)
> + bus_shift = PCIE_ECAM_BUS_SHIFT;
> +
> if (busr->start > busr->end)
> return ERR_PTR(-EINVAL);
>
> @@ -46,14 +54,14 @@ struct pci_config_window *pci_ecam_create(struct device *dev,
> cfg->busr.end = busr->end;
> cfg->busr.flags = IORESOURCE_BUS;
> bus_range = resource_size(&cfg->busr);
> - bus_range_max = resource_size(cfgres) >> ops->bus_shift;
> + bus_range_max = resource_size(cfgres) >> bus_shift;
> if (bus_range > bus_range_max) {
> bus_range = bus_range_max;
> cfg->busr.end = busr->start + bus_range - 1;
> dev_warn(dev, "ECAM area %pR can only accommodate %pR (reduced from %pR desired)\n",
> cfgres, &cfg->busr, busr);
> }
> - bsz = 1 << ops->bus_shift;
> + bsz = 1 << bus_shift;
>
> cfg->res.start = cfgres->start;
> cfg->res.end = cfgres->end;
> -----------------------------[cut here]-----------------------------
next prev parent reply other threads:[~2020-12-10 17:39 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-29 23:07 [PATCH v6 0/5] PCI: Unify ECAM constants in native PCI Express drivers Krzysztof Wilczyński
2020-11-29 23:07 ` [PATCH v6 1/5] " Krzysztof Wilczyński
2020-11-30 11:08 ` Lorenzo Pieralisi
2020-11-30 15:30 ` Krzysztof Wilczyński
2020-11-30 18:23 ` Derrick, Jonathan
2020-12-06 20:16 ` Krzysztof Wilczyński
2020-12-07 3:25 ` Florian Fainelli
2020-12-07 20:29 ` Jim Quinlan
2020-11-29 23:07 ` [PATCH v6 2/5] PCI: thunder-pem: Add constant for custom ".bus_shit" initialiser Krzysztof Wilczyński
2020-11-29 23:07 ` [PATCH v6 3/5] PCI: iproc: Convert to use the new ECAM constants Krzysztof Wilczyński
2020-11-29 23:07 ` [PATCH v6 4/5] PCI: vmd: Update type of the __iomem pointers Krzysztof Wilczyński
2020-11-30 9:06 ` David Laight
2020-11-30 17:20 ` Bjorn Helgaas
2020-11-30 18:19 ` Derrick, Jonathan
2020-11-29 23:07 ` [PATCH v6 5/5] PCI: xgene: Removed unused ".bus_shift" initialisers from pci-xgene.c Krzysztof Wilczyński
2020-12-01 15:34 ` [PATCH v6 0/5] PCI: Unify ECAM constants in native PCI Express drivers Lorenzo Pieralisi
2020-12-08 15:41 ` Michael Walle
2020-12-08 21:06 ` Bjorn Helgaas
2020-12-08 21:11 ` Michael Walle
2020-12-09 12:36 ` Bjorn Helgaas
2020-12-09 13:08 ` Michael Walle
2020-12-09 14:57 ` Bjorn Helgaas
2020-12-09 15:40 ` Michael Walle
2020-12-09 20:29 ` Vladimir Oltean
2020-12-09 20:59 ` Bjorn Helgaas
2020-12-09 21:20 ` Vladimir Oltean
2020-12-09 21:34 ` Bjorn Helgaas
2020-12-09 21:43 ` Vladimir Oltean
2020-12-09 22:05 ` Bjorn Helgaas
2020-12-10 17:38 ` Bjorn Helgaas [this message]
2020-12-10 19:58 ` Michael Walle
2020-12-08 16:07 ` Qian Cai
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=20201210173809.GA37355@bjorn-Precision-5520 \
--to=helgaas@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=alexm.osslist@gmail.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=benh@kernel.crashing.org \
--cc=bhelgaas@google.com \
--cc=f.fainelli@gmail.com \
--cc=heiko@sntech.de \
--cc=jonathan.derrick@intel.com \
--cc=jonnyc@amazon.com \
--cc=kw@linux.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=michael@walle.cc \
--cc=michal.simek@xilinx.com \
--cc=mpe@ellerman.id.au \
--cc=nsaenzjulienne@suse.de \
--cc=olteanv@gmail.com \
--cc=paulus@samba.org \
--cc=rjui@broadcom.com \
--cc=robh@kernel.org \
--cc=rrichter@marvell.com \
--cc=sbranden@broadcom.com \
--cc=shawn.lin@rock-chips.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=toan@os.amperecomputing.com \
--cc=wangzhou1@hisilicon.com \
--cc=will@kernel.org \
/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).