Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2020206lqb; Mon, 27 May 2024 05:32:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUqcmFMtMwNjW7cTvD+mzdeORvNWPPbgHaVT0bqTHDKfykiI75UHvCIAQVdNI1JAQpaHs+2USB1gxtPlRSdPkRtw6CaaMfRFkPvoaUkBw== X-Google-Smtp-Source: AGHT+IEqfGBQWuKfKIosuz9QmXFVhwed2lMARF1gYggazyo0BusTYXloJl0sDxpzqJcKpK/BJwql X-Received: by 2002:a05:620a:1654:b0:792:b921:5a55 with SMTP id af79cd13be357-794ab0822demr918104785a.26.1716813140696; Mon, 27 May 2024 05:32:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716813140; cv=pass; d=google.com; s=arc-20160816; b=oP69dlr4Xue8LRxqiMuH0dyptzv1YUwEdpl3r5LLwtxA9mtsJOxxW0SnO5Pjh9F4aC p3b7yDqyNcrd6N0bZ0b7SmkkWQdDxRwoqpiYtsPou4DvPJZPi+YMWSdLv/yu/vrqCDB1 B7Id3Xs7DKZJhu7BlI9qcwmmt01X9o/NyUeKbrE6M+/8b8nJHMu0ixKcQQWV6m/ngeKh OuEqWEpYzXZj7L2vADfFZA5hFbMwrsaSETW1LsE/1TqJRi944eeo16Qk2vvDkubz+Z5K R2ebPWO8VDXhTtTjghCeB40iavwtsWCZLrQ5d9IJDTGf+2f0KcFGz9KwWm1Eeshm0wcO NDNw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=ZJDUGLRRsJ0ivWLRLg9qi0jczqwj4hSiWcWfn/3vXsg=; fh=6Vm123wvtU5AYu4em6YRdrfZl7M2gNgdwpa9ApaAFiU=; b=b9qP0S06bGORj7nrxGqTFgSpbWGFPXhx5GM1DMdqw0h5CL1qI37DkDmzMM+qjRcH/k kEAMNrxeLc8nsjtnk4XcV3p/xtru97QzwoxEifsKGdXnRXMM7cAGg7XAeghUD9v+njdl MqG/FTGts4ZOdK0KWe4/Oe+oD3fA1aZpsRvE0FJfg9fBWLBRH9/40ZD/igjWvZYBskGl sjcrSgUqRq3LZ5ZX7Ji+9FK8YpceUJrAXY43S70iuMtJtuyr+d2zFV9KW56lvJwOh+2h RbkBXQ7gf8xry/rm/Ddvc9g/kSOu/8ooiJLCfJlMgj0C1TjSBjmQ3IXvCYYNyYUcGosr zl2w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Zm2sB3HX; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-190585-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190585-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-794abcab4b8si836801185a.71.2024.05.27.05.32.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 05:32:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190585-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Zm2sB3HX; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-190585-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190585-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6B6711C2202A for ; Mon, 27 May 2024 12:32:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D98C615E5D9; Mon, 27 May 2024 12:32:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Zm2sB3HX" Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B90515E5BA for ; Mon, 27 May 2024 12:32:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716813125; cv=none; b=W4dZ2y5BhEk4u1QsfYD1y9UrPx/bCn6AAlfm4bOkAMyItMMoSTcRFmzrb11lN3dYiOy8savQWLtdXXuclucePAjsGN5H1+vDYBK3YU1ungZZBZiIgJU3rjyz2UirKlvsToUHUAijBDwzVGuNM9A4QIHjtcVVgWf+p2XOqzhr7Oo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716813125; c=relaxed/simple; bh=goUxZvIFN/u5EojLxx/8XlvUz1D2u0hDwKrpvKzzkOs=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=sSerbxXxSke+4qvZ7VyN48pxVEik+EFjTIz8Tp6k3IxMV7YkJaoDpV1EheiEu9JT7SfCwdhOavhpuhOuoEo87qEeaX7HEAD8n2Cx0RP/xedkl7xTifLraGinQAcs50ztT4CadXxlzTbdIEwAXpmmy0HN/clsPYpnvU+vLO9axd4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Zm2sB3HX; arc=none smtp.client-ip=209.85.219.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-df771959b5bso3329327276.1 for ; Mon, 27 May 2024 05:32:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716813122; x=1717417922; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ZJDUGLRRsJ0ivWLRLg9qi0jczqwj4hSiWcWfn/3vXsg=; b=Zm2sB3HXlYpP98E0ld4n3B7LgvUwguSUtQ21GGd0yRALluXUIL0yIbqkxSchqAXOsR LxqVz+WMBtM/I3jRVcNOORgmptvrWd0y87ZMdcyg2ueMdwzJJXD5vNxcdY9t4A4Gu1rP wcSSkwYMEv2acmmMNFM1DyMa8zwvPxsvJAa8LLHtoXfSK+/wnDI2A+jiNU0uGaI+1NgF H8y5g9ZaOCl/+0uvJZmsXeJl1U3EccnD0dSe7OPt3A7wHcjDalVYLUaDegI/tZbuCBec H9jTJKyya2JVB0dcLuqBDtuUpas2Pi7uFoVNEUeoFKIqpGPi5Pp/TYYpsJOV2YAsMOHG M0+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716813122; x=1717417922; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZJDUGLRRsJ0ivWLRLg9qi0jczqwj4hSiWcWfn/3vXsg=; b=ir98PIemHHA2GuP0WT1+xm+BYrYmdzX7Kyi1Q9cjBkkz265GbrMoOqJueW9Tfm297o JcFcR30s8c/Tnfi8puLZp1ilALDT8pu9Ldzvmyz0VBJFR2JkUr9VHCx/dKYoTLjOndXf jP+ipi2+nt2J3REpkzi2C283AWTLEKfLGLQaFNImAR9V18jthED77AgEjYqEgY49BvQ8 x8Nvsbfdqnwzvf48pZCOAu2+3tSrt3HwxPsE6QAYlUTQXuXcV0gnhb59Spw7qqZWpbNZ 1dc3WGEk0kMy6mTDjzaDGgTWTuzb3DeU8FPX+bWkiJ+MDfTrnNq05yExfZw9lPS5rlJR Unsw== X-Forwarded-Encrypted: i=1; AJvYcCXb1ahCyF8MNVEnrRvUd283PAS58E9i8qZ6dP504apUS94YK2+agJIwUVapXGYxc5/KVAYQo9SxrkBET0UxswKwi7Ww6/VcMB3SaVWl X-Gm-Message-State: AOJu0YzOFZfQjSLdD7rWLHqJ557LA5bNkkNBUEGnZy3Zt4y9uO4na7Pw qUtHmNgIHSHrWA60EvEhcWfr4K/bemU5JZrxP+yIeDRGxnEUyIXNfPDFSK4amy7ahoJ3OyRKgsc vvHu1QnZKWcwZWmgrfMMWq7NjL1dyhd2hi2a3KQ== X-Received: by 2002:a25:abeb:0:b0:df7:69a2:f823 with SMTP id 3f1490d57ef6-df77215546amr9090048276.7.1716813122592; Mon, 27 May 2024 05:32:02 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240503111436.113089-1-yuklin.soo@starfivetech.com> <20240503111436.113089-7-yuklin.soo@starfivetech.com> In-Reply-To: <20240503111436.113089-7-yuklin.soo@starfivetech.com> From: Linus Walleij Date: Mon, 27 May 2024 14:31:51 +0200 Message-ID: Subject: Re: [RFC PATCH v3 6/7] gpiolib: enable GPIO interrupt to wake up a system from sleep To: Alex Soo Cc: Bartosz Golaszewski , Hal Feng , Ley Foon Tan , Jianlong Huang , Emil Renner Berthing , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Drew Fustini , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, Paul Walmsley , Palmer Dabbelt , Albert Ou Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, May 3, 2024 at 1:15=E2=80=AFPM Alex Soo wrote: > Add function gpiochip_wakeup_irq_setup() to configure and enable a > GPIO pin with interrupt wakeup capability according to user-defined > wakeup-gpios property in the device tree. Interrupt generated by > toggling the logic level (rising/falling edge) on the specified > GPIO pin can wake up a system from sleep mode. > > Signed-off-by: Alex Soo This is a very helpful patch I think. I'm looking forward to the next iteration. > @@ -1045,8 +1047,15 @@ int gpiochip_add_data_with_key(struct gpio_chip *g= c, void *data, > if (ret) > goto err_remove_irqchip; > } > + > + ret =3D gpiochip_wakeup_irq_setup(gc); > + if (ret) > + goto err_remove_device; Do we have any in-tree drivers that do this by themselves already? In that case we should convert them to use this function in the same patch to avoid regressions. > +static irqreturn_t gpio_wake_irq_handler(int irq, void *data) > +{ > + struct irq_data *irq_data =3D data; I'm minimalist so I usually just call the parameter "d" instead of "data" and irq_data I would call *id but it's your pick. > + > + if (!irq_data || irq !=3D irq_data->irq) > + return IRQ_NONE; > + > + return IRQ_HANDLED; Please add some debug print: struct gpio_chip *gc =3D irq_data->chip_data; chip_dbg(gc, "GPIO wakeup on IRQ %d\n", irq); The rest looks good to me (after fixing Andy's comments!) I would perhaps put some debug print that "GPIO wakeup enabled at offset %d" in the end as well, so people can easily follow this in the debug prints. Yours, Linus Walleij