Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3528869pxv; Mon, 28 Jun 2021 06:43:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwgUOSt90LHazjcoUAskCw65S54L4SMydfzuddwdnBZEvip6xSbEYoLg3flAN1LqHeKcEM X-Received: by 2002:a17:906:4fc6:: with SMTP id i6mr24170747ejw.472.1624887782704; Mon, 28 Jun 2021 06:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624887782; cv=none; d=google.com; s=arc-20160816; b=h7I9g+m9ElRrwKDIC7Qb8ubCt0xLTtEoxK3OH/Z++0kEbFjeOxGZCtJ1a+7CeOrZPM aTKeBblpEv2aMGfYwwvfggabfPIflQ2ytHQWtieEN4hiZUIt2hFt2X7wdO/3OuJZWUeR VsmBo29Ska6xjarIqF48sBdboispa3lhzczluFWgZekWzBab3873XPdJfaXprydhOWwR FOK4IAQq3LHcPdgQ9EM/6JUHikshGnoBROYYsBJUtD6si4J/L094pZTgPFeWR6iXpI2M KRKRtIukD5QJgRrf7XDklYRf9Di+KUdvlp7JPrcb+stjhFXktcNCPYaQ5NBHRsr46x5E bwEw== 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=J0zWLnENjoZcvSkz0GaaLHvicuPlecPlHuFYuJAX7Oc=; b=kIbPs71gTR3M/9BAKUUPYhGkCoSzdqkD/EasD0yPeL6foe/FEnw06AMPVDogOEK3eo rbScfFu6URfxeVL4N28B5LoJfErs42XMgfg4T7xN/JZeAPn+HNQIuL/ZdywUGaaZ4cwt Ij2HApEfrcY1SPOLuyTfhOhxdN/QnSeaP6UkZya4y4hbbHeHBRFZrZat6sp3IlG+dGe/ 3zp8I44QIFw/KGTlM+d0smo2FFrjDUqbiFZs2QEFjmPHG0e9Dl+hM3IbIl5JxnjsGu8r J0TjjjqEL7iPhvib6rZRfIB6P2UMoDrys2cbUhMKk3f726qClfva9dzyKti1pW9E7yNU Ek6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KxFAuX6J; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw1si13964100edb.82.2021.06.28.06.42.38; Mon, 28 Jun 2021 06:43:02 -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=@gmail.com header.s=20161025 header.b=KxFAuX6J; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232002AbhF1Nnz (ORCPT + 99 others); Mon, 28 Jun 2021 09:43:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230154AbhF1Nny (ORCPT ); Mon, 28 Jun 2021 09:43:54 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79FA2C061574; Mon, 28 Jun 2021 06:41:29 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id b1so2459655pls.5; Mon, 28 Jun 2021 06:41:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=J0zWLnENjoZcvSkz0GaaLHvicuPlecPlHuFYuJAX7Oc=; b=KxFAuX6JnjLzFtLeIvbW9xVGLQkYU5APMZG7yJYfy3KH+1vxiTi8yTPN3weVUz4sH+ p5wNqPH4HRuv3pv1+iwZplQbU58eMLUK7r1b9RwWsl1A5sLEwt6LubEVg0vrWtYUa6PP NIWxVPv3Ttri+C6vXj5PPnF9ScNhiUt4bPtPueTRizV4b/gqEjuzgNfbOhxMCT5c05zM zpHIukQ1jzEy2OBZvuldeW2Telpus0/sqLiyaPfVl7On6htx6ZzfH8PbdykWOKRDRkAy nAu9yHvralGM5092TlQQKLfnTkjkmU4gocadwIFH3+OYasRkJZVsN4F07tuynUMYlyvQ 63BQ== 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=J0zWLnENjoZcvSkz0GaaLHvicuPlecPlHuFYuJAX7Oc=; b=eBoDNe8c0VWAYZG6o3K0eeKFuvoOtgHpdl4oWfJzPe1csFNRCXGK7Zp457snkfTA7q FDl9oLxlzzMfCRkbsTtgrnOaTso1GeubVGS6h+Pd/1z6ni/W3HWZrdPT9JXfjI2cu2EC hrfHw5kJz0OFnvJLeyQirISvmHH4jYn/W8yLCoUIOo8ZK6ji48QtgevFBXhXWb2sGaPw Rz8Fmex0n6PzqHUVC5atzxROWUxLPGH6QpJQ/P4DSBHEFLL/N87M57oDD5BsZgFieb2v q+7itWvJzlLuEcEi3DnYoEU8FQtU7yx5V4+Wb/jp65gYRq3eBGf6EQ4nsmLCXMYbfTmH Gf2Q== X-Gm-Message-State: AOAM5318nfygEB5W3sQ/JeL0Vbgy8dLVxDJKBloNNWU/lxewqDKW3IIe +ZLIf0bL3dSYAwsZI7V61UbRG6/JkBezcfhqbtQ= X-Received: by 2002:a17:90a:bc89:: with SMTP id x9mr28051362pjr.228.1624887689062; Mon, 28 Jun 2021 06:41:29 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andy Shevchenko Date: Mon, 28 Jun 2021 16:40:51 +0300 Message-ID: Subject: Re: gpiochip_lock_as_irq on pins without FLAG_REQUESTED: bug or feature ? To: Vincent Pelletier Cc: Linus Walleij , 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 6:37 AM Vincent Pelletier wrote: > > Hello, > > While trying to debug an IRQ handling issue on a sifive-unmatched board > (which is a very recent board on a recent architecture, so I would not > be overly surprised if there were bugs in hiding), I realised that I was able > to claim via sysfs GPIO pins which are being actively used as IRQ sources. > > Checking drivers/gpio/gpiolib.c and kernel/irq/chip.c, I believe this is because > 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. I could confirm this by adding (just as a debugging aid): > WARN_ON(!test_bit(FLAG_REQUESTED, &desc->flags)); > early in gpiochip_lock_as_irq, and this statement gets triggered. > > Is this intentional ? IIRC the GPIO can be locked as IRQ without being requested (perhaps for legacy/historical reasons). But I forgot all code paths anyway, so I'm expecting that Linus and or Bart can elaborate this better. > Does this requesting belong to something else in the codepath from > request_threaded_irq (and similar) ? > Could it be something missing in the devicetree for this board ? > > 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. -- With Best Regards, Andy Shevchenko