Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp648268imm; Mon, 21 May 2018 11:52:05 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoYHUooWaxE01W9RFu9cB0KpFUQUziBth3Si+58NgiGv9MdxdHa2FtFmgrkyi5Um7LkBwH5 X-Received: by 2002:a17:902:43:: with SMTP id 61-v6mr21861275pla.112.1526928725741; Mon, 21 May 2018 11:52:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526928725; cv=none; d=google.com; s=arc-20160816; b=DNHVgiU+rCtA2Vpm7HlStRY+pDxUYs6of1E42cd16HFCkBa3k2Rinaxcft5SMoImgH 2M1ypmIVFDIil8nh22+og6waKb852Lsql1e5eyc3BZEilups9VlcCBFPJDndQFjmq/k4 4W6qbqSJuL2TbI8xJkzMuuQwc50mqWGH/9NgDZMpi3mNVG1Wlmud7o11vjxmHDAOqdZO colCgt28qJUmE00zMHPiUFDlozp8i273now2MowO1WxvcrSQw/HtwcsXdeYNkEqcpwFN HhMERxPa2Z8z12tIjQIyZ0kOTwMucPKoXPrDGclXm1a+pfVj2XstBQwIFG6DZk49pPqB fyLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Fyr/4JRf9UAkOIUtGnb66Xd7lt5y0EIy5DoiH4YPfPw=; b=OJdpyWEpEYAKreYQkvCfkvbbfRvgMzNZx1f/l7htbwBsn0cOI41N+GIB7ghgzzlAbS hYKLNFkQafZbrY450cZrtlrRbdEJ0u3sSFtitSQG1eJDOvzEnjBzxv2wsM3A4Ybgh6FP vE7fhTJhHUHZyJh79eoOoFz96gglezQF7ZRehJkWA7wjU1Gzc5om1Ra4DTOClU3a2iFA icFyt8vRHTKmBVsL3UKSWnowsbAvPg5SdVniANTx9IG7vhsZwLiLtwyYcavfrUFduH2f Ov6OjnYtDqoapF9DfzRQBbbqal0YsNzTjJxfmMqe2TCvtCwd3tuch3o3FAVlmo8PzHK0 wi0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tRtHcNGm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id f66-v6si11398472pgc.391.2018.05.21.11.51.51; Mon, 21 May 2018 11:52:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tRtHcNGm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1751127AbeEUSvd (ORCPT + 99 others); Mon, 21 May 2018 14:51:33 -0400 Received: from mail-vk0-f67.google.com ([209.85.213.67]:42049 "EHLO mail-vk0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750773AbeEUSvb (ORCPT ); Mon, 21 May 2018 14:51:31 -0400 Received: by mail-vk0-f67.google.com with SMTP id j7-v6so9364247vkc.9 for ; Mon, 21 May 2018 11:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Fyr/4JRf9UAkOIUtGnb66Xd7lt5y0EIy5DoiH4YPfPw=; b=tRtHcNGmJ8dcm+apKlC0rkNaaqBp1K8G7sEptOzDUjC8CaCr5ewoxC7bnxeoOwXTkE zbMnSVSnwRQhR3JoKSEo9Y1YVrYd1dXeEcPwDDZcdqNulZ67AWXeFAVQtaWHfpzSdDKO wqyLVNZpnOE1bkmzI/fhSjlRJy5+tgAEy4EDNN7NMXRDJgtJrsZVxTe81xS1dL5cgO7t k8VF4B8IqF6DEuDRx0jdKRwmv4Bcy7jgEb0NKxQhpPtKoXcLTEK50HdXDRU9mhCmiYyD 1+yGQhDPxwuPYNMxJEQC3/vsbcRBRamU6JEbNpPiLRAiy3CoBfIFTDf8efZJqzIOtxlw omHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Fyr/4JRf9UAkOIUtGnb66Xd7lt5y0EIy5DoiH4YPfPw=; b=uZ5XVdfOYCWcVR+eKpQknYD02VkniYaFF+bHpaGaW9tvMfSi1AnabROkNMvo2HqDWM HgHyVNXc2r5ELhL577WHONh+1OKOmMMGEKXI/ArsPTT6ppEJ65/tdf+EZVm/ExyVMP1Q tSALUoGnnfRzeeilmP4rQCiL1EqkVKlHUzmFYHDAzNrbLNULx8L3DnrrnQeAOzzNjEOp vkv64F1jmRtknaQAaHSxn7ZaLLA9t3Dr9iIZnkpTJ4iXH05DC2rss1EmPH6bWHbgbRuz fI9TyXwGfvWUtTTgqfsvv6RRyNR+espZpH6LHeuoHtNX/tB+XwPNucaeE13DKxjWzkyP zAXw== X-Gm-Message-State: ALKqPwdREitnhrdzeSdDP9YOjS1AJDsTu+pkDP0UFBmkCGYpIi3vORkp JPt2uzveFF9YJ70rr0U6xHQikdHFAaFmW0/G5XA= X-Received: by 2002:a1f:1b06:: with SMTP id b6-v6mr14050873vkb.25.1526928690631; Mon, 21 May 2018 11:51:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.144.74 with HTTP; Mon, 21 May 2018 11:51:30 -0700 (PDT) In-Reply-To: References: <5af57fea.1c69fb81.885f0.2377.GMRIR@mx.google.com> <20180511123915.GC16141@n2100.armlinux.org.uk> <1526303498.3494.11.camel@pengutronix.de> From: Pintu Kumar Date: Tue, 22 May 2018 00:21:30 +0530 Message-ID: Subject: Re: Delivery Status Notification (Failure) To: Lucas Stach Cc: Russell King - ARM Linux , open list , linux-arm-kernel@lists.infradead.org, kernelnewbies@kernelnewbies.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dear Lucas, Can you give me some pointers on how to set affinity for entire GPIO Bank. Currently I am exploring drivers/gpio/gpio-mxc.c to find out how the GPIO banks are set up. I also found that affinity can be set using: desc->irq_data.affinity, may be by using cpumask_copy(...). But still I am not familiar with this. So, I need your help. Thank You! Regards, Pintu On Thu, May 17, 2018 at 6:58 PM, Pintu Kumar wrote: > On Mon, May 14, 2018 at 7:58 PM, Pintu Kumar wrote: >> >> On Mon, May 14, 2018 at 6:41 PM, Lucas Stach wrote: >> > Am Montag, den 14.05.2018, 17:42 +0530 schrieb Pintu Kumar: >> >> Hi, >> >> >> >> Is there any work around possible to set IRQ affinity for some GPIO >> >> interrupt ? >> >> How to avoid CPU0 to receive the current GPIO interrupt ? >> >> How do we assign GPIO interrupts to any CPU other than CPU0 ? >> >> Is it possible to isolate CPU0 for a sometime, from my GPIO driver so >> >> that GPIO interrupt can be served by another CPU ? >> >> >> >> Need your inputs to decide whether it is still possible to set >> >> affinity for GPIO interrupt, or its impossible ? >> > >> > This is not possible. The GPIO IRQs are aggregated into one GPC/GIC IRQ >> > line per GPIO bank, so it is not possible to change affinity of a >> > single GPIO interrupt to another CPU. >> >> OK. Thanks for your confirmation. >> >> > Best we could do is change the >> > affinity of the whole bank, >> > > Hi, > > I found that the driver is responsible for setting GPIO bank in i.MX7: > https://elixir.bootlin.com/linux/v4.2/source/drivers/gpio/gpio-mxc.c > > However I still dont know how to set the cpumask for one of the GPIO Bank. > > From this link, it seems it is possible to set affinity for a GPIO IRQ. > https://community.nxp.com/thread/303144 > > But when I try it form my GPIO138 (GPIO5_IO10) it did not help. > > So, as you said, I wanted to change affinity for the whole GPIO bank and try it. > Please give me some pointers. > > Thanks > > >> OK. How can we do this on the fly from my driver code. >> If you have any reference please let me know. >> This is required only for experimental purpose to prove the point to be mgmt. >> My idea is, from the driver, change the affinity of the whole bank. >> So, the GPIO interrupt can be delivered on to this specific CPU bank. >> Once I am done, I will revert back to the old bank. >> Please give me some hint on how to do this from my kernel module.... >> >> >> > but given the limited usefulness of >> > something like that, nobody bothered to implement such a thing. >> > >> > Regards, >> > Lucas >> > >> >> >> >> >> >> On Fri, May 11, 2018 at 8:07 PM, Pintu Kumar >> >> wrote: >> >> > On Fri, May 11, 2018 at 6:34 PM, Lucas Stach > >> > e> wrote: >> >> > > Am Freitag, den 11.05.2018, 13:39 +0100 schrieb Russell King - >> >> > > ARM Linux: >> >> > > > On Fri, May 11, 2018 at 05:07:37PM +0530, Pintu Kumar wrote: >> >> > > > > Hi, >> >> > > > > >> >> > > > > I need one help. >> >> > > > > I am using i.MX7 Sabre board with kernel version 4.1.15 >> >> > > > > >> >> > > > > Let's say I am interested in GPIO number: 21 >> >> > > > > I wanted to set CPU affinity for particular GPIO->IRQ number, >> >> > > > > so I >> >> > > > > tried the below steps: >> >> > > > > root@10:~# echo 21 > /sys/class/gpio/export >> >> > > > > root@10:~# echo "rising" > /sys/class/gpio/gpio21/edge >> >> > > > > root@10:~# cat /proc/interrupts | grep 21 >> >> > > > > 47: 0 0 gpio-mxc 21 Edge gpiolib >> >> > > > > root@10:~# cat /sys/class/gpio/gpio21/direction >> >> > > > > in >> >> > > > > root@10:~# cat /proc/irq/47/smp_affinity >> >> > > > > 3 >> >> > > > > root@10:~# echo 2 > /proc/irq/47/smp_affinity >> >> > > > > -bash: echo: write error: Input/output error >> >> > > > > >> >> > > > > But I get input/output error. >> >> > > > > When I debug further, found that irq_can_set_affinity is >> >> > > > > returning 0: >> >> > > > > [ 0.000000] genirq: irq_can_set_affinity (0): balance: 1, >> >> > > > > irq_data.chip: a81b7e48, irq_set_affinity: (null) >> >> > > > > [ 0.000000] write_irq_affinity: FAIL >> >> > > > > >> >> > > > > I also tried first setting /proc/irq/default_smp_affinity to >> >> > > > > 2 (from 3). >> >> > > > > This change is working, but the smp_affinity setting for the >> >> > > > > new IRQ >> >> > > > > is not working. >> >> > > > > >> >> > > > > When I try to set smp_affinity for mmc0, then it works. >> >> > > > > # cat /proc/interrupts | grep mmc >> >> > > > > 295: 55 0 GPCV2 22 Edge mmc0 >> >> > > > > 296: 0 0 GPCV2 23 Edge mmc1 >> >> > > > > 297: 52 0 GPCV2 24 Edge mmc2 >> >> > > > > >> >> > > > > root@10:~# echo 2 > /proc/irq/295/smp_affinity >> >> > > > > root@10:~# >> >> > > > > >> >> > > > > >> >> > > > > So, I wanted to know what are the conditions for which >> >> > > > > setting >> >> > > > > smp_affinity for an IRQ will work ? >> >> > > > > >> >> > > > > Is there any way by which I can set CPU affinity to a GPIO -> >> >> > > > > IRQ ? >> >> > > > > Whether, irq_set_affinity_hint() will work in this case ? >> >> > > > >> >> > > > IRQ affinity is only supported where interrupts are _directly_ >> >> > > > wired to >> >> > > > the GIC. It's the GIC which does the interrupt steering to the >> >> > > > CPU >> >> > > > cores. >> >> > > > >> >> > > > Interrupts on downstream interrupt controllers (such as GPCV2) >> >> > > > have no >> >> > > > ability to be directed independently to other CPUs - the only >> >> > > > possible >> >> > > > way to change the mapping is to move _all_ interrupts on that >> >> > > > controller, >> >> > > > and any downstream chained interrupts at GIC level. >> >> > > > >> >> > > > Hence why Interrupt 295 has no irq_set_affinity function: there >> >> > > > is no way >> >> > > > for the interrupt controller itself to change the affinity of >> >> > > > the input >> >> > > > interrupt. >> >> > > >> >> > > The GPCv2 though is a secondary IRQ controller which has a 1:1 >> >> > > mapping >> >> > > of its input IRQs to the upstream GIC IRQ lines. Affinity can >> >> > > thus be >> >> > > handled by forwarding the request to the GIC by >> >> > > irq_chip_set_affinity_parent(). >> >> > > >> >> > > As this is handled correctly in the upstream kernel since the >> >> > > first >> >> > > commit introducing support for the GPCv2, it seems the issue is >> >> > > only >> >> > > present in some downstream kernel. >> >> > > >> >> > >> >> > OK. Thanks so much for your reply. >> >> > >> >> > I saw some of the drivers using irq_set_affinity_hint() to force >> >> > the >> >> > IRQ affinity to a particular CPU. >> >> > This is the sample: >> >> > { >> >> > cpumask_clear(mask); >> >> > cpumask_set_cpu(cpu, mask); >> >> > irq_set_affinity_hint(irq, mask); >> >> > } >> >> > >> >> > Whether this logic will work for a particular GPIO pin ? >> >> > > > >> >> >> > >> >> > > Regards, >> >> > > Lucas