From patchwork Sun Nov 14 22:23:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12618437 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6696CC43217 for ; Sun, 14 Nov 2021 22:24:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 41EB3611C9 for ; Sun, 14 Nov 2021 22:24:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233593AbhKNW1T (ORCPT ); Sun, 14 Nov 2021 17:27:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231877AbhKNW1R (ORCPT ); Sun, 14 Nov 2021 17:27:17 -0500 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4603C061766; Sun, 14 Nov 2021 14:24:18 -0800 (PST) Received: by mail-lf1-x12b.google.com with SMTP id b1so32406558lfs.13; Sun, 14 Nov 2021 14:24:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LzfnJDYRPIbOYnQp6TazcGixcuXnMsld1zX3xBTAG/4=; b=Tu3DHxlSGfZYgLzq1BKOtWw+D8xZBCRnu5s2IBd9G5bdM5yJpKCKVVyMc6yYjrA0Mi WFw3hvBi3WNZ8AO4UfHT5xRTV77SfSfgAgK5mTjJdm9Hkg+Vhc04FXPSaNMlbkyODsHI 1VOj+0ANS5tYI0Zdp/3Vxo54Q8mFduyLPvucPrhpAf5BrUVALgBzR57kaDpGPcWaOXpq 4WZCj7IBNQ5BAVJGXkHl/Qin4oeuu1H8uWhAhtQrQj/ghbafSQBP1ZXPppb9fPWAPO2r DYEGTE7h3WzZ/HDcQROz42XOGCitd0aNxRy8i36VsEh7j9wWCLUbm89caLZdat4qeeSw /VCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LzfnJDYRPIbOYnQp6TazcGixcuXnMsld1zX3xBTAG/4=; b=LQQlSJHnyRLe9FWVxqw/EOVMQZS2LGUETCWjR+vYGF/hATlwwB8Rzv5bT4bGTxNec0 jpMujTe4DLIUG3n2cI2QGV6Mjur7eVBq3Xtdz6D6wkvEzszX33HUC9gYRLKYh/JHpkx+ ywG8vIVy5O1Vii0+Oxkft3OzKwvZYm3z4YqGsw2Wv8X9+lb/Jfo1icaFkJ1JrWaL/Guz KMXovfxEacEDQp7F2atZu3zeDtRGeFiqAg6cstVl7C8qZj6I+dSNdz8JrrA3jqHpgyG7 Ugvh4BLXwBqdG8B4y0x0rpCoQ+qsGBHzuNeBYcgfClUwRjmtNhm4e9fLOio4pFZVfbaI F0UA== X-Gm-Message-State: AOAM5312TG7qXT3oNqvmrCMOkf9i/TRk+pDFZCy5kLABbp3ClGEGdabS 5xECiJM2V9if79pcrArgwmE= X-Google-Smtp-Source: ABdhPJw4xMnJaOoDMfFen4/iR4euxDB7rJafPi3c/TWp5BwoS0xRps4qLkqO785pIFyyTZagtMK40A== X-Received: by 2002:ac2:5615:: with SMTP id v21mr32118034lfd.112.1636928657147; Sun, 14 Nov 2021 14:24:17 -0800 (PST) Received: from localhost.localdomain (46-138-46-211.dynamic.spd-mgts.ru. [46.138.46.211]) by smtp.gmail.com with ESMTPSA id d6sm1223339lfi.52.2021.11.14.14.24.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Nov 2021 14:24:16 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mauro Carvalho Chehab , Greg Kroah-Hartman , Anton Bambura , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/3] media: staging: tegra-vde: Support reference picture marking Date: Mon, 15 Nov 2021 01:23:51 +0300 Message-Id: <20211114222353.22435-2-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211114222353.22435-1-digetx@gmail.com> References: <20211114222353.22435-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Thierry Reding Tegra114 and Tegra124 support reference picture marking, which will cause BSEV to write picture marking data to SDRAM. Make sure there is a valid destination address for that data to avoid error messages from the memory controller. [digetx@gmail.com: added BO support and moved secure BO allocation to kernel] Tested-by: Anton Bambura # T114 ASUS TF701T Signed-off-by: Thierry Reding Signed-off-by: Dmitry Osipenko --- drivers/staging/media/tegra-vde/vde.c | 120 +++++++++++++++++++++++++- drivers/staging/media/tegra-vde/vde.h | 18 ++++ 2 files changed, 137 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/tegra-vde/vde.c b/drivers/staging/media/tegra-vde/vde.c index 859f60a70904..42da57f191ef 100644 --- a/drivers/staging/media/tegra-vde/vde.c +++ b/drivers/staging/media/tegra-vde/vde.c @@ -85,6 +85,92 @@ static int tegra_vde_wait_mbe(struct tegra_vde *vde) (tmp >= 0x10), 1, 100); } +static struct tegra_vde_bo * +tegra_vde_alloc_bo(struct tegra_vde *vde, enum dma_data_direction dma_dir, + size_t size) +{ + struct device *dev = vde->miscdev.parent; + struct tegra_vde_bo *bo; + int err; + + bo = kzalloc(sizeof(*bo), GFP_KERNEL); + if (!bo) + return NULL; + + bo->vde = vde; + bo->size = size; + bo->dma_dir = dma_dir; + bo->dma_attrs = DMA_ATTR_WRITE_COMBINE | + DMA_ATTR_NO_KERNEL_MAPPING; + + if (!vde->domain) + bo->dma_attrs |= DMA_ATTR_FORCE_CONTIGUOUS; + + bo->dma_cookie = dma_alloc_attrs(dev, bo->size, &bo->dma_handle, + GFP_KERNEL, bo->dma_attrs); + if (!bo->dma_cookie) { + dev_err(dev, "Failed to allocate DMA buffer of size: %zu\n", + bo->size); + goto free_bo; + } + + err = dma_get_sgtable_attrs(dev, &bo->sgt, bo->dma_cookie, + bo->dma_handle, bo->size, bo->dma_attrs); + if (err) { + dev_err(dev, "Failed to get DMA buffer SG table: %d\n", err); + goto free_attrs; + } + + err = dma_map_sgtable(dev, &bo->sgt, bo->dma_dir, bo->dma_attrs); + if (err) { + dev_err(dev, "Failed to map DMA buffer SG table: %d\n", err); + goto free_table; + } + + if (vde->domain) { + err = tegra_vde_iommu_map(vde, &bo->sgt, &bo->iova, bo->size); + if (err) { + dev_err(dev, "Failed to map DMA buffer IOVA: %d\n", err); + goto unmap_sgtable; + } + + bo->dma_addr = iova_dma_addr(&vde->iova, bo->iova); + } else { + bo->dma_addr = sg_dma_address(bo->sgt.sgl); + } + + return bo; + +unmap_sgtable: + dma_unmap_sgtable(dev, &bo->sgt, bo->dma_dir, bo->dma_attrs); +free_table: + sg_free_table(&bo->sgt); +free_attrs: + dma_free_attrs(dev, bo->size, bo->dma_cookie, bo->dma_handle, + bo->dma_attrs); +free_bo: + kfree(bo); + + return NULL; +} + +static void tegra_vde_free_bo(struct tegra_vde_bo *bo) +{ + struct tegra_vde *vde = bo->vde; + struct device *dev = vde->miscdev.parent; + + if (vde->domain) + tegra_vde_iommu_unmap(vde, bo->iova); + + dma_unmap_sgtable(dev, &bo->sgt, bo->dma_dir, bo->dma_attrs); + + sg_free_table(&bo->sgt); + + dma_free_attrs(dev, bo->size, bo->dma_cookie, bo->dma_handle, + bo->dma_attrs); + kfree(bo); +} + static int tegra_vde_setup_mbe_frame_idx(struct tegra_vde *vde, unsigned int refs_nb, bool setup_refs) @@ -425,6 +511,9 @@ static int tegra_vde_setup_hw_context(struct tegra_vde *vde, tegra_vde_writel(vde, bitstream_data_addr, vde->sxe, 0x6C); + if (vde->soc->supports_ref_pic_marking) + tegra_vde_writel(vde, vde->secure_bo->dma_addr, vde->sxe, 0x7c); + value = 0x10000005; value |= ctx->pic_width_in_mbs << 11; value |= ctx->pic_height_in_mbs << 3; @@ -994,6 +1083,8 @@ static int tegra_vde_probe(struct platform_device *pdev) platform_set_drvdata(pdev, vde); + vde->soc = of_device_get_match_data(&pdev->dev); + vde->sxe = devm_platform_ioremap_resource_byname(pdev, "sxe"); if (IS_ERR(vde->sxe)) return PTR_ERR(vde->sxe); @@ -1119,6 +1210,12 @@ static int tegra_vde_probe(struct platform_device *pdev) pm_runtime_put(dev); + vde->secure_bo = tegra_vde_alloc_bo(vde, DMA_FROM_DEVICE, 4096); + if (!vde->secure_bo) { + dev_err(dev, "Failed to allocate secure BO\n"); + goto err_pm_runtime; + } + return 0; err_pm_runtime: @@ -1142,6 +1239,8 @@ static int tegra_vde_remove(struct platform_device *pdev) struct tegra_vde *vde = platform_get_drvdata(pdev); struct device *dev = &pdev->dev; + tegra_vde_free_bo(vde->secure_bo); + /* * As it increments RPM usage_count even on errors, we don't need to * check the returned code here. @@ -1214,8 +1313,27 @@ static const struct dev_pm_ops tegra_vde_pm_ops = { tegra_vde_pm_resume) }; +static const struct tegra_vde_soc tegra124_vde_soc = { + .supports_ref_pic_marking = true, +}; + +static const struct tegra_vde_soc tegra114_vde_soc = { + .supports_ref_pic_marking = true, +}; + +static const struct tegra_vde_soc tegra30_vde_soc = { + .supports_ref_pic_marking = false, +}; + +static const struct tegra_vde_soc tegra20_vde_soc = { + .supports_ref_pic_marking = false, +}; + static const struct of_device_id tegra_vde_of_match[] = { - { .compatible = "nvidia,tegra20-vde", }, + { .compatible = "nvidia,tegra124-vde", .data = &tegra124_vde_soc }, + { .compatible = "nvidia,tegra114-vde", .data = &tegra114_vde_soc }, + { .compatible = "nvidia,tegra30-vde", .data = &tegra30_vde_soc }, + { .compatible = "nvidia,tegra20-vde", .data = &tegra20_vde_soc }, { }, }; MODULE_DEVICE_TABLE(of, tegra_vde_of_match); diff --git a/drivers/staging/media/tegra-vde/vde.h b/drivers/staging/media/tegra-vde/vde.h index 5561291b0c88..bbd42b8d9991 100644 --- a/drivers/staging/media/tegra-vde/vde.h +++ b/drivers/staging/media/tegra-vde/vde.h @@ -24,6 +24,22 @@ struct iommu_domain; struct reset_control; struct dma_buf_attachment; +struct tegra_vde_soc { + bool supports_ref_pic_marking; +}; + +struct tegra_vde_bo { + struct iova *iova; + struct sg_table sgt; + struct tegra_vde *vde; + enum dma_data_direction dma_dir; + unsigned long dma_attrs; + dma_addr_t dma_handle; + dma_addr_t dma_addr; + void *dma_cookie; + size_t size; +}; + struct tegra_vde { void __iomem *sxe; void __iomem *bsev; @@ -48,6 +64,8 @@ struct tegra_vde { struct iova_domain iova; struct iova *iova_resv_static_addresses; struct iova *iova_resv_last_page; + const struct tegra_vde_soc *soc; + struct tegra_vde_bo *secure_bo; dma_addr_t iram_lists_addr; u32 *iram; }; From patchwork Sun Nov 14 22:23:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12618441 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD4A9C433FE for ; Sun, 14 Nov 2021 22:24:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B761961156 for ; Sun, 14 Nov 2021 22:24:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234872AbhKNW1X (ORCPT ); Sun, 14 Nov 2021 17:27:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231968AbhKNW1R (ORCPT ); Sun, 14 Nov 2021 17:27:17 -0500 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DF77C061767; Sun, 14 Nov 2021 14:24:19 -0800 (PST) Received: by mail-lf1-x130.google.com with SMTP id bi37so33329609lfb.5; Sun, 14 Nov 2021 14:24:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KAUkz2SRPh78XWLAzuTkM/CtAlT6USvDgmC5PSJlsC4=; b=IkfTsXNX2YKbkn4lfSWNNpx04E2sE+JT0mqnydwTWOcL3viNEeFO8WQbWDiUIuMv9L 9+Z4blaVKFFiq288OO/ZHDd10I55kjAuCcDSPJGXij4zWGSmbPjJOg0CZwXuEbWwsfqz JzeGPtv3t3UZmHiPX+xOfMU8ZdbGwP3df5dAkLPKAmx6I9mV44g5SGX0elwaEzdX6Q0n xKjoDDS21+WDJTGY//tmTUVJbQQ5L7/kP9NWpZiIVidetsmkWsfDv2sQDm3ez2opda6D 7hrI/gJ8M6cUQ6H1cG7dyRFEfmdGi654RIlbERMeajRFKQ/5OsRKN7oMRddFimPzGKb2 Njjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KAUkz2SRPh78XWLAzuTkM/CtAlT6USvDgmC5PSJlsC4=; b=4tk0jVY6vbneYblVjTKuY1mmMSaht5lr1+UmQQZYQkN5yjZ3VBo/+kTU4rNCzv3OWv 5uql1usnRre10E9P/WBbqLhZQl3nh5tAEBxJ8b+dYxFRW9YgwS9xwJCAr4MKPDQqViLj 8eOCoO6DzoxuOC0wbEMwb7ptnzLWSV4RLzMkBk2nU0dWq+Rma7cn3hdKlU5kB0b3iCF2 12sZq4zelZy+AulpTOFY4Yj3elqTY7LFFItoLU4aFbPv2AVUI18SKA3yXFjI03bGFajR r4mHeU10/dOBbXraFl4+p/XejoQ4CY1x9T1Y6VlKuQpNtUcFb4D1sHMdEZ1YrD+Qgv+K 33Ng== X-Gm-Message-State: AOAM531aIHQG5DNpB3a257cVlsx9FBqDeWMkYUDSTtQlJjImva6iBWCE nTLV3on8vrTnyeJxqsvBRsM= X-Google-Smtp-Source: ABdhPJxYMrC3XGSSkzeRtsVyfysLitYoXFFyVKPySBwCCul3412jKa6/XnksEzH0Wh6Gv2vGsb6GoQ== X-Received: by 2002:a05:6512:3b0a:: with SMTP id f10mr29917406lfv.410.1636928657801; Sun, 14 Nov 2021 14:24:17 -0800 (PST) Received: from localhost.localdomain (46-138-46-211.dynamic.spd-mgts.ru. [46.138.46.211]) by smtp.gmail.com with ESMTPSA id d6sm1223339lfi.52.2021.11.14.14.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Nov 2021 14:24:17 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mauro Carvalho Chehab , Greg Kroah-Hartman , Anton Bambura , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 2/3] media: staging: tegra-vde: Properly mark invalid entries Date: Mon, 15 Nov 2021 01:23:52 +0300 Message-Id: <20211114222353.22435-3-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211114222353.22435-1-digetx@gmail.com> References: <20211114222353.22435-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Thierry Reding Entries in the reference picture list are marked as invalid by setting the frame ID to 0x3f. Signed-off-by: Thierry Reding Signed-off-by: Dmitry Osipenko --- drivers/staging/media/tegra-vde/vde.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/tegra-vde/vde.c b/drivers/staging/media/tegra-vde/vde.c index 42da57f191ef..ba7ef280423b 100644 --- a/drivers/staging/media/tegra-vde/vde.c +++ b/drivers/staging/media/tegra-vde/vde.c @@ -336,7 +336,7 @@ static void tegra_vde_setup_iram_tables(struct tegra_vde *vde, value |= frame->frame_num; } else { aux_addr = 0x6ADEAD00; - value = 0; + value = 0x3f; } tegra_vde_setup_iram_entry(vde, 0, i, value, aux_addr); From patchwork Sun Nov 14 22:23:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12618439 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95D2AC4167D for ; Sun, 14 Nov 2021 22:24:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E40061106 for ; Sun, 14 Nov 2021 22:24:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234737AbhKNW1U (ORCPT ); Sun, 14 Nov 2021 17:27:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231243AbhKNW1R (ORCPT ); Sun, 14 Nov 2021 17:27:17 -0500 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17F50C0613B9; Sun, 14 Nov 2021 14:24:20 -0800 (PST) Received: by mail-lf1-x12a.google.com with SMTP id n12so28654661lfe.1; Sun, 14 Nov 2021 14:24:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OEY8Nv/ShgRU0be328a4aBs0udunklwNBMGijdPI63A=; b=cOgM5FYoqjFqOnpJE/4mVM0ZcNneFPxHhFY8ye/Nl3FL4D0U4Rt5EiQrhI8KlAp1zn 4jLPgILJnHxHvKaB9GqRpjnuhmFbiRONmmu0ZNR5K3GZtBy+e9x1qvy4nwQ/6cLcqeo0 k57SD88+ypVfGKq3wyQPPKeeXSH7B01b3h5G6GbhMJ5LOE0856ILNHLLtj4eMVT2rnCg F795q1L9ZN8UhSgkMAOR2LnU9ROgbOEzwQJCqWeeKYq5xyOGZVEecliRXGMCTxKRrAas cUp1Ve4YHpKiG2GXpZ5qX6UUQqg4Myh8r7lHnivGAlKbiUjums1EItKPqzbZQceW4DBb NUfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OEY8Nv/ShgRU0be328a4aBs0udunklwNBMGijdPI63A=; b=BmKlOo9WsohQ29bM9IS8QNCdPg1jTsQeijRegjgIBvUiZCcyZuM68dSG30HcBOvEJB 4k7NwGZQfkp/x5aH8UQP3A6klk4/q8yYZqExyCcSbJig0bhBEpE83o4YqSHRYSxRRVbM 9Yy5ruLpFhGRmAXGtFVMWw7W4HzaWBshqKB7NnV5IR1hVrsQuKVvAD2KdEUR8LzJiuoJ ptZtcniMwOA3N/iES+mJGNLV60DlqnSlnfCPsXgbF+ahFyhfKSSLbqCBQ7AmqNm5UmSl TjA/fcy+HKYC/bd96fL/rByJilUigkx0Ln7MJCevUZgNXtXd+/TsiH8uwdGxFWoN5AWk TJ2w== X-Gm-Message-State: AOAM533kxd813asTwKEKOIIvvfHVIyA/bf9QNA7royybi3uo9sUV5+N/ HvipUUep7EczaAD/fw6Nikc= X-Google-Smtp-Source: ABdhPJzW0nxDlZoObnVzlzn9JAha6ommfx0LkvsUcTy9htb9etg78w3p+CGJ7a5ztElCsuaTlpOO/w== X-Received: by 2002:a05:6512:2289:: with SMTP id f9mr19798702lfu.619.1636928658479; Sun, 14 Nov 2021 14:24:18 -0800 (PST) Received: from localhost.localdomain (46-138-46-211.dynamic.spd-mgts.ru. [46.138.46.211]) by smtp.gmail.com with ESMTPSA id d6sm1223339lfi.52.2021.11.14.14.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Nov 2021 14:24:18 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mauro Carvalho Chehab , Greg Kroah-Hartman , Anton Bambura , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 3/3] media: staging: tegra-vde: Reorder misc device registration Date: Mon, 15 Nov 2021 01:23:53 +0300 Message-Id: <20211114222353.22435-4-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211114222353.22435-1-digetx@gmail.com> References: <20211114222353.22435-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Register misc device in the end of driver's probing since device should become visible to userspace once driver is fully prepared. Do the opposite in case of driver removal. This is a minor improvement that doesn't solve any problem, but makes code more consistent. Signed-off-by: Dmitry Osipenko --- drivers/staging/media/tegra-vde/vde.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/staging/media/tegra-vde/vde.c b/drivers/staging/media/tegra-vde/vde.c index ba7ef280423b..404d963690c5 100644 --- a/drivers/staging/media/tegra-vde/vde.c +++ b/drivers/staging/media/tegra-vde/vde.c @@ -1189,12 +1189,6 @@ static int tegra_vde_probe(struct platform_device *pdev) goto err_gen_free; } - err = misc_register(&vde->miscdev); - if (err) { - dev_err(dev, "Failed to register misc device: %d\n", err); - goto err_deinit_iommu; - } - pm_runtime_enable(dev); pm_runtime_use_autosuspend(dev); pm_runtime_set_autosuspend_delay(dev, 300); @@ -1216,15 +1210,20 @@ static int tegra_vde_probe(struct platform_device *pdev) goto err_pm_runtime; } + err = misc_register(&vde->miscdev); + if (err) { + dev_err(dev, "Failed to register misc device: %d\n", err); + goto err_free_secure_bo; + } + return 0; +err_free_secure_bo: + tegra_vde_free_bo(vde->secure_bo); err_pm_runtime: - misc_deregister(&vde->miscdev); - pm_runtime_dont_use_autosuspend(dev); pm_runtime_disable(dev); -err_deinit_iommu: tegra_vde_iommu_deinit(vde); err_gen_free: @@ -1239,6 +1238,8 @@ static int tegra_vde_remove(struct platform_device *pdev) struct tegra_vde *vde = platform_get_drvdata(pdev); struct device *dev = &pdev->dev; + misc_deregister(&vde->miscdev); + tegra_vde_free_bo(vde->secure_bo); /* @@ -1257,8 +1258,6 @@ static int tegra_vde_remove(struct platform_device *pdev) pm_runtime_put_noidle(dev); clk_disable_unprepare(vde->clk); - misc_deregister(&vde->miscdev); - tegra_vde_dmabuf_cache_unmap_all(vde); tegra_vde_iommu_deinit(vde);