Skip to content

Commit 8a5de2d

Browse files
yilunxu1984mfischer
authored andcommitted
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: Xu Yilun <yilun.xu@intel.com> Reviewed-by: Tom Rix <trix@redhat.com> Acked-by: Wu Hao <hao.wu@intel.com> Signed-off-by: Moritz Fischer <mdf@kernel.org>
1 parent e6c013c commit 8a5de2d

3 files changed

Lines changed: 21 additions & 20 deletions

File tree

‎drivers/fpga/dfl-fme-perf.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ struct fme_perf_priv {
148148
struct device *dev;
149149
void __iomem *ioaddr;
150150
struct pmu pmu;
151-
u64 id;
151+
u16 id;
152152

153153
u32 fab_users;
154154
u32 fab_port_id;

‎drivers/fpga/dfl.c‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static const char *dfl_pdata_key_strings[DFL_ID_MAX] = {
5858
*/
5959
struct dfl_dev_info {
6060
const char *name;
61-
u32 dfh_id;
61+
u16 dfh_id;
6262
struct idr id;
6363
enum dfl_fpga_devt_type devt_type;
6464
};
@@ -134,7 +134,7 @@ static enum dfl_id_type feature_dev_id_type(struct platform_device *pdev)
134134
return DFL_ID_MAX;
135135
}
136136

137-
static enum dfl_id_type dfh_id_to_type(u32 id)
137+
static enum dfl_id_type dfh_id_to_type(u16 id)
138138
{
139139
int i;
140140

@@ -454,7 +454,7 @@ struct build_feature_devs_info {
454454
* @nr_irqs: number of irqs of this sub feature.
455455
*/
456456
struct dfl_feature_info {
457-
u64 fid;
457+
u16 fid;
458458
struct resource mmio_res;
459459
void __iomem *ioaddr;
460460
struct list_head node;
@@ -649,7 +649,7 @@ static inline u32 feature_size(void __iomem *start)
649649
return ofst ? ofst : 4096;
650650
}
651651

652-
static u64 feature_id(void __iomem *start)
652+
static u16 feature_id(void __iomem *start)
653653
{
654654
u64 v = readq(start + DFH);
655655
u16 id = FIELD_GET(DFH_ID, v);
@@ -667,7 +667,7 @@ static u64 feature_id(void __iomem *start)
667667
}
668668

669669
static int parse_feature_irqs(struct build_feature_devs_info *binfo,
670-
resource_size_t ofst, u64 fid,
670+
resource_size_t ofst, u16 fid,
671671
unsigned int *irq_base, unsigned int *nr_irqs)
672672
{
673673
void __iomem *base = binfo->ioaddr + ofst;
@@ -713,20 +713,20 @@ static int parse_feature_irqs(struct build_feature_devs_info *binfo,
713713
return 0;
714714
}
715715

716-
dev_dbg(binfo->dev, "feature: 0x%llx, irq_base: %u, nr_irqs: %u\n",
716+
dev_dbg(binfo->dev, "feature: 0x%x, irq_base: %u, nr_irqs: %u\n",
717717
fid, ibase, inr);
718718

719719
if (ibase + inr > binfo->nr_irqs) {
720720
dev_err(binfo->dev,
721-
"Invalid interrupt number in feature 0x%llx\n", fid);
721+
"Invalid interrupt number in feature 0x%x\n", fid);
722722
return -EINVAL;
723723
}
724724

725725
for (i = 0; i < inr; i++) {
726726
virq = binfo->irq_table[ibase + i];
727727
if (virq < 0 || virq > NR_IRQS) {
728728
dev_err(binfo->dev,
729-
"Invalid irq table entry for feature 0x%llx\n",
729+
"Invalid irq table entry for feature 0x%x\n",
730730
fid);
731731
return -EINVAL;
732732
}
@@ -748,7 +748,7 @@ static int parse_feature_irqs(struct build_feature_devs_info *binfo,
748748
static int
749749
create_feature_instance(struct build_feature_devs_info *binfo,
750750
struct dfl_fpga_enum_dfl *dfl, resource_size_t ofst,
751-
resource_size_t size, u64 fid)
751+
resource_size_t size, u16 fid)
752752
{
753753
unsigned int irq_base, nr_irqs;
754754
struct dfl_feature_info *finfo;
@@ -819,9 +819,10 @@ static int parse_feature_fiu(struct build_feature_devs_info *binfo,
819819
struct dfl_fpga_enum_dfl *dfl,
820820
resource_size_t ofst)
821821
{
822-
u32 id, offset;
823-
u64 v;
824822
int ret = 0;
823+
u32 offset;
824+
u16 id;
825+
u64 v;
825826

826827
v = readq(dfl->ioaddr + ofst + DFH);
827828
id = FIELD_GET(DFH_ID, v);
@@ -855,8 +856,8 @@ static int parse_feature_private(struct build_feature_devs_info *binfo,
855856
resource_size_t ofst)
856857
{
857858
if (!binfo->feature_dev) {
858-
dev_err(binfo->dev, "the private feature %llx does not belong to any AFU.\n",
859-
(unsigned long long)feature_id(dfl->ioaddr + ofst));
859+
dev_err(binfo->dev, "the private feature 0x%x does not belong to any AFU.\n",
860+
feature_id(dfl->ioaddr + ofst));
860861
return -EINVAL;
861862
}
862863

@@ -1424,7 +1425,7 @@ static int do_set_irq_trigger(struct dfl_feature *feature, unsigned int idx,
14241425
return 0;
14251426

14261427
feature->irq_ctx[idx].name =
1427-
kasprintf(GFP_KERNEL, "fpga-irq[%u](%s-%llx)", idx,
1428+
kasprintf(GFP_KERNEL, "fpga-irq[%u](%s-%x)", idx,
14281429
dev_name(&pdev->dev), feature->id);
14291430
if (!feature->irq_ctx[idx].name)
14301431
return -ENOMEM;

‎drivers/fpga/dfl.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ int dfl_fpga_check_port_id(struct platform_device *pdev, void *pport_id);
197197
* @id: unique dfl private feature id.
198198
*/
199199
struct dfl_feature_id {
200-
u64 id;
200+
u16 id;
201201
};
202202

203203
/**
@@ -240,7 +240,7 @@ struct dfl_feature_irq_ctx {
240240
*/
241241
struct dfl_feature {
242242
struct platform_device *dev;
243-
u64 id;
243+
u16 id;
244244
int resource_index;
245245
void __iomem *ioaddr;
246246
struct dfl_feature_irq_ctx *irq_ctx;
@@ -365,7 +365,7 @@ struct platform_device *dfl_fpga_inode_to_feature_dev(struct inode *inode)
365365
(feature) < (pdata)->features + (pdata)->num; (feature)++)
366366

367367
static inline
368-
struct dfl_feature *dfl_get_feature_by_id(struct device *dev, u64 id)
368+
struct dfl_feature *dfl_get_feature_by_id(struct device *dev, u16 id)
369369
{
370370
struct dfl_feature_platform_data *pdata = dev_get_platdata(dev);
371371
struct dfl_feature *feature;
@@ -378,7 +378,7 @@ struct dfl_feature *dfl_get_feature_by_id(struct device *dev, u64 id)
378378
}
379379

380380
static inline
381-
void __iomem *dfl_get_feature_ioaddr_by_id(struct device *dev, u64 id)
381+
void __iomem *dfl_get_feature_ioaddr_by_id(struct device *dev, u16 id)
382382
{
383383
struct dfl_feature *feature = dfl_get_feature_by_id(dev, id);
384384

@@ -389,7 +389,7 @@ void __iomem *dfl_get_feature_ioaddr_by_id(struct device *dev, u64 id)
389389
return NULL;
390390
}
391391

392-
static inline bool is_dfl_feature_present(struct device *dev, u64 id)
392+
static inline bool is_dfl_feature_present(struct device *dev, u16 id)
393393
{
394394
return !!dfl_get_feature_ioaddr_by_id(dev, id);
395395
}

0 commit comments

Comments
 (0)