From patchwork Thu Jul 23 09:02:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 51388 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id B0D3C22A9E for ; Thu, 23 Jul 2015 09:03:11 +0000 (UTC) Received: by wilm20 with SMTP id m20sf44702431wil.2 for ; Thu, 23 Jul 2015 02:03:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:cc:subject:content-type:content-transfer-encoding :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=jarKPW/JjgHTus7eLbUnVvIoFF2bpOmYzCPRsHFlbU0=; b=PmfFNgpDA5dDFtaWAvtvl88mIeGqBPFDV8qFudDcFUkcs8wm5Vc2TVstjCLP9jzK3t q2fYU8ffnaBgKFpNggMs4lV2lHiREiRKSUr22gzabHEhLNEErSGvdJ9mkx+mKro38GFI po1QLmAxneqRNgio81SmsPctBE2KD6oB37cDOjT5Y0Ald0mJZN9jXmDQl5SY+mOTqWuO hirazdmCBrcq3oGUOIoSnctQ7w1tNwp9cvUMlSYdYk5B9eAa8gkpbgfxJpHvkT4zW0VM Xv2CORXUhlJ1E6+ok7ggjiMENyPYWlYb/XLlzRJ5ix8nhYwZw5M7JYwd07eub9oqeAG9 YAQg== X-Gm-Message-State: ALoCoQmEL93KdundW9y3ZIF0S2AYLsecVa+c7fTk/xlsPhw1W/blGiBIdMCyARJYLl9ZTnu3iQ6U X-Received: by 10.113.3.8 with SMTP id bs8mr1649691lbd.23.1437642190920; Thu, 23 Jul 2015 02:03:10 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.242.2 with SMTP id wm2ls187809lac.38.gmail; Thu, 23 Jul 2015 02:03:10 -0700 (PDT) X-Received: by 10.152.203.233 with SMTP id kt9mr5738155lac.99.1437642190775; Thu, 23 Jul 2015 02:03:10 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id oh3si3585284lbb.45.2015.07.23.02.03.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Jul 2015 02:03:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbbqi7 with SMTP id qi7so72794019lbb.3 for ; Thu, 23 Jul 2015 02:03:10 -0700 (PDT) X-Received: by 10.152.37.228 with SMTP id b4mr6525713lak.117.1437642190665; Thu, 23 Jul 2015 02:03:10 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp422294lba; Thu, 23 Jul 2015 02:03:09 -0700 (PDT) X-Received: by 10.107.157.4 with SMTP id g4mr11763505ioe.66.1437642189152; Thu, 23 Jul 2015 02:03:09 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o10si3858474ioe.121.2015.07.23.02.03.08; Thu, 23 Jul 2015 02:03:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752262AbbGWJDH (ORCPT + 6 others); Thu, 23 Jul 2015 05:03:07 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:37353 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752106AbbGWJDC (ORCPT ); Thu, 23 Jul 2015 05:03:02 -0400 Received: by wibud3 with SMTP id ud3so208619086wib.0 for ; Thu, 23 Jul 2015 02:03:01 -0700 (PDT) X-Received: by 10.194.5.103 with SMTP id r7mr13153012wjr.47.1437642181321; Thu, 23 Jul 2015 02:03:01 -0700 (PDT) Received: from [192.168.27.147] ([37.157.136.206]) by smtp.googlemail.com with ESMTPSA id r8sm20837765wiz.5.2015.07.23.02.02.59 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Jul 2015 02:03:00 -0700 (PDT) Message-ID: <55B0ADB6.6020304@linaro.org> Date: Thu, 23 Jul 2015 12:02:46 +0300 From: Stanimir Varbanov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: robdclark@gmail.com CC: "linux-arm-msm@vger.kernel.org" , Nicolas Dechesne Subject: drm: msm: run into issues Sender: linux-arm-msm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: stanimir.varbanov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Hi Rob, I run into issues with msm drm driver while implementing a test application which use v4l2 vidc (venus) decoder driver to decode videos and msm drm driver to display the decoded frames. The v4l2 test application use msm drm as dmabuf exporter by DRM_IOCTL_MODE_CREATE_DUMB and DRM_IOCTL_PRIME_HANDLE_TO_FD from libdrm. So far the test app is able to decode and display using dmabuf type of buffers (so, to honest it is slower than using mmap & memcpy but this is another story). The problems start when destroying drm buffers by call to DRM_IOCTL_MODE_DESTROY_DUMB ioctl and also when closing dmabuf fd. The issues I'm seeing are: - the first and the major one happens in msm_gem_free_object() where we are trying to free sg table which table is already freed by drm_prime core in dmabuf .detach callback. In fact the msm_gem_free_object is called by dmabuf .release callback which should be happened after .detach. I find weird to call sg_table_free in .detach callback and did not understand why it is there. - the second one is again in msm_gem.c::put_pages dma_unmap_sg call. Some background, vidc (venus) driver use dma-iommu infrastructure copped from qcom downstream kernel to abstract iommu map/unmap [1]. On the other side when drm driver is exporter it use swiotbl [2] dma map operations, dma_map_sg will fill sg->dma_address with phy addresses. So when vidc call dma_map_sg the sg dma_address is filled with iova address then drm call dma_unmap_sg expecting phy addresses. If I didn't express myself well, see the hack bellow which I made to prevent kernel crash. Any thoughts? diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 7482b06cd08f..c4c0f8084b11 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -155,10 +155,10 @@ static void drm_gem_map_detach(struct dma_buf *dma_buf, if (prime_attach->dir != DMA_NONE) dma_unmap_sg(attach->dev, sgt->sgl, sgt->nents, prime_attach->dir); - sg_free_table(sgt); +/* sg_free_table(sgt);*/ } - kfree(sgt); +/* kfree(sgt);*/ kfree(prime_attach); attach->priv = NULL; } diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index 9b6220140e99..a78a24ca2fda 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -116,9 +116,10 @@ static void put_pages(struct drm_gem_object *obj) /* For non-cached buffers, ensure the new pages are clean * because display controller, GPU, etc. are not coherent: */ - if (msm_obj->flags & (MSM_BO_WC|MSM_BO_UNCACHED)) +/* if (msm_obj->flags & (MSM_BO_WC|MSM_BO_UNCACHED)) dma_unmap_sg(obj->dev->dev, msm_obj->sgt->sgl, msm_obj->sgt->nents, DMA_BIDIRECTIONAL); +*/ sg_free_table(msm_obj->sgt); kfree(msm_obj->sgt);