All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wasim Khan <wasim.khan@nxp.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 12/12] pci: ls_pcie_g4: Add size check for config resource
Date: Mon, 28 Sep 2020 16:26:14 +0530	[thread overview]
Message-ID: <1601290574-20151-13-git-send-email-wasim.khan@nxp.com> (raw)
In-Reply-To: <1601290574-20151-1-git-send-email-wasim.khan@nxp.com>

resource "config" is required to have minimum 4KB space
to access all config space of PCI Express EP.

Signed-off-by: Wasim Khan <wasim.khan@nxp.com>
---
Changes in V2:
- Updated commit description
- Fix CheckPatch issue
- Change size check to 4KB to access PCIe config space

Changes in V3:
- No Change

 drivers/pci/pcie_layerscape_gen4.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/pci/pcie_layerscape_gen4.c b/drivers/pci/pcie_layerscape_gen4.c
index 0226bde..6e71173 100644
--- a/drivers/pci/pcie_layerscape_gen4.c
+++ b/drivers/pci/pcie_layerscape_gen4.c
@@ -455,6 +455,7 @@ static int ls_pcie_g4_probe(struct udevice *dev)
 	u32 link_ctrl_sta;
 	u32 val;
 	int ret;
+	fdt_size_t cfg_size;
 
 	pcie->bus = dev;
 
@@ -488,6 +489,13 @@ static int ls_pcie_g4_probe(struct udevice *dev)
 		return ret;
 	}
 
+	cfg_size = fdt_resource_size(&pcie->cfg_res);
+	if (cfg_size < SZ_4K) {
+		printf("PCIe%d: %s Invalid size(0x%llx) for resource \"config\",expected minimum 0x%x\n",
+		       PCIE_SRDS_PRTCL(pcie->idx), dev->name, cfg_size, SZ_4K);
+		return 0;
+	}
+
 	pcie->cfg = map_physmem(pcie->cfg_res.start,
 				fdt_resource_size(&pcie->cfg_res),
 				MAP_NOCACHE);
-- 
2.7.4

  parent reply	other threads:[~2020-09-28 10:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-28 10:56 [PATCH v2 00/12] Add label to pcie nodes Wasim Khan
2020-09-28 10:56 ` [PATCH v2 01/12] configs: lx2160a: Enable CONFIG_PCIE_LAYERSCAPE_GEN4 Wasim Khan
2020-12-11  7:58   ` Priyanka Jain
2020-09-28 10:56 ` [PATCH v2 02/12] pci: layerscape: Print pcie controller number starting from 1 Wasim Khan
2020-09-28 10:56 ` [PATCH v2 03/12] pci: ls_pcie_g4: " Wasim Khan
2020-09-28 10:56 ` [PATCH v2 04/12] arm: dts: lx2160a: add label to pcie nodes in dts Wasim Khan
2020-09-28 10:56 ` [PATCH v2 05/12] arm: dts: ls1046a: " Wasim Khan
2020-09-28 10:56 ` [PATCH v2 06/12] arm: dts: ls2080a: " Wasim Khan
2020-09-28 10:56 ` [PATCH v2 07/12] arm: dts: ls1088a: " Wasim Khan
2020-09-28 10:56 ` [PATCH v2 08/12] arm: dts: ls1012a: " Wasim Khan
2020-09-28 10:56 ` [PATCH v2 09/12] arm: dts: ls1043a: " Wasim Khan
2020-09-28 10:56 ` [PATCH v2 10/12] arm: dts: ls1028a: " Wasim Khan
2020-09-28 10:56 ` [PATCH v2 11/12] pci: layerscape: Add size check for config resource Wasim Khan
2020-09-28 10:56 ` Wasim Khan [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-08-04 11:18 [PATCH v2 00/12] Add label to pcie nodes Wasim Khan
2020-08-04 11:18 ` [PATCH v2 12/12] pci: ls_pcie_g4: Add size check for config resource Wasim Khan

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=1601290574-20151-13-git-send-email-wasim.khan@nxp.com \
    --to=wasim.khan@nxp.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.