Commit f5a34778 authored by Federico Vaga's avatar Federico Vaga

trigger: always use GFP_ATOMIC on allocation

in_atomic() function should not be used inside a driver, and it does not
guarantee atomic context detection. Following the comment from the
kernel source

/*
 * Are we running in atomic context?  WARNING: this macro cannot
 * always detect atomic context; in particular, it cannot know about
 * held spinlocks in non-preemptible kernels.  Thus it should not be
 * used in the general case to determine whether sleeping is possible.
 * Do not use in_atomic() in driver code.
 */
Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent d7861915
...@@ -291,10 +291,6 @@ static int zfat_arm_trigger(struct zio_ti *ti) ...@@ -291,10 +291,6 @@ static int zfat_arm_trigger(struct zio_ti *ti)
uint32_t dev_mem_off; uint32_t dev_mem_off;
int i, err = 0; int i, err = 0;
struct zio_attribute *ti_zattr = ti->zattr_set.std_zattr; struct zio_attribute *ti_zattr = ti->zattr_set.std_zattr;
gfp_t gfp;
/* if fsm-auto-start is active, we re-allocate at interrupt time */
gfp = in_atomic() ? GFP_ATOMIC : GFP_KERNEL;
dev_dbg(msgdev, "Arming trigger\n"); dev_dbg(msgdev, "Arming trigger\n");
...@@ -316,8 +312,12 @@ static int zfat_arm_trigger(struct zio_ti *ti) ...@@ -316,8 +312,12 @@ static int zfat_arm_trigger(struct zio_ti *ti)
return -EINVAL; return -EINVAL;
} }
/* Allocate a new block for DMA transfer */ /*
zfad_block = kmalloc(sizeof(struct zfad_block) * fa->n_shots, gfp); * Allocate a new block for DMA transfer. Sometimes we are in an
* atomic context and we cannot use in_atomic()
*/
zfad_block = kmalloc(sizeof(struct zfad_block) * fa->n_shots,
GFP_ATOMIC);
if (!zfad_block) if (!zfad_block)
return -ENOMEM; return -ENOMEM;
...@@ -347,7 +347,8 @@ static int zfat_arm_trigger(struct zio_ti *ti) ...@@ -347,7 +347,8 @@ static int zfat_arm_trigger(struct zio_ti *ti)
/* Allocate ZIO blocks */ /* Allocate ZIO blocks */
for (i = 0; i < fa->n_shots; ++i) { for (i = 0; i < fa->n_shots; ++i) {
dev_dbg(msgdev, "Allocating block %d ...\n", i); dev_dbg(msgdev, "Allocating block %d ...\n", i);
block = zio_buffer_alloc_block(interleave->bi, size, gfp); block = zio_buffer_alloc_block(interleave->bi, size,
GFP_ATOMIC);
if (!block) { if (!block) {
dev_err(msgdev, dev_err(msgdev,
"\narm trigger fail, cannot allocate block\n"); "\narm trigger fail, cannot allocate block\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment