Skip to content

Commit 5c664ac

Browse files
madalinbucurdavem330
authored andcommitted
soc/qman: add return value to interrupt coalesce changing APIs
Check that the values received by the portal interrupt coalesce change APIs are in range. Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com> Signed-off-by: Roy Pledge <roy.pledge@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 830b61b commit 5c664ac

2 files changed

Lines changed: 32 additions & 9 deletions

File tree

‎drivers/soc/fsl/qbman/qman.c‎

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
#define MAX_IRQNAME 16 /* big enough for "QMan portal %d" */
3737
#define QMAN_POLL_LIMIT 32
3838
#define QMAN_PIRQ_DQRR_ITHRESH 12
39+
#define QMAN_DQRR_IT_MAX 15
40+
#define QMAN_ITP_MAX 0xFFF
3941
#define QMAN_PIRQ_MR_ITHRESH 4
4042
#define QMAN_PIRQ_IPERIOD 100
4143

@@ -727,9 +729,15 @@ static inline void qm_dqrr_vdqcr_set(struct qm_portal *portal, u32 vdqcr)
727729
qm_out(portal, QM_REG_DQRR_VDQCR, vdqcr);
728730
}
729731

730-
static inline void qm_dqrr_set_ithresh(struct qm_portal *portal, u8 ithresh)
732+
static inline int qm_dqrr_set_ithresh(struct qm_portal *portal, u8 ithresh)
731733
{
734+
735+
if (ithresh > QMAN_DQRR_IT_MAX)
736+
return -EINVAL;
737+
732738
qm_out(portal, QM_REG_DQRR_ITR, ithresh);
739+
740+
return 0;
733741
}
734742

735743
/* --- MR API --- */
@@ -1012,13 +1020,20 @@ static inline void put_affine_portal(void)
10121020

10131021
static struct workqueue_struct *qm_portal_wq;
10141022

1015-
void qman_dqrr_set_ithresh(struct qman_portal *portal, u8 ithresh)
1023+
int qman_dqrr_set_ithresh(struct qman_portal *portal, u8 ithresh)
10161024
{
1025+
int res;
1026+
10171027
if (!portal)
1018-
return;
1028+
return -EINVAL;
1029+
1030+
res = qm_dqrr_set_ithresh(&portal->p, ithresh);
1031+
if (res)
1032+
return res;
10191033

1020-
qm_dqrr_set_ithresh(&portal->p, ithresh);
10211034
portal->p.dqrr.ithresh = ithresh;
1035+
1036+
return 0;
10221037
}
10231038
EXPORT_SYMBOL(qman_dqrr_set_ithresh);
10241039

@@ -1036,10 +1051,14 @@ void qman_portal_get_iperiod(struct qman_portal *portal, u32 *iperiod)
10361051
}
10371052
EXPORT_SYMBOL(qman_portal_get_iperiod);
10381053

1039-
void qman_portal_set_iperiod(struct qman_portal *portal, u32 iperiod)
1054+
int qman_portal_set_iperiod(struct qman_portal *portal, u32 iperiod)
10401055
{
1041-
if (portal)
1042-
qm_out(&portal->p, QM_REG_ITPR, iperiod);
1056+
if (!portal || iperiod > QMAN_ITP_MAX)
1057+
return -EINVAL;
1058+
1059+
qm_out(&portal->p, QM_REG_ITPR, iperiod);
1060+
1061+
return 0;
10431062
}
10441063
EXPORT_SYMBOL(qman_portal_set_iperiod);
10451064

‎include/soc/fsl/qman.h‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,8 +1205,10 @@ void qman_dqrr_get_ithresh(struct qman_portal *portal, u8 *ithresh);
12051205
* qman_dqrr_set_ithresh - Set coalesce interrupt threshold
12061206
* @portal: portal to set the new value on
12071207
* @ithresh: new threshold value
1208+
*
1209+
* Returns 0 on success, or a negative error code.
12081210
*/
1209-
void qman_dqrr_set_ithresh(struct qman_portal *portal, u8 ithresh);
1211+
int qman_dqrr_set_ithresh(struct qman_portal *portal, u8 ithresh);
12101212

12111213
/**
12121214
* qman_dqrr_get_iperiod - Get coalesce interrupt period
@@ -1219,7 +1221,9 @@ void qman_portal_get_iperiod(struct qman_portal *portal, u32 *iperiod);
12191221
* qman_dqrr_set_iperiod - Set coalesce interrupt period
12201222
* @portal: portal to set the new value on
12211223
* @ithresh: new period value
1224+
*
1225+
* Returns 0 on success, or a negative error code.
12221226
*/
1223-
void qman_portal_set_iperiod(struct qman_portal *portal, u32 iperiod);
1227+
int qman_portal_set_iperiod(struct qman_portal *portal, u32 iperiod);
12241228

12251229
#endif /* __FSL_QMAN_H */

0 commit comments

Comments
 (0)