Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2816300rwb; Mon, 15 Aug 2022 11:56:28 -0700 (PDT) X-Google-Smtp-Source: AA6agR7gGwZm8UOxPLdvXfjKjSTRE6V2AgiC8vsa7lPv5LMirGYtRKH4ZFGDsyVGngvdF+4BoEV0 X-Received: by 2002:a17:907:1629:b0:730:7d10:639c with SMTP id hb41-20020a170907162900b007307d10639cmr10906803ejc.256.1660589788495; Mon, 15 Aug 2022 11:56:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660589788; cv=none; d=google.com; s=arc-20160816; b=SjNyqTeQfo0rW3LgDtZUiS/n2Qm28it1XQ+dK7BmVdg8d4xC58SiIF8I4jkOJ3z/uL bfpOHXkpGV+dRRj/sADRgVlEfW9IllizEZh4/++6cHlV0CPhuVJrNPTMciEmxSS//lkF 5YGWFPVrnI8IPzI5XJII28DkfF8p0/hExy2XPuuHtBcC7ODC8yKuDoQgaxkaxROQN0gB hAmT9vthu2UkDPq9uVLA1wswrnhLbsdLsuMC1v9e1foItbpTYBCWB+2Lpwz5V/uzh0So xqrX4bBlxfP0B2c9Zd9cL4UkUhoNdQAeo/3Gd4NBdHUtJEASWU/Wl43MWZwiedZUY8qb eUkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=E4eT/vj8d5+WjKjlR1ScQxK0vPAxqqy57nLkJI/M1FM=; b=AO9hL/t2OdrktISDJDTlLI/A/1pLSbZ21wfjhlX+H5GU9MK1lmfhC9awypQUDYSNzt Yplfc3UgUE9FZer0wqrayRLKO4jLSfn38mIW1n9I3cnozqfzwZon6F2GcsGXIZ470ikq ZHn8JIeCWkvPZ/tA283+sBiicNgS+waNgptI/kpaWqaGV3GbmXahVeXwH2AwYDrk7fB7 6ArFq4H6XKdYwae560GppYTFR3sb8XjBl9MVjOXu5CjslgdhYD85timv2tjQ+FGblWbj l4dg68BE50Ll+lC24O1fzMUNEs66DED8ea7UmC7XJTKyYsErD73v7e4ulyQKE1U9ujCA arFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cryqR7vW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pj10-20020a170906d78a00b0073157f7b81dsi6777559ejb.524.2022.08.15.11.56.00; Mon, 15 Aug 2022 11:56:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cryqR7vW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231207AbiHOSwy (ORCPT + 99 others); Mon, 15 Aug 2022 14:52:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243825AbiHOSrU (ORCPT ); Mon, 15 Aug 2022 14:47:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6E55422E4; Mon, 15 Aug 2022 11:28:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 39598B8108F; Mon, 15 Aug 2022 18:28:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B406C433C1; Mon, 15 Aug 2022 18:28:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660588111; bh=glN6sxhxG13vQizBKcYdIeAELf9tcp4qdEOf3tEnxBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cryqR7vW2QnRmqy8wCuIOjm7b6heXl4xZ0B0wMMQqqTKJOFbg17uh0JCnjdkkCkdI 8AOhQSpnLgEKb+95gef9LNytSw7wRyUqiEVcC3RLSMQSj4XZIRu+JT3t/1ykiGwNg8 5qn4g0jJq8Y9of0vDOI/vo+oId4UGazNoPDdn7Io= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dave Stevenson , Maxime Ripard , Sasha Levin Subject: [PATCH 5.15 299/779] drm/vc4: dsi: Release workaround buffer and DMA Date: Mon, 15 Aug 2022 19:59:03 +0200 Message-Id: <20220815180350.058059034@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Stevenson [ Upstream commit 89c4bbe2a01ea401c2b0fabc104720809084b77f ] On Pi0-3 the driver allocates a buffer and requests a DMA channel because the ARM can't write to DSI1's registers directly. However, we never release that buffer or channel. Let's add a device-managed action to release each. Fixes: 4078f5757144 ("drm/vc4: Add DSI driver") Signed-off-by: Dave Stevenson Link: https://lore.kernel.org/r/20220613144800.326124-12-maxime@cerno.tech Signed-off-by: Maxime Ripard Signed-off-by: Sasha Levin --- drivers/gpu/drm/vc4/vc4_dsi.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c index 98308a17e4ed..e82ee94cafc7 100644 --- a/drivers/gpu/drm/vc4/vc4_dsi.c +++ b/drivers/gpu/drm/vc4/vc4_dsi.c @@ -1487,13 +1487,29 @@ vc4_dsi_init_phy_clocks(struct vc4_dsi *dsi) dsi->clk_onecell); } +static void vc4_dsi_dma_mem_release(void *ptr) +{ + struct vc4_dsi *dsi = ptr; + struct device *dev = &dsi->pdev->dev; + + dma_free_coherent(dev, 4, dsi->reg_dma_mem, dsi->reg_dma_paddr); + dsi->reg_dma_mem = NULL; +} + +static void vc4_dsi_dma_chan_release(void *ptr) +{ + struct vc4_dsi *dsi = ptr; + + dma_release_channel(dsi->reg_dma_chan); + dsi->reg_dma_chan = NULL; +} + static int vc4_dsi_bind(struct device *dev, struct device *master, void *data) { struct platform_device *pdev = to_platform_device(dev); struct drm_device *drm = dev_get_drvdata(master); struct vc4_dsi *dsi = dev_get_drvdata(dev); struct vc4_dsi_encoder *vc4_dsi_encoder; - dma_cap_mask_t dma_mask; int ret; dsi->variant = of_device_get_match_data(dev); @@ -1527,6 +1543,8 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data) * so set up a channel for talking to it. */ if (dsi->variant->broken_axi_workaround) { + dma_cap_mask_t dma_mask; + dsi->reg_dma_mem = dma_alloc_coherent(dev, 4, &dsi->reg_dma_paddr, GFP_KERNEL); @@ -1535,8 +1553,13 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data) return -ENOMEM; } + ret = devm_add_action_or_reset(dev, vc4_dsi_dma_mem_release, dsi); + if (ret) + return ret; + dma_cap_zero(dma_mask); dma_cap_set(DMA_MEMCPY, dma_mask); + dsi->reg_dma_chan = dma_request_chan_by_mask(&dma_mask); if (IS_ERR(dsi->reg_dma_chan)) { ret = PTR_ERR(dsi->reg_dma_chan); @@ -1546,6 +1569,10 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data) return ret; } + ret = devm_add_action_or_reset(dev, vc4_dsi_dma_chan_release, dsi); + if (ret) + return ret; + /* Get the physical address of the device's registers. The * struct resource for the regs gives us the bus address * instead. -- 2.35.1