mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-25 05:38:29 +07:00
ff474e8ca8
- Support "hybrid" iommu/direct DMA ops for coherent_mask < dma_mask from Benjamin Herrenschmidt - EEH fixes for SRIOV from Gavin - Introduce rtas_get_sensor_fast() for IRQ handlers from Thomas Huth - Use hardware RNG for arch_get_random_seed_* not arch_get_random_* from Paul Mackerras - Seccomp filter support from Michael Ellerman - opal_cec_reboot2() handling for HMIs & machine checks from Mahesh Salgaonkar - Add powerpc timebase as a trace clock source from Naveen N. Rao - Misc cleanups in the xmon, signal & SLB code from Anshuman Khandual - Add an inline function to update POWER8 HID0 from Gautham R. Shenoy - Fix pte_pagesize_index() crash on 4K w/64K hash from Michael Ellerman - Drop support for 64K local store on 4K kernels from Michael Ellerman - move dma_get_required_mask() from pnv_phb to pci_controller_ops from Andrew Donnellan - Initialize distance lookup table from drconf path from Nikunj A Dadhania - Enable RTC class support from Vaibhav Jain - Disable automatically blocked PCI config from Gavin Shan - Add LEDs driver for PowerNV platform from Vasant Hegde - Fix endianness issues in the HVSI driver from Laurent Dufour - Kexec endian fixes from Samuel Mendoza-Jonas - Fix corrupted pdn list from Gavin Shan - Fix fenced PHB caused by eeh_slot_error_detail() from Gavin Shan - Freescale updates from Scott: Highlights include 32-bit memcpy/memset optimizations, checksum optimizations, 85xx config fragments and updates, device tree updates, e6500 fixes for non-SMP, and misc cleanup and minor fixes. - A ton of cxl updates & fixes: - Add explicit precision specifiers from Rasmus Villemoes - use more common format specifier from Rasmus Villemoes - Destroy cxl_adapter_idr on module_exit from Johannes Thumshirn - Destroy afu->contexts_idr on release of an afu from Johannes Thumshirn - Compile with -Werror from Daniel Axtens - EEH support from Daniel Axtens - Plug irq_bitmap getting leaked in cxl_context from Vaibhav Jain - Add alternate MMIO error handling from Ian Munsie - Allow release of contexts which have been OPENED but not STARTED from Andrew Donnellan - Remove use of macro DEFINE_PCI_DEVICE_TABLE from Vaishali Thakkar - Release irqs if memory allocation fails from Vaibhav Jain - Remove racy attempt to force EEH invocation in reset from Daniel Axtens - Fix + cleanup error paths in cxl_dev_context_init from Ian Munsie - Fix force unmapping mmaps of contexts allocated through the kernel api from Ian Munsie - Set up and enable PSL Timebase from Philippe Bergheaud -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJV5+GzAAoJEFHr6jzI4aWA0iAP/jcd0kNaNBzLgcDKKygKdgz4 xn4EWu81vfMfZYWesb0ATrjlH0hLsRxSXoFUqUMhtJTa5kNAoCIaz/M8WBALS50h aT+i7br4WEU2j2FcaMyP3iAZx/2hl+2utODJSHPRWPkec1fUDBfEyBf++e520RWM HUQGIGZXh8yq7KMA96Pwhsvls9vOB8hS2UdU/NS8ff3J5jFvXC1/WmF2qfzJBS1V 8iHyz26Jl8+dJ+et7iC2oD5XQAjIH1oJgOyPVPBzAQttfi8RjuVzRA30TfPBAUwI lC9nlmPy6bCe4kiQYWVB1z7GegHyW/9vkeuMj/u8mZbqpaayMEMZmd2C3iNDXNHx i2NSvdln539t4qWYsV2v6lVCfa/ayDHD73Wackj5Dk394tzXnpCPhxNzc2yKEd5v h7vwYc9jBhsbfSCSogaM+gSHJ1APgCidggHJMYYNA2nN2u6V62RpsMB7zp/1+Q2v yqYdD8oYF4Dm21x/ujaNFrlizROD46WS0UqdJ3yP6HAqRYIpRXtibmpECJgt1n5h HjADEci4hQ2UQxdMdp/Q5KZnPTJebBtrZrmkW5r6cZBUaTB5TVkFaEWN44CT/Loh tMNeA3qOBN06CaQS2WL3UUUWpbZq9fSbWuUZ5lWZDb5AOyRxe5eWVYNLkiyIXozY L24l1bYdBhXahnjoS/kc =n9+X -----END PGP SIGNATURE----- Merge tag 'powerpc-4.3-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux Pull powerpc updates from Michael Ellerman: - support "hybrid" iommu/direct DMA ops for coherent_mask < dma_mask from Benjamin Herrenschmidt - EEH fixes for SRIOV from Gavin - introduce rtas_get_sensor_fast() for IRQ handlers from Thomas Huth - use hardware RNG for arch_get_random_seed_* not arch_get_random_* from Paul Mackerras - seccomp filter support from Michael Ellerman - opal_cec_reboot2() handling for HMIs & machine checks from Mahesh Salgaonkar - add powerpc timebase as a trace clock source from Naveen N. Rao - misc cleanups in the xmon, signal & SLB code from Anshuman Khandual - add an inline function to update POWER8 HID0 from Gautham R. Shenoy - fix pte_pagesize_index() crash on 4K w/64K hash from Michael Ellerman - drop support for 64K local store on 4K kernels from Michael Ellerman - move dma_get_required_mask() from pnv_phb to pci_controller_ops from Andrew Donnellan - initialize distance lookup table from drconf path from Nikunj A Dadhania - enable RTC class support from Vaibhav Jain - disable automatically blocked PCI config from Gavin Shan - add LEDs driver for PowerNV platform from Vasant Hegde - fix endianness issues in the HVSI driver from Laurent Dufour - kexec endian fixes from Samuel Mendoza-Jonas - fix corrupted pdn list from Gavin Shan - fix fenced PHB caused by eeh_slot_error_detail() from Gavin Shan - Freescale updates from Scott: Highlights include 32-bit memcpy/memset optimizations, checksum optimizations, 85xx config fragments and updates, device tree updates, e6500 fixes for non-SMP, and misc cleanup and minor fixes. - a ton of cxl updates & fixes: - add explicit precision specifiers from Rasmus Villemoes - use more common format specifier from Rasmus Villemoes - destroy cxl_adapter_idr on module_exit from Johannes Thumshirn - destroy afu->contexts_idr on release of an afu from Johannes Thumshirn - compile with -Werror from Daniel Axtens - EEH support from Daniel Axtens - plug irq_bitmap getting leaked in cxl_context from Vaibhav Jain - add alternate MMIO error handling from Ian Munsie - allow release of contexts which have been OPENED but not STARTED from Andrew Donnellan - remove use of macro DEFINE_PCI_DEVICE_TABLE from Vaishali Thakkar - release irqs if memory allocation fails from Vaibhav Jain - remove racy attempt to force EEH invocation in reset from Daniel Axtens - fix + cleanup error paths in cxl_dev_context_init from Ian Munsie - fix force unmapping mmaps of contexts allocated through the kernel api from Ian Munsie - set up and enable PSL Timebase from Philippe Bergheaud * tag 'powerpc-4.3-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: (140 commits) cxl: Set up and enable PSL Timebase cxl: Fix force unmapping mmaps of contexts allocated through the kernel api cxl: Fix + cleanup error paths in cxl_dev_context_init powerpc/eeh: Fix fenced PHB caused by eeh_slot_error_detail() powerpc/pseries: Cleanup on pci_dn_reconfig_notifier() powerpc/pseries: Fix corrupted pdn list powerpc/powernv: Enable LEDS support powerpc/iommu: Set default DMA offset in dma_dev_setup cxl: Remove racy attempt to force EEH invocation in reset cxl: Release irqs if memory allocation fails cxl: Remove use of macro DEFINE_PCI_DEVICE_TABLE powerpc/powernv: Fix mis-merge of OPAL support for LEDS driver powerpc/powernv: Reset HILE before kexec_sequence() powerpc/kexec: Reset secondary cpu endianness before kexec powerpc/hvsi: Fix endianness issues in the HVSI driver leds/powernv: Add driver for PowerNV platform powerpc/powernv: Create LED platform device powerpc/powernv: Add OPAL interfaces for accessing and modifying system LED states powerpc/powernv: Fix the log message when disabling VF cxl: Allow release of contexts which have been OPENED but not STARTED ...
213 lines
4.9 KiB
C
213 lines
4.9 KiB
C
/*
|
|
* MSI support for PPC4xx SoCs using High Speed Transfer Assist (HSTA) for
|
|
* generation of the interrupt.
|
|
*
|
|
* Copyright © 2013 Alistair Popple <alistair@popple.id.au> IBM Corporation
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
* option) any later version.
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/msi.h>
|
|
#include <linux/of.h>
|
|
#include <linux/of_platform.h>
|
|
#include <linux/pci.h>
|
|
#include <linux/semaphore.h>
|
|
#include <asm/msi_bitmap.h>
|
|
#include <asm/ppc-pci.h>
|
|
|
|
struct ppc4xx_hsta_msi {
|
|
struct device *dev;
|
|
|
|
/* The ioremapped HSTA MSI IO space */
|
|
u32 __iomem *data;
|
|
|
|
/* Physical address of HSTA MSI IO space */
|
|
u64 address;
|
|
struct msi_bitmap bmp;
|
|
|
|
/* An array mapping offsets to hardware IRQs */
|
|
int *irq_map;
|
|
|
|
/* Number of hwirqs supported */
|
|
int irq_count;
|
|
};
|
|
static struct ppc4xx_hsta_msi ppc4xx_hsta_msi;
|
|
|
|
static int hsta_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
|
|
{
|
|
struct msi_msg msg;
|
|
struct msi_desc *entry;
|
|
int irq, hwirq;
|
|
u64 addr;
|
|
|
|
/* We don't support MSI-X */
|
|
if (type == PCI_CAP_ID_MSIX) {
|
|
pr_debug("%s: MSI-X not supported.\n", __func__);
|
|
return -EINVAL;
|
|
}
|
|
|
|
for_each_pci_msi_entry(entry, dev) {
|
|
irq = msi_bitmap_alloc_hwirqs(&ppc4xx_hsta_msi.bmp, 1);
|
|
if (irq < 0) {
|
|
pr_debug("%s: Failed to allocate msi interrupt\n",
|
|
__func__);
|
|
return irq;
|
|
}
|
|
|
|
hwirq = ppc4xx_hsta_msi.irq_map[irq];
|
|
if (hwirq == NO_IRQ) {
|
|
pr_err("%s: Failed mapping irq %d\n", __func__, irq);
|
|
return -EINVAL;
|
|
}
|
|
|
|
/*
|
|
* HSTA generates interrupts on writes to 128-bit aligned
|
|
* addresses.
|
|
*/
|
|
addr = ppc4xx_hsta_msi.address + irq*0x10;
|
|
msg.address_hi = upper_32_bits(addr);
|
|
msg.address_lo = lower_32_bits(addr);
|
|
|
|
/* Data is not used by the HSTA. */
|
|
msg.data = 0;
|
|
|
|
pr_debug("%s: Setup irq %d (0x%0llx)\n", __func__, hwirq,
|
|
(((u64) msg.address_hi) << 32) | msg.address_lo);
|
|
|
|
if (irq_set_msi_desc(hwirq, entry)) {
|
|
pr_err(
|
|
"%s: Invalid hwirq %d specified in device tree\n",
|
|
__func__, hwirq);
|
|
msi_bitmap_free_hwirqs(&ppc4xx_hsta_msi.bmp, irq, 1);
|
|
return -EINVAL;
|
|
}
|
|
pci_write_msi_msg(hwirq, &msg);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int hsta_find_hwirq_offset(int hwirq)
|
|
{
|
|
int irq;
|
|
|
|
/* Find the offset given the hwirq */
|
|
for (irq = 0; irq < ppc4xx_hsta_msi.irq_count; irq++)
|
|
if (ppc4xx_hsta_msi.irq_map[irq] == hwirq)
|
|
return irq;
|
|
|
|
return -EINVAL;
|
|
}
|
|
|
|
static void hsta_teardown_msi_irqs(struct pci_dev *dev)
|
|
{
|
|
struct msi_desc *entry;
|
|
int irq;
|
|
|
|
for_each_pci_msi_entry(entry, dev) {
|
|
if (entry->irq == NO_IRQ)
|
|
continue;
|
|
|
|
irq = hsta_find_hwirq_offset(entry->irq);
|
|
|
|
/* entry->irq should always be in irq_map */
|
|
BUG_ON(irq < 0);
|
|
irq_set_msi_desc(entry->irq, NULL);
|
|
msi_bitmap_free_hwirqs(&ppc4xx_hsta_msi.bmp, irq, 1);
|
|
pr_debug("%s: Teardown IRQ %u (index %u)\n", __func__,
|
|
entry->irq, irq);
|
|
}
|
|
}
|
|
|
|
static int hsta_msi_probe(struct platform_device *pdev)
|
|
{
|
|
struct device *dev = &pdev->dev;
|
|
struct resource *mem;
|
|
int irq, ret, irq_count;
|
|
struct pci_controller *phb;
|
|
|
|
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
if (!mem) {
|
|
dev_err(dev, "Unable to get mmio space\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
irq_count = of_irq_count(dev->of_node);
|
|
if (!irq_count) {
|
|
dev_err(dev, "Unable to find IRQ range\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
ppc4xx_hsta_msi.dev = dev;
|
|
ppc4xx_hsta_msi.address = mem->start;
|
|
ppc4xx_hsta_msi.data = ioremap(mem->start, resource_size(mem));
|
|
ppc4xx_hsta_msi.irq_count = irq_count;
|
|
if (!ppc4xx_hsta_msi.data) {
|
|
dev_err(dev, "Unable to map memory\n");
|
|
return -ENOMEM;
|
|
}
|
|
|
|
ret = msi_bitmap_alloc(&ppc4xx_hsta_msi.bmp, irq_count, dev->of_node);
|
|
if (ret)
|
|
goto out;
|
|
|
|
ppc4xx_hsta_msi.irq_map = kmalloc(sizeof(int) * irq_count, GFP_KERNEL);
|
|
if (!ppc4xx_hsta_msi.irq_map) {
|
|
ret = -ENOMEM;
|
|
goto out1;
|
|
}
|
|
|
|
/* Setup a mapping from irq offsets to hardware irq numbers */
|
|
for (irq = 0; irq < irq_count; irq++) {
|
|
ppc4xx_hsta_msi.irq_map[irq] =
|
|
irq_of_parse_and_map(dev->of_node, irq);
|
|
if (ppc4xx_hsta_msi.irq_map[irq] == NO_IRQ) {
|
|
dev_err(dev, "Unable to map IRQ\n");
|
|
ret = -EINVAL;
|
|
goto out2;
|
|
}
|
|
}
|
|
|
|
list_for_each_entry(phb, &hose_list, list_node) {
|
|
phb->controller_ops.setup_msi_irqs = hsta_setup_msi_irqs;
|
|
phb->controller_ops.teardown_msi_irqs = hsta_teardown_msi_irqs;
|
|
}
|
|
return 0;
|
|
|
|
out2:
|
|
kfree(ppc4xx_hsta_msi.irq_map);
|
|
|
|
out1:
|
|
msi_bitmap_free(&ppc4xx_hsta_msi.bmp);
|
|
|
|
out:
|
|
iounmap(ppc4xx_hsta_msi.data);
|
|
return ret;
|
|
}
|
|
|
|
static const struct of_device_id hsta_msi_ids[] = {
|
|
{
|
|
.compatible = "ibm,hsta-msi",
|
|
},
|
|
{}
|
|
};
|
|
|
|
static struct platform_driver hsta_msi_driver = {
|
|
.probe = hsta_msi_probe,
|
|
.driver = {
|
|
.name = "hsta-msi",
|
|
.of_match_table = hsta_msi_ids,
|
|
},
|
|
};
|
|
|
|
static int hsta_msi_init(void)
|
|
{
|
|
return platform_driver_register(&hsta_msi_driver);
|
|
}
|
|
subsys_initcall(hsta_msi_init);
|