Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fpga: dfl: check feature type before parse irq info

Previously the feature IDs defined are unique, no matter
which feature type. But currently we want to extend its
usage to have a per-type feature ID space, so this patch
adds feature type checking as well just before look into
feature ID for different features which have irq info.

Signed-off-by: Tianfei zhang <tianfei.zhang@intel.com>
Reviewed-by: Matthew Gerlach <matthew.gerlach@linux.intel.com>
Acked-by: Wu Hao <hao.wu@intel.com>
Acked-by: Moritz Fischer <mdf@kernel.org>
Link: https://lore.kernel.org/r/20220419032942.427429-2-tianfei.zhang@intel.com
Signed-off-by: Xu Yilun <yilun.xu@intel.com>

authored by

Tianfei zhang and committed by
Xu Yilun
88b3f3ff 838a8438

+22 -16
+22 -16
drivers/fpga/dfl.c
··· 940 940 { 941 941 void __iomem *base = binfo->ioaddr + ofst; 942 942 unsigned int i, ibase, inr = 0; 943 + enum dfl_id_type type; 943 944 int virq; 944 945 u64 v; 946 + 947 + type = feature_dev_id_type(binfo->feature_dev); 945 948 946 949 /* 947 950 * Ideally DFL framework should only read info from DFL header, but ··· 960 957 * code will be added. But in order to be compatible to old version 961 958 * DFL, the driver may still fall back to these quirks. 962 959 */ 963 - switch (fid) { 964 - case PORT_FEATURE_ID_UINT: 965 - v = readq(base + PORT_UINT_CAP); 966 - ibase = FIELD_GET(PORT_UINT_CAP_FST_VECT, v); 967 - inr = FIELD_GET(PORT_UINT_CAP_INT_NUM, v); 968 - break; 969 - case PORT_FEATURE_ID_ERROR: 970 - v = readq(base + PORT_ERROR_CAP); 971 - ibase = FIELD_GET(PORT_ERROR_CAP_INT_VECT, v); 972 - inr = FIELD_GET(PORT_ERROR_CAP_SUPP_INT, v); 973 - break; 974 - case FME_FEATURE_ID_GLOBAL_ERR: 975 - v = readq(base + FME_ERROR_CAP); 976 - ibase = FIELD_GET(FME_ERROR_CAP_INT_VECT, v); 977 - inr = FIELD_GET(FME_ERROR_CAP_SUPP_INT, v); 978 - break; 960 + if (type == PORT_ID) { 961 + switch (fid) { 962 + case PORT_FEATURE_ID_UINT: 963 + v = readq(base + PORT_UINT_CAP); 964 + ibase = FIELD_GET(PORT_UINT_CAP_FST_VECT, v); 965 + inr = FIELD_GET(PORT_UINT_CAP_INT_NUM, v); 966 + break; 967 + case PORT_FEATURE_ID_ERROR: 968 + v = readq(base + PORT_ERROR_CAP); 969 + ibase = FIELD_GET(PORT_ERROR_CAP_INT_VECT, v); 970 + inr = FIELD_GET(PORT_ERROR_CAP_SUPP_INT, v); 971 + break; 972 + } 973 + } else if (type == FME_ID) { 974 + if (fid == FME_FEATURE_ID_GLOBAL_ERR) { 975 + v = readq(base + FME_ERROR_CAP); 976 + ibase = FIELD_GET(FME_ERROR_CAP_INT_VECT, v); 977 + inr = FIELD_GET(FME_ERROR_CAP_SUPP_INT, v); 978 + } 979 979 } 980 980 981 981 if (!inr) {