Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4037997ybe; Mon, 9 Sep 2019 03:13:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVzTZvA+MJZ1ZRA91n9127J4g8cH4hw0rtqfIGqLuOK6jtmschWV83IfgPDX2kf2Z9LiQU X-Received: by 2002:a50:9eee:: with SMTP id a101mr1002420edf.128.1568023989174; Mon, 09 Sep 2019 03:13:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568023989; cv=none; d=google.com; s=arc-20160816; b=lwRHWvYpEwOisPnGvWDgLNEB6Esj3hLzxVKKHn8IoVgJl+uoiRpSRpkSn9YZImIoi/ 7vQJR68NPbaWqlJgHFhU88cpsYdbGJ1azEeT3e0Ax41vqnRhVAdpjXgo58m+HfMmX54V IFFRtZRz6OY/gTexc2tT5K5s4oGDs1tc2moxFsizwl7eCiH9x6VITZZ1/fYYlRAOpKjo OF5vJFuWBn1xZRFe1AzeTlZrhg9cEl99+SbNT8UyYAvJGmXR4dEfeNYv6FKksMfsH5n+ iRDU0IfZ8D0bBJzqSCqkxteAFvGo7Hm6PYuMukAnPXk0K+3QzuSvlPDZt218BAGI7vKj 91lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=92tXCJo8jjZnu68Eo68xp1zcbvqvhIZ+1JzhkizuUIc=; b=Yxup0XmklRe6Re8rcYxIy0+Q3231lOAFUv8SJeasxOTDye35e0KSQIQ9OXWxDFfjr5 jKa4ufaJPdTu+V5M8cUG/WxOXzTPY7QtqpHWdEe78n6Y+TBSZDsVuu6PIMHPcPCJ7W3B F3wsgLgH0+yjh3OZGWPNiu3oYunWVB4HkDn8cCk1KWFSEh2dI8Ug80I1lAdZtOYvAwMc VgU8PEcJLhXcijSkMovJ5VkiiCvsK0lsfI60hIekkNs5ygS2cVPWPJGoJHS7wlDx2Kur UZ2S9Pyno+KbzmljrtaV5dUtAddDoRmE2DIdP4/1PPDSM9y5JtCBFgCW96MGus5kiqvi dTOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WmGrhzCA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b4si6661540edk.331.2019.09.09.03.12.45; Mon, 09 Sep 2019 03:13:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WmGrhzCA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726407AbfIHMqq (ORCPT + 99 others); Sun, 8 Sep 2019 08:46:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:34474 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730446AbfIHMql (ORCPT ); Sun, 8 Sep 2019 08:46:41 -0400 Received: from localhost (unknown [62.28.240.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3E29D20644; Sun, 8 Sep 2019 12:46:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567946800; bh=ERRG1WAcuwqcV2Fq65t+WAXGXS4wFs2DDWfRyDNA7a8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WmGrhzCAP2t99K9s7Zclpta2Qp8CjkHrtGSR4QBPXJwLgaNnK70GVLQL8Kisozd6x 4ZGc/hyVJpucs1bzDVyHG3fIRkxCbPgDUjz9CSCTN7M1WYWQWKQYtuH6Q3adVOa8Xy 2bqLdGzYXoXGF85WgUlLg2id24ls6Myb+5HpCav8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexandre Courbot , Tomasz Figa , CK Hu , Sasha Levin Subject: [PATCH 4.14 09/40] drm/mediatek: set DMA max segment size Date: Sun, 8 Sep 2019 13:41:42 +0100 Message-Id: <20190908121118.317307114@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190908121114.260662089@linuxfoundation.org> References: <20190908121114.260662089@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 070955558e820b9a89c570b91b1f21762f62b288 ] This driver requires imported PRIME buffers to appear contiguously in its IO address space. Make sure this is the case by setting the maximum DMA segment size to a more suitable value than the default 64KB. Signed-off-by: Alexandre Courbot Reviewed-by: Tomasz Figa Signed-off-by: CK Hu Signed-off-by: Sasha Levin --- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 35 ++++++++++++++++++++++++-- drivers/gpu/drm/mediatek/mtk_drm_drv.h | 2 ++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c index 4a89cd2e4f1c5..034b50080304f 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c @@ -185,6 +185,7 @@ static int mtk_drm_kms_init(struct drm_device *drm) struct mtk_drm_private *private = drm->dev_private; struct platform_device *pdev; struct device_node *np; + struct device *dma_dev; int ret; if (!iommu_present(&platform_bus_type)) @@ -242,7 +243,29 @@ static int mtk_drm_kms_init(struct drm_device *drm) goto err_component_unbind; } - private->dma_dev = &pdev->dev; + dma_dev = &pdev->dev; + private->dma_dev = dma_dev; + + /* + * Configure the DMA segment size to make sure we get contiguous IOVA + * when importing PRIME buffers. + */ + if (!dma_dev->dma_parms) { + private->dma_parms_allocated = true; + dma_dev->dma_parms = + devm_kzalloc(drm->dev, sizeof(*dma_dev->dma_parms), + GFP_KERNEL); + } + if (!dma_dev->dma_parms) { + ret = -ENOMEM; + goto err_component_unbind; + } + + ret = dma_set_max_seg_size(dma_dev, (unsigned int)DMA_BIT_MASK(32)); + if (ret) { + dev_err(dma_dev, "Failed to set DMA segment size\n"); + goto err_unset_dma_parms; + } /* * We don't use the drm_irq_install() helpers provided by the DRM @@ -252,13 +275,16 @@ static int mtk_drm_kms_init(struct drm_device *drm) drm->irq_enabled = true; ret = drm_vblank_init(drm, MAX_CRTC); if (ret < 0) - goto err_component_unbind; + goto err_unset_dma_parms; drm_kms_helper_poll_init(drm); drm_mode_config_reset(drm); return 0; +err_unset_dma_parms: + if (private->dma_parms_allocated) + dma_dev->dma_parms = NULL; err_component_unbind: component_unbind_all(drm->dev, drm); err_config_cleanup: @@ -269,9 +295,14 @@ err_config_cleanup: static void mtk_drm_kms_deinit(struct drm_device *drm) { + struct mtk_drm_private *private = drm->dev_private; + drm_kms_helper_poll_fini(drm); drm_atomic_helper_shutdown(drm); + if (private->dma_parms_allocated) + private->dma_dev->dma_parms = NULL; + component_unbind_all(drm->dev, drm); drm_mode_config_cleanup(drm); } diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.h b/drivers/gpu/drm/mediatek/mtk_drm_drv.h index c3378c452c0a0..445dd45e65ebc 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.h @@ -56,6 +56,8 @@ struct mtk_drm_private { } commit; struct drm_atomic_state *suspend_state; + + bool dma_parms_allocated; }; extern struct platform_driver mtk_ddp_driver; -- 2.20.1