Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dabac7ce authored by Stephen Boyd's avatar Stephen Boyd
Browse files

regmap: Allocate buffers with GFP_ATOMIC when fast_io == true



If a regmap is using fast_io, allocate the scratch buffer in
regmap_bulk_write() with GFP_ATOMIC instead of GFP_KERNEL.
Otherwise we may schedule while atomic.

Change-Id: I45cb1463558e87851dab7a07ba5118cbd6dd4952
Reported-by: default avatarAbhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
parent 3feae538
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ struct regmap {
	regmap_lock lock;
	regmap_unlock unlock;
	void *lock_arg; /* This is passed to lock/unlock functions */
	gfp_t alloc_flags;

	struct device *dev; /* Device we do I/O on */
	void *work_buf;     /* Scratch buffer used to format I/O */
+7 −1
Original line number Diff line number Diff line
@@ -562,6 +562,12 @@ struct regmap *regmap_init(struct device *dev,
		}
		map->lock_arg = map;
	}

	if ((bus && bus->fast_io) || config->fast_io)
		map->alloc_flags = GFP_ATOMIC;
	else
		map->alloc_flags = GFP_KERNEL;

	map->format.reg_bytes = DIV_ROUND_UP(config->reg_bits, 8);
	map->format.pad_bytes = config->pad_bits / 8;
	map->format.val_bytes = DIV_ROUND_UP(config->val_bits, 8);
@@ -1716,7 +1722,7 @@ out:
		if (!val_count)
			return -EINVAL;

		wval = kmemdup(val, val_count * val_bytes, GFP_KERNEL);
		wval = kmemdup(val, val_count * val_bytes, map->alloc_flags);
		if (!wval) {
			dev_err(map->dev, "Error in memory allocation\n");
			return -ENOMEM;