[v2] pinctrl: samsung: add irq_set_affinity() for non wake up external gpio interrupt
Message ID | 20231126094618.2545116-1-youngmin.nam@samsung.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp2373588vqx; Sun, 26 Nov 2023 01:11:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhT4drRUYJVWGLgdU8s6tTV3ulTX/y8rD8WVO2xDS73S6Ww68Zfef4tTO2cFFK7ss3D3H+ X-Received: by 2002:a05:6e02:152b:b0:35a:b184:74fb with SMTP id i11-20020a056e02152b00b0035ab18474fbmr11050370ilu.9.1700989896488; Sun, 26 Nov 2023 01:11:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700989896; cv=none; d=google.com; s=arc-20160816; b=QaQONdwsjh8vua8pz5RR2IXj3PVzgZE6H1xUUnZY1F60GRq3vqf3AS6Vot9ElRJkUO oYC65pjR79OR+k11rwIwDYwLQ2630kJ/SRsPiVc+1sx6h/D1orrtRTP0CE7riSrQq0i9 3N0FIeex3xCOYRnoS7XA6NrqOYTQ0vJ1hhsjDEQ3YSqO+FWzFy1Cl4HpCJqvk/JToawy cgRIRZcdlQWEooVkM0XxhIDzOAvwfFYdEz6hQ/97NDUvgek3sVmIop4UMBXUM1jPqWsN fRhJtbClWCUKgGGEPlOFN39cPT3qKPoolBvznShG+9+hTmsUsHWPXLkjl6GT8Za4tvNN 1LhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature:dkim-filter; bh=GuiA2IISUqc9VQUQYIOqTFT2qSk66J6Ur4YwPXb8HcM=; fh=UOWUHydFlZyUEt6ulKh2rg45KKSpuCfCDZgfOZ7i+EU=; b=DG08e6uYs2p/zJzd0iRLSqf0wjO4vwlSJkT4QOfDB0Cb2fFkh1HBbM4J0J+a1G51CJ RcrDHOGCUeuZjHuorRbV04YAVy+nQjTbyjIG2ISSXedtz/EQe6ktVoKi15RwHXDoIXW+ OWiLraR1zUHFV71H53w/CZx9jijKK2hogoudpcNt9CFaT1L2lgC+wvToMKiHFFiNn0P6 2R8bPws/LpgmJDmH235UMlvSnbRRZYNmutpNpyb07lkehD/utyx8r3BRuRRP54pGrEof 057uDstQSHZ+iUYIw6CrpqVxvyNgQRLimFPbUKcJrGRsILu9VFQdDGJyaRGJ5ccZQuC5 ij8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=MSQhllYe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id n15-20020a63ee4f000000b005be0028c5easi7417440pgk.401.2023.11.26.01.11.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Nov 2023 01:11:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=MSQhllYe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 7BFC48084074; Sun, 26 Nov 2023 01:11:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229447AbjKZJLX (ORCPT <rfc822;kernel.ruili@gmail.com> + 99 others); Sun, 26 Nov 2023 04:11:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjKZJLW (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 26 Nov 2023 04:11:22 -0500 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACE41D3 for <linux-kernel@vger.kernel.org>; Sun, 26 Nov 2023 01:11:26 -0800 (PST) Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20231126091122epoutp0461562eea38e18a1ddb3d6f7184b9ba17~bIUk5p3mM3213732137epoutp046 for <linux-kernel@vger.kernel.org>; Sun, 26 Nov 2023 09:11:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20231126091122epoutp0461562eea38e18a1ddb3d6f7184b9ba17~bIUk5p3mM3213732137epoutp046 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1700989882; bh=GuiA2IISUqc9VQUQYIOqTFT2qSk66J6Ur4YwPXb8HcM=; h=From:To:Cc:Subject:Date:References:From; b=MSQhllYeRJo7jd27M/gySwJhzWbynt/2Uh5rohoIs2ZoUZPwRNmBdo2MB3tvUUNWM F2mCLCB2FcFt0ne+v6IYqMeIS3sIk0aWNprZSXYtShfwoCWA9kLT5XCa9fq+oG5ELO /r16Mdfe0Zpq5yvSpzZpSVVOtYwcp3cTiMLySipg= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20231126091121epcas2p182a52384ebd985e4fcbf017bd32fc0e2~bIUjuzWMo3013430134epcas2p1X; Sun, 26 Nov 2023 09:11:21 +0000 (GMT) Received: from epsmgec2p1.samsung.com (unknown [182.195.36.102]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4SdNHs0PcHz4x9Pv; Sun, 26 Nov 2023 09:11:21 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmgec2p1.samsung.com (Symantec Messaging Gateway) with SMTP id B7.B8.08648.8BB03656; Sun, 26 Nov 2023 18:11:20 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p4.samsung.com (KnoxPortal) with ESMTPA id 20231126091120epcas2p4a1320e3b0f9be8f8a0f575a322981d38~bIUjAro321687416874epcas2p4C; Sun, 26 Nov 2023 09:11:20 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20231126091120epsmtrp18ea6c518276c3eff3ec6aca67af2397d~bIUi9YZCq0797007970epsmtrp1T; Sun, 26 Nov 2023 09:11:20 +0000 (GMT) X-AuditID: b6c32a43-721fd700000021c8-aa-65630bb896fa Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 08.B7.08755.8BB03656; Sun, 26 Nov 2023 18:11:20 +0900 (KST) Received: from perf.dsn.sec.samsung.com (unknown [10.229.95.91]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20231126091120epsmtip2230b13d97d9a43a23c54f80b96768f89~bIUiuNZfI1550915509epsmtip2q; Sun, 26 Nov 2023 09:11:20 +0000 (GMT) From: Youngmin Nam <youngmin.nam@samsung.com> To: tomasz.figa@gmail.com, krzysztof.kozlowski@linaro.org, s.nawrocki@samsung.com, alim.akhtar@samsung.com, linus.walleij@linaro.org Cc: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, semen.protsenko@linaro.org, Youngmin Nam <youngmin.nam@samsung.com> Subject: [PATCH v2] pinctrl: samsung: add irq_set_affinity() for non wake up external gpio interrupt Date: Sun, 26 Nov 2023 18:46:18 +0900 Message-Id: <20231126094618.2545116-1-youngmin.nam@samsung.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIJsWRmVeSWpSXmKPExsWy7bCmqe4O7uRUg8ZtFhYP5m1js9j7eiu7 xZQ/y5ksNj2+xmqxef4fRovLu+awWcw4v4/J4vCbdlaL531A1qpdQInFBz6xO3B77Jx1l93j zrU9bB6bl9R79G1ZxejxeZNcAGtUtk1GamJKapFCal5yfkpmXrqtkndwvHO8qZmBoa6hpYW5 kkJeYm6qrZKLT4CuW2YO0GVKCmWJOaVAoYDE4mIlfTubovzSklSFjPziElul1IKUnALzAr3i xNzi0rx0vbzUEitDAwMjU6DChOyMDeu+MBbcFqpYOusZawPjbr4uRk4OCQETifk/L7F0MXJx CAnsYJQ4cu8eO4TziVHi6sVWKOcbo8TWZfcYYVrWNz9khUjsZZRo+bEbLCEk8JVR4uC5cBCb TUBXYtuJf2BxEYE2RonOvQEgDcwC5xgl7vdMYAZJCAukSUz41sgGYrMIqErcvLGfFcTmFbCX +LX9IlCcA2ibvMTiBxIQYUGJkzOfsIDYzEDh5q2zmUFmSgi8ZZc4dauHBeI6F4mftw+xQ9jC Eq+Ob4GypSRe9rdB2dkSq39dgrIrJNrv9TBD2MYSs561M4LsZRbQlFi/Sx/iBGWJI7eg1vJJ dBz+yw4R5pXoaBOCaFST+DVlAzR4ZCR2L14BNdBD4tnkTeyQ0ImV+Px2NcsERvlZSJ6ZheSZ WQh7FzAyr2IUSy0ozk1PTTYqMITHaXJ+7iZGcNrUct7BeGX+P71DjEwcjIcYJTiYlUR4c//E pwrxpiRWVqUW5ccXleakFh9iNAWG7kRmKdHkfGDiziuJNzSxNDAxMzM0NzI1MFcS573XOjdF SCA9sSQ1OzW1ILUIpo+Jg1Oqgal7y//nt1zrj7h8XN+XbfJp/Z8WCcX/ne36OrNY91YnSlxK rYlxylU7nLf6YrPQDgvXRR/ib6ot2t3JP5NHO33pNfOwZSn+0+b1LL/Cb71WZwq/ryFzSkXF gidO7rlCzpov3apKM+e+DMvZvk2Zw6+hJyl49SyJtItX5I9MKI7+GbWhb5lkrIjFJQXzvzL3 1Eo3sare/7H50a82i81eiz81bVe3mqpe4/ZrwdSvF2dyPa3akbPg+FrxkP0PbN5s0WBUXsxQ oJ2nn113jM/7y4Fg54LvRhv9DJ7XNahxu0XvurIl/fqOxtfhSxt1uB/ffrjJ8PbhqsjqlFen /kuZ9/CqG8R7JCyWdmU8uqxGWomlOCPRUIu5qDgRAFiBgq4kBAAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMLMWRmVeSWpSXmKPExsWy7bCSvO4O7uRUg85rkhYP5m1js9j7eiu7 xZQ/y5ksNj2+xmqxef4fRovLu+awWcw4v4/J4vCbdlaL531A1qpdQInFBz6xO3B77Jx1l93j zrU9bB6bl9R79G1ZxejxeZNcAGsUl01Kak5mWWqRvl0CV8aGdV8YC24LVSyd9Yy1gXE3Xxcj J4eEgInE+uaHrF2MXBxCArsZJSbtfc8CkZCRuL3yMiuELSxxv+UIVNFnRon/a46BJdgEdCW2 nfjHCJIQEehhlNj8agILiMMscIVRYsvipYwgVcICKRLnf5wEG8sioCpx88Z+sG5eAXuJX9sv snUxcgCtkJdY/EACIiwocXLmE7ByZqBw89bZzBMY+WYhSc1CklrAyLSKUTK1oDg3PbfYsMAw L7Vcrzgxt7g0L10vOT93EyM4nLU0dzBuX/VB7xAjEwfjIUYJDmYlEd7cP/GpQrwpiZVVqUX5 8UWlOanFhxilOViUxHnFX/SmCAmkJ5akZqemFqQWwWSZODilGpiWtmSu5J6/K+nH9e8/pae+ flj58NDRbbc+F6eEzzKasqtye6Ti08i1W37PUepaYr9S/cjHL0HqEis5/lV7HL1xbKavY7FH U9T0KxcO/5mvddKy29vrQ8DPvPNvVZZNdXL7LHBLcu+knpp3qUz9qz3MJa2SfnTd3aHJuU7C ycnzf3MGg71K3uPTxh3Pv9rq2r8xuVghUCCivu7Kzonf5UTO7eff2F+q+6Jxl0Th1l2M5U+X T5IRrLH5uvNGG2/N3wfVq+8Wmh601g9aWe/2hf3z5Nr7Gnt7DHNevTl2x6wmPclNfsMZx20T frZO2v16Y+EUvqdWKzNfrfgR72C8RWN7eijXsg3yoqofK3rictMOKbEUZyQaajEXFScCAEKe zXzWAgAA X-CMS-MailID: 20231126091120epcas2p4a1320e3b0f9be8f8a0f575a322981d38 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20231126091120epcas2p4a1320e3b0f9be8f8a0f575a322981d38 References: <CGME20231126091120epcas2p4a1320e3b0f9be8f8a0f575a322981d38@epcas2p4.samsung.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sun, 26 Nov 2023 01:11:33 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783617181720882979 X-GMAIL-MSGID: 1783617181720882979 |
Series |
[v2] pinctrl: samsung: add irq_set_affinity() for non wake up external gpio interrupt
|
|
Commit Message
Youngmin Nam
Nov. 26, 2023, 9:46 a.m. UTC
To support affinity setting for non wake up external gpio interrupt, add irq_set_affinity callback using irq number from pinctrl driver data. Before this patch, changing the irq affinity of gpio interrupt is not possible: # cat /proc/irq/418/smp_affinity 3ff # echo 00f > /proc/irq/418/smp_affinity # cat /proc/irq/418/smp_affinity 3ff # cat /proc/interrupts CPU0 CPU1 CPU2 CPU3 ... 418: 3631 0 0 0 ... With this patch applied, it's possible to change irq affinity of gpio interrupt: # cat /proc/irq/418/smp_affinity 3ff # echo 00f > /proc/irq/418/smp_affinity # cat /proc/irq/418/smp_affinity 00f # cat /proc/interrupts CPU0 CPU1 CPU2 CPU3 ... 418: 3893 201 181 188 ... Signed-off-by: Youngmin Nam <youngmin.nam@samsung.com> Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> --- drivers/pinctrl/samsung/pinctrl-exynos.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
Comments
On 26/11/2023 10:46, Youngmin Nam wrote: > To support affinity setting for non wake up external gpio interrupt, > add irq_set_affinity callback using irq number from pinctrl driver data. > > Before this patch, changing the irq affinity of gpio interrupt is not possible: > > # cat /proc/irq/418/smp_affinity > 3ff > # echo 00f > /proc/irq/418/smp_affinity Does this command succeed on your board? > # cat /proc/irq/418/smp_affinity > 3ff > # cat /proc/interrupts > CPU0 CPU1 CPU2 CPU3 ... > 418: 3631 0 0 0 ... > > With this patch applied, it's possible to change irq affinity of gpio interrupt: ... On which board did you test it? > + if (parent) > + return parent->chip->irq_set_affinity(parent, dest, force); > + I think there is a helper for it: irq_chip_set_affinity_parent(). Best regards, Krzysztof
On Mon, Nov 27, 2023 at 10:54:56AM +0100, Krzysztof Kozlowski wrote: > On 26/11/2023 10:46, Youngmin Nam wrote: > > To support affinity setting for non wake up external gpio interrupt, > > add irq_set_affinity callback using irq number from pinctrl driver data. > > > > Before this patch, changing the irq affinity of gpio interrupt is not possible: > > > > # cat /proc/irq/418/smp_affinity > > 3ff > > # echo 00f > /proc/irq/418/smp_affinity > > Does this command succeed on your board? > Yes. > > # cat /proc/irq/418/smp_affinity > > 3ff > > # cat /proc/interrupts > > CPU0 CPU1 CPU2 CPU3 ... > > 418: 3631 0 0 0 ... > > > > With this patch applied, it's possible to change irq affinity of gpio interrupt: > > ... > > On which board did you test it? > > I tested on S5E9945 ERD(Exynos Reference Development) board. > > + if (parent) > > + return parent->chip->irq_set_affinity(parent, dest, force); > > + > > I think there is a helper for it: irq_chip_set_affinity_parent(). > > The irq_chip_set_affinity_parent() requires parent_data of irq_data. But when I tested as below, exynos's irqd->parent_data was null. So we should use irqchip's affinity function instead of the helper function. --- a/drivers/pinctrl/samsung/pinctrl-exynos.c +++ b/drivers/pinctrl/samsung/pinctrl-exynos.c @@ -153,14 +153,12 @@ static int exynos_irq_set_type(struct irq_data *irqd, unsigned int type) static int exynos_irq_set_affinity(struct irq_data *irqd, const struct cpumask *dest, bool force) { - struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd); - struct samsung_pinctrl_drv_data *d = bank->drvdata; - struct irq_data *parent = irq_get_irq_data(d->irq); - - if (parent) - return parent->chip->irq_set_affinity(parent, dest, force); + if (!irqd->parent_data) { + pr_err("irqd->parent_data is null!!\n"); + return -EINVAL; + } - return -EINVAL; + return irq_chip_set_affinity_parent(irqd, dest, force); } [ 149.658395] irqd->parent_data is null!! > Best regards, > Krzysztof > >
On 28/11/2023 02:01, Youngmin Nam wrote: > On Mon, Nov 27, 2023 at 10:54:56AM +0100, Krzysztof Kozlowski wrote: >> On 26/11/2023 10:46, Youngmin Nam wrote: >>> To support affinity setting for non wake up external gpio interrupt, >>> add irq_set_affinity callback using irq number from pinctrl driver data. >>> >>> Before this patch, changing the irq affinity of gpio interrupt is not possible: >>> >>> # cat /proc/irq/418/smp_affinity >>> 3ff >>> # echo 00f > /proc/irq/418/smp_affinity >> >> Does this command succeed on your board? >> > Yes. Hm, fails all the time one mine. > >>> # cat /proc/irq/418/smp_affinity >>> 3ff >>> # cat /proc/interrupts >>> CPU0 CPU1 CPU2 CPU3 ... >>> 418: 3631 0 0 0 ... >>> >>> With this patch applied, it's possible to change irq affinity of gpio interrupt: >> >> ... >> >> On which board did you test it? >> >> > I tested on S5E9945 ERD(Exynos Reference Development) board. There is no such board upstream. How can we reproduce this issue? I am afraid we cannot test neither the bug nor the fix. > >>> + if (parent) >>> + return parent->chip->irq_set_affinity(parent, dest, force); >>> + >> >> I think there is a helper for it: irq_chip_set_affinity_parent(). >> >> > > The irq_chip_set_affinity_parent() requires parent_data of irq_data. Hm, so now I wonder why do we not have parent_data... > But when I tested as below, exynos's irqd->parent_data was null. > So we should use irqchip's affinity function instead of the helper function. > Best regards, Krzysztof
On Tue, Nov 28, 2023 at 1:29 AM Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> wrote: > > On 28/11/2023 02:01, Youngmin Nam wrote: > > On Mon, Nov 27, 2023 at 10:54:56AM +0100, Krzysztof Kozlowski wrote: > >> On 26/11/2023 10:46, Youngmin Nam wrote: > >>> To support affinity setting for non wake up external gpio interrupt, > >>> add irq_set_affinity callback using irq number from pinctrl driver data. > >>> > >>> Before this patch, changing the irq affinity of gpio interrupt is not possible: > >>> > >>> # cat /proc/irq/418/smp_affinity > >>> 3ff > >>> # echo 00f > /proc/irq/418/smp_affinity > >> > >> Does this command succeed on your board? > >> > > Yes. > > Hm, fails all the time one mine. > I tried to test this patch on E850-96, and an attempt to write into smp_affinity (for some GPIO irq) also fails for me: # echo f0 > smp_affinity -bash: echo: write error: Input/output error When I add some pr_err() to exynos_irq_set_affinity(), I can't see those printed in dmesg. So I guess exynos_irq_set_affinity() doesn't get called at all. So the error probably happens before .irq_set_affinity callback gets called. Youngmin, can you please try and test this patch on E850-96? This board is already supported in upstream kernel. For example you can use "Volume Up" interrupt for the test, which is GPIO irq. > > > >>> # cat /proc/irq/418/smp_affinity > >>> 3ff > >>> # cat /proc/interrupts > >>> CPU0 CPU1 CPU2 CPU3 ... > >>> 418: 3631 0 0 0 ... > >>> > >>> With this patch applied, it's possible to change irq affinity of gpio interrupt: > >> > >> ... > >> > >> On which board did you test it? > >> > >> > > I tested on S5E9945 ERD(Exynos Reference Development) board. > > There is no such board upstream. How can we reproduce this issue? I am > afraid we cannot test neither the bug nor the fix. > > > > >>> + if (parent) > >>> + return parent->chip->irq_set_affinity(parent, dest, force); > >>> + > >> > >> I think there is a helper for it: irq_chip_set_affinity_parent(). > >> > >> > > > > The irq_chip_set_affinity_parent() requires parent_data of irq_data. > > Hm, so now I wonder why do we not have parent_data... > > > But when I tested as below, exynos's irqd->parent_data was null. > > So we should use irqchip's affinity function instead of the helper function. > > > > > > Best regards, > Krzysztof >
On Tue, Nov 28, 2023 at 03:35:53PM -0600, Sam Protsenko wrote: > On Tue, Nov 28, 2023 at 1:29 AM Krzysztof Kozlowski > <krzysztof.kozlowski@linaro.org> wrote: > > > > On 28/11/2023 02:01, Youngmin Nam wrote: > > > On Mon, Nov 27, 2023 at 10:54:56AM +0100, Krzysztof Kozlowski wrote: > > >> On 26/11/2023 10:46, Youngmin Nam wrote: > > >>> To support affinity setting for non wake up external gpio interrupt, > > >>> add irq_set_affinity callback using irq number from pinctrl driver data. > > >>> > > >>> Before this patch, changing the irq affinity of gpio interrupt is not possible: > > >>> > > >>> # cat /proc/irq/418/smp_affinity > > >>> 3ff > > >>> # echo 00f > /proc/irq/418/smp_affinity > > >> > > >> Does this command succeed on your board? > > >> > > > Yes. > > > > Hm, fails all the time one mine. > > > > I tried to test this patch on E850-96, and an attempt to write into > smp_affinity (for some GPIO irq) also fails for me: > > # echo f0 > smp_affinity > -bash: echo: write error: Input/output error > > When I add some pr_err() to exynos_irq_set_affinity(), I can't see > those printed in dmesg. So I guess exynos_irq_set_affinity() doesn't > get called at all. So the error probably happens before > .irq_set_affinity callback gets called. > > Youngmin, can you please try and test this patch on E850-96? This > board is already supported in upstream kernel. For example you can use > "Volume Up" interrupt for the test, which is GPIO irq. > I intened this affinity setting would work only on *Non* Wakeup External Interrupt. The "Volume Up" on E850-96 board is connected with "gpa0-7" and that is Wakeup External interrupt so that we can't test the callback. I couldn't find out a pin for the test on E850-96 board yet. We can test if there is a usage of *Non" Wake up External Interrupt of GPIO on E850-96 board. Do you have any idea ? Thanks > > > > > >>> # cat /proc/irq/418/smp_affinity > > >>> 3ff > > >>> # cat /proc/interrupts > > >>> CPU0 CPU1 CPU2 CPU3 ... > > >>> 418: 3631 0 0 0 ... > > >>> > > >>> With this patch applied, it's possible to change irq affinity of gpio interrupt: > > >> > > >> ... > > >> > > >> On which board did you test it? > > >> > > >> > > > I tested on S5E9945 ERD(Exynos Reference Development) board. > > > > There is no such board upstream. How can we reproduce this issue? I am > > afraid we cannot test neither the bug nor the fix. > > > > > > > >>> + if (parent) > > >>> + return parent->chip->irq_set_affinity(parent, dest, force); > > >>> + > > >> > > >> I think there is a helper for it: irq_chip_set_affinity_parent(). > > >> > > >> > > > > > > The irq_chip_set_affinity_parent() requires parent_data of irq_data. > > > > Hm, so now I wonder why do we not have parent_data... > > > > > But when I tested as below, exynos's irqd->parent_data was null. > > > So we should use irqchip's affinity function instead of the helper function. > > > > > > > > > > > Best regards, > > Krzysztof > > >
On 29/11/2023 08:07, Youngmin Nam wrote: > On Tue, Nov 28, 2023 at 03:35:53PM -0600, Sam Protsenko wrote: >> On Tue, Nov 28, 2023 at 1:29 AM Krzysztof Kozlowski >> <krzysztof.kozlowski@linaro.org> wrote: >>> >>> On 28/11/2023 02:01, Youngmin Nam wrote: >>>> On Mon, Nov 27, 2023 at 10:54:56AM +0100, Krzysztof Kozlowski wrote: >>>>> On 26/11/2023 10:46, Youngmin Nam wrote: >>>>>> To support affinity setting for non wake up external gpio interrupt, >>>>>> add irq_set_affinity callback using irq number from pinctrl driver data. >>>>>> >>>>>> Before this patch, changing the irq affinity of gpio interrupt is not possible: >>>>>> >>>>>> # cat /proc/irq/418/smp_affinity >>>>>> 3ff >>>>>> # echo 00f > /proc/irq/418/smp_affinity >>>>> >>>>> Does this command succeed on your board? >>>>> >>>> Yes. >>> >>> Hm, fails all the time one mine. >>> >> >> I tried to test this patch on E850-96, and an attempt to write into >> smp_affinity (for some GPIO irq) also fails for me: >> >> # echo f0 > smp_affinity >> -bash: echo: write error: Input/output error >> >> When I add some pr_err() to exynos_irq_set_affinity(), I can't see >> those printed in dmesg. So I guess exynos_irq_set_affinity() doesn't >> get called at all. So the error probably happens before >> .irq_set_affinity callback gets called. >> >> Youngmin, can you please try and test this patch on E850-96? This >> board is already supported in upstream kernel. For example you can use >> "Volume Up" interrupt for the test, which is GPIO irq. >> > > I intened this affinity setting would work only on *Non* Wakeup External Interrupt. > The "Volume Up" on E850-96 board is connected with "gpa0-7" and > that is Wakeup External interrupt so that we can't test the callback. > > I couldn't find out a pin for the test on E850-96 board yet. > We can test if there is a usage of *Non" Wake up External Interrupt of GPIO > on E850-96 board. > > Do you have any idea ? Please test on any upstream platform or upstream your existing platform. I hesitate to take this change because I don't trust Samsung that this was tested on mainline kernel. OK, for sure 100% it was not tested on mainline, but I am afraid that differences were far beyond just missing platforms. Therefore the issue might or might not exist at all. Maybe issue is caused by other Samsung non-upstreamed code. Best regards, Krzysztof
On 29/11/2023 09:46, Youngmin Nam wrote: >>> I couldn't find out a pin for the test on E850-96 board yet. >>> We can test if there is a usage of *Non" Wake up External Interrupt of GPIO >>> on E850-96 board. >>> >>> Do you have any idea ? >> >> Please test on any upstream platform or upstream your existing platform. >> I hesitate to take this change because I don't trust Samsung that this >> was tested on mainline kernel. OK, for sure 100% it was not tested on >> mainline, but I am afraid that differences were far beyond just missing >> platforms. Therefore the issue might or might not exist at all. Maybe >> issue is caused by other Samsung non-upstreamed code. >> >> Best regards, >> Krzysztof > > Sure. Let me find how to test on upstreamed device like E850-96 board. There are many reasons why companies using Linux for their products should be involved in upstreaming their devices. The one visible from this conversation: Whatever technical debt you have, it will be only growing because upstream might not even take simple patches from you, until you start contributing with the rest. Samsung's out-of-tree kernels are so far away from the upstream, that basically we might feel that contributions from Samsung are not addressing real problems. This will affect your Android trees due to GKI. That's one more argument to talk to with your managers why staying away from the upstream is not the best idea. Second argument is look at your competitor: Qualcomm, one of the most active upstreamers of SoC code doing awesome job. Best regards, Krzysztof
On Wed, Nov 29, 2023 at 09:00:04AM +0100, Krzysztof Kozlowski wrote: > On 29/11/2023 08:07, Youngmin Nam wrote: > > On Tue, Nov 28, 2023 at 03:35:53PM -0600, Sam Protsenko wrote: > >> On Tue, Nov 28, 2023 at 1:29 AM Krzysztof Kozlowski > >> <krzysztof.kozlowski@linaro.org> wrote: > >>> > >>> On 28/11/2023 02:01, Youngmin Nam wrote: > >>>> On Mon, Nov 27, 2023 at 10:54:56AM +0100, Krzysztof Kozlowski wrote: > >>>>> On 26/11/2023 10:46, Youngmin Nam wrote: > >>>>>> To support affinity setting for non wake up external gpio interrupt, > >>>>>> add irq_set_affinity callback using irq number from pinctrl driver data. > >>>>>> > >>>>>> Before this patch, changing the irq affinity of gpio interrupt is not possible: > >>>>>> > >>>>>> # cat /proc/irq/418/smp_affinity > >>>>>> 3ff > >>>>>> # echo 00f > /proc/irq/418/smp_affinity > >>>>> > >>>>> Does this command succeed on your board? > >>>>> > >>>> Yes. > >>> > >>> Hm, fails all the time one mine. > >>> > >> > >> I tried to test this patch on E850-96, and an attempt to write into > >> smp_affinity (for some GPIO irq) also fails for me: > >> > >> # echo f0 > smp_affinity > >> -bash: echo: write error: Input/output error > >> > >> When I add some pr_err() to exynos_irq_set_affinity(), I can't see > >> those printed in dmesg. So I guess exynos_irq_set_affinity() doesn't > >> get called at all. So the error probably happens before > >> .irq_set_affinity callback gets called. > >> > >> Youngmin, can you please try and test this patch on E850-96? This > >> board is already supported in upstream kernel. For example you can use > >> "Volume Up" interrupt for the test, which is GPIO irq. > >> > > > > I intened this affinity setting would work only on *Non* Wakeup External Interrupt. > > The "Volume Up" on E850-96 board is connected with "gpa0-7" and > > that is Wakeup External interrupt so that we can't test the callback. > > > > I couldn't find out a pin for the test on E850-96 board yet. > > We can test if there is a usage of *Non" Wake up External Interrupt of GPIO > > on E850-96 board. > > > > Do you have any idea ? > > Please test on any upstream platform or upstream your existing platform. > I hesitate to take this change because I don't trust Samsung that this > was tested on mainline kernel. OK, for sure 100% it was not tested on > mainline, but I am afraid that differences were far beyond just missing > platforms. Therefore the issue might or might not exist at all. Maybe > issue is caused by other Samsung non-upstreamed code. > > Best regards, > Krzysztof Sure. Let me find how to test on upstreamed device like E850-96 board. > > >
On Wed, Nov 29, 2023 at 09:39:45AM +0100, Krzysztof Kozlowski wrote: > On 29/11/2023 09:46, Youngmin Nam wrote: > >>> I couldn't find out a pin for the test on E850-96 board yet. > >>> We can test if there is a usage of *Non" Wake up External Interrupt of GPIO > >>> on E850-96 board. > >>> > >>> Do you have any idea ? > >> > >> Please test on any upstream platform or upstream your existing platform. > >> I hesitate to take this change because I don't trust Samsung that this > >> was tested on mainline kernel. OK, for sure 100% it was not tested on > >> mainline, but I am afraid that differences were far beyond just missing > >> platforms. Therefore the issue might or might not exist at all. Maybe > >> issue is caused by other Samsung non-upstreamed code. > >> > >> Best regards, > >> Krzysztof > > > > Sure. Let me find how to test on upstreamed device like E850-96 board. > > There are many reasons why companies using Linux for their products > should be involved in upstreaming their devices. > > The one visible from this conversation: Whatever technical debt you > have, it will be only growing because upstream might not even take > simple patches from you, until you start contributing with the rest. > Samsung's out-of-tree kernels are so far away from the upstream, that > basically we might feel that contributions from Samsung are not > addressing real problems. This will affect your Android trees due to GKI. > > That's one more argument to talk to with your managers why staying away > from the upstream is not the best idea. > > Second argument is look at your competitor: Qualcomm, one of the most > active upstreamers of SoC code doing awesome job. > > Best regards, > Krzysztof Thank you for your opinion. By the way, this patch is not related with GKI and I just thought this work would be helpful to all exynos platform. But it seems that changing affinity of any irqs including gpio is not allowed on exynos platform. So we need to debug by adding some logs. > >
On Wed, Nov 29, 2023 at 12:32 AM Youngmin Nam <youngmin.nam@samsung.com> wrote: > > I tried to test this patch on E850-96, and an attempt to write into > > smp_affinity (for some GPIO irq) also fails for me: > > > > # echo f0 > smp_affinity > > -bash: echo: write error: Input/output error > > > > When I add some pr_err() to exynos_irq_set_affinity(), I can't see > > those printed in dmesg. So I guess exynos_irq_set_affinity() doesn't > > get called at all. So the error probably happens before > > .irq_set_affinity callback gets called. > > > > Youngmin, can you please try and test this patch on E850-96? This > > board is already supported in upstream kernel. For example you can use > > "Volume Up" interrupt for the test, which is GPIO irq. > > > > I intened this affinity setting would work only on *Non* Wakeup External Interrupt. > The "Volume Up" on E850-96 board is connected with "gpa0-7" and > that is Wakeup External interrupt so that we can't test the callback. > Oh no. It was really silly mistake on my part :) But please check my answer below for good news. > I couldn't find out a pin for the test on E850-96 board yet. > We can test if there is a usage of *Non" Wake up External Interrupt of GPIO > on E850-96 board. > > Do you have any idea ? > Yep, just managed to successfully test your patch on E850-96. My testing procedure below might appear messy, but I didn't want to do any extra soldering :) Used GPG1[0] pin for testing. As you can see from schematics [1], GPG1[0] is connected to R196 resistor (which is not installed on the board). I've modified E850-96 dts file like this: 8<---------------------------------------------------------------------------->8 gpio-keys { compatible = "gpio-keys"; pinctrl-names = "default"; - pinctrl-0 = <&key_voldown_pins &key_volup_pins>; + pinctrl-0 = <&key_voldown_pins &key_volup_pins &key_test_pins>; ... + test-key { + label = "Test Key"; + linux,code = <KEY_RIGHTCTRL>; + gpios = <&gpg1 0 GPIO_ACTIVE_LOW>; + }; }; ... +&pinctrl_peri { + key_test_pins: key-test-pins { + samsung,pins = "gpg1-0"; + samsung,pin-function = <EXYNOS_PIN_FUNC_EINT>; + samsung,pin-pud = <EXYNOS_PIN_PULL_NONE>; + samsung,pin-drv = <EXYNOS5420_PIN_DRV_LV1>; + }; +}; 8<---------------------------------------------------------------------------->8 It appeared in /proc/interrupts as follows: 87: 2 0 0 0 0 0 0 0 gpg1 0 Edge Test Key Then I touched R196 resistor pads with my finger (emulating key press) and looked again at /proc/interrupts: 87: 444 0 0 0 0 0 0 0 gpg1 0 Edge Test Key Then I reconfigured smp_affinity like so: # cat /proc/irq/87/smp_affinity ff # echo f0 > /proc/irq/87/smp_affinity # cat /proc/irq/87/smp_affinity f0 Then I messed with R196 resistor pads with my finger again, and re-checked /proc/interrupts: CPU0 CPU1 CPU2 CPU3 CPU4 CPU5 CPU6 CPU7 87: 444 0 0 0 234 0 0 0 gpg1 0 Edge Test Key And without this patch that procedure above of course doesn't work. So as far as I'm concerned, feel free to add: Tested-by: Sam Protsenko <semen.protsenko@linaro.org> [1] https://www.96boards.org/documentation/consumer/e850-96b/hardware-docs/files/e850-96b-schematics.pdf Thanks!
On Wed, Nov 29, 2023 at 12:48:56PM -0600, Sam Protsenko wrote: > On Wed, Nov 29, 2023 at 12:32 AM Youngmin Nam <youngmin.nam@samsung.com> wrote: > > > I tried to test this patch on E850-96, and an attempt to write into > > > smp_affinity (for some GPIO irq) also fails for me: > > > > > > # echo f0 > smp_affinity > > > -bash: echo: write error: Input/output error > > > > > > When I add some pr_err() to exynos_irq_set_affinity(), I can't see > > > those printed in dmesg. So I guess exynos_irq_set_affinity() doesn't > > > get called at all. So the error probably happens before > > > .irq_set_affinity callback gets called. > > > > > > Youngmin, can you please try and test this patch on E850-96? This > > > board is already supported in upstream kernel. For example you can use > > > "Volume Up" interrupt for the test, which is GPIO irq. > > > > > > > I intened this affinity setting would work only on *Non* Wakeup External Interrupt. > > The "Volume Up" on E850-96 board is connected with "gpa0-7" and > > that is Wakeup External interrupt so that we can't test the callback. > > > > Oh no. It was really silly mistake on my part :) But please check my > answer below for good news. > > > I couldn't find out a pin for the test on E850-96 board yet. > > We can test if there is a usage of *Non" Wake up External Interrupt of GPIO > > on E850-96 board. > > > > Do you have any idea ? > > > > Yep, just managed to successfully test your patch on E850-96. My > testing procedure below might appear messy, but I didn't want to do > any extra soldering :) > > Used GPG1[0] pin for testing. As you can see from schematics [1], > GPG1[0] is connected to R196 resistor (which is not installed on the > board). > > I've modified E850-96 dts file like this: > > 8<---------------------------------------------------------------------------->8 > gpio-keys { > compatible = "gpio-keys"; > pinctrl-names = "default"; > - pinctrl-0 = <&key_voldown_pins &key_volup_pins>; > + pinctrl-0 = <&key_voldown_pins &key_volup_pins &key_test_pins>; > > ... > > + test-key { > + label = "Test Key"; > + linux,code = <KEY_RIGHTCTRL>; > + gpios = <&gpg1 0 GPIO_ACTIVE_LOW>; > + }; > }; > > ... > > +&pinctrl_peri { > + key_test_pins: key-test-pins { > + samsung,pins = "gpg1-0"; > + samsung,pin-function = <EXYNOS_PIN_FUNC_EINT>; > + samsung,pin-pud = <EXYNOS_PIN_PULL_NONE>; > + samsung,pin-drv = <EXYNOS5420_PIN_DRV_LV1>; > + }; > +}; > 8<---------------------------------------------------------------------------->8 > > It appeared in /proc/interrupts as follows: > > 87: 2 0 0 0 0 > 0 0 0 gpg1 0 Edge Test Key > > Then I touched R196 resistor pads with my finger (emulating key press) > and looked again at /proc/interrupts: > > 87: 444 0 0 0 0 > 0 0 0 gpg1 0 Edge Test Key > > Then I reconfigured smp_affinity like so: > > # cat /proc/irq/87/smp_affinity > ff > # echo f0 > /proc/irq/87/smp_affinity > # cat /proc/irq/87/smp_affinity > f0 > > Then I messed with R196 resistor pads with my finger again, and > re-checked /proc/interrupts: > > CPU0 CPU1 CPU2 CPU3 CPU4 > CPU5 CPU6 CPU7 > 87: 444 0 0 0 234 > 0 0 0 gpg1 0 Edge Test Key > > And without this patch that procedure above of course doesn't work. > > So as far as I'm concerned, feel free to add: > > Tested-by: Sam Protsenko <semen.protsenko@linaro.org> > > [1] https://protect2.fireeye.com/v1/url?k=d3eebafe-8c7293d4-d3ef31b1-000babe598f7-06c0db00473e1bca&q=1&e=855a917d-d0f9-49cd-8e05-7cccf44d06a8&u=https%3A%2F%2Fwww.96boards.org%2Fdocumentation%2Fconsumer%2Fe850-96b%2Fhardware-docs%2Ffiles%2Fe850-96b-schematics.pdf > > Thanks! > Thanks for your test Sam. It's really great work. I confirmed the patch did work by following your test sequence as below. * Before CPU0 CPU1 CPU2 CPU3 CPU4 ... 87: 40 0 0 0 0 ... gpg1 0 Edge Test Key * After 87: 40 0 0 0 22 ... gpg1 0 Edge Test Key Krzysztof, Sam and I tested this patch on e850-95 board. Let me update commit message with test result and will update patchset. Thanks.
On Sun, 26 Nov 2023 18:46:18 +0900, Youngmin Nam wrote: > To support affinity setting for non wake up external gpio interrupt, > add irq_set_affinity callback using irq number from pinctrl driver data. > > Before this patch, changing the irq affinity of gpio interrupt is not possible: > > # cat /proc/irq/418/smp_affinity > 3ff > # echo 00f > /proc/irq/418/smp_affinity > # cat /proc/irq/418/smp_affinity > 3ff > # cat /proc/interrupts > CPU0 CPU1 CPU2 CPU3 ... > 418: 3631 0 0 0 ... > > [...] Applied, thanks! [1/1] pinctrl: samsung: add irq_set_affinity() for non wake up external gpio interrupt https://git.kernel.org/pinctrl/samsung/c/b77f5ef8ebe4d8ee3a712a216415d7f4d4d0acf2 Best regards,
On 30/11/2023 08:30, Youngmin Nam wrote: > Thanks for your test Sam. It's really great work. > I confirmed the patch did work by following your test sequence as below. > > * Before > CPU0 CPU1 CPU2 CPU3 CPU4 ... > 87: 40 0 0 0 0 ... gpg1 0 Edge Test Key > > * After > 87: 40 0 0 0 22 ... gpg1 0 Edge Test Key > > Krzysztof, > Sam and I tested this patch on e850-95 board. > Let me update commit message with test result and will update patchset. Be sure you always run checkpatch on every patch you send. [Checkpatch] WARNING: Prefer a maximum 75 chars per line (possible unwrapped commit description?) Best regards, Krzysztof
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c index 6b58ec84e34b..5d7b788282e9 100644 --- a/drivers/pinctrl/samsung/pinctrl-exynos.c +++ b/drivers/pinctrl/samsung/pinctrl-exynos.c @@ -147,6 +147,19 @@ static int exynos_irq_set_type(struct irq_data *irqd, unsigned int type) return 0; } +static int exynos_irq_set_affinity(struct irq_data *irqd, + const struct cpumask *dest, bool force) +{ + struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd); + struct samsung_pinctrl_drv_data *d = bank->drvdata; + struct irq_data *parent = irq_get_irq_data(d->irq); + + if (parent) + return parent->chip->irq_set_affinity(parent, dest, force); + + return -EINVAL; +} + static int exynos_irq_request_resources(struct irq_data *irqd) { struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd); @@ -212,6 +225,7 @@ static const struct exynos_irq_chip exynos_gpio_irq_chip __initconst = { .irq_mask = exynos_irq_mask, .irq_ack = exynos_irq_ack, .irq_set_type = exynos_irq_set_type, + .irq_set_affinity = exynos_irq_set_affinity, .irq_request_resources = exynos_irq_request_resources, .irq_release_resources = exynos_irq_release_resources, },