From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (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 2B04442EEAD; Wed, 1 Jul 2026 12:09:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782907748; cv=none; b=PWT8xXx1ixCXWl7KhhV/bUKhxjbFRBZ/cQBqZI0ojTagOc0G/6H3Sq3fwXcOS8pczNT3zaqEGzSdCR/4u8w8mGjlr5OJ63XSuh1oeazNo1FmWNxf/qez+MkzSvOY1KEYI4ldj1rM1ti282I96BMKfE7Z9lNu/gdKjvCKSaCIG4c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782907748; c=relaxed/simple; bh=08ry/i3F382Lh0S0s/t9xY0zSs5C1Db8yjNFGTPWguY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TmA3seBIXMJGO5nq637fEPQ1ZhB0y7OC+VAH8FN+RPXcSTpZEFSIgTssfP0QG2CD0e5odbZmczdNDew3odXBBUC0XYmk1zReHZuo2lSvKyI4LzL7mQcTR+WVjNQ1+2TaR+XsrW/06fONITS2BaZATuSqAPwEUcZ7F7dc2utNVUo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=oDZMOmqT; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="oDZMOmqT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1782907747; x=1814443747; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=08ry/i3F382Lh0S0s/t9xY0zSs5C1Db8yjNFGTPWguY=; b=oDZMOmqTFZTrt9fYwHfWJq8QIq2F6Fn6nGE63kiXTgrkBtEKHwKB1Boe 6umJsleD0mJvyFV42jFNSxnBWsXdBex9wbT+iJgVQrYJwhAPKbacEJssd G6SAbuYRiBfeyYQvqFod+A1L3j/6SRqCeNilJ1ITa5S1wcW5DUw89KfcH UwUlsQ2W+GXRSfQc853qTLbs4cPBTrBZe/KgVBST9IXpkWH0QGfq0V5Qc BPZSY/uJi2bIQ3h/+tmMruxo/PG/2giOveW5DoCCUzndTcgeGiC2H0wr0 4riGdbBQXUa6JiiRG8Yt9I3hNYpdMDwWwZa0OyeYRPqQlQhygd+YIVM1n g==; X-CSE-ConnectionGUID: G13uG0NGSHGCVUKvsTqLhg== X-CSE-MsgGUID: /S8p7V7uTIeSUezhksr19Q== X-IronPort-AV: E=McAfee;i="6800,10657,11833"; a="93994695" X-IronPort-AV: E=Sophos;i="6.25,141,1779174000"; d="scan'208";a="93994695" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2026 05:09:06 -0700 X-CSE-ConnectionGUID: zSNBwqYBSpup2dxfqAqjrA== X-CSE-MsgGUID: lvaVgl7QSza6Rq5O2mrj3A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,141,1779174000"; d="scan'208";a="249187367" Received: from conormcd-mobl2.ger.corp.intel.com (HELO localhost) ([10.245.244.65]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2026 05:09:00 -0700 Date: Wed, 1 Jul 2026 15:08:57 +0300 From: Andy Shevchenko To: Michael Walle Cc: Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , "robh@kernel.org" , "krzk+dt@kernel.org" , "conor+dt@kernel.org" , "afaerber@suse.com" , "wbg@kernel.org" , "mathieu.dubois-briand@bootlin.com" , "lars@metafoo.de" , "Michael.Hennerich@analog.com" , "jic23@kernel.org" , "nuno.sa@analog.com" , "andy@kernel.org" , "dlechner@baylibre.com" , =?utf-8?B?VFlfQ2hhbmdb5by15a2Q6YC4XQ==?= , "linux-gpio@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-realtek-soc@lists.infradead.org" , "linux-iio@vger.kernel.org" , =?utf-8?B?Q1lfSHVhbmdb6buD6Ymm5pmPXQ==?= , Stanley =?utf-8?B?Q2hhbmdb5piM6IKy5b63XQ==?= , James Tai =?utf-8?B?W+aItOW/l+WzsF0=?= , Yu-Chun Lin =?utf-8?B?W+ael+elkOWQm10=?= Subject: Re: [PATCH v3 2/7] gpio: regmap: add gpio_regmap_get_gpiochip() accessor Message-ID: References: Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo On Wed, Jul 01, 2026 at 01:38:54PM +0200, Michael Walle wrote: > On Wed Jul 1, 2026 at 12:55 PM CEST, Andy Shevchenko wrote: > > On Wed, Jul 01, 2026 at 01:01:10PM +0300, Andy Shevchenko wrote: > >> On Wed, Jul 1, 2026 at 11:44 AM Michael Walle wrote: > >> > On Fri Jun 19, 2026 at 11:08 PM CEST, Linus Walleij wrote: > >> > > On Mon, Jun 8, 2026 at 4:41 PM Michael Walle wrote: > >> > > > >> > >> >>> Without an accessor like gpio_regmap_get_gpiochip(), we cannot retrieve the > >> > >> >>> gpio_chip instantiated inside gpio-regmap.c to fulfill these requirements in our > >> > >> >>> map() function. > >> > >> > >> > >> Why is gpiochip_irq_reqres() called in the first place? Isn't that > >> > >> only called if the irq handling is set up via gc->irq.chip and not > >> > >> via gpiochip_irqchip_add_domain() like in gpio-regmap? > >> > > > >> > > Not really, the gpiochip_irq_reqres() is called to mark that a > >> > > GPIO line is used for IRQ, so the gpiolib cannot turn this > >> > > GPIO into an output line, gpiod_direction_out() will fail > >> > > on lines used for IRQ. So it's a failsafe. > >> > > > >> > > You can live without it of course, but then you don't get > >> > > this failsafe. > >> > > >> > Thanks for the explanation! So did I make a mistake years ago by > >> > adding the gpiochip_irqchip_add_domain(), see commit 6a45b0e2589f > >> > ("gpiolib: Introduce gpiochip_irqchip_add_domain()") > >> > > >> > As Yu-Chun found, gpiochip_irq_reqres() expect the irq chip data > >> > to be a gpio_chip, which isn't the case (in general) for an > >> > externally allocated domain, is it? > >> > >> So the whole issue comes from the fact that the IRQ chip is not marked > >> as immutable. For immutable IRQ chips (which all GPIO provides should > >> have) there is no such issue to begin with, id est there is no > >> gpiochip_irq_reqres() callback assigned (and respective _relres). > > > > Ah, for immutable chips we put either custom ones or > > GPIOCHIP_IRQ_RESOURCE_HELPERS which actually refers to those callbacks. > > > > So, if the domain is external, it should also provide irq_request_resources > > and release callbacks. In the custom case we can wrap gpiochip_reqres_irq() > > and gpiochip_relres_irq() respectively. > > Exactly. And its seems that this should have been possible with this > series, too. > > Apart from that, most drivers use regmap-irq with gpio-regmap. For > this we'd probably have to add something to regmap-irq because that > module owns the irq_chip. > > > But we need to have a struct gpio_chip pointer for them. And note, the > > IRQ chip data can be anything in that case, so it's not a requirement. > > That's what I've meant. Conceptionally, it should be part of > gpiochip_irqchip_add_domain()/gpiolib, so a user doesn't have to > have that knowledge. But I don't see how this could be achieved. But it can be hidden in gpio-regmap + regmap-irq. So, what we need is: - patch regmap-irq to be able to customize irq_request_resources and release - provide default callbacks in gpio-regmap (and export for external domains) - use those callbacks by default when gpio-regmap creates an IRQ chip The leftovers are the drivers that use gpio-regmap + their own call to regmap-irq. I haven't looked into them closely, they usually have custom xlate and something else. OTOH, they will be able to customize the resource handling as well. -- With Best Regards, Andy Shevchenko