Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp998552iob; Fri, 13 May 2022 19:06:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykCB7BXPbbTfCol7S31EkBlomMTvOxYU9sAEptv3RFnagJiga5zbbadBuCcBZqZk7DPual X-Received: by 2002:a05:600c:4fce:b0:394:5f8e:8124 with SMTP id o14-20020a05600c4fce00b003945f8e8124mr17490013wmq.107.1652494013367; Fri, 13 May 2022 19:06:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652494013; cv=none; d=google.com; s=arc-20160816; b=0tk41BgUV3BG1Lrh2Pwh5neBqBqOsX23V1cSRjx4K1MoQ3e6ASCWDgH1hBFQYtd9sS VT5N5ZDRFu1Rs0f3mEBCXQs6MsiroJWYEnlfk6gQp2kld9riEMDdxC9+bzolOQgqhrj9 8W15t6oDTn/J6kSWpwUfTZTbEKw1PtiZ4ZWY8w4lwxMiQC7KLvVtB1/zX1WivbGdDhKd KE81v17DF36ceKwWUP/Ulo023Kn8ENjD0pEHFuri2KmBwTpahcF1JUuYfLmz8KYWIe9R ftx2I4/McxFVCqYXEGW6TWv78OhlMM8iXhh4CnGIB9Yy24/xv3hoWXG/TOGr5Bz5HTdx nG/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=cDf56ztQPBCcZZJ7QUrd+Gca39+mdnDOAe1uKcepMDQ=; b=OxS5z00k85lwRT6w12RiVpEYlIYLR81Gzpk3R9E7LcHFMXAw0yZlwRneRzCZb7l3M4 sHEN9R5dRlDkUli71O7o4C43hEqYS+0/ZAM4xZFGurDxMq5SBDihlXVDlIRTEJi+piqW 4xKX4cBNm3lWO4h1NC5zIxImBb1I4mM78xCaUJefBCrV/GSU2uQOAK8f/yuDT/3X8/QW n+dIyzMbcaRmugv3iRAXmcO3LsZPk1ApXeVKt8Jd1bnQdea9YD2y4l2yp/4MgkawJFM9 yCvoNBzm3f6TMFocwGmWA9e5QisDFZDSK75Ol9fCZ2JlurQOv0RJtAgVbt/M/nwCWLPh oJ9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pegICUYU; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id f18-20020a7bcc12000000b0038c90f60d42si3965193wmh.230.2022.05.13.19.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 19:06:53 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pegICUYU; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7AA402F6243; Fri, 13 May 2022 17:27:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357237AbiELR4M (ORCPT + 99 others); Thu, 12 May 2022 13:56:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357411AbiELR4I (ORCPT ); Thu, 12 May 2022 13:56:08 -0400 Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8088C1FCEF; Thu, 12 May 2022 10:56:05 -0700 (PDT) Received: by mail-yb1-xb34.google.com with SMTP id i38so11123254ybj.13; Thu, 12 May 2022 10:56:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cDf56ztQPBCcZZJ7QUrd+Gca39+mdnDOAe1uKcepMDQ=; b=pegICUYUytx85orAdIVv5XS7x83nbZWGrPKozBcGu7LZ2N31Zlzr2ABeWgeo9ZesfS Q46RwOAW6yxxghjbVmkXVxsEg/BryIOfQ3mfkdzsG8xzoLv8Yilx09aPJnBldN7Z/7b7 iWbBrfZzxJ5KURGwvm+G0EXuSnjYDntNzjI4Y8N6XeAbE2n6NPky7JIYWCzPTXm7tEjO RsQJG3xgvgfKSCGD5z9I4Wa01etuxs70zkPy+/6p9ciwhp/rka2A4cY3LzTHsA7VUbua gcHS/yDdnG5Blol+61ocBmo3OujeKdGWgOWV9TuPkxDYgchtGYmz8quKf2sqmrERJHar NlOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cDf56ztQPBCcZZJ7QUrd+Gca39+mdnDOAe1uKcepMDQ=; b=HiIiN6zAIOZyX+k166tTg0/1qu5zpcM55F3EvKgGy31+zwb/kWi0nkDiJh8CNNB5pS 337hwwTvuuE1ZbieZWn6bAxCddDC9ESB8BRDpdqE2Uagx/E3pRR020kh0/A6tfBAOeJp RuOds7RBNpDPmLc7Pr2ZR/DU5Yw3V9gncaXGjM5J3tBUhBLE0/x6Nsa9pgqcJLtyres1 SbXBTgd0lQo3F5+p26bRp/cFx0fbCYAgazxxBhrKO7XGmq9/CLMLwkrlm9ZlQy8Z9bta xcbLIlHOu9a5jdboMaKDodOKjBjHjyUKXbh5IWhizfzXj7MtAhW8mCpe0ZE8Rf9/ytLR uH2w== X-Gm-Message-State: AOAM5329dxDl45P9i7/FoDcOtUcsDKrmF3+XPzsEpPCx/TEBSTGY46pj 65keujk+5AIkdnNn6wApyK1CEFsHLGA7JltFF2w= X-Received: by 2002:a5b:246:0:b0:619:5651:3907 with SMTP id g6-20020a5b0246000000b0061956513907mr1061247ybp.190.1652378164781; Thu, 12 May 2022 10:56:04 -0700 (PDT) MIME-Version: 1.0 References: <20220511183210.5248-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20220511183210.5248-4-prabhakar.mahadev-lad.rj@bp.renesas.com> <87y1z75770.wl-maz@kernel.org> <87wneq6fz3.wl-maz@kernel.org> <87v8ua67kt.wl-maz@kernel.org> In-Reply-To: <87v8ua67kt.wl-maz@kernel.org> From: "Lad, Prabhakar" Date: Thu, 12 May 2022 18:55:38 +0100 Message-ID: Subject: Re: [PATCH v3 3/5] gpio: gpiolib: Allow free() callback to be overridden To: Marc Zyngier Cc: Lad Prabhakar , Geert Uytterhoeven , Linus Walleij , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Bartosz Golaszewski , Philipp Zabel , "open list:GPIO SUBSYSTEM" , LKML , Linux-Renesas , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Phil Edworthy , Biju Das Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Hi Marc, On Thu, May 12, 2022 at 5:26 PM Marc Zyngier wrote: > > On Thu, 12 May 2022 14:50:05 +0100, > "Lad, Prabhakar" wrote: > > > > Hi Marc, > > > > On Thu, May 12, 2022 at 2:24 PM Marc Zyngier wrote: > > > > > > On Thu, 12 May 2022 13:48:53 +0100, > > > "Lad, Prabhakar" wrote: > > > > > > > > Hi Marc, > > > > > > > > Thank you for the review. > > > > > > > > On Thu, May 12, 2022 at 12:19 PM Marc Zyngier wrote: > > > > > > > > > > On Wed, 11 May 2022 19:32:08 +0100, > > > > > Lad Prabhakar wrote: > > > > > > > > > > > > Allow free() callback to be overridden from irq_domain_ops for > > > > > > hierarchical chips. > > > > > > > > > > > > This allows drivers to free any resources which are allocated during > > > > > > populate_parent_alloc_arg(). > > > > > > > > > > Do you mean more than the fwspec? I don't see this being used. > > > > > > > > > The free callback is used in patch 5/5 where free is overridden by > > > > rzg2l_gpio_irq_domain_free. I just gave an example there as an > > > > populate_parent_alloc_arg() In actual in the child_to_parent_hwirq > > > > callback I am using a bitmap [0] to get a free tint slot, this bitmap > > > > needs freeing up when the GPIO interrupt is released from the driver > > > > that as when overridden free callback frees the allocated tint slot so > > > > that its available for re-use. > > > > > > Right, so that's actually a different life-cycle, and the whole > > > populate_parent_alloc_arg() is a red herring. What you want is to free > > > resources that have been allocated via some other paths. It'd be good > > Is there any other path which I have missed where I can free up resources? > > No, that's the only one. It is just that usually, the alloc() > callback is where you are supposed to perform... allocations. > OK. > It'd be good if you could move your allocation there, as I would > expect calls to child_to_parent_hwirq() to be idempotent. > For now I'll go with the current implementation, as currently a an array is maintained which is tied with the tint slot and child (which is obtained from child_to_parent_hwirq) > > > > > if your commit message actually reflected this instead of using an > > > example that doesn't actually exist. > > > > > My bad, I will update the commit message. > > > > > > > > > > > There is also the question of why we need to have dynamic allocation > > > > > for the fwspec itself. Why isn't that a simple stack allocation in the > > > > > context of gpiochip_hierarchy_irq_domain_alloc()? > > > > > > > > > you mean gpio core itself should handle the fwspec > > > > allocation/freeing? > > > > > > Yes. The only reason we resort to dynamic allocation is because > > > ThunderX is using MSI-based GPIOs, and thus doesn't use a fwspec (no > > > firmware is involved here). > > > > > I see.. > > > > > If we had a union of the two types, we could just have a stack > > > variable, and pass that along, completely sidestepping the whole > > > dynamic allocation/freeing business. > > > > > Right agreed. > > FWIW, I've just posted a PoC patch[1]. > I guess I'll have to rebase my changes on top of it now ;) Cheers, Prabhakar