Commit ea64d1f0 authored by Alessandro Rubini's avatar Alessandro Rubini

bugfix: general: use GFP_ATOMIC for registration-time allocs

Registration of devices is done with a mutex held. as device_attach()
calls device_lock() (in the upstream kernel).

Thus, allocation of minor numbers must use GFP_ATOMIC. Similarly, the
default buffer and the default trigger for a new device being
registered are allocated within the critical section.

The problem also applies when changing a buffer or trigger type
at runtime, because sysfs_write_file() takes a mutex on the file.
Thus, all triggers and buffers are affected.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
Acked-by: 's avatarFederico Vaga <federico.vaga@gmail.com>
parent dc0a2c7b
...@@ -229,7 +229,7 @@ static struct zio_bi *zbk_create(struct zio_buffer_type *zbuf, ...@@ -229,7 +229,7 @@ static struct zio_bi *zbk_create(struct zio_buffer_type *zbuf,
pr_debug("%s:%d\n", __func__, __LINE__); pr_debug("%s:%d\n", __func__, __LINE__);
zbki = kzalloc(sizeof(*zbki), GFP_KERNEL); zbki = kzalloc(sizeof(*zbki), GFP_ATOMIC);
if (!zbki) if (!zbki)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
INIT_LIST_HEAD(&zbki->list); INIT_LIST_HEAD(&zbki->list);
......
...@@ -331,7 +331,7 @@ static struct zio_bi *zbk_create(struct zio_buffer_type *zbuf, ...@@ -331,7 +331,7 @@ static struct zio_bi *zbk_create(struct zio_buffer_type *zbuf,
size = 1024 * zbuf->zattr_set.std_zattr[ZIO_ATTR_ZBUF_MAXKB].value; size = 1024 * zbuf->zattr_set.std_zattr[ZIO_ATTR_ZBUF_MAXKB].value;
zbki = kzalloc(sizeof(*zbki), GFP_KERNEL); zbki = kzalloc(sizeof(*zbki), GFP_ATOMIC);
ffa = zio_ffa_create(0, size); ffa = zio_ffa_create(0, size);
data = vmalloc(size); data = vmalloc(size);
if (!zbki || !ffa || !data) if (!zbki || !ffa || !data)
......
...@@ -158,7 +158,7 @@ int zio_minorbase_get(struct zio_cset *zcset) ...@@ -158,7 +158,7 @@ int zio_minorbase_get(struct zio_cset *zcset)
int nminors = zcset->n_chan * 2; int nminors = zcset->n_chan * 2;
zio_ffa_reset(zstat->minors); /* always start from zero */ zio_ffa_reset(zstat->minors); /* always start from zero */
i = zio_ffa_alloc(zstat->minors, nminors, GFP_KERNEL); i = zio_ffa_alloc(zstat->minors, nminors, GFP_ATOMIC);
if (i == ZIO_FFA_NOSPACE) if (i == ZIO_FFA_NOSPACE)
return -ENOMEM; return -ENOMEM;
zcset->minor = i; zcset->minor = i;
......
...@@ -2300,7 +2300,9 @@ The detailed meaning of the operations is as follows: ...@@ -2300,7 +2300,9 @@ The detailed meaning of the operations is as follows:
(resp. de-associated from) a new cset. @code{create} returns (resp. de-associated from) a new cset. @code{create} returns
a disabled trigger instance structure, which is usually part of a larger a disabled trigger instance structure, which is usually part of a larger
structure, accessed by using structure, accessed by using
@code{container_of}. Please look at existing triggers for details. @code{container_of}. Allocations at create time must be @t{GFP_ATOMIC}
because the kernel holds a mutex when creating a trigger instance.
Please look at existing triggers for details.
@findex push_block @findex push_block
@item push_block @item push_block
...@@ -2465,6 +2467,8 @@ This is the specific role of each method in the structure: ...@@ -2465,6 +2467,8 @@ This is the specific role of each method in the structure:
is usually be part of a bigger structure, accessible using is usually be part of a bigger structure, accessible using
@code{container_of}. If creation @code{container_of}. If creation
fails, the method must return an @t{ERR_PTR} value, not NULL. fails, the method must return an @t{ERR_PTR} value, not NULL.
Allocations at create time must be @t{GFP_ATOMIC}
because the kernel holds a mutex when creating a trigger instance.
@c FIXME: check ERR_PTR use @c FIXME: check ERR_PTR use
@findex alloc_block @findex alloc_block
......
...@@ -220,7 +220,7 @@ static struct zio_ti *ztt_create(struct zio_trigger_type *trig, ...@@ -220,7 +220,7 @@ static struct zio_ti *ztt_create(struct zio_trigger_type *trig,
pr_debug("%s:%d\n", __func__, __LINE__); pr_debug("%s:%d\n", __func__, __LINE__);
ztt = kzalloc(sizeof(struct ztt_instance), GFP_KERNEL); ztt = kzalloc(sizeof(struct ztt_instance), GFP_ATOMIC);
if (!ztt) if (!ztt)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
ti = &ztt->ti; ti = &ztt->ti;
......
...@@ -96,7 +96,7 @@ static struct zio_ti *zti_create(struct zio_trigger_type *trig, ...@@ -96,7 +96,7 @@ static struct zio_ti *zti_create(struct zio_trigger_type *trig,
pr_debug("%s:%d\n", __func__, __LINE__); pr_debug("%s:%d\n", __func__, __LINE__);
ti = kzalloc(sizeof(*ti), GFP_KERNEL); ti = kzalloc(sizeof(*ti), GFP_ATOMIC);
if (!ti) if (!ti)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
ti->flags = ZIO_DISABLED; ti->flags = ZIO_DISABLED;
......
...@@ -163,7 +163,7 @@ static struct zio_ti *ztt_create(struct zio_trigger_type *trig, ...@@ -163,7 +163,7 @@ static struct zio_ti *ztt_create(struct zio_trigger_type *trig,
pr_debug("%s:%d\n", __func__, __LINE__); pr_debug("%s:%d\n", __func__, __LINE__);
ztt = kzalloc(sizeof(struct ztt_instance), GFP_KERNEL); ztt = kzalloc(sizeof(struct ztt_instance), GFP_ATOMIC);
if (!ztt) if (!ztt)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
ti = &ztt->ti; ti = &ztt->ti;
......
...@@ -112,7 +112,7 @@ static struct zio_ti *ztu_create(struct zio_trigger_type *trig, ...@@ -112,7 +112,7 @@ static struct zio_ti *ztu_create(struct zio_trigger_type *trig,
pr_debug("%s:%d\n", __func__, __LINE__); pr_debug("%s:%d\n", __func__, __LINE__);
ti = kzalloc(sizeof(*ti), GFP_KERNEL); ti = kzalloc(sizeof(*ti), GFP_ATOMIC);
if (!ti) if (!ti)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
ti->flags = ZIO_DISABLED; ti->flags = ZIO_DISABLED;
......
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