Skip to content

Commit d4ec3d5

Browse files
committed
Merge tag 'vfio-v5.16-rc1' of git://github.com/awilliam/linux-vfio
Pull VFIO updates from Alex Williamson: - Cleanup vfio iommu_group creation (Christoph Hellwig) - Add individual device reset for vfio/fsl-mc (Diana Craciun) - IGD OpRegion 2.0+ support (Colin Xu) - Use modern cdev lifecycle for vfio_group (Jason Gunthorpe) - Use new mdev API in vfio_ccw (Jason Gunthorpe) * tag 'vfio-v5.16-rc1' of git://github.com/awilliam/linux-vfio: (27 commits) vfio/ccw: Convert to use vfio_register_emulated_iommu_dev() vfio/ccw: Pass vfio_ccw_private not mdev_device to various functions vfio/ccw: Use functions for alloc/free of the vfio_ccw_private vfio/ccw: Remove unneeded GFP_DMA vfio: Use cdev_device_add() instead of device_create() vfio: Use a refcount_t instead of a kref in the vfio_group vfio: Don't leak a group reference if the group already exists vfio: Do not open code the group list search in vfio_create_group() vfio: Delete vfio_get/put_group from vfio_iommu_group_notifier() vfio/pci: Add OpRegion 2.0+ Extended VBT support. vfio/iommu_type1: remove IS_IOMMU_CAP_DOMAIN_IN_CONTAINER vfio/iommu_type1: remove the "external" domain vfio/iommu_type1: initialize pgsize_bitmap in ->open vfio/spapr_tce: reject mediated devices vfio: clean up the check for mediated device in vfio_iommu_type1 vfio: remove the unused mdev iommu hook vfio: move the vfio_iommu_driver_ops interface out of <linux/vfio.h> vfio: remove unused method from vfio_iommu_driver_ops vfio: simplify iommu group allocation for mediated devices vfio: remove the iommudata hack for noiommu groups ...
2 parents a602285 + 3bf1311 commit d4ec3d5

File tree

23 files changed

+945
-903
lines changed

23 files changed

+945
-903
lines changed

drivers/bus/fsl-mc/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ mc-bus-driver-objs := fsl-mc-bus.o \
1515
dprc-driver.o \
1616
fsl-mc-allocator.o \
1717
fsl-mc-msi.o \
18-
dpmcp.o
18+
dpmcp.o \
19+
obj-api.o
1920

2021
# MC userspace support
2122
obj-$(CONFIG_FSL_MC_UAPI_SUPPORT) += fsl-mc-uapi.o

drivers/bus/fsl-mc/fsl-mc-private.h

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ struct dpmng_rsp_get_version {
4848

4949
/* DPMCP command IDs */
5050
#define DPMCP_CMDID_CLOSE DPMCP_CMD(0x800)
51-
#define DPMCP_CMDID_OPEN DPMCP_CMD(0x80b)
5251
#define DPMCP_CMDID_RESET DPMCP_CMD(0x005)
5352

5453
struct dpmcp_cmd_open {
@@ -91,7 +90,6 @@ int dpmcp_reset(struct fsl_mc_io *mc_io,
9190

9291
/* DPRC command IDs */
9392
#define DPRC_CMDID_CLOSE DPRC_CMD(0x800)
94-
#define DPRC_CMDID_OPEN DPRC_CMD(0x805)
9593
#define DPRC_CMDID_GET_API_VERSION DPRC_CMD(0xa05)
9694

9795
#define DPRC_CMDID_GET_ATTR DPRC_CMD(0x004)
@@ -453,7 +451,6 @@ int dprc_get_connection(struct fsl_mc_io *mc_io,
453451

454452
/* Command IDs */
455453
#define DPBP_CMDID_CLOSE DPBP_CMD(0x800)
456-
#define DPBP_CMDID_OPEN DPBP_CMD(0x804)
457454

458455
#define DPBP_CMDID_ENABLE DPBP_CMD(0x002)
459456
#define DPBP_CMDID_DISABLE DPBP_CMD(0x003)
@@ -492,7 +489,6 @@ struct dpbp_rsp_get_attributes {
492489

493490
/* Command IDs */
494491
#define DPCON_CMDID_CLOSE DPCON_CMD(0x800)
495-
#define DPCON_CMDID_OPEN DPCON_CMD(0x808)
496492

497493
#define DPCON_CMDID_ENABLE DPCON_CMD(0x002)
498494
#define DPCON_CMDID_DISABLE DPCON_CMD(0x003)
@@ -524,6 +520,41 @@ struct dpcon_cmd_set_notification {
524520
__le64 user_ctx;
525521
};
526522

523+
/*
524+
* Generic FSL MC API
525+
*/
526+
527+
/* generic command versioning */
528+
#define OBJ_CMD_BASE_VERSION 1
529+
#define OBJ_CMD_ID_OFFSET 4
530+
531+
#define OBJ_CMD(id) (((id) << OBJ_CMD_ID_OFFSET) | OBJ_CMD_BASE_VERSION)
532+
533+
/* open command codes */
534+
#define DPRTC_CMDID_OPEN OBJ_CMD(0x810)
535+
#define DPNI_CMDID_OPEN OBJ_CMD(0x801)
536+
#define DPSW_CMDID_OPEN OBJ_CMD(0x802)
537+
#define DPIO_CMDID_OPEN OBJ_CMD(0x803)
538+
#define DPBP_CMDID_OPEN OBJ_CMD(0x804)
539+
#define DPRC_CMDID_OPEN OBJ_CMD(0x805)
540+
#define DPDMUX_CMDID_OPEN OBJ_CMD(0x806)
541+
#define DPCI_CMDID_OPEN OBJ_CMD(0x807)
542+
#define DPCON_CMDID_OPEN OBJ_CMD(0x808)
543+
#define DPSECI_CMDID_OPEN OBJ_CMD(0x809)
544+
#define DPAIOP_CMDID_OPEN OBJ_CMD(0x80a)
545+
#define DPMCP_CMDID_OPEN OBJ_CMD(0x80b)
546+
#define DPMAC_CMDID_OPEN OBJ_CMD(0x80c)
547+
#define DPDCEI_CMDID_OPEN OBJ_CMD(0x80d)
548+
#define DPDMAI_CMDID_OPEN OBJ_CMD(0x80e)
549+
#define DPDBG_CMDID_OPEN OBJ_CMD(0x80f)
550+
551+
/* Generic object command IDs */
552+
#define OBJ_CMDID_CLOSE OBJ_CMD(0x800)
553+
#define OBJ_CMDID_RESET OBJ_CMD(0x005)
554+
555+
struct fsl_mc_obj_cmd_open {
556+
__le32 obj_id;
557+
};
527558

528559
/**
529560
* struct fsl_mc_resource_pool - Pool of MC resources of a given

drivers/bus/fsl-mc/obj-api.c

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
2+
/*
3+
* Copyright 2021 NXP
4+
*
5+
*/
6+
#include <linux/kernel.h>
7+
#include <linux/fsl/mc.h>
8+
9+
#include "fsl-mc-private.h"
10+
11+
static int fsl_mc_get_open_cmd_id(const char *type)
12+
{
13+
static const struct {
14+
int cmd_id;
15+
const char *type;
16+
} dev_ids[] = {
17+
{ DPRTC_CMDID_OPEN, "dprtc" },
18+
{ DPRC_CMDID_OPEN, "dprc" },
19+
{ DPNI_CMDID_OPEN, "dpni" },
20+
{ DPIO_CMDID_OPEN, "dpio" },
21+
{ DPSW_CMDID_OPEN, "dpsw" },
22+
{ DPBP_CMDID_OPEN, "dpbp" },
23+
{ DPCON_CMDID_OPEN, "dpcon" },
24+
{ DPMCP_CMDID_OPEN, "dpmcp" },
25+
{ DPMAC_CMDID_OPEN, "dpmac" },
26+
{ DPSECI_CMDID_OPEN, "dpseci" },
27+
{ DPDMUX_CMDID_OPEN, "dpdmux" },
28+
{ DPDCEI_CMDID_OPEN, "dpdcei" },
29+
{ DPAIOP_CMDID_OPEN, "dpaiop" },
30+
{ DPCI_CMDID_OPEN, "dpci" },
31+
{ DPDMAI_CMDID_OPEN, "dpdmai" },
32+
{ DPDBG_CMDID_OPEN, "dpdbg" },
33+
{ 0, NULL }
34+
};
35+
int i;
36+
37+
for (i = 0; dev_ids[i].type; i++)
38+
if (!strcmp(dev_ids[i].type, type))
39+
return dev_ids[i].cmd_id;
40+
41+
return -1;
42+
}
43+
44+
int fsl_mc_obj_open(struct fsl_mc_io *mc_io,
45+
u32 cmd_flags,
46+
int obj_id,
47+
char *obj_type,
48+
u16 *token)
49+
{
50+
struct fsl_mc_command cmd = { 0 };
51+
struct fsl_mc_obj_cmd_open *cmd_params;
52+
int err = 0;
53+
int cmd_id = fsl_mc_get_open_cmd_id(obj_type);
54+
55+
if (cmd_id == -1)
56+
return -ENODEV;
57+
58+
/* prepare command */
59+
cmd.header = mc_encode_cmd_header(cmd_id, cmd_flags, 0);
60+
cmd_params = (struct fsl_mc_obj_cmd_open *)cmd.params;
61+
cmd_params->obj_id = cpu_to_le32(obj_id);
62+
63+
/* send command to mc*/
64+
err = mc_send_command(mc_io, &cmd);
65+
if (err)
66+
return err;
67+
68+
/* retrieve response parameters */
69+
*token = mc_cmd_hdr_read_token(&cmd);
70+
71+
return err;
72+
}
73+
EXPORT_SYMBOL_GPL(fsl_mc_obj_open);
74+
75+
int fsl_mc_obj_close(struct fsl_mc_io *mc_io,
76+
u32 cmd_flags,
77+
u16 token)
78+
{
79+
struct fsl_mc_command cmd = { 0 };
80+
81+
/* prepare command */
82+
cmd.header = mc_encode_cmd_header(OBJ_CMDID_CLOSE, cmd_flags,
83+
token);
84+
85+
/* send command to mc*/
86+
return mc_send_command(mc_io, &cmd);
87+
}
88+
EXPORT_SYMBOL_GPL(fsl_mc_obj_close);
89+
90+
int fsl_mc_obj_reset(struct fsl_mc_io *mc_io,
91+
u32 cmd_flags,
92+
u16 token)
93+
{
94+
struct fsl_mc_command cmd = { 0 };
95+
96+
/* prepare command */
97+
cmd.header = mc_encode_cmd_header(OBJ_CMDID_RESET, cmd_flags,
98+
token);
99+
100+
/* send command to mc*/
101+
return mc_send_command(mc_io, &cmd);
102+
}
103+
EXPORT_SYMBOL_GPL(fsl_mc_obj_reset);

0 commit comments

Comments
 (0)