Received: by 10.223.164.202 with SMTP id h10csp2457979wrb; Thu, 16 Nov 2017 15:56:46 -0800 (PST) X-Google-Smtp-Source: AGs4zMbykcpVqRu8zP4kvExp3W6nql06rLNsbToGHxCO8E7Enp6jQ5UnXXYdTDT82L8SLGc4r56+ X-Received: by 10.98.93.136 with SMTP id n8mr12796pfj.215.1510876606166; Thu, 16 Nov 2017 15:56:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510876606; cv=none; d=google.com; s=arc-20160816; b=pei7egxrF3KAUqX52nvMcLkwromXPAJ8av5zEg+3v98NP3RV+kSCuYm9ZAQTMnlxbU TgeiKiL0CC08Nfs6Mjdp4PJ2anBwxzC5qg6Wp5MvETGeYmes+VuTrcx9mELVtMfoXkel P+TMxT0r4SwvM55ShtaswHKYt4vc8jQXRtykI0n2v1ZTvpSny31JahvIpWb63cCTsxd8 GSINPLTl6ut3FjkoYdEjg1suRVyctAPtb/+sWRjutk5LssyshOZ8zv6KeJOqJzdF2Dk8 oAX7kFJN2rVS96iyvIQt0Pr6ljq/Stvr1cEMGv4kn1h4uo7o163rG80P99w5DWaCwhJ2 xDKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=TwPWs1xGGNudr81i+0alzfv4EmxJp+jU9J4SPGVlNUo=; b=PG7nJdqh5qniWp6NifaEhUWn+i9b+L5ow4cvD20ipZrTUUggfIsPuMWzj+Re0bWwb+ uBULCh/6t1KwOOucfz1k43jNcyj2XCGifn09zDaYZWKxBEVF0+y8w3GXLMLn8AnLefe6 VG0S8W9SiV9XzU31RLhb60iFK98ThiVWVbZ8rZ+SmQDvLjRpcNg1vLVZ/Dz8KETptREf +wI4ODj5C7zDjWbpM957tRmdwN9k9wMLV6U2o9zgTyoTKN9E/Ypd0xXB7KB7oC7iWFHk MNNBOZ5hOc8jzuMeEVe1VcILufnyjnx7e+6B3V+y8BYoAd+DIM4EoYQjycViR3VutoPX 93LA== 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 q29si1697879pgc.765.2017.11.16.15.56.33; Thu, 16 Nov 2017 15:56:46 -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 S966723AbdKPSf1 (ORCPT + 92 others); Thu, 16 Nov 2017 13:35:27 -0500 Received: from bastet.se.axis.com ([195.60.68.11]:33017 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966691AbdKPSeo (ORCPT ); Thu, 16 Nov 2017 13:34:44 -0500 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 84D65180EA; Thu, 16 Nov 2017 19:34:40 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bastet.se.axis.com Received: from bastet.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bastet.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id 141ENmLOd_Wt; Thu, 16 Nov 2017 19:34:39 +0100 (CET) Received: from boulder03.se.axis.com (boulder03.se.axis.com [10.0.8.17]) by bastet.se.axis.com (Postfix) with ESMTPS id C2BE018133; Thu, 16 Nov 2017 19:34:39 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A6CC81E07B; Thu, 16 Nov 2017 19:34:39 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9B2331E079; Thu, 16 Nov 2017 19:34:39 +0100 (CET) Received: from thoth.se.axis.com (unknown [10.0.2.173]) by boulder03.se.axis.com (Postfix) with ESMTP; Thu, 16 Nov 2017 19:34:39 +0100 (CET) Received: from lnxartpec1.se.axis.com (lnxartpec1.se.axis.com [10.88.4.10]) by thoth.se.axis.com (Postfix) with ESMTP id 8EC91FA1; Thu, 16 Nov 2017 19:34:39 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id 886D9400FC; Thu, 16 Nov 2017 19:34:39 +0100 (CET) From: Niklas Cassel To: Jingoo Han , Joao Pinto , Bjorn Helgaas Cc: Niklas Cassel , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] PCI: designware-ep: use ffz() instead of find_first_zero_bit() Date: Thu, 16 Nov 2017 19:34:38 +0100 Message-Id: <20171116183438.12613-1-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 X-TM-AS-GCONF: 00 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org find_first_zero_bit()'s parameter 'size' is defined in bits, not in bytes. find_first_zero_bit() was called with bytes rather than bits, which thus defined a too low upper limit, causing dw_pcie_ep_inbound_atu() to assign iatu index #4 to both bar 4 and bar 5, which made bar 5 overwrite the settings set by bar 4. ./pcitest.sh BAR tests BAR0: OKAY BAR1: OKAY BAR2: OKAY BAR3: OKAY BAR4: NOT OKAY BAR5: OKAY Fix this by using replacing find_first_zero_bit() with ffz(), since ffz() only works on a single 'unsigned long' and therefore does not need a size argument. Signed-off-by: Niklas Cassel --- drivers/pci/dwc/pcie-designware-ep.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/pci/dwc/pcie-designware-ep.c b/drivers/pci/dwc/pcie-designware-ep.c index d53d5f168363..ab9a9e160daf 100644 --- a/drivers/pci/dwc/pcie-designware-ep.c +++ b/drivers/pci/dwc/pcie-designware-ep.c @@ -70,8 +70,7 @@ static int dw_pcie_ep_inbound_atu(struct dw_pcie_ep *ep, enum pci_barno bar, u32 free_win; struct dw_pcie *pci = to_dw_pcie_from_ep(ep); - free_win = find_first_zero_bit(&ep->ib_window_map, - sizeof(ep->ib_window_map)); + free_win = ffz(ep->ib_window_map); if (free_win >= ep->num_ib_windows) { dev_err(pci->dev, "no free inbound window\n"); return -EINVAL; @@ -96,8 +95,7 @@ static int dw_pcie_ep_outbound_atu(struct dw_pcie_ep *ep, phys_addr_t phys_addr, u32 free_win; struct dw_pcie *pci = to_dw_pcie_from_ep(ep); - free_win = find_first_zero_bit(&ep->ob_window_map, - sizeof(ep->ob_window_map)); + free_win = ffz(ep->ob_window_map); if (free_win >= ep->num_ob_windows) { dev_err(pci->dev, "no free outbound window\n"); return -EINVAL; -- 2.14.2 From 1584743145620267943@xxx Wed Nov 22 05:33:56 +0000 2017 X-GM-THRID: 1584743145620267943 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread