From patchwork Tue Jun 25 01:19:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Shiji Yang X-Patchwork-Id: 1951850 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=outlook.com header.i=@outlook.com header.a=rsa-sha256 header.s=selector1 header.b=PRP04t0r; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.199.223; helo=ny.mirrors.kernel.org; envelope-from=linux-gpio+bounces-7661-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W7RsS4rbzz1ydW for ; Tue, 25 Jun 2024 11:22:52 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7D6431C213E3 for ; Tue, 25 Jun 2024 01:22:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8AD4414005; Tue, 25 Jun 2024 01:22:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=outlook.com header.i=@outlook.com header.b="PRP04t0r" X-Original-To: linux-gpio@vger.kernel.org Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01olkn2057.outbound.protection.outlook.com [40.92.98.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61A73125C0; Tue, 25 Jun 2024 01:22:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.98.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719278564; cv=fail; b=aWzKQ/XVEvCKRNdM4p7xcE1xwfrciD/lxcv8hBJ0aO0XA2kTGKMktmrIYJWnOuYcxFWp2UDoY/Z0newpuXzwOB7IXD3udi+ORm7xhGytT7VJggctZmc1/CzhqAYReNmZuLVUQNL/GkV79JHAkbvdLOvLr3H1I7UhWP1o7/iBAiQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719278564; c=relaxed/simple; bh=Qasblls7Wx1EPc1Bn+f2i+1jmtYxvgZZV7CNjivZlKA=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=t0e8iCTkaqopC5PRoqjeVm8vTSensIu68TNrkaBTxI2P4rK6PcEN3EG2KKJ/EiLQfMxjhJ9v5p/O6u2kMgkoEKlqHIMVH3PJ6SDYuavvnpfk7OajkLA9acG0a5CkiAHQXcs0fRrJ7UOt13plmgnWgFdFgxqz4n2UDOhZ1mjHlYk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=outlook.com; spf=pass smtp.mailfrom=outlook.com; dkim=pass (2048-bit key) header.d=outlook.com header.i=@outlook.com header.b=PRP04t0r; arc=fail smtp.client-ip=40.92.98.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=outlook.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=outlook.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RrMI8LPct+XnVnxOa1Hhb1UaQh+3dyCkABNi53SD1VEtIm4UvvscQ5UcRs1Dh127GmYP2Zux7LXAKe4X19ypV2SdK/Dp/PB0LAhEwKw0gpKu7cIjn3BxaDTu/PvaiSgehsbneKPnjn0R13JffR+jQyvlwqCuWgrks/Pb/sWT0y4VrQxsN1N2P4FMsTlz13Z1/yNTQVFkatTcs/jWcxkUZH+7E1+f8WnMbK/I/bio4INuP+Pdr1//Df9RvTyRxP1lJ+pDMP2PJS24zqFnkGPpXK226ORp4eb7yLW9UFClVV5D9dgvDT8ysiVqmej7OklJCBwOYLeeLZxtdwSlPDTQ9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lmVDfoWHIWQ1HAmojW4Xd+B30iohYxP0oR4kXaedYso=; b=BdrUtuCwh6a5db1Jv05BsMgjmDbMCe1e5tYxcQTtPRqCedQu1GzSptjan3quEAUz7eQqY1ouWlW9QByWETiiJ5vvSt4ACoNt6mdgu+WNDnSJxm1rWqkiqlhfJquN2bwsGIarQEV4my62x0xPzB6L5fLgS7ZlKJqYSQhIEX55tcg6NtzYrtWoVjED2Upqu2mrwqXAJR3VmH/G0hxou0Yg4D2Tktl9trVPp1aNwPXU87owiq9p1lJgCg4e8iaI9D1RQzN59B6XvOrkj3jnxAmhvKyLlahqxF8TGSKNlEbfRT5/dKV+7R1TRwq+esTckd220GIFeeXqkUrltLDyQL60tA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lmVDfoWHIWQ1HAmojW4Xd+B30iohYxP0oR4kXaedYso=; b=PRP04t0ra28ab+8+03frHUIRLFfv9W+Abr/+9gwjsnF0aw/UCtqqa1TCNcTygHVmNJ6h0vl2lYJaOstt3GZ16m6SgrBy1QfePHf9nKcbwcy/JT1r/sauMpDRIrS71R4rN6LyPwFGmlF7t6EfX09k89tEgS6YW+4EsspZSXNNZbjTv57P0NM6QBlfHy2g6SVnHX7O9D2f259nkM2E9X1RATIqMnK7m/2XbEMajduyBulJ36s767Ll8sSvTxXEE8eA023c11z3IKiH3RBK5a+jLaltVX04igmFO0SiWfxP6aVtg2bGoxxDqgtqJ5FWg1mCPOWRlXIQr2CXigqkxDUJ4A== Received: from TYCP286MB0895.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:77::8) by TY1P286MB3391.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:2ea::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.29; Tue, 25 Jun 2024 01:22:38 +0000 Received: from TYCP286MB0895.JPNP286.PROD.OUTLOOK.COM ([fe80::ad5c:3146:bd0d:f17c]) by TYCP286MB0895.JPNP286.PROD.OUTLOOK.COM ([fe80::ad5c:3146:bd0d:f17c%4]) with mapi id 15.20.7698.025; Tue, 25 Jun 2024 01:22:38 +0000 From: Shiji Yang To: linux-gpio@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Asmaa Mnebhi , Andy Shevchenko , linux-kernel@vger.kernel.org, Shiji Yang , Mark Mentovai , Jonas Gorski , =?utf-8?b?TMOzcsOhbmQgSG9ydsOhdGg=?= Subject: [PATCH] gpio: mmio: do not calculate bgpio_bits via "ngpios" Date: Tue, 25 Jun 2024 09:19:49 +0800 Message-ID: X-Mailer: git-send-email 2.39.2 X-TMN: [1xm748C15vxX+HJp7UMLJHAa7XOeRZOf] X-ClientProxiedBy: JH0PR01CA0159.apcprd01.prod.exchangelabs.com (2603:1096:990:7::8) To TYCP286MB0895.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:77::8) X-Microsoft-Original-Message-ID: <20240625011949.7865-1-yangshiji66@outlook.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCP286MB0895:EE_|TY1P286MB3391:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e9d6ca8-adaf-42f3-297f-08dc94b54d29 X-Microsoft-Antispam: BCL:0;ARA:14566002|461199025|4302099010|440099025|3412199022|1602099009|1710799023; X-Microsoft-Antispam-Message-Info: ZcWu98LG7sI8FtKn+R3SMStLmc3dyOXb8pyKFrx4lTsCGFXY7igu1BS3Fnyo4kJH9cui60AFzEV9K8SaA1hV/dwngHvsr3pJZ2lTMKoyxlfNJrYdeXVUvvOHQUXJbwrEhYeuJHKvkalVmeEXvT+ERZoMqBzzGV4FmsTi9szpzGtCMBIYAZLDDn9eGCeWpPSABF/u8+AHMQgU7XJfxsfwLV40WfFY1PKEB89I/zfBiibCouWtFMo9B0rX2mCIpdKtuRT1GwwF/Mq7sfSQzxfhR9PaYvduqEo6lxa5hn9qQfAQx3qQde5emBdMlWlREsKm37Z+0WulJz0VkF4nlbby6dBPea8ZNYTXn5DOOXclPuZmZZI2Y9MhvHdeZqFXJAV3ksu518PYNMe0+h0NjgOxGLJGgOuSfaIlG5bJILgiBcVuwFqMJtajp9IFK052QfpgXwzeJo/cYMEj49x35lTmzGQzumlVuqOeIDQpL9Y14GEeZSALiZQCTqlu6peTnYME5VCaRg1cjSulkVC5w00zDuoO436rQxyu198T/koWkO0qorjxSF9Ynkmvt5NAlB2mj4+joUOoHV3dem7nDQAjJkJvkkaFn0v5xGnSbaSka/VbKJ0kawPZElV02BbMmypMAghrrvKz8Scadvy4DbG8ttKf55xIlQGSluMEtQfvsXB4S3ECvSMbfuKr+EruLcqlfx5QGGfwFo6TAljr5BjRjQ== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: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htidSJoBUBIMzbAKSDvigWEB6zQm5aHKC+d1kjZ8Hl5B4?= =?utf-8?q?KUEoa5eh8Fk7BVuNPtch3c+KRQHtkNqGmcBc+ni7bMSIDHziOXsfdIAEbR2tXkdxS?= =?utf-8?q?KlQJH+rXwkAnMz9864AVzsRb7Wb4ROSR2kfdZM7BXdyOXVAmoxD46Sz8gBHyELXEP?= =?utf-8?q?D2ZwlYhHqMEKJvK9fRGCvVdQ1HFIOZsacI51XDYtIObaCubsbL6vRw7olwJ5jIJIt?= =?utf-8?q?L+nLtHA3MeKSzxNLy0e44sRoI/PzauNzfGl7Qj14SgZBlhUwXE6QuWuxnAJP1fM73?= =?utf-8?q?FBhMc8CyHeMe09BAl5XgZl6+8Ml2KffOZ732T5NDpZr1K+WzPtpNUq6QBBSKpcdWf?= =?utf-8?q?zuepd4AZWmtwuz++A?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e9d6ca8-adaf-42f3-297f-08dc94b54d29 X-MS-Exchange-CrossTenant-AuthSource: TYCP286MB0895.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2024 01:22:38.7403 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY1P286MB3391 bgpio_bits must be aligned with the data bus width. For example, on a 32 bit big endian system and we only have 16 GPIOs. If we only assume bgpio_bits=16 we can never control the GPIO because the base address is the lowest address. low address high address ------------------------------------------------- | byte3 | byte2 | byte1 | byte0 | ------------------------------------------------- | NaN | NaN | gpio8-15 | gpio0-7 | ------------------------------------------------- Fixes: 55b2395e4e92 ("gpio: mmio: handle "ngpios" properly in bgpio_init()") Fixes: https://github.com/openwrt/openwrt/issues/15739 Reported-by: Mark Mentovai Signed-off-by: Shiji Yang Suggested-By: Mark Mentovai Reviewed-by: Jonas Gorski Tested-by: Lóránd Horváth Reviewed-by: Linus Walleij --- drivers/gpio/gpio-mmio.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c index 71e1af7c2184..d89e78f0ead3 100644 --- a/drivers/gpio/gpio-mmio.c +++ b/drivers/gpio/gpio-mmio.c @@ -619,8 +619,6 @@ int bgpio_init(struct gpio_chip *gc, struct device *dev, ret = gpiochip_get_ngpios(gc, dev); if (ret) gc->ngpio = gc->bgpio_bits; - else - gc->bgpio_bits = roundup_pow_of_two(round_up(gc->ngpio, 8)); ret = bgpio_setup_io(gc, dat, set, clr, flags); if (ret)