linux-fpga.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] fpga: dfl: Avoid reads to AFU CSRs during enumeration
@ 2021-09-16 21:07 Russ Weight
  2021-09-16 22:24 ` Moritz Fischer
  2021-09-17  5:42 ` Greg KH
  0 siblings, 2 replies; 7+ messages in thread
From: Russ Weight @ 2021-09-16 21:07 UTC (permalink / raw)
  To: mdf, linux-fpga
  Cc: trix, lgoncalv, yilun.xu, hao.wu, matthew.gerlach, rc,
	Russ Weight, stable

CSR address space for Accelerator Functional Units (AFU) is not available
during the early Device Feature List (DFL) enumeration. Early access
to this space results in invalid data and port errors. This change adds
a condition to prevent an early read from the AFU CSR space.

Signed-off-by: Russ Weight <russell.h.weight@intel.com>

Fixes: 23bcda750558 ("fpga: dfl: expose feature revision from struct
dfl_device")
Cc: stable@vger.kernel.org
---
 drivers/fpga/dfl.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
index c99b78ee008a..f86666cf2c6a 100644
--- a/drivers/fpga/dfl.c
+++ b/drivers/fpga/dfl.c
@@ -1019,16 +1019,18 @@ create_feature_instance(struct build_feature_devs_info *binfo,
 {
 	unsigned int irq_base, nr_irqs;
 	struct dfl_feature_info *finfo;
+	u8 revision = 0;
 	int ret;
-	u8 revision;
 	u64 v;
 
-	v = readq(binfo->ioaddr + ofst);
-	revision = FIELD_GET(DFH_REVISION, v);
+	if (fid != FEATURE_ID_AFU) {
+		v = readq(binfo->ioaddr + ofst);
+		revision = FIELD_GET(DFH_REVISION, v);
 
-	/* read feature size and id if inputs are invalid */
-	size = size ? size : feature_size(v);
-	fid = fid ? fid : feature_id(v);
+		/* read feature size and id if inputs are invalid */
+		size = size ? size : feature_size(v);
+		fid = fid ? fid : feature_id(v);
+	}
 
 	if (binfo->len - ofst < size)
 		return -EINVAL;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-09-17 18:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-16 21:07 [PATCH 1/1] fpga: dfl: Avoid reads to AFU CSRs during enumeration Russ Weight
2021-09-16 22:24 ` Moritz Fischer
2021-09-16 22:34   ` Russ Weight
2021-09-16 22:50     ` Moritz Fischer
2021-09-17 18:24       ` Russ Weight
2021-09-17  5:42 ` Greg KH
2021-09-17 16:26   ` Moritz Fischer

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).