Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3097813ybi; Thu, 18 Jul 2019 20:59:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzmk1Rm1xyoPB0vjvgCz7b9nxCjDCY2luvKKV7mqEcn8QwgDy+WRCxXYTLqyxONibCuqhIr X-Received: by 2002:a17:90a:2041:: with SMTP id n59mr53051762pjc.6.1563508793849; Thu, 18 Jul 2019 20:59:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563508793; cv=none; d=google.com; s=arc-20160816; b=C3/kBi+Kykk55gmVmhnVGpFaPtYBbL2zfJhU+7ZUyKQ14GzaUjCkFGEMMX0j28/3oW XH3BUnYMoNOPXZIkfG85ESMhMosXH5PYNBHfqPRazU4f+s0jNbW4AoeTqALQCy14C6Bn lcAjza66bghRMTgFEermzaZKJVnDQKFhl492liohMDB9mMmEmlmrykLOLA70fCn54xmG KNro8jbGr+j8/lDBl0wkyU/+1mH4sDuc5GEmScp+/3RBJF3uk6pGcJAU9iN6uw615xdV tDzGbvMCuHSDhH3lrOxkDZ93YQ+Vl2a4MAK47sQwfha9k1RgFnaxz4k/Q01Bb+Bsmmi2 52dw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1R6IQCxi47yeEbyANLLIqCF+vw15ST7ktFwsUClik0A=; b=E7gqG9yBo8KEABQPckSGhwU6WLLa4QK0w+K8uA9p5GUJ7zxVcrCfZoCbd5UdCkZrUo jzNBnl6dQqFVsCHuKoN6cj29wxguba49xsOEJEOPH84R1MdXvT0ajgbgEZzZvFeCvVah ZPFsVBAVhiPOTABG0M9GJxkuKuhyG7rj1bmVAWzIUmD1sAOZx9Cp2UYudJj3TrDcdYcu ggSi/m1MOdfCYd5MYx+nNxIv6hFv180hHQ0KUtUlxWRKKvEz8uJEZNCE62W64fnsZ9qe CqzVOqD6qoOrI2V/897+UEOcJEIfm5cOWXVn5dX8XEI59X/IxP/lF3Fdp2lRpqaPON/h H1mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CrOBPF4h; 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=pass (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 w16si178538pfi.31.2019.07.18.20.59.38; Thu, 18 Jul 2019 20:59:53 -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; dkim=pass header.i=@kernel.org header.s=default header.b=CrOBPF4h; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728242AbfGSD6n (ORCPT + 99 others); Thu, 18 Jul 2019 23:58:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:58036 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728206AbfGSD6j (ORCPT ); Thu, 18 Jul 2019 23:58:39 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0E03D21851; Fri, 19 Jul 2019 03:58:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508718; bh=R3UxDjgTbacNgKcJvMdnsgwwpj7qgbnHxLcI0sBnYsw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CrOBPF4hHcblIC7sFQ8nOU6D6vcoSc/uKhMk6R8CO5/fG/zSkPpoNgJaOFXb8IUP3 hg4ysYyoyMXyDm15GpiKvTkfzrJ75x7Ew/Z7P4KjkJPJ7PVFeAM2BuMdhqBCE1+a89 mfKvcBMTvkErVR7qL+CUV2F8uNrTBslrMscO/Xvk= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alan Mikhak , Lorenzo Pieralisi , Kishon Vijay Abraham I , Sasha Levin , linux-pci@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH AUTOSEL 5.2 051/171] PCI: endpoint: Allocate enough space for fixed size BAR Date: Thu, 18 Jul 2019 23:54:42 -0400 Message-Id: <20190719035643.14300-51-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alan Mikhak [ Upstream commit f16fb16ed16c7f561e9c41c9ae4107c7f6aa553c ] PCI endpoint test function code should honor the .bar_fixed_size parameter from underlying endpoint controller drivers or results may be unexpected. In pci_epf_test_alloc_space(), check if BAR being used for test register space is a fixed size BAR. If so, allocate the required fixed size. Signed-off-by: Alan Mikhak Signed-off-by: Lorenzo Pieralisi Acked-by: Kishon Vijay Abraham I Signed-off-by: Sasha Levin --- drivers/pci/endpoint/functions/pci-epf-test.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index 27806987e93b..7d41e6684b87 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -434,10 +434,16 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf) int bar; enum pci_barno test_reg_bar = epf_test->test_reg_bar; const struct pci_epc_features *epc_features; + size_t test_reg_size; epc_features = epf_test->epc_features; - base = pci_epf_alloc_space(epf, sizeof(struct pci_epf_test_reg), + if (epc_features->bar_fixed_size[test_reg_bar]) + test_reg_size = bar_size[test_reg_bar]; + else + test_reg_size = sizeof(struct pci_epf_test_reg); + + base = pci_epf_alloc_space(epf, test_reg_size, test_reg_bar, epc_features->align); if (!base) { dev_err(dev, "Failed to allocated register space\n"); -- 2.20.1