Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2884117lqt; Tue, 23 Apr 2024 04:53:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVJ54hu1a1tYltPVUzAWTRr6y7lQPSWcvsrX3Y8fCaZYSouyWG2HCewU6CMzzSMD/SPeQBZKPpIrN0RsdAoBjpjFswDRqqwPPCXZa6AAA== X-Google-Smtp-Source: AGHT+IGMCCtaq78JV0Oy9LSLoB4q6tmmdg8/ssbc64DYLAXRQSg+6gXo6aPe807NO3cQJIPsFVsZ X-Received: by 2002:a05:6a00:9285:b0:6ed:def7:6acb with SMTP id jw5-20020a056a00928500b006eddef76acbmr14185291pfb.14.1713873215173; Tue, 23 Apr 2024 04:53:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713873215; cv=pass; d=google.com; s=arc-20160816; b=EKZBC61mghGr0TkWsDQtXNs+GyrV2+RK07Y/1z8ge1OojBtyFStAQAJuFOU/XdEbQz 0QQDi4ZWphVmkRwWvQqE0N/RHOVMSNzwSDzOL7sbR5I8AvgkOmXyGZjxl3L/3c7Jyi7g hUJdC+baJujgTpIHLlUG5j3kq3ZqgqyC6xVq/WWnwHmHQEMwdJ6foF9qPy5Ss2WdqQ/s 70+UCHC+vMyXZY+ppSmonihN+GxE2YUbf+8NyYJvwMzBVFojisZDe0t+ufGyJqpQ6xLL vXiGsofttVRDyo8miUAQLTLVt/ql49tAD6yegdkh67WGJs67l14fyoD3/12G5q9zIBpF PgSg== 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=lHww8guo9joHfM40pOxCx1WuFD69gCMICsgCV/kfVdI=; fh=le52ptUomAqdq6zDpcMg2D80kL5AgpPOprRP65/zGoU=; b=hvlEefr+e+u/OMB838feYHVlbHOIuCQVRnXFGka55IJ30dCQ5F4CuIno2T042Ap6Ar zBkTsaNnr63yotpFziEfU/JYnhWKTiXPWzlvhAu9blk4h3YGK9nyj9gFwicbPKHD9usX iIiMW9/gAZUp8TNSgKjk/TvGxozcaAorG/eX3U2SH9xiVzy4nCLudXLw9J5Frkn+vUb4 QxBwIl5iPoF1Li/Rs4pU6hvCH0pS0z7hg4WqUjPdepA3sxvvDqgR/A8goIBGHzltIzO4 DooQZP36GFwAuhGTiQVEgl/tqGPk/UVbr34AVGBsgW2Rf3nBv5EBsdn0+gPeh2iRpyFF 0mFQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="jUNa/QHf"; 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-155051-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155051-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h6-20020a056a00170600b006e69fdb9967si9666872pfc.3.2024.04.23.04.53.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 04:53:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155051-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="jUNa/QHf"; 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-155051-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155051-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 15CC128757C for ; Tue, 23 Apr 2024 11:49:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC173142634; Tue, 23 Apr 2024 11:41:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jUNa/QHf" Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) (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 1A2CA1420B3 for ; Tue, 23 Apr 2024 11:41:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713872469; cv=none; b=qKPplGkuQwBsMMUlT1bYtbTNrZYb6DNXNqE08gwKyDynfzvjWGTZEKIZSc5ZOHuWRiVTt+ZcSQ3CYvBJL7MIfIFulAaKvPqu1cxv62deS554HDcEMNx9firfZJV7DAESAD1c/wufGrqR5PF1M1h3NY6nWgt/1dW76EyNho4mnjQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713872469; c=relaxed/simple; bh=jGSxB/aKBQrvQZyFP9ugxKa9qzrbfWhqVhGn/ZIkYAs=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Ago4uCu17HOGaz3eg2q55gju3hB/5qOgNVrNicVEHPvb5p8XQuO7wJzFqlDHBxrLgQ89hdnhetgsrQVvo9WMMjs+G1TWx7LREbc6fNIh8jzD7LqEuEAnjd/Sl/3WyR6XZ1D7jrLy03vMYSb3yGMYOYQ0jMUwP0GdYKOnVKRQCMM= 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=jUNa/QHf; arc=none smtp.client-ip=209.85.219.171 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-f171.google.com with SMTP id 3f1490d57ef6-dc6dcd9124bso5169205276.1 for ; Tue, 23 Apr 2024 04:41:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713872466; x=1714477266; 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=lHww8guo9joHfM40pOxCx1WuFD69gCMICsgCV/kfVdI=; b=jUNa/QHf+h7rYfkyPkjek9PKWLdqhYn8cYkiC0ZAa62e0AthIsdqVaYno2Psgu54Tw uGB5D8REfnmWsukIeVHj6PGddpntyXFlHNKuiTAHQ2UG44fKPlmLzBdQrn656KyFViXv 36GuWW834TeQTyRaWp4QxurOJ6mxzmpSdThL4pbt8jFxflYLIE+TPUQoiMQqW7O1E6Ss PNMyVuXkYz0rU7Flh/7J2Sr1heGl+7Mae6Pw+gHCQJNuYwKw9U7X5KJRXRWCjSDd64ca +XqNq1ZFw+EAjP62mGVaLWygdTyauWXRSzDvP7nvO7Jta9NClP4bKUdaGAMRihp0Ouqb 4qKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713872466; x=1714477266; 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=lHww8guo9joHfM40pOxCx1WuFD69gCMICsgCV/kfVdI=; b=mSEcJjSVa7PSfhT3ab7XLbjiP+LaDOk76N16Os+H+C+sAhuYXT7HlvM0gI0gBYz2gm 33mBS9L+FXSxwTMu4xrMDvpJMZ74AfZXQxX06bXIKxes5oU7k3P0UWziA+tF5/Bp1N60 YtZA1T4W3XKaxifhA+e1gaJofOwhk/aEI6JEvz6oYPFBiIwmDW6yHNeMxZQfZUpPOZhH fNGCnwijS0AgPIurJJYO7Ta34RDZ2eUQdAXJR3fAQyIteU3MA9n3eNHggSadrBvp2m0j KhwtkFS+Yx37OlpUxHvXypVSHkigdwGUT0EtXca7eh7fKlGnkcxShqAlPmExH7/i/hiZ tzSA== X-Forwarded-Encrypted: i=1; AJvYcCXPCo+bUiqWo6qtEq+idWvAVdKpqCi35tx+RBXrL836eTjU2FTcTca4bvD6qCqrutpvRiSyXRLD/YFwZWGSwqTs595q6S0MnXpdMfMl X-Gm-Message-State: AOJu0YxV716iRpx00IzRmpE8fhN9xcicNMZwlZcIJCUefRK5sWXf3blD ptX3+pUAaX7jl084YBAoYctKCWJamqpyeQJuhncyCxmboArM5EDgsH2B3QQE6cwnJov6HwgU9Vt g9LrIwiTDrI3W54vh/zndcsEzdbn3mqbOmJ5C/FBvV8RYTZtCqwY= X-Received: by 2002:a25:bc45:0:b0:de5:5084:715d with SMTP id d5-20020a25bc45000000b00de55084715dmr1506637ybk.53.1713872466081; Tue, 23 Apr 2024 04:41:06 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240423022814.3951048-1-haibo.chen@nxp.com> In-Reply-To: <20240423022814.3951048-1-haibo.chen@nxp.com> From: Linus Walleij Date: Tue, 23 Apr 2024 13:40:55 +0200 Message-ID: Subject: Re: [PATCH] gpio: vf610: always set GPIO to input mode when used as interrupt source To: haibo.chen@nxp.com Cc: brgl@bgdev.pl, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 23, 2024 at 4:28=E2=80=AFAM wrote: > From: Haibo Chen > > Though the default pin configuration is INPUT, but if the prior stage doe= s > configure the pins as OUTPUT, then Linux will not reconfigure the pin as > INPUT. > > e.g. When use one pin as interrupt source, and set as low level trigger, > if prior stage already set this pin as OUTPUT low, then will meet interru= pt > storm. > > So always set GPIO to input mode when used as interrupt source to fix abo= ve > case. > > Signed-off-by: Haibo Chen > --- > drivers/gpio/gpio-vf610.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c > index 07e5e6323e86..305b0bcdee6f 100644 > --- a/drivers/gpio/gpio-vf610.c > +++ b/drivers/gpio/gpio-vf610.c > @@ -214,7 +214,7 @@ static int vf610_gpio_irq_set_type(struct irq_data *d= , u32 type) > else > irq_set_handler_locked(d, handle_edge_irq); > > - return 0; > + return port->gc.direction_input(&port->gc, d->hwirq); Just call vf610_gpio_direction_input() instead of indirecting through gc->direction_input(), no need to jump through the vtable and as Bartosz says: it just makes that struct vulnerable. Second: In this patch also implement gc->get_direction() which is currently unimplemented. If you are going to change the direction of a GPIO randomly at runtime then the framework really likes to have a chance to know the current direction for obvious reasons. Yours, Linus Walleij