Received: by 10.223.164.202 with SMTP id h10csp1129558wrb; Fri, 17 Nov 2017 14:30:30 -0800 (PST) X-Google-Smtp-Source: AGs4zMYcudXb1odJLEJT2Dww2OU4vilX977jb6DA0BDjgvh/Uh2GpJYCslWDADAyYD/XahePZXxD X-Received: by 10.159.252.138 with SMTP id bb10mr6489510plb.163.1510957830184; Fri, 17 Nov 2017 14:30:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510957830; cv=none; d=google.com; s=arc-20160816; b=Vzaljtcr5gG7+r5CMpHO3GcfBBU0Lh72BU2gg0uJOz6v8FCvFjaegYiq/Ee7nMaqKl HS6QAqQgor5imVYTvR+C+OIcuXTuu8Vnc/DHiadRT5Ru3ozEZgI3JQsCXHE7BC8T8Iis zyY1eu/1t+MfVfzvL8TVVr7eLal0vI8KVGXFSWiYmzvUY4qEaL3u2gO+ZQ3FLweskvPy hKMugPhM++OWBc3ywm5RZHB6G0EiMYvehLX6DVfFQIoZLshOmZAD5RswTWvcqqLx0oHp 8gBFL5+HKBJbQhkcUpqtrfJJUc3FjUpHeJiH+MKr8AuzuIya4hUwepzjUD6yVEooGDeF JBXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=0x6MA2kGHMVkVOSCiOWEyCm9Vo5FmfTwSUyPtdqO9tE=; b=ziyB53NQR2Bvf6LvdIgsDc8G0CVaGjJUZGvX/gUfb/ab9aHdV4l/q1bM/xUkdO28EJ bVAM9D2+I2r0ArxAl2CYA2Q23dPl2oF35L3TF1BeKqN09AIXgfsKqoThMPfEtsTuSQUK i0xqbiY9czAZ4gbQ4c7DTDruLnldpT+k0acerBK0i9JYvyKN6i2ct/9e6d6HUCJJUm4P NOCszqjUjklHsvWOFXIXCsi32YGQ3zBdk48N9TkwuPZdXuVhbrnFkoly/2T2j/kUCqEO TnSMTFLHsrDGZtdMDJkyCf9Jcycd9+Gs54AdAEy3j6m9eZlwBRd0kR8jHGmfn02UKVqB yLjw== 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 l10si3453067pgn.223.2017.11.17.14.30.17; Fri, 17 Nov 2017 14:30:30 -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 S935264AbdKQPBW (ORCPT + 93 others); Fri, 17 Nov 2017 10:01:22 -0500 Received: from bastet.se.axis.com ([195.60.68.11]:42435 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934263AbdKQPAv (ORCPT ); Fri, 17 Nov 2017 10:00:51 -0500 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id D3F6B185B9; Fri, 17 Nov 2017 16:00:49 +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 mlOkiJB1G-QD; Fri, 17 Nov 2017 16:00:47 +0100 (CET) Received: from boulder02.se.axis.com (boulder02.se.axis.com [10.0.8.16]) by bastet.se.axis.com (Postfix) with ESMTPS id 94A71185CB; Fri, 17 Nov 2017 16:00:47 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 556AC1A098; Fri, 17 Nov 2017 16:00:47 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 49F5A1A069; Fri, 17 Nov 2017 16:00:47 +0100 (CET) Received: from seth.se.axis.com (unknown [10.0.2.172]) by boulder02.se.axis.com (Postfix) with ESMTP; Fri, 17 Nov 2017 16:00:47 +0100 (CET) Received: from lnxartpec1.se.axis.com (lnxartpec1.se.axis.com [10.88.4.10]) by seth.se.axis.com (Postfix) with ESMTP id 3D2611099; Fri, 17 Nov 2017 16:00:47 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id 3933C400FC; Fri, 17 Nov 2017 16:00:47 +0100 (CET) From: Niklas Cassel To: Jingoo Han , Joao Pinto , Lorenzo Pieralisi , Bjorn Helgaas Cc: Niklas Cassel , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] PCI: designware-ep: Fix find_first_zero_bit() usage Date: Fri, 17 Nov 2017 16:00:40 +0100 Message-Id: <20171117150041.30509-2-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171117150041.30509-1-niklas.cassel@axis.com> References: <20171117150041.30509-1-niklas.cassel@axis.com> 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 size in 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. 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. Fixes: f8aed6ec624f ("PCI: dwc: designware: Add EP mode support") 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 1584761645735913204@xxx Wed Nov 22 10:27:59 +0000 2017 X-GM-THRID: 1584761645735913204 X-Gmail-Labels: Inbox,Category Promotions,HistoricalUnread