Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp623077img; Thu, 28 Feb 2019 05:20:16 -0800 (PST) X-Google-Smtp-Source: AHgI3IZwdeujLWyy6gJXEXaTITXYb3BJyjUqqPVhp7ibxw0vp7tIDR5ssDwjviUlmuiPVC3XEjnp X-Received: by 2002:a65:5142:: with SMTP id g2mr8466137pgq.149.1551360016628; Thu, 28 Feb 2019 05:20:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551360016; cv=none; d=google.com; s=arc-20160816; b=caWrIdOiy2pcLQi/YgiXMJgxKhFdDFG9vitIWBDHHnq6UEv6yNY5tf2az9gb/61Ixe shvWJQMCrVCO0m/n6fSkP2KoPA54r8l9J1X2/b/6gkYCx2LXYGP7GQUS9W9Zg+tC0ZSu UUMNbyuVukjyWltqD/BRv1sN43ZzOZ/FZgarQ07A1arIlSj8hm+EuuZE83/rxjFAG7Nx ZqW8/042QubRe1qmuqjkZiuG7XeXVRhgvLqebm8gggD2mkOgRlK5+9Qqj6nHFPlwq4+x FbtfFpODtAo2MfyZPAV+7ziQe9Ap6MFrfBVXoLBQqLZQg72VVcyJx0x/I6cPbwdiXMCa T4jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=qiKfOEoD7LWvT6XVeHYGuetm6Dw1yMRQvisIUR8he/Q=; b=uMo9uK7Jz/3cUbJ5lTLfp2ce3jBiPPU94+wWRRyp+ggZRvCrul3cXiCOHozB6rSazG p7tJ2CMdaH7N+Xk4VWbYwETA6Fc9UZzRlaydFanfMkPKNInnpzPfUfHkM9FPlwKkw2gB yCTF/JB+re6DrSFu3U0g+dsQZC+abdu3+ezGqzXxfzP/3erl65LoTFCq86yv/7bs+GNS kWtmb9MxJmoy3isyp61I2hy1zgfFh7PVhzXpral7/XFDebVdD8PDmV6y3XuwKhx4OUQW kRxuKg2HzG5co9pQ1sxIskN03emybDrTPHxf7iCVuu9lbWY9Q6ZKjTiqS9tD+ZZiJVmG /Sig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@prevas.se header.s=selector1 header.b=gw8CpdqL; 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 s10si8729308pgp.564.2019.02.28.05.19.52; Thu, 28 Feb 2019 05:20:16 -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=@prevas.se header.s=selector1 header.b=gw8CpdqL; 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 S1732404AbfB1KbG (ORCPT + 99 others); Thu, 28 Feb 2019 05:31:06 -0500 Received: from mail-eopbgr80119.outbound.protection.outlook.com ([40.107.8.119]:56544 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726918AbfB1KbF (ORCPT ); Thu, 28 Feb 2019 05:31:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.se; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qiKfOEoD7LWvT6XVeHYGuetm6Dw1yMRQvisIUR8he/Q=; b=gw8CpdqL/fO8y6rdBy9mQ+HUpeCpQGIfEojTxMObaQE2dtQd+BHhAKnlEg2M0jBH+hXL20zXGqiC1OmRobk4thbZxvaW8L2cxp2ktkB6Y+7Ws9GkWZZWILBzP2tdJF8+Nc7R+68gKmE7rOdI/9n7eZiLzcjKoStecahBOoI+V4o= Received: from VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM (20.178.126.212) by VI1PR10MB0509.EURPRD10.PROD.OUTLOOK.COM (10.167.201.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.16; Thu, 28 Feb 2019 10:30:41 +0000 Received: from VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM ([fe80::d49:d85b:58bf:cd5b]) by VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM ([fe80::d49:d85b:58bf:cd5b%6]) with mapi id 15.20.1643.022; Thu, 28 Feb 2019 10:30:41 +0000 From: Rasmus Villemoes To: Qiang Zhao , Leo Li CC: Scott Wood , "linux-kernel@vger.kernel.org" , Timur Tabi , Rasmus Villemoes Subject: [PATCH 2/4] soc/fsl/qe: qe.c: reduce static memory footprint by 1.7K Thread-Topic: [PATCH 2/4] soc/fsl/qe: qe.c: reduce static memory footprint by 1.7K Thread-Index: AQHUz1CnAOIVCpxVHkiuxkUMgN/E7A== Date: Thu, 28 Feb 2019 10:30:41 +0000 Message-ID: <20190228103026.9566-3-rasmus.villemoes@prevas.dk> References: <338677b2-ef74-2afc-4542-c66f1acdb7e5@prevas.dk> <20190228103026.9566-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20190228103026.9566-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0127.eurprd05.prod.outlook.com (2603:10a6:7:28::14) To VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e3::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Rasmus.Villemoes@prevas.se; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [81.216.59.226] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0fa6443e-1e30-42f0-3f86-08d69d67c9c3 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020);SRVR:VI1PR10MB0509; x-ms-traffictypediagnostic: VI1PR10MB0509: x-microsoft-antispam-prvs: x-forefront-prvs: 0962D394D2 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(136003)(39850400004)(376002)(366004)(346002)(396003)(189003)(199004)(476003)(446003)(11346002)(2616005)(8936002)(44832011)(8976002)(106356001)(42882007)(486006)(68736007)(186003)(50226002)(107886003)(105586002)(54906003)(74482002)(110136005)(316002)(5660300002)(97736004)(1076003)(72206003)(2906002)(52116002)(71190400001)(6486002)(305945005)(478600001)(256004)(71200400001)(53936002)(14444005)(99286004)(6436002)(66066001)(6512007)(6116002)(81156014)(81166006)(102836004)(4326008)(25786009)(6506007)(386003)(26005)(76176011)(7736002)(36756003)(8676002)(14454004)(3846002)(2004002);DIR:OUT;SFP:1102;SCL:1;SRVR:VI1PR10MB0509;H:VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: prevas.se does not designate permitted sender hosts) x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1;VI1PR10MB0509;23:c/tvSpQ1+lKObDsKaK296uh1iKVUeRGa26Pp1BQ?= =?iso-8859-1?Q?CCGx+kx+XsTRy2ucE+br9y2Sm4ZnzSPbKU9HPQpCrJeaj6zdlJcOkJAaPh?= =?iso-8859-1?Q?CZ6bqVQUGBxyJOGyPGPbzzf7AObw3k3XHgwZgTuYxUNpEGYiP2/IV9CYtw?= =?iso-8859-1?Q?0VMjdd7TLY7rP17s1rY6xBmEzyjDca81/obs+bB6jIglm9+g0GWKv2g2s7?= =?iso-8859-1?Q?LP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FGZOE/73J75LFFH+QWTW?= =?iso-8859-1?Q?ezs+AyA554BFnGtA/4oXYmSkR83RCY/GbNXVgnaPzpfLHa7lYkzZAqLQcf?= =?iso-8859-1?Q?g86FcOspuhob+4+QyOgqmym7IyczcKMrrucCk9WM+e1tgpAuahuv6oEnui?= =?iso-8859-1?Q?g/t55bDlwbUCFmQEb+LbLs3hg6vRaOqlTVVjKqYS3HXwtDDFyGfGFIYjxJ?= =?iso-8859-1?Q?7qo/E0qJRQG/FdVSKNNivt/bpJOTG3jPzQ3vP4ckdEBRCX7ElqG+AYnDzG?= =?iso-8859-1?Q?4TSNGlz9/tVsRpDi/u10cSfn7fzAWvNKVL38I8iMeE7OKYDpEYQ=3D=3D?= x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: q/hLy4F0sAld+yopBovsRKuMS9F6X6w2vWe4Q28b2Fo21alVcn88Q6U1iP6IDooJmemxOV2m9bmZoawaZbdWEQZOZrSH7H3S5/PSUCcjLp7c6pKLS7kIY5Tw8dwbUpxBEC5vF5tLYABBJu6gYkifLYQgkCl92onuo/9/NBYkl3UAw3Ntskdn85nON0zkHSBemrNXWWvVKOmImmAiCGVfNabrx0W05xdSTP1vu4noWcYvj6lMvrjV1EWf6+bHuXLynvPlPPw1Fa3YE63aVpCjoZ3yJHsgG+gIlIXgbAW4SBlzy/tBS2Te4GgB7AxAIR4XTJnwddxVR9Tq46TubwsFnuPeW4ZhQ5FXVZmEyw57ePRcPv1IAYborbVItFgfj0uB2FtO1qCiIjEHvV4C7igEG82PQV+ymHjZSn0Uie6UfJI= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 0fa6443e-1e30-42f0-3f86-08d69d67c9c3 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Feb 2019 10:30:40.6278 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB0509 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The current array of struct qe_snum use 256*4 bytes for just keeping track of the free/used state of each index, and the struct layout means there's another 768 bytes of padding. If we just unzip that structure, the array of snum values just use 256 bytes, while the free/inuse state can be tracked in a 32 byte bitmap. So this reduces the .data footprint by 1760 bytes. It also serves as preparation for introducing another DT binding for specifying the snum values. Signed-off-by: Rasmus Villemoes --- drivers/soc/fsl/qe/qe.c | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/drivers/soc/fsl/qe/qe.c b/drivers/soc/fsl/qe/qe.c index 4b6aa6b3b685..9b9737a583ef 100644 --- a/drivers/soc/fsl/qe/qe.c +++ b/drivers/soc/fsl/qe/qe.c @@ -14,6 +14,7 @@ * Free Software Foundation; either version 2 of the License, or (at you= r * option) any later version. */ +#include #include #include #include @@ -43,25 +44,14 @@ static DEFINE_SPINLOCK(qe_lock); DEFINE_SPINLOCK(cmxgcr_lock); EXPORT_SYMBOL(cmxgcr_lock); =20 -/* QE snum state */ -enum qe_snum_state { - QE_SNUM_STATE_USED, - QE_SNUM_STATE_FREE -}; - -/* QE snum */ -struct qe_snum { - u8 num; - enum qe_snum_state state; -}; - /* We allocate this here because it is used almost exclusively for * the communication processor devices. */ struct qe_immap __iomem *qe_immr; EXPORT_SYMBOL(qe_immr); =20 -static struct qe_snum snums[QE_NUM_OF_SNUM]; /* Dynamically allocated SNUM= s */ +static u8 snums[QE_NUM_OF_SNUM]; /* Dynamically allocated SNUMs */ +static DECLARE_BITMAP(snum_state, QE_NUM_OF_SNUM); static unsigned int qe_num_of_snum; =20 static phys_addr_t qebase =3D -1; @@ -308,6 +298,7 @@ static void qe_snums_init(void) }; const u8 *snum_init; =20 + bitmap_zero(snum_state, QE_NUM_OF_SNUM); qe_num_of_snum =3D qe_get_num_of_snums(); =20 if (qe_num_of_snum =3D=3D 76) @@ -315,10 +306,8 @@ static void qe_snums_init(void) else snum_init =3D snum_init_46; =20 - for (i =3D 0; i < qe_num_of_snum; i++) { - snums[i].num =3D snum_init[i]; - snums[i].state =3D QE_SNUM_STATE_FREE; - } + for (i =3D 0; i < qe_num_of_snum; i++) + snums[i] =3D snum_init[i]; } =20 int qe_get_snum(void) @@ -328,12 +317,10 @@ int qe_get_snum(void) int i; =20 spin_lock_irqsave(&qe_lock, flags); - for (i =3D 0; i < qe_num_of_snum; i++) { - if (snums[i].state =3D=3D QE_SNUM_STATE_FREE) { - snums[i].state =3D QE_SNUM_STATE_USED; - snum =3D snums[i].num; - break; - } + i =3D find_first_zero_bit(snum_state, qe_num_of_snum); + if (i < qe_num_of_snum) { + set_bit(i, snum_state); + snum =3D snums[i]; } spin_unlock_irqrestore(&qe_lock, flags); =20 @@ -346,8 +333,8 @@ void qe_put_snum(u8 snum) int i; =20 for (i =3D 0; i < qe_num_of_snum; i++) { - if (snums[i].num =3D=3D snum) { - snums[i].state =3D QE_SNUM_STATE_FREE; + if (snums[i] =3D=3D snum) { + clear_bit(i, snum_state); break; } } --=20 2.20.1