From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jon Hunter Subject: Re: [PATCH 06/15] irqdomain: Ensure type settings match for an existing mapping Date: Fri, 18 Mar 2016 10:33:26 +0000 Message-ID: <56EBD976.7090107@nvidia.com> References: <1458224359-32665-1-git-send-email-jonathanh@nvidia.com> <1458224359-32665-7-git-send-email-jonathanh@nvidia.com> <56EAF4E1.5020201@nvidia.com> <56EBD272.1040404@ti.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <56EBD272.1040404-l0cyMroinI0@public.gmane.org> Sender: linux-tegra-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Grygorii Strashko , Thomas Gleixner , Jason Cooper , Marc Zyngier , =?UTF-8?Q?Beno=c3=aet_Cousson?= , Tony Lindgren , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Stephen Warren , Thierry Reding Cc: Kevin Hilman , Geert Uytterhoeven , Lars-Peter Clausen , Linus Walleij , linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-tegra@vger.kernel.org On 18/03/16 10:03, Grygorii Strashko wrote: > On 03/17/2016 08:18 PM, Jon Hunter wrote: >> >> On 17/03/16 14:19, Jon Hunter wrote: >>> When mapping an IRQ, if a mapping already exists, then we simply return >>> the virtual IRQ number. However, we do not check that the type settings >>> for the existing mapping match those for the mapping that is about to be >>> created. It may be unlikely that the type settings would not match, but >>> check for this and don't return a valid IRQ mapping if the type settings >>> do not match. >>> >>> WARN if the type return by irq_domain_translate() has bits outside the >>> sense mask set and then clear these bits. If these bits are not cleared >>> then this will cause the comparision of the type settings for an >>> existing mapping to fail with that of the new mapping even if the sense >>> bit themselves match. The reason being is that the existing type >>> settings are read by calling irq_get_trigger_type() which will clear >>> any bits outside the sense mask. This will allow us to detect irqchips >>> that are not correctly clearing these bits and fix them. >>> >>> Signed-off-by: Jon Hunter >>> --- >>> kernel/irq/irqdomain.c | 59 >>> ++++++++++++++++++++++++++++++++++++-------------- >>> 1 file changed, 43 insertions(+), 16 deletions(-) >>> >>> diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c >>> index 3a519a01118b..0ea285baa619 100644 >>> --- a/kernel/irq/irqdomain.c >>> +++ b/kernel/irq/irqdomain.c >>> @@ -549,6 +549,13 @@ static int irq_domain_translate(struct >>> irq_domain *d, >>> fwspec->param, fwspec->param_count, >>> hwirq, type); >>> > > >>> + /* >>> + * WARN if the irqchip returns a type with bits >>> + * outside the sense mask set and clear these bits. >>> + */ >>> + if (WARN_ON(*type & ~IRQ_TYPE_SENSE_MASK)) >>> + *type &= IRQ_TYPE_SENSE_MASK; > > Not sure that this warn and in this place make sense. > type will come unchanged here from caller irq_create_fwspec_mapping() Yes you are right. I missed the return statement. I can move to irq_create_fwspec_mapping(). Cheers Jon From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756871AbcCRKdo (ORCPT ); Fri, 18 Mar 2016 06:33:44 -0400 Received: from hqemgate16.nvidia.com ([216.228.121.65]:19369 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752188AbcCRKdd (ORCPT ); Fri, 18 Mar 2016 06:33:33 -0400 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Fri, 18 Mar 2016 03:32:40 -0700 Subject: Re: [PATCH 06/15] irqdomain: Ensure type settings match for an existing mapping To: Grygorii Strashko , Thomas Gleixner , Jason Cooper , Marc Zyngier , =?UTF-8?Q?Beno=c3=aet_Cousson?= , Tony Lindgren , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , "Kumar Gala" , Stephen Warren , "Thierry Reding" References: <1458224359-32665-1-git-send-email-jonathanh@nvidia.com> <1458224359-32665-7-git-send-email-jonathanh@nvidia.com> <56EAF4E1.5020201@nvidia.com> <56EBD272.1040404@ti.com> CC: Kevin Hilman , Geert Uytterhoeven , Lars-Peter Clausen , Linus Walleij , , , , From: Jon Hunter Message-ID: <56EBD976.7090107@nvidia.com> Date: Fri, 18 Mar 2016 10:33:26 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <56EBD272.1040404@ti.com> X-Originating-IP: [10.21.132.114] X-ClientProxiedBy: UKMAIL101.nvidia.com (10.26.138.13) To UKMAIL101.nvidia.com (10.26.138.13) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18/03/16 10:03, Grygorii Strashko wrote: > On 03/17/2016 08:18 PM, Jon Hunter wrote: >> >> On 17/03/16 14:19, Jon Hunter wrote: >>> When mapping an IRQ, if a mapping already exists, then we simply return >>> the virtual IRQ number. However, we do not check that the type settings >>> for the existing mapping match those for the mapping that is about to be >>> created. It may be unlikely that the type settings would not match, but >>> check for this and don't return a valid IRQ mapping if the type settings >>> do not match. >>> >>> WARN if the type return by irq_domain_translate() has bits outside the >>> sense mask set and then clear these bits. If these bits are not cleared >>> then this will cause the comparision of the type settings for an >>> existing mapping to fail with that of the new mapping even if the sense >>> bit themselves match. The reason being is that the existing type >>> settings are read by calling irq_get_trigger_type() which will clear >>> any bits outside the sense mask. This will allow us to detect irqchips >>> that are not correctly clearing these bits and fix them. >>> >>> Signed-off-by: Jon Hunter >>> --- >>> kernel/irq/irqdomain.c | 59 >>> ++++++++++++++++++++++++++++++++++++-------------- >>> 1 file changed, 43 insertions(+), 16 deletions(-) >>> >>> diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c >>> index 3a519a01118b..0ea285baa619 100644 >>> --- a/kernel/irq/irqdomain.c >>> +++ b/kernel/irq/irqdomain.c >>> @@ -549,6 +549,13 @@ static int irq_domain_translate(struct >>> irq_domain *d, >>> fwspec->param, fwspec->param_count, >>> hwirq, type); >>> > > >>> + /* >>> + * WARN if the irqchip returns a type with bits >>> + * outside the sense mask set and clear these bits. >>> + */ >>> + if (WARN_ON(*type & ~IRQ_TYPE_SENSE_MASK)) >>> + *type &= IRQ_TYPE_SENSE_MASK; > > Not sure that this warn and in this place make sense. > type will come unchanged here from caller irq_create_fwspec_mapping() Yes you are right. I missed the return statement. I can move to irq_create_fwspec_mapping(). Cheers Jon