Commit 52990a5f authored by Jens Axboe's avatar Jens Axboe

block: setup bounce bio_sets properly

We're only setting up the bounce bio sets if we happen
to need bouncing for regular HIGHMEM, not if we only need
it for ISA devices.

Protect the ISA bounce setup with a mutex, since it's
being invoked from driver init functions and can thus be
called in parallel.

Cc: stable@vger.kernel.org
Reported-by: default avatarOndrej Zary <linux@rainbow-software.org>
Tested-by: default avatarOndrej Zary <linux@rainbow-software.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent d459d853
...@@ -31,6 +31,24 @@ ...@@ -31,6 +31,24 @@
static struct bio_set bounce_bio_set, bounce_bio_split; static struct bio_set bounce_bio_set, bounce_bio_split;
static mempool_t page_pool, isa_page_pool; static mempool_t page_pool, isa_page_pool;
static void init_bounce_bioset(void)
{
static bool bounce_bs_setup;
int ret;
if (bounce_bs_setup)
return;
ret = bioset_init(&bounce_bio_set, BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS);
BUG_ON(ret);
if (bioset_integrity_create(&bounce_bio_set, BIO_POOL_SIZE))
BUG_ON(1);
ret = bioset_init(&bounce_bio_split, BIO_POOL_SIZE, 0, 0);
BUG_ON(ret);
bounce_bs_setup = true;
}
#if defined(CONFIG_HIGHMEM) #if defined(CONFIG_HIGHMEM)
static __init int init_emergency_pool(void) static __init int init_emergency_pool(void)
{ {
...@@ -44,14 +62,7 @@ static __init int init_emergency_pool(void) ...@@ -44,14 +62,7 @@ static __init int init_emergency_pool(void)
BUG_ON(ret); BUG_ON(ret);
pr_info("pool size: %d pages\n", POOL_SIZE); pr_info("pool size: %d pages\n", POOL_SIZE);
ret = bioset_init(&bounce_bio_set, BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS); init_bounce_bioset();
BUG_ON(ret);
if (bioset_integrity_create(&bounce_bio_set, BIO_POOL_SIZE))
BUG_ON(1);
ret = bioset_init(&bounce_bio_split, BIO_POOL_SIZE, 0, 0);
BUG_ON(ret);
return 0; return 0;
} }
...@@ -86,6 +97,8 @@ static void *mempool_alloc_pages_isa(gfp_t gfp_mask, void *data) ...@@ -86,6 +97,8 @@ static void *mempool_alloc_pages_isa(gfp_t gfp_mask, void *data)
return mempool_alloc_pages(gfp_mask | GFP_DMA, data); return mempool_alloc_pages(gfp_mask | GFP_DMA, data);
} }
static DEFINE_MUTEX(isa_mutex);
/* /*
* gets called "every" time someone init's a queue with BLK_BOUNCE_ISA * gets called "every" time someone init's a queue with BLK_BOUNCE_ISA
* as the max address, so check if the pool has already been created. * as the max address, so check if the pool has already been created.
...@@ -94,14 +107,20 @@ int init_emergency_isa_pool(void) ...@@ -94,14 +107,20 @@ int init_emergency_isa_pool(void)
{ {
int ret; int ret;
if (mempool_initialized(&isa_page_pool)) mutex_lock(&isa_mutex);
if (mempool_initialized(&isa_page_pool)) {
mutex_unlock(&isa_mutex);
return 0; return 0;
}
ret = mempool_init(&isa_page_pool, ISA_POOL_SIZE, mempool_alloc_pages_isa, ret = mempool_init(&isa_page_pool, ISA_POOL_SIZE, mempool_alloc_pages_isa,
mempool_free_pages, (void *) 0); mempool_free_pages, (void *) 0);
BUG_ON(ret); BUG_ON(ret);
pr_info("isa pool size: %d pages\n", ISA_POOL_SIZE); pr_info("isa pool size: %d pages\n", ISA_POOL_SIZE);
init_bounce_bioset();
mutex_unlock(&isa_mutex);
return 0; return 0;
} }
......
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