From patchwork Mon May 13 11:14:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 10940737 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 A7DBB6C5 for ; Mon, 13 May 2019 11:15:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94F3327C0B for ; Mon, 13 May 2019 11:15:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8655F27CF3; Mon, 13 May 2019 11:15:34 +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=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 34E6927C0B for ; Mon, 13 May 2019 11:15:34 +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=WO6gtgHVZPJMGIKvYnGOn5gDAiEBvv8qzk/SsEYaZ+Y=; b=NWTJB/WLbhs9zA YpjeQoHcau6N5VMDYjNqcMYPlEf2dIpNdNue/TTPg3X1BFS+kU305ves2PHgulWL7NDCxGG763ZUd 4yyqVobl2EeOKdlrGwVDwhVA7CooqgxLZIcoNrYdCdm/YyL1FZkrFVL/RPuuGa6mKlZc0WakKgvQ/ /1LI/fHutbqLKgYBoxZ+B1MzkOHer+s2fNgFfCmid1+1nRYBJ96pNhG9OfYkTNaLUu3jCFehlSWxR OvM3RBPEXgKc2Jh/8dmF19V7JCIS7NNL71LE/HKkYGbzKowyjcWB2DS9B2J+c8brCqEhC+08e9d4/ XWzwumhr5bVvo+hjDpHg==; 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 1hQ8vX-0001kq-JO; Mon, 13 May 2019 11:15:27 +0000 Received: from mail-eopbgr60095.outbound.protection.outlook.com ([40.107.6.95] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQ8v8-00006d-5k for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 11:15:03 +0000 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=D+8Kgzm9ZzUSGh/sqgH4zHXiaGOchvRxgwWj8JNneO4=; b=l9vGglx1dMIFFOzP3xDXscmFb78V0HBmIDxPULOjiEke9vVogpJYFcyPbK/0xtyK6Y2/Cj0Ge6A/kCgPlvYW0aA8Sq344+gbPk5hQsENDP4LrNm2HfQ1sr6EKu4JDt6MPlVg/RXMx9LKSNUmPPrB/yMLIesPp6r5YtmVByWYSVg= Received: from VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM (20.178.126.212) by VI1PR10MB1950.EURPRD10.PROD.OUTLOOK.COM (52.134.27.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1878.24; Mon, 13 May 2019 11:14:54 +0000 Received: from VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM ([fe80::48b8:9cff:182:f3d8]) by VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM ([fe80::48b8:9cff:182:f3d8%2]) with mapi id 15.20.1878.024; Mon, 13 May 2019 11:14:54 +0000 From: Rasmus Villemoes To: "devicetree@vger.kernel.org" , Qiang Zhao , Li Yang Subject: [PATCH v3 1/6] soc/fsl/qe: qe.c: drop useless static qualifier Thread-Topic: [PATCH v3 1/6] soc/fsl/qe: qe.c: drop useless static qualifier Thread-Index: AQHVCX0XqWweYTTW4Ui0pvWYzLl4aw== Date: Mon, 13 May 2019 11:14:54 +0000 Message-ID: <20190513111442.25724-2-rasmus.villemoes@prevas.dk> References: <20190501092841.9026-1-rasmus.villemoes@prevas.dk> <20190513111442.25724-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20190513111442.25724-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0101CA0022.eurprd01.prod.exchangelabs.com (2603:10a6:3:77::32) 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: d8673d95-778f-4240-5171-08d6d79439c2 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020); SRVR:VI1PR10MB1950; x-ms-traffictypediagnostic: VI1PR10MB1950: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:497; x-forefront-prvs: 0036736630 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(39850400004)(366004)(376002)(136003)(396003)(189003)(199004)(6512007)(66066001)(53936002)(107886003)(52116002)(68736007)(256004)(14444005)(71200400001)(71190400001)(76176011)(6436002)(478600001)(4744005)(6486002)(1076003)(36756003)(5660300002)(72206003)(74482002)(446003)(81156014)(8676002)(14454004)(99286004)(2501003)(66946007)(66476007)(66556008)(64756008)(66446008)(73956011)(54906003)(11346002)(2616005)(42882007)(476003)(81166006)(44832011)(50226002)(486006)(8936002)(110136005)(8976002)(6116002)(7416002)(316002)(3846002)(2906002)(305945005)(7736002)(186003)(25786009)(102836004)(6506007)(386003)(4326008)(26005); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB1950; 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-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: fbA/ERyrEYvUSXkEukIoMKq5Xr5HmpRlg9OAIUuBpj4wDPD/Vb1S0rAJVJ2ezzoe+5K30sKDDcQuY7a9stY7FDsBAisT0Kui9kC/o3AtVh/jm+3TvY75+jDxsZt7mwoB5SqHT+Kth1nWjNILh+Tj2gLv2A9HlIQ85ZXTsyw9kyzxQd0oS6c2cUFKRPTWjux0Xdmiz16hvH5tJW3j+aa3Lo7xfWN4z3/z5gk1qh8cwBtJraaPeSh5baHxHJErxXe6iZiiSxjo1PQuBiDAs8n6PA6hg8xAX3oip1c91bW/3Kzf4FI2SlrJ6aszBC+Icipu4HmaMMqYQC+9D15un4ROFzl5VThzA7zSbOsb1YMFSK+grsvpGNq7R9gabnXvOwM5ojMRpLIpqTN0RzklYuknZeEqOYxFHOEKjGPDnnGlByo= MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: d8673d95-778f-4240-5171-08d6d79439c2 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 May 2019 11:14:54.6923 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB1950 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_041502_238423_0F9708FB X-CRM114-Status: GOOD ( 12.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christophe Leroy , Mark Rutland , "linux-kernel@vger.kernel.org" , Scott Wood , Joakim Tjernlund , Rasmus Villemoes , Rob Herring , "linuxppc-dev@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The local variable snum_init has no reason to have static storage duration. Reviewed-by: Christophe Leroy Reviewed-by: Qiang Zhao Signed-off-by: Rasmus Villemoes --- drivers/soc/fsl/qe/qe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/soc/fsl/qe/qe.c b/drivers/soc/fsl/qe/qe.c index 612d9c551be5..855373deb746 100644 --- a/drivers/soc/fsl/qe/qe.c +++ b/drivers/soc/fsl/qe/qe.c @@ -306,7 +306,7 @@ static void qe_snums_init(void) 0x28, 0x29, 0x38, 0x39, 0x48, 0x49, 0x58, 0x59, 0x68, 0x69, 0x78, 0x79, 0x80, 0x81, }; - static const u8 *snum_init; + const u8 *snum_init; qe_num_of_snum = qe_get_num_of_snums(); From patchwork Mon May 13 11:14:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 10940739 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 04C326C5 for ; Mon, 13 May 2019 11:15:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E971C27C0B for ; Mon, 13 May 2019 11:15:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC98627CF3; Mon, 13 May 2019 11:15:47 +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=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 F122327C0B for ; Mon, 13 May 2019 11:15:45 +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=HT/LhrQL1R5bitzUxFknPVBgPYikuhj5DoX8cuuD3R4=; b=kiphPW0AUZf9En 92fpjKzOWp/V8VF53er8fMgYKxzW18ys1LdVq7NNb0CJnz3Fw8UUmvmZLiQzu1ctFN/mWT3Dyp5Wb ROY7pJV8EFGMd0MkMWuu/N0VuLmCQE6JWINzm2WEqxMv+o9yneBOgVQIAm98NFNPsUzM876iWVKGK QhL6LjxwPZMfVK/ZzcJMm5wbtRsjG+/HmIIAYk7f9sg1zYVMRfPKhbJ21VQ0a1WW5GVA/rHKnWIS8 Gcfno6Zcha2YmdJ53QWsmq/lUOTMY7fkW3gI6ItK6bDNhOnqRsjM+fkz1i5yNNuQh/1rhcevDBQbH 3+0dnOA2zdCu+RUIwBTA==; 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 1hQ8vg-00020i-Ir; Mon, 13 May 2019 11:15:36 +0000 Received: from mail-eopbgr60095.outbound.protection.outlook.com ([40.107.6.95] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQ8vA-00006d-3y for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 11:15:10 +0000 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=tQ+Vu1B7o4nUf0HtPMhFACUNFbgaLB1ESmjsz6wJxf4=; b=bzn+jfDWwo8KzGuNTqEElJ4p062d852hqj7JJqiOhHrJiLwa84f6wbS/ztaaT87zfbJiRM0IQkYbHo6O3OJCT2b18dQ6vMbfrwabbOjQO7JNdQLydyjwqCM1/5IFVPLaUkbLdFuTV9BU97x+47+pF+ZiLWW/N57OUiGjmzAT39k= Received: from VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM (20.178.126.212) by VI1PR10MB1950.EURPRD10.PROD.OUTLOOK.COM (52.134.27.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1878.24; Mon, 13 May 2019 11:14:56 +0000 Received: from VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM ([fe80::48b8:9cff:182:f3d8]) by VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM ([fe80::48b8:9cff:182:f3d8%2]) with mapi id 15.20.1878.024; Mon, 13 May 2019 11:14:56 +0000 From: Rasmus Villemoes To: "devicetree@vger.kernel.org" , Qiang Zhao , Li Yang Subject: [PATCH v3 2/6] soc/fsl/qe: qe.c: reduce static memory footprint by 1.7K Thread-Topic: [PATCH v3 2/6] soc/fsl/qe: qe.c: reduce static memory footprint by 1.7K Thread-Index: AQHVCX0YHaTN9I1nZ0mTjY4/MGa+1g== Date: Mon, 13 May 2019 11:14:56 +0000 Message-ID: <20190513111442.25724-3-rasmus.villemoes@prevas.dk> References: <20190501092841.9026-1-rasmus.villemoes@prevas.dk> <20190513111442.25724-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20190513111442.25724-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0101CA0022.eurprd01.prod.exchangelabs.com (2603:10a6:3:77::32) 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: e116e3c1-1d4e-4e3c-9350-08d6d7943a9f x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020); SRVR:VI1PR10MB1950; x-ms-traffictypediagnostic: VI1PR10MB1950: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4941; x-forefront-prvs: 0036736630 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(39850400004)(366004)(376002)(136003)(396003)(189003)(199004)(6512007)(66066001)(53936002)(107886003)(52116002)(68736007)(256004)(14444005)(71200400001)(71190400001)(76176011)(6436002)(478600001)(6486002)(1076003)(36756003)(5660300002)(72206003)(74482002)(446003)(81156014)(8676002)(14454004)(99286004)(2501003)(66946007)(66476007)(66556008)(64756008)(66446008)(73956011)(54906003)(11346002)(2616005)(42882007)(476003)(81166006)(44832011)(50226002)(486006)(8936002)(110136005)(8976002)(6116002)(7416002)(316002)(3846002)(2906002)(305945005)(7736002)(186003)(25786009)(102836004)(6506007)(386003)(4326008)(26005)(2004002); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB1950; 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-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: /MzA1gMzdmwXeo0B+phDTnQTsjVLbVMjknSi9MggE1xlwzbm55Ke8j6v3DuupP7wMJZZaVh8QjSyRPVporVefDeIvQdaUvzFxo0axPtOvbz8flaRqAW67+Prgz8kj/V1f4Y8h57Ky1qwDwKJjMKXr1Yx3l+a01qW/TxUD/Sw0jlFWbTKUckaZ/LNEZ/J/R0EzuGVppLtl/u/2PGS5BrcSXAu1BehUQ3zo+i972bFN+Dt5nLFUQNXYAEo9dFlKN6wydOEioSJ3DU009xx0ATcxkVpcK5hkzt/OVy2kiTnmKz3x/PDDquLd70HgbUPZcngmIAZAeSKShPWus5pJ4Tx6KnjJmUgc1dsrYyEz2jGkxGytJqZ1r81OxMC875S7J8BMF3UleO6I4o3opcqjWYpcbYOIeWA0ZVczDEugbfzGTw= MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: e116e3c1-1d4e-4e3c-9350-08d6d7943a9f X-MS-Exchange-CrossTenant-originalarrivaltime: 13 May 2019 11:14:56.0733 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB1950 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_041504_575279_ACE8DEA8 X-CRM114-Status: GOOD ( 14.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christophe Leroy , Mark Rutland , "linux-kernel@vger.kernel.org" , Scott Wood , Joakim Tjernlund , Rasmus Villemoes , Rob Herring , "linuxppc-dev@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Reviewed-by: Christophe Leroy Reviewed-by: Qiang Zhao Signed-off-by: Rasmus Villemoes --- drivers/soc/fsl/qe/qe.c | 42 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/drivers/soc/fsl/qe/qe.c b/drivers/soc/fsl/qe/qe.c index 855373deb746..4b59109df22b 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 your * 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); -/* 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); -static struct qe_snum snums[QE_NUM_OF_SNUM]; /* Dynamically allocated SNUMs */ +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; static phys_addr_t qebase = -1; @@ -315,10 +305,8 @@ static void qe_snums_init(void) else snum_init = snum_init_46; - for (i = 0; i < qe_num_of_snum; i++) { - snums[i].num = snum_init[i]; - snums[i].state = QE_SNUM_STATE_FREE; - } + bitmap_zero(snum_state, QE_NUM_OF_SNUM); + memcpy(snums, snum_init, qe_num_of_snum); } int qe_get_snum(void) @@ -328,12 +316,10 @@ int qe_get_snum(void) int i; spin_lock_irqsave(&qe_lock, flags); - for (i = 0; i < qe_num_of_snum; i++) { - if (snums[i].state == QE_SNUM_STATE_FREE) { - snums[i].state = QE_SNUM_STATE_USED; - snum = snums[i].num; - break; - } + i = find_first_zero_bit(snum_state, qe_num_of_snum); + if (i < qe_num_of_snum) { + set_bit(i, snum_state); + snum = snums[i]; } spin_unlock_irqrestore(&qe_lock, flags); @@ -343,14 +329,10 @@ EXPORT_SYMBOL(qe_get_snum); void qe_put_snum(u8 snum) { - int i; + const u8 *p = memchr(snums, snum, qe_num_of_snum); - for (i = 0; i < qe_num_of_snum; i++) { - if (snums[i].num == snum) { - snums[i].state = QE_SNUM_STATE_FREE; - break; - } - } + if (p) + clear_bit(p - snums, snum_state); } EXPORT_SYMBOL(qe_put_snum); From patchwork Mon May 13 11:14:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 10940741 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 4741F112C for ; Mon, 13 May 2019 11:15:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3887B27C0B for ; Mon, 13 May 2019 11:15:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CFE127CF3; Mon, 13 May 2019 11:15:51 +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=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 B6FE527C0B for ; Mon, 13 May 2019 11:15:50 +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=L6mPm1baulDn71pTIXJTUg4HbR3FqPIeHbmep+t9ta4=; b=aVbl1q0mOxKdjV No8GeFh/aSYQZrvpbjL1XXvG2lSqRPCTOjPKzmaA4Yy39cgJtJajDHpXi3Wyquvdg4wQ8yLo5BBBn KQoewkKDaNys/Whgki2id4QuJNzhNtHPI9BY+TFfVVOPiSwi/z4wKlu8nV0DXIwnEKZuiNQ7MD1ue 4PQIp55pJ/MKFQ2izKHJSAy3fTKSlzoHCRt3pI0BGsfoZpOaX4qeEVZnOeH1MTdiAsvrq8PJHUEKs Udcrz6HvPYgxdoiYeXON3GUzYs1nw1GwjzvdwWFuIc8B+XseJISQWc4FwRbzf0Wpggsu8Jjy4POW/ 0jetQNklXUpcOSXZXijA==; 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 1hQ8vs-0002KU-KQ; Mon, 13 May 2019 11:15:48 +0000 Received: from mail-eopbgr60095.outbound.protection.outlook.com ([40.107.6.95] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQ8vG-00006d-JW for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 11:15:15 +0000 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=qo+O+Ii8OjvSUslmDWw61z/f9fV+jOgr8GgArqpHKfw=; b=aqkUGtatxVjttxBZ+t+QTNz64cj3yK/rkJ2bzYdu2raifP1n3OhPgAqA3bLGdkwlwv0O977ilpKxz8KFeZQZxC23nfc/s+EFoURG1+ZhclRtFpcA/EFNKOVosKYMhdn69GjLsKidXz5Us7p9WG6BovIYvg8tLMUp1JKSiFDj7PA= Received: from VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM (20.178.126.212) by VI1PR10MB1950.EURPRD10.PROD.OUTLOOK.COM (52.134.27.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1878.24; Mon, 13 May 2019 11:14:57 +0000 Received: from VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM ([fe80::48b8:9cff:182:f3d8]) by VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM ([fe80::48b8:9cff:182:f3d8%2]) with mapi id 15.20.1878.024; Mon, 13 May 2019 11:14:57 +0000 From: Rasmus Villemoes To: "devicetree@vger.kernel.org" , Qiang Zhao , Li Yang Subject: [PATCH v3 3/6] soc/fsl/qe: qe.c: introduce qe_get_device_node helper Thread-Topic: [PATCH v3 3/6] soc/fsl/qe: qe.c: introduce qe_get_device_node helper Thread-Index: AQHVCX0ZmfxjQSeIP0i7kbKp8jFn9w== Date: Mon, 13 May 2019 11:14:57 +0000 Message-ID: <20190513111442.25724-4-rasmus.villemoes@prevas.dk> References: <20190501092841.9026-1-rasmus.villemoes@prevas.dk> <20190513111442.25724-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20190513111442.25724-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0101CA0022.eurprd01.prod.exchangelabs.com (2603:10a6:3:77::32) 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: 1f06e736-9291-4630-cb62-08d6d7943b77 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020); SRVR:VI1PR10MB1950; x-ms-traffictypediagnostic: VI1PR10MB1950: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5516; x-forefront-prvs: 0036736630 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(39850400004)(366004)(376002)(136003)(396003)(189003)(199004)(6512007)(66066001)(53936002)(107886003)(52116002)(68736007)(256004)(71200400001)(71190400001)(76176011)(6436002)(478600001)(6486002)(1076003)(36756003)(5660300002)(72206003)(74482002)(446003)(81156014)(8676002)(14454004)(99286004)(2501003)(66946007)(66476007)(66556008)(64756008)(66446008)(73956011)(54906003)(11346002)(2616005)(42882007)(476003)(81166006)(44832011)(50226002)(486006)(8936002)(110136005)(8976002)(6116002)(7416002)(316002)(3846002)(2906002)(305945005)(7736002)(186003)(25786009)(102836004)(6506007)(386003)(4326008)(26005); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB1950; 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-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: ArtsQHOM0nwZbifYlvn6D8HfGnYeem7j6DNy57LCKPip+6AzhUJnsxVJah7P4pb5hAd9XoOxN+otW3l09psRgWNMGdGYvlmlIezYQXD3TVwuWd2fNh+/F7TjJmMWFXE1JVifDLtuiB8F0I8rJFegC4M/76k/OOwB1bP4kA09j6klALCbOQ6MTi55efL3IjH51MQM8o9z1jeg8CK3uXbAgaWW44zG3+ngTRRgx1j8afZhD1iYMJ4Bk+S2PAQeoBr6swUjmVhmzimQoIytlHd3lS1a1bt3oPLUGnjZA0xfaz7JyBRTwogNgQZX9D8yEEuPuVG86pFofzkT6TB0gZXqlaZIPy+xeHsYpt/HBS/u2lnEQm7Wuh32A+jtX/BS+7NVvgAUW6Be+uqs3gk7WW/twTK+8CgLnrVqBXf6VOhWj9c= MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 1f06e736-9291-4630-cb62-08d6d7943b77 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 May 2019 11:14:57.4903 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB1950 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_041511_068011_46B8C3BC X-CRM114-Status: GOOD ( 14.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christophe Leroy , Mark Rutland , "linux-kernel@vger.kernel.org" , Scott Wood , Joakim Tjernlund , Rasmus Villemoes , Rob Herring , "linuxppc-dev@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The 'try of_find_compatible_node(NULL, NULL, "fsl,qe"), fall back to of_find_node_by_type(NULL, "qe")' pattern is repeated five times. Factor it into a common helper. Reviewed-by: Christophe Leroy Reviewed-by: Qiang Zhao Signed-off-by: Rasmus Villemoes --- drivers/soc/fsl/qe/qe.c | 71 +++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 42 deletions(-) diff --git a/drivers/soc/fsl/qe/qe.c b/drivers/soc/fsl/qe/qe.c index 4b59109df22b..4b444846d590 100644 --- a/drivers/soc/fsl/qe/qe.c +++ b/drivers/soc/fsl/qe/qe.c @@ -56,6 +56,20 @@ static unsigned int qe_num_of_snum; static phys_addr_t qebase = -1; +static struct device_node *qe_get_device_node(void) +{ + struct device_node *qe; + + /* + * Newer device trees have an "fsl,qe" compatible property for the QE + * node, but we still need to support older device trees. + */ + qe = of_find_compatible_node(NULL, NULL, "fsl,qe"); + if (qe) + return qe; + return of_find_node_by_type(NULL, "qe"); +} + static phys_addr_t get_qe_base(void) { struct device_node *qe; @@ -65,12 +79,9 @@ static phys_addr_t get_qe_base(void) if (qebase != -1) return qebase; - qe = of_find_compatible_node(NULL, NULL, "fsl,qe"); - if (!qe) { - qe = of_find_node_by_type(NULL, "qe"); - if (!qe) - return qebase; - } + qe = qe_get_device_node(); + if (!qe) + return qebase; ret = of_address_to_resource(qe, 0, &res); if (!ret) @@ -164,12 +175,9 @@ unsigned int qe_get_brg_clk(void) if (brg_clk) return brg_clk; - qe = of_find_compatible_node(NULL, NULL, "fsl,qe"); - if (!qe) { - qe = of_find_node_by_type(NULL, "qe"); - if (!qe) - return brg_clk; - } + qe = qe_get_device_node(); + if (!qe) + return brg_clk; prop = of_get_property(qe, "brg-frequency", &size); if (prop && size == sizeof(*prop)) @@ -558,16 +566,9 @@ struct qe_firmware_info *qe_get_firmware_info(void) initialized = 1; - /* - * Newer device trees have an "fsl,qe" compatible property for the QE - * node, but we still need to support older device trees. - */ - qe = of_find_compatible_node(NULL, NULL, "fsl,qe"); - if (!qe) { - qe = of_find_node_by_type(NULL, "qe"); - if (!qe) - return NULL; - } + qe = qe_get_device_node(); + if (!qe) + return NULL; /* Find the 'firmware' child node */ fw = of_get_child_by_name(qe, "firmware"); @@ -613,16 +614,9 @@ unsigned int qe_get_num_of_risc(void) unsigned int num_of_risc = 0; const u32 *prop; - qe = of_find_compatible_node(NULL, NULL, "fsl,qe"); - if (!qe) { - /* Older devices trees did not have an "fsl,qe" - * compatible property, so we need to look for - * the QE node by name. - */ - qe = of_find_node_by_type(NULL, "qe"); - if (!qe) - return num_of_risc; - } + qe = qe_get_device_node(); + if (!qe) + return num_of_risc; prop = of_get_property(qe, "fsl,qe-num-riscs", &size); if (prop && size == sizeof(*prop)) @@ -642,16 +636,9 @@ unsigned int qe_get_num_of_snums(void) const u32 *prop; num_of_snums = 28; /* The default number of snum for threads is 28 */ - qe = of_find_compatible_node(NULL, NULL, "fsl,qe"); - if (!qe) { - /* Older devices trees did not have an "fsl,qe" - * compatible property, so we need to look for - * the QE node by name. - */ - qe = of_find_node_by_type(NULL, "qe"); - if (!qe) - return num_of_snums; - } + qe = qe_get_device_node(); + if (!qe) + return num_of_snums; prop = of_get_property(qe, "fsl,qe-num-snums", &size); if (prop && size == sizeof(*prop)) { From patchwork Mon May 13 11:14:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 10940747 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 B71C56C5 for ; Mon, 13 May 2019 11:16:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A922D27C0B for ; Mon, 13 May 2019 11:16:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D44E27CF3; Mon, 13 May 2019 11:16:40 +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=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 4097427C0B for ; Mon, 13 May 2019 11:16:40 +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=ZF1ZayqCP1KDStla7/F7xSuE8J90JuStFZC7PFgIysw=; b=ef7+Ih5bH/TGy3 dM9xGPnvfraBU9yvbse7Lb6VO+nMi8QZHt13RykmQkUAu2y9ZycDe8c4XiJz8kTz9zh5NzboYpFdF Cfp4c+U4Z2pokBpgYHhP0PcLcWDMuHYjyF9JjLt62rJR3uIPI++F0+eKE5XBXflPJN+cvvXtokKJU 1af9vgkaxhd8ANxDesmqqCXkH/2Ad8pwLOo40eeytgC0hHrMJ9ww8TLzr0ARB1kWzKcUHt5IRz2/b SjeVgq2BMq2wfT9Veh7vxl04a8EBcrWf8w4xpZjSDUCQ9A0YhaxYXPqUVtMo0wxEo25DmJmrjHUTs Vm8fdM3gde8ykJFeWpRA==; 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 1hQ8wg-0002tx-2E; Mon, 13 May 2019 11:16:38 +0000 Received: from mail-eopbgr60095.outbound.protection.outlook.com ([40.107.6.95] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQ8vL-00006d-KF for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 11:15:25 +0000 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=sEuej7ss5STPp4OHMYfz0R03yzlH8IWgkfe+AgmlSy8=; b=LeVG7LDnVSxhb+Xq6Q6oyRjQmFim7bMUYbRCiS635BmgwJrqhI25i19OTxHFAOPMQ6bO8rHfbdZeqRkQOYATTbolyd33ctZrIK2TYZW4lRxzuyO1AO74t5PAvy3czD1ChBRIbBdzE65UjIkcJomtj903VpylFPsSgejjVPKOx2w= Received: from VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM (20.178.126.212) by VI1PR10MB1950.EURPRD10.PROD.OUTLOOK.COM (52.134.27.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1878.24; Mon, 13 May 2019 11:14:58 +0000 Received: from VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM ([fe80::48b8:9cff:182:f3d8]) by VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM ([fe80::48b8:9cff:182:f3d8%2]) with mapi id 15.20.1878.024; Mon, 13 May 2019 11:14:58 +0000 From: Rasmus Villemoes To: "devicetree@vger.kernel.org" , Qiang Zhao , Li Yang Subject: [PATCH v3 4/6] dt-bindings: soc/fsl: qe: document new fsl,qe-snums binding Thread-Topic: [PATCH v3 4/6] dt-bindings: soc/fsl: qe: document new fsl,qe-snums binding Thread-Index: AQHVCX0ZXnBvt/NFO0u+76ybHNsHbQ== Date: Mon, 13 May 2019 11:14:58 +0000 Message-ID: <20190513111442.25724-5-rasmus.villemoes@prevas.dk> References: <20190501092841.9026-1-rasmus.villemoes@prevas.dk> <20190513111442.25724-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20190513111442.25724-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0101CA0022.eurprd01.prod.exchangelabs.com (2603:10a6:3:77::32) 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: 2ae9f9da-f716-49b5-d22d-08d6d7943c4a x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020); SRVR:VI1PR10MB1950; x-ms-traffictypediagnostic: VI1PR10MB1950: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2958; x-forefront-prvs: 0036736630 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(39850400004)(366004)(376002)(136003)(396003)(40224003)(52084003)(189003)(199004)(51914003)(6512007)(66066001)(53936002)(107886003)(52116002)(68736007)(256004)(14444005)(71200400001)(71190400001)(76176011)(6436002)(478600001)(6486002)(1076003)(36756003)(5660300002)(72206003)(74482002)(446003)(81156014)(8676002)(14454004)(99286004)(2501003)(66946007)(66476007)(66556008)(64756008)(66446008)(73956011)(54906003)(11346002)(2616005)(42882007)(476003)(81166006)(44832011)(50226002)(486006)(8936002)(110136005)(8976002)(6116002)(7416002)(316002)(3846002)(2906002)(305945005)(7736002)(186003)(25786009)(102836004)(6506007)(386003)(4326008)(26005)(142933001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB1950; 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-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: iY4V8mvoG5SJUI2Hu3/s4cR0ATbU25JjUJY87KCD/Z579idi+L4su6UuQ0Cx3iZODFEeMuECo4maI3ZfHIyrJnmttEnuRsSHUAzbT39sJfeX7Dvvo7N4B232GHOS1clZL4swA7snUAwX8llmHp8IYB+emPUL2C2OeisZsAxIoxg+GtqS7hUylSRUfSykKE3MB1iGBhXQxSyrEph5UX5uR4z1C8ACgChCvQ7p6XEQChZe0kkhMDyqO2YRHcy2XivFCNkrU+CAE4p2MfvUKoLXRgyVxKtFIV4nK4Pn3o7g4s5ao9WpXTVb0w5HA1yMWjLCULwusRRL7et4ErbpE0yoGtA9sgAm5HC+T/f0skwfS64/HUW6tSoW+dUDXmCuIhXBLLWezoZjYGut9AGVmzFA6bptD2hXVnT8YjoL95EAmtU= MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 2ae9f9da-f716-49b5-d22d-08d6d7943c4a X-MS-Exchange-CrossTenant-originalarrivaltime: 13 May 2019 11:14:58.8953 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB1950 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_041515_798533_076A1A3C X-CRM114-Status: GOOD ( 15.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christophe Leroy , Mark Rutland , "linux-kernel@vger.kernel.org" , Scott Wood , Joakim Tjernlund , Rasmus Villemoes , Rob Herring , "linuxppc-dev@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Reading table 4-30, and its footnotes, of the QUICC Engine Block Reference Manual shows that the set of snum _values_ is not necessarily just a function of the _number_ of snums, as given in the fsl,qe-num-snums property. As an alternative, to make it easier to add support for other variants of the QUICC engine IP, this introduces a new binding fsl,qe-snums, which automatically encodes both the number of snums and the actual values to use. Signed-off-by: Rasmus Villemoes Reviewed-by: Rob Herring --- Rob, thanks for the review of v2. However, since I moved the example from the commit log to the binding (per Joakim's request), I didn't add a Reviewed-by tag for this revision. .../devicetree/bindings/soc/fsl/cpm_qe/qe.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe.txt b/Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe.txt index d7afaff5faff..05ec2a838c54 100644 --- a/Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe.txt +++ b/Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe.txt @@ -18,7 +18,8 @@ Required properties: - reg : offset and length of the device registers. - bus-frequency : the clock frequency for QUICC Engine. - fsl,qe-num-riscs: define how many RISC engines the QE has. -- fsl,qe-num-snums: define how many serial number(SNUM) the QE can use for the +- fsl,qe-snums: This property has to be specified as '/bits/ 8' value, + defining the array of serial number (SNUM) values for the virtual threads. Optional properties: @@ -34,6 +35,11 @@ Recommended properties - brg-frequency : the internal clock source frequency for baud-rate generators in Hz. +Deprecated properties +- fsl,qe-num-snums: define how many serial number(SNUM) the QE can use + for the threads. Use fsl,qe-snums instead to not only specify the + number of snums, but also their values. + Example: qe@e0100000 { #address-cells = <1>; @@ -44,6 +50,11 @@ Example: reg = ; brg-frequency = <0>; bus-frequency = <179A7B00>; + fsl,qe-snums = /bits/ 8 < + 0x04 0x05 0x0C 0x0D 0x14 0x15 0x1C 0x1D + 0x24 0x25 0x2C 0x2D 0x34 0x35 0x88 0x89 + 0x98 0x99 0xA8 0xA9 0xB8 0xB9 0xC8 0xC9 + 0xD8 0xD9 0xE8 0xE9>; } * Multi-User RAM (MURAM) From patchwork Mon May 13 11:15:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 10940749 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 A8C206C5 for ; Mon, 13 May 2019 11:16:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 976EE27C0B for ; Mon, 13 May 2019 11:16:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8892B27CF3; Mon, 13 May 2019 11:16:57 +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=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 0D4AA27C0B for ; Mon, 13 May 2019 11:16:57 +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=zEcbGGvJUE02xnOZ8c+qtdjUlai5te+4PuxHrE0d+lc=; b=oV5zD2nG7g1blU ZVLiBgUuZCqvQSgDE3b4J/0ZrKOIVyjzFDpkryOFR6BxuQM9jp21pKYaQCgbHiyBQYbVuPzu7tCCw 7w9hz95BE/F4aPvG2xyI3sG6LuHBtHuEGFYo3kxFYCoU1rfEW9NxXJQvjghMu153XKFf/Z6tz9tYr 80Z1Q9eO0l3V2ZZgV0qoiBU7TP3qabRUoFJydxZMZc54MP1IF0PyfjNjAlj1RPrQml/STwcW/YxYf AlMtdvfDSR0buJSkDeJ/n2FyacPx3uOExvDFS0wNtkikVXU9ZO0etHyQgLC/I4dh5kesu/OjrH/1s +eJzTE0iK0iHJo2FB5Hg==; 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 1hQ8wq-00038v-HY; Mon, 13 May 2019 11:16:48 +0000 Received: from mail-eopbgr60095.outbound.protection.outlook.com ([40.107.6.95] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQ8vV-00006d-CO for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 11:15:30 +0000 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=hFXFaYxZbDf4YVKZ2AuPrr15Glit1zEkKAeApbr5ys0=; b=bH6O7GUIk0a6YuBfsMyJb+HX88KimZLLAxKOsJ8vhs4JqRPD2IfddEkgGnIRfPDg+XfepG3uCE0vi3/3hdazZMScX5f/gKqPnb/eON79SJsLN0gxryE3zelbKV4FE7R91CmSNpdvdzQ1128BURsZTJFbXvZSbWasz/x4Ld3L9w8= Received: from VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM (20.178.126.212) by VI1PR10MB1950.EURPRD10.PROD.OUTLOOK.COM (52.134.27.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1878.24; Mon, 13 May 2019 11:15:00 +0000 Received: from VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM ([fe80::48b8:9cff:182:f3d8]) by VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM ([fe80::48b8:9cff:182:f3d8%2]) with mapi id 15.20.1878.024; Mon, 13 May 2019 11:15:00 +0000 From: Rasmus Villemoes To: "devicetree@vger.kernel.org" , Qiang Zhao , Li Yang Subject: [PATCH v3 5/6] soc/fsl/qe: qe.c: support fsl,qe-snums property Thread-Topic: [PATCH v3 5/6] soc/fsl/qe: qe.c: support fsl,qe-snums property Thread-Index: AQHVCX0azViUEmjOIE6yA42BiGSQgw== Date: Mon, 13 May 2019 11:15:00 +0000 Message-ID: <20190513111442.25724-6-rasmus.villemoes@prevas.dk> References: <20190501092841.9026-1-rasmus.villemoes@prevas.dk> <20190513111442.25724-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20190513111442.25724-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0101CA0022.eurprd01.prod.exchangelabs.com (2603:10a6:3:77::32) 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: ba6d851b-b994-4ae2-98d2-08d6d7943d20 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020); SRVR:VI1PR10MB1950; x-ms-traffictypediagnostic: VI1PR10MB1950: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2399; x-forefront-prvs: 0036736630 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(39850400004)(366004)(376002)(136003)(396003)(189003)(199004)(6512007)(66066001)(53936002)(107886003)(52116002)(68736007)(256004)(71200400001)(71190400001)(76176011)(6436002)(478600001)(6486002)(1076003)(36756003)(5660300002)(72206003)(74482002)(446003)(81156014)(8676002)(14454004)(99286004)(2501003)(66946007)(66476007)(66556008)(64756008)(66446008)(73956011)(54906003)(11346002)(2616005)(42882007)(476003)(81166006)(44832011)(50226002)(486006)(8936002)(110136005)(8976002)(6116002)(7416002)(316002)(3846002)(2906002)(305945005)(7736002)(186003)(25786009)(102836004)(6506007)(386003)(4326008)(26005)(142933001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB1950; 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-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: uJp8v4HOR+DW0xmeKxRc1EOdLFAgYrI0AEqNoNqyhOG6PqFo7qwAU3dytXRXzDPBn4f2FN1iOVNasjvZIY9V65dZyPX+my2KzNnvBdT33X8Km364xW7ISus11ZKTSpAPXmuNKEQUzwfnKukCLd+6y6+3g9P6c5dE0lkM6gMZPp4hBkrwt9nHAeVlU8a6E5t1C4g8HrOr/CsCYxQykV+2E2sNOmKy5m59d50Ugyu0PIm0uKOe8pNLG8xkSYTu8QoYBsLjXlSrVW4z8Nm/5rHOVu+kWRnWe4vwOmJXjLfLY8bWHAcEa5t9S4ctYwE+cjPIsAKXrj8RydZJDOF7q+mFCr+xloUwAiwEOHWlxeJAA3nilTOPHV1iyBRLkhT4AsXe/JtWPgF7AxpTI/ZRuDwDVEOyJjjX5vy57prB1D9QIss= MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: ba6d851b-b994-4ae2-98d2-08d6d7943d20 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 May 2019 11:15:00.2763 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB1950 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_041526_097946_4BFB125F X-CRM114-Status: GOOD ( 15.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christophe Leroy , Mark Rutland , "linux-kernel@vger.kernel.org" , Scott Wood , Joakim Tjernlund , Rasmus Villemoes , Rob Herring , "linuxppc-dev@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add driver support for the newly introduced fsl,qe-snums property. Conveniently, of_property_read_variable_u8_array does exactly what we need: If the property fsl,qe-snums is found (and has an allowed size), the array of values get copied to snums, and the return value is the number of snums - we cannot assign directly to num_of_snums, since we need to check whether the return value is negative. Reviewed-by: Christophe Leroy Reviewed-by: Qiang Zhao Signed-off-by: Rasmus Villemoes --- drivers/soc/fsl/qe/qe.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/soc/fsl/qe/qe.c b/drivers/soc/fsl/qe/qe.c index 4b444846d590..1d27187b251c 100644 --- a/drivers/soc/fsl/qe/qe.c +++ b/drivers/soc/fsl/qe/qe.c @@ -283,7 +283,6 @@ EXPORT_SYMBOL(qe_clock_source); */ static void qe_snums_init(void) { - int i; static const u8 snum_init_76[] = { 0x04, 0x05, 0x0C, 0x0D, 0x14, 0x15, 0x1C, 0x1D, 0x24, 0x25, 0x2C, 0x2D, 0x34, 0x35, 0x88, 0x89, @@ -304,7 +303,21 @@ static void qe_snums_init(void) 0x28, 0x29, 0x38, 0x39, 0x48, 0x49, 0x58, 0x59, 0x68, 0x69, 0x78, 0x79, 0x80, 0x81, }; + struct device_node *qe; const u8 *snum_init; + int i; + + bitmap_zero(snum_state, QE_NUM_OF_SNUM); + qe = qe_get_device_node(); + if (qe) { + i = of_property_read_variable_u8_array(qe, "fsl,qe-snums", + snums, 1, QE_NUM_OF_SNUM); + of_node_put(qe); + if (i > 0) { + qe_num_of_snum = i; + return; + } + } qe_num_of_snum = qe_get_num_of_snums(); @@ -313,7 +326,6 @@ static void qe_snums_init(void) else snum_init = snum_init_46; - bitmap_zero(snum_state, QE_NUM_OF_SNUM); memcpy(snums, snum_init, qe_num_of_snum); } From patchwork Mon May 13 11:15:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 10940745 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 EC0E6112C for ; Mon, 13 May 2019 11:16:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDC9227C0B for ; Mon, 13 May 2019 11:16:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D16B627CF3; Mon, 13 May 2019 11:16:36 +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=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 40AC827C2D for ; Mon, 13 May 2019 11:16:32 +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=gBo1logl/V1CU9ipoHJk/rzPIlMCQiUoIt/IezszufM=; b=ssdCdNJ7hcKySC a3SX8a6+JA06Rxj1Au3ouUX0XEFQ6x8mKdKtxjAlFemfZ1sS9198034DBjdhFURTquPcacifsqj3w +OzoM/0apnrWyMMAfWDrtBVbf9Tt7gD02DZSRhAsK3FeNZBKNA2j9kCGI3FQcsG68uoyb0pxolOnv N//mZKkN36jqbkHX5JHTiCaHIfZslid4KKhmYgk6YEk/tfuGbLiaD/Y3lkvp/MczOnJ6gq8rI3al5 QVXxBi2JtzKofY1W1InEvMMAn872yil64TnC1RTsVU5EUwYfUz8xrgkG0gmL35MhVi50aHAZwUIwf 5iA02bHEV+JcBn+ZkfCw==; 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 1hQ8wW-0002hu-19; Mon, 13 May 2019 11:16:28 +0000 Received: from mail-eopbgr60095.outbound.protection.outlook.com ([40.107.6.95] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hQ8va-00006d-IN for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2019 11:15:47 +0000 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=FLwTavdf2f5v45DlX8rnErmRk2XNba9+SN9MfIcFeaE=; b=rBowXL4LjvL0wsugji/KKaNyLowGb8DUWweNcuEJbTrJlVIyZ31flCrdaz9H6EJRcu/9ixDtmaaNeBzOKVH0fD2xg2Hbx5GzJkOi4PkVgvY5LcCpIhLqxGF5UU6pqzvd01PwAb0Au6oTQKoaJukTxZFEHobl3DNoP21hXBC6Qjs= Received: from VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM (20.178.126.212) by VI1PR10MB1950.EURPRD10.PROD.OUTLOOK.COM (52.134.27.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1878.24; Mon, 13 May 2019 11:15:01 +0000 Received: from VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM ([fe80::48b8:9cff:182:f3d8]) by VI1PR10MB2672.EURPRD10.PROD.OUTLOOK.COM ([fe80::48b8:9cff:182:f3d8%2]) with mapi id 15.20.1878.024; Mon, 13 May 2019 11:15:01 +0000 From: Rasmus Villemoes To: "devicetree@vger.kernel.org" , Qiang Zhao , Li Yang Subject: [PATCH v3 6/6] soc/fsl/qe: qe.c: fold qe_get_num_of_snums into qe_snums_init Thread-Topic: [PATCH v3 6/6] soc/fsl/qe: qe.c: fold qe_get_num_of_snums into qe_snums_init Thread-Index: AQHVCX0bEKLJFUyWYkaQDXSFkv+0GA== Date: Mon, 13 May 2019 11:15:01 +0000 Message-ID: <20190513111442.25724-7-rasmus.villemoes@prevas.dk> References: <20190501092841.9026-1-rasmus.villemoes@prevas.dk> <20190513111442.25724-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20190513111442.25724-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0101CA0022.eurprd01.prod.exchangelabs.com (2603:10a6:3:77::32) 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: 2c56ed77-12be-4613-dc27-08d6d7943df2 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020); SRVR:VI1PR10MB1950; x-ms-traffictypediagnostic: VI1PR10MB1950: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2449; x-forefront-prvs: 0036736630 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(979002)(346002)(39850400004)(366004)(376002)(136003)(396003)(189003)(199004)(6512007)(66066001)(53936002)(107886003)(52116002)(68736007)(256004)(71200400001)(71190400001)(76176011)(6436002)(478600001)(6486002)(1076003)(36756003)(5660300002)(72206003)(74482002)(446003)(81156014)(8676002)(14454004)(99286004)(2501003)(66946007)(66476007)(66556008)(64756008)(66446008)(73956011)(54906003)(11346002)(2616005)(42882007)(476003)(81166006)(44832011)(50226002)(486006)(8936002)(110136005)(8976002)(6116002)(7416002)(316002)(3846002)(2906002)(305945005)(7736002)(186003)(25786009)(102836004)(6506007)(386003)(4326008)(26005)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB1950; 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-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: ae+KoThFXl+AYG5NmiAhCz+jvu73ZiG+fI5e2PZj362uALr9ieKBFc7kPC9sPKMqAAt97IM1457BPaeqr1JD2hZJcuR4TsJ8e8f/SqyOCmhXubQ1/+SYTpzQFV0Fj3avEBHDAKOwXLwk4FXfFHA7eZjWycEw4gjZJ0gh1Aky1Ul4HUnUi2MX8/+H0+VQ16LnMPzB5wpI6wLpoIXKgUujMbbxXRGl62cIzXiPuQKfEfVjD8d8jWQMIOj+REd9EHLG3EIuW9TAK9G2ZDOqbepmQoxCiE+7N09T4bQAonsVXsXiVS5/9rqrSgt3IRqDxkRyleRt+lSOZQO8wm2OomWvj5GThA3DOdbXIY8lLLgOUW1pBeR11aqBWHr8I4XcFofRqT2IdNoiMsQk3nAqN2V8733YYOMVlvhEaeHzd45jC4Q= MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 2c56ed77-12be-4613-dc27-08d6d7943df2 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 May 2019 11:15:01.7434 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB1950 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190513_041531_184052_036F343B X-CRM114-Status: GOOD ( 18.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christophe Leroy , Mark Rutland , "linux-kernel@vger.kernel.org" , Scott Wood , Joakim Tjernlund , Rasmus Villemoes , Rob Herring , "linuxppc-dev@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The comment "No QE ever has fewer than 28 SNUMs" is false; e.g. the MPC8309 has 14. The code path returning -EINVAL is also a recipe for instant disaster, since the caller (qe_snums_init) uncritically assigns the return value to the unsigned qe_num_of_snum, and would thus proceed to attempt to copy 4GB from snum_init_46[] to the snum[] array. So fold the handling of the legacy fsl,qe-num-snums into qe_snums_init, and make sure we do not end up using the snum_init_46 array in cases other than the two where we know it makes sense. Reviewed-by: Christophe Leroy Reviewed-by: Qiang Zhao Signed-off-by: Rasmus Villemoes --- drivers/soc/fsl/qe/qe.c | 46 ++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/drivers/soc/fsl/qe/qe.c b/drivers/soc/fsl/qe/qe.c index 1d27187b251c..852060caff24 100644 --- a/drivers/soc/fsl/qe/qe.c +++ b/drivers/soc/fsl/qe/qe.c @@ -308,24 +308,33 @@ static void qe_snums_init(void) int i; bitmap_zero(snum_state, QE_NUM_OF_SNUM); + qe_num_of_snum = 28; /* The default number of snum for threads is 28 */ qe = qe_get_device_node(); if (qe) { i = of_property_read_variable_u8_array(qe, "fsl,qe-snums", snums, 1, QE_NUM_OF_SNUM); - of_node_put(qe); if (i > 0) { + of_node_put(qe); qe_num_of_snum = i; return; } + /* + * Fall back to legacy binding of using the value of + * fsl,qe-num-snums to choose one of the static arrays + * above. + */ + of_property_read_u32(qe, "fsl,qe-num-snums", &qe_num_of_snum); + of_node_put(qe); } - qe_num_of_snum = qe_get_num_of_snums(); - - if (qe_num_of_snum == 76) + if (qe_num_of_snum == 76) { snum_init = snum_init_76; - else + } else if (qe_num_of_snum == 28 || qe_num_of_snum == 46) { snum_init = snum_init_46; - + } else { + pr_err("QE: unsupported value of fsl,qe-num-snums: %u\n", qe_num_of_snum); + return; + } memcpy(snums, snum_init, qe_num_of_snum); } @@ -642,30 +651,7 @@ EXPORT_SYMBOL(qe_get_num_of_risc); unsigned int qe_get_num_of_snums(void) { - struct device_node *qe; - int size; - unsigned int num_of_snums; - const u32 *prop; - - num_of_snums = 28; /* The default number of snum for threads is 28 */ - qe = qe_get_device_node(); - if (!qe) - return num_of_snums; - - prop = of_get_property(qe, "fsl,qe-num-snums", &size); - if (prop && size == sizeof(*prop)) { - num_of_snums = *prop; - if ((num_of_snums < 28) || (num_of_snums > QE_NUM_OF_SNUM)) { - /* No QE ever has fewer than 28 SNUMs */ - pr_err("QE: number of snum is invalid\n"); - of_node_put(qe); - return -EINVAL; - } - } - - of_node_put(qe); - - return num_of_snums; + return qe_num_of_snum; } EXPORT_SYMBOL(qe_get_num_of_snums);