Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4721623ybl; Wed, 22 Jan 2020 03:31:13 -0800 (PST) X-Google-Smtp-Source: APXvYqzOQh1ccSrmbLVyC4xbOKJUNt4d8a32T1NsI/q/mwjWgeLooEYvVZFKwYKcnQVehm0Nls7L X-Received: by 2002:aca:ec50:: with SMTP id k77mr6569737oih.114.1579692673631; Wed, 22 Jan 2020 03:31:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579692673; cv=none; d=google.com; s=arc-20160816; b=lRN9fPSpsBl3SHtpgFcjt6g/ye0WwLLjoPjr5ETwufQE1BVRRN4cSFfxvKaL9IpMXj pj0l2Oh+xkvB4IrZh3Zf6NgHd5suneN9BA+eNPZJf3OgPzHFK4j8EVwx1dycBuS7vYfx 9cQQpltGwoIN4Vfpv1VjEM52ZD7MhmRBJeS/m8ThvH8Q4azXbbDxYCtqv8oORoqcUjJ5 LcdynMvs+j/GTfebHoyPmFJFNywvkA8GaxXK4xfFl9gjg+ZzDoENxyUx7MxlawoGQVT4 HrDLYu1fMPwq9tIayOk+SVLdaBYGy7UmyZY0yCC23PstazKRlTCNef+nQGz2V5abPf6m 1I3Q== 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=zXx8xszmZgSBXwYYeYMorGEUbVUISeiDbJMv3BrHjeQ=; b=DmvuXCxt0rqJA12tkcoy8rICjhwuDwKHjxu0Tz8GqIrqOQ3QsupawCYOgNjATuVk9w dcMHwOpd15riohAa7G36qo4xYTHxqsePbDWmTXYllI+KGCER55tjdqlNtoR0xOUn3vn4 5eTr/8l3/pW/9fc5RxThZkCKNEjAvVgZ1TTTrShkGFst9BdrbBUVwE8etEXxms+5Y+IX rChgii4MSvyuFWr3dFHOxTnXgx738Z7/nIG/45t/izs4l5Uopu1EjDWZzu9gTwjEB5QC wmYyfZ0qcpAcc6FNbV/jV7sFtgKu/O2hUx/5hFAIVLSV9dhhc1Ytg5xVUvrMrosS27sF RAHA== 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 e22si23649871otj.38.2020.01.22.03.31.00; Wed, 22 Jan 2020 03:31:13 -0800 (PST) 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 S1728890AbgAVLaC (ORCPT + 99 others); Wed, 22 Jan 2020 06:30:02 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:10130 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725911AbgAVLaC (ORCPT ); Wed, 22 Jan 2020 06:30:02 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id DCEDA8B92F11E2311C26; Wed, 22 Jan 2020 19:29:59 +0800 (CST) Received: from [127.0.0.1] (10.173.222.27) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.439.0; Wed, 22 Jan 2020 19:29:49 +0800 Subject: Re: [PATCH] irqchip/gic-v3-its: Don't confuse get_vlpi_map() by writing DB config To: Marc Zyngier CC: , , , , References: <20200122085609.658-1-yuzenghui@huawei.com> <4aaaad3ae7367c5c932c430e18550d9e@kernel.org> From: Zenghui Yu Message-ID: <06a484bd-4f46-6884-1bee-9b7b65fd0856@huawei.com> Date: Wed, 22 Jan 2020 19:29:48 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 MIME-Version: 1.0 In-Reply-To: <4aaaad3ae7367c5c932c430e18550d9e@kernel.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.173.222.27] 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 2020/1/22 18:44, Marc Zyngier wrote: > Hi Zenghui, > > Thanks for this. > > On 2020-01-22 08:56, Zenghui Yu wrote: >> When we're writing config for the doorbell interrupt, get_vlpi_map() will >> get confused by doorbell's d->parent_data hack and find the wrong its_dev >> as chip data and the wrong event. >> >> Fix this issue by making sure no doorbells will be involved before >> invoking >> get_vlpi_map(), which restore some of the logic in lpi_write_config(). >> >> Fixes: c1d4d5cd203c ("irqchip/gic-v3-its: Add its_vlpi_map helpers") >> Signed-off-by: Zenghui Yu >> --- >> >> This is based on mainline and can't be directly applied to the current >> irqchip-next. >> >>  drivers/irqchip/irq-gic-v3-its.c | 5 +++-- >>  1 file changed, 3 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/irqchip/irq-gic-v3-its.c >> b/drivers/irqchip/irq-gic-v3-its.c >> index e05673bcd52b..cc8a4fcbd6d6 100644 >> --- a/drivers/irqchip/irq-gic-v3-its.c >> +++ b/drivers/irqchip/irq-gic-v3-its.c >> @@ -1181,12 +1181,13 @@ static struct its_vlpi_map >> *get_vlpi_map(struct irq_data *d) >> >>  static void lpi_write_config(struct irq_data *d, u8 clr, u8 set) >>  { >> -    struct its_vlpi_map *map = get_vlpi_map(d); >>      irq_hw_number_t hwirq; >>      void *va; >>      u8 *cfg; >> >> -    if (map) { >> +    if (irqd_is_forwarded_to_vcpu(d)) { >> +        struct its_vlpi_map *map = get_vlpi_map(d); >> + >>          va = page_address(map->vm->vprop_page); >>          hwirq = map->vintid; > > Shouldn't we fix get_vlpi_map() instead? Something like (untested): > > diff --git a/drivers/irqchip/irq-gic-v3-its.c > b/drivers/irqchip/irq-gic-v3-its.c > index e05673bcd52b..b704214390c0 100644 > --- a/drivers/irqchip/irq-gic-v3-its.c > +++ b/drivers/irqchip/irq-gic-v3-its.c > @@ -1170,13 +1170,14 @@ static void its_send_vclear(struct its_device > *dev, u32 event_id) >   */ >  static struct its_vlpi_map *get_vlpi_map(struct irq_data *d) >  { > -    struct its_device *its_dev = irq_data_get_irq_chip_data(d); > -    u32 event = its_get_event_id(d); > +    if (irqd_is_forwarded_to_vcpu(d)) { > +        struct its_device *its_dev = irq_data_get_irq_chip_data(d); > +        u32 event = its_get_event_id(d); > > -    if (!irqd_is_forwarded_to_vcpu(d)) > -        return NULL; > +        return dev_event_to_vlpi_map(its_dev, event); > +    } > > -    return dev_event_to_vlpi_map(its_dev, event); > +    return NULL; >  } > >  static void lpi_write_config(struct irq_data *d, u8 clr, u8 set) > > > Or am I missing the actual problem? No. I also thought about fixing the issue by this way and I'm OK with both approaches. > > Overall, I'm starting to hate that ->parent hack as it's been the source > of a number of bugs. (thankfully it's rarely used and we've so far handled them carefully, except the lpi_write_config issue in this patch...) > > The main issue is that the VPE hierarchy is missing one level (it has > no ITS domain, and goes directly from the VPE domain to the low-level > GIC domain). It means we end-up special-casing things, and that's never > good... Yeah, this may comes from the fact that the per-vPE doorbell is not served by ITS and can be asserted by redistributor directly. And the special doorbell is programmed together with those normal LPI (translated from MSI by ITS). Thanks, Zenghui