dmaengine: idxd: correct reserved token calculation
authorDave Jiang <dave.jiang@intel.com>
Tue, 18 Feb 2020 16:51:58 +0000 (09:51 -0700)
committerVinod Koul <vkoul@kernel.org>
Wed, 19 Feb 2020 09:18:46 +0000 (14:48 +0530)
The calcuation for limit of reserved token did not take into account the
change the user wanted vs the current group reserved token. This causes
changing of the reserved token to be possible only after we set the value
of the reserved token back to 0. Fix calculation so we can set a value that
is non zero for reserved token.

Fixes: c52ca478233c ("dmaengine: idxd: add configuration component of driver")
Reported-by: Jerry Chen <jerry.t.chen@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/158204471889.37789.7749177228265869168.stgit@djiang5-desk3.ch.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/idxd/sysfs.c

index 298855ca934f294f7c12586a9f28a9e7857f001f..edbfe83325eb3c010b51d17f187f9bf427ecd4cf 100644 (file)
@@ -519,7 +519,7 @@ static ssize_t group_tokens_reserved_store(struct device *dev,
        if (val > idxd->max_tokens)
                return -EINVAL;
 
-       if (val > idxd->nr_tokens)
+       if (val > idxd->nr_tokens + group->tokens_reserved)
                return -EINVAL;
 
        group->tokens_reserved = val;