drm/vmwgfx: Use dma-coherent memory for high-bandwidth port messaging
Subsystems (3)
PATCH 1/1 drm/vmwgfx: Use dma-coherent memory for high-bandwidth port messaging
From: Thomas Hellstrom <[email protected]>
With AMD-SEV high-bandwidth port messaging runs into trouble since the message content is encrypted using the vm-specific key, and the hypervisor is unable to read it.
So use unencrypted dma-coherent bounce buffers for temporary message storage space. Allocating that memory is expensive so a future optimization might include a static unencrypted memory area for messages.
--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 4 +-- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 4 +-- drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 45 +++++++++++++++++------------ 3 files changed, 31 insertions(+), 22 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +2 -2
@@ -908,13 +908,13 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)snprintf (host_log,sizeof (host_log),"vmwgfx: %s-%s" ,VMWGFX_REPO ,VMWGFX_GIT_VERSION ); -vmw_host_log (host_log); +vmw_host_log (dev->dev, host_log);memset (host_log,0 ,sizeof (host_log));snprintf (host_log,sizeof (host_log),"vmwgfx: Module Version: %d.%d.%d" ,VMWGFX_DRIVER_MAJOR ,VMWGFX_DRIVER_MINOR ,VMWGFX_DRIVER_PATCHLEVEL ); -vmw_host_log (host_log); +vmw_host_log (dev->dev, host_log);if (dev_priv->enable_fb) {vmw_fifo_resource_inc (dev_priv);
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +2 -2
@@ -1389,9 +1389,9 @@ int vmw_bo_cpu_blit(struct ttm_buffer_object *dst, struct vmw_diff_cpy *diff);/* Host messaging -vmwgfx_msg.c: */ -int vmw_host_get_guestinfo (const char *guest_info_param, +int vmw_host_get_guestinfo (struct device *dev,const char *guest_info_param,char *buffer,size_t *length); -int vmw_host_log (const char *log); +int vmw_host_log (struct device *dev,const char *log);/* VMW logging */
drivers/gpu/drm/vmwgfx/vmwgfx_msg.c +27 -18
152 lines not on this page · raw message
Signature · 6 lines
2.21.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 drm/vmwgfx: Use coherent memory if there are dma mapping size restrictions
From: Thomas Hellstrom <[email protected]>
We're gradually moving towards using DMA coherent memory in most situations, although TTM interactions with the DMA layers is still a work-in-progress. Meanwhile, use coherent memory when there are size restrictions meaning that there is a chance that streaming dma mapping of large buffer objects may fail.
Also move DMA mask settings to the vmw_dma_select_mode function, since it's important that we set the correct DMA masks before calling the dma_max_mapping_size() function.
--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 31 +++++++---------------------- 1 file changed, 7 insertions(+), 24 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +7 -24
@@ -569,7 +569,10 @@ static int vmw_dma_select_mode(struct vmw_private *dev_priv) [vmw_dma_map_populate] = "Caching DMA mappings.", [vmw_dma_map_bind] = "Giving up DMA mappings early."}; -if (vmw_force_coherent) + (void )dma_set_mask_and_coherent (dev_priv->dev->dev,DMA_BIT_MASK (64 )); + +if (vmw_force_coherent || +dma_max_mapping_size (dev_priv->dev->dev) !=SIZE_MAX ) dev_priv->map_mode = vmw_dma_alloc_coherent;else if (vmw_restrict_iommu) dev_priv->map_mode = vmw_dma_map_bind;
@@ -582,30 +585,15 @@ static int vmw_dma_select_mode(struct vmw_private *dev_priv)return -EINVAL ;DRM_INFO ("DMA map mode: %s\n" , names[dev_priv->map_mode]); -return 0 ; -} -/** -* vmw_dma_masks - set required page- and dma masks -* -* @dev: Pointer to struct drm-device -* -* With 32-bit we can only handle 32 bit PFNs. Optionally set that -* restriction also for 64-bit systems. -*/ -static int vmw_dma_masks (struct vmw_private *dev_priv) -{ -struct drm_device *dev = dev_priv->dev; -int ret =0 ; - - ret =dma_set_mask_and_coherent (dev->dev,DMA_BIT_MASK (64 ));if (dev_priv->map_mode != vmw_dma_phys && (sizeof (unsigned long ) ==4 || vmw_restrict_dma_mask)) {DRM_INFO ("Restricting DMA addresses to 44 bits.\n" ); -return dma_set_mask_and_coherent (dev->dev,DMA_BIT_MASK (44 )); +return dma_set_mask_and_coherent (dev_priv->dev->dev, +DMA_BIT_MASK (44 )); } -return ret; +return 0 ; }static int vmw_driver_load (struct drm_device *dev,unsigned long chipset)
@@ -674,7 +662,6 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) dev_priv->capabilities2 =vmw_read (dev_priv,SVGA_REG_CAP2 ); } - ret =vmw_dma_select_mode (dev_priv);if (unlikely (ret !=0 )) {DRM_INFO ("Restricting capabilities due to IOMMU setup.\n" );
@@ -746,10 +733,6 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)if (dev_priv->capabilities &SVGA_CAP_CAP2_REGISTER )vmw_print_capabilities2 (dev_priv->capabilities2); - ret =vmw_dma_masks (dev_priv); -if (unlikely (ret !=0 )) - goto out_err0; - dma_set_max_seg_size(dev->dev, min_t(unsigned int, U32_MAX & PAGE_MASK,SCATTERLIST_MAX_SEGMENT ));
Signature · 6 lines
2.21.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH] drm/vmwgfx: Use coherent memory if there are dma mapping size restrictions
Hi,
Quoted 27 lines · Christoph Hellwig
Quoted 26 lines · Thomas Hellström (VMware)
From: Thomas Hellstrom <[email protected]>
We're gradually moving towards using DMA coherent memory in most situations, although TTM interactions with the DMA layers is still a work-in-progress. Meanwhile, use coherent memory when there are size restrictions meaning that there is a chance that streaming dma mapping of large buffer objects may fail.
Also move DMA mask settings to thevmw_dma_select_modefunction, since it's important that we set the correct DMA masks before calling thedma_max_mapping_size()function.Cc Christoph Hellwig <[email protected]>Signed-off-by Thomas Hellstrom <[email protected]>Reviewed-by Brian Paul <[email protected]>--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 31 +++++++---------------------- 1 file changed, 7 insertions(+), 24 deletions(-)drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +0
-0@@ -569,7 +569,10 @@ static int vmw_dma_select_mode(struct vmw_private *dev_priv) [vmw_dma_map_populate] = "Caching DMA mappings.", [vmw_dma_map_bind] = "Giving up DMA mappings early."};
Quoted 5 lines
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c static int vmw_dma_select_mode(struct vmw_private *dev_priv) · line 572
Quoted 2 lines
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1
-1-if (vmw_force_coherent) + (void )dma_set_mask_and_coherent (dev_priv->dev->dev,DMA_BIT_MASK (64 ));Please don't use void cast on returns. Also this genercally can't fail, so if it fails anyway it is fatal, and you should actually return an error.
OK. Will fix.
Quoted 6 lines
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c static int vmw_dma_select_mode(struct vmw_private *dev_priv) · line 575
Quoted 3 lines
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +2
-0+if (vmw_force_coherent || +dma_max_mapping_size (dev_priv->dev->dev) !=SIZE_MAX )I don't think this is the right check to see if swiotlb would be used. You probably want to call
dma_addressing_limited(). Please also add a comment explaining the call here.
If I understand things correctly, dma_addressing_limited() would always return false on vmwgfx, at least if the "restrict to 44 bit" option is removed. The "odd" modes we want to catch is someone setting swiotlb=force, or someone enabling SEV. In both cases, vmwgfx would break down due to limited DMA space even if streaming DMA was fixed with appropriate sync calls.
The same holds for vmw_pvscsi (which we discussed before) where the large queue depth will typically fill the SWIOTLB causing excessive non-fatal error logging. dma_max_mapping_size() currently catch these modes, but best I guess would be dma_swiotlb_forced() function that could be used in cases like this?
Quoted 6 lines
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c static int vmw_dma_select_mode(struct vmw_private *dev_priv) · line 589
Quoted 3 lines
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +0
-0if (dev_priv->map_mode != vmw_dma_phys &&AFAIK
vmw_dma_physcan't even be set in current mainline and is dead code. Can you check if I'm missing something? Certainly all three branches above don't set it.
I'll remove that dead code for v2.
Quoted 12 lines
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c static int vmw_dma_select_mode(struct vmw_private *dev_priv) · line 593
Quoted 6 lines
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +2
-1(sizeof(unsigned long) == 4 || vmw_restrict_dma_mask)) {DRM_INFO ("Restricting DMA addresses to 44 bits.\n" ); -return dma_set_mask_and_coherent (dev->dev,DMA_BIT_MASK (44 )); +return dma_set_mask_and_coherent (dev_priv->dev->dev, +DMA_BIT_MASK (44 ));Can you keep setting the DMA mask together?
E.g. make the whole thing something like:
static int
vmw_dma_select_mode(struct vmw_private *dev_priv)
Quoted 10 lines
{
if (dma_addressing_limited(dev_priv->dev->dev) || vmw_force_coherent) {
/*
* XXX: what about AMD iommu? virtio-iommu? Also
* swiotlb should be always available where we can
* address more than 32-bit of memory..
*/
if (!IS_ENABLED(CONFIG_SWIOTLB) &&
!IS_ENABLED(CONFIG_INTEL_IOMMU))
return -EINVAL;The above check is only to see if coherent memory functionality is really compiled in into TTM. We have a patchset that got lost in the last merge window to fix this properly and avoid confusion about this. I'll rebase on that.
Quoted 7 lines
dev_priv->map_mode = vmw_dma_alloc_coherent;
} else if (vmw_restrict_iommu) {
dev_priv->map_mode = vmw_dma_map_bind;
} else {
dev_priv->map_mode = vmw_dma_map_populate;
}Quoted 8 lines
/* * On 32-bit systems we can only handle 32 bit PFNs. Optionally set * that restriction also for 64-bit systems. */ return dma_set_mask_and_coherent(dev->dev, (IS_ENABLED(CONFIG_64BIT) && !vmw_restrict_dma_mask) ? 64 : 44); }
Thanks,
Thomas
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 drm/vmwgfx: remove set but not used variable 'srf'
In reply to Thomas Hellström (VMware)From: YueHaibing <[email protected]>
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c:339:22:
warning: variable srf set but not used [-Wunused-but-set-variable]
'srf' is never used, so can be removed.
--- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +0 -2
@@ -336,7 +336,6 @@ static void vmw_hw_surface_destroy(struct vmw_resource *res) {struct vmw_private *dev_priv = res->dev_priv; -struct vmw_surface *srf;void *cmd;if (res->func->destroy == vmw_gb_surface_destroy) {
@@ -360,7 +359,6 @@ static void vmw_hw_surface_destroy(struct vmw_resource *res)*/ mutex_lock (&dev_priv->cmdbuf_mutex); - srf =vmw_res_to_srf (res); dev_priv->used_memory_size -= res->backup_size;mutex_unlock (&dev_priv->cmdbuf_mutex); }
Signature · 6 lines
2.21.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 6 lines · Thomas Hellström (VMware)
From: Thomas Hellstrom <[email protected]>
With AMD-SEV high-bandwidth port messaging runs into trouble since the message content is encrypted using the vm-specific key, and the hypervisor is unable to read it.
Quoted 6 lines
So use unencrypted dma-coherent bounce buffers for temporary message storage space. Allocating that memory is expensive so a future optimization might include a static unencrypted memory area for messages.
Signed-off-by Thomas Hellstrom <[email protected]>Reviewed-by Brian Paul <[email protected]>
Hi Thomas,
The 0day team has been doing clang builds for us and sending the results to our mailing list for triage; this patch causes the following warning. Seems legitimate, mind taking a look at it and resolving it how you see fit?
Cheers,
Nathan
Quoted 127 lines · kbuild test robot
CC: [email protected]
In-Reply-To: <[email protected]>
References: <[email protected]>
TO: "Thomas Hellström (VMware)" <[email protected]>
CC: [email protected], Thomas Hellstrom <[email protected]>, Brian Paul <[email protected]>, Thomas Hellstrom <[email protected]>, Brian Paul <[email protected]>
CC: Thomas Hellstrom <[email protected]>, Brian Paul <[email protected]>Hi "Thomas,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[also build test WARNING on v5.4-rc7 next-20191113]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]url: https://github.com/0day-ci/linux/commits/Thomas-Hellstr-m-VMware/drm-vmwgfx-Use-dma-coherent-memory-for-high-bandwidth-port-messaging/20191114-020818 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 0e3f1ad80fc8cb0c517fd9a9afb22752b741fa76 config: x86_64-rhel-7.6 (attached as .config) compiler: clang version 10.0.0 (git://gitmirror/llvm_project 335ac2eb662ce5f1888e2a50310b01fba2d40d68) reproduce: # save the attached .config to linux build tree make ARCH=x86_64If you fix the issue, kindly add following tag
Reported-by kbuild test robot <[email protected]>All warnings (new ones prefixed by >>):
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/vmwgfx/vmwgfx_msg.c:441:6: warning: variable 'reply_handle' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]if (vmw_send_msg(&channel, msg) || ^~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/vmwgfx/vmwgfx_msg.c:467:47: note: uninitialized use occurs here dma_free_coherent(dev, reply_len + 1, reply, reply_handle); ^~~~~~~~~~~~ drivers/gpu/drm/vmwgfx/vmwgfx_msg.c:441:6: note: remove the '||' if its condition is always false if (vmw_send_msg(&channel, msg) || ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/vmwgfx/vmwgfx_msg.c:421:37: note: initialize the variable 'reply_handle' to silence this warning dma_addr_t req_handle, reply_handle; ^ = 01 warning generated.
vim +441
drivers/gpu/drm/vmwgfx/vmwgfx_msg.c89da76fde68de1 Sinclair Yeh 2016-04-27 400 89da76fde68de1 Sinclair Yeh 2016-04-27 401 89da76fde68de1 Sinclair Yeh 2016-04-27 402 /** 89da76fde68de1 Sinclair Yeh 2016-04-27 403 * vmw_host_get_guestinfo: Gets a GuestInfo parameter 89da76fde68de1 Sinclair Yeh 2016-04-27 404 * 89da76fde68de1 Sinclair Yeh 2016-04-27 405 * Gets the value of a GuestInfo.* parameter. The value returned will be in 89da76fde68de1 Sinclair Yeh 2016-04-27 406 * a string, and it is up to the caller to post-process. 89da76fde68de1 Sinclair Yeh 2016-04-27 407 * 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 408 * @dev: Pointer to struct device used for coherent memory allocation 89da76fde68de1 Sinclair Yeh 2016-04-27 409 * @guest_info_param: Parameter to get, e.g. GuestInfo.svga.gl3 89da76fde68de1 Sinclair Yeh 2016-04-27 410 * @buffer: if NULL, *reply_len will contain reply size. 89da76fde68de1 Sinclair Yeh 2016-04-27 411 * @length: size of the reply_buf. Set to size of reply upon return 89da76fde68de1 Sinclair Yeh 2016-04-27 412 * 89da76fde68de1 Sinclair Yeh 2016-04-27 413 * Returns: 0 on success 89da76fde68de1 Sinclair Yeh 2016-04-27 414 */ 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 415 int vmw_host_get_guestinfo(struct device *dev, const char *guest_info_param, 89da76fde68de1 Sinclair Yeh 2016-04-27 416 char *buffer, size_t *length) 89da76fde68de1 Sinclair Yeh 2016-04-27 417 { 89da76fde68de1 Sinclair Yeh 2016-04-27 418 struct rpc_channel channel; 89da76fde68de1 Sinclair Yeh 2016-04-27 419 char *msg, *reply = NULL; 6073a09210e06f Himanshu Jha 2018-03-22 420 size_t reply_len = 0; 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 421 dma_addr_t req_handle, reply_handle; 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 422 int req_len = strlen("info-get ") + strlen(guest_info_param) + 1; 89da76fde68de1 Sinclair Yeh 2016-04-27 423 89da76fde68de1 Sinclair Yeh 2016-04-27 424 if (!vmw_msg_enabled) 89da76fde68de1 Sinclair Yeh 2016-04-27 425 return -ENODEV; 89da76fde68de1 Sinclair Yeh 2016-04-27 426 89da76fde68de1 Sinclair Yeh 2016-04-27 427 if (!guest_info_param || !length) 89da76fde68de1 Sinclair Yeh 2016-04-27 428 return -EINVAL; 89da76fde68de1 Sinclair Yeh 2016-04-27 429 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 430 msg = dma_alloc_coherent(dev, req_len, &req_handle, GFP_KERNEL); 1a4adb05632e90 Ravikant B Sharma 2016-11-08 431 if (!msg) { 3fbeccf8ceb165 Thomas Hellstrom 2018-06-20 432 DRM_ERROR("Cannot allocate memory to get guest info \"%s\".", 3fbeccf8ceb165 Thomas Hellstrom 2018-06-20 433 guest_info_param); 89da76fde68de1 Sinclair Yeh 2016-04-27 434 return -ENOMEM; 89da76fde68de1 Sinclair Yeh 2016-04-27 435 } 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 436 snprintf(msg, req_len, "info-get %s", guest_info_param); 89da76fde68de1 Sinclair Yeh 2016-04-27 437 f37230c0ad4810 Thomas Hellstrom 2018-05-23 438 if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM)) f37230c0ad4810 Thomas Hellstrom 2018-05-23 439 goto out_open; 89da76fde68de1 Sinclair Yeh 2016-04-27 440 f37230c0ad4810 Thomas Hellstrom 2018-05-23 @441 if (vmw_send_msg(&channel, msg) || 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 442 vmw_recv_msg(dev, &channel, (void *) &reply, &reply_len, 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 443 &reply_handle)) f37230c0ad4810 Thomas Hellstrom 2018-05-23 444 goto out_msg; 89da76fde68de1 Sinclair Yeh 2016-04-27 445 f37230c0ad4810 Thomas Hellstrom 2018-05-23 446 vmw_close_channel(&channel); 89da76fde68de1 Sinclair Yeh 2016-04-27 447 if (buffer && reply && reply_len > 0) { 89da76fde68de1 Sinclair Yeh 2016-04-27 448 /* Remove reply code, which are the first 2 characters of 89da76fde68de1 Sinclair Yeh 2016-04-27 449 * the reply 89da76fde68de1 Sinclair Yeh 2016-04-27 450 */ 89da76fde68de1 Sinclair Yeh 2016-04-27 451 reply_len = max(reply_len - 2, (size_t) 0); 89da76fde68de1 Sinclair Yeh 2016-04-27 452 reply_len = min(reply_len, *length); 89da76fde68de1 Sinclair Yeh 2016-04-27 453 89da76fde68de1 Sinclair Yeh 2016-04-27 454 if (reply_len > 0) 89da76fde68de1 Sinclair Yeh 2016-04-27 455 memcpy(buffer, reply + 2, reply_len); 89da76fde68de1 Sinclair Yeh 2016-04-27 456 } 89da76fde68de1 Sinclair Yeh 2016-04-27 457 89da76fde68de1 Sinclair Yeh 2016-04-27 458 *length = reply_len; 89da76fde68de1 Sinclair Yeh 2016-04-27 459 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 460 dma_free_coherent(dev, reply_len + 1, reply, reply_handle); 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 461 dma_free_coherent(dev, req_len, msg, req_handle); 89da76fde68de1 Sinclair Yeh 2016-04-27 462 f37230c0ad4810 Thomas Hellstrom 2018-05-23 463 return 0; f37230c0ad4810 Thomas Hellstrom 2018-05-23 464 f37230c0ad4810 Thomas Hellstrom 2018-05-23 465 out_msg: f37230c0ad4810 Thomas Hellstrom 2018-05-23 466 vmw_close_channel(&channel); 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 467 dma_free_coherent(dev, reply_len + 1, reply, reply_handle); f37230c0ad4810 Thomas Hellstrom 2018-05-23 468 out_open: f37230c0ad4810 Thomas Hellstrom 2018-05-23 469 *length = 0; f37230c0ad4810 Thomas Hellstrom 2018-05-23 470 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 471 DRM_ERROR("Failed to get guest info \"%s\".", guest_info_param); 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 472 dma_free_coherent(dev, req_len, msg, req_handle); f37230c0ad4810 Thomas Hellstrom 2018-05-23 473 return -EINVAL; 89da76fde68de1 Sinclair Yeh 2016-04-27 474 } 89da76fde68de1 Sinclair Yeh 2016-04-27 475:::::: The code at line 441 was first introduced by commit
::::::f37230c0ad481091bc136788ff8b37dc86300c6ddrm/vmwgfx: Fix host logging / guestinfo reading error paths
Quoted 6 lines
:::::: TO: Thomas Hellstrom <[email protected]> :::::: CC: Thomas Hellstrom <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/[email protected] Intel Corporation
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi, Nathan,
Quoted 15 lines · Nathan Chancellor
Quoted 6 lines · Thomas Hellström (VMware)
From: Thomas Hellstrom <[email protected]>
With AMD-SEV high-bandwidth port messaging runs into trouble since the message content is encrypted using the vm-specific key, and the hypervisor is unable to read it.
Quoted 6 lines
So use unencrypted dma-coherent bounce buffers for temporary message storage space. Allocating that memory is expensive so a future optimization might include a static unencrypted memory area for messages.
Signed-off-by Thomas Hellstrom <[email protected]>Reviewed-by Brian Paul <[email protected]>Hi Thomas,
Quoted 7 lines
The 0day team has been doing clang builds for us and sending the results to our mailing list for triage; this patch causes the following warning. Seems legitimate, mind taking a look at it and resolving it how you see fit?
Cheers,
Nathan
This should be harmless as dma_free_coherent() with reply == NULL is a nop, but anyway I'll respin to silence the warning.
Thanks,
Thomas
Quoted 128 lines · kbuild test robot
Quoted 127 lines
CC: [email protected]
In-Reply-To: <[email protected]>
References: <[email protected]>
TO: "Thomas Hellström (VMware)" <[email protected]>
CC: [email protected], Thomas Hellstrom <[email protected]>, Brian Paul <[email protected]>, Thomas Hellstrom <[email protected]>, Brian Paul <[email protected]>
CC: Thomas Hellstrom <[email protected]>, Brian Paul <[email protected]>Hi "Thomas,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[also build test WARNING on v5.4-rc7 next-20191113]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]url: https://github.com/0day-ci/linux/commits/Thomas-Hellstr-m-VMware/drm-vmwgfx-Use-dma-coherent-memory-for-high-bandwidth-port-messaging/20191114-020818 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 0e3f1ad80fc8cb0c517fd9a9afb22752b741fa76 config: x86_64-rhel-7.6 (attached as .config) compiler: clang version 10.0.0 (git://gitmirror/llvm_project 335ac2eb662ce5f1888e2a50310b01fba2d40d68) reproduce: # save the attached .config to linux build tree make ARCH=x86_64If you fix the issue, kindly add following tag
Reported-by kbuild test robot <[email protected]>All warnings (new ones prefixed by >>):
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/vmwgfx/vmwgfx_msg.c:441:6: warning: variable 'reply_handle' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]if (vmw_send_msg(&channel, msg) || ^~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/vmwgfx/vmwgfx_msg.c:467:47: note: uninitialized use occurs here dma_free_coherent(dev, reply_len + 1, reply, reply_handle); ^~~~~~~~~~~~ drivers/gpu/drm/vmwgfx/vmwgfx_msg.c:441:6: note: remove the '||' if its condition is always false if (vmw_send_msg(&channel, msg) || ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/vmwgfx/vmwgfx_msg.c:421:37: note: initialize the variable 'reply_handle' to silence this warning dma_addr_t req_handle, reply_handle; ^ = 0 1 warning generated.vim +441
drivers/gpu/drm/vmwgfx/vmwgfx_msg.c89da76fde68de1 Sinclair Yeh 2016-04-27 400 89da76fde68de1 Sinclair Yeh 2016-04-27 401 89da76fde68de1 Sinclair Yeh 2016-04-27 402 /** 89da76fde68de1 Sinclair Yeh 2016-04-27 403 * vmw_host_get_guestinfo: Gets a GuestInfo parameter 89da76fde68de1 Sinclair Yeh 2016-04-27 404 * 89da76fde68de1 Sinclair Yeh 2016-04-27 405 * Gets the value of a GuestInfo.* parameter. The value returned will be in 89da76fde68de1 Sinclair Yeh 2016-04-27 406 * a string, and it is up to the caller to post-process. 89da76fde68de1 Sinclair Yeh 2016-04-27 407 * 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 408 * @dev: Pointer to struct device used for coherent memory allocation 89da76fde68de1 Sinclair Yeh 2016-04-27 409 * @guest_info_param: Parameter to get, e.g. GuestInfo.svga.gl3 89da76fde68de1 Sinclair Yeh 2016-04-27 410 * @buffer: if NULL, *reply_len will contain reply size. 89da76fde68de1 Sinclair Yeh 2016-04-27 411 * @length: size of the reply_buf. Set to size of reply upon return 89da76fde68de1 Sinclair Yeh 2016-04-27 412 * 89da76fde68de1 Sinclair Yeh 2016-04-27 413 * Returns: 0 on success 89da76fde68de1 Sinclair Yeh 2016-04-27 414 */ 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 415 int vmw_host_get_guestinfo(struct device *dev, const char *guest_info_param, 89da76fde68de1 Sinclair Yeh 2016-04-27 416 char *buffer, size_t *length) 89da76fde68de1 Sinclair Yeh 2016-04-27 417 { 89da76fde68de1 Sinclair Yeh 2016-04-27 418 struct rpc_channel channel; 89da76fde68de1 Sinclair Yeh 2016-04-27 419 char *msg, *reply = NULL; 6073a09210e06f Himanshu Jha 2018-03-22 420 size_t reply_len = 0; 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 421 dma_addr_t req_handle, reply_handle; 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 422 int req_len = strlen("info-get ") + strlen(guest_info_param) + 1; 89da76fde68de1 Sinclair Yeh 2016-04-27 423 89da76fde68de1 Sinclair Yeh 2016-04-27 424 if (!vmw_msg_enabled) 89da76fde68de1 Sinclair Yeh 2016-04-27 425 return -ENODEV; 89da76fde68de1 Sinclair Yeh 2016-04-27 426 89da76fde68de1 Sinclair Yeh 2016-04-27 427 if (!guest_info_param || !length) 89da76fde68de1 Sinclair Yeh 2016-04-27 428 return -EINVAL; 89da76fde68de1 Sinclair Yeh 2016-04-27 429 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 430 msg = dma_alloc_coherent(dev, req_len, &req_handle, GFP_KERNEL); 1a4adb05632e90 Ravikant B Sharma 2016-11-08 431 if (!msg) { 3fbeccf8ceb165 Thomas Hellstrom 2018-06-20 432 DRM_ERROR("Cannot allocate memory to get guest info \"%s\".", 3fbeccf8ceb165 Thomas Hellstrom 2018-06-20 433 guest_info_param); 89da76fde68de1 Sinclair Yeh 2016-04-27 434 return -ENOMEM; 89da76fde68de1 Sinclair Yeh 2016-04-27 435 } 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 436 snprintf(msg, req_len, "info-get %s", guest_info_param); 89da76fde68de1 Sinclair Yeh 2016-04-27 437 f37230c0ad4810 Thomas Hellstrom 2018-05-23 438 if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM)) f37230c0ad4810 Thomas Hellstrom 2018-05-23 439 goto out_open; 89da76fde68de1 Sinclair Yeh 2016-04-27 440 f37230c0ad4810 Thomas Hellstrom 2018-05-23 @441 if (vmw_send_msg(&channel, msg) || 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 442 vmw_recv_msg(dev, &channel, (void *) &reply, &reply_len, 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 443 &reply_handle)) f37230c0ad4810 Thomas Hellstrom 2018-05-23 444 goto out_msg; 89da76fde68de1 Sinclair Yeh 2016-04-27 445 f37230c0ad4810 Thomas Hellstrom 2018-05-23 446 vmw_close_channel(&channel); 89da76fde68de1 Sinclair Yeh 2016-04-27 447 if (buffer && reply && reply_len > 0) { 89da76fde68de1 Sinclair Yeh 2016-04-27 448 /* Remove reply code, which are the first 2 characters of 89da76fde68de1 Sinclair Yeh 2016-04-27 449 * the reply 89da76fde68de1 Sinclair Yeh 2016-04-27 450 */ 89da76fde68de1 Sinclair Yeh 2016-04-27 451 reply_len = max(reply_len - 2, (size_t) 0); 89da76fde68de1 Sinclair Yeh 2016-04-27 452 reply_len = min(reply_len, *length); 89da76fde68de1 Sinclair Yeh 2016-04-27 453 89da76fde68de1 Sinclair Yeh 2016-04-27 454 if (reply_len > 0) 89da76fde68de1 Sinclair Yeh 2016-04-27 455 memcpy(buffer, reply + 2, reply_len); 89da76fde68de1 Sinclair Yeh 2016-04-27 456 } 89da76fde68de1 Sinclair Yeh 2016-04-27 457 89da76fde68de1 Sinclair Yeh 2016-04-27 458 *length = reply_len; 89da76fde68de1 Sinclair Yeh 2016-04-27 459 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 460 dma_free_coherent(dev, reply_len + 1, reply, reply_handle); 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 461 dma_free_coherent(dev, req_len, msg, req_handle); 89da76fde68de1 Sinclair Yeh 2016-04-27 462 f37230c0ad4810 Thomas Hellstrom 2018-05-23 463 return 0; f37230c0ad4810 Thomas Hellstrom 2018-05-23 464 f37230c0ad4810 Thomas Hellstrom 2018-05-23 465 out_msg: f37230c0ad4810 Thomas Hellstrom 2018-05-23 466 vmw_close_channel(&channel); 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 467 dma_free_coherent(dev, reply_len + 1, reply, reply_handle); f37230c0ad4810 Thomas Hellstrom 2018-05-23 468 out_open: f37230c0ad4810 Thomas Hellstrom 2018-05-23 469 *length = 0; f37230c0ad4810 Thomas Hellstrom 2018-05-23 470 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 471 DRM_ERROR("Failed to get guest info \"%s\".", guest_info_param); 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 472 dma_free_coherent(dev, req_len, msg, req_handle); f37230c0ad4810 Thomas Hellstrom 2018-05-23 473 return -EINVAL; 89da76fde68de1 Sinclair Yeh 2016-04-27 474 } 89da76fde68de1 Sinclair Yeh 2016-04-27 475:::::: The code at line 441 was first introduced by commit
::::::f37230c0ad481091bc136788ff8b37dc86300c6ddrm/vmwgfx: Fix host logging / guestinfo reading error paths
Quoted 6 lines
Quoted 6 lines
:::::: TO: Thomas Hellstrom <[email protected]> :::::: CC: Thomas Hellstrom <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/[email protected] Intel Corporation
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel