Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2785539ybl; Mon, 19 Aug 2019 07:30:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqy62T/9jfG/DRwu6XrO4SiuF3JgU9ldFLhVis2eTAUSFi9217BAhLagkPpBr/2jg59RvMhZ X-Received: by 2002:a62:86cf:: with SMTP id x198mr15510989pfd.195.1566225046742; Mon, 19 Aug 2019 07:30:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566225046; cv=none; d=google.com; s=arc-20160816; b=vvyS6VF5XLc9+s+WC8A62IGapEJvebKvElzq3/7fqLc/yj5sbtQzJJVuRjr0PNRbre GqgdmyPd+6UJoRXvC0eytw2dQXHaEtreZtW93jUC/iGD6sNwchvlvDFDjD8Ar41zr1Pz c/XoKCPjaahNPqqosuhn3l2l1v2VI6v3+ynPw0gpvJE5nTF7Te6TXQqqWoB0XZ4/vWjC +Ag3cWlcv8i0PVmjGV9qJ77GTknuonoSj0ehFpOlq4Uk04eEyF+WYoFGGihWED/rW7Kj ePLKeMUWVEDvhTIXC50+svUNaR05vneqVuRy8MQhC+jLW8KqQt9fKdbsaNiIrbuh/l/7 Xn+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=r5mBeFtaBUfDME+qGaA6uWTkVCT+b0MkeyXCp7X+Tcc=; b=YGb3bDx8pXaUtfTO/Yv9LMWjfopTT7ozOkxPuxPRhS6fohBMY0wSqB6qe1J/rWzbDe Du+mMzF+4tmeqq3xX6QhVoS3VAhdD7WaaZR0+OMAM4MDX3KlcN3DaAGi+r6g1+sNPel7 aeHtvXOVfb9Jf9xO9s57ohk0MAHEt8/dWzNuvZgvX11CinBhpLpXP7pmIpKi3v3Zcua6 JzlUltNjui4C4PO7Sn/Q9LW/z/bWySkfBw7bVd+QZ+zpbi8NqQBwB2n+TqGcFwgLD3t0 yW2N9Oc6AuvZo1NHLoLID/lYcyZva1hcW+zMxCTvfxAMBLXSrknWDhLO1vDUZ36OCN8R nGog== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l186si9758213pge.215.2019.08.19.07.30.30; Mon, 19 Aug 2019 07:30:46 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726959AbfHSO3R (ORCPT + 99 others); Mon, 19 Aug 2019 10:29:17 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5158 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726314AbfHSO3R (ORCPT ); Mon, 19 Aug 2019 10:29:17 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 90E4EABBEAC6BB8EC53D; Mon, 19 Aug 2019 22:29:13 +0800 (CST) Received: from [127.0.0.1] (10.184.12.158) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Mon, 19 Aug 2019 22:29:07 +0800 Subject: Re: [PATCH v2 01/12] irqchip/gic: Rework gic_configure_irq to take the full ICFGR base To: Marc Zyngier CC: Thomas Gleixner , Jason Cooper , Julien Thierry , Rob Herring , Lokesh Vutla , John Garry , , "Shameerali Kolothum Thodi" , References: <20190806100121.240767-1-maz@kernel.org> <20190806100121.240767-2-maz@kernel.org> From: Zenghui Yu Message-ID: Date: Mon, 19 Aug 2019 22:26:25 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:64.0) Gecko/20100101 Thunderbird/64.0 MIME-Version: 1.0 In-Reply-To: <20190806100121.240767-2-maz@kernel.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.184.12.158] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marc, On 2019/8/6 18:01, Marc Zyngier wrote: > gic_configure_irq is currently passed the (re)distributor address, > to which it applies an a fixed offset to get to the configuration > registers. This offset is constant across all GICs, or rather it was > until to v3.1... > > An easy way out is for the individual drivers to pass the base > address of the configuration register for the considered interrupt. > At the same time, move part of the error handling back to the > individual drivers, as things are about to change on that front. > > Signed-off-by: Marc Zyngier > --- > drivers/irqchip/irq-gic-common.c | 14 +++++--------- > drivers/irqchip/irq-gic-v3.c | 11 ++++++++++- > drivers/irqchip/irq-gic.c | 10 +++++++++- > drivers/irqchip/irq-hip04.c | 7 ++++++- > 4 files changed, 30 insertions(+), 12 deletions(-) > > diff --git a/drivers/irqchip/irq-gic-common.c b/drivers/irqchip/irq-gic-common.c > index b0a8215a13fc..6900b6f0921c 100644 > --- a/drivers/irqchip/irq-gic-common.c > +++ b/drivers/irqchip/irq-gic-common.c > @@ -63,7 +63,7 @@ int gic_configure_irq(unsigned int irq, unsigned int type, > * for "irq", depending on "type". > */ > raw_spin_lock_irqsave(&irq_controller_lock, flags); > - val = oldval = readl_relaxed(base + GIC_DIST_CONFIG + confoff); > + val = oldval = readl_relaxed(base + confoff); > if (type & IRQ_TYPE_LEVEL_MASK) > val &= ~confmask; > else if (type & IRQ_TYPE_EDGE_BOTH) > @@ -83,14 +83,10 @@ int gic_configure_irq(unsigned int irq, unsigned int type, > * does not allow us to set the configuration or we are in a > * non-secure mode, and hence it may not be catastrophic. > */ > - writel_relaxed(val, base + GIC_DIST_CONFIG + confoff); > - if (readl_relaxed(base + GIC_DIST_CONFIG + confoff) != val) { > - if (WARN_ON(irq >= 32)) > - ret = -EINVAL; Since this WARN_ON is dropped, the comment above should also be updated. But what is the reason for deleting it? (It may give us some points when we fail to set type for SPIs.) Thanks, zenghui > - else > - pr_warn("GIC: PPI%d is secure or misconfigured\n", > - irq - 16); > - } > + writel_relaxed(val, base + confoff); > + if (readl_relaxed(base + confoff) != val) > + ret = -EINVAL; > + > raw_spin_unlock_irqrestore(&irq_controller_lock, flags); > > if (sync_access) > diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c > index 96d927f0f91a..b250e69908f8 100644 > --- a/drivers/irqchip/irq-gic-v3.c > +++ b/drivers/irqchip/irq-gic-v3.c > @@ -407,6 +407,7 @@ static int gic_set_type(struct irq_data *d, unsigned int type) > unsigned int irq = gic_irq(d); > void (*rwp_wait)(void); > void __iomem *base; > + int ret; > > /* Interrupt configuration for SGIs can't be changed */ > if (irq < 16) > @@ -425,7 +426,15 @@ static int gic_set_type(struct irq_data *d, unsigned int type) > rwp_wait = gic_dist_wait_for_rwp; > } > > - return gic_configure_irq(irq, type, base, rwp_wait); > + > + ret = gic_configure_irq(irq, type, base + GICD_ICFGR, rwp_wait); > + if (ret && irq < 32) { > + /* Misconfigured PPIs are usually not fatal */ > + pr_warn("GIC: PPI%d is secure or misconfigured\n", irq - 16); > + ret = 0; > + } > + > + return ret; > } > > static int gic_irq_set_vcpu_affinity(struct irq_data *d, void *vcpu) > diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c > index e45f45e68720..ab48760acabb 100644 > --- a/drivers/irqchip/irq-gic.c > +++ b/drivers/irqchip/irq-gic.c > @@ -291,6 +291,7 @@ static int gic_set_type(struct irq_data *d, unsigned int type) > { > void __iomem *base = gic_dist_base(d); > unsigned int gicirq = gic_irq(d); > + int ret; > > /* Interrupt configuration for SGIs can't be changed */ > if (gicirq < 16) > @@ -301,7 +302,14 @@ static int gic_set_type(struct irq_data *d, unsigned int type) > type != IRQ_TYPE_EDGE_RISING) > return -EINVAL; > > - return gic_configure_irq(gicirq, type, base, NULL); > + ret = gic_configure_irq(gicirq, type, base + GIC_DIST_CONFIG, NULL); > + if (ret && gicirq < 32) { > + /* Misconfigured PPIs are usually not fatal */ > + pr_warn("GIC: PPI%d is secure or misconfigured\n", gicirq - 16); > + ret = 0; > + } > + > + return ret; > } > > static int gic_irq_set_vcpu_affinity(struct irq_data *d, void *vcpu) > diff --git a/drivers/irqchip/irq-hip04.c b/drivers/irqchip/irq-hip04.c > index cf705827599c..1626131834a6 100644 > --- a/drivers/irqchip/irq-hip04.c > +++ b/drivers/irqchip/irq-hip04.c > @@ -130,7 +130,12 @@ static int hip04_irq_set_type(struct irq_data *d, unsigned int type) > > raw_spin_lock(&irq_controller_lock); > > - ret = gic_configure_irq(irq, type, base, NULL); > + ret = gic_configure_irq(irq, type, base + GIC_DIST_CONFIG, NULL); > + if (ret && irq < 32) { > + /* Misconfigured PPIs are usually not fatal */ > + pr_warn("GIC: PPI%d is secure or misconfigured\n", irq - 16); > + ret = 0; > + } > > raw_spin_unlock(&irq_controller_lock); > >