Re: [External] Re: [PATCH 0/7] Introduce vdpa management tool
On 2020/12/2 下午2:24, Parav Pandit wrote: From: Jason Wang Sent: Wednesday, December 2, 2020 11:21 AM On 2020/12/2 下午12:53, Parav Pandit wrote: From: Yongji Xie Sent: Wednesday, December 2, 2020 9:00 AM On Tue, Dec 1, 2020 at 11:59 PM Parav Pandit wrote: From: Yongji Xie Sent: Tuesday, December 1, 2020 7:49 PM On Tue, Dec 1, 2020 at 7:32 PM Parav Pandit wrote: From: Yongji Xie Sent: Tuesday, December 1, 2020 3:26 PM On Tue, Dec 1, 2020 at 2:25 PM Jason Wang wrote: On 2020/11/30 下午3:07, Yongji Xie wrote: Thanks for adding me, Jason! Now I'm working on a v2 patchset for VDUSE (vDPA Device in Userspace) [1]. This tool is very useful for the vduse device. So I'm considering integrating this into my v2 patchset. But there is one problem: In this tool, vdpa device config action and enable action are combined into one netlink msg: VDPA_CMD_DEV_NEW. But in vduse case, it needs to be splitted because a chardev should be created and opened by a userspace process before we enable the vdpa device (call vdpa_register_device()). So I'd like to know whether it's possible (or have some plans) to add two new netlink msgs something like: VDPA_CMD_DEV_ENABLE and VDPA_CMD_DEV_DISABLE to make the config path more flexible. Actually, we've discussed such intermediate step in some early discussion. It looks to me VDUSE could be one of the users of this. Or I wonder whether we can switch to use anonymous inode(fd) for VDUSE then fetching it via an VDUSE_GET_DEVICE_FD ioctl? Yes, we can. Actually the current implementation in VDUSE is like this. But seems like this is still a intermediate step. The fd should be binded to a name or something else which need to be configured before. The name could be specified via the netlink. It looks to me the real issue is that until the device is connected with a userspace, it can't be used. So we also need to fail the enabling if it doesn't opened. Yes, that's true. So you mean we can firstly try to fetch the fd binded to a name/vduse_id via an VDUSE_GET_DEVICE_FD, then use the name/vduse_id as a attribute to create vdpa device? It looks fine to me. I probably do not well understand. I tried reading patch [1] and few things do not look correct as below. Creating the vdpa device on the bus device and destroying the device from the workqueue seems unnecessary and racy. It seems vduse driver needs This is something should be done as part of the vdpa dev add command, instead of connecting two sides separately and ensuring race free access to it. So VDUSE_DEV_START and VDUSE_DEV_STOP should possibly be avoided. Yes, we can avoid these two ioctls with the help of the management tool. $ vdpa dev add parentdev vduse_mgmtdev type net name foo2 When above command is executed it creates necessary vdpa device foo2 on the bus. When user binds foo2 device with the vduse driver, in the probe(), it creates respective char device to access it from user space. I see. So vduse cannot work with any existing vdpa devices like ifc, mlx5 or netdevsim. It has its own implementation similar to fuse with its own backend of choice. More below. But vduse driver is not a vdpa bus driver. It works like vdpasim driver, but offloads the data plane and control plane to a user space process. In that case to draw parallel lines, 1. netdevsim: (a) create resources in kernel sw (b) datapath simulates in kernel 2. ifc + mlx5 vdpa dev: (a) creates resource in hw (b) data path is in hw 3. vduse: (a) creates resources in userspace sw (b) data path is in user space. hence creates data path resources for user space. So char device is created, removed as result of vdpa device creation. For example, $ vdpa dev add parentdev vduse_mgmtdev type net name foo2 Above command will create char device for user space. Similar command for ifc/mlx5 would have created similar channel for rest of the config commands in hw. vduse channel = char device, eventfd etc. ifc/mlx5 hw channel = bar, irq, command interface etc Netdev sim channel = sw direct calls Does it make sense? In my understanding, to make vdpa work, we need a backend (datapath resources) and a frontend (a vdpa device attached to a vdpa bus). In the above example, it looks like we use the command "vdpa dev add ..." to create a backend, so do we need another command to create a frontend? For block device there is certainly some backend to process the IOs. Sometimes backend to be setup first, before its front end is exposed. "vdpa dev add" is the front end command who connects to the backend (implicitly) for network device. vhost->vdpa_block_device->backend_io_processor (usr,hw,kernel). And it needs a way to connect to backend when explicitly specified during creation time. Something like, $ vdpa dev add parentdev vdpa_vduse type block name foo3 handle In above example some vendor device specific unique handle is passed based on backend setup in hardware/user space. In below 3 examples, vdpa
[PATCH] vhost_vdpa: return -EFAULT if copy_to_user() fails
The copy_to_user() function returns the number of bytes remaining to be copied but this should return -EFAULT to the user. Fixes: 1b48dc03e575 ("vhost: vdpa: report iova range") Signed-off-by: Dan Carpenter --- drivers/vhost/vdpa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index d6a37b66770b..ef688c8c0e0e 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -344,7 +344,9 @@ static long vhost_vdpa_get_iova_range(struct vhost_vdpa *v, u32 __user *argp) .last = v->range.last, }; - return copy_to_user(argp, , sizeof(range)); + if (copy_to_user(argp, , sizeof(range))) + return -EFAULT; + return 0; } static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, -- 2.29.2 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
RE: [External] Re: [PATCH 0/7] Introduce vdpa management tool
> From: Jason Wang > Sent: Wednesday, December 2, 2020 11:21 AM > > On 2020/12/2 下午12:53, Parav Pandit wrote: > > > >> From: Yongji Xie > >> Sent: Wednesday, December 2, 2020 9:00 AM > >> > >> On Tue, Dec 1, 2020 at 11:59 PM Parav Pandit wrote: > >>> > >>> > From: Yongji Xie > Sent: Tuesday, December 1, 2020 7:49 PM > > On Tue, Dec 1, 2020 at 7:32 PM Parav Pandit > wrote: > > > > > >> From: Yongji Xie > >> Sent: Tuesday, December 1, 2020 3:26 PM > >> > >> On Tue, Dec 1, 2020 at 2:25 PM Jason Wang > > wrote: > >>> > >>> On 2020/11/30 下午3:07, Yongji Xie wrote: > >> Thanks for adding me, Jason! > >> > >> Now I'm working on a v2 patchset for VDUSE (vDPA Device in > >> Userspace) [1]. This tool is very useful for the vduse device. > >> So I'm considering integrating this into my v2 patchset. > >> But there is one problem: > >> > >> In this tool, vdpa device config action and enable action are > >> combined into one netlink msg: VDPA_CMD_DEV_NEW. But in > vduse > >> case, it needs to be splitted because a chardev should be > >> created and opened by a userspace process before we enable > >> the vdpa device (call vdpa_register_device()). > >> > >> So I'd like to know whether it's possible (or have some > >> plans) to add two new netlink msgs something like: > >> VDPA_CMD_DEV_ENABLE > >> and > >> VDPA_CMD_DEV_DISABLE to make the config path more > flexible. > >> > > Actually, we've discussed such intermediate step in some early > > discussion. It looks to me VDUSE could be one of the users of > >> this. > > Or I wonder whether we can switch to use anonymous > > inode(fd) for VDUSE then fetching it via an > > VDUSE_GET_DEVICE_FD > >> ioctl? > Yes, we can. Actually the current implementation in VDUSE is > like this. But seems like this is still a intermediate step. > The fd should be binded to a name or something else which need > to be configured before. > >>> > >>> The name could be specified via the netlink. It looks to me the > >>> real issue is that until the device is connected with a > >>> userspace, it can't be used. So we also need to fail the > >>> enabling if it doesn't > opened. > >> Yes, that's true. So you mean we can firstly try to fetch the fd > >> binded to a name/vduse_id via an VDUSE_GET_DEVICE_FD, then > use > >> the name/vduse_id as a attribute to create vdpa device? It looks > >> fine to > >> me. > > I probably do not well understand. I tried reading patch [1] and > > few things > do not look correct as below. > > Creating the vdpa device on the bus device and destroying the > > device from > the workqueue seems unnecessary and racy. > > It seems vduse driver needs > > This is something should be done as part of the vdpa dev add > > command, > instead of connecting two sides separately and ensuring race free > access to it. > > So VDUSE_DEV_START and VDUSE_DEV_STOP should possibly be > avoided. > > > Yes, we can avoid these two ioctls with the help of the management > tool. > > > $ vdpa dev add parentdev vduse_mgmtdev type net name foo2 > > > > When above command is executed it creates necessary vdpa device > > foo2 > on the bus. > > When user binds foo2 device with the vduse driver, in the probe(), > > it > creates respective char device to access it from user space. > > >>> I see. So vduse cannot work with any existing vdpa devices like ifc, > >>> mlx5 or > >> netdevsim. > >>> It has its own implementation similar to fuse with its own backend of > choice. > >>> More below. > >>> > But vduse driver is not a vdpa bus driver. It works like vdpasim > driver, but offloads the data plane and control plane to a user space > process. > >>> In that case to draw parallel lines, > >>> > >>> 1. netdevsim: > >>> (a) create resources in kernel sw > >>> (b) datapath simulates in kernel > >>> > >>> 2. ifc + mlx5 vdpa dev: > >>> (a) creates resource in hw > >>> (b) data path is in hw > >>> > >>> 3. vduse: > >>> (a) creates resources in userspace sw > >>> (b) data path is in user space. > >>> hence creates data path resources for user space. > >>> So char device is created, removed as result of vdpa device creation. > >>> > >>> For example, > >>> $ vdpa dev add parentdev vduse_mgmtdev type net name foo2 > >>> > >>> Above command will create char device for user space. > >>> > >>> Similar command for ifc/mlx5 would have created similar channel for > >>> rest of > >> the config commands in hw. > >>> vduse channel = char device, eventfd etc. > >>> ifc/mlx5 hw channel = bar, irq, command interface etc Netdev sim > >>> channel = sw direct calls > >>> > >>> Does it make
Re: [External] Re: [PATCH 0/7] Introduce vdpa management tool
On 2020/12/2 下午12:53, Parav Pandit wrote: From: Yongji Xie Sent: Wednesday, December 2, 2020 9:00 AM On Tue, Dec 1, 2020 at 11:59 PM Parav Pandit wrote: From: Yongji Xie Sent: Tuesday, December 1, 2020 7:49 PM On Tue, Dec 1, 2020 at 7:32 PM Parav Pandit wrote: From: Yongji Xie Sent: Tuesday, December 1, 2020 3:26 PM On Tue, Dec 1, 2020 at 2:25 PM Jason Wang wrote: On 2020/11/30 下午3:07, Yongji Xie wrote: Thanks for adding me, Jason! Now I'm working on a v2 patchset for VDUSE (vDPA Device in Userspace) [1]. This tool is very useful for the vduse device. So I'm considering integrating this into my v2 patchset. But there is one problem: In this tool, vdpa device config action and enable action are combined into one netlink msg: VDPA_CMD_DEV_NEW. But in vduse case, it needs to be splitted because a chardev should be created and opened by a userspace process before we enable the vdpa device (call vdpa_register_device()). So I'd like to know whether it's possible (or have some plans) to add two new netlink msgs something like: VDPA_CMD_DEV_ENABLE and VDPA_CMD_DEV_DISABLE to make the config path more flexible. Actually, we've discussed such intermediate step in some early discussion. It looks to me VDUSE could be one of the users of this. Or I wonder whether we can switch to use anonymous inode(fd) for VDUSE then fetching it via an VDUSE_GET_DEVICE_FD ioctl? Yes, we can. Actually the current implementation in VDUSE is like this. But seems like this is still a intermediate step. The fd should be binded to a name or something else which need to be configured before. The name could be specified via the netlink. It looks to me the real issue is that until the device is connected with a userspace, it can't be used. So we also need to fail the enabling if it doesn't opened. Yes, that's true. So you mean we can firstly try to fetch the fd binded to a name/vduse_id via an VDUSE_GET_DEVICE_FD, then use the name/vduse_id as a attribute to create vdpa device? It looks fine to me. I probably do not well understand. I tried reading patch [1] and few things do not look correct as below. Creating the vdpa device on the bus device and destroying the device from the workqueue seems unnecessary and racy. It seems vduse driver needs This is something should be done as part of the vdpa dev add command, instead of connecting two sides separately and ensuring race free access to it. So VDUSE_DEV_START and VDUSE_DEV_STOP should possibly be avoided. Yes, we can avoid these two ioctls with the help of the management tool. $ vdpa dev add parentdev vduse_mgmtdev type net name foo2 When above command is executed it creates necessary vdpa device foo2 on the bus. When user binds foo2 device with the vduse driver, in the probe(), it creates respective char device to access it from user space. I see. So vduse cannot work with any existing vdpa devices like ifc, mlx5 or netdevsim. It has its own implementation similar to fuse with its own backend of choice. More below. But vduse driver is not a vdpa bus driver. It works like vdpasim driver, but offloads the data plane and control plane to a user space process. In that case to draw parallel lines, 1. netdevsim: (a) create resources in kernel sw (b) datapath simulates in kernel 2. ifc + mlx5 vdpa dev: (a) creates resource in hw (b) data path is in hw 3. vduse: (a) creates resources in userspace sw (b) data path is in user space. hence creates data path resources for user space. So char device is created, removed as result of vdpa device creation. For example, $ vdpa dev add parentdev vduse_mgmtdev type net name foo2 Above command will create char device for user space. Similar command for ifc/mlx5 would have created similar channel for rest of the config commands in hw. vduse channel = char device, eventfd etc. ifc/mlx5 hw channel = bar, irq, command interface etc Netdev sim channel = sw direct calls Does it make sense? In my understanding, to make vdpa work, we need a backend (datapath resources) and a frontend (a vdpa device attached to a vdpa bus). In the above example, it looks like we use the command "vdpa dev add ..." to create a backend, so do we need another command to create a frontend? For block device there is certainly some backend to process the IOs. Sometimes backend to be setup first, before its front end is exposed. "vdpa dev add" is the front end command who connects to the backend (implicitly) for network device. vhost->vdpa_block_device->backend_io_processor (usr,hw,kernel). And it needs a way to connect to backend when explicitly specified during creation time. Something like, $ vdpa dev add parentdev vdpa_vduse type block name foo3 handle In above example some vendor device specific unique handle is passed based on backend setup in hardware/user space. In below 3 examples, vdpa block simulator is connecting to backend block or file. $ vdpa dev add parentdev vdpa_blocksim type block name
Re: [External] Re: [PATCH 0/7] Introduce vdpa management tool
On 2020/12/1 下午5:55, Yongji Xie wrote: On Tue, Dec 1, 2020 at 2:25 PM Jason Wang wrote: On 2020/11/30 下午3:07, Yongji Xie wrote: Thanks for adding me, Jason! Now I'm working on a v2 patchset for VDUSE (vDPA Device in Userspace) [1]. This tool is very useful for the vduse device. So I'm considering integrating this into my v2 patchset. But there is one problem: In this tool, vdpa device config action and enable action are combined into one netlink msg: VDPA_CMD_DEV_NEW. But in vduse case, it needs to be splitted because a chardev should be created and opened by a userspace process before we enable the vdpa device (call vdpa_register_device()). So I'd like to know whether it's possible (or have some plans) to add two new netlink msgs something like: VDPA_CMD_DEV_ENABLE and VDPA_CMD_DEV_DISABLE to make the config path more flexible. Actually, we've discussed such intermediate step in some early discussion. It looks to me VDUSE could be one of the users of this. Or I wonder whether we can switch to use anonymous inode(fd) for VDUSE then fetching it via an VDUSE_GET_DEVICE_FD ioctl? Yes, we can. Actually the current implementation in VDUSE is like this. But seems like this is still a intermediate step. The fd should be binded to a name or something else which need to be configured before. The name could be specified via the netlink. It looks to me the real issue is that until the device is connected with a userspace, it can't be used. So we also need to fail the enabling if it doesn't opened. Yes, that's true. So you mean we can firstly try to fetch the fd binded to a name/vduse_id via an VDUSE_GET_DEVICE_FD, then use the name/vduse_id as a attribute to create vdpa device? It looks fine to me. Yes, something like this. The anonymous fd will be created during dev_add() and the fd will be carried in the msg to userspace. Thanks Thanks, Yongji ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
RE: [External] Re: [PATCH 0/7] Introduce vdpa management tool
> From: Yongji Xie > Sent: Wednesday, December 2, 2020 9:00 AM > > On Tue, Dec 1, 2020 at 11:59 PM Parav Pandit wrote: > > > > > > > > > From: Yongji Xie > > > Sent: Tuesday, December 1, 2020 7:49 PM > > > > > > On Tue, Dec 1, 2020 at 7:32 PM Parav Pandit wrote: > > > > > > > > > > > > > > > > > From: Yongji Xie > > > > > Sent: Tuesday, December 1, 2020 3:26 PM > > > > > > > > > > On Tue, Dec 1, 2020 at 2:25 PM Jason Wang > > > wrote: > > > > > > > > > > > > > > > > > > On 2020/11/30 下午3:07, Yongji Xie wrote: > > > > > > >>> Thanks for adding me, Jason! > > > > > > >>> > > > > > > >>> Now I'm working on a v2 patchset for VDUSE (vDPA Device in > > > > > > >>> Userspace) [1]. This tool is very useful for the vduse device. > > > > > > >>> So I'm considering integrating this into my v2 patchset. > > > > > > >>> But there is one problem: > > > > > > >>> > > > > > > >>> In this tool, vdpa device config action and enable action > > > > > > >>> are combined into one netlink msg: VDPA_CMD_DEV_NEW. But > > > > > > >>> in > > > vduse > > > > > > >>> case, it needs to be splitted because a chardev should be > > > > > > >>> created and opened by a userspace process before we enable > > > > > > >>> the vdpa device (call vdpa_register_device()). > > > > > > >>> > > > > > > >>> So I'd like to know whether it's possible (or have some > > > > > > >>> plans) to add two new netlink msgs something like: > > > > > > >>> VDPA_CMD_DEV_ENABLE > > > > > and > > > > > > >>> VDPA_CMD_DEV_DISABLE to make the config path more flexible. > > > > > > >>> > > > > > > >> Actually, we've discussed such intermediate step in some > > > > > > >> early discussion. It looks to me VDUSE could be one of the users > > > > > > >> of > this. > > > > > > >> > > > > > > >> Or I wonder whether we can switch to use anonymous > > > > > > >> inode(fd) for VDUSE then fetching it via an VDUSE_GET_DEVICE_FD > ioctl? > > > > > > >> > > > > > > > Yes, we can. Actually the current implementation in VDUSE is > > > > > > > like this. But seems like this is still a intermediate step. > > > > > > > The fd should be binded to a name or something else which > > > > > > > need to be configured before. > > > > > > > > > > > > > > > > > > The name could be specified via the netlink. It looks to me > > > > > > the real issue is that until the device is connected with a > > > > > > userspace, it can't be used. So we also need to fail the > > > > > > enabling if it doesn't > > > opened. > > > > > > > > > > > > > > > > Yes, that's true. So you mean we can firstly try to fetch the fd > > > > > binded to a name/vduse_id via an VDUSE_GET_DEVICE_FD, then use > > > > > the name/vduse_id as a attribute to create vdpa device? It looks fine > > > > > to > me. > > > > > > > > I probably do not well understand. I tried reading patch [1] and > > > > few things > > > do not look correct as below. > > > > Creating the vdpa device on the bus device and destroying the > > > > device from > > > the workqueue seems unnecessary and racy. > > > > > > > > It seems vduse driver needs > > > > This is something should be done as part of the vdpa dev add > > > > command, > > > instead of connecting two sides separately and ensuring race free > > > access to it. > > > > > > > > So VDUSE_DEV_START and VDUSE_DEV_STOP should possibly be avoided. > > > > > > > > > > Yes, we can avoid these two ioctls with the help of the management tool. > > > > > > > $ vdpa dev add parentdev vduse_mgmtdev type net name foo2 > > > > > > > > When above command is executed it creates necessary vdpa device > > > > foo2 > > > on the bus. > > > > When user binds foo2 device with the vduse driver, in the probe(), > > > > it > > > creates respective char device to access it from user space. > > > > > I see. So vduse cannot work with any existing vdpa devices like ifc, mlx5 or > netdevsim. > > It has its own implementation similar to fuse with its own backend of > > choice. > > More below. > > > > > But vduse driver is not a vdpa bus driver. It works like vdpasim > > > driver, but offloads the data plane and control plane to a user space > > > process. > > > > In that case to draw parallel lines, > > > > 1. netdevsim: > > (a) create resources in kernel sw > > (b) datapath simulates in kernel > > > > 2. ifc + mlx5 vdpa dev: > > (a) creates resource in hw > > (b) data path is in hw > > > > 3. vduse: > > (a) creates resources in userspace sw > > (b) data path is in user space. > > hence creates data path resources for user space. > > So char device is created, removed as result of vdpa device creation. > > > > For example, > > $ vdpa dev add parentdev vduse_mgmtdev type net name foo2 > > > > Above command will create char device for user space. > > > > Similar command for ifc/mlx5 would have created similar channel for rest of > the config commands in hw. > > vduse channel = char device, eventfd etc. > > ifc/mlx5 hw channel = bar, irq, command interface etc Netdev sim > > channel = sw direct calls > > > > Does it
Re: [PATCH] vdpa/mlx5: Use random MAC for the vdpa net instance
On 2020/12/1 下午5:23, Cindy Lu wrote: On Mon, Nov 30, 2020 at 11:33 PM Michael S. Tsirkin wrote: On Mon, Nov 30, 2020 at 06:41:45PM +0800, Cindy Lu wrote: On Mon, Nov 30, 2020 at 5:33 PM Michael S. Tsirkin wrote: On Mon, Nov 30, 2020 at 11:27:59AM +0200, Eli Cohen wrote: On Mon, Nov 30, 2020 at 04:00:51AM -0500, Michael S. Tsirkin wrote: On Mon, Nov 30, 2020 at 08:27:46AM +0200, Eli Cohen wrote: On Sun, Nov 29, 2020 at 03:08:22PM -0500, Michael S. Tsirkin wrote: On Sun, Nov 29, 2020 at 08:43:51AM +0200, Eli Cohen wrote: We should not try to use the VF MAC address as that is used by the regular (e.g. mlx5_core) NIC implementation. Instead, use a random generated MAC address. Suggested by: Cindy Lu Fixes: 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices") Signed-off-by: Eli Cohen I didn't realise it's possible to use VF in two ways with and without vdpa. Using a VF you can create quite a few resources, e.g. send queues recieve queues, virtio_net queues etc. So you can possibly create several instances of vdpa net devices and nic net devices. Could you include a bit more description on the failure mode? Well, using the MAC address of the nic vport is wrong since that is the MAC of the regular NIC implementation of mlx5_core. Right but ATM it doesn't coexist with vdpa so what's the problem? This call is wrong: mlx5_query_nic_vport_mac_address() Is switching to a random mac for such an unusual configuration really justified? Since I can't use the NIC's MAC address, I have two options: 1. To get the MAC address as was chosen by the user administering the NIC. This should invoke the set_config callback. Unfortunately this is not implemented yet. 2. Use a random MAC address. This is OK since if (1) is implemented it can always override this random configuration. It looks like changing a MAC could break some guests, can it not? No, it will not. The current version of mlx5 VDPA does not allow regular NIC driver and VDPA to co-exist. I have patches ready that enable that from steering point of view. I will post them here once other patches on which they depend will be merged. https://patchwork.ozlabs.org/project/netdev/patch/20201120230339.651609-12-sae...@nvidia.com/ Could you be more explicit on the following points: - which configuration is broken ATM (as in, two device have identical macs? any other issues)? The only wrong thing is the call to mlx5_query_nic_vport_mac_address(). It's not breaking anything yet is wrong. The random MAC address setting is required for the steering patches. Okay so I'm not sure the Fixes tag at least is appropriate if it's a dependency of a new feature. - why won't device MAC change from guest point of view? It's lack of implementation in qemu as far as I know. Sorry not sure I understand. What's not implemented in QEMU? HI Michael, there are some bug in qemu to set_config, this will fix in future, But this patch is still needed, because without this patch the mlx driver will give an 0 mac address to qemu and qemu will overwrite the default mac address. This will cause traffic down. Hmm the patch description says VF mac address, not 0 address. Confused. If there's no mac we can clear VIRTIO_NET_F_MAC and have guest use a random value ... I'm not sure this can work for all types of vDPA (e.g it could not be a learning bridge in the swtich). hi Michael, I have tried as your suggestion, seems even remove the VIRTIO_NET_F_MAC the qemu will still call get_cinfig and overwrite the default address in VM, This looks a bug in qemu, in guest driver we had: /* Configuration may specify what MAC to use. Otherwise random. */ if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC)) virtio_cread_bytes(vdev, offsetof(struct virtio_net_config, mac), dev->dev_addr, dev->addr_len); else eth_hw_addr_random(dev); this process is like vdpa _init -->qemu call get_config ->mlx driver will give an mac address with all 0--> qemu will not check this mac address and use it --> overwrite the mac address in qemu So for my understanding there are several method to fix this problem 1, qemu check the mac address, if the mac address is all 0, qemu will ignore it and set the random mac address to mlx driver. So my understanding is that, if mac address is all 0, vDPA parent should not advertise VIRTIO_NET_F_MAC. And qemu should emulate this feature as you did: 1) get a random mac 2) advertise VIRTIO_NET_F_MAC 3) set the random mac to vDPA through set_config 4) advertise the random mac to emulated config to guest 2. mlx driver checks the mac address and if this mac is 0, return fail to qemu, but this need to change the UAPI. uAPI is probably fine since ioctl can fail. We can change the to allow the set_config to fail but virito spec doesn't have a way to advertise the error in this case. Anyway, the driver only risk itself for setting a wrong
Re: [GIT PULL] vhost,vdpa: bugfixes
The pull request you sent on Mon, 30 Nov 2020 03:50:10 -0500: > https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git tags/for_linus has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/f43691b59fae581ca83349539c686ecf4a01e42d Thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 00/10] vhost/qemu: thread per IO SCSI vq
On Tue, Dec 01, 2020 at 02:45:18PM +0100, Stefano Garzarella wrote: > On Tue, Dec 01, 2020 at 12:59:43PM +, Stefan Hajnoczi wrote: > > On Fri, Nov 20, 2020 at 07:31:08AM -0500, Michael S. Tsirkin wrote: > > > On Fri, Nov 20, 2020 at 08:45:49AM +, Stefan Hajnoczi wrote: > > > > On Thu, Nov 19, 2020 at 5:08 PM Stefan Hajnoczi > > > > wrote: > > > > > > > > > > On Thu, Nov 19, 2020 at 4:43 PM Mike Christie > > > > > wrote: > > > > > > > > > > > > On 11/19/20 10:24 AM, Stefan Hajnoczi wrote: > > > > > > > On Thu, Nov 19, 2020 at 4:13 PM Mike Christie > > > > > > > wrote: > > > > > > >> > > > > > > >> On 11/19/20 8:46 AM, Michael S. Tsirkin wrote: > > > > > > >>> On Wed, Nov 18, 2020 at 11:31:17AM +, Stefan Hajnoczi wrote: > > > > > > > struct vhost_run_worker_info { > > > > > > > struct timespec *timeout; > > > > > > > sigset_t *sigmask; > > > > > > > > > > > > > > /* List of virtqueues to process */ > > > > > > > unsigned nvqs; > > > > > > > unsigned vqs[]; > > > > > > > }; > > > > > > > > > > > > > > /* This blocks until the timeout is reached, a signal is > > > > > > > received, or > > > > > > > the vhost device is destroyed */ > > > > > > > int ret = ioctl(vhost_fd, VHOST_RUN_WORKER, ); > > > > > > > > > > > > > > As you can see, userspace isn't involved with dealing with the > > > > > > > requests. It just acts as a thread donor to the vhost driver. > > > > > > > > > > > > > > We would want the VHOST_RUN_WORKER calls to be infrequent to > > > > > > > avoid the > > > > > > > penalty of switching into the kernel, copying in the arguments, > > > > > > > etc. > > > > > > > > > > > > I didn't get this part. Why have the timeout? When the timeout > > > > > > expires, > > > > > > does userspace just call right back down to the kernel or does it do > > > > > > some sort of processing/operation? > > > > > > > > > > > > You could have your worker function run from that ioctl wait for a > > > > > > signal or a wake up call from the vhost_work/poll functions. > > > > > > > > > > An optional timeout argument is common in blocking interfaces like > > > > > poll(2), recvmmsg(2), etc. > > > > > > > > > > Although something can send a signal to the thread instead, > > > > > implementing that in an application is more awkward than passing a > > > > > struct timespec. > > > > > > > > > > Compared to other blocking calls we don't expect > > > > > ioctl(VHOST_RUN_WORKER) to return soon, so maybe the timeout will > > > > > rarely be used and can be dropped from the interface. > > > > > > > > > > BTW the code I posted wasn't a carefully thought out proposal :). The > > > > > details still need to be considered and I'm going to be offline for > > > > > the next week so maybe someone else can think it through in the > > > > > meantime. > > > > > > > > One final thought before I'm offline for a week. If > > > > ioctl(VHOST_RUN_WORKER) is specific to a single vhost device instance > > > > then it's hard to support poll-mode (busy waiting) workers because > > > > each device instance consumes a whole CPU. If we stick to an interface > > > > where the kernel manages the worker threads then it's easier to share > > > > workers between devices for polling. > > > > > > > > > Yes that is the reason vhost did its own reason in the first place. > > > > > > > > > I am vaguely thinking about poll(2) or a similar interface, > > > which can wait for an event on multiple FDs. > > > > I can imagine how using poll(2) would work from a userspace perspective, > > but on the kernel side I don't think it can be implemented cleanly. > > poll(2) is tied to the file_operations->poll() callback and > > read/write/error events. Not to mention there isn't a way to substitue > > the vhost worker thread function instead of scheduling out the current > > thread while waiting for poll fd events. > > > > But maybe ioctl(VHOST_WORKER_RUN) can do it: > > > > struct vhost_run_worker_dev { > > int vhostfd; /* /dev/vhost-TYPE fd */ > > unsigned nvqs;/* number of virtqueues in vqs[] */ > > unsigned vqs[]; /* virtqueues to process */ > > }; > > > > struct vhost_run_worker_info { > > struct timespec *timeout; > > sigset_t *sigmask; > > > > unsigned ndevices; > > struct vhost_run_worker_dev *devices[]; > > }; > > > > In the simple case userspace sets ndevices to 1 and we just handle > > virtqueues for the current device. > > > > In the fancier shared worker thread case the userspace process has the > > vhost fds of all the devices it is processing and passes them to > > ioctl(VHOST_WORKER_RUN) via struct vhost_run_worker_dev elements. > > Which fd will be used for this IOCTL? One of the 'vhostfd' or we should > create a new /dev/vhost-workers (or something similar)? > > Maybe the new device will be cleaner and can be reused also for other stuff > (I'm thinking about vDPA software devices). > > > > > From a security perspective it means the userspace thread
RE: [External] Re: [PATCH 0/7] Introduce vdpa management tool
> From: Yongji Xie > Sent: Tuesday, December 1, 2020 7:49 PM > > On Tue, Dec 1, 2020 at 7:32 PM Parav Pandit wrote: > > > > > > > > > From: Yongji Xie > > > Sent: Tuesday, December 1, 2020 3:26 PM > > > > > > On Tue, Dec 1, 2020 at 2:25 PM Jason Wang > wrote: > > > > > > > > > > > > On 2020/11/30 下午3:07, Yongji Xie wrote: > > > > >>> Thanks for adding me, Jason! > > > > >>> > > > > >>> Now I'm working on a v2 patchset for VDUSE (vDPA Device in > > > > >>> Userspace) [1]. This tool is very useful for the vduse device. > > > > >>> So I'm considering integrating this into my v2 patchset. But > > > > >>> there is one problem: > > > > >>> > > > > >>> In this tool, vdpa device config action and enable action are > > > > >>> combined into one netlink msg: VDPA_CMD_DEV_NEW. But in > vduse > > > > >>> case, it needs to be splitted because a chardev should be > > > > >>> created and opened by a userspace process before we enable the > > > > >>> vdpa device (call vdpa_register_device()). > > > > >>> > > > > >>> So I'd like to know whether it's possible (or have some plans) > > > > >>> to add two new netlink msgs something like: > > > > >>> VDPA_CMD_DEV_ENABLE > > > and > > > > >>> VDPA_CMD_DEV_DISABLE to make the config path more flexible. > > > > >>> > > > > >> Actually, we've discussed such intermediate step in some early > > > > >> discussion. It looks to me VDUSE could be one of the users of this. > > > > >> > > > > >> Or I wonder whether we can switch to use anonymous inode(fd) > > > > >> for VDUSE then fetching it via an VDUSE_GET_DEVICE_FD ioctl? > > > > >> > > > > > Yes, we can. Actually the current implementation in VDUSE is > > > > > like this. But seems like this is still a intermediate step. > > > > > The fd should be binded to a name or something else which need > > > > > to be configured before. > > > > > > > > > > > > The name could be specified via the netlink. It looks to me the > > > > real issue is that until the device is connected with a userspace, > > > > it can't be used. So we also need to fail the enabling if it doesn't > opened. > > > > > > > > > > Yes, that's true. So you mean we can firstly try to fetch the fd > > > binded to a name/vduse_id via an VDUSE_GET_DEVICE_FD, then use the > > > name/vduse_id as a attribute to create vdpa device? It looks fine to me. > > > > I probably do not well understand. I tried reading patch [1] and few things > do not look correct as below. > > Creating the vdpa device on the bus device and destroying the device from > the workqueue seems unnecessary and racy. > > > > It seems vduse driver needs > > This is something should be done as part of the vdpa dev add command, > instead of connecting two sides separately and ensuring race free access to > it. > > > > So VDUSE_DEV_START and VDUSE_DEV_STOP should possibly be avoided. > > > > Yes, we can avoid these two ioctls with the help of the management tool. > > > $ vdpa dev add parentdev vduse_mgmtdev type net name foo2 > > > > When above command is executed it creates necessary vdpa device foo2 > on the bus. > > When user binds foo2 device with the vduse driver, in the probe(), it > creates respective char device to access it from user space. > I see. So vduse cannot work with any existing vdpa devices like ifc, mlx5 or netdevsim. It has its own implementation similar to fuse with its own backend of choice. More below. > But vduse driver is not a vdpa bus driver. It works like vdpasim driver, but > offloads the data plane and control plane to a user space process. In that case to draw parallel lines, 1. netdevsim: (a) create resources in kernel sw (b) datapath simulates in kernel 2. ifc + mlx5 vdpa dev: (a) creates resource in hw (b) data path is in hw 3. vduse: (a) creates resources in userspace sw (b) data path is in user space. hence creates data path resources for user space. So char device is created, removed as result of vdpa device creation. For example, $ vdpa dev add parentdev vduse_mgmtdev type net name foo2 Above command will create char device for user space. Similar command for ifc/mlx5 would have created similar channel for rest of the config commands in hw. vduse channel = char device, eventfd etc. ifc/mlx5 hw channel = bar, irq, command interface etc Netdev sim channel = sw direct calls Does it make sense? ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 000/141] Fix fall-through warnings for Clang
On Sun, Nov 22, 2020 at 08:17:03AM -0800, Kees Cook wrote: > On Fri, Nov 20, 2020 at 11:51:42AM -0800, Jakub Kicinski wrote: > > On Fri, 20 Nov 2020 11:30:40 -0800 Kees Cook wrote: > > > On Fri, Nov 20, 2020 at 10:53:44AM -0800, Jakub Kicinski wrote: > > > > On Fri, 20 Nov 2020 12:21:39 -0600 Gustavo A. R. Silva wrote: > > > > > This series aims to fix almost all remaining fall-through warnings in > > > > > order to enable -Wimplicit-fallthrough for Clang. > > > > > > > > > > In preparation to enable -Wimplicit-fallthrough for Clang, explicitly > > > > > add multiple break/goto/return/fallthrough statements instead of just > > > > > letting the code fall through to the next case. > > > > > > > > > > Notice that in order to enable -Wimplicit-fallthrough for Clang, this > > > > > change[1] is meant to be reverted at some point. So, this patch helps > > > > > to move in that direction. > > > > > > > > > > Something important to mention is that there is currently a > > > > > discrepancy > > > > > between GCC and Clang when dealing with switch fall-through to empty > > > > > case > > > > > statements or to cases that only contain a break/continue/return > > > > > statement[2][3][4]. > > > > > > > > Are we sure we want to make this change? Was it discussed before? > > > > > > > > Are there any bugs Clangs puritanical definition of fallthrough helped > > > > find? > > > > > > > > IMVHO compiler warnings are supposed to warn about issues that could > > > > be bugs. Falling through to default: break; can hardly be a bug?! > > > > > > It's certainly a place where the intent is not always clear. I think > > > this makes all the cases unambiguous, and doesn't impact the machine > > > code, since the compiler will happily optimize away any behavioral > > > redundancy. > > > > If none of the 140 patches here fix a real bug, and there is no change > > to machine code then it sounds to me like a W=2 kind of a warning. > > FWIW, this series has found at least one bug so far: > https://lore.kernel.org/lkml/CAFCwf11izHF=g1mGry1fE5kvFFFrxzhPSM6qKAO8gxSp=kr...@mail.gmail.com/ This is a fallthrough to a return and not to a break. That should trigger a warning. The fallthrough to a break should not generate a warning. The bug we're trying to fix is "missing break statement" but if the result of the bug is "we hit a break statement" then now we're just talking about style. GCC should limit itself to warning about potentially buggy code. regards, dan carpenter ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 000/141] Fix fall-through warnings for Clang
On Mon, Nov 23, 2020 at 05:32:51PM -0800, Nick Desaulniers wrote: > On Sun, Nov 22, 2020 at 8:17 AM Kees Cook wrote: > > > > On Fri, Nov 20, 2020 at 11:51:42AM -0800, Jakub Kicinski wrote: > > > If none of the 140 patches here fix a real bug, and there is no change > > > to machine code then it sounds to me like a W=2 kind of a warning. > > > > FWIW, this series has found at least one bug so far: > > https://lore.kernel.org/lkml/CAFCwf11izHF=g1mGry1fE5kvFFFrxzhPSM6qKAO8gxSp=kr...@mail.gmail.com/ > > So looks like the bulk of these are: > switch (x) { > case 0: > ++x; > default: > break; > } This should not generate a warning. > > I have a patch that fixes those up for clang: > https://reviews.llvm.org/D91895 > > There's 3 other cases that don't quite match between GCC and Clang I > observe in the kernel: > switch (x) { > case 0: > ++x; > default: > goto y; > } > y:; This should generate a warning. > > switch (x) { > case 0: > ++x; > default: > return; > } Warn for this. > > switch (x) { > case 0: > ++x; > default: > ; > } Don't warn for this. If adding a break statement changes the flow of the code then warn about potentially missing break statements, but if it doesn't change anything then don't warn about it. regards, dan carpenter ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 00/10] vhost/qemu: thread per IO SCSI vq
On Tue, Dec 01, 2020 at 12:59:43PM +, Stefan Hajnoczi wrote: On Fri, Nov 20, 2020 at 07:31:08AM -0500, Michael S. Tsirkin wrote: On Fri, Nov 20, 2020 at 08:45:49AM +, Stefan Hajnoczi wrote: > On Thu, Nov 19, 2020 at 5:08 PM Stefan Hajnoczi wrote: > > > > On Thu, Nov 19, 2020 at 4:43 PM Mike Christie > > wrote: > > > > > > On 11/19/20 10:24 AM, Stefan Hajnoczi wrote: > > > > On Thu, Nov 19, 2020 at 4:13 PM Mike Christie > > > > wrote: > > > >> > > > >> On 11/19/20 8:46 AM, Michael S. Tsirkin wrote: > > > >>> On Wed, Nov 18, 2020 at 11:31:17AM +, Stefan Hajnoczi wrote: > > > > struct vhost_run_worker_info { > > > > struct timespec *timeout; > > > > sigset_t *sigmask; > > > > > > > > /* List of virtqueues to process */ > > > > unsigned nvqs; > > > > unsigned vqs[]; > > > > }; > > > > > > > > /* This blocks until the timeout is reached, a signal is received, or > > > > the vhost device is destroyed */ > > > > int ret = ioctl(vhost_fd, VHOST_RUN_WORKER, ); > > > > > > > > As you can see, userspace isn't involved with dealing with the > > > > requests. It just acts as a thread donor to the vhost driver. > > > > > > > > We would want the VHOST_RUN_WORKER calls to be infrequent to avoid the > > > > penalty of switching into the kernel, copying in the arguments, etc. > > > > > > I didn't get this part. Why have the timeout? When the timeout expires, > > > does userspace just call right back down to the kernel or does it do > > > some sort of processing/operation? > > > > > > You could have your worker function run from that ioctl wait for a > > > signal or a wake up call from the vhost_work/poll functions. > > > > An optional timeout argument is common in blocking interfaces like > > poll(2), recvmmsg(2), etc. > > > > Although something can send a signal to the thread instead, > > implementing that in an application is more awkward than passing a > > struct timespec. > > > > Compared to other blocking calls we don't expect > > ioctl(VHOST_RUN_WORKER) to return soon, so maybe the timeout will > > rarely be used and can be dropped from the interface. > > > > BTW the code I posted wasn't a carefully thought out proposal :). The > > details still need to be considered and I'm going to be offline for > > the next week so maybe someone else can think it through in the > > meantime. > > One final thought before I'm offline for a week. If > ioctl(VHOST_RUN_WORKER) is specific to a single vhost device instance > then it's hard to support poll-mode (busy waiting) workers because > each device instance consumes a whole CPU. If we stick to an interface > where the kernel manages the worker threads then it's easier to share > workers between devices for polling. Yes that is the reason vhost did its own reason in the first place. I am vaguely thinking about poll(2) or a similar interface, which can wait for an event on multiple FDs. I can imagine how using poll(2) would work from a userspace perspective, but on the kernel side I don't think it can be implemented cleanly. poll(2) is tied to the file_operations->poll() callback and read/write/error events. Not to mention there isn't a way to substitue the vhost worker thread function instead of scheduling out the current thread while waiting for poll fd events. But maybe ioctl(VHOST_WORKER_RUN) can do it: struct vhost_run_worker_dev { int vhostfd; /* /dev/vhost-TYPE fd */ unsigned nvqs;/* number of virtqueues in vqs[] */ unsigned vqs[]; /* virtqueues to process */ }; struct vhost_run_worker_info { struct timespec *timeout; sigset_t *sigmask; unsigned ndevices; struct vhost_run_worker_dev *devices[]; }; In the simple case userspace sets ndevices to 1 and we just handle virtqueues for the current device. In the fancier shared worker thread case the userspace process has the vhost fds of all the devices it is processing and passes them to ioctl(VHOST_WORKER_RUN) via struct vhost_run_worker_dev elements. Which fd will be used for this IOCTL? One of the 'vhostfd' or we should create a new /dev/vhost-workers (or something similar)? Maybe the new device will be cleaner and can be reused also for other stuff (I'm thinking about vDPA software devices). From a security perspective it means the userspace thread has access to all vhost devices (because it has their fds). I'm not sure how the mm is supposed to work. The devices might be associated with different userspace processes (guests) and therefore have different virtual memory. Maybe in this case we should do something similar to io_uring SQPOLL kthread where kthread_use_mm()/kthread_unuse_mm() is used to switch virtual memory spaces. After writing, I saw that we already do it this in the vhost_worker() in drivers/vhost/vhost.c Just wanted to push this discussion along a little further. I'm buried under emails and probably wont be very active over the next few days. I think ioctl(VHOST_WORKER_RUN) might
Re: [PATCH 00/10] vhost/qemu: thread per IO SCSI vq
On Fri, Nov 20, 2020 at 07:31:08AM -0500, Michael S. Tsirkin wrote: > On Fri, Nov 20, 2020 at 08:45:49AM +, Stefan Hajnoczi wrote: > > On Thu, Nov 19, 2020 at 5:08 PM Stefan Hajnoczi wrote: > > > > > > On Thu, Nov 19, 2020 at 4:43 PM Mike Christie > > > wrote: > > > > > > > > On 11/19/20 10:24 AM, Stefan Hajnoczi wrote: > > > > > On Thu, Nov 19, 2020 at 4:13 PM Mike Christie > > > > > wrote: > > > > >> > > > > >> On 11/19/20 8:46 AM, Michael S. Tsirkin wrote: > > > > >>> On Wed, Nov 18, 2020 at 11:31:17AM +, Stefan Hajnoczi wrote: > > > > > struct vhost_run_worker_info { > > > > > struct timespec *timeout; > > > > > sigset_t *sigmask; > > > > > > > > > > /* List of virtqueues to process */ > > > > > unsigned nvqs; > > > > > unsigned vqs[]; > > > > > }; > > > > > > > > > > /* This blocks until the timeout is reached, a signal is received, or > > > > > the vhost device is destroyed */ > > > > > int ret = ioctl(vhost_fd, VHOST_RUN_WORKER, ); > > > > > > > > > > As you can see, userspace isn't involved with dealing with the > > > > > requests. It just acts as a thread donor to the vhost driver. > > > > > > > > > > We would want the VHOST_RUN_WORKER calls to be infrequent to avoid the > > > > > penalty of switching into the kernel, copying in the arguments, etc. > > > > > > > > I didn't get this part. Why have the timeout? When the timeout expires, > > > > does userspace just call right back down to the kernel or does it do > > > > some sort of processing/operation? > > > > > > > > You could have your worker function run from that ioctl wait for a > > > > signal or a wake up call from the vhost_work/poll functions. > > > > > > An optional timeout argument is common in blocking interfaces like > > > poll(2), recvmmsg(2), etc. > > > > > > Although something can send a signal to the thread instead, > > > implementing that in an application is more awkward than passing a > > > struct timespec. > > > > > > Compared to other blocking calls we don't expect > > > ioctl(VHOST_RUN_WORKER) to return soon, so maybe the timeout will > > > rarely be used and can be dropped from the interface. > > > > > > BTW the code I posted wasn't a carefully thought out proposal :). The > > > details still need to be considered and I'm going to be offline for > > > the next week so maybe someone else can think it through in the > > > meantime. > > > > One final thought before I'm offline for a week. If > > ioctl(VHOST_RUN_WORKER) is specific to a single vhost device instance > > then it's hard to support poll-mode (busy waiting) workers because > > each device instance consumes a whole CPU. If we stick to an interface > > where the kernel manages the worker threads then it's easier to share > > workers between devices for polling. > > > Yes that is the reason vhost did its own reason in the first place. > > > I am vaguely thinking about poll(2) or a similar interface, > which can wait for an event on multiple FDs. I can imagine how using poll(2) would work from a userspace perspective, but on the kernel side I don't think it can be implemented cleanly. poll(2) is tied to the file_operations->poll() callback and read/write/error events. Not to mention there isn't a way to substitue the vhost worker thread function instead of scheduling out the current thread while waiting for poll fd events. But maybe ioctl(VHOST_WORKER_RUN) can do it: struct vhost_run_worker_dev { int vhostfd; /* /dev/vhost-TYPE fd */ unsigned nvqs;/* number of virtqueues in vqs[] */ unsigned vqs[]; /* virtqueues to process */ }; struct vhost_run_worker_info { struct timespec *timeout; sigset_t *sigmask; unsigned ndevices; struct vhost_run_worker_dev *devices[]; }; In the simple case userspace sets ndevices to 1 and we just handle virtqueues for the current device. In the fancier shared worker thread case the userspace process has the vhost fds of all the devices it is processing and passes them to ioctl(VHOST_WORKER_RUN) via struct vhost_run_worker_dev elements. >From a security perspective it means the userspace thread has access to all vhost devices (because it has their fds). I'm not sure how the mm is supposed to work. The devices might be associated with different userspace processes (guests) and therefore have different virtual memory. Just wanted to push this discussion along a little further. I'm buried under emails and probably wont be very active over the next few days. Stefan signature.asc Description: PGP signature ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
RE: [External] Re: [PATCH 0/7] Introduce vdpa management tool
> From: Yongji Xie > Sent: Tuesday, December 1, 2020 3:26 PM > > On Tue, Dec 1, 2020 at 2:25 PM Jason Wang wrote: > > > > > > On 2020/11/30 下午3:07, Yongji Xie wrote: > > >>> Thanks for adding me, Jason! > > >>> > > >>> Now I'm working on a v2 patchset for VDUSE (vDPA Device in > > >>> Userspace) [1]. This tool is very useful for the vduse device. So > > >>> I'm considering integrating this into my v2 patchset. But there is > > >>> one problem: > > >>> > > >>> In this tool, vdpa device config action and enable action are > > >>> combined into one netlink msg: VDPA_CMD_DEV_NEW. But in vduse > > >>> case, it needs to be splitted because a chardev should be created > > >>> and opened by a userspace process before we enable the vdpa device > > >>> (call vdpa_register_device()). > > >>> > > >>> So I'd like to know whether it's possible (or have some plans) to > > >>> add two new netlink msgs something like: VDPA_CMD_DEV_ENABLE > and > > >>> VDPA_CMD_DEV_DISABLE to make the config path more flexible. > > >>> > > >> Actually, we've discussed such intermediate step in some early > > >> discussion. It looks to me VDUSE could be one of the users of this. > > >> > > >> Or I wonder whether we can switch to use anonymous inode(fd) for > > >> VDUSE then fetching it via an VDUSE_GET_DEVICE_FD ioctl? > > >> > > > Yes, we can. Actually the current implementation in VDUSE is like > > > this. But seems like this is still a intermediate step. The fd > > > should be binded to a name or something else which need to be > > > configured before. > > > > > > The name could be specified via the netlink. It looks to me the real > > issue is that until the device is connected with a userspace, it can't > > be used. So we also need to fail the enabling if it doesn't opened. > > > > Yes, that's true. So you mean we can firstly try to fetch the fd binded to a > name/vduse_id via an VDUSE_GET_DEVICE_FD, then use the > name/vduse_id as a attribute to create vdpa device? It looks fine to me. I probably do not well understand. I tried reading patch [1] and few things do not look correct as below. Creating the vdpa device on the bus device and destroying the device from the workqueue seems unnecessary and racy. It seems vduse driver needs This is something should be done as part of the vdpa dev add command, instead of connecting two sides separately and ensuring race free access to it. So VDUSE_DEV_START and VDUSE_DEV_STOP should possibly be avoided. $ vdpa dev add parentdev vduse_mgmtdev type net name foo2 When above command is executed it creates necessary vdpa device foo2 on the bus. When user binds foo2 device with the vduse driver, in the probe(), it creates respective char device to access it from user space. Depending on which driver foo2 device is bound it, it can be used, either via (a) existing vhost stack or (b) some vdpa Netdev driver? (not sure its current state), or (c) vduse user space. This will have sane model to me without races unless I am missing something fundamental here. This way there are not two ways to create vdpa devices from user space. Consumers can be of different types (vhost, vduse etc) of the bus device as above mentioned. [1] https://www.spinics.net/lists/linux-mm/msg231581.html ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH] vdpa/mlx5: Use random MAC for the vdpa net instance
On Tue, Dec 01, 2020 at 05:23:18PM +0800, Cindy Lu wrote: > On Mon, Nov 30, 2020 at 11:33 PM Michael S. Tsirkin wrote: > > > > On Mon, Nov 30, 2020 at 06:41:45PM +0800, Cindy Lu wrote: > > > On Mon, Nov 30, 2020 at 5:33 PM Michael S. Tsirkin > > > wrote: > > > > > > > > On Mon, Nov 30, 2020 at 11:27:59AM +0200, Eli Cohen wrote: > > > > > On Mon, Nov 30, 2020 at 04:00:51AM -0500, Michael S. Tsirkin wrote: > > > > > > On Mon, Nov 30, 2020 at 08:27:46AM +0200, Eli Cohen wrote: > > > > > > > On Sun, Nov 29, 2020 at 03:08:22PM -0500, Michael S. Tsirkin > > > > > > > wrote: > > > > > > > > On Sun, Nov 29, 2020 at 08:43:51AM +0200, Eli Cohen wrote: > > > > > > > > > We should not try to use the VF MAC address as that is used > > > > > > > > > by the > > > > > > > > > regular (e.g. mlx5_core) NIC implementation. Instead, use a > > > > > > > > > random > > > > > > > > > generated MAC address. > > > > > > > > > > > > > > > > > > Suggested by: Cindy Lu > > > > > > > > > Fixes: 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for > > > > > > > > > supported mlx5 devices") > > > > > > > > > Signed-off-by: Eli Cohen > > > > > > > > > > > > > > > > I didn't realise it's possible to use VF in two ways > > > > > > > > with and without vdpa. > > > > > > > > > > > > > > Using a VF you can create quite a few resources, e.g. send queues > > > > > > > recieve queues, virtio_net queues etc. So you can possibly create > > > > > > > several instances of vdpa net devices and nic net devices. > > > > > > > > > > > > > > > Could you include a bit more description on the failure > > > > > > > > mode? > > > > > > > > > > > > > > Well, using the MAC address of the nic vport is wrong since that > > > > > > > is the > > > > > > > MAC of the regular NIC implementation of mlx5_core. > > > > > > > > > > > > Right but ATM it doesn't coexist with vdpa so what's the problem? > > > > > > > > > > > > > > > > This call is wrong: mlx5_query_nic_vport_mac_address() > > > > > > > > > > > > > Is switching to a random mac for such an unusual > > > > > > > > configuration really justified? > > > > > > > > > > > > > > Since I can't use the NIC's MAC address, I have two options: > > > > > > > 1. To get the MAC address as was chosen by the user administering > > > > > > > the > > > > > > >NIC. This should invoke the set_config callback. Unfortunately > > > > > > > this > > > > > > >is not implemented yet. > > > > > > > > > > > > > > 2. Use a random MAC address. This is OK since if (1) is > > > > > > > implemented it > > > > > > >can always override this random configuration. > > > > > > > > > > > > > > > It looks like changing a MAC could break some guests, > > > > > > > > can it not? > > > > > > > > > > > > > > > > > > > > > > No, it will not. The current version of mlx5 VDPA does not allow > > > > > > > regular > > > > > > > NIC driver and VDPA to co-exist. I have patches ready that enable > > > > > > > that > > > > > > > from steering point of view. I will post them here once other > > > > > > > patches on > > > > > > > which they depend will be merged. > > > > > > > > > > > > > > https://patchwork.ozlabs.org/project/netdev/patch/20201120230339.651609-12-sae...@nvidia.com/ > > > > > > > > > > > > Could you be more explicit on the following points: > > > > > > - which configuration is broken ATM (as in, two device have > > > > > > identical > > > > > > macs? any other issues)? > > > > > > > > > > The only wrong thing is the call to > > > > > mlx5_query_nic_vport_mac_address(). > > > > > It's not breaking anything yet is wrong. The random MAC address > > > > > setting > > > > > is required for the steering patches. > > > > > > > > Okay so I'm not sure the Fixes tag at least is appropriate if it's a > > > > dependency of a new feature. > > > > > > > > > > - why won't device MAC change from guest point of view? > > > > > > > > > > > > > > > > It's lack of implementation in qemu as far as I know. > > > > > > > > Sorry not sure I understand. What's not implemented in QEMU? > > > > > > > HI Michael, there are some bug in qemu to set_config, this will fix in > > > future, > > > But this patch is still needed, because without this patch the mlx > > > driver will give an 0 mac address to qemu > > > and qemu will overwrite the default mac address. This will cause traffic > > > down. > > > > Hmm the patch description says VF mac address, not 0 address. Confused. > > If there's no mac we can clear VIRTIO_NET_F_MAC and have guest > > use a random value ... > > > hi Michael, > I have tried as your suggestion, seems even remove the > VIRTIO_NET_F_MAC the qemu will still call get_cinfig and overwrite the > default address in VM, > this process is like > vdpa _init -->qemu call get_config ->mlx driver will give an mac > address with all 0--> > qemu will not check this mac address and use it --> overwrite the mac > address in qemu Right but guest will ignore it then, right? > So for my understanding there are several method to fix this
Re: [PATCH v2 12/17] vdpa_sim: add get_config callback in vdpasim_dev_attr
On Tue, Dec 01, 2020 at 11:44:19AM +0800, Jason Wang wrote: On 2020/11/30 下午10:14, Stefano Garzarella wrote: On Mon, Nov 30, 2020 at 11:25:31AM +0800, Jason Wang wrote: On 2020/11/26 下午10:49, Stefano Garzarella wrote: The get_config callback can be used by the device to fill the config structure. The callback will be invoked in vdpasim_get_config() before copying bytes into caller buffer. Move vDPA-net config updates from vdpasim_set_features() in the new vdpasim_net_get_config() callback. Signed-off-by: Stefano Garzarella --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 33 +++- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index c07ddf6af720..8b87ce0485b6 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -58,6 +58,8 @@ struct vdpasim_virtqueue { #define VDPASIM_NET_FEATURES (VDPASIM_FEATURES | \ (1ULL << VIRTIO_NET_F_MAC)) +struct vdpasim; + struct vdpasim_dev_attr { u64 supported_features; size_t config_size; @@ -65,6 +67,7 @@ struct vdpasim_dev_attr { u32 id; work_func_t work_fn; + void (*get_config)(struct vdpasim *vdpasim, void *config); }; /* State of each vdpasim device */ @@ -520,8 +523,6 @@ static u64 vdpasim_get_features(struct vdpa_device *vdpa) static int vdpasim_set_features(struct vdpa_device *vdpa, u64 features) { struct vdpasim *vdpasim = vdpa_to_sim(vdpa); - struct virtio_net_config *config = - (struct virtio_net_config *)vdpasim->config; /* DMA mapping must be done by driver */ if (!(features & (1ULL << VIRTIO_F_ACCESS_PLATFORM))) @@ -529,15 +530,6 @@ static int vdpasim_set_features(struct vdpa_device *vdpa, u64 features) vdpasim->features = features & vdpasim->dev_attr.supported_features; - /* We generally only know whether guest is using the legacy interface - * here, so generally that's the earliest we can set config fields. - * Note: We actually require VIRTIO_F_ACCESS_PLATFORM above which - * implies VIRTIO_F_VERSION_1, but let's not try to be clever here. - */ - - config->mtu = cpu_to_vdpasim16(vdpasim, 1500); - config->status = cpu_to_vdpasim16(vdpasim, VIRTIO_NET_S_LINK_UP); - memcpy(config->mac, macaddr_buf, ETH_ALEN); return 0; } @@ -593,8 +585,12 @@ static void vdpasim_get_config(struct vdpa_device *vdpa, unsigned int offset, { struct vdpasim *vdpasim = vdpa_to_sim(vdpa); - if (offset + len < vdpasim->dev_attr.config_size) - memcpy(buf, vdpasim->config + offset, len); + if (offset + len > vdpasim->dev_attr.config_size) + return; + + vdpasim->dev_attr.get_config(vdpasim, vdpasim->config); + + memcpy(buf, vdpasim->config + offset, len); } I wonder how much value we can get from vdpasim->config consider we've already had get_config() method. Is it possible to copy to the buffer directly here? I had thought of eliminating it too, but then I wanted to do something similar to what we do in QEMU (hw/virtio/virtio.c), leaving in the simulator core the buffer, the memory copy (handling offset and len), and the boundary checks. In this way each device should simply fill the entire configuration and we can avoid code duplication. Storing the configuration in the core may also be useful if some device needs to support config writes. I think in that way we need should provide config_write(). Yes, I'll add set_config() callback. Do you think it makes sense, or is it better to move everything in the device? I prefer to do that in the device but it's also fine keep what the patch has done. Okay, for now I'll keep it and add the set_config() callback, but I'm open to move it in the device. Thanks, Stefano ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH v2 01/20] drm/amdgpu: Fix trailing whitespaces
Reviewed-by: Christian König on patch #1 and #15. Acked-by: Christian König on patch #2 and #16. Regards, Christian. Am 01.12.20 um 11:35 schrieb Thomas Zimmermann: Adhere to kernel coding style. Signed-off-by: Thomas Zimmermann Acked-by: Alex Deucher Acked-by: Sam Ravnborg Cc: Alex Deucher Cc: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 5f304425c948..da23c0f21311 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -4922,8 +4922,8 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta case pci_channel_io_normal: return PCI_ERS_RESULT_CAN_RECOVER; /* Fatal error, prepare for slot reset */ - case pci_channel_io_frozen: - /* + case pci_channel_io_frozen: + /* * Cancel and wait for all TDRs in progress if failing to * set adev->in_gpu_reset in amdgpu_device_lock_adev * @@ -5014,7 +5014,7 @@ pci_ers_result_t amdgpu_pci_slot_reset(struct pci_dev *pdev) goto out; } - adev->in_pci_err_recovery = true; + adev->in_pci_err_recovery = true; r = amdgpu_device_pre_asic_reset(adev, NULL, _full_reset); adev->in_pci_err_recovery = false; if (r) ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[PATCH v2 07/20] drm/gma500: Remove references to struct drm_device.pdev
Using struct drm_device.pdev is deprecated. Convert gma500 to struct drm_device.dev. No functional changes. Signed-off-by: Thomas Zimmermann Acked-by: Sam Ravnborg Cc: Patrik Jakobsson --- drivers/gpu/drm/gma500/cdv_device.c| 22 - drivers/gpu/drm/gma500/cdv_intel_crt.c | 3 +- drivers/gpu/drm/gma500/cdv_intel_lvds.c| 4 +-- drivers/gpu/drm/gma500/framebuffer.c | 9 +++--- drivers/gpu/drm/gma500/gma_device.c| 3 +- drivers/gpu/drm/gma500/gma_display.c | 4 +-- drivers/gpu/drm/gma500/gtt.c | 20 ++-- drivers/gpu/drm/gma500/intel_bios.c| 2 +- drivers/gpu/drm/gma500/intel_gmbus.c | 4 +-- drivers/gpu/drm/gma500/intel_i2c.c | 2 +- drivers/gpu/drm/gma500/mdfld_device.c | 4 ++- drivers/gpu/drm/gma500/mdfld_dsi_dpi.c | 8 ++--- drivers/gpu/drm/gma500/mid_bios.c | 9 -- drivers/gpu/drm/gma500/oaktrail_device.c | 3 +- drivers/gpu/drm/gma500/oaktrail_lvds.c | 2 +- drivers/gpu/drm/gma500/oaktrail_lvds_i2c.c | 2 +- drivers/gpu/drm/gma500/opregion.c | 3 +- drivers/gpu/drm/gma500/power.c | 13 drivers/gpu/drm/gma500/psb_drv.c | 16 +- drivers/gpu/drm/gma500/psb_drv.h | 8 ++--- drivers/gpu/drm/gma500/psb_intel_lvds.c| 4 +-- drivers/gpu/drm/gma500/psb_intel_sdvo.c| 2 +- drivers/gpu/drm/gma500/tc35876x-dsi-lvds.c | 36 +++--- 23 files changed, 101 insertions(+), 82 deletions(-) diff --git a/drivers/gpu/drm/gma500/cdv_device.c b/drivers/gpu/drm/gma500/cdv_device.c index e0b728f246fb..19e055dbd4c2 100644 --- a/drivers/gpu/drm/gma500/cdv_device.c +++ b/drivers/gpu/drm/gma500/cdv_device.c @@ -95,13 +95,14 @@ static u32 cdv_get_max_backlight(struct drm_device *dev) static int cdv_get_brightness(struct backlight_device *bd) { struct drm_device *dev = bl_get_data(bd); + struct pci_dev *pdev = to_pci_dev(dev->dev); u32 val = REG_READ(BLC_PWM_CTL) & BACKLIGHT_DUTY_CYCLE_MASK; if (cdv_backlight_combination_mode(dev)) { u8 lbpc; val &= ~1; - pci_read_config_byte(dev->pdev, 0xF4, ); + pci_read_config_byte(pdev, 0xF4, ); val *= lbpc; } return (val * 100)/cdv_get_max_backlight(dev); @@ -111,6 +112,7 @@ static int cdv_get_brightness(struct backlight_device *bd) static int cdv_set_brightness(struct backlight_device *bd) { struct drm_device *dev = bl_get_data(bd); + struct pci_dev *pdev = to_pci_dev(dev->dev); int level = bd->props.brightness; u32 blc_pwm_ctl; @@ -128,7 +130,7 @@ static int cdv_set_brightness(struct backlight_device *bd) lbpc = level * 0xfe / max + 1; level /= lbpc; - pci_write_config_byte(dev->pdev, 0xF4, lbpc); + pci_write_config_byte(pdev, 0xF4, lbpc); } blc_pwm_ctl = REG_READ(BLC_PWM_CTL) & ~BACKLIGHT_DUTY_CYCLE_MASK; @@ -205,8 +207,9 @@ static inline void CDV_MSG_WRITE32(int domain, uint port, uint offset, static void cdv_init_pm(struct drm_device *dev) { struct drm_psb_private *dev_priv = dev->dev_private; + struct pci_dev *pdev = to_pci_dev(dev->dev); u32 pwr_cnt; - int domain = pci_domain_nr(dev->pdev->bus); + int domain = pci_domain_nr(pdev->bus); int i; dev_priv->apm_base = CDV_MSG_READ32(domain, PSB_PUNIT_PORT, @@ -234,6 +237,8 @@ static void cdv_init_pm(struct drm_device *dev) static void cdv_errata(struct drm_device *dev) { + struct pci_dev *pdev = to_pci_dev(dev->dev); + /* Disable bonus launch. * CPU and GPU competes for memory and display misses updates and * flickers. Worst with dual core, dual displays. @@ -242,7 +247,7 @@ static void cdv_errata(struct drm_device *dev) * Bonus Launch to work around the issue, by degrading * performance. */ -CDV_MSG_WRITE32(pci_domain_nr(dev->pdev->bus), 3, 0x30, 0x08027108); +CDV_MSG_WRITE32(pci_domain_nr(pdev->bus), 3, 0x30, 0x08027108); } /** @@ -255,12 +260,13 @@ static void cdv_errata(struct drm_device *dev) static int cdv_save_display_registers(struct drm_device *dev) { struct drm_psb_private *dev_priv = dev->dev_private; + struct pci_dev *pdev = to_pci_dev(dev->dev); struct psb_save_area *regs = _priv->regs; struct drm_connector *connector; dev_dbg(dev->dev, "Saving GPU registers.\n"); - pci_read_config_byte(dev->pdev, 0xF4, >cdv.saveLBB); + pci_read_config_byte(pdev, 0xF4, >cdv.saveLBB); regs->cdv.saveDSPCLK_GATE_D = REG_READ(DSPCLK_GATE_D); regs->cdv.saveRAMCLK_GATE_D = REG_READ(RAMCLK_GATE_D); @@ -309,11 +315,12 @@ static int cdv_save_display_registers(struct drm_device *dev) static int cdv_restore_display_registers(struct drm_device *dev) { struct
[PATCH v2 16/20] drm/radeon: Remove references to struct drm_device.pdev
Using struct drm_device.pdev is deprecated. Convert radeon to struct drm_device.dev. No functional changes. Signed-off-by: Thomas Zimmermann Acked-by: Alex Deucher Cc: Alex Deucher Cc: Christian König --- drivers/gpu/drm/radeon/atombios_encoders.c| 6 +- drivers/gpu/drm/radeon/r100.c | 25 +++--- drivers/gpu/drm/radeon/radeon.h | 32 +++ drivers/gpu/drm/radeon/radeon_atombios.c | 89 ++- drivers/gpu/drm/radeon/radeon_bios.c | 6 +- drivers/gpu/drm/radeon/radeon_combios.c | 55 ++-- drivers/gpu/drm/radeon/radeon_cs.c| 3 +- drivers/gpu/drm/radeon/radeon_device.c| 17 ++-- drivers/gpu/drm/radeon/radeon_display.c | 2 +- drivers/gpu/drm/radeon/radeon_drv.c | 3 +- drivers/gpu/drm/radeon/radeon_fb.c| 2 +- drivers/gpu/drm/radeon/radeon_gem.c | 6 +- drivers/gpu/drm/radeon/radeon_i2c.c | 2 +- drivers/gpu/drm/radeon/radeon_irq_kms.c | 2 +- drivers/gpu/drm/radeon/radeon_kms.c | 18 ++-- .../gpu/drm/radeon/radeon_legacy_encoders.c | 6 +- drivers/gpu/drm/radeon/rs780_dpm.c| 7 +- 17 files changed, 142 insertions(+), 139 deletions(-) diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c index cc5ee1b3af84..a9ae8b6c5991 100644 --- a/drivers/gpu/drm/radeon/atombios_encoders.c +++ b/drivers/gpu/drm/radeon/atombios_encoders.c @@ -2065,9 +2065,9 @@ atombios_apply_encoder_quirks(struct drm_encoder *encoder, struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc); /* Funky macbooks */ - if ((dev->pdev->device == 0x71C5) && - (dev->pdev->subsystem_vendor == 0x106b) && - (dev->pdev->subsystem_device == 0x0080)) { + if ((rdev->pdev->device == 0x71C5) && + (rdev->pdev->subsystem_vendor == 0x106b) && + (rdev->pdev->subsystem_device == 0x0080)) { if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) { uint32_t lvtma_bit_depth_control = RREG32(AVIVO_LVTMA_BIT_DEPTH_CONTROL); diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c index e4ae09b5294d..984eeb893d76 100644 --- a/drivers/gpu/drm/radeon/r100.c +++ b/drivers/gpu/drm/radeon/r100.c @@ -2611,7 +2611,6 @@ int r100_asic_reset(struct radeon_device *rdev, bool hard) void r100_set_common_regs(struct radeon_device *rdev) { - struct drm_device *dev = rdev->ddev; bool force_dac2 = false; u32 tmp; @@ -2629,7 +2628,7 @@ void r100_set_common_regs(struct radeon_device *rdev) * don't report it in the bios connector * table. */ - switch (dev->pdev->device) { + switch (rdev->pdev->device) { /* RN50 */ case 0x515e: case 0x5969: @@ -2639,17 +2638,17 @@ void r100_set_common_regs(struct radeon_device *rdev) case 0x5159: case 0x515a: /* DELL triple head servers */ - if ((dev->pdev->subsystem_vendor == 0x1028 /* DELL */) && - ((dev->pdev->subsystem_device == 0x016c) || -(dev->pdev->subsystem_device == 0x016d) || -(dev->pdev->subsystem_device == 0x016e) || -(dev->pdev->subsystem_device == 0x016f) || -(dev->pdev->subsystem_device == 0x0170) || -(dev->pdev->subsystem_device == 0x017d) || -(dev->pdev->subsystem_device == 0x017e) || -(dev->pdev->subsystem_device == 0x0183) || -(dev->pdev->subsystem_device == 0x018a) || -(dev->pdev->subsystem_device == 0x019a))) + if ((rdev->pdev->subsystem_vendor == 0x1028 /* DELL */) && + ((rdev->pdev->subsystem_device == 0x016c) || +(rdev->pdev->subsystem_device == 0x016d) || +(rdev->pdev->subsystem_device == 0x016e) || +(rdev->pdev->subsystem_device == 0x016f) || +(rdev->pdev->subsystem_device == 0x0170) || +(rdev->pdev->subsystem_device == 0x017d) || +(rdev->pdev->subsystem_device == 0x017e) || +(rdev->pdev->subsystem_device == 0x0183) || +(rdev->pdev->subsystem_device == 0x018a) || +(rdev->pdev->subsystem_device == 0x019a))) force_dac2 = true; break; } diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 28cb8ced91b9..87ef62a7ec4e 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h @@ -2623,14 +2623,14 @@ void r100_pll_errata_after_index(struct radeon_device *rdev); (rdev->family == CHIP_RV410) || \ (rdev->family == CHIP_RS400) || \
[PATCH v2 13/20] drm/nouveau: Remove references to struct drm_device.pdev
Using struct drm_device.pdev is deprecated. Convert nouveau to struct drm_device.dev. No functional changes. Signed-off-by: Thomas Zimmermann Cc: Ben Skeggs --- drivers/gpu/drm/nouveau/dispnv04/arb.c | 12 +++- drivers/gpu/drm/nouveau/dispnv04/disp.h | 14 -- drivers/gpu/drm/nouveau/dispnv04/hw.c | 10 ++ drivers/gpu/drm/nouveau/nouveau_abi16.c | 7 --- drivers/gpu/drm/nouveau/nouveau_acpi.c | 2 +- drivers/gpu/drm/nouveau/nouveau_bios.c | 11 --- drivers/gpu/drm/nouveau/nouveau_connector.c | 10 ++ drivers/gpu/drm/nouveau/nouveau_drm.c | 5 ++--- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 6 -- drivers/gpu/drm/nouveau/nouveau_vga.c | 20 10 files changed, 58 insertions(+), 39 deletions(-) diff --git a/drivers/gpu/drm/nouveau/dispnv04/arb.c b/drivers/gpu/drm/nouveau/dispnv04/arb.c index 9d4a2d97507e..1d3542d6006b 100644 --- a/drivers/gpu/drm/nouveau/dispnv04/arb.c +++ b/drivers/gpu/drm/nouveau/dispnv04/arb.c @@ -200,16 +200,17 @@ nv04_update_arb(struct drm_device *dev, int VClk, int bpp, int MClk = nouveau_hw_get_clock(dev, PLL_MEMORY); int NVClk = nouveau_hw_get_clock(dev, PLL_CORE); uint32_t cfg1 = nvif_rd32(device, NV04_PFB_CFG1); + struct pci_dev *pdev = to_pci_dev(dev->dev); sim_data.pclk_khz = VClk; sim_data.mclk_khz = MClk; sim_data.nvclk_khz = NVClk; sim_data.bpp = bpp; sim_data.two_heads = nv_two_heads(dev); - if ((dev->pdev->device & 0x) == 0x01a0 /*CHIPSET_NFORCE*/ || - (dev->pdev->device & 0x) == 0x01f0 /*CHIPSET_NFORCE2*/) { + if ((pdev->device & 0x) == 0x01a0 /*CHIPSET_NFORCE*/ || + (pdev->device & 0x) == 0x01f0 /*CHIPSET_NFORCE2*/) { uint32_t type; - int domain = pci_domain_nr(dev->pdev->bus); + int domain = pci_domain_nr(pdev->bus); pci_read_config_dword(pci_get_domain_bus_and_slot(domain, 0, 1), 0x7c, ); @@ -251,11 +252,12 @@ void nouveau_calc_arb(struct drm_device *dev, int vclk, int bpp, int *burst, int *lwm) { struct nouveau_drm *drm = nouveau_drm(dev); + struct pci_dev *pdev = to_pci_dev(dev->dev); if (drm->client.device.info.family < NV_DEVICE_INFO_V0_KELVIN) nv04_update_arb(dev, vclk, bpp, burst, lwm); - else if ((dev->pdev->device & 0xfff0) == 0x0240 /*CHIPSET_C51*/ || -(dev->pdev->device & 0xfff0) == 0x03d0 /*CHIPSET_C512*/) { + else if ((pdev->device & 0xfff0) == 0x0240 /*CHIPSET_C51*/ || +(pdev->device & 0xfff0) == 0x03d0 /*CHIPSET_C512*/) { *burst = 128; *lwm = 0x0480; } else diff --git a/drivers/gpu/drm/nouveau/dispnv04/disp.h b/drivers/gpu/drm/nouveau/dispnv04/disp.h index 5ace5e906949..f0a24126641a 100644 --- a/drivers/gpu/drm/nouveau/dispnv04/disp.h +++ b/drivers/gpu/drm/nouveau/dispnv04/disp.h @@ -130,7 +130,7 @@ static inline bool nv_two_heads(struct drm_device *dev) { struct nouveau_drm *drm = nouveau_drm(dev); - const int impl = dev->pdev->device & 0x0ff0; + const int impl = to_pci_dev(dev->dev)->device & 0x0ff0; if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_CELSIUS && impl != 0x0100 && impl != 0x0150 && impl != 0x01a0 && impl != 0x0200) @@ -142,14 +142,14 @@ nv_two_heads(struct drm_device *dev) static inline bool nv_gf4_disp_arch(struct drm_device *dev) { - return nv_two_heads(dev) && (dev->pdev->device & 0x0ff0) != 0x0110; + return nv_two_heads(dev) && (to_pci_dev(dev->dev)->device & 0x0ff0) != 0x0110; } static inline bool nv_two_reg_pll(struct drm_device *dev) { struct nouveau_drm *drm = nouveau_drm(dev); - const int impl = dev->pdev->device & 0x0ff0; + const int impl = to_pci_dev(dev->dev)->device & 0x0ff0; if (impl == 0x0310 || impl == 0x0340 || drm->client.device.info.family >= NV_DEVICE_INFO_V0_CURIE) return true; @@ -160,9 +160,11 @@ static inline bool nv_match_device(struct drm_device *dev, unsigned device, unsigned sub_vendor, unsigned sub_device) { - return dev->pdev->device == device && - dev->pdev->subsystem_vendor == sub_vendor && - dev->pdev->subsystem_device == sub_device; + struct pci_dev *pdev = to_pci_dev(dev->dev); + + return pdev->device == device && + pdev->subsystem_vendor == sub_vendor && + pdev->subsystem_device == sub_device; } #include diff --git a/drivers/gpu/drm/nouveau/dispnv04/hw.c b/drivers/gpu/drm/nouveau/dispnv04/hw.c index b674d68ef28a..f7d35657aa64 100644 --- a/drivers/gpu/drm/nouveau/dispnv04/hw.c +++ b/drivers/gpu/drm/nouveau/dispnv04/hw.c @@ -214,14 +214,15 @@ nouveau_hw_pllvals_to_clk(struct nvkm_pll_vals *pv) int nouveau_hw_get_clock(struct
[PATCH v2 20/20] drm: Upcast struct drm_device.dev to struct pci_device; replace pdev
We have DRM drivers based on USB, SPI and platform devices. All of them are fine with storing their device reference in struct drm_device.dev. PCI devices should be no exception. Therefore struct drm_device.pdev is deprecated. Instead upcast from struct drm_device.dev with to_pci_dev(). PCI-specific code can use dev_is_pci() to test for a PCI device. This patch changes the DRM core code and documentation accordingly. Struct drm_device.pdev is being moved to legacy status. Signed-off-by: Thomas Zimmermann Acked-by: Sam Ravnborg --- drivers/gpu/drm/drm_agpsupport.c | 9 ++--- drivers/gpu/drm/drm_bufs.c | 4 ++-- drivers/gpu/drm/drm_edid.c | 7 ++- drivers/gpu/drm/drm_irq.c| 12 +++- drivers/gpu/drm/drm_pci.c| 26 +++--- drivers/gpu/drm/drm_vm.c | 2 +- include/drm/drm_device.h | 12 +--- 7 files changed, 46 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c index 4c7ad46fdd21..a4040fe4f4ba 100644 --- a/drivers/gpu/drm/drm_agpsupport.c +++ b/drivers/gpu/drm/drm_agpsupport.c @@ -103,11 +103,13 @@ int drm_agp_info_ioctl(struct drm_device *dev, void *data, */ int drm_agp_acquire(struct drm_device *dev) { + struct pci_dev *pdev = to_pci_dev(dev->dev); + if (!dev->agp) return -ENODEV; if (dev->agp->acquired) return -EBUSY; - dev->agp->bridge = agp_backend_acquire(dev->pdev); + dev->agp->bridge = agp_backend_acquire(pdev); if (!dev->agp->bridge) return -ENODEV; dev->agp->acquired = 1; @@ -402,14 +404,15 @@ int drm_agp_free_ioctl(struct drm_device *dev, void *data, */ struct drm_agp_head *drm_agp_init(struct drm_device *dev) { + struct pci_dev *pdev = to_pci_dev(dev->dev); struct drm_agp_head *head = NULL; head = kzalloc(sizeof(*head), GFP_KERNEL); if (!head) return NULL; - head->bridge = agp_find_bridge(dev->pdev); + head->bridge = agp_find_bridge(pdev); if (!head->bridge) { - head->bridge = agp_backend_acquire(dev->pdev); + head->bridge = agp_backend_acquire(pdev); if (!head->bridge) { kfree(head); return NULL; diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c index aeb1327e3077..e3d77dfefb0a 100644 --- a/drivers/gpu/drm/drm_bufs.c +++ b/drivers/gpu/drm/drm_bufs.c @@ -326,7 +326,7 @@ static int drm_addmap_core(struct drm_device *dev, resource_size_t offset, * As we're limiting the address to 2^32-1 (or less), * casting it down to 32 bits is no problem, but we * need to point to a 64bit variable first. */ - map->handle = dma_alloc_coherent(>pdev->dev, + map->handle = dma_alloc_coherent(dev->dev, map->size, >offset, GFP_KERNEL); @@ -556,7 +556,7 @@ int drm_legacy_rmmap_locked(struct drm_device *dev, struct drm_local_map *map) case _DRM_SCATTER_GATHER: break; case _DRM_CONSISTENT: - dma_free_coherent(>pdev->dev, + dma_free_coherent(dev->dev, map->size, map->handle, map->offset); diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 74f5a3197214..555a04ce2179 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -2075,9 +2076,13 @@ EXPORT_SYMBOL(drm_get_edid); struct edid *drm_get_edid_switcheroo(struct drm_connector *connector, struct i2c_adapter *adapter) { - struct pci_dev *pdev = connector->dev->pdev; + struct drm_device *dev = connector->dev; + struct pci_dev *pdev = to_pci_dev(dev->dev); struct edid *edid; + if (drm_WARN_ON_ONCE(dev, !dev_is_pci(dev->dev))) + return NULL; + vga_switcheroo_lock_ddc(pdev); edid = drm_get_edid(connector, adapter); vga_switcheroo_unlock_ddc(pdev); diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 09d6e9e2e075..22986a9a593b 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -122,7 +122,7 @@ int drm_irq_install(struct drm_device *dev, int irq) dev->driver->irq_preinstall(dev); /* PCI devices require shared interrupts. */ - if (dev->pdev) + if (dev_is_pci(dev->dev)) sh_flags = IRQF_SHARED; ret = request_irq(irq, dev->driver->irq_handler, @@ -140,7 +140,7 @@ int drm_irq_install(struct drm_device *dev, int irq) if
[PATCH v2 19/20] drm/vmwgfx: Remove references to struct drm_device.pdev
Using struct drm_device.pdev is deprecated. Convert vmwgfx to struct drm_device.dev. No functional changes. Signed-off-by: Thomas Zimmermann Reviewed-by: Zack Rusin Acked-by: Sam Ravnborg Cc: Roland Scheidegger --- drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c | 8 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c| 27 +- drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 2 +- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c index 9a9fe10d829b..83a8d34704ea 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c @@ -1230,7 +1230,7 @@ int vmw_cmdbuf_set_pool_size(struct vmw_cmdbuf_man *man, /* First, try to allocate a huge chunk of DMA memory */ size = PAGE_ALIGN(size); - man->map = dma_alloc_coherent(_priv->dev->pdev->dev, size, + man->map = dma_alloc_coherent(dev_priv->dev->dev, size, >handle, GFP_KERNEL); if (man->map) { man->using_mob = false; @@ -1313,7 +1313,7 @@ struct vmw_cmdbuf_man *vmw_cmdbuf_man_create(struct vmw_private *dev_priv) man->num_contexts = (dev_priv->capabilities & SVGA_CAP_HP_CMD_QUEUE) ? 2 : 1; man->headers = dma_pool_create("vmwgfx cmdbuf", - _priv->dev->pdev->dev, + dev_priv->dev->dev, sizeof(SVGACBHeader), 64, PAGE_SIZE); if (!man->headers) { @@ -1322,7 +1322,7 @@ struct vmw_cmdbuf_man *vmw_cmdbuf_man_create(struct vmw_private *dev_priv) } man->dheaders = dma_pool_create("vmwgfx inline cmdbuf", - _priv->dev->pdev->dev, + dev_priv->dev->dev, sizeof(struct vmw_cmdbuf_dheader), 64, PAGE_SIZE); if (!man->dheaders) { @@ -1387,7 +1387,7 @@ void vmw_cmdbuf_remove_pool(struct vmw_cmdbuf_man *man) ttm_bo_put(man->cmd_space); man->cmd_space = NULL; } else { - dma_free_coherent(>dev_priv->dev->pdev->dev, + dma_free_coherent(man->dev_priv->dev->dev, man->size, man->map, man->handle); } } diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 216daf93022c..e63e08f5b14f 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -652,6 +652,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) enum vmw_res_type i; bool refuse_dma = false; char host_log[100] = {0}; + struct pci_dev *pdev = to_pci_dev(dev->dev); dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL); if (unlikely(!dev_priv)) { @@ -659,7 +660,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) return -ENOMEM; } - pci_set_master(dev->pdev); + pci_set_master(pdev); dev_priv->dev = dev; dev_priv->vmw_chipset = chipset; @@ -688,9 +689,9 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) dev_priv->used_memory_size = 0; - dev_priv->io_start = pci_resource_start(dev->pdev, 0); - dev_priv->vram_start = pci_resource_start(dev->pdev, 1); - dev_priv->mmio_start = pci_resource_start(dev->pdev, 2); + dev_priv->io_start = pci_resource_start(pdev, 0); + dev_priv->vram_start = pci_resource_start(pdev, 1); + dev_priv->mmio_start = pci_resource_start(pdev, 2); dev_priv->assume_16bpp = !!vmw_assume_16bpp; @@ -840,7 +841,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) dev->dev_private = dev_priv; - ret = pci_request_regions(dev->pdev, "vmwgfx probe"); + ret = pci_request_regions(pdev, "vmwgfx probe"); dev_priv->stealth = (ret != 0); if (dev_priv->stealth) { /** @@ -849,7 +850,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) DRM_INFO("It appears like vesafb is loaded. " "Ignore above error if any.\n"); - ret = pci_request_region(dev->pdev, 2, "vmwgfx stealth probe"); + ret = pci_request_region(pdev, 2, "vmwgfx stealth probe"); if (unlikely(ret != 0)) { DRM_ERROR("Failed reserving the SVGA MMIO resource.\n"); goto out_no_device; @@ -857,7 +858,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) } if (dev_priv->capabilities & SVGA_CAP_IRQMASK) { - ret = vmw_irq_install(dev, dev->pdev->irq); + ret =
[PATCH v2 08/20] drm/hibmc: Remove references to struct drm_device.pdev
Using struct drm_device.pdev is deprecated. Convert hibmc to struct drm_device.dev. No functional changes. Signed-off-by: Thomas Zimmermann Acked-by: Sam Ravnborg Cc: Xinliang Liu Cc: Tian Tao Cc: John Stultz Cc: Xinwei Kong Cc: Chen Feng --- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 10 +- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_i2c.c | 2 +- drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c index d845657fd99c..ac5868343d0c 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c @@ -203,7 +203,7 @@ static void hibmc_hw_config(struct hibmc_drm_private *priv) static int hibmc_hw_map(struct hibmc_drm_private *priv) { struct drm_device *dev = priv->dev; - struct pci_dev *pdev = dev->pdev; + struct pci_dev *pdev = to_pci_dev(dev->dev); resource_size_t addr, size, ioaddr, iosize; ioaddr = pci_resource_start(pdev, 1); @@ -249,7 +249,7 @@ static int hibmc_unload(struct drm_device *dev) if (dev->irq_enabled) drm_irq_uninstall(dev); - pci_disable_msi(dev->pdev); + pci_disable_msi(to_pci_dev(dev->dev)); hibmc_kms_fini(priv); hibmc_mm_fini(priv); dev->dev_private = NULL; @@ -258,6 +258,7 @@ static int hibmc_unload(struct drm_device *dev) static int hibmc_load(struct drm_device *dev) { + struct pci_dev *pdev = to_pci_dev(dev->dev); struct hibmc_drm_private *priv; int ret; @@ -287,11 +288,11 @@ static int hibmc_load(struct drm_device *dev) goto err; } - ret = pci_enable_msi(dev->pdev); + ret = pci_enable_msi(pdev); if (ret) { drm_warn(dev, "enabling MSI failed: %d\n", ret); } else { - ret = drm_irq_install(dev, dev->pdev->irq); + ret = drm_irq_install(dev, pdev->irq); if (ret) drm_warn(dev, "install irq failed: %d\n", ret); } @@ -324,7 +325,6 @@ static int hibmc_pci_probe(struct pci_dev *pdev, return PTR_ERR(dev); } - dev->pdev = pdev; pci_set_drvdata(pdev, dev); ret = pci_enable_device(pdev); diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_i2c.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_i2c.c index 86d712090d87..410bd019bb35 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_i2c.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_i2c.c @@ -83,7 +83,7 @@ int hibmc_ddc_create(struct drm_device *drm_dev, connector->adapter.owner = THIS_MODULE; connector->adapter.class = I2C_CLASS_DDC; snprintf(connector->adapter.name, I2C_NAME_SIZE, "HIS i2c bit bus"); - connector->adapter.dev.parent = _dev->pdev->dev; + connector->adapter.dev.parent = drm_dev->dev; i2c_set_adapdata(>adapter, connector); connector->adapter.algo_data = >bit_data; diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c index 602ece11bb4a..77f075075db2 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c @@ -26,9 +26,9 @@ int hibmc_mm_init(struct hibmc_drm_private *hibmc) struct drm_vram_mm *vmm; int ret; struct drm_device *dev = hibmc->dev; + struct pci_dev *pdev = to_pci_dev(dev->dev); - vmm = drm_vram_helper_alloc_mm(dev, - pci_resource_start(dev->pdev, 0), + vmm = drm_vram_helper_alloc_mm(dev, pci_resource_start(pdev, 0), hibmc->fb_size); if (IS_ERR(vmm)) { ret = PTR_ERR(vmm); -- 2.29.2 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[PATCH v2 09/20] drm/i915: Remove references to struct drm_device.pdev
Using struct drm_device.pdev is deprecated. Convert i915 to struct drm_device.dev. No functional changes. v2: * move gt/ and gvt/ changes into separate patches Signed-off-by: Thomas Zimmermann Cc: Jani Nikula Cc: Joonas Lahtinen Cc: Rodrigo Vivi --- drivers/gpu/drm/i915/display/intel_bios.c | 2 +- drivers/gpu/drm/i915/display/intel_cdclk.c| 14 ++--- drivers/gpu/drm/i915/display/intel_csr.c | 2 +- drivers/gpu/drm/i915/display/intel_dsi_vbt.c | 2 +- drivers/gpu/drm/i915/display/intel_fbdev.c| 2 +- drivers/gpu/drm/i915/display/intel_gmbus.c| 2 +- .../gpu/drm/i915/display/intel_lpe_audio.c| 5 +++-- drivers/gpu/drm/i915/display/intel_opregion.c | 6 +++--- drivers/gpu/drm/i915/display/intel_overlay.c | 2 +- drivers/gpu/drm/i915/display/intel_panel.c| 4 ++-- drivers/gpu/drm/i915/display/intel_quirks.c | 2 +- drivers/gpu/drm/i915/display/intel_sdvo.c | 2 +- drivers/gpu/drm/i915/display/intel_vga.c | 8 drivers/gpu/drm/i915/gem/i915_gem_phys.c | 6 +++--- drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 2 +- drivers/gpu/drm/i915/i915_debugfs.c | 2 +- drivers/gpu/drm/i915/i915_drv.c | 20 +-- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/i915_gem_gtt.c | 4 ++-- drivers/gpu/drm/i915/i915_getparam.c | 5 +++-- drivers/gpu/drm/i915/i915_gpu_error.c | 2 +- drivers/gpu/drm/i915/i915_irq.c | 6 +++--- drivers/gpu/drm/i915/i915_pmu.c | 5 +++-- drivers/gpu/drm/i915/i915_suspend.c | 4 ++-- drivers/gpu/drm/i915/i915_switcheroo.c| 4 ++-- drivers/gpu/drm/i915/i915_vgpu.c | 2 +- drivers/gpu/drm/i915/intel_device_info.c | 2 +- drivers/gpu/drm/i915/intel_region_lmem.c | 8 drivers/gpu/drm/i915/intel_runtime_pm.c | 2 +- drivers/gpu/drm/i915/intel_uncore.c | 4 ++-- .../gpu/drm/i915/selftests/mock_gem_device.c | 1 - drivers/gpu/drm/i915/selftests/mock_gtt.c | 2 +- 32 files changed, 68 insertions(+), 68 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c index 4cc949b228f2..8879676372a3 100644 --- a/drivers/gpu/drm/i915/display/intel_bios.c +++ b/drivers/gpu/drm/i915/display/intel_bios.c @@ -2088,7 +2088,7 @@ bool intel_bios_is_valid_vbt(const void *buf, size_t size) static struct vbt_header *oprom_get_vbt(struct drm_i915_private *dev_priv) { - struct pci_dev *pdev = dev_priv->drm.pdev; + struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev); void __iomem *p = NULL, *oprom; struct vbt_header *vbt; u16 vbt_size; diff --git a/drivers/gpu/drm/i915/display/intel_cdclk.c b/drivers/gpu/drm/i915/display/intel_cdclk.c index c449d28d0560..a6e13208dc50 100644 --- a/drivers/gpu/drm/i915/display/intel_cdclk.c +++ b/drivers/gpu/drm/i915/display/intel_cdclk.c @@ -96,7 +96,7 @@ static void fixed_450mhz_get_cdclk(struct drm_i915_private *dev_priv, static void i85x_get_cdclk(struct drm_i915_private *dev_priv, struct intel_cdclk_config *cdclk_config) { - struct pci_dev *pdev = dev_priv->drm.pdev; + struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev); u16 hpllcc = 0; /* @@ -138,7 +138,7 @@ static void i85x_get_cdclk(struct drm_i915_private *dev_priv, static void i915gm_get_cdclk(struct drm_i915_private *dev_priv, struct intel_cdclk_config *cdclk_config) { - struct pci_dev *pdev = dev_priv->drm.pdev; + struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev); u16 gcfgc = 0; pci_read_config_word(pdev, GCFGC, ); @@ -162,7 +162,7 @@ static void i915gm_get_cdclk(struct drm_i915_private *dev_priv, static void i945gm_get_cdclk(struct drm_i915_private *dev_priv, struct intel_cdclk_config *cdclk_config) { - struct pci_dev *pdev = dev_priv->drm.pdev; + struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev); u16 gcfgc = 0; pci_read_config_word(pdev, GCFGC, ); @@ -256,7 +256,7 @@ static unsigned int intel_hpll_vco(struct drm_i915_private *dev_priv) static void g33_get_cdclk(struct drm_i915_private *dev_priv, struct intel_cdclk_config *cdclk_config) { - struct pci_dev *pdev = dev_priv->drm.pdev; + struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev); static const u8 div_3200[] = { 12, 10, 8, 7, 5, 16 }; static const u8 div_4000[] = { 14, 12, 10, 8, 6, 20 }; static const u8 div_4800[] = { 20, 14, 12, 10, 8, 24 }; @@ -305,7 +305,7 @@ static void g33_get_cdclk(struct drm_i915_private *dev_priv, static void pnv_get_cdclk(struct drm_i915_private *dev_priv, struct intel_cdclk_config *cdclk_config) { - struct pci_dev *pdev = dev_priv->drm.pdev; + struct pci_dev *pdev =
[PATCH v2 17/20] drm/vboxvideo: Remove references to struct drm_device.pdev
Using struct drm_device.pdev is deprecated. Convert vboxvideo to struct drm_device.dev. No functional changes. Signed-off-by: Thomas Zimmermann Acked-by: Sam Ravnborg Cc: Hans de Goede --- drivers/gpu/drm/vboxvideo/vbox_drv.c | 11 ++- drivers/gpu/drm/vboxvideo/vbox_irq.c | 4 +++- drivers/gpu/drm/vboxvideo/vbox_main.c | 8 ++-- drivers/gpu/drm/vboxvideo/vbox_ttm.c | 7 --- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/vboxvideo/vbox_drv.c b/drivers/gpu/drm/vboxvideo/vbox_drv.c index f3eac72cb46e..e534896b6cfd 100644 --- a/drivers/gpu/drm/vboxvideo/vbox_drv.c +++ b/drivers/gpu/drm/vboxvideo/vbox_drv.c @@ -51,7 +51,6 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (IS_ERR(vbox)) return PTR_ERR(vbox); - vbox->ddev.pdev = pdev; pci_set_drvdata(pdev, vbox); mutex_init(>hw_mutex); @@ -109,15 +108,16 @@ static void vbox_pci_remove(struct pci_dev *pdev) static int vbox_pm_suspend(struct device *dev) { struct vbox_private *vbox = dev_get_drvdata(dev); + struct pci_dev *pdev = to_pci_dev(dev); int error; error = drm_mode_config_helper_suspend(>ddev); if (error) return error; - pci_save_state(vbox->ddev.pdev); - pci_disable_device(vbox->ddev.pdev); - pci_set_power_state(vbox->ddev.pdev, PCI_D3hot); + pci_save_state(pdev); + pci_disable_device(pdev); + pci_set_power_state(pdev, PCI_D3hot); return 0; } @@ -125,8 +125,9 @@ static int vbox_pm_suspend(struct device *dev) static int vbox_pm_resume(struct device *dev) { struct vbox_private *vbox = dev_get_drvdata(dev); + struct pci_dev *pdev = to_pci_dev(dev); - if (pci_enable_device(vbox->ddev.pdev)) + if (pci_enable_device(pdev)) return -EIO; return drm_mode_config_helper_resume(>ddev); diff --git a/drivers/gpu/drm/vboxvideo/vbox_irq.c b/drivers/gpu/drm/vboxvideo/vbox_irq.c index 631657fa554f..b3ded68603ba 100644 --- a/drivers/gpu/drm/vboxvideo/vbox_irq.c +++ b/drivers/gpu/drm/vboxvideo/vbox_irq.c @@ -170,10 +170,12 @@ static void vbox_hotplug_worker(struct work_struct *work) int vbox_irq_init(struct vbox_private *vbox) { + struct pci_dev *pdev = to_pci_dev(vbox->ddev.dev); + INIT_WORK(>hotplug_work, vbox_hotplug_worker); vbox_update_mode_hints(vbox); - return drm_irq_install(>ddev, vbox->ddev.pdev->irq); + return drm_irq_install(>ddev, pdev->irq); } void vbox_irq_fini(struct vbox_private *vbox) diff --git a/drivers/gpu/drm/vboxvideo/vbox_main.c b/drivers/gpu/drm/vboxvideo/vbox_main.c index d68d9bad7674..f28779715ccd 100644 --- a/drivers/gpu/drm/vboxvideo/vbox_main.c +++ b/drivers/gpu/drm/vboxvideo/vbox_main.c @@ -8,7 +8,9 @@ * Hans de Goede */ +#include #include + #include #include #include @@ -30,6 +32,7 @@ void vbox_report_caps(struct vbox_private *vbox) static int vbox_accel_init(struct vbox_private *vbox) { + struct pci_dev *pdev = to_pci_dev(vbox->ddev.dev); struct vbva_buffer *vbva; unsigned int i; @@ -41,7 +44,7 @@ static int vbox_accel_init(struct vbox_private *vbox) /* Take a command buffer for each screen from the end of usable VRAM. */ vbox->available_vram_size -= vbox->num_crtcs * VBVA_MIN_BUFFER_SIZE; - vbox->vbva_buffers = pci_iomap_range(vbox->ddev.pdev, 0, + vbox->vbva_buffers = pci_iomap_range(pdev, 0, vbox->available_vram_size, vbox->num_crtcs * VBVA_MIN_BUFFER_SIZE); @@ -106,6 +109,7 @@ bool vbox_check_supported(u16 id) int vbox_hw_init(struct vbox_private *vbox) { + struct pci_dev *pdev = to_pci_dev(vbox->ddev.dev); int ret = -ENOMEM; vbox->full_vram_size = inl(VBE_DISPI_IOPORT_DATA); @@ -115,7 +119,7 @@ int vbox_hw_init(struct vbox_private *vbox) /* Map guest-heap at end of vram */ vbox->guest_heap = - pci_iomap_range(vbox->ddev.pdev, 0, GUEST_HEAP_OFFSET(vbox), + pci_iomap_range(pdev, 0, GUEST_HEAP_OFFSET(vbox), GUEST_HEAP_SIZE); if (!vbox->guest_heap) return -ENOMEM; diff --git a/drivers/gpu/drm/vboxvideo/vbox_ttm.c b/drivers/gpu/drm/vboxvideo/vbox_ttm.c index f5a06675da43..0066a3c1dfc9 100644 --- a/drivers/gpu/drm/vboxvideo/vbox_ttm.c +++ b/drivers/gpu/drm/vboxvideo/vbox_ttm.c @@ -15,8 +15,9 @@ int vbox_mm_init(struct vbox_private *vbox) struct drm_vram_mm *vmm; int ret; struct drm_device *dev = >ddev; + struct pci_dev *pdev = to_pci_dev(dev->dev); - vmm = drm_vram_helper_alloc_mm(dev, pci_resource_start(dev->pdev, 0), + vmm = drm_vram_helper_alloc_mm(dev, pci_resource_start(pdev, 0),
[PATCH v2 18/20] drm/virtgpu: Remove references to struct drm_device.pdev
Using struct drm_device.pdev is deprecated. Convert virtgpu to struct drm_device.dev. No functional changes. Signed-off-by: Thomas Zimmermann Acked-by: Sam Ravnborg Cc: Gerd Hoffmann --- drivers/gpu/drm/virtio/virtgpu_drv.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c index 27f13bd29c13..a21dc3ad6f88 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.c +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c @@ -54,7 +54,6 @@ static int virtio_gpu_pci_quirk(struct drm_device *dev, struct virtio_device *vd DRM_INFO("pci: %s detected at %s\n", vga ? "virtio-vga" : "virtio-gpu-pci", pname); - dev->pdev = pdev; if (vga) drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "virtiodrmfb"); -- 2.29.2 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[PATCH v2 15/20] drm/radeon: Fix trailing whitespaces
Adhere to kernel coding style. Signed-off-by: Thomas Zimmermann Acked-by: Alex Deucher Cc: Alex Deucher Cc: Christian König --- drivers/gpu/drm/radeon/r100.c | 2 +- drivers/gpu/drm/radeon/radeon_kms.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c index 24c8db673931..e4ae09b5294d 100644 --- a/drivers/gpu/drm/radeon/r100.c +++ b/drivers/gpu/drm/radeon/r100.c @@ -2797,7 +2797,7 @@ void r100_vram_init_sizes(struct radeon_device *rdev) rdev->mc.real_vram_size = 8192 * 1024; WREG32(RADEON_CONFIG_MEMSIZE, rdev->mc.real_vram_size); } - /* Fix for RN50, M6, M7 with 8/16/32(??) MBs of VRAM - + /* Fix for RN50, M6, M7 with 8/16/32(??) MBs of VRAM - * Novell bug 204882 + along with lots of ubuntu ones */ if (rdev->mc.aper_size > config_aper_size) diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c index abb3bdd9ca25..75b038740ea8 100644 --- a/drivers/gpu/drm/radeon/radeon_kms.c +++ b/drivers/gpu/drm/radeon/radeon_kms.c @@ -74,7 +74,7 @@ void radeon_driver_unload_kms(struct drm_device *dev) } radeon_acpi_fini(rdev); - + radeon_modeset_fini(rdev); radeon_device_fini(rdev); -- 2.29.2 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[PATCH v2 06/20] drm/gma500: Fix trailing whitespaces
Adhere to kernel coding style. Signed-off-by: Thomas Zimmermann Acked-by: Sam Ravnborg Cc: Patrik Jakobsson --- drivers/gpu/drm/gma500/cdv_device.c | 8 drivers/gpu/drm/gma500/intel_bios.c | 4 ++-- drivers/gpu/drm/gma500/oaktrail_device.c | 2 +- drivers/gpu/drm/gma500/psb_intel_lvds.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/gma500/cdv_device.c b/drivers/gpu/drm/gma500/cdv_device.c index e75293e4a52f..e0b728f246fb 100644 --- a/drivers/gpu/drm/gma500/cdv_device.c +++ b/drivers/gpu/drm/gma500/cdv_device.c @@ -421,16 +421,16 @@ static int cdv_power_up(struct drm_device *dev) static void cdv_hotplug_work_func(struct work_struct *work) { struct drm_psb_private *dev_priv = container_of(work, struct drm_psb_private, - hotplug_work); + hotplug_work); struct drm_device *dev = dev_priv->dev; /* Just fire off a uevent and let userspace tell us what to do */ drm_helper_hpd_irq_event(dev); -} +} /* The core driver has received a hotplug IRQ. We are in IRQ context so extract the needed information and kick off queued processing */ - + static int cdv_hotplug_event(struct drm_device *dev) { struct drm_psb_private *dev_priv = dev->dev_private; @@ -449,7 +449,7 @@ static void cdv_hotplug_enable(struct drm_device *dev, bool on) } else { REG_WRITE(PORT_HOTPLUG_EN, 0); REG_WRITE(PORT_HOTPLUG_STAT, REG_READ(PORT_HOTPLUG_STAT)); - } + } } static const char *force_audio_names[] = { diff --git a/drivers/gpu/drm/gma500/intel_bios.c b/drivers/gpu/drm/gma500/intel_bios.c index 8ad6337eeba3..08e1dacbdbc8 100644 --- a/drivers/gpu/drm/gma500/intel_bios.c +++ b/drivers/gpu/drm/gma500/intel_bios.c @@ -50,7 +50,7 @@ parse_edp(struct drm_psb_private *dev_priv, struct bdb_header *bdb) uint8_t panel_type; edp = find_section(bdb, BDB_EDP); - + dev_priv->edp.bpp = 18; if (!edp) { if (dev_priv->edp.support) { @@ -80,7 +80,7 @@ parse_edp(struct drm_psb_private *dev_priv, struct bdb_header *bdb) dev_priv->edp.pps = *edp_pps; DRM_DEBUG_KMS("EDP timing in vbt t1_t3 %d t8 %d t9 %d t10 %d t11_t12 %d\n", - dev_priv->edp.pps.t1_t3, dev_priv->edp.pps.t8, + dev_priv->edp.pps.t1_t3, dev_priv->edp.pps.t8, dev_priv->edp.pps.t9, dev_priv->edp.pps.t10, dev_priv->edp.pps.t11_t12); diff --git a/drivers/gpu/drm/gma500/oaktrail_device.c b/drivers/gpu/drm/gma500/oaktrail_device.c index 8754290b0e23..d9f8324f7c58 100644 --- a/drivers/gpu/drm/gma500/oaktrail_device.c +++ b/drivers/gpu/drm/gma500/oaktrail_device.c @@ -505,7 +505,7 @@ static int oaktrail_chip_setup(struct drm_device *dev) { struct drm_psb_private *dev_priv = dev->dev_private; int ret; - + if (pci_enable_msi(dev->pdev)) dev_warn(dev->dev, "Enabling MSI failed!\n"); diff --git a/drivers/gpu/drm/gma500/psb_intel_lvds.c b/drivers/gpu/drm/gma500/psb_intel_lvds.c index 063c66bb946d..49228e2cf480 100644 --- a/drivers/gpu/drm/gma500/psb_intel_lvds.c +++ b/drivers/gpu/drm/gma500/psb_intel_lvds.c @@ -216,7 +216,7 @@ static void psb_intel_lvds_set_power(struct drm_device *dev, bool on) dev_err(dev->dev, "set power, chip off!\n"); return; } - + if (on) { REG_WRITE(PP_CONTROL, REG_READ(PP_CONTROL) | POWER_TARGET_ON); -- 2.29.2 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[PATCH v2 14/20] drm/qxl: Remove references to struct drm_device.pdev
Using struct drm_device.pdev is deprecated. Convert qxl to struct drm_device.dev. No functional changes. Signed-off-by: Thomas Zimmermann Acked-by: Sam Ravnborg Cc: Gerd Hoffmann --- drivers/gpu/drm/qxl/qxl_drv.c | 2 +- drivers/gpu/drm/qxl/qxl_ioctl.c | 3 ++- drivers/gpu/drm/qxl/qxl_irq.c | 3 ++- drivers/gpu/drm/qxl/qxl_kms.c | 1 - 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c index 6e7f16f4cec7..fb5f6a5e81d7 100644 --- a/drivers/gpu/drm/qxl/qxl_drv.c +++ b/drivers/gpu/drm/qxl/qxl_drv.c @@ -163,7 +163,7 @@ DEFINE_DRM_GEM_FOPS(qxl_fops); static int qxl_drm_freeze(struct drm_device *dev) { - struct pci_dev *pdev = dev->pdev; + struct pci_dev *pdev = to_pci_dev(dev->dev); struct qxl_device *qdev = to_qxl(dev); int ret; diff --git a/drivers/gpu/drm/qxl/qxl_ioctl.c b/drivers/gpu/drm/qxl/qxl_ioctl.c index 16e1e589508e..b6075f452b9e 100644 --- a/drivers/gpu/drm/qxl/qxl_ioctl.c +++ b/drivers/gpu/drm/qxl/qxl_ioctl.c @@ -370,13 +370,14 @@ static int qxl_clientcap_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct qxl_device *qdev = to_qxl(dev); + struct pci_dev *pdev = to_pci_dev(dev->dev); struct drm_qxl_clientcap *param = data; int byte, idx; byte = param->index / 8; idx = param->index % 8; - if (dev->pdev->revision < 4) + if (pdev->revision < 4) return -ENOSYS; if (byte >= 58) diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c index 1ba5a702d763..ddf6588a2a38 100644 --- a/drivers/gpu/drm/qxl/qxl_irq.c +++ b/drivers/gpu/drm/qxl/qxl_irq.c @@ -81,6 +81,7 @@ static void qxl_client_monitors_config_work_func(struct work_struct *work) int qxl_irq_init(struct qxl_device *qdev) { + struct pci_dev *pdev = to_pci_dev(qdev->ddev.dev); int ret; init_waitqueue_head(>display_event); @@ -93,7 +94,7 @@ int qxl_irq_init(struct qxl_device *qdev) atomic_set(>irq_received_cursor, 0); atomic_set(>irq_received_io_cmd, 0); qdev->irq_received_error = 0; - ret = drm_irq_install(>ddev, qdev->ddev.pdev->irq); + ret = drm_irq_install(>ddev, pdev->irq); qdev->ram_header->int_mask = QXL_INTERRUPT_MASK; if (unlikely(ret != 0)) { DRM_ERROR("Failed installing irq: %d\n", ret); diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c index 228e2b9198f1..4a60a52ab62e 100644 --- a/drivers/gpu/drm/qxl/qxl_kms.c +++ b/drivers/gpu/drm/qxl/qxl_kms.c @@ -111,7 +111,6 @@ int qxl_device_init(struct qxl_device *qdev, { int r, sb; - qdev->ddev.pdev = pdev; pci_set_drvdata(pdev, >ddev); mutex_init(>gem.mutex); -- 2.29.2 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[PATCH v2 11/20] drm/i915/gvt: Remove references to struct drm_device.pdev
Using struct drm_device.pdev is deprecated. Convert i915 to struct drm_device.dev. No functional changes. Signed-off-by: Thomas Zimmermann Cc: Jani Nikula Cc: Joonas Lahtinen Cc: Rodrigo Vivi --- drivers/gpu/drm/i915/gvt/cfg_space.c | 5 +++-- drivers/gpu/drm/i915/gvt/firmware.c | 10 +- drivers/gpu/drm/i915/gvt/gtt.c | 12 ++-- drivers/gpu/drm/i915/gvt/gvt.c | 6 +++--- drivers/gpu/drm/i915/gvt/kvmgt.c | 4 ++-- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/i915/gvt/cfg_space.c b/drivers/gpu/drm/i915/gvt/cfg_space.c index ad86c5eb5bba..b490e3db2e38 100644 --- a/drivers/gpu/drm/i915/gvt/cfg_space.c +++ b/drivers/gpu/drm/i915/gvt/cfg_space.c @@ -374,6 +374,7 @@ void intel_vgpu_init_cfg_space(struct intel_vgpu *vgpu, bool primary) { struct intel_gvt *gvt = vgpu->gvt; + struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev); const struct intel_gvt_device_info *info = >device_info; u16 *gmch_ctl; u8 next; @@ -407,9 +408,9 @@ void intel_vgpu_init_cfg_space(struct intel_vgpu *vgpu, memset(vgpu_cfg_space(vgpu) + INTEL_GVT_PCI_OPREGION, 0, 4); vgpu->cfg_space.bar[INTEL_GVT_PCI_BAR_GTTMMIO].size = - pci_resource_len(gvt->gt->i915->drm.pdev, 0); + pci_resource_len(pdev, 0); vgpu->cfg_space.bar[INTEL_GVT_PCI_BAR_APERTURE].size = - pci_resource_len(gvt->gt->i915->drm.pdev, 2); + pci_resource_len(pdev, 2); memset(vgpu_cfg_space(vgpu) + PCI_ROM_ADDRESS, 0, 4); diff --git a/drivers/gpu/drm/i915/gvt/firmware.c b/drivers/gpu/drm/i915/gvt/firmware.c index 990a181094e3..1a8274a3f4b1 100644 --- a/drivers/gpu/drm/i915/gvt/firmware.c +++ b/drivers/gpu/drm/i915/gvt/firmware.c @@ -76,7 +76,7 @@ static int mmio_snapshot_handler(struct intel_gvt *gvt, u32 offset, void *data) static int expose_firmware_sysfs(struct intel_gvt *gvt) { struct intel_gvt_device_info *info = >device_info; - struct pci_dev *pdev = gvt->gt->i915->drm.pdev; + struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev); struct gvt_firmware_header *h; void *firmware; void *p; @@ -127,7 +127,7 @@ static int expose_firmware_sysfs(struct intel_gvt *gvt) static void clean_firmware_sysfs(struct intel_gvt *gvt) { - struct pci_dev *pdev = gvt->gt->i915->drm.pdev; + struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev); device_remove_bin_file(>dev, _attr); vfree(firmware_attr.private); @@ -151,7 +151,7 @@ static int verify_firmware(struct intel_gvt *gvt, const struct firmware *fw) { struct intel_gvt_device_info *info = >device_info; - struct pci_dev *pdev = gvt->gt->i915->drm.pdev; + struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev); struct gvt_firmware_header *h; unsigned long id, crc32_start; const void *mem; @@ -205,7 +205,7 @@ static int verify_firmware(struct intel_gvt *gvt, int intel_gvt_load_firmware(struct intel_gvt *gvt) { struct intel_gvt_device_info *info = >device_info; - struct pci_dev *pdev = gvt->gt->i915->drm.pdev; + struct pci_dev *pdev = to_pci_dev(gvt->gt->i915->drm.dev); struct intel_gvt_firmware *firmware = >firmware; struct gvt_firmware_header *h; const struct firmware *fw; @@ -240,7 +240,7 @@ int intel_gvt_load_firmware(struct intel_gvt *gvt) gvt_dbg_core("request hw state firmware %s...\n", path); - ret = request_firmware(, path, >gt->i915->drm.pdev->dev); + ret = request_firmware(, path, gvt->gt->i915->drm.dev); kfree(path); if (ret) diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c index 897c007ea96a..6d12a5a401f6 100644 --- a/drivers/gpu/drm/i915/gvt/gtt.c +++ b/drivers/gpu/drm/i915/gvt/gtt.c @@ -746,7 +746,7 @@ static int detach_oos_page(struct intel_vgpu *vgpu, static void ppgtt_free_spt(struct intel_vgpu_ppgtt_spt *spt) { - struct device *kdev = >vgpu->gvt->gt->i915->drm.pdev->dev; + struct device *kdev = spt->vgpu->gvt->gt->i915->drm.dev; trace_spt_free(spt->vgpu->id, spt, spt->guest_page.type); @@ -831,7 +831,7 @@ static int reclaim_one_ppgtt_mm(struct intel_gvt *gvt); static struct intel_vgpu_ppgtt_spt *ppgtt_alloc_spt( struct intel_vgpu *vgpu, enum intel_gvt_gtt_type type) { - struct device *kdev = >gvt->gt->i915->drm.pdev->dev; + struct device *kdev = vgpu->gvt->gt->i915->drm.dev; struct intel_vgpu_ppgtt_spt *spt = NULL; dma_addr_t daddr; int ret; @@ -2402,7 +2402,7 @@ static int alloc_scratch_pages(struct intel_vgpu *vgpu, vgpu->gvt->device_info.gtt_entry_size_shift; void *scratch_pt; int i; - struct device *dev = >gvt->gt->i915->drm.pdev->dev; + struct device *dev =
[PATCH v2 12/20] drm/mgag200: Remove references to struct drm_device.pdev
Using struct drm_device.pdev is deprecated. Convert mgag200 to struct drm_device.dev. No functional changes. Signed-off-by: Thomas Zimmermann Acked-by: Sam Ravnborg --- drivers/gpu/drm/mgag200/mgag200_drv.c | 20 +++- drivers/gpu/drm/mgag200/mgag200_i2c.c | 2 +- drivers/gpu/drm/mgag200/mgag200_mm.c | 10 ++ 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c index a977c9f49719..4e4c105f9a50 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.c +++ b/drivers/gpu/drm/mgag200/mgag200_drv.c @@ -47,10 +47,11 @@ static const struct drm_driver mgag200_driver = { static bool mgag200_has_sgram(struct mga_device *mdev) { struct drm_device *dev = >base; + struct pci_dev *pdev = to_pci_dev(dev->dev); u32 option; int ret; - ret = pci_read_config_dword(dev->pdev, PCI_MGA_OPTION, ); + ret = pci_read_config_dword(pdev, PCI_MGA_OPTION, ); if (drm_WARN(dev, ret, "failed to read PCI config dword: %d\n", ret)) return false; @@ -60,6 +61,7 @@ static bool mgag200_has_sgram(struct mga_device *mdev) static int mgag200_regs_init(struct mga_device *mdev) { struct drm_device *dev = >base; + struct pci_dev *pdev = to_pci_dev(dev->dev); u32 option, option2; u8 crtcext3; @@ -99,13 +101,13 @@ static int mgag200_regs_init(struct mga_device *mdev) } if (option) - pci_write_config_dword(dev->pdev, PCI_MGA_OPTION, option); + pci_write_config_dword(pdev, PCI_MGA_OPTION, option); if (option2) - pci_write_config_dword(dev->pdev, PCI_MGA_OPTION2, option2); + pci_write_config_dword(pdev, PCI_MGA_OPTION2, option2); /* BAR 1 contains registers */ - mdev->rmmio_base = pci_resource_start(dev->pdev, 1); - mdev->rmmio_size = pci_resource_len(dev->pdev, 1); + mdev->rmmio_base = pci_resource_start(pdev, 1); + mdev->rmmio_size = pci_resource_len(pdev, 1); if (!devm_request_mem_region(dev->dev, mdev->rmmio_base, mdev->rmmio_size, "mgadrmfb_mmio")) { @@ -113,7 +115,7 @@ static int mgag200_regs_init(struct mga_device *mdev) return -ENOMEM; } - mdev->rmmio = pcim_iomap(dev->pdev, 1, 0); + mdev->rmmio = pcim_iomap(pdev, 1, 0); if (mdev->rmmio == NULL) return -ENOMEM; @@ -218,6 +220,7 @@ static void mgag200_g200_interpret_bios(struct mga_device *mdev, static void mgag200_g200_init_refclk(struct mga_device *mdev) { struct drm_device *dev = >base; + struct pci_dev *pdev = to_pci_dev(dev->dev); unsigned char __iomem *rom; unsigned char *bios; size_t size; @@ -226,7 +229,7 @@ static void mgag200_g200_init_refclk(struct mga_device *mdev) mdev->model.g200.pclk_max = 23; mdev->model.g200.ref_clk = 27050; - rom = pci_map_rom(dev->pdev, ); + rom = pci_map_rom(pdev, ); if (!rom) return; @@ -244,7 +247,7 @@ static void mgag200_g200_init_refclk(struct mga_device *mdev) vfree(bios); out: - pci_unmap_rom(dev->pdev, rom); + pci_unmap_rom(pdev, rom); } static void mgag200_g200se_init_unique_id(struct mga_device *mdev) @@ -301,7 +304,6 @@ mgag200_device_create(struct pci_dev *pdev, unsigned long flags) return mdev; dev = >base; - dev->pdev = pdev; pci_set_drvdata(pdev, dev); ret = mgag200_device_init(mdev, flags); diff --git a/drivers/gpu/drm/mgag200/mgag200_i2c.c b/drivers/gpu/drm/mgag200/mgag200_i2c.c index 09731e614e46..ac8e34eef513 100644 --- a/drivers/gpu/drm/mgag200/mgag200_i2c.c +++ b/drivers/gpu/drm/mgag200/mgag200_i2c.c @@ -126,7 +126,7 @@ struct mga_i2c_chan *mgag200_i2c_create(struct drm_device *dev) i2c->clock = clock; i2c->adapter.owner = THIS_MODULE; i2c->adapter.class = I2C_CLASS_DDC; - i2c->adapter.dev.parent = >pdev->dev; + i2c->adapter.dev.parent = dev->dev; i2c->dev = dev; i2c_set_adapdata(>adapter, i2c); snprintf(i2c->adapter.name, sizeof(i2c->adapter.name), "mga i2c"); diff --git a/drivers/gpu/drm/mgag200/mgag200_mm.c b/drivers/gpu/drm/mgag200/mgag200_mm.c index 641f1aa992be..b667371b69a4 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mm.c +++ b/drivers/gpu/drm/mgag200/mgag200_mm.c @@ -78,11 +78,12 @@ static size_t mgag200_probe_vram(struct mga_device *mdev, void __iomem *mem, static void mgag200_mm_release(struct drm_device *dev, void *ptr) { struct mga_device *mdev = to_mga_device(dev); + struct pci_dev *pdev = to_pci_dev(dev->dev); mdev->vram_fb_available = 0; iounmap(mdev->vram); - arch_io_free_memtype_wc(pci_resource_start(dev->pdev, 0), - pci_resource_len(dev->pdev, 0)); +
[PATCH v2 10/20] drm/i915/gt: Remove references to struct drm_device.pdev
Using struct drm_device.pdev is deprecated. Convert i915 to struct drm_device.dev. No functional changes. Signed-off-by: Thomas Zimmermann Cc: Jani Nikula Cc: Joonas Lahtinen Cc: Rodrigo Vivi --- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 2 +- drivers/gpu/drm/i915/gt/intel_ggtt.c | 10 +- drivers/gpu/drm/i915/gt/intel_ppgtt.c | 2 +- drivers/gpu/drm/i915/gt/intel_rc6.c | 4 ++-- drivers/gpu/drm/i915/gt/intel_reset.c | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c index d4e988b2816a..71bd2e22e7c6 100644 --- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c +++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c @@ -1228,7 +1228,7 @@ bool intel_engine_is_idle(struct intel_engine_cs *engine) /* Waiting to drain ELSP? */ if (execlists_active(>execlists)) { - synchronize_hardirq(engine->i915->drm.pdev->irq); + synchronize_hardirq(to_pci_dev(engine->i915->drm.dev)->irq); intel_engine_flush_submission(engine); diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt.c b/drivers/gpu/drm/i915/gt/intel_ggtt.c index cf94525be2c1..591c6a2a0a8f 100644 --- a/drivers/gpu/drm/i915/gt/intel_ggtt.c +++ b/drivers/gpu/drm/i915/gt/intel_ggtt.c @@ -760,7 +760,7 @@ static unsigned int chv_get_total_gtt_size(u16 gmch_ctrl) static int ggtt_probe_common(struct i915_ggtt *ggtt, u64 size) { struct drm_i915_private *i915 = ggtt->vm.i915; - struct pci_dev *pdev = i915->drm.pdev; + struct pci_dev *pdev = to_pci_dev(i915->drm.dev); phys_addr_t phys_addr; int ret; @@ -830,7 +830,7 @@ static struct resource pci_resource(struct pci_dev *pdev, int bar) static int gen8_gmch_probe(struct i915_ggtt *ggtt) { struct drm_i915_private *i915 = ggtt->vm.i915; - struct pci_dev *pdev = i915->drm.pdev; + struct pci_dev *pdev = to_pci_dev(i915->drm.dev); unsigned int size; u16 snb_gmch_ctl; @@ -974,7 +974,7 @@ static u64 iris_pte_encode(dma_addr_t addr, static int gen6_gmch_probe(struct i915_ggtt *ggtt) { struct drm_i915_private *i915 = ggtt->vm.i915; - struct pci_dev *pdev = i915->drm.pdev; + struct pci_dev *pdev = to_pci_dev(i915->drm.dev); unsigned int size; u16 snb_gmch_ctl; @@ -1037,7 +1037,7 @@ static int i915_gmch_probe(struct i915_ggtt *ggtt) phys_addr_t gmadr_base; int ret; - ret = intel_gmch_probe(i915->bridge_dev, i915->drm.pdev, NULL); + ret = intel_gmch_probe(i915->bridge_dev, to_pci_dev(i915->drm.dev), NULL); if (!ret) { drm_err(>drm, "failed to set up gmch\n"); return -EIO; @@ -1077,7 +1077,7 @@ static int ggtt_probe_hw(struct i915_ggtt *ggtt, struct intel_gt *gt) ggtt->vm.gt = gt; ggtt->vm.i915 = i915; - ggtt->vm.dma = >drm.pdev->dev; + ggtt->vm.dma = i915->drm.dev; if (INTEL_GEN(i915) <= 5) ret = i915_gmch_probe(ggtt); diff --git a/drivers/gpu/drm/i915/gt/intel_ppgtt.c b/drivers/gpu/drm/i915/gt/intel_ppgtt.c index 46d9aceda64c..01b7d08532f2 100644 --- a/drivers/gpu/drm/i915/gt/intel_ppgtt.c +++ b/drivers/gpu/drm/i915/gt/intel_ppgtt.c @@ -301,7 +301,7 @@ void ppgtt_init(struct i915_ppgtt *ppgtt, struct intel_gt *gt) ppgtt->vm.gt = gt; ppgtt->vm.i915 = i915; - ppgtt->vm.dma = >drm.pdev->dev; + ppgtt->vm.dma = i915->drm.dev; ppgtt->vm.total = BIT_ULL(INTEL_INFO(i915)->ppgtt_size); i915_address_space_init(>vm, VM_CLASS_PPGTT); diff --git a/drivers/gpu/drm/i915/gt/intel_rc6.c b/drivers/gpu/drm/i915/gt/intel_rc6.c index d7b8e4457fc2..cce53fb9589c 100644 --- a/drivers/gpu/drm/i915/gt/intel_rc6.c +++ b/drivers/gpu/drm/i915/gt/intel_rc6.c @@ -485,14 +485,14 @@ static bool rc6_supported(struct intel_rc6 *rc6) static void rpm_get(struct intel_rc6 *rc6) { GEM_BUG_ON(rc6->wakeref); - pm_runtime_get_sync(_to_i915(rc6)->drm.pdev->dev); + pm_runtime_get_sync(rc6_to_i915(rc6)->drm.dev); rc6->wakeref = true; } static void rpm_put(struct intel_rc6 *rc6) { GEM_BUG_ON(!rc6->wakeref); - pm_runtime_put(_to_i915(rc6)->drm.pdev->dev); + pm_runtime_put(rc6_to_i915(rc6)->drm.dev); rc6->wakeref = false; } diff --git a/drivers/gpu/drm/i915/gt/intel_reset.c b/drivers/gpu/drm/i915/gt/intel_reset.c index 3654c955e6be..a49faf4ec139 100644 --- a/drivers/gpu/drm/i915/gt/intel_reset.c +++ b/drivers/gpu/drm/i915/gt/intel_reset.c @@ -180,7 +180,7 @@ static int i915_do_reset(struct intel_gt *gt, intel_engine_mask_t engine_mask, unsigned int retry) { - struct pci_dev *pdev = gt->i915->drm.pdev; + struct pci_dev *pdev = to_pci_dev(gt->i915->drm.dev); int err; /* Assert reset for at least 20 usec, and wait for acknowledgement. */ @@ -209,7
[PATCH v2 03/20] drm/ast: Remove references to struct drm_device.pdev
Using struct drm_device.pdev is deprecated. Convert ast to struct drm_device.dev. No functional changes. Signed-off-by: Thomas Zimmermann Acked-by: Sam Ravnborg --- drivers/gpu/drm/ast/ast_drv.c | 4 ++-- drivers/gpu/drm/ast/ast_main.c | 25 + drivers/gpu/drm/ast/ast_mm.c | 17 + drivers/gpu/drm/ast/ast_mode.c | 5 +++-- drivers/gpu/drm/ast/ast_post.c | 8 +--- 5 files changed, 32 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c index 667b450606ef..ea8164e7a6dc 100644 --- a/drivers/gpu/drm/ast/ast_drv.c +++ b/drivers/gpu/drm/ast/ast_drv.c @@ -147,7 +147,7 @@ static int ast_drm_freeze(struct drm_device *dev) error = drm_mode_config_helper_suspend(dev); if (error) return error; - pci_save_state(dev->pdev); + pci_save_state(to_pci_dev(dev->dev)); return 0; } @@ -162,7 +162,7 @@ static int ast_drm_resume(struct drm_device *dev) { int ret; - if (pci_enable_device(dev->pdev)) + if (pci_enable_device(to_pci_dev(dev->dev))) return -EIO; ret = ast_drm_thaw(dev); diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c index 1b13199858cb..0ac3c2039c4b 100644 --- a/drivers/gpu/drm/ast/ast_main.c +++ b/drivers/gpu/drm/ast/ast_main.c @@ -67,8 +67,9 @@ uint8_t ast_get_index_reg_mask(struct ast_private *ast, static void ast_detect_config_mode(struct drm_device *dev, u32 *scu_rev) { - struct device_node *np = dev->pdev->dev.of_node; + struct device_node *np = dev->dev->of_node; struct ast_private *ast = to_ast_private(dev); + struct pci_dev *pdev = to_pci_dev(dev->dev); uint32_t data, jregd0, jregd1; /* Defaults */ @@ -85,7 +86,7 @@ static void ast_detect_config_mode(struct drm_device *dev, u32 *scu_rev) } /* Not all families have a P2A bridge */ - if (dev->pdev->device != PCI_CHIP_AST2000) + if (pdev->device != PCI_CHIP_AST2000) return; /* @@ -119,6 +120,7 @@ static void ast_detect_config_mode(struct drm_device *dev, u32 *scu_rev) static int ast_detect_chip(struct drm_device *dev, bool *need_post) { struct ast_private *ast = to_ast_private(dev); + struct pci_dev *pdev = to_pci_dev(dev->dev); uint32_t jreg, scu_rev; /* @@ -143,19 +145,19 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post) ast_detect_config_mode(dev, _rev); /* Identify chipset */ - if (dev->pdev->revision >= 0x50) { + if (pdev->revision >= 0x50) { ast->chip = AST2600; drm_info(dev, "AST 2600 detected\n"); - } else if (dev->pdev->revision >= 0x40) { + } else if (pdev->revision >= 0x40) { ast->chip = AST2500; drm_info(dev, "AST 2500 detected\n"); - } else if (dev->pdev->revision >= 0x30) { + } else if (pdev->revision >= 0x30) { ast->chip = AST2400; drm_info(dev, "AST 2400 detected\n"); - } else if (dev->pdev->revision >= 0x20) { + } else if (pdev->revision >= 0x20) { ast->chip = AST2300; drm_info(dev, "AST 2300 detected\n"); - } else if (dev->pdev->revision >= 0x10) { + } else if (pdev->revision >= 0x10) { switch (scu_rev & 0x0300) { case 0x0200: ast->chip = AST1100; @@ -265,7 +267,7 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post) static int ast_get_dram_info(struct drm_device *dev) { - struct device_node *np = dev->pdev->dev.of_node; + struct device_node *np = dev->dev->of_node; struct ast_private *ast = to_ast_private(dev); uint32_t mcr_cfg, mcr_scu_mpll, mcr_scu_strap; uint32_t denum, num, div, ref_pll, dsel; @@ -409,10 +411,9 @@ struct ast_private *ast_device_create(const struct drm_driver *drv, return ast; dev = >base; - dev->pdev = pdev; pci_set_drvdata(pdev, dev); - ast->regs = pci_iomap(dev->pdev, 1, 0); + ast->regs = pci_iomap(pdev, 1, 0); if (!ast->regs) return ERR_PTR(-EIO); @@ -421,14 +422,14 @@ struct ast_private *ast_device_create(const struct drm_driver *drv, * assume the chip has MMIO enabled by default (rev 0x20 * and higher). */ - if (!(pci_resource_flags(dev->pdev, 2) & IORESOURCE_IO)) { + if (!(pci_resource_flags(pdev, 2) & IORESOURCE_IO)) { drm_info(dev, "platform has no IO space, trying MMIO\n"); ast->ioregs = ast->regs + AST_IO_MM_OFFSET; } /* "map" IO regs if the above hasn't done so already */ if (!ast->ioregs) { - ast->ioregs = pci_iomap(dev->pdev, 2, 0); + ast->ioregs = pci_iomap(pdev, 2, 0); if
[PATCH v2 02/20] drm/amdgpu: Remove references to struct drm_device.pdev
Using struct drm_device.pdev is deprecated. Convert amdgpu to struct drm_device.dev. No functional changes. Signed-off-by: Thomas Zimmermann Acked-by: Alex Deucher Acked-by: Sam Ravnborg Cc: Alex Deucher Cc: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 17 - drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 10 +- drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 10 +- 7 files changed, 22 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index da23c0f21311..26ee571ff9f4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -1404,9 +1404,9 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, /* don't suspend or resume card normally */ dev->switch_power_state = DRM_SWITCH_POWER_CHANGING; - pci_set_power_state(dev->pdev, PCI_D0); - amdgpu_device_load_pci_state(dev->pdev); - r = pci_enable_device(dev->pdev); + pci_set_power_state(pdev, PCI_D0); + amdgpu_device_load_pci_state(pdev); + r = pci_enable_device(pdev); if (r) DRM_WARN("pci_enable_device failed (%d)\n", r); amdgpu_device_resume(dev, true); @@ -1418,10 +1418,10 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, drm_kms_helper_poll_disable(dev); dev->switch_power_state = DRM_SWITCH_POWER_CHANGING; amdgpu_device_suspend(dev, true); - amdgpu_device_cache_pci_state(dev->pdev); + amdgpu_device_cache_pci_state(pdev); /* Shut down the device */ - pci_disable_device(dev->pdev); - pci_set_power_state(dev->pdev, PCI_D3cold); + pci_disable_device(pdev); + pci_set_power_state(pdev, PCI_D3cold); dev->switch_power_state = DRM_SWITCH_POWER_OFF; } } @@ -1684,8 +1684,7 @@ static void amdgpu_device_enable_virtual_display(struct amdgpu_device *adev) adev->enable_virtual_display = false; if (amdgpu_virtual_display) { - struct drm_device *ddev = adev_to_drm(adev); - const char *pci_address_name = pci_name(ddev->pdev); + const char *pci_address_name = pci_name(adev->pdev); char *pciaddstr, *pciaddstr_tmp, *pciaddname_tmp, *pciaddname; pciaddstr = kstrdup(amdgpu_virtual_display, GFP_KERNEL); @@ -3375,7 +3374,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, } } - pci_enable_pcie_error_reporting(adev->ddev.pdev); + pci_enable_pcie_error_reporting(adev->pdev); /* Post card if necessary */ if (amdgpu_device_need_post(adev)) { diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c index 2e8a8b57639f..77974c3981fa 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c @@ -721,13 +721,14 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev, struct drm_file *file_priv, const struct drm_mode_fb_cmd2 *mode_cmd) { + struct amdgpu_device *adev = drm_to_adev(dev); struct drm_gem_object *obj; struct amdgpu_framebuffer *amdgpu_fb; int ret; obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]); if (obj == NULL) { - dev_err(>pdev->dev, "No GEM object associated to handle 0x%08X, " + dev_err(>pdev->dev, "No GEM object associated to handle 0x%08X, " "can't create framebuffer\n", mode_cmd->handles[0]); return ERR_PTR(-ENOENT); } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 624294e0b9f3..bdc35c3f8523 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -1192,7 +1192,6 @@ static int amdgpu_pci_probe(struct pci_dev *pdev, if (ret) return ret; - ddev->pdev = pdev; pci_set_drvdata(pdev, ddev); ret = amdgpu_driver_load_kms(adev, ent->driver_data); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c index 0bf7d36c6686..51cd49c6f38f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c @@ -271,7 +271,7 @@ static int amdgpufb_create(struct drm_fb_helper *helper, DRM_INFO("fb depth is %d\n", fb->format->depth);
[PATCH v2 05/20] drm/cirrus: Remove references to struct drm_device.pdev
Using struct drm_device.pdev is deprecated. Convert cirrus to struct drm_device.dev. No functional changes. Signed-off-by: Thomas Zimmermann Acked-by: Sam Ravnborg Cc: Gerd Hoffmann --- drivers/gpu/drm/tiny/cirrus.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/gpu/drm/tiny/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c index 561c49d8657a..a043e602199e 100644 --- a/drivers/gpu/drm/tiny/cirrus.c +++ b/drivers/gpu/drm/tiny/cirrus.c @@ -602,7 +602,6 @@ static int cirrus_pci_probe(struct pci_dev *pdev, drm_mode_config_reset(dev); - dev->pdev = pdev; pci_set_drvdata(pdev, dev); ret = drm_dev_register(dev, 0); if (ret) -- 2.29.2 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[PATCH v2 04/20] drm/bochs: Remove references to struct drm_device.pdev
Using struct drm_device.pdev is deprecated. Convert bochs to struct drm_device.dev. No functional changes. Signed-off-by: Thomas Zimmermann Acked-by: Sam Ravnborg Cc: Gerd Hoffmann --- drivers/gpu/drm/bochs/bochs_drv.c | 1 - drivers/gpu/drm/bochs/bochs_hw.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bochs/bochs_drv.c b/drivers/gpu/drm/bochs/bochs_drv.c index fd454225fd19..b469624fe40d 100644 --- a/drivers/gpu/drm/bochs/bochs_drv.c +++ b/drivers/gpu/drm/bochs/bochs_drv.c @@ -121,7 +121,6 @@ static int bochs_pci_probe(struct pci_dev *pdev, if (ret) goto err_free_dev; - dev->pdev = pdev; pci_set_drvdata(pdev, dev); ret = bochs_load(dev); diff --git a/drivers/gpu/drm/bochs/bochs_hw.c b/drivers/gpu/drm/bochs/bochs_hw.c index dce4672e3fc8..2d7380a9890e 100644 --- a/drivers/gpu/drm/bochs/bochs_hw.c +++ b/drivers/gpu/drm/bochs/bochs_hw.c @@ -110,7 +110,7 @@ int bochs_hw_load_edid(struct bochs_device *bochs) int bochs_hw_init(struct drm_device *dev) { struct bochs_device *bochs = dev->dev_private; - struct pci_dev *pdev = dev->pdev; + struct pci_dev *pdev = to_pci_dev(dev->dev); unsigned long addr, size, mem, ioaddr, iosize; u16 id; @@ -201,7 +201,7 @@ void bochs_hw_fini(struct drm_device *dev) release_region(VBE_DISPI_IOPORT_INDEX, 2); if (bochs->fb_map) iounmap(bochs->fb_map); - pci_release_regions(dev->pdev); + pci_release_regions(to_pci_dev(dev->dev)); kfree(bochs->edid); } -- 2.29.2 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[PATCH v2 00/20] drm: Move struct drm_device.pdev to legacy
The pdev field in struct drm_device points to a PCI device structure and goes back to UMS-only days when all DRM drivers were for PCI devices. Meanwhile we also support USB, SPI and platform devices. Each of those uses the generic device stored in struct drm_device.dev. To reduce duplication and remove the special case of PCI, this patchset converts all modesetting drivers from pdev to dev and makes pdev a field for legacy UMS drivers. For PCI devices, the pointer in struct drm_device.dev can be upcasted to struct pci_device; or tested for PCI with dev_is_pci(). In several places the code can use the dev field directly. After converting all drivers and the DRM core, the pdev fields becomes only relevant for legacy drivers. In a later patchset, we may want to convert these as well and remove pdev entirely. The patchset touches many files, but the individual changes are mostly trivial. I suggest to merge each driver's patch through the respective tree and later the rest through drm-misc-next. v2: * move whitespace fixes into separate patches (Alex, Sam) * move i915 gt/ and gvt/ changes into separate patches (Joonas) Thomas Zimmermann (20): drm/amdgpu: Fix trailing whitespaces drm/amdgpu: Remove references to struct drm_device.pdev drm/ast: Remove references to struct drm_device.pdev drm/bochs: Remove references to struct drm_device.pdev drm/cirrus: Remove references to struct drm_device.pdev drm/gma500: Fix trailing whitespaces drm/gma500: Remove references to struct drm_device.pdev drm/hibmc: Remove references to struct drm_device.pdev drm/i915: Remove references to struct drm_device.pdev drm/i915/gt: Remove references to struct drm_device.pdev drm/i915/gvt: Remove references to struct drm_device.pdev drm/mgag200: Remove references to struct drm_device.pdev drm/nouveau: Remove references to struct drm_device.pdev drm/qxl: Remove references to struct drm_device.pdev drm/radeon: Fix trailing whitespaces drm/radeon: Remove references to struct drm_device.pdev drm/vboxvideo: Remove references to struct drm_device.pdev drm/virtgpu: Remove references to struct drm_device.pdev drm/vmwgfx: Remove references to struct drm_device.pdev drm: Upcast struct drm_device.dev to struct pci_device; replace pdev drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 23 +++-- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c| 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 10 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 10 +-- drivers/gpu/drm/ast/ast_drv.c | 4 +- drivers/gpu/drm/ast/ast_main.c| 25 +++--- drivers/gpu/drm/ast/ast_mm.c | 17 ++-- drivers/gpu/drm/ast/ast_mode.c| 5 +- drivers/gpu/drm/ast/ast_post.c| 8 +- drivers/gpu/drm/bochs/bochs_drv.c | 1 - drivers/gpu/drm/bochs/bochs_hw.c | 4 +- drivers/gpu/drm/drm_agpsupport.c | 9 +- drivers/gpu/drm/drm_bufs.c| 4 +- drivers/gpu/drm/drm_edid.c| 7 +- drivers/gpu/drm/drm_irq.c | 12 +-- drivers/gpu/drm/drm_pci.c | 26 +++--- drivers/gpu/drm/drm_vm.c | 2 +- drivers/gpu/drm/gma500/cdv_device.c | 30 --- drivers/gpu/drm/gma500/cdv_intel_crt.c| 3 +- drivers/gpu/drm/gma500/cdv_intel_lvds.c | 4 +- drivers/gpu/drm/gma500/framebuffer.c | 9 +- drivers/gpu/drm/gma500/gma_device.c | 3 +- drivers/gpu/drm/gma500/gma_display.c | 4 +- drivers/gpu/drm/gma500/gtt.c | 20 +++-- drivers/gpu/drm/gma500/intel_bios.c | 6 +- drivers/gpu/drm/gma500/intel_gmbus.c | 4 +- drivers/gpu/drm/gma500/intel_i2c.c| 2 +- drivers/gpu/drm/gma500/mdfld_device.c | 4 +- drivers/gpu/drm/gma500/mdfld_dsi_dpi.c| 8 +- drivers/gpu/drm/gma500/mid_bios.c | 9 +- drivers/gpu/drm/gma500/oaktrail_device.c | 5 +- drivers/gpu/drm/gma500/oaktrail_lvds.c| 2 +- drivers/gpu/drm/gma500/oaktrail_lvds_i2c.c| 2 +- drivers/gpu/drm/gma500/opregion.c | 3 +- drivers/gpu/drm/gma500/power.c| 13 +-- drivers/gpu/drm/gma500/psb_drv.c | 16 ++-- drivers/gpu/drm/gma500/psb_drv.h | 8 +- drivers/gpu/drm/gma500/psb_intel_lvds.c | 6 +- drivers/gpu/drm/gma500/psb_intel_sdvo.c | 2 +- drivers/gpu/drm/gma500/tc35876x-dsi-lvds.c| 36 .../gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 10 +-- .../gpu/drm/hisilicon/hibmc/hibmc_drm_i2c.c | 2 +- drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c | 4 +- drivers/gpu/drm/i915/display/intel_bios.c | 2 +- drivers/gpu/drm/i915/display/intel_cdclk.c| 14 +--
[PATCH v2 01/20] drm/amdgpu: Fix trailing whitespaces
Adhere to kernel coding style. Signed-off-by: Thomas Zimmermann Acked-by: Alex Deucher Acked-by: Sam Ravnborg Cc: Alex Deucher Cc: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 5f304425c948..da23c0f21311 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -4922,8 +4922,8 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta case pci_channel_io_normal: return PCI_ERS_RESULT_CAN_RECOVER; /* Fatal error, prepare for slot reset */ - case pci_channel_io_frozen: - /* + case pci_channel_io_frozen: + /* * Cancel and wait for all TDRs in progress if failing to * set adev->in_gpu_reset in amdgpu_device_lock_adev * @@ -5014,7 +5014,7 @@ pci_ers_result_t amdgpu_pci_slot_reset(struct pci_dev *pdev) goto out; } - adev->in_pci_err_recovery = true; + adev->in_pci_err_recovery = true; r = amdgpu_device_pre_asic_reset(adev, NULL, _full_reset); adev->in_pci_err_recovery = false; if (r) -- 2.29.2 ___ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 09/15] drm/nouveau: Remove references to struct drm_device.pdev
Hi Sam Am 24.11.20 um 22:42 schrieb Sam Ravnborg: Hi Thomas. On Tue, Nov 24, 2020 at 12:38:18PM +0100, Thomas Zimmermann wrote: Using struct drm_device.pdev is deprecated. Convert nouveau to struct drm_device.dev. No functional changes. Signed-off-by: Thomas Zimmermann Cc: Ben Skeggs Suggestion to an alternative implmentation below. --- drivers/gpu/drm/nouveau/dispnv04/arb.c | 12 +++- drivers/gpu/drm/nouveau/dispnv04/disp.h | 14 -- drivers/gpu/drm/nouveau/dispnv04/hw.c | 10 ++ drivers/gpu/drm/nouveau/nouveau_abi16.c | 7 --- drivers/gpu/drm/nouveau/nouveau_acpi.c | 2 +- drivers/gpu/drm/nouveau/nouveau_bios.c | 11 --- drivers/gpu/drm/nouveau/nouveau_connector.c | 10 ++ drivers/gpu/drm/nouveau/nouveau_drm.c | 5 ++--- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 6 -- drivers/gpu/drm/nouveau/nouveau_vga.c | 20 10 files changed, 58 insertions(+), 39 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c index d204ea8a5618..7cc683b8dc7a 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c @@ -110,6 +110,9 @@ static int call_lvds_manufacturer_script(struct drm_device *dev, struct dcb_outp struct nvbios *bios = >vbios; uint8_t sub = bios->data[bios->fp.xlated_entry + script] + (bios->fp.link_c_increment && dcbent->or & DCB_OUTPUT_C ? 1 : 0); uint16_t scriptofs = ROM16(bios->data[bios->init_script_tbls_ptr + sub * 2]); +#ifdef __powerpc__ + struct pci_dev *pdev = to_pci_dev(dev->dev); +#endif Or int device = 0; if (!bios->fp.xlated_entry || !sub || !scriptofs) return -EINVAL; @@ -123,8 +126,8 @@ static int call_lvds_manufacturer_script(struct drm_device *dev, struct dcb_outp #ifdef __powerpc__ /* Powerbook specific quirks */ device = to_pci_dev(dev->dev)->device; if (script == LVDS_RESET && (device == 0x0179 || device == 0x0189 || device == 0x0329)) I see the point, but I'm trying to not change the existing implementation too much. if (script == LVDS_RESET && - (dev->pdev->device == 0x0179 || dev->pdev->device == 0x0189 || -dev->pdev->device == 0x0329)) + (pdev->device == 0x0179 || pdev->device == 0x0189 || +pdev->device == 0x0329)) nv_write_tmds(dev, dcbent->or, 0, 0x02, 0x72); #endif diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c index 24ec5339efb4..4fc0fa696461 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c +++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c @@ -396,7 +396,9 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, NV_INFO(drm, "allocated %dx%d fb: 0x%llx, bo %p\n", fb->width, fb->height, nvbo->offset, nvbo); - vga_switcheroo_client_fb_set(dev->pdev, info); + if (dev_is_pci(dev->dev)) + vga_switcheroo_client_fb_set(to_pci_dev(dev->dev), info); + I cannot see why dev_is_pci() is needed here. So I am obviously missing something :-( vga_switcheroo_client_fb_set() expects a PCI device. It's a bit of a stretch, but at least it is possible to pass NULL for non-PCI devices. Passing the upcasted dev->dev is just garbage. As the VGA switcheroo is only relevant for PCI devices, I added the branching to make this work reliably. Best regards Thomas return 0; out_unlock: @@ -548,7 +550,7 @@ nouveau_fbcon_init(struct drm_device *dev) int ret; if (!dev->mode_config.num_crtc || - (dev->pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA) + (to_pci_dev(dev->dev)->class >> 8) != PCI_CLASS_DISPLAY_VGA) return 0; fbcon = kzalloc(sizeof(struct nouveau_fbdev), GFP_KERNEL); diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c index c85dd8afa3c3..7c4b374b3eca 100644 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c @@ -87,18 +87,20 @@ nouveau_vga_init(struct nouveau_drm *drm) { struct drm_device *dev = drm->dev; bool runtime = nouveau_pmops_runtime(); + struct pci_dev *pdev; /* only relevant for PCI devices */ - if (!dev->pdev) + if (!dev_is_pci(dev->dev)) return; + pdev = to_pci_dev(dev->dev); - vga_client_register(dev->pdev, dev, NULL, nouveau_vga_set_decode); + vga_client_register(pdev, dev, NULL, nouveau_vga_set_decode); /* don't register Thunderbolt eGPU with vga_switcheroo */ - if (pci_is_thunderbolt_attached(dev->pdev)) + if (pci_is_thunderbolt_attached(pdev)) return; - vga_switcheroo_register_client(dev->pdev, _switcheroo_ops, runtime); + vga_switcheroo_register_client(pdev, _switcheroo_ops, runtime); if (runtime &&