Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2198682ybe; Tue, 3 Sep 2019 09:17:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwyyTTHJeQJx+cJFrAuCyfQyYUgSj/VUdGzCntdO402SSHjupyveUD8Dv0IvhqrMhhdz3nx X-Received: by 2002:a17:90a:fc89:: with SMTP id ci9mr113340pjb.48.1567527450536; Tue, 03 Sep 2019 09:17:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567527450; cv=none; d=google.com; s=arc-20160816; b=j3nsQFC5BwilL4EAJ8XZz0KisB2UWV+S7q3u6Fpoeq0//LxyWsixbKcER0yBWK4wNa omVLmI1cmJbtJ2CnRvb2i1ignbGaH1reV6tAL4u9FhSgTShS54DVuVkbUS/z+mqnsJvg TJV+c7UdmbgXH1H7Zjcvg0HTmVd6koU+YIBp8QvSD9sSznPvCA7kK8/0Rzas9oRWMVZ0 ouLVh/yGwxYIMdUo0LbM3Q/7WbqBeD5bwyP8QdCiI/TTgIzZAEB8utB3WTCUWZOXwy7e d37nbJ5O6kSIS6wdTsvclKk0nC4ep709e9VuGgvrOUlw4p2QNR04bE+Gs0opE/rXqxkH NG3Q== 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:organization:from:references:cc:to:subject; bh=6de0vw42YWBEytWt4eqQO9UFQ2kmlDVp92klHi/ghts=; b=qxEAe//YOeh/TSe08KhGdF2NOtXjFLmEbEMDk2+As/m5ForuqaNJFdg6fbOzRTMF6L Lwfbsvp0UPox4bbYHuYDNXV2KE0qqeCbedoLp63TWYPC7eHmeKLzVY3VlOdx6bh4Exok 2OvEPOk16RB54dL9Xcnl3Z9WQUy6y+f+kGCuIH+OWduem6q2OF1GOBIpDWJWlxC1Gr48 +E+yGlD7G6q9dUii3zF3BbqJB87heEB9QMQEpvX4NUGNZHUHpSuUWoKULfsZk/0eb0R3 nTiSeupyzjnQnocs2tKWJKJGHdH90JVrUm0dkSdYafr3L0cBHIJYqL1gv9XleJgD69VG MZrA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q25si15034411pgv.114.2019.09.03.09.17.14; Tue, 03 Sep 2019 09:17:30 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729898AbfICQQT (ORCPT + 99 others); Tue, 3 Sep 2019 12:16:19 -0400 Received: from foss.arm.com ([217.140.110.172]:39972 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728571AbfICQQT (ORCPT ); Tue, 3 Sep 2019 12:16:19 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ADC9B360; Tue, 3 Sep 2019 09:16:18 -0700 (PDT) Received: from [10.1.197.61] (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A960A3F246; Tue, 3 Sep 2019 09:16:17 -0700 (PDT) Subject: Re: PCI/kernel msi code vs GIC ITS driver conflict? To: John Garry , Thomas Gleixner , Bjorn Helgaas Cc: Linux PCI , Linuxarm , "luojiaxing@huawei.com" , "linux-kernel@vger.kernel.org" References: From: Marc Zyngier Organization: Approximate Message-ID: <5fd4c1cf-76c1-4054-3754-549317509310@kernel.org> Date: Tue, 3 Sep 2019 17:16:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi John, On 03/09/2019 15:09, John Garry wrote: > Hi Marc, Bjorn, Thomas, > > We've come across a conflict with the kernel/pci msi code and GIC ITS > driver on our arm64 system, whereby we can't unbind and re-bind a PCI > device driver under special conditions. I'll explain... > > Our PCI device support 32 MSIs. The driver attempts to allocate msi > vectors with min msi=17, max msi = 32, and affd.pre vectors = 16. For > our test we make nr_cpus = 1 (just anything less than 16). Just to confirm: this PCI device is requiring Multi-MSI, right? As opposed to MSI-X? > We find that the pci/kernel msi code gives us 17 vectors, but the GIC > ITS code reserves 32 lpi maps in its_irq_domain_alloc(). The problem > then occurs when unbinding the driver in its_irq_domain_free() call, > where we only clear bits for 17 vectors. So if we unbind the driver and > then attempt to bind again, it fails. Is this device, by any chance, sharing its requested-id with another device? By being behind a bridge of some sort? There is some code to deal with it, but I'm not sure it has ever been verified in anger... > Where the fault lies, I can't say. Maybe the kernel msi code should > always give power of 2 vectors - as I understand, the PCI spec mandates > this. Or maybe the GIC ITS driver has a problem in the free path, as > above. Or maybe the PCI driver should not be allowed to request !power > of 2 min/max vectors. > > Opinion? My hunch is that it is an ITS driver bug: the PCI layer is allowed to give any number of MSIs to an endpoint driver, as long as they match the requirements of the allocation for Multi-MSI. That's the responsibility of the ITS driver. If unbind/bind fails, it means that somehow we've missed the freeing of the LPIs, which isn't good. Is the device common enough that I can try and reproduce the issue? If there's a Linux driver somewhere, I can always hack something in emulation and find out... Thanks, M. -- Jazz is not dead, it just smells funny...