From patchwork Tue Mar 12 10:51:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 1910944 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=oMmjwdiu; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:4601:e00::3; helo=am.mirrors.kernel.org; envelope-from=linux-pci+bounces-4752-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [IPv6:2604:1380:4601:e00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tv9TJ3yCyz1yWn for ; Tue, 12 Mar 2024 21:52:36 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 937A71F22C75 for ; Tue, 12 Mar 2024 10:52:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3597A78662; Tue, 12 Mar 2024 10:52:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oMmjwdiu" X-Original-To: linux-pci@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FE1A78292 for ; Tue, 12 Mar 2024 10:52:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710240752; cv=none; b=CdnbJF7cYC3MchXfHNZRWPG870MkQESAAdSRqSiX43ujs6XTtE2AwhdReOVAXTsBYUIPyA7NIRM8SCLLjIdOv4BfobvP5gDI5UBm46mGTkwsNE7h3+aGQrTiDu3pr1x3a8cvBY4MKSTBdmGlGWtstz96zHMKxD2d7miGSMcfmjc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710240752; c=relaxed/simple; bh=+5dCeZi10/u3RMlvjT4oH8IBPzU4bcYd+CsEmIgXsME=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fFucZTxEnAewTHZxoCj0CkUgCuMKZaGmNf2c+0QWgjE1+VlWOZCVL4CNwgKmoiUzI6CVMYgCZibdZLjAMTWfxf1rvaW9LBt3r6oGH7aVHxa+00Nyt7h7OwioV37OJdhxz28vWyclXGI506TyTYcUhBi9f8elxPILF1WRc4tT+Qk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oMmjwdiu; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D69E7C43390; Tue, 12 Mar 2024 10:52:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710240751; bh=+5dCeZi10/u3RMlvjT4oH8IBPzU4bcYd+CsEmIgXsME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oMmjwdiulXfNKuGy87L81k+OLhk5IxuypqfMJaHpqa1voG1Rvtus+BMgyR+Y4G5ij fFYmrAswW0873Z7cZXVyHkalLjzN9AKzWAqukDNNnppsvXzzkdmHvTbY4cF+v/1xA1 l6s4kVYjsggZV7FqtOI3mN3ERx8Ze/14x5jOas0rjLFamMHYk1cJV5bjd27QqjycFF bfsFBoOKV5ds7WNUhtqevkNsZISAARITiZD445j4eVVmD6SXsxJXtbNwGJGEQKI7GZ GUHbf65C826U7m8fsN4y2R4ku0fwNkcI3RekIFqyOfUNUXWHBU6UKwbspchyoDYYUl vCP+V5DXS77Ww== From: Niklas Cassel To: Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Kishon Vijay Abraham I , Bjorn Helgaas Cc: Shradha Todi , Damien Le Moal , Niklas Cassel , linux-pci@vger.kernel.org Subject: [PATCH v2 2/9] PCI: endpoint: Allocate a 64-bit BAR if that is the only option Date: Tue, 12 Mar 2024 11:51:42 +0100 Message-ID: <20240312105152.3457899-3-cassel@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240312105152.3457899-1-cassel@kernel.org> References: <20240312105152.3457899-1-cassel@kernel.org> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 pci_epf_alloc_space() already sets the 64-bit flag if the BAR size is larger than 4GB, even if the caller did not explicitly request a 64-bit BAR. Thus, let pci_epf_alloc_space() also set the 64-bit flag if the hardware description says that the specific BAR can only be 64-bit. Signed-off-by: Niklas Cassel --- drivers/pci/endpoint/functions/pci-epf-test.c | 3 ++- drivers/pci/endpoint/pci-epf-core.c | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index 01ba088849cc..8c9802b9b835 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -868,7 +868,8 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf) /* * pci_epf_alloc_space() might have given us a 64-bit BAR, - * if we requested a size larger than 4 GB. + * either because the BAR can only be a 64-bit BAR, or if + * we requested a size larger than 4 GB. */ add = (epf_bar->flags & PCI_BASE_ADDRESS_MEM_TYPE_64) ? 2 : 1; } diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c index 0a28a0b0911b..e7dbbeb1f0de 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -304,9 +304,10 @@ void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar, epf_bar[bar].addr = space; epf_bar[bar].size = size; epf_bar[bar].barno = bar; - epf_bar[bar].flags |= upper_32_bits(size) ? - PCI_BASE_ADDRESS_MEM_TYPE_64 : - PCI_BASE_ADDRESS_MEM_TYPE_32; + if (upper_32_bits(size) || epc_features->bar[bar].only_64bit) + epf_bar[bar].flags |= PCI_BASE_ADDRESS_MEM_TYPE_64; + else + epf_bar[bar].flags |= PCI_BASE_ADDRESS_MEM_TYPE_32; return space; }