From patchwork Tue Feb 12 14:01:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 10807983 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 28A30746 for ; Tue, 12 Feb 2019 14:01:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14B582B8F9 for ; Tue, 12 Feb 2019 14:01:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 129632B8FD; Tue, 12 Feb 2019 14:01:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AFD2B2B8F9 for ; Tue, 12 Feb 2019 14:01:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8zE/eOBELY+EYMZ4XZYKvHcwQDaFtAQVTQxMCnLUF3Y=; b=s6TVutiE3q0dsb fXTRYSpfAkglKQCXrG8VHOljnxDZBUF9VpQovna0gJpoc97DL9cSVQyZjzSpnj1Os0nhG+3/BOEvt g0rfNwmjI5IT6Pf/9st9EjR7Qfx9/W6L2R6CECBQ6KWyyEq++1GPPQQ3gAuULuvWwIbmPESo7VVj8 ltSUOxdifU7EWIoEPvUy1YJAaBEhCYeiJL3uKSsdlDZPgPtGR74ceLE4FhZdHaW9/kauXS/CVCOpS vpcP4b03bUAGYuI9h6QnI7OxZM/ocd8/VSLhBk5yAc93gcictOu8sKRNRVxXu4/3RF6bNbW0cVune O8IlqM3LI45DVU3/SHFQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtYcp-0003IN-Qi; Tue, 12 Feb 2019 14:01:27 +0000 Received: from esa5.hgst.iphmx.com ([216.71.153.144]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtYcj-0003HC-Ur for linux-riscv@lists.infradead.org; Tue, 12 Feb 2019 14:01:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1549980082; x=1581516082; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=Sk3fdN0LwxgJvMgUpwPfeV1OJbFU3WDo0eWIv38YgDg=; b=LmZMQhliymK1ZyAvST85OAbumz9+Og/cTs1kuHw1G75CR254bs9YZ/A9 Qk8qc6yXyeHVSLJSVLI4sqWB7Dq0AxV8oF+hXSCJBdn69PFo43gNWksct CAhKNyAiu6oy+dwjdvzkZnsaZlM9wWwxNbZPYYBfIPkNlPDrLyd/+vHtv rJogwAjM+pgYzPwCE711scHzmw82tIOpYPLTK9uwuLAUKH1yaTGZuEdRJ ejJy+T6IeRBD9ev5NFo774+sK0G7xKn06M9nEdiqjV2SZErH8lk/koMyp UVDjhbbKVSbv0mZcTbHdx5W/alvl/u/SG80lZb6G231ecfkfFue2HxznI g==; X-IronPort-AV: E=Sophos;i="5.58,362,1544457600"; d="scan'208";a="102320715" Received: from mail-by2nam05lp2053.outbound.protection.outlook.com (HELO NAM05-BY2-obe.outbound.protection.outlook.com) ([104.47.50.53]) by ob1.hgst.iphmx.com with ESMTP; 12 Feb 2019 22:01:21 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VC6FY+xLOBsl1N4zS/biP8WkZqLwzg471RcMRzpWkXU=; b=I6x34EpOp3qDR06fTudIPiGYjBbFia5plHluaJodwi5IBkvc+UQjfuRBIqsN2DajVjNELlJAFtFXUQvdX3JrQqmc3TwCZvGevU9xaXbtFQGIfqE1Knxgqik+9Su5n49ocwYxs71xLtNCABFfo4lcmWG0uaRWhPguLn5IBbJylCI= Received: from MN2PR04MB6061.namprd04.prod.outlook.com (20.178.247.148) by MN2PR04MB6062.namprd04.prod.outlook.com (20.178.247.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1601.21; Tue, 12 Feb 2019 14:01:19 +0000 Received: from MN2PR04MB6061.namprd04.prod.outlook.com ([fe80::2cdb:c465:af57:8be1]) by MN2PR04MB6061.namprd04.prod.outlook.com ([fe80::2cdb:c465:af57:8be1%7]) with mapi id 15.20.1601.023; Tue, 12 Feb 2019 14:01:19 +0000 From: Anup Patel To: Palmer Dabbelt , Albert Ou Subject: [PATCH v3 6/6] RISC-V: Implement keepinitrd kernel parameter Thread-Topic: [PATCH v3 6/6] RISC-V: Implement keepinitrd kernel parameter Thread-Index: AQHUwtttaGujNBaGJ026ihx5TuVFxQ== Date: Tue, 12 Feb 2019 14:01:19 +0000 Message-ID: <20190212135942.105008-7-anup.patel@wdc.com> References: <20190212135942.105008-1-anup.patel@wdc.com> In-Reply-To: <20190212135942.105008-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MA1PR01CA0126.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:35::20) To MN2PR04MB6061.namprd04.prod.outlook.com (2603:10b6:208:de::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Anup.Patel@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [49.207.48.205] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5e0ec97e-51d9-41a7-fe4a-08d690f28fdd x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(4618075)(2017052603328)(7153060)(7193020); SRVR:MN2PR04MB6062; x-ms-traffictypediagnostic: MN2PR04MB6062: wdcipoutbound: EOP-TRUE x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; MN2PR04MB6062; 23:U8Me1X3UFR5HtADcyV2iC1gFXU+lYon36UqrYry?= =?iso-8859-1?q?/UAnYi/o9H8lLqM?= =?iso-8859-1?q?EY2Ihw3JQd9TXmsRI1lS49iliQ8G+7fP4riv8eLkXJklMH53yk0vcaDjdd14?= =?iso-8859-1?q?TSTMspNUleBReiw1udZT0oDo3SF5kUSsnW+66bZ+OFkoH+nOD2mrv+haq97F?= =?iso-8859-1?q?PJPdsxgGiNpO3+8adWZyDBeORKv8RwDElvrZgc8CJ/rruCi9IhCX88oVAwlI?= =?iso-8859-1?q?pIpIhEqWii3xjUptDNt4U4oMtjNnrDLGBn43ZaLc85TxrIhc05luuZ+v5OcW?= =?iso-8859-1?q?m0iAO1yIaO/EsQm0Fm4yXZKRS1g5TOFnOPx64JcsgPhq3B9pNpG7BK99FzJz?= =?iso-8859-1?q?J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SCo8tiNaIm0IQgp58XzTSjGIlJmr257W84Jp?= =?iso-8859-1?q?S2MpckGCSOvsE/gQ/QQsIuURvjhOMTNkikvFuWWN7JSKLbmg=3D=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 0946DC87A1 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(376002)(346002)(136003)(366004)(396003)(199004)(189003)(8676002)(2906002)(81166006)(86362001)(44832011)(50226002)(2616005)(11346002)(106356001)(446003)(68736007)(316002)(53936002)(476003)(81156014)(76176011)(105586002)(25786009)(486006)(8936002)(14444005)(55236004)(14454004)(6116002)(256004)(4326008)(36756003)(3846002)(71200400001)(71190400001)(102836004)(66066001)(386003)(52116002)(6506007)(99286004)(1076003)(186003)(6512007)(2171002)(54906003)(110136005)(6436002)(7736002)(26005)(72206003)(478600001)(305945005)(6486002)(97736004); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR04MB6062; H:MN2PR04MB6061.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 4X49z4u9GRfKePYOMv6bSyPFVg9Vs1+fxfCAsH0zFHJ5gvgZoL+rpIrqpb8i+ED8C8OV3v4fI0klH6fOe8ira+KDK1TsYnsJxZKI5+qCu+Scz43Or3PDBJMjI0UZYXid6CT65cQI0ereJl3QaE8oBYKK5lGp7Pc062DoJhRX8oM6lPjXwSuNnlq4BdDc8kDyYyyrnt6srUZ3BiKwuLFgygGFbqhZoCyLg13cH02U9/ZQ3nv6hF7iayu64TEUJl/2hj9BLyZ01oEaTzpUes+TpDGGHA0DIpf5TIQQ6B9wbYPcHdaVnIfvJekaB4rEu/zMJ4X8+DMLIB8hm5bT81nUFS38MbT/dVT7yGmfocUiRSDmugys71IpAHCKLIxssQqdjm7zXCAQMPtVkydtJ+DbeNN1hSuGORL0qkPgaUML+c8= MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e0ec97e-51d9-41a7-fe4a-08d690f28fdd X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Feb 2019 14:01:16.5492 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR04MB6062 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190212_060122_128262_2A3E1EC8 X-CRM114-Status: GOOD ( 14.78 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , "linux-kernel@vger.kernel.org" , Christoph Hellwig , Atish Patra , Paul Walmsley , "linux-riscv@lists.infradead.org" Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch implements keepinitrd kernel parameter. By default, keepinitrd=0 so initrd memory will be freed by default freed but users can pass "keepinitrd=1" to keep the initrd memory. The keepinitrd kernel parameter is already implemented by unicore32, arm, and arm64 architectures and it is documented at: Documentation/admin-guide/kernel-parameters.txt Signed-off-by: Anup Patel --- arch/riscv/kernel/setup.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index 9cd583b6d1cd..46e547dd8245 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -97,8 +97,20 @@ static void __init setup_initrd(void) initrd_end = 0; } -void free_initrd_mem(unsigned long start, unsigned long end) +static int keep_initrd __initdata; + +static int __init keepinitrd_setup(char *__unused) +{ + keep_initrd = 1; + return 1; +} + +__setup("keepinitrd", keepinitrd_setup); + +void __init free_initrd_mem(unsigned long start, unsigned long end) { + if (!keep_initrd) + memblock_free(__pa(start), end - start); } #endif /* CONFIG_BLK_DEV_INITRD */