Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3492893imu; Sun, 11 Nov 2018 16:20:17 -0800 (PST) X-Google-Smtp-Source: AJdET5cV4TSUn4aw6q5tL66DX/h8LTfcDCxRYUJ9H0+pV12nH78O8z3SeB0IK+8Ez3D/US7HXTzj X-Received: by 2002:a17:902:aa4b:: with SMTP id c11-v6mr16833969plr.303.1541982017756; Sun, 11 Nov 2018 16:20:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541982017; cv=none; d=google.com; s=arc-20160816; b=b5xrG3DgBo4Aq5NAxXcqUr4sl5lZL4MWFYjlzLnjTBcmsLARSrjo63i8ypw8MZ3h/O gdPpp4C1KkEEKOJ/ufhpj1WB35ah2+g9zRn2OvWygiJT8w00LfjVaJXYeocijbqe8ccK IaX2AoxuiiznXlD5zsBu8E7VCRiv2kYZ5UvuQILxFrgR0o9+0rv5nAPVR3tQIxRUWYlh pLoe3K41VVdDoJpnf8zpQftsqeOu2DXA191NVK4mSscqaQI07uSNRWc9o246HpKywyTz TCRVJmapCl/5Sn1ZqjZAeXdBFRJ+z0xZRz84HMxDKBSPhrLNPKm7gWt+fMno9APR0Dmh gzJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ys4icfM1YEEzjMTrfv+HRptbNdfl8UkS5PMXCdqWnxM=; b=U2YDdL1z9RwM42D03JgctmwXn5akJb8KCgD2HVbVmGpAOGxuq5rIhUxhXMxd7Ts/4M TKegUPcskyl0/W0xbGpU0FVov7CKPIsjNzopl0imBYBOFcak1QlmYCWvQGTo/lE9lTuT eaklVJiEwjJE4uN7jRYk48YzenOgXKlUDaqm5hQHvIufMl/rQP8qh3m7w0Y1RWUM26cY UQCjBUZ0ldbG3+Ea3f2erS5h17goH/rZHdLSu7OLYre+ky7epuL6nO59lZvG7yzNLHeA TAgFKd/QoFE14anYRb0PX2M1FmDe9XezALFoFWGjVzu0Kd+LgAgqlDOruqLRsv/U8qEi bAPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pmrQzHVG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t3-v6si16675318pfa.170.2018.11.11.16.20.02; Sun, 11 Nov 2018 16:20:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pmrQzHVG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729852AbeKLIQy (ORCPT + 99 others); Mon, 12 Nov 2018 03:16:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:58420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729799AbeKLIQx (ORCPT ); Mon, 12 Nov 2018 03:16:53 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 37B7C21722; Sun, 11 Nov 2018 22:26:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975218; bh=6YF1Mp31GPjB7oIjvaY/4UToBPQqrPWM2f+j5xDlg4U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pmrQzHVG3yL5dbZMJNKB4edH04uVFKtB/kuUEQxb48q8ioKyWk53hDd+dg+updNmf oqNlJZHCQuSdIeyEAX20ht0nUy1sKJbr7p0mgU1/agB2xX1K1mRHfRxFZ6S5kf8kbA 5gRTh0cxYE78jbhXTPwdEVykOIOPtxkANuhUbjhQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ondrej Zary , Jens Axboe Subject: [PATCH 4.19 018/361] block: setup bounce bio_sets properly Date: Sun, 11 Nov 2018 14:16:05 -0800 Message-Id: <20181111221622.297660997@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jens Axboe commit 52990a5fb0c991ecafebdab43138b5ed41376852 upstream. 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: Ondrej Zary Tested-by: Ondrej Zary Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- block/bounce.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) --- a/block/bounce.c +++ b/block/bounce.c @@ -31,6 +31,24 @@ static struct bio_set bounce_bio_set, bounce_bio_split; 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) static __init int init_emergency_pool(void) { @@ -44,14 +62,7 @@ static __init int init_emergency_pool(vo BUG_ON(ret); pr_info("pool size: %d pages\n", POOL_SIZE); - 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); - + init_bounce_bioset(); return 0; } @@ -86,6 +97,8 @@ static void *mempool_alloc_pages_isa(gfp 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 * as the max address, so check if the pool has already been created. @@ -94,14 +107,20 @@ int init_emergency_isa_pool(void) { int ret; - if (mempool_initialized(&isa_page_pool)) + mutex_lock(&isa_mutex); + + if (mempool_initialized(&isa_page_pool)) { + mutex_unlock(&isa_mutex); return 0; + } ret = mempool_init(&isa_page_pool, ISA_POOL_SIZE, mempool_alloc_pages_isa, mempool_free_pages, (void *) 0); BUG_ON(ret); pr_info("isa pool size: %d pages\n", ISA_POOL_SIZE); + init_bounce_bioset(); + mutex_unlock(&isa_mutex); return 0; }