Re: [PATCH] regmap: Allocate buffers with GFP_ATOMIC when fast_io == true

From: Stephen Boyd
Date: Fri Sep 11 2015 - 12:17:10 EST


On 09/11, Mark Brown wrote:
> On Thu, Sep 10, 2015 at 12:27:01PM -0700, Stephen Boyd wrote:
> > If a regmap is using fast_io, allocate buffers in the write APIs
> > with GFP_ATOMIC instead of GFP_KERNEL. Otherwise we may schedule
> > while atomic.
>
> Why is this needed? If something needs fast I/O it probably doesn't
> want to be going down any of the code paths that result in us doing
> allocations. I'd expect either no cache, a flat cache or setting up
> defaults at initialisation time.

We tripped over this with regmap_bulk_write() users on the SPMI
bus. How about going down the same paths as !map->can_multi_write
and map->use_single_rw if fast_io == true? Something like this
untested patch.

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 29128c6af445..4f2d75527c7f 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -573,8 +573,8 @@ struct regmap *regmap_init(struct device *dev,
map->reg_stride = config->reg_stride;
else
map->reg_stride = 1;
- map->use_single_rw = config->use_single_rw;
- map->can_multi_write = config->can_multi_write;
+ map->use_single_rw = config->use_single_rw || config->fast_io;
+ map->can_multi_write = config->can_multi_write && !config->fast_io;
map->dev = dev;
map->bus = bus;
map->bus_context = bus_context;

--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/