Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp662458pxb; Tue, 2 Feb 2021 14:46:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJylzLVTCmCR0gW84jlhVkILMQ9RKA+F2YBdyt6fzZketYNK8hfLHr5wGOnVqnFzF8cDVi4J X-Received: by 2002:aa7:dc0d:: with SMTP id b13mr326398edu.170.1612306006145; Tue, 02 Feb 2021 14:46:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612306006; cv=none; d=google.com; s=arc-20160816; b=HmQGnC1t3zCRq+3JJwzPE2q2MZK1gX0m3oKQes86+ft+FssELx7uFQoWTQ2QSw9j/z d9UYaJgX/yyr7E+67ym4PfLngRDGa6U5bjl6kQIHcDM7ZoyPuysWtJ7GzdnxK3WRQN3b y+ZiC9DXo3b26RD2bIBLvRUYSi0VUjRlunZuwdt2PZg7YbkecUnOwCjEBGNywKCrs8uk 8I1ah3L9eOjIkiqqhBR52W4Si4iK9wjVVWtKg3fSAdYs4qo8iFRBSg67fcz6urHAMDqW wVLfIzgtsxx9b0NrDyrvOiYRqWza6pQ3NfO2kZU12yT6CIQwgbbExjT/33IPsod2E57c 2jOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=1Q6XNyHEQuecyokg5KIhGDm/GD44rZvoy4elg3Z2sEA=; b=SM05rwegB9R0Cnv50UmXa9RmmSeKSavHUqUZtfjnMvrIz7G7iXZIcxxN1R9Uo4YSrk oEUxEwr7KiKuTqWgdsRFwNt5HvB3e7+PIowBDv6arrzVWJcuGnfbieq5b7Mssj8KdbH9 mFvJPiGEsTFT1dt71KnGVQTkpvYZKtETjOlnXCPQIGTbw/Wao5dxHhF5Z8IXea9IqPyc AK8GOAfMlXLAm30iHiTV10paQosqI6C+4pcpI+8iJX5TJwuGbl0QqcVfMbBP7fyBGoGu blQOt83XzoY/tK2L0npFqc43C4dlDBi0IL+wX5a5TEpplBy07mkLnMvAm2nbx7exGVUx dToA== 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 dk8si93102edb.76.2021.02.02.14.46.21; Tue, 02 Feb 2021 14:46:46 -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 S235195AbhBBPub (ORCPT + 99 others); Tue, 2 Feb 2021 10:50:31 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]:2483 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235646AbhBBPsg (ORCPT ); Tue, 2 Feb 2021 10:48:36 -0500 Received: from fraeml714-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4DVTdP4plgz67jmx; Tue, 2 Feb 2021 23:44:25 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml714-chm.china.huawei.com (10.206.15.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 2 Feb 2021 16:47:54 +0100 Received: from [10.47.3.41] (10.47.3.41) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 2 Feb 2021 15:47:53 +0000 Subject: Re: PCI MSI issue with reinserting a driver To: Marc Zyngier CC: Thomas Gleixner , Zhou Wang , References: <87o8h3lj0n.wl-maz@kernel.org> <8a54fdd0-950b-f801-e83d-750aef73ab3c@huawei.com> <4848792ce8c9ed7490e2205281a3cbda@kernel.org> From: John Garry Message-ID: <28c56995-501a-880b-e6dd-ac76b8290c2c@huawei.com> Date: Tue, 2 Feb 2021 15:46:25 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 In-Reply-To: <4848792ce8c9ed7490e2205281a3cbda@kernel.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.47.3.41] X-ClientProxiedBy: lhreml733-chm.china.huawei.com (10.201.108.84) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/02/2021 14:48, Marc Zyngier wrote: >>> >>> Not sure. I also now notice an error for the SAS PCI driver on D06 >>> when nr_cpus < 16, which means number of MSI vectors allocated < 32, >>> so looks the same problem. There we try to allocate 16 + max(nr cpus, >>> 16) MSI. >>> >>> Anyway, let me have a look today to see what is going wrong. >>> >> Could this be the problem: >> >> nr_cpus=11 >> >> In alloc path, we have: >>     its_alloc_device_irq(nvecs=27 = 16+11) >>       bitmap_find_free_region(order = 5); >> In free path, we have: >>     its_irq_domain_free(nvecs = 1) and free each 27 vecs >>       bitmap_release_region(order = 0) >> >> So we allocate 32 bits, but only free 27. And 2nd alloc for 32 fails. [ ... ] >> >> >> But I'm not sure that we have any requirement for those map bits to be >> consecutive. > > We can't really do that. All the events must be contiguous, > and there is also a lot of assumptions in the ITS driver that > LPI allocations is also contiguous. > > But there is also the fact that for Multi-MSI, we *must* > allocate 32 vectors. Any driver could assume that if we have > allocated 17 vectors, then there is another 15 available. > > My question still stand: how was this working with the previous > behaviour? Because previously in this scenario we would allocate 32 bits and free 32 bits in the map; but now we allocate 32 bits, yet only free 27 - so leak 5 bits. And this comes from how irq_domain_free_irqs_hierarchy() now frees per-interrupt, instead of all irqs per domain. Before: In free path, we have: its_irq_domain_free(nvecs = 27) bitmap_release_region(count order = 5 == 32bits) Current: In free path, we have: its_irq_domain_free(nvecs = 1) for free each 27 vecs bitmap_release_region(count order = 0 == 1bit) Cheers, John