Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp281924pxb; Mon, 8 Feb 2021 23:27:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJpUqA91L92Dib6Vbgai+ivq/qBZpeXtsphIjCo10l746Cb7GkogFCvCyVmbBMoq5oKeH0 X-Received: by 2002:aa7:da55:: with SMTP id w21mr21849515eds.138.1612855670945; Mon, 08 Feb 2021 23:27:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612855670; cv=none; d=google.com; s=arc-20160816; b=T1QIGdfZKMKcIb04EJwMeBkX2xVPAE2zSYOW7Ou5ugGXH/YHQxCVerXoyZIpmVl4P8 Usc723YIVyCqbB/zG09aw4xojdvG+2GCjSM/JfMQRXjyboafAOjyxheWAb6ux/QbKx0u WkYGf2UYHIrUKLh3XKFmedcBrGyz8C27uXTAO1p2ePBUU9yIYEeobirOpzmR5eXbGLzV gEBh8ReUdQRPJ2/PsW8KcSIT4MRkJd0W4Qoam8w29I/W1pHCKMln52fPEqXLjoZtlc07 0xjg754CL5S/BJ8j0AmbJ3yvy58l45AMbX51NugaXBHyD8vY3MwonctwlnfTCdWkv53A ExpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=xqWbyUez/O6HTnPRNNtie+gqfQpBvGdQQURvflxNtyk=; b=CbCZwJ7Gu9gHWd5T+UaPo653H0KSqgrVl742zcVd08R4Vu9+t3b9IBOIwxPfOljv7H N2z9Ph7gBlVIBSNrKEKhtIfcHYmtkYBpcMaxeOI7AV3ELZf+2yzJ5FVY4H7eNTWjp4cU v2gm8GQyqvXJrRt0KqFxI6jurCOwmVVTcVxoPzf9NfC2KN/hCYp/fSGsKsq/N8ZDbQsS 6oVLzuCM+G/wLXj1eeXipiYB1DcDGywEDTnwXK5wIToua3lrF7pmLdXqZHfGDkXziVcZ N5rhE3lQCLuYqgFbUyBIohqzm4gYt0hV4pZfvGzLR0v7lsgdzoIfkkUG+nEhKQtFycvF VqSA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k23si2329162ejq.693.2021.02.08.23.27.27; Mon, 08 Feb 2021 23:27:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230313AbhBIH0j (ORCPT + 99 others); Tue, 9 Feb 2021 02:26:39 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:12501 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230329AbhBIH0O (ORCPT ); Tue, 9 Feb 2021 02:26:14 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DZZBn4XhfzjLHC; Tue, 9 Feb 2021 15:24:01 +0800 (CST) Received: from [127.0.0.1] (10.40.192.131) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.498.0; Tue, 9 Feb 2021 15:25:22 +0800 Subject: Re: [PATCH v1 1/2] irqchip/gic-v3-its: don't set bitmap for LPI which user didn't allocate To: Marc Zyngier CC: , , References: <1612781926-56206-1-git-send-email-luojiaxing@huawei.com> <1612781926-56206-2-git-send-email-luojiaxing@huawei.com> <508c6c07a2c599ae1fc8b726fda69b44@kernel.org> From: luojiaxing Message-ID: Date: Tue, 9 Feb 2021 15:25:22 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <508c6c07a2c599ae1fc8b726fda69b44@kernel.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [10.40.192.131] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/2/8 19:59, Marc Zyngier wrote: > On 2021-02-08 10:58, Luo Jiaxing wrote: >> The driver sets the LPI bitmap of device based on >> get_count_order(nvecs). >> This means that when the number of LPI interrupts does not meet the >> power >> of two, redundant bits are set in the LPI bitmap. However, when free >> interrupt, these redundant bits is not cleared. As a result, device will >> fails to allocate the same numbers of interrupts next time. >> >> Therefore, clear the redundant bits set in LPI bitmap. >> >> Fixes: 4615fbc3788d ("genirq/irqdomain: Don't try to free an interrupt >> that has no mapping") >> >> Signed-off-by: Luo Jiaxing >> --- >>  drivers/irqchip/irq-gic-v3-its.c | 4 ++++ >>  1 file changed, 4 insertions(+) >> >> diff --git a/drivers/irqchip/irq-gic-v3-its.c >> b/drivers/irqchip/irq-gic-v3-its.c >> index ed46e60..027f7ef 100644 >> --- a/drivers/irqchip/irq-gic-v3-its.c >> +++ b/drivers/irqchip/irq-gic-v3-its.c >> @@ -3435,6 +3435,10 @@ static int its_alloc_device_irq(struct >> its_device *dev, int nvecs, irq_hw_number >> >>      *hwirq = dev->event_map.lpi_base + idx; >> >> +    bitmap_clear(dev->event_map.lpi_map, >> +             idx + nvecs, >> +             roundup_pow_of_two(nvecs) - nvecs); >> + >>      return 0; >>  } > > What makes you think that the remaining LPIs are free to be released? I think that the LPI bitmap is used to mark the valid LPI interrupts allocated to the PCIe device. Therefore, for the remaining LPIs, the ITS can reserve entries in the ITT table, but the bitmap does not need to be set. Maybe my understanding is wrong, and I'm a little confused about the function of this bitmap. > Even if the end-point has request a non-po2 number of MSIs, it could > very well rely on the the rest of it to be available (specially in the > case of PCI Multi-MSI). yes, you are right. But for Multi-MSI, does it mean that one PCIE device can own several MSI interrupts? Another question, is it possible for module driver to use these remaining LPIs? For example, in my case I allcoate 32 MSI with 16 affi-IRQ in it. MSI can only offer 20 MSIs because online CPU number is 4 and it create 20 msi desc then. ITS create a its device for this PCIe device and generate a ITT tabel for 32 MSIs. so in MSI, it provide 20 valid MSIs, but in ITS, lpi bitmap show that 32 MSI is allocated. This logic is a bit strange and a little incomprehensible. > > Have a look at the thread pointed out by John for a potential fix. Sorry for missing that, I think it can fix my issue too, let me test it later. Thanks jiaxing > > Thanks, > >         M.