Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3384714imm; Mon, 6 Aug 2018 03:58:39 -0700 (PDT) X-Google-Smtp-Source: AAOMgpej0Er0CM0gvaR5lf3LDsOD/SVXwPzqlE9Kv2M93iSncqooxk4WiVKCPq3t/w3hhWeami48 X-Received: by 2002:a62:4083:: with SMTP id f3-v6mr16544149pfd.229.1533553119043; Mon, 06 Aug 2018 03:58:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533553119; cv=none; d=google.com; s=arc-20160816; b=BTp9h+GN6XBrfCxEJ6LtsYqqCp3/x00w9h78mXokuWdsaWt+9H+Pkp4FFp7kEWIzAn 51IwxkdNOfES9I8TSRzcVeHV2lyN6ROuccuE0TkHhf80zkhb3ymrK37tB/0q8NqsVXyy kLncZnb01omoIBPmv08f3AqXRuldpTHhctx3CSGJ7hTCpJSCjwXsev6zFBqhEDcPl99c 94KeBtAl3ld/RDJqzR7n6M1zqoHRbqSR9Kvubzxj2ZdmRLMV6Cpft5H+YcXTGVlkW2QO ktwtd3ZYUAtChkeb5vMY2+Uom90Q6ahGEzskn1qBI8lwiLJhD0AfAQ4s/Vlldp1HhMF7 IHjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=FlNoTNQMOT4iy/rnXm9Q3ArF/PUrkwkGocJAK1A0JLY=; b=hFP4TWpkrP2QTJfnVJVBpw7pu/hZ9ikpo/vdgvyn/zgajof3hH6U8voxlVZcAImpXW 3kE4kgqb3GtPKaH3OykhLUlgfi4094HkKcZInE6SAmU+UapYWWS7jTRJcZoBq26mRiLn o0wT6xxrHJJefeqDBas4bMxv0obBKmlYazJZaiJ4LAFL2Rg4OC91cQcKMiAwMPJWtSMq y9kh0qeOWizg5W9UDIQ6DXMOwecyMJBLsi4SXNQiT8+xckISgRStU2DF/FeN267BNKZ/ 6kuNSgl+zh5aFCJyQT7IiWV1Qxog2qnQzQi0tIpqL//dk+dWxWOP75gyMaM4BlLFWb77 latw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d35-v6si9607721pla.116.2018.08.06.03.58.24; Mon, 06 Aug 2018 03:58:39 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730349AbeHFNB3 (ORCPT + 99 others); Mon, 6 Aug 2018 09:01:29 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52398 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730229AbeHFNB2 (ORCPT ); Mon, 6 Aug 2018 09:01:28 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w76An5u6147263 for ; Mon, 6 Aug 2018 06:52:58 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2kpkksumm3-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 06 Aug 2018 06:52:58 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 6 Aug 2018 11:52:55 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 6 Aug 2018 11:52:53 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w76AqqvI10420372 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 6 Aug 2018 10:52:52 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD21211C05C; Mon, 6 Aug 2018 13:53:00 +0100 (BST) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6D34711C04A; Mon, 6 Aug 2018 13:52:58 +0100 (BST) Received: from rapoport-lnx (unknown [9.148.8.115]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 6 Aug 2018 13:52:58 +0100 (BST) Received: by rapoport-lnx (sSMTP sendmail emulation); Mon, 06 Aug 2018 13:52:48 +0300 From: Mike Rapoport To: "David S. Miller" Cc: Sam Ravnborg , Michal Hocko , sparclinux@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Rapoport Subject: [PATCH v2 3/3] sparc32: split ramdisk detection and reservation to a helper function Date: Mon, 6 Aug 2018 13:52:35 +0300 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533552755-16679-1-git-send-email-rppt@linux.vnet.ibm.com> References: <1533552755-16679-1-git-send-email-rppt@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18080610-0028-0000-0000-000002E62309 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18080610-0029-0000-0000-0000239E4474 Message-Id: <1533552755-16679-4-git-send-email-rppt@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-08-06_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808060117 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The detection and reservation of ramdisk memory were separated to allow bootmem bitmap initialization after the ramdisk boundaries are detected. Since the bootmem initialization is removed, the reservation of ramdisk memory is done immediately after its boundaries are found. Split the entire block into a separate helper function. Signed-off-by: Mike Rapoport Suggested-by: Sam Ravnborg --- arch/sparc/mm/init_32.c | 56 +++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c index e786fe0..92634d4 100644 --- a/arch/sparc/mm/init_32.c +++ b/arch/sparc/mm/init_32.c @@ -102,6 +102,36 @@ static unsigned long calc_max_low_pfn(void) return tmp; } +static void __init find_ramdisk(unsigned long end_of_phys_memory) +{ +#ifdef CONFIG_BLK_DEV_INITRD + unsigned long size; + + /* Now have to check initial ramdisk, so that it won't pass + * the end of memory + */ + if (sparc_ramdisk_image) { + if (sparc_ramdisk_image >= (unsigned long)&_end - 2 * PAGE_SIZE) + sparc_ramdisk_image -= KERNBASE; + initrd_start = sparc_ramdisk_image + phys_base; + initrd_end = initrd_start + sparc_ramdisk_size; + if (initrd_end > end_of_phys_memory) { + printk(KERN_CRIT "initrd extends beyond end of memory " + "(0x%016lx > 0x%016lx)\ndisabling initrd\n", + initrd_end, end_of_phys_memory); + initrd_start = 0; + } else { + /* Reserve the initrd image area. */ + size = initrd_end - initrd_start; + memblock_reserve(initrd_start, size); + + initrd_start = (initrd_start - phys_base) + PAGE_OFFSET; + initrd_end = (initrd_end - phys_base) + PAGE_OFFSET; + } + } +#endif +} + unsigned long __init bootmem_init(unsigned long *pages_avail) { unsigned long start_pfn, bytes_avail, size; @@ -160,32 +190,8 @@ unsigned long __init bootmem_init(unsigned long *pages_avail) high_pages >> (20 - PAGE_SHIFT)); } -#ifdef CONFIG_BLK_DEV_INITRD - /* Now have to check initial ramdisk, so that it won't pass - * the end of memory - */ - if (sparc_ramdisk_image) { - if (sparc_ramdisk_image >= (unsigned long)&_end - 2 * PAGE_SIZE) - sparc_ramdisk_image -= KERNBASE; - initrd_start = sparc_ramdisk_image + phys_base; - initrd_end = initrd_start + sparc_ramdisk_size; - if (initrd_end > end_of_phys_memory) { - printk(KERN_CRIT "initrd extends beyond end of memory " - "(0x%016lx > 0x%016lx)\ndisabling initrd\n", - initrd_end, end_of_phys_memory); - initrd_start = 0; - } - } - - if (initrd_start) { - /* Reserve the initrd image area. */ - size = initrd_end - initrd_start; - memblock_reserve(initrd_start, size); + find_ramdisk(end_of_phys_memory); - initrd_start = (initrd_start - phys_base) + PAGE_OFFSET; - initrd_end = (initrd_end - phys_base) + PAGE_OFFSET; - } -#endif /* Reserve the kernel text/data/bss. */ size = (start_pfn << PAGE_SHIFT) - phys_base; memblock_reserve(phys_base, size); -- 2.7.4