Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5934016ybi; Wed, 12 Jun 2019 10:58:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4Ae673mz8sV6Fndwa611L3C7/aIIv7LZJx9ZbocL70OJc6mH2q+yJfioxqBtkIk8aOR0T X-Received: by 2002:a63:e53:: with SMTP id 19mr1553249pgo.137.1560362311413; Wed, 12 Jun 2019 10:58:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560362311; cv=none; d=google.com; s=arc-20160816; b=f5llZ6X2f3btkBvfFq6LGzImrj6KHjaJcHtGp9MyI5RH4oJ40/dK2QgKhO6pFpCv0Q DJo5L+RYmIq+1DEmnmUd18bW3tjGJiMwwqY1Uza5ZjG/yIYIxH3H98sQ0a1HO6he1WdF blSsqHVLXaAdSpqL6LD9BsqrQXXhujZYLPXHTJaW0qyNrjYyeeln2uj5nTDNA7bE5msD cQJgznkeWjr9bwEQ0ZjuPnSYqONtE7SZWX2TRRNVoIsxCYaf2Xl7X7H5RdtwAG9PSJNe 5fHBkGKqgWZk+LjQ1RkNlRrKLACZddIDR/e/iV5aDR0Gpvip83cJexxgxB6IcHfw95mf vl8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:organization:user-agent :references:in-reply-to:subject:cc:to:from:message-id:date; bh=6hI+fQRuSPWk2BOlgrCpWq7/vPK7gNi0zwbIK+/OYZ0=; b=SSA8oKftRnWoFkJB9/c1IS3aHX6LvuQEw9hqDhQbJ3lLvGOLphXuJI3z71tmrN+6sZ 47tjPsqsqj0333SnAYefKzC2w4Fn406tIjLkVGuLwtLWMPiofLnwdPvWJtqa6lpYzsg6 6kCUeta6p+Ib8AWma3ezyqG3ocDfizqOEBA/+vKinqwSFioLjObfrNG/zsoVivgr3FV/ HHC+poE1SFUvMkyp+UwSdxaLOS9I1CIcSi69VpS+u9aM64yrbmdv9UEwv1IAexIha5yb AyaYm3mMO6XP9XChTjhMQRFd12Ik8Ok2jYaqmIz+0tyShij/0+BoWpsdLg9lsIrH/lQX 629g== 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 s15si426523pjp.38.2019.06.12.10.58.17; Wed, 12 Jun 2019 10:58:31 -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 S1728599AbfFLNCH (ORCPT + 99 others); Wed, 12 Jun 2019 09:02:07 -0400 Received: from foss.arm.com ([217.140.110.172]:52970 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727579AbfFLNCH (ORCPT ); Wed, 12 Jun 2019 09:02:07 -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 1A77228; Wed, 12 Jun 2019 06:02:06 -0700 (PDT) Received: from big-swifty.misterjones.org (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1D6013F246; Wed, 12 Jun 2019 06:02:03 -0700 (PDT) Date: Wed, 12 Jun 2019 14:01:56 +0100 Message-ID: <86r27zarej.wl-marc.zyngier@arm.com> From: Marc Zyngier To: Bharat Kumar Gogada Cc: , , , , , Subject: Re: [PATCH v4] PCI: xilinx-nwl: Fix Multi MSI data programming In-Reply-To: <1560334679-9206-1-git-send-email-bharat.kumar.gogada@xilinx.com> References: <1560334679-9206-1-git-send-email-bharat.kumar.gogada@xilinx.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/26 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Organization: ARM Ltd MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 12 Jun 2019 11:17:59 +0100, Bharat Kumar Gogada wrote: > > The current Multi MSI data programming fails if multiple end points > requesting MSI and multi MSI are connected with switch, i.e the current > multi MSI data being given is not considering the number of vectors > being requested in case of multi MSI. > Ex: Two EP's connected via switch, EP1 requesting single MSI first, > EP2 requesting Multi MSI of count four. The current code gives > MSI data 0x0 to EP1 and 0x1 to EP2, but EP2 can modify lower two bits > due to which EP2 also sends interrupt with MSI data 0x0 which results > in always invoking virq of EP1 due to which EP2 MSI interrupt never > gets handled. I think there is a much simpler explanation for this: Multi-MSI mandates that the base interrupt number is naturally aligned to its size. Having switches in the middle is just a way to expose the issue, but you could see it failing with a single end-point and two MSIs that are assigned on an odd boundary. > > Fix Multi MSI data programming with required alignment by > using number of vectors being requested. > > Fixes: ab597d35ef11 ("PCI: xilinx-nwl: Add support for Xilinx NWL PCIe > Host Controller") > > Signed-off-by: Bharat Kumar Gogada > --- > V4: > - Using a different bitmap registration API whcih serves single and multi > MSI requests. > --- > drivers/pci/controller/pcie-xilinx-nwl.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/drivers/pci/controller/pcie-xilinx-nwl.c b/drivers/pci/controller/pcie-xilinx-nwl.c > index 81538d7..a9e07b8 100644 > --- a/drivers/pci/controller/pcie-xilinx-nwl.c > +++ b/drivers/pci/controller/pcie-xilinx-nwl.c > @@ -483,15 +483,13 @@ static int nwl_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, > int i; > > mutex_lock(&msi->lock); > - bit = bitmap_find_next_zero_area(msi->bitmap, INT_PCI_MSI_NR, 0, > - nr_irqs, 0); > - if (bit >= INT_PCI_MSI_NR) { > + bit = bitmap_find_free_region(msi->bitmap, INT_PCI_MSI_NR, > + get_count_order(nr_irqs)); > + if (bit < 0) { > mutex_unlock(&msi->lock); > return -ENOSPC; > } > > - bitmap_set(msi->bitmap, bit, nr_irqs); > - > for (i = 0; i < nr_irqs; i++) { > irq_domain_set_info(domain, virq + i, bit + i, &nwl_irq_chip, > domain->host_data, handle_simple_irq, > @@ -509,7 +507,8 @@ static void nwl_irq_domain_free(struct irq_domain *domain, unsigned int virq, > struct nwl_msi *msi = &pcie->msi; > > mutex_lock(&msi->lock); > - bitmap_clear(msi->bitmap, data->hwirq, nr_irqs); > + bitmap_release_region(msi->bitmap, data->hwirq, > + get_count_order(nr_irqs)); > mutex_unlock(&msi->lock); > } > > -- > 2.7.4 > As for the body of the patch: Suggested-by: Marc Zyngier Acked-by: Marc Zyngier Thanks, M. -- Jazz is not dead, it just smells funny.