Jason Gunthorpe
38a68934aa
vfio: Move vfio_iommu_group_get() to vfio_register_group_dev()
...
We don't need to hold a reference to the group in the driver as well as
obtain a reference to the same group as the first thing
vfio_register_group_dev() does.
Since the drivers never use the group move this all into the core code.
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com >
Signed-off-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Kevin Tian <kevin.tian@intel.com >
Link: https://lore.kernel.org/r/20210924155705.4258-2-hch@lst.de
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2021-09-30 12:46:43 -06:00
Alex Williamson
ea870730d8
Merge branches 'v5.15/vfio/spdx-license-cleanups', 'v5.15/vfio/dma-valid-waited-v3', 'v5.15/vfio/vfio-pci-core-v5' and 'v5.15/vfio/vfio-ap' into v5.15/vfio/next
2021-08-26 11:08:50 -06:00
Jason Gunthorpe
85c94dcffc
vfio: Use kconfig if XX/endif blocks instead of repeating 'depends on'
...
This results in less kconfig wordage and a simpler understanding of the
required "depends on" to create the menu structure.
The next patch increases the nesting level a lot so this is a nice
preparatory simplification.
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Signed-off-by: Yishai Hadas <yishaih@nvidia.com >
Link: https://lore.kernel.org/r/20210826103912.128972-13-yishaih@nvidia.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2021-08-26 10:36:51 -06:00
Jason Gunthorpe
ca4ddaac7f
vfio: Use select for eventfd
...
If VFIO_VIRQFD is required then turn on eventfd automatically.
The majority of kconfig users of the EVENTFD use select not depends on.
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Signed-off-by: Yishai Hadas <yishaih@nvidia.com >
Link: https://lore.kernel.org/r/20210826103912.128972-12-yishaih@nvidia.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2021-08-26 10:36:51 -06:00
Cai Huoqing
ab78130e6e
vfio: platform: reset: Convert to SPDX identifier
...
use SPDX-License-Identifier instead of a verbose license text
Signed-off-by: Cai Huoqing <caihuoqing@baidu.com >
Link: https://lore.kernel.org/r/20210822043643.2040-1-caihuoqing@baidu.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2021-08-24 11:59:10 -06:00
Jason Gunthorpe
ab7e5e34a9
vfio/platform: Use open_device() instead of open coding a refcnt scheme
...
Platform simply wants to run some code when the device is first
opened/last closed. Use the core framework and locking for this. Aside
from removing a bit of code this narrows the locking scope from a global
lock.
Reviewed-by: Cornelia Huck <cohuck@redhat.com >
Reviewed-by: Eric Auger <eric.auger@redhat.com >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com >
Signed-off-by: Yishai Hadas <yishaih@nvidia.com >
Link: https://lore.kernel.org/r/7-v4-9ea22c5e6afb+1adf-vfio_reflck_jgg@nvidia.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2021-08-11 09:50:11 -06:00
Max Gurtovoy
ae03c3771b
vfio: Introduce a vfio_uninit_group_dev() API call
...
This pairs with vfio_init_group_dev() and allows undoing any state that is
stored in the vfio_device unrelated to registration. Add appropriately
placed calls to all the drivers.
The following patch will use this to add pre-registration state for the
device set.
Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com >
Reviewed-by: Cornelia Huck <cohuck@redhat.com >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com >
Link: https://lore.kernel.org/r/3-v4-9ea22c5e6afb+1adf-vfio_reflck_jgg@nvidia.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2021-08-11 09:50:10 -06:00
Max Gurtovoy
3b62a62429
vfio/platform: remove unneeded parent_module attribute
...
The vfio core driver is now taking refcount on the provider drivers,
remove redundant parent_module attribute from vfio_platform_device
structure.
Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com >
Acked-by: Eric Auger <eric.auger@redhat.com >
Link: https://lore.kernel.org/r/20210518192133.59195-3-mgurtovoy@nvidia.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2021-06-15 14:12:15 -06:00
Max Gurtovoy
9dcf01d957
vfio: centralize module refcount in subsystem layer
...
Remove code duplication and move module refcounting to the subsystem
module.
Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com >
Reviewed-by: Eric Auger <eric.auger@redhat.com >
Link: https://lore.kernel.org/r/20210518192133.59195-2-mgurtovoy@nvidia.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2021-06-15 14:12:15 -06:00
Max Gurtovoy
dc51ff91cf
vfio/platform: fix module_put call in error flow
...
The ->parent_module is the one that use in try_module_get. It should
also be the one the we use in module_put during vfio_platform_open().
Fixes: 32a2d71c4e ("vfio: platform: introduce vfio-platform-base module")
Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com >
Message-Id: <20210518192133.59195-1-mgurtovoy@nvidia.com >
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2021-05-24 13:40:13 -06:00
Alex Williamson
6a2a235aa6
Merge branches 'v5.13/vfio/embed-vfio_device', 'v5.13/vfio/misc' and 'v5.13/vfio/nvlink' into v5.13/vfio/next
...
Spelling fixes merged with file deletion.
Conflicts:
drivers/vfio/pci/vfio_pci_nvlink2.c
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2021-04-06 12:01:51 -06:00
Jason Gunthorpe
1e04ec1420
vfio: Remove device_data from the vfio bus driver API
...
There are no longer any users, so it can go away. Everything is using
container_of now.
Reviewed-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Kevin Tian <kevin.tian@intel.com >
Reviewed-by: Cornelia Huck <cohuck@redhat.com >
Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com >
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com >
Message-Id: <14-v3-225de1400dfc+4e074-vfio1_jgg@nvidia.com >
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2021-04-06 11:55:11 -06:00
Jason Gunthorpe
6df62c5b05
vfio: Make vfio_device_ops pass a 'struct vfio_device *' instead of 'void *'
...
This is the standard kernel pattern, the ops associated with a struct get
the struct pointer in for typesafety. The expected design is to use
container_of to cleanly go from the subsystem level type to the driver
level type without having any type erasure in a void *.
Reviewed-by: Dan Williams <dan.j.williams@intel.com >
Reviewed-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Cornelia Huck <cohuck@redhat.com >
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com >
Message-Id: <12-v3-225de1400dfc+4e074-vfio1_jgg@nvidia.com >
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2021-04-06 11:55:11 -06:00
Jason Gunthorpe
cb61645868
vfio/platform: Use vfio_init/register/unregister_group_dev
...
platform already allocates a struct vfio_platform_device with exactly
the same lifetime as vfio_device, switch to the new API and embed
vfio_device in vfio_platform_device.
Reviewed-by: Christoph Hellwig <hch@lst.de >
Reviewed-by: Cornelia Huck <cohuck@redhat.com >
Acked-by: Eric Auger <eric.auger@redhat.com >
Tested-by: Eric Auger <eric.auger@redhat.com >
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com >
Message-Id: <4-v3-225de1400dfc+4e074-vfio1_jgg@nvidia.com >
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2021-04-06 11:55:10 -06:00
Zhen Lei
f5c858ec2b
vfio/platform: Fix spelling mistake "registe" -> "register"
...
There is a spelling mistake in a comment, fix it.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com >
Acked-by: Eric Auger <eric.auger@redhat.com >
Message-Id: <20210326083528.1329-5-thunder.leizhen@huawei.com >
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2021-04-06 11:53:50 -06:00
Jason Gunthorpe
3b49dfb08c
ARM: amba: Allow some ARM_AMBA users to compile with COMPILE_TEST
...
CONFIG_VFIO_AMBA has a light use of AMBA, adding some inline fallbacks
when AMBA is disabled will allow it to be compiled under COMPILE_TEST and
make VFIO easier to maintain.
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com >
Message-Id: <3-v1-df057e0f92c3+91-vfio_arm_compile_test_jgg@nvidia.com >
Reviewed-by: Eric Auger <eric.auger@redhat.com >
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2021-03-16 10:39:28 -06:00
Jason Gunthorpe
d3d72a6dff
vfio-platform: Add COMPILE_TEST to VFIO_PLATFORM
...
x86 can build platform bus code too, so vfio-platform and all the platform
reset implementations compile successfully on x86.
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com >
Message-Id: <2-v1-df057e0f92c3+91-vfio_arm_compile_test_jgg@nvidia.com >
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2021-03-16 10:39:28 -06:00
Uwe Kleine-König
3fd269e74f
amba: Make the remove callback return void
...
All amba drivers return 0 in their remove callback. Together with the
driver core ignoring the return value anyhow, it doesn't make sense to
return a value here.
Change the remove prototype to return void, which makes it explicit that
returning an error value doesn't work as expected. This simplifies changing
the core remove callback to return void, too.
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org >
Reviewed-by: Arnd Bergmann <arnd@arndb.de >
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com >
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com >
Acked-by: Krzysztof Kozlowski <krzk@kernel.org > # for drivers/memory
Acked-by: Mark Brown <broonie@kernel.org >
Acked-by: Linus Walleij <linus.walleij@linaro.org >
Acked-by: Suzuki K Poulose <suzuki.poulose@arm.com > # for hwtracing/coresight
Acked-By: Vinod Koul <vkoul@kernel.org > # for dmaengine
Acked-by: Guenter Roeck <linux@roeck-us.net > # for watchdog
Acked-by: Wolfram Sang <wsa@kernel.org > # for I2C
Acked-by: Takashi Iwai <tiwai@suse.de > # for sound
Acked-by: Vladimir Zapolskiy <vz@mleia.com > # for memory/pl172
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Link: https://lore.kernel.org/r/20210126165835.687514-5-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de >
2021-02-02 14:25:50 +01:00
Uwe Kleine-König
5b495ac8fe
vfio: platform: simplify device removal
...
vfio_platform_remove_common() cannot return non-NULL in
vfio_amba_remove() as the latter is only called if vfio_amba_probe()
returned success.
Diagnosed-by: Arnd Bergmann <arnd@arndb.de >
Acked-by: Eric Auger <eric.auger@redhat.com >
Link: https://lore.kernel.org/r/20210126165835.687514-4-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de >
2021-02-02 14:24:23 +01:00
Andy Shevchenko
feaba5932b
vfio: platform: Switch to use platform_get_mem_or_io()
...
Switch to use new platform_get_mem_or_io() instead of home grown analogue.
Cc: Alex Williamson <alex.williamson@redhat.com >
Cc: Cornelia Huck <cohuck@redhat.com >
Cc: kvm@vger.kernel.org
Acked-by: Eric Auger <eric.auger@redhat.com >
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com >
Link: https://lore.kernel.org/r/20201209203642.27648-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2020-12-10 16:31:46 +01:00
Zhang Qilong
bb742ad019
vfio: platform: fix reference leak in vfio_platform_open
...
pm_runtime_get_sync() will increment pm usage counter even it
failed. Forgetting to call pm_runtime_put will result in
reference leak in vfio_platform_open, so we should fix it.
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com >
Acked-by: Eric Auger <eric.auger@redhat.com >
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2020-11-03 11:07:40 -07:00
Eric Auger
723fe298ad
vfio: platform: Switch to platform_get_irq_optional()
...
Since commit 7723f4c5ec ("driver core: platform: Add an error
message to platform_get_irq*()"), platform_get_irq() calls dev_err()
on an error. As we enumerate all interrupts until platform_get_irq()
fails, we now systematically get a message such as:
"vfio-platform fff51000.ethernet: IRQ index 3 not found" which is
a false positive.
Let's use platform_get_irq_optional() instead.
Signed-off-by: Eric Auger <eric.auger@redhat.com >
Cc: stable@vger.kernel.org # v5.3+
Reviewed-by: Andre Przywara <andre.przywara@arm.com >
Tested-by: Andre Przywara <andre.przywara@arm.com >
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2020-03-24 09:26:30 -06:00
Linus Torvalds
a6d5f9dca4
Merge tag 'vfio-v5.6-rc1' of git://github.com/awilliam/linux-vfio
...
Pull VFIO updates from Alex Williamson:
- Fix nvlink error path (Alexey Kardashevskiy)
- Update nvlink and spapr to use mmgrab() (Julia Lawall)
- Update static declaration (Ben Dooks)
- Annotate __iomem to fix sparse warnings (Ben Dooks)
* tag 'vfio-v5.6-rc1' of git://github.com/awilliam/linux-vfio:
vfio: platform: fix __iomem in vfio_platform_amdxgbe.c
vfio/mdev: make create attribute static
vfio/spapr_tce: use mmgrab
vfio: vfio_pci_nvlink2: use mmgrab
vfio/spapr/nvlink2: Skip unpinning pages on error exit
2020-02-03 22:22:05 +00:00
Ben Dooks (Codethink)
7b5372ba04
vfio: platform: fix __iomem in vfio_platform_amdxgbe.c
...
The ioaddr should have __iomem marker on it, so add that to fix
the following sparse warnings:
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:33:44: warning: incorrect type in argument 2 (different address spaces)
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:33:44: expected void volatile [noderef] <asn:2> *addr
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:33:44: got void *
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:34:33: warning: incorrect type in argument 1 (different address spaces)
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:34:33: expected void const volatile [noderef] <asn:2> *addr
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:34:33: got void *
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:44:44: warning: incorrect type in argument 2 (different address spaces)
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:44:44: expected void volatile [noderef] <asn:2> *addr
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:44:44: got void *
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:45:33: warning: incorrect type in argument 2 (different address spaces)
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:45:33: expected void volatile [noderef] <asn:2> *addr
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:45:33: got void *
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:69:41: warning: incorrect type in argument 1 (different address spaces)
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:69:41: expected void *ioaddr
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:69:41: got void [noderef] <asn:2> *ioaddr
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:71:30: warning: incorrect type in argument 1 (different address spaces)
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:71:30: expected void *ioaddr
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:71:30: got void [noderef] <asn:2> *ioaddr
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:76:49: warning: incorrect type in argument 1 (different address spaces)
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:76:49: expected void *ioaddr
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:76:49: got void [noderef] <asn:2> *ioaddr
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:85:37: warning: incorrect type in argument 1 (different address spaces)
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:85:37: expected void *ioaddr
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:85:37: got void [noderef] <asn:2> *ioaddr
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:87:30: warning: incorrect type in argument 1 (different address spaces)
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:87:30: expected void *ioaddr
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:87:30: got void [noderef] <asn:2> *ioaddr
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:90:30: warning: incorrect type in argument 1 (different address spaces)
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:90:30: expected void *ioaddr
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:90:30: got void [noderef] <asn:2> *ioaddr
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:93:30: warning: incorrect type in argument 1 (different address spaces)
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:93:30: expected void *ioaddr
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c:93:30: got void [noderef] <asn:2> *ioaddr
Signed-off-by: Ben Dooks (Codethink) <ben.dooks@codethink.co.uk >
Acked-by: Eric Auger <eric.auger@redhat.com >
Signed-off-by: Alex Williamson <alex.williamson@redhat.com >
2020-01-09 11:32:14 -07:00
Christoph Hellwig
4bdc0d676a
remove ioremap_nocache and devm_ioremap_nocache
...
ioremap has provided non-cached semantics by default since the Linux 2.6
days, so remove the additional ioremap_nocache interface.
Signed-off-by: Christoph Hellwig <hch@lst.de >
Acked-by: Arnd Bergmann <arnd@arndb.de >
2020-01-06 09:45:59 +01:00