Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756576AbdGXTL3 (ORCPT ); Mon, 24 Jul 2017 15:11:29 -0400 Received: from mail-sn1nam01on0067.outbound.protection.outlook.com ([104.47.32.67]:44920 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756169AbdGXTJL (ORCPT ); Mon, 24 Jul 2017 15:09:11 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: linux-kernel@vger.kernel.org, x86@kernel.org, linux-efi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Borislav Petkov , Andy Lutomirski , Tony Luck , Piotr Luc , Tom Lendacky , Fenghua Yu , Lu Baolu , Reza Arbab , David Howells , Matt Fleming , "Kirill A . Shutemov" , Laura Abbott , Ard Biesheuvel , Andrew Morton , Eric Biederman , Benjamin Herrenschmidt , Paul Mackerras , Konrad Rzeszutek Wilk , Jonathan Corbet , Dave Airlie , Kees Cook , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Arnd Bergmann , Tejun Heo , Christoph Lameter , Brijesh Singh Subject: [RFC Part1 PATCH v3 09/17] resource: Consolidate resource walking code Date: Mon, 24 Jul 2017 14:07:49 -0500 Message-Id: <20170724190757.11278-10-brijesh.singh@amd.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170724190757.11278-1-brijesh.singh@amd.com> References: <20170724190757.11278-1-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: CY4PR04CA0049.namprd04.prod.outlook.com (10.171.243.142) To CY1PR12MB0150.namprd12.prod.outlook.com (10.161.173.20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 89e75ff0-1a33-4ae1-44e3-08d4d2c76009 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:CY1PR12MB0150; X-Microsoft-Exchange-Diagnostics: 1;CY1PR12MB0150;3:Ix3tW+X13igtohQM4EEiTNjTuvosEf8pRN25INYUqLbhHn1BnHO0//z7+tPJTiPAdgbUmX6vKDNjTKLLD1ySrkR4YdC77zwWYAP04w1oUJkg29AoVLq6HWi0BUioqrKaMwXzjzKvdMqvUMP3xjpXUADYx+wi1pMyhTvaur5NFSfyVXQf5uw69Z804pakA2UFJHPs2DaeJ3DYtpDpBvmezgUsECMvwVRj0Z6Gs6M09lqGwbWvvbkso+IBJKwhvp3pRHMyDMpqLk/nBtD3PaL1Ugxqro0Bc6dl2B7hcR5weqb3J9zvzZgq1m0UjaT5e3lA6XubVIRyHl4OdG2KKMpZ0WoMKH1mxLyPJWdXHsK4LtA4NjzqsIV6er+rvLqMjjkG0bK1L3kIUHSddYJKr+0wmdCdGCQdvDZ/9c8cXc8s+avYMt8paRu3oXvOmYwqWukUYcW1uSx8fe0bAWCNKUjfWlcCaJj0fLdQ2UFXn3tTTvaf35/gsVaTTreo3366pz8eIqVfFg4TEucow25rUkj7ArlZOdnlCpTMCu+7yX0xGhb/XUcAkO1rrqFSgKTArjaqzWKfnQiWV30tJZWP0TL5PsIiEseJEiJttJLm3xJk+wIvbMGlGm4y+/R8l4Qsw4hM8YsxYWYFZ+0h+faQ10SJMiNFgiXX0H1s7awTLrZyuL2hT4zkzN3NCzVzKT0bPKkAnmelOwhwTkdnzAu8oaFvWs84EWvcADXEdlJRTNCHhNz52LiLQ4H7nTwn82NBNQYl215XAzZKMHdqhx950xBuBQ== X-MS-TrafficTypeDiagnostic: CY1PR12MB0150: X-Microsoft-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V8M1hV9MEAhLssut1PcWeEpycTH/BjZtLseB7LOTwifb8PtNdqq79zX2Eg0FTumu3I4qYjIpnZmZf1bbBz9xaO X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123564025)(20161123555025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123562025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY1PR12MB0150;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY1PR12MB0150; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY1PR12MB0150;4:AMfmrzxeiaYXmxdvSIDWAw7Gx+R3BRlFB8BnK8tWle?= =?us-ascii?Q?fzZ9Tq6Sf/9O+f4Dt1Hj4qZM5sSXRVhtQsJhypo9TgeR3R4nB5Z+ZP1h0S/b?= =?us-ascii?Q?7Z2s0bzsABu+mKvXBpCzE7VfT202YwKX56EaqsGVe96+RFpusA3KPfE3JRWW?= =?us-ascii?Q?YltpHEjBDRg1NfDLZwvbj0nPwjvaN1xeTjgfM1Cp3PJof51/LUM+OXLzDedr?= =?us-ascii?Q?nLTgjStn+ZJRuSoU+STcw9uoKnTlDG5tl0JEdSnHhChxgQgiT9GPwnV3mMJI?= =?us-ascii?Q?G5OyTAwy5SKuGtpApdE0Xw+D02hyRbuNMp+5de8el+zU8NvmJL6aZWIa9W7Z?= =?us-ascii?Q?cetFddMDW2B5a/VoZo2btyRWhIpGnS/rJckmXdjuWhIK0PjRfuZnY+w+YjJ2?= =?us-ascii?Q?bKzl5vinJq8Rs8zcW9GlYOZblTbmz8LJXH+/hrWI+XHaK2GcjUNTFADi4puC?= =?us-ascii?Q?/6ayznC5KO2oWm4vbU8RiZktR93JaF98vQJ3jqdHeUMHEKDLqGZxx8Rysipt?= =?us-ascii?Q?aPizyvV/IqiBJEmkAHUYdVKmAtFaZThKozNjf2ek1A5AqiLTujBI0bzPf679?= =?us-ascii?Q?GJAHqUD5SOxBdDZSzRwtLuaJDrbsRcGgs03LWtz/2JIeIPRBbkESS3QroOI/?= =?us-ascii?Q?A546sDuK/2r/6BWVJ7JnPb+QLCQCQb0R1glxrTgcIOe9zWTiZrd21e47ZRtg?= =?us-ascii?Q?KcNehOReZ/xv0J3jrVv0WwBeq63KE5jszUqJA2lojPptKuFtJvFtgK1hy/Kw?= =?us-ascii?Q?Qlxdts4LhRxsWywLiEN448gk5byJdeE/8pNKGtz38PDbUMfKbNE9eU3V09es?= =?us-ascii?Q?8sRHNYtVN8qqFFn/CxSvO/54xp8lCZMmiQ8z9Qn8M9ftJYfmGFtF46hP+mdu?= =?us-ascii?Q?nahN4UbIf8zSg+hb0+SMSndQoiLlT0L6VeCo52HkJlOIvccsyfL3px12YFz+?= =?us-ascii?Q?v/Fux8kcKVz2yHggJhWWHs+zkcuAxFsfX9boHscLxoq4jwpGMMrXD64uJF4z?= =?us-ascii?Q?oSDeM9/CBHDMYYi4vn/stS38As9lL6OIlX6hRizztmpZv0esgFHx7nPZaaq0?= =?us-ascii?Q?TvAyS4icrqzwM5g390uzRff4agxAyY1yjhPYxj+VBdncWMZcWI8H6GzpuBQy?= =?us-ascii?Q?w6wpRvTgOIejmsR+ynC5LzD2Xz03reuMaFlWKVb1peVzyqfqchOukp2g9Y99?= =?us-ascii?Q?mZTpXCsrBhuUNBPuF5dISzhFDaHgmKWvDn?= X-Forefront-PRVS: 0378F1E47A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(7370300001)(6009001)(39840400002)(39850400002)(39450400003)(39400400002)(39410400002)(39860400002)(199003)(189002)(4326008)(81156014)(7350300001)(81166006)(50226002)(50466002)(68736007)(36756003)(38730400002)(1076002)(110136004)(53936002)(6116002)(25786009)(48376002)(8676002)(86362001)(305945005)(54906002)(7736002)(2950100002)(6666003)(50986999)(101416001)(47776003)(105586002)(5660300001)(5003940100001)(7416002)(33646002)(106356001)(66066001)(6486002)(7406005)(97736004)(189998001)(3846002)(76176999)(2906002)(53416004)(42186005)(478600001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR12MB0150;H:ubuntu-010236106000.amd.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY1PR12MB0150;23:2Ms+NXqul1RR3m4xGr0298W2FRsNlTxov1QRBpULJ?= =?us-ascii?Q?d4+j4hningZp7+dN2bOYJ0c091Ke1Ys5n/OPb56ERDnqQ5O1h6lWbhUj1mP+?= =?us-ascii?Q?IsWg7emX8e2xUan8MGvcM9EdRndsCAykPJE8e+EQ5/vJzxCmylc57JOkx+EX?= =?us-ascii?Q?wVVl2XFDxsb410l/tYCvAacJArSdnt2sga9kedz44jo3g5v9p1za3Gl3wAs5?= =?us-ascii?Q?UStZ8Lj+WlEYzElapOI4G+BfHDKR0/RV0KFSkhRNz80zoIgVrRX+7WSX4zA9?= =?us-ascii?Q?L1Bq3+1U4jh+LPLMaIZbactq4ZGZQeRDA15gBI377+C8v3JG7C18F9qPuHs3?= =?us-ascii?Q?gkf2rQeHE+WO3no2MHCtDbHZgrnyzs9d5vyNHkolFGa30Ywl6EWVB5YlWQyZ?= =?us-ascii?Q?qSO2MVCDdu9DZAtrA1rs5NHX4z/nkgcFPTdz9wT6SJqXre+fEXwk97zv6XTg?= =?us-ascii?Q?TkoaSlnw5lun8aPzvF1Be35nktEt5xE7cpPPJJg5lmfrvP+emkSmRAlamvIW?= =?us-ascii?Q?VcKP6c82x0KiovVg8+haooQ2YzkmCMebQdWOYiBRm7Xjc63QDqaomywqer84?= =?us-ascii?Q?+tyd/MbITWj9YwyDKjY/3QC9Qly9rMkxoOWwNkRqNTNRpBbytLP84sNEIpmu?= =?us-ascii?Q?/XpjSyyd3Xib9nNaEPcV8KYSKVDwPpCsSoLzBXsweqDJG+xIuDc9dzkmucxm?= =?us-ascii?Q?etcFZOjQaVKKnVsbPRmrdqPbgT4H0ONlyHujSxCZm1JrDPgXnHPjad9oQFC/?= =?us-ascii?Q?bz8d+iMIFVXX5/UzASnrMfzIBB7BKdSgnr/9PW+BVEr6tnKvGS1WMoEmqGWo?= =?us-ascii?Q?YXqQr/V5xXZlI2NxaIHA2aR/XBq9ZaJYLs1WvI8qjwM+yM4b8Xcxq8dkAQOx?= =?us-ascii?Q?KW8II8F2WXqw/bagzdWz9gACv5y40mM3oEbgDF3zI5def+6lAzSPfZ7bbSq7?= =?us-ascii?Q?Zykb4zZtxV6w23e6S1tQt4U+BwUksFl3BRwygMf+WmQhfQowYgpQkmiFaxjN?= =?us-ascii?Q?Kvbuzj4LXiMiDzsjfc0aHytpPvLWszlGHfe3klg7wX6OvzAoewJ0jsqLg10V?= =?us-ascii?Q?RiU/NDnIjLOHOfGy6nQ3+MlQ8C+4tjgIISN8ls0lgkt52ttsSaflV3fhh5ka?= =?us-ascii?Q?pp7puqgC5v+fpFQ+TmXVnYzRHACHn9fMN4LZBy8608zQ7suefqtTnXtLpQKu?= =?us-ascii?Q?BmPSER8nmZRIP1JXBOxvtc7xm/TQCRxevMO4wTuDTPnPYkbQiNI0KKLJTlWv?= =?us-ascii?Q?dZlajqgLCYUnup+qx+U7GNsuCVbbthUozPDcagkGpR9dFeo8dFJKLx5QyoKs?= =?us-ascii?Q?+lxubanNqxnYsXS37Hybes=3D?= X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY1PR12MB0150;6:9SVAAQDxQq5KKjPQvdbsPxUhXinD0gQkyaCVFwpMA6?= =?us-ascii?Q?uExRYbBq2APu+TicjojtUWyJ2/aY5sXRCJAypPhzNxATI89mZnGm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ZkVb4+3+FO8dP4Kv7oAIHhC3v0eiRRQkIVlCINMtgY2?= =?us-ascii?Q?ZYOnc+/27M4V45NZ4+jSzj?= X-Microsoft-Exchange-Diagnostics: 1;CY1PR12MB0150;5:w2utXBdYRwd+bzYeRjEB++UuoG9klRgcc5aVJuSixyqj2worPdIVjpg8Sk/YeCrIu1JfetbshmgpLU2w7jSijs24gPxfBcuimrxIaykRhzmBzQpmQ/PElE8Q4R8LkjIF3CYkiFt1YZZyJJO50iY6s/LX/ekuBXbLYkKj8D54agSwt4rrVmhjKk61B/ij+u+zEZG0vCEdDEN08ar40Qkwo+Fb4/1kGV3MXvTnDCaRHECykwEBVvcmZ98IpUl8sU5vH7uMRChTutcsRljlu10To5K4a1OQukMKnW2g7ew7AO+LEPAgoUvtQXdEvZzEvBO/akKy5DWK/T+5DtOo6umf7bSDOmJUh6xrNpJwj4ua++74BCmrt5Qk4TCVCxwwobGd+OBJQeOQxNm7mCfjDR4ILT9bxphXpJKZ0shTNJVldPz6stE5LJ83LFg7HxvLY6qk+/Y+K//pgmaMMzBS0pi+WjoV2MY+e86T9Zb9J+pODeQVVrLlQS8R+PdizFftxzHv;24:6HHCjgoBC3hs3AUr4rkQHxRtE6dDjxqTsTXm3BgfY2Nu0saDaIW6T4mJAl+TyMaxFs0JR1ZaV10iN4tnUgkKESx+zgjphqeVhqmm/YKvrdU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY1PR12MB0150;7:i7tdoWSNkJe5YDEj/1XCiA7w4bsARHTT8Y8iXzToVxLDgHddGzoD95cb9xinRlpM2OpWnQUblpgD05taLSzQdzAS7lOXK3s1DAE2FkqiIBMJqREtOoVWzgQq/OF78QdB6AJ9P5pMuWsqRVXlCBlX84btJAuTapbI4uxqq2ZlRkMgeTaps2oYpClZ0oszmnSIAvYHnftZYsVVSK/yPodIiAoLgMyG9Klxk/jLfI4EiHPho8pa3ZaDBLt00Lg3DdVgqkUpvH/jfN2DlDAK9KgorPi4wgabItvvt/hn+OZ79Y+bLKobvl4dX2AHO8Mkg9Kx8ao+33Wge6R9sDPqw8dili/9O9DFK03jBfAiSrZsF4LTZ5jWJ0ftvyMKBZdWbnkO+vKf+SkvwQJ/ivWTfRFIRN+pOk2FXhQu0nQUsKpcCPsubZpXWBc8LGqNUPJYpm+3dZO9Nls6lnRWwBC3HyOKrNOuhniQyliwiLRfdZispN5bM3llVRusgTifKRqNz9rehnHN4c0ZfkpB+O2b0MpHY7K1uQ4ssXgJPOr4npwN6W7iHJKcB03X+hczW+dYVWgziSMvaEmd1Ahs9fJd27rINEQNJSX/Dnna2a4HcxtqQ4tJd/TQ2ZJ8mV6TC5DkkdgJFQVc9OQ+O7UBcee1hbpeKPWmzFfhWmAelvUHv6lWCwVbby7Q0zy7JoLNX/3Z/vnIDFaAhhnA1QngS9NVU/Lm7mrRyW8ovO6G/TFMwq2kFK3PCTpNJvuX//wZKPZkPrMVfOoJQwh/XAmbxKRdCNwchotOHbRfIkYsc0gBu0mGKp8= X-Microsoft-Exchange-Diagnostics: 1;CY1PR12MB0150;20:7A6R5mBiQS+rdxCjAz6pIPBie1t2Jqb4tSwbdxt0kUzOmfAyqHzFgNZdQ3Ofapsq96bHVp6sr4efUiupD0AwRtk66V49zLC/+YYdO0rpbsj/syCwFF5i3GfLLoHi46iI9/itBBnYmd3SABYBnkzQaPzBYhXWHtiqLDVGnFyT6RFpGvz2YzUJ2hnW5grwjx+uIcFnaYC0ZmhMl6Jpl5Arb+v2nCUrM3MIESgEsNcBA29H9qBu5Kljixjt3U+Jt3BO X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2017 19:08:30.3096 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0150 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2982 Lines: 112 From: Tom Lendacky The walk_iomem_res_desc(), walk_system_ram_res() and walk_system_ram_range() functions each have much of the same code. Create a new function that consolidates the common code from these functions in one place to reduce the amount of duplicated code. Signed-off-by: Tom Lendacky Signed-off-by: Brijesh Singh --- kernel/resource.c | 53 ++++++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/kernel/resource.c b/kernel/resource.c index 9b5f044..7b20b3e 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -397,9 +397,30 @@ static int find_next_iomem_res(struct resource *res, unsigned long desc, res->start = p->start; if (res->end > p->end) res->end = p->end; + res->desc = p->desc; return 0; } +static int __walk_iomem_res_desc(struct resource *res, unsigned long desc, + bool first_level_children_only, + void *arg, int (*func)(u64, u64, void *)) +{ + u64 orig_end = res->end; + int ret = -1; + + while ((res->start < res->end) && + !find_next_iomem_res(res, desc, first_level_children_only)) { + ret = (*func)(res->start, res->end, arg); + if (ret) + break; + + res->start = res->end + 1; + res->end = orig_end; + } + + return ret; +} + /* * Walks through iomem resources and calls func() with matching resource * ranges. This walks through whole tree and not just first level children. @@ -418,26 +439,12 @@ int walk_iomem_res_desc(unsigned long desc, unsigned long flags, u64 start, u64 end, void *arg, int (*func)(u64, u64, void *)) { struct resource res; - u64 orig_end; - int ret = -1; res.start = start; res.end = end; res.flags = flags; - orig_end = res.end; - - while ((res.start < res.end) && - (!find_next_iomem_res(&res, desc, false))) { - - ret = (*func)(res.start, res.end, arg); - if (ret) - break; - - res.start = res.end + 1; - res.end = orig_end; - } - return ret; + return __walk_iomem_res_desc(&res, desc, false, arg, func); } /* @@ -451,22 +458,13 @@ int walk_system_ram_res(u64 start, u64 end, void *arg, int (*func)(u64, u64, void *)) { struct resource res; - u64 orig_end; - int ret = -1; res.start = start; res.end = end; res.flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; - orig_end = res.end; - while ((res.start < res.end) && - (!find_next_iomem_res(&res, IORES_DESC_NONE, true))) { - ret = (*func)(res.start, res.end, arg); - if (ret) - break; - res.start = res.end + 1; - res.end = orig_end; - } - return ret; + + return __walk_iomem_res_desc(&res, IORES_DESC_NONE, true, + arg, func); } #if !defined(CONFIG_ARCH_HAS_WALK_MEMORY) @@ -508,6 +506,7 @@ static int __is_ram(unsigned long pfn, unsigned long nr_pages, void *arg) { return 1; } + /* * This generic page_is_ram() returns true if specified address is * registered as System RAM in iomem_resource list. -- 2.9.4