Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp626450rwr; Thu, 4 May 2023 07:40:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Q4XtiUNtKodBiaM3hHO0I/cmUyLCVomdOdok1HjX02WiiJbTgthnwO2ywskExPNT5lv1E X-Received: by 2002:a17:90b:3696:b0:250:5f4:5652 with SMTP id mj22-20020a17090b369600b0025005f45652mr1937442pjb.39.1683211203658; Thu, 04 May 2023 07:40:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1683211203; cv=pass; d=google.com; s=arc-20160816; b=JVXpxaCDT3RdLHIBQaNpaWlQ+pxsOL6TFP1e9Pil+kQ4qlv0xKX4y4yPtw0KDK4VKU 9DhS4moTb850T8up91iOm6PVlGK6w9HAqPyVuGx1w8gDvOjrezElMxZ0vwZl+MYjPwoo NRZ8P6M7KUVV6rK+oZQ1d+v8B8CYzxXmakZNs2JqJOs34JOCWNArlHAhifKbDjNfzzKn yFAgQfReQXS9iySnN/B51tlgOQrrrjAZcagWQVLmYrkFSSCQ8N74Nov2yoMq4PojFvHu astu1z5ugFM4AH06ztCK+dTNZ+uuZIeF/8nNsKgiBkuyyEowJhRymkaUlXBc7i42VbVt YQZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :dkim-signature; bh=Mn8aM/iOlqop1wIUdOpz0u7+SqgKrBcg5DuetY0DXiE=; b=o9lDVdACiIS9u4ShpUQB2vYbNeUOdZWe2JJzAJBXL/lW/D0XpbNN/XwmxtgZoxGM9L Ie0zCFcL6fWR7Cc11LWjXrOmpbOAigpoKxlqKOsEh3wq8F1FteFcsWeOqvmnYmtj1xbh yqK1saehQI2oRamtzKWnCr41cZviNABK8clK6i8aFeedzeomry0nvAm8YpVZcDXG1TC2 cwR3v2O7awNXAzWJ9e/QpG7Zbchy5XbM74j5UwBYiyc59O62T7+y9uM6JoxCoc1yPbsl iR6vPPn2zmFH8F4Hjnzns7YjifCPZHSdNFriuqLFEghLky5ckGl50qkhDtFp0IEAj8c3 1bjw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=oLVFaxLv; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r7-20020a63e507000000b005285958c85bsi25261406pgh.807.2023.05.04.07.39.47; Thu, 04 May 2023 07:40:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=oLVFaxLv; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231126AbjEDOQL (ORCPT + 99 others); Thu, 4 May 2023 10:16:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230424AbjEDOQH (ORCPT ); Thu, 4 May 2023 10:16:07 -0400 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01olkn2080c.outbound.protection.outlook.com [IPv6:2a01:111:f403:704b::80c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3635383FD; Thu, 4 May 2023 07:16:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f387mgaaKU+HiHbHN5SmO/05EhYqlND8GR7Cn6qcVPOdhs0s5xekCyRAWwN5YLAooCoIGzs9m4PYSTqxY82BdcAIkKpoylJ5FISCFwre2tM6FTbaKkPL/NUyDe6qIGCGPHj2s7QWDBvcEH5ZsjtWZg8rVHF2maXkGWGUj95m7qIQq1ADEAbZl9eJ/WGjcArKS8C92hZIVUyTUQuapLifeq9glcy6QH5jk2zbEWevjAA8ANsHE7K+ucod9bjDaytZiBLb915lz9VeN93zLNrZeVu9YR5SLw+BIgmCcMFVvDOmpQXHC8j7QBdVe53B+54r/yuFK5XM1Ze6AnQmmOimyQ== 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=Mn8aM/iOlqop1wIUdOpz0u7+SqgKrBcg5DuetY0DXiE=; b=Qb8E7lzhPYWp+95ngli/UEsMOdivGuYNHURWvNjIhe3drdmUEZE8/sqDhSPVzDLAMBRyLJt3RqGM9mTBw6qzoIwB8Z15b8BvnKSpR8SS9o45AwIoarb7nF94+Ie/zcQKBGFKKlsUVSUDGAUWuIWbUO3T3Pwfm9Wjf0JcRaMurjtDwUvky8eGyfgGMz1OF4NhRAliGobmapOSnfwPU6fpb0CqPqmCjlLo0QK5X0HexnZOoN03SA/4acQlWMdtuLG0wfmPnfXUGTwRkv+EpQvInXVCXeOjRl03cI3mV5P2ZPmTNDNx5Yo6wf0e9aX7uTG4nWszUV1ry8GmxuAlOHzjFg== 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=Mn8aM/iOlqop1wIUdOpz0u7+SqgKrBcg5DuetY0DXiE=; b=oLVFaxLvxcLwAhYrWiEhKbZFZea5uYAz365vu2PRKcXYbrIcPvgjBgEIzl3JliBpa0vDsS46WEFAGk73msjs6gRFAef8scDP6NGHQAXjr+DuMuMy1lpJ6efTkrAdCyFyHrwoETYLfKx8AKA5sQSegSr15KbVoLikDxC/KzVShTO54nOOj6Ln+rZUsrQvDRa7d5MITFIRKmfOAnJkEVcwjLPR1R/LxcIy4tUah7V1D3fodkvPWFV+U9+w+G/zPJuAosClnTcNPLdeRWThLwnaIYib+CAKl/tjJNIwbLvZQkd8lxYYl9Xp9ryw27TO3e5r91Bft9UbN1NSJPwpyKdY3A== Received: from TY0PR01MB5444.apcprd01.prod.exchangelabs.com (2603:1096:400:32b::13) by PSAPR01MB3926.apcprd01.prod.exchangelabs.com (2603:1096:301:23::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.26; Thu, 4 May 2023 14:16:01 +0000 Received: from TY0PR01MB5444.apcprd01.prod.exchangelabs.com ([fe80::3f42:e9a0:b922:882b]) by TY0PR01MB5444.apcprd01.prod.exchangelabs.com ([fe80::3f42:e9a0:b922:882b%7]) with mapi id 15.20.6363.027; Thu, 4 May 2023 14:16:01 +0000 Content-Type: text/plain; charset=utf-8 Subject: Re: [PATCH v2] gpio: gpiolib: clear the array_info's memory space From: Yan Wang In-Reply-To: Date: Thu, 4 May 2023 22:15:57 +0800 Cc: linus.walleij@linaro.org, brgl@bgdev.pl, "open list:GPIO SUBSYSTEM" , open list Content-Transfer-Encoding: quoted-printable Message-ID: References: <202304232146.7M89pwCz-lkp@intel.com> To: Andy Shevchenko X-Mailer: Apple Mail (2.3696.120.41.1.2) X-TMN: [Pzso/XucFW6dDeewCU4AbMNLPkl68h0K] X-ClientProxiedBy: TY2PR02CA0052.apcprd02.prod.outlook.com (2603:1096:404:e2::16) To TY0PR01MB5444.apcprd01.prod.exchangelabs.com (2603:1096:400:32b::13) X-Microsoft-Original-Message-ID: <553231DF-FCE4-4DBF-A9EB-48D3EA5B1F9A@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TY0PR01MB5444:EE_|PSAPR01MB3926:EE_ X-MS-Office365-Filtering-Correlation-Id: ade3c397-a6c6-4564-54c4-08db4caa1681 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yUrGKgbvctuT7+s6ERSW7LpWNtG2CB8vFkQ1FLnJgMdOYbVVqZ8+dafxGZsjwhS+yXqoGFeBvQjT1OKztrB0OmE/MiM4OMOzRsX+gSIfuUpa/W8PxHfrT3yD+h9nPr/oh7tYO8GlXIC5B7EVAB0QGP4JheWBAvW1ImWd8FrTkA0WrCVK91L+E2k+7cyD/OEkFoZYUkAPtWWdZVe7WrPDjGOfLs4xRJBzUI+EZFDoK4Y1wS4KIbE5P9zTd1Rs2tnODvHNNjyCyXI2OKJdBOQH/BG3QVhxF0Bv5uK4rEJ0giUhvBDhRc5jISMwwZ0HH7BHL5K0AXGvO2TsJTmw7tRXy9EsLADzJ+ZQrwzK9IWxFwlMYIRofCeOxcWvXphAZuS5PNWhTOVxzr9waCiBfuDiYeV6eGFm5US6S4fYwntNS/W6DjJGBob+So9iT+bIsLy+40i8q8N422L0IALw2KcXaduyz8Vg89dLBe+uug4Rt4MDjQbyTKnC5X2OWURFlvXxog8HPdV5CXvViMagPOBLLqIZd/6357Z7buq3KJi3AH0cBL4pwfKDLUdaYKKB6+/gIWM9LxGnDb6PXq9pqF0MTXPeRVsxziLBUQbchg4/558= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?blFWTUdjZUtVeWg5N25GRlpJK0pKUVVBOWs1N2tlajhKM2xsOUtsTGhhdWJY?= =?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UydW9yUm1PT0xMdXFpMkx0cXBiekI0K216?= =?utf-8?B?aVcyMnpOZHBENEFNSmR1VlQ2b24zMXVXbFRmYi83YmpXdnlTNTUzR2F3SW9X?= =?utf-8?B?WWlOczZwNGQvYitxc0lRZDh6VEtHTFpzVGFWY1daSHFid0R3QTF2RmhZTHdB?= =?utf-8?B?cStpdHVJaG0rWkRid25HbjU4VExLaFliZlJ3SC9uUTIwOG9ET3FmZHRUSHZv?= =?utf-8?B?L0NsRHpxVkNQM1p6a2g5eTZHR2VIWlAwTGk5c2p6K0x6aDUzYWhObUJPSndh?= =?utf-8?B?RmxJQUpPSGQ2ZVE1dUxGSng2UlRMQWExYlhodEZySzczcE1VckNCYytXdnls?= =?utf-8?B?cTNoK284NHJjMVhVY05yWGQrTmtZVjdVZUEyYTJUYThhNDA4a0lnbk9lV0oy?= =?utf-8?B?Zjh6ZE5QbTQzQ3NFenY1LzBNTnlwNmIwMWNoM0l4a1EzWFdXN1BhRWhoSTBv?= =?utf-8?B?cGhtUDdXY2x5WEhZaFlVL3dJTGc4RnRQckF0M1JBbjJyRTlqcmhYdFZQb1NP?= =?utf-8?B?R0hRUWpNN2psWDA0cFBlS2x3SmpLT0VYc3JGUU9ReWg4RHV5aTh0dis5Nk8x?= =?utf-8?B?WSswdHR1SnRHWjdkenZYcUM4V052TWUxM2hmSjNhcEVVditVaDUvSTFoaFpm?= =?utf-8?B?MC9hSUNzUGNiUHlvd0REUndMSlE5SUI1K2RxcjBwdzRqdHo2TUZZT21saTEr?= =?utf-8?B?bzlCUmZjcVlnc1RGZlZxdURlTkUySWc9PQ==?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ade3c397-a6c6-4564-54c4-08db4caa1681 X-MS-Exchange-CrossTenant-AuthSource: TY0PR01MB5444.apcprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2023 14:16:01.3603 (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: PSAPR01MB3926 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On May 4, 2023, at 19:36, Andy Shevchenko wro= te: >=20 > On Thu, May 4, 2023 at 12:38=E2=80=AFPM Yan Wang wr= ote: >> On 4/26/2023 10:42 PM, andy.shevchenko@gmail.com wrote: >>> Sun, Apr 23, 2023 at 09:59:43PM +0800, Yan Wang kirjoitti: >>>> if hardware number different to array index,it needs to clear to point= s >>>> memory space if the array_info have been assigned a value. >>> Can you explain a bit more what's going on there? >=20 > ... >=20 >> I use gpiod_get_array() to get a gpio array form the node of DTS. >>=20 >> the node is as follows: >> ... >> gpios =3D <&gpio1 0 0>, <&gpio1 10 0>; >> ... >>=20 >> First scan pin-0 of gpio1,its index and hardware number are 0, >>=20 >> if (descs->ndescs =3D=3D 0 && gpio_chip_hwgpio(desc) =3D=3D 0) { >> ... >> descs->info =3D array_info. >> } >>=20 >> Then scan pin-10 , its index is 1 ,but hardware number is 10 . >>=20 >> if (gpio_chip_hwgpio(desc) !=3D descs->ndescs) { >> array_info =3D NULL; >> } >> just set array_info =3D NULL, Should the array_info point to memory be >> cleared ? >=20 > This is a good question. The entire algorithm is a bit difficult to > understand from the first glance. I need some time to check it myself. Looking forward to your test results. >=20 >> if not cleared ,I use the gpiod_set_array_value_cansleep() to pull up or >> down pin-10 is invalid. >=20 > I'm not sure I follow. The array operations are against the given > array of the descriptors. If you ask to have that operation done, the > all descriptors in the array should be considered. >=20 >> I found that the set_mask and get_mask vlaues of descs->info are seted >> 0x03 in gpiod_get_array(), >=20 > Yes, this mask is for the argument. The 0x03 is the correct one. >=20 >> I think 0x401 is their correct value. >=20 > No. You have an array of two elements, and not 11. Due to hardware number are 10 and 0 , so this mask is 0x401=EF=BC=88bit10 a= nd bit0 are 1=EF=BC=89. >=20 >>>> if (bitmap_full(array_info->get_mask, descs->ndescs)) { >>>> + /*clear descs->info*/ >>>> + memset(array_info, 0, sizeof(struct gpio_array)); >>>> array_info =3D NULL; >>>> } >=20 >=20 > --=20 > With Best Regards, > Andy Shevchenko