forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'vfio-v4.4-rc1' of git://github.com/awilliam/linux-vfio
Pull VFIO updates from Alex Williamson: - Use kernel interfaces for VPD emulation (Alex Williamson) - Platform fix for releasing IRQs (Eric Auger) - Type1 IOMMU always advertises PAGE_SIZE support when smaller mapping sizes are available (Eric Auger) - Platform fixes for incorrectly using copies of structures rather than pointers to structures (James Morse) - Rework platform reset modules, fix leak, and add AMD xgbe reset module (Eric Auger) - Fix vfio_device_get_from_name() return value (Joerg Roedel) - No-IOMMU interface (Alex Williamson) - Fix potential out of bounds array access in PCI config handling (Dan Carpenter) * tag 'vfio-v4.4-rc1' of git://github.com/awilliam/linux-vfio: vfio/pci: make an array larger vfio: Include No-IOMMU mode vfio: Fix bug in vfio_device_get_from_name() VFIO: platform: reset: AMD xgbe reset module vfio: platform: reset: calxedaxgmac: fix ioaddr leak vfio: platform: add dev_info on device reset vfio: platform: use list of registered reset function vfio: platform: add compat in vfio_platform_device vfio: platform: reset: calxedaxgmac: add reset function registration vfio: platform: introduce module_vfio_reset_handler macro vfio: platform: add capability to register a reset function vfio: platform: introduce vfio-platform-base module vfio/platform: store mapped memory in region, instead of an on-stack copy vfio/type1: handle case where IOMMU does not support PAGE_SIZE size VFIO: platform: clear IRQ_NOAUTOEN when de-assigning the IRQ vfio/pci: Use kernel VPD access functions vfio: Whitelist PCI bridges
- Loading branch information
Showing
17 changed files
with
616 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
|
||
vfio-platform-y := vfio_platform.o vfio_platform_common.o vfio_platform_irq.o | ||
vfio-platform-base-y := vfio_platform_common.o vfio_platform_irq.o | ||
vfio-platform-y := vfio_platform.o | ||
|
||
obj-$(CONFIG_VFIO_PLATFORM) += vfio-platform.o | ||
obj-$(CONFIG_VFIO_PLATFORM) += vfio-platform-base.o | ||
obj-$(CONFIG_VFIO_PLATFORM) += reset/ | ||
|
||
vfio-amba-y := vfio_amba.o | ||
|
||
obj-$(CONFIG_VFIO_AMBA) += vfio-amba.o | ||
obj-$(CONFIG_VFIO_AMBA) += vfio-platform-base.o | ||
obj-$(CONFIG_VFIO_AMBA) += reset/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
vfio-platform-calxedaxgmac-y := vfio_platform_calxedaxgmac.o | ||
vfio-platform-amdxgbe-y := vfio_platform_amdxgbe.o | ||
|
||
ccflags-y += -Idrivers/vfio/platform | ||
|
||
obj-$(CONFIG_VFIO_PLATFORM_CALXEDAXGMAC_RESET) += vfio-platform-calxedaxgmac.o | ||
obj-$(CONFIG_VFIO_PLATFORM_AMDXGBE_RESET) += vfio-platform-amdxgbe.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
* VFIO platform driver specialized for AMD xgbe reset | ||
* reset code is inherited from AMD xgbe native driver | ||
* | ||
* Copyright (c) 2015 Linaro Ltd. | ||
* www.linaro.org | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms and conditions of the GNU General Public License, | ||
* version 2, as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <linux/module.h> | ||
#include <linux/kernel.h> | ||
#include <linux/init.h> | ||
#include <linux/io.h> | ||
#include <uapi/linux/mdio.h> | ||
#include <linux/delay.h> | ||
|
||
#include "vfio_platform_private.h" | ||
|
||
#define DMA_MR 0x3000 | ||
#define MAC_VR 0x0110 | ||
#define DMA_ISR 0x3008 | ||
#define MAC_ISR 0x00b0 | ||
#define PCS_MMD_SELECT 0xff | ||
#define MDIO_AN_INT 0x8002 | ||
#define MDIO_AN_INTMASK 0x8001 | ||
|
||
static unsigned int xmdio_read(void *ioaddr, unsigned int mmd, | ||
unsigned int reg) | ||
{ | ||
unsigned int mmd_address, value; | ||
|
||
mmd_address = (mmd << 16) | ((reg) & 0xffff); | ||
iowrite32(mmd_address >> 8, ioaddr + (PCS_MMD_SELECT << 2)); | ||
value = ioread32(ioaddr + ((mmd_address & 0xff) << 2)); | ||
return value; | ||
} | ||
|
||
static void xmdio_write(void *ioaddr, unsigned int mmd, | ||
unsigned int reg, unsigned int value) | ||
{ | ||
unsigned int mmd_address; | ||
|
||
mmd_address = (mmd << 16) | ((reg) & 0xffff); | ||
iowrite32(mmd_address >> 8, ioaddr + (PCS_MMD_SELECT << 2)); | ||
iowrite32(value, ioaddr + ((mmd_address & 0xff) << 2)); | ||
} | ||
|
||
int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev) | ||
{ | ||
struct vfio_platform_region *xgmac_regs = &vdev->regions[0]; | ||
struct vfio_platform_region *xpcs_regs = &vdev->regions[1]; | ||
u32 dma_mr_value, pcs_value, value; | ||
unsigned int count; | ||
|
||
if (!xgmac_regs->ioaddr) { | ||
xgmac_regs->ioaddr = | ||
ioremap_nocache(xgmac_regs->addr, xgmac_regs->size); | ||
if (!xgmac_regs->ioaddr) | ||
return -ENOMEM; | ||
} | ||
if (!xpcs_regs->ioaddr) { | ||
xpcs_regs->ioaddr = | ||
ioremap_nocache(xpcs_regs->addr, xpcs_regs->size); | ||
if (!xpcs_regs->ioaddr) | ||
return -ENOMEM; | ||
} | ||
|
||
/* reset the PHY through MDIO*/ | ||
pcs_value = xmdio_read(xpcs_regs->ioaddr, MDIO_MMD_PCS, MDIO_CTRL1); | ||
pcs_value |= MDIO_CTRL1_RESET; | ||
xmdio_write(xpcs_regs->ioaddr, MDIO_MMD_PCS, MDIO_CTRL1, pcs_value); | ||
|
||
count = 50; | ||
do { | ||
msleep(20); | ||
pcs_value = xmdio_read(xpcs_regs->ioaddr, MDIO_MMD_PCS, | ||
MDIO_CTRL1); | ||
} while ((pcs_value & MDIO_CTRL1_RESET) && --count); | ||
|
||
if (pcs_value & MDIO_CTRL1_RESET) | ||
pr_warn("%s XGBE PHY reset timeout\n", __func__); | ||
|
||
/* disable auto-negotiation */ | ||
value = xmdio_read(xpcs_regs->ioaddr, MDIO_MMD_AN, MDIO_CTRL1); | ||
value &= ~MDIO_AN_CTRL1_ENABLE; | ||
xmdio_write(xpcs_regs->ioaddr, MDIO_MMD_AN, MDIO_CTRL1, value); | ||
|
||
/* disable AN IRQ */ | ||
xmdio_write(xpcs_regs->ioaddr, MDIO_MMD_AN, MDIO_AN_INTMASK, 0); | ||
|
||
/* clear AN IRQ */ | ||
xmdio_write(xpcs_regs->ioaddr, MDIO_MMD_AN, MDIO_AN_INT, 0); | ||
|
||
/* MAC software reset */ | ||
dma_mr_value = ioread32(xgmac_regs->ioaddr + DMA_MR); | ||
dma_mr_value |= 0x1; | ||
iowrite32(dma_mr_value, xgmac_regs->ioaddr + DMA_MR); | ||
|
||
usleep_range(10, 15); | ||
|
||
count = 2000; | ||
while (count-- && (ioread32(xgmac_regs->ioaddr + DMA_MR) & 1)) | ||
usleep_range(500, 600); | ||
|
||
if (!count) | ||
pr_warn("%s MAC SW reset failed\n", __func__); | ||
|
||
return 0; | ||
} | ||
|
||
module_vfio_reset_handler("amd,xgbe-seattle-v1a", vfio_platform_amdxgbe_reset); | ||
|
||
MODULE_VERSION("0.1"); | ||
MODULE_LICENSE("GPL v2"); | ||
MODULE_AUTHOR("Eric Auger <[email protected]>"); | ||
MODULE_DESCRIPTION("Reset support for AMD xgbe vfio platform device"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,8 +30,6 @@ | |
#define DRIVER_AUTHOR "Eric Auger <[email protected]>" | ||
#define DRIVER_DESC "Reset support for Calxeda xgmac vfio platform device" | ||
|
||
#define CALXEDAXGMAC_COMPAT "calxeda,hb-xgmac" | ||
|
||
/* XGMAC Register definitions */ | ||
#define XGMAC_CONTROL 0x00000000 /* MAC Configuration */ | ||
|
||
|
@@ -61,24 +59,25 @@ static inline void xgmac_mac_disable(void __iomem *ioaddr) | |
|
||
int vfio_platform_calxedaxgmac_reset(struct vfio_platform_device *vdev) | ||
{ | ||
struct vfio_platform_region reg = vdev->regions[0]; | ||
struct vfio_platform_region *reg = &vdev->regions[0]; | ||
|
||
if (!reg.ioaddr) { | ||
reg.ioaddr = | ||
ioremap_nocache(reg.addr, reg.size); | ||
if (!reg.ioaddr) | ||
if (!reg->ioaddr) { | ||
reg->ioaddr = | ||
ioremap_nocache(reg->addr, reg->size); | ||
if (!reg->ioaddr) | ||
return -ENOMEM; | ||
} | ||
|
||
/* disable IRQ */ | ||
writel(0, reg.ioaddr + XGMAC_DMA_INTR_ENA); | ||
writel(0, reg->ioaddr + XGMAC_DMA_INTR_ENA); | ||
|
||
/* Disable the MAC core */ | ||
xgmac_mac_disable(reg.ioaddr); | ||
xgmac_mac_disable(reg->ioaddr); | ||
|
||
return 0; | ||
} | ||
EXPORT_SYMBOL_GPL(vfio_platform_calxedaxgmac_reset); | ||
|
||
module_vfio_reset_handler("calxeda,hb-xgmac", vfio_platform_calxedaxgmac_reset); | ||
|
||
MODULE_VERSION(DRIVER_VERSION); | ||
MODULE_LICENSE("GPL v2"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.