From: Elad Nachman <enachman@marvell.com>
To: <thomas.petazzoni@bootlin.com>, <bhelgaas@google.com>,
<lpieralisi@kernel.org>, <robh@kernel.org>, <kw@linux.com>,
<krzysztof.kozlowski+dt@linaro.org>, <linux-pci@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: Elad Nachman <enachman@marvell.com>
Subject: [PATCH v3 6/7] PCI: dwc: Introduce Configurable DMA mask
Date: Thu, 23 Feb 2023 20:05:30 +0200 [thread overview]
Message-ID: <20230223180531.15148-7-enachman@marvell.com> (raw)
In-Reply-To: <20230223180531.15148-1-enachman@marvell.com>
From: Elad Nachman <enachman@marvell.com>
Some devices, such as AC5 and AC5X have their physical DDR memory
start at address 0x2_0000_0000 . In order to have the DMA
coherent allocation succeed later, a different DMA mask is
required, as defined in the DT file for such SOCs.
If not defined, fallback to 32-bit as previously done in the code.
DT property is called num-dmamask , and can range between 33 and 64.
Signed-off-by: Elad Nachman <enachman@marvell.com>
---
.../pci/controller/dwc/pcie-designware-host.c | 23 ++++++++++++++-----
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index 9952057c8819..ac851b065325 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -204,7 +204,6 @@ static int dw_pcie_irq_domain_alloc(struct irq_domain *domain,
pp->msi_irq_chip,
pp, handle_edge_irq,
NULL, NULL);
-
return 0;
}
@@ -250,7 +249,6 @@ int dw_pcie_allocate_domains(struct dw_pcie_rp *pp)
irq_domain_remove(pp->irq_domain);
return -ENOMEM;
}
-
return 0;
}
@@ -325,10 +323,12 @@ static int dw_pcie_msi_host_init(struct dw_pcie_rp *pp)
{
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
struct device *dev = pci->dev;
+ struct device_node *np = dev->of_node;
struct platform_device *pdev = to_platform_device(dev);
u64 *msi_vaddr;
int ret;
u32 ctrl, num_ctrls;
+ u32 num_dma_maskbits;
for (ctrl = 0; ctrl < MAX_MSI_CTRLS; ctrl++)
pp->irq_mask[ctrl] = ~0;
@@ -367,18 +367,30 @@ static int dw_pcie_msi_host_init(struct dw_pcie_rp *pp)
}
/*
+ * Some devices, such as AC5 and AC5X have their physical DDR memory
+ * start at address 0x2_0000_0000 . In order to have the DMA
+ * coherent allocation succeed later, a different DMA mask is
+ * required, as defined in the DT file for such SOCs.
+ * If not defined, fallback to 32-bit as described below:
+ *
* Even though the iMSI-RX Module supports 64-bit addresses some
* peripheral PCIe devices may lack 64-bit message support. In
* order not to miss MSI TLPs from those devices the MSI target
* address has to be within the lowest 4GB.
*
- * Note until there is a better alternative found the reservation is
+ * Note until there is a better alternative found, the reservation is
* done by allocating from the artificially limited DMA-coherent
* memory.
*/
- ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
+ ret = of_property_read_u32(np, "num-dmamask", &num_dma_maskbits);
if (ret)
- dev_warn(dev, "Failed to set DMA mask to 32-bit. Devices with only 32-bit MSI support may not work properly\n");
+ num_dma_maskbits = 32;
+
+ ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(num_dma_maskbits));
+ if (ret)
+ dev_warn(dev,
+ "Failed to set DMA mask to %u-bit. Devices with only 32-bit MSI support may not work properly\n",
+ num_dma_maskbits);
msi_vaddr = dmam_alloc_coherent(dev, sizeof(u64), &pp->msi_data,
GFP_KERNEL);
@@ -420,7 +432,6 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)
dev_err(dev, "Missing *config* reg space\n");
return -ENODEV;
}
-
bridge = devm_pci_alloc_host_bridge(dev, 0);
if (!bridge)
return -ENOMEM;
--
2.17.1
next prev parent reply other threads:[~2023-02-23 18:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-23 18:05 [PATCH v3 0/7] PCI: dwc: Add support for Marvell AC5 SoC Elad Nachman
2023-02-23 18:05 ` [PATCH v3 1/7] dt-bindings: PCI: armada8k: Add compatible string for " Elad Nachman
2023-02-23 18:05 ` [PATCH v3 2/7] PCI: armada8k: Add AC5 SoC support Elad Nachman
2023-02-23 18:05 ` [PATCH v3 3/7] PCI: armada8k: Add MSI support for AC5 SoC Elad Nachman
2023-02-23 18:05 ` [PATCH v3 4/7] dt-bindings: PCI: dwc: add DMA, region mask bits Elad Nachman
2023-02-23 18:12 ` Krzysztof Kozlowski
2023-02-27 18:55 ` Rob Herring
2023-02-23 18:05 ` [PATCH v3 5/7] PCI: dwc: support AC5 Legacy PCIe interrupts Elad Nachman
2023-02-23 19:48 ` Bjorn Helgaas
2023-02-23 18:05 ` Elad Nachman [this message]
2023-02-23 18:14 ` [PATCH v3 6/7] PCI: dwc: Introduce Configurable DMA mask Krzysztof Kozlowski
2023-02-23 18:05 ` [PATCH v3 7/7] PCI: dwc: Introduce region limit from DT Elad Nachman
2023-02-23 18:16 ` Krzysztof Kozlowski
2023-02-23 19:42 ` [PATCH v3 0/7] PCI: dwc: Add support for Marvell AC5 SoC Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230223180531.15148-7-enachman@marvell.com \
--to=enachman@marvell.com \
--cc=bhelgaas@google.com \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=kw@linux.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=robh@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®