diff options
author | Russ Weight <russell.h.weight@intel.com> | 2021-09-16 14:07:33 -0700 |
---|---|---|
committer | Moritz Fischer <mdf@kernel.org> | 2021-09-16 15:20:55 -0700 |
commit | e9a9970bf520c99e530d8f1fa5b5c22671fad4ef (patch) | |
tree | 2197e0266005ead0be3097696f477dc6ba0d047f /drivers/fpga | |
parent | a1e4470823d99e75b596748086e120dea169ed3c (diff) | |
download | linux-e9a9970bf520c99e530d8f1fa5b5c22671fad4ef.tar.gz linux-e9a9970bf520c99e530d8f1fa5b5c22671fad4ef.tar.bz2 linux-e9a9970bf520c99e530d8f1fa5b5c22671fad4ef.zip |
fpga: dfl: Avoid reads to AFU CSRs during enumeration
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.
Fixes: 1604986c3e6b ("fpga: dfl: expose feature revision from struct dfl_device")
Cc: stable@vger.kernel.org
Signed-off-by: Russ Weight <russell.h.weight@intel.com>
Signed-off-by: Moritz Fischer <mdf@kernel.org>
Diffstat (limited to 'drivers/fpga')
-rw-r--r-- | drivers/fpga/dfl.c | 14 |
1 files 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; |