Commit 8a5de2de authored by Xu Yilun's avatar Xu Yilun Committed by Moritz Fischer

fpga: dfl: change data type of feature id to u16

The feature id is stored in a 12 bit field in DFH. So a u16 variable is
enough for feature id.

This patch changes all feature id related places to fit u16.
Signed-off-by: default avatarXu Yilun <yilun.xu@intel.com>
Reviewed-by: default avatarTom Rix <trix@redhat.com>
Acked-by: default avatarWu Hao <hao.wu@intel.com>
Signed-off-by: default avatarMoritz Fischer <mdf@kernel.org>
parent e6c013c3
...@@ -148,7 +148,7 @@ struct fme_perf_priv { ...@@ -148,7 +148,7 @@ struct fme_perf_priv {
struct device *dev; struct device *dev;
void __iomem *ioaddr; void __iomem *ioaddr;
struct pmu pmu; struct pmu pmu;
u64 id; u16 id;
u32 fab_users; u32 fab_users;
u32 fab_port_id; u32 fab_port_id;
......
...@@ -58,7 +58,7 @@ static const char *dfl_pdata_key_strings[DFL_ID_MAX] = { ...@@ -58,7 +58,7 @@ static const char *dfl_pdata_key_strings[DFL_ID_MAX] = {
*/ */
struct dfl_dev_info { struct dfl_dev_info {
const char *name; const char *name;
u32 dfh_id; u16 dfh_id;
struct idr id; struct idr id;
enum dfl_fpga_devt_type devt_type; enum dfl_fpga_devt_type devt_type;
}; };
...@@ -134,7 +134,7 @@ static enum dfl_id_type feature_dev_id_type(struct platform_device *pdev) ...@@ -134,7 +134,7 @@ static enum dfl_id_type feature_dev_id_type(struct platform_device *pdev)
return DFL_ID_MAX; return DFL_ID_MAX;
} }
static enum dfl_id_type dfh_id_to_type(u32 id) static enum dfl_id_type dfh_id_to_type(u16 id)
{ {
int i; int i;
...@@ -454,7 +454,7 @@ struct build_feature_devs_info { ...@@ -454,7 +454,7 @@ struct build_feature_devs_info {
* @nr_irqs: number of irqs of this sub feature. * @nr_irqs: number of irqs of this sub feature.
*/ */
struct dfl_feature_info { struct dfl_feature_info {
u64 fid; u16 fid;
struct resource mmio_res; struct resource mmio_res;
void __iomem *ioaddr; void __iomem *ioaddr;
struct list_head node; struct list_head node;
...@@ -649,7 +649,7 @@ static inline u32 feature_size(void __iomem *start) ...@@ -649,7 +649,7 @@ static inline u32 feature_size(void __iomem *start)
return ofst ? ofst : 4096; return ofst ? ofst : 4096;
} }
static u64 feature_id(void __iomem *start) static u16 feature_id(void __iomem *start)
{ {
u64 v = readq(start + DFH); u64 v = readq(start + DFH);
u16 id = FIELD_GET(DFH_ID, v); u16 id = FIELD_GET(DFH_ID, v);
...@@ -667,7 +667,7 @@ static u64 feature_id(void __iomem *start) ...@@ -667,7 +667,7 @@ static u64 feature_id(void __iomem *start)
} }
static int parse_feature_irqs(struct build_feature_devs_info *binfo, static int parse_feature_irqs(struct build_feature_devs_info *binfo,
resource_size_t ofst, u64 fid, resource_size_t ofst, u16 fid,
unsigned int *irq_base, unsigned int *nr_irqs) unsigned int *irq_base, unsigned int *nr_irqs)
{ {
void __iomem *base = binfo->ioaddr + ofst; void __iomem *base = binfo->ioaddr + ofst;
...@@ -713,12 +713,12 @@ static int parse_feature_irqs(struct build_feature_devs_info *binfo, ...@@ -713,12 +713,12 @@ static int parse_feature_irqs(struct build_feature_devs_info *binfo,
return 0; return 0;
} }
dev_dbg(binfo->dev, "feature: 0x%llx, irq_base: %u, nr_irqs: %u\n", dev_dbg(binfo->dev, "feature: 0x%x, irq_base: %u, nr_irqs: %u\n",
fid, ibase, inr); fid, ibase, inr);
if (ibase + inr > binfo->nr_irqs) { if (ibase + inr > binfo->nr_irqs) {
dev_err(binfo->dev, dev_err(binfo->dev,
"Invalid interrupt number in feature 0x%llx\n", fid); "Invalid interrupt number in feature 0x%x\n", fid);
return -EINVAL; return -EINVAL;
} }
...@@ -726,7 +726,7 @@ static int parse_feature_irqs(struct build_feature_devs_info *binfo, ...@@ -726,7 +726,7 @@ static int parse_feature_irqs(struct build_feature_devs_info *binfo,
virq = binfo->irq_table[ibase + i]; virq = binfo->irq_table[ibase + i];
if (virq < 0 || virq > NR_IRQS) { if (virq < 0 || virq > NR_IRQS) {
dev_err(binfo->dev, dev_err(binfo->dev,
"Invalid irq table entry for feature 0x%llx\n", "Invalid irq table entry for feature 0x%x\n",
fid); fid);
return -EINVAL; return -EINVAL;
} }
...@@ -748,7 +748,7 @@ static int parse_feature_irqs(struct build_feature_devs_info *binfo, ...@@ -748,7 +748,7 @@ static int parse_feature_irqs(struct build_feature_devs_info *binfo,
static int static int
create_feature_instance(struct build_feature_devs_info *binfo, create_feature_instance(struct build_feature_devs_info *binfo,
struct dfl_fpga_enum_dfl *dfl, resource_size_t ofst, struct dfl_fpga_enum_dfl *dfl, resource_size_t ofst,
resource_size_t size, u64 fid) resource_size_t size, u16 fid)
{ {
unsigned int irq_base, nr_irqs; unsigned int irq_base, nr_irqs;
struct dfl_feature_info *finfo; struct dfl_feature_info *finfo;
...@@ -819,9 +819,10 @@ static int parse_feature_fiu(struct build_feature_devs_info *binfo, ...@@ -819,9 +819,10 @@ static int parse_feature_fiu(struct build_feature_devs_info *binfo,
struct dfl_fpga_enum_dfl *dfl, struct dfl_fpga_enum_dfl *dfl,
resource_size_t ofst) resource_size_t ofst)
{ {
u32 id, offset;
u64 v;
int ret = 0; int ret = 0;
u32 offset;
u16 id;
u64 v;
v = readq(dfl->ioaddr + ofst + DFH); v = readq(dfl->ioaddr + ofst + DFH);
id = FIELD_GET(DFH_ID, v); id = FIELD_GET(DFH_ID, v);
...@@ -855,8 +856,8 @@ static int parse_feature_private(struct build_feature_devs_info *binfo, ...@@ -855,8 +856,8 @@ static int parse_feature_private(struct build_feature_devs_info *binfo,
resource_size_t ofst) resource_size_t ofst)
{ {
if (!binfo->feature_dev) { if (!binfo->feature_dev) {
dev_err(binfo->dev, "the private feature %llx does not belong to any AFU.\n", dev_err(binfo->dev, "the private feature 0x%x does not belong to any AFU.\n",
(unsigned long long)feature_id(dfl->ioaddr + ofst)); feature_id(dfl->ioaddr + ofst));
return -EINVAL; return -EINVAL;
} }
...@@ -1424,7 +1425,7 @@ static int do_set_irq_trigger(struct dfl_feature *feature, unsigned int idx, ...@@ -1424,7 +1425,7 @@ static int do_set_irq_trigger(struct dfl_feature *feature, unsigned int idx,
return 0; return 0;
feature->irq_ctx[idx].name = feature->irq_ctx[idx].name =
kasprintf(GFP_KERNEL, "fpga-irq[%u](%s-%llx)", idx, kasprintf(GFP_KERNEL, "fpga-irq[%u](%s-%x)", idx,
dev_name(&pdev->dev), feature->id); dev_name(&pdev->dev), feature->id);
if (!feature->irq_ctx[idx].name) if (!feature->irq_ctx[idx].name)
return -ENOMEM; return -ENOMEM;
......
...@@ -197,7 +197,7 @@ int dfl_fpga_check_port_id(struct platform_device *pdev, void *pport_id); ...@@ -197,7 +197,7 @@ int dfl_fpga_check_port_id(struct platform_device *pdev, void *pport_id);
* @id: unique dfl private feature id. * @id: unique dfl private feature id.
*/ */
struct dfl_feature_id { struct dfl_feature_id {
u64 id; u16 id;
}; };
/** /**
...@@ -240,7 +240,7 @@ struct dfl_feature_irq_ctx { ...@@ -240,7 +240,7 @@ struct dfl_feature_irq_ctx {
*/ */
struct dfl_feature { struct dfl_feature {
struct platform_device *dev; struct platform_device *dev;
u64 id; u16 id;
int resource_index; int resource_index;
void __iomem *ioaddr; void __iomem *ioaddr;
struct dfl_feature_irq_ctx *irq_ctx; struct dfl_feature_irq_ctx *irq_ctx;
...@@ -365,7 +365,7 @@ struct platform_device *dfl_fpga_inode_to_feature_dev(struct inode *inode) ...@@ -365,7 +365,7 @@ struct platform_device *dfl_fpga_inode_to_feature_dev(struct inode *inode)
(feature) < (pdata)->features + (pdata)->num; (feature)++) (feature) < (pdata)->features + (pdata)->num; (feature)++)
static inline static inline
struct dfl_feature *dfl_get_feature_by_id(struct device *dev, u64 id) struct dfl_feature *dfl_get_feature_by_id(struct device *dev, u16 id)
{ {
struct dfl_feature_platform_data *pdata = dev_get_platdata(dev); struct dfl_feature_platform_data *pdata = dev_get_platdata(dev);
struct dfl_feature *feature; struct dfl_feature *feature;
...@@ -378,7 +378,7 @@ struct dfl_feature *dfl_get_feature_by_id(struct device *dev, u64 id) ...@@ -378,7 +378,7 @@ struct dfl_feature *dfl_get_feature_by_id(struct device *dev, u64 id)
} }
static inline static inline
void __iomem *dfl_get_feature_ioaddr_by_id(struct device *dev, u64 id) void __iomem *dfl_get_feature_ioaddr_by_id(struct device *dev, u16 id)
{ {
struct dfl_feature *feature = dfl_get_feature_by_id(dev, id); struct dfl_feature *feature = dfl_get_feature_by_id(dev, id);
...@@ -389,7 +389,7 @@ void __iomem *dfl_get_feature_ioaddr_by_id(struct device *dev, u64 id) ...@@ -389,7 +389,7 @@ void __iomem *dfl_get_feature_ioaddr_by_id(struct device *dev, u64 id)
return NULL; return NULL;
} }
static inline bool is_dfl_feature_present(struct device *dev, u64 id) static inline bool is_dfl_feature_present(struct device *dev, u16 id)
{ {
return !!dfl_get_feature_ioaddr_by_id(dev, id); return !!dfl_get_feature_ioaddr_by_id(dev, id);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment