Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1091965pxv; Thu, 1 Jul 2021 17:12:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1cBQe4nXgAmla7qdF7vi0kKGVuBTlGXxwtTgzk2+i9XfTRQBVwGh/k+I7d0y5S7Wvv393 X-Received: by 2002:aa7:c3d8:: with SMTP id l24mr3129246edr.172.1625184777600; Thu, 01 Jul 2021 17:12:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625184777; cv=none; d=google.com; s=arc-20160816; b=VENtXY7+Nr0vMv6+7CcM+jRXTSaxJo2fTrnV6QV1KhXdmOjGKYBlSiAoIjLAAHSEAz DdR1jXTk/fxDuUL6Kkwj46Bhc39PXeWe5paRNHac5PchLHvSeuOFHeaNdVc+c9iUdnm2 NeLBsKHQY73OBivwHkjnD3qa36Gi1IKdO78bW6D2JYzhEEwJLxVJwBKsgmwd0Im23bdB oDcUSHTyTfNl1oeSFK53ZzCVpC9MHB0PX29rGjQ5uSDNDzi4HqnbWeSwhLdr+I21ghuM SdXCvWXVsuOE5dm+NLgfGX8m2XTdc/qVYln6TW/BVIeX/g8jnKKP4hKpdmlDQ8FCPHOm WIow== 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=aSioyAxRhL+T4Kz1oYTd6+IXqYGgxKke1/8HrWftbXw=; b=TUfFTNyZK8S7my2geXNil4RvqUZ2vZcMqn2DufBBMK0j/BUGiBlu8seJ5KAw1NeVww 3YQuuDURX6RYPhvpzgEsLj4Ndz1P3t8XsfJgRCSYeIl1a8fiosH9kYHksqTkVJyv2HmZ +wmN1dhVXYv8uiI90FtwI0b/PWK+dhBsi7uhKPDKsyDBTz6gfI6YqT/jYNVEmY0fAMa6 CV0TJuMK6xaqUXh7cQQrAvXw5wBpmggImV6vMoYBABS0voZsLLfvRGOD/2TrbBCPQ5JP hTPf095zYQ/4Bpu319XZZTYgqrkBL+HXBrTEq95WObYkqg7h2AHAcZOXBkDG/uEFfqYO 4NlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GYo3bgZG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kl18si1415259ejc.160.2021.07.01.17.12.34; Thu, 01 Jul 2021 17:12:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GYo3bgZG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234312AbhGBAMC (ORCPT + 99 others); Thu, 1 Jul 2021 20:12:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234195AbhGBAMB (ORCPT ); Thu, 1 Jul 2021 20:12:01 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08923C061762 for ; Thu, 1 Jul 2021 17:09:29 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id t17so15057558lfq.0 for ; Thu, 01 Jul 2021 17:09:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aSioyAxRhL+T4Kz1oYTd6+IXqYGgxKke1/8HrWftbXw=; b=GYo3bgZGgzxukZ//9CU0suFsHalp9rrtUeco7oqsVp9rmAxIKKJMDHV5MmCreRKCYe NwPJQtTClEcVfx6welm/q4dWWLj+0OvhO5QaVC9lJPdOeo3kOXYMHoWLNf7jFfv5eHHT CRZYRlH9Owfa1lgs/7Y2nLZrNaDHOPcWl1i9d2a30EMLI2oqqR2ixfdiMx5DpdOd1FTi lbPuE/fWimNQiXA2vT7FY8iuyTq8QH91dn779cfKw2s726Lk8VPxkAAltkI2Ecd5aN2c x0SULlAyr3Pj8Lo6v0Q2xQ15JReGyT7CPOQHbr0hApuAwGcnQepOFg8giGv3WGETZU9y IBQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aSioyAxRhL+T4Kz1oYTd6+IXqYGgxKke1/8HrWftbXw=; b=NExIj9kqnrM6wSCcGw6FeOOBJxntgIlZm4MWuwCI/WO8RHxUIx0ySRq0PfjVt31Rh9 351IgtEPTc2LH7dyBz/WQeIRHz8dzNUNuzfi3PhX+0d5zeDbWb4MZ9fh8VMfcGyTMlSM ihJlSMdsVvTbaDLCaxJAUoHbpNGZzz03iaNPLjL/BJrbVA1Jsfod3Z3HwopqyQKh8FtI vMUHFKpp0ZitRFumKCU2nCJtaLlpFJKCu03DKiL/6v9nR/WwfSEk4U8e1QHj8UHfWlUV d+j2bXYL8vyTYSk47u5wfU72YxCmMh8JzUhVduKKNbCZUYaTAZAf7/a11DRrF8q7IY2y L4nA== X-Gm-Message-State: AOAM531H+yDp75vzJxtsGfPKpx3Cx+YTNmtCgXSfQHJ45BwkBeIw7AiE An2w7iQ1Hj+YOvrzuDhob78/rw4uLyte1iTUAcn/kA== X-Received: by 2002:a19:f202:: with SMTP id q2mr1642554lfh.586.1625184568235; Thu, 01 Jul 2021 17:09:28 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Linus Walleij Date: Fri, 2 Jul 2021 02:09:17 +0200 Message-ID: Subject: Re: gpiochip_lock_as_irq on pins without FLAG_REQUESTED: bug or feature ? To: Vincent Pelletier Cc: Bartosz Golaszewski , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 28, 2021 at 5:37 AM Vincent Pelletier wrote: > gpiolib (gpiochip_irq_reqres, gpiochip_reqres_irq, gpiochip_lock_as_irq) > does not call gpiod_request_{,commit}, resulting in a pin which is available > for use. Nope and they should not. > Is this intentional ? Yes. The basic reason is that gpiochips and irqchips are orthogonal. You can request an IRQ on a GPIO line without requesting the GPIO line for anything else. This is also used when drivers want to inspect the state of a GPIO line (read the value) while the same line triggers IRQs. This is perfectly legal. An extreme example is: drivers/media/cec/platform/cec-gpio/cec-gpio.c There is sometimes confusion around gpiod_to_irq(). This is just a convenience function locating the IRQ for a certain GPIO. Both resources still have to be requested separately and there is no dependency between them, they are just often implemented in the same driver, using two different subsystem APIs, in the end. sysfs can't be used as any guide here since it conflates GPIO lines and IRQs and provides several dangerous ways to shoot oneself in the foot. The chardev does a better job at keeping this in order. > Also, I notice that both gpiochip_hierarchy_add_domain and > gpiochip_reqres_irq call gpiochip_lock_as_irq, and I am surprised I do not > get any error about this: in my understanding only the first call on a given pin > should succeed, but with my WARN_ON I am seeing both stack traces and > no other warning. Hm that may be a subtle bug. The state is just a bool so the first to leave will turn out the lights for whoever is left in the room :P Yours, Linus Walleij