[Accel-config] [PATCH 1/7] accel-config: Skip configuring ats_disable if the attribute is not present
Fenghua Yu <[email protected]> Tue, 1 Aug 2023 14:52:26 -0700
| Newsgroups | dev.linux.lists.accel-config |
|---|---|
| Message-ID | <[email protected]> |
Not every IDXD device supports Address Translation Service (ATS) disable feature. Add the check so the ATS disable attribute can only be written on the IDXD devices that support the feature. Signed-off-by: Fenghua Yu <[email protected]> Reviewed-by: Ramesh Thomas <[email protected]> --- accfg/config.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/accfg/config.c b/accfg/config.c index 08952f8..2631fd9 100644 --- a/accfg/config.c +++ b/accfg/config.c @@ -117,6 +117,7 @@ static const struct group_set_table group_table[] = { static bool is_wq_threshold_writable(struct accfg_wq *wq, int val); static bool is_wq_prs_disable_writable(struct accfg_wq *wq, int val); +static bool is_wq_ats_disable_writable(struct accfg_wq *wq, int val); static const struct wq_set_table wq_table[] = { { "size", accfg_wq_set_size, NULL, NULL, NULL }, @@ -132,7 +133,8 @@ static const struct wq_set_table wq_table[] = { { "max_transfer_size", NULL, accfg_wq_set_max_transfer_size, NULL, NULL }, { "threshold", accfg_wq_set_threshold, NULL, NULL, is_wq_threshold_writable }, - { "ats_disable", accfg_wq_set_ats_disable, NULL, NULL, NULL }, + { "ats_disable", accfg_wq_set_ats_disable, NULL, NULL, + is_wq_ats_disable_writable }, { "prs_disable", accfg_wq_set_prs_disable, NULL, NULL, is_wq_prs_disable_writable }, }; @@ -231,6 +233,17 @@ static bool is_wq_prs_disable_writable(struct accfg_wq *wq, int val) return true; } +static bool is_wq_ats_disable_writable(struct accfg_wq *wq, int val) +{ + if (val < 0 || val > 1) + return false; + + if (accfg_wq_get_ats_disable(wq) < 0) + return false; + + return true; +} + static int device_attribute_filter(char *key) { for (int i = 0; i < (int)ARRAY_SIZE(device_table); i++) { -- 2.31.1