Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2930008rwb; Mon, 15 Aug 2022 14:15:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR6zcpZdPjIHUBp0s4NVAMh8DoOjlEY9pjWeDUHr7o7fL0Locn9/ypnAspE8UYuAsUIR2SCv X-Received: by 2002:a63:170d:0:b0:415:f76d:45e1 with SMTP id x13-20020a63170d000000b00415f76d45e1mr15292929pgl.171.1660598069780; Mon, 15 Aug 2022 14:14:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660598069; cv=none; d=google.com; s=arc-20160816; b=Z2/j1wNQGTv7l0Axv7kMkG0ZRZEHD8pUqQztkTvYxJiTbc/0oyDOykMq3EF7ZGJCZt 3UAzLGegmGWwDD6mWqNIwk7nJ2fo+qmBjNQUUfmresHoD/MQZkTDS4+l7Xyqf1dr+/mb 5UE9ibe0OsXK1N1rvoq4rv9Gn+/Pa+Ml4ITzrjQV4l9rP67YM+o/4Gt+GZeZnPvY8HoN nuhpJmgUoMzUdK19+BkQmdjtxbc/YRXhXwh1GTukNZFIvpux+Nu/ONmPlOq3VgemkiuK U9pDyI1MC5WjgTSBxv6yVX93IVHxtFlfxZQYZpbXX93C3k/JkDkstyBaUbJrm2V3ki8N HpZQ== 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=u8n66fHpAg0ZUf6yRchTeib8mEYZQZXxPF9k2AFB3STmdScoMutKxINRC0QKGAy1ug F9Tz6KLEr9YJpa5ZAHxDufz+CmbNzpXrZf/u7AyQR5F4SYQ0vLQW0qdr6bndp9+pEXJ1 MHP490QLXOKoquGF2O3XnJAAqtWu7Iz7Mk96cyiHDyvwpEyGkt5LjCU8WShPEpYmSog/ 2D6L1pvFs7uPK/7OS9i8b+A/CdATyp1DZR7j847kVaQCUTGNdxoGwsjn8BS5gCsMK9j+ LQSniHmzJ4+W6vE6aZDuHVEAshuY+9ujE+VxElMb7E07HirQpDkL54tvntPzZ79lG4GZ dPZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JvM48E3r; 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 u9-20020a632349000000b0040d287c145fsi10024643pgm.460.2022.08.15.14.14.18; Mon, 15 Aug 2022 14:14:29 -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=JvM48E3r; 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 S242856AbiHOVER (ORCPT + 99 others); Mon, 15 Aug 2022 17:04:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347496AbiHOVCC (ORCPT ); Mon, 15 Aug 2022 17:02:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AC9EC9932; Mon, 15 Aug 2022 12:13:57 -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 dfw.source.kernel.org (Postfix) with ESMTPS id AA20560F27; Mon, 15 Aug 2022 19:13:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95B3FC433D6; Mon, 15 Aug 2022 19:13:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660590836; bh=glN6sxhxG13vQizBKcYdIeAELf9tcp4qdEOf3tEnxBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JvM48E3rrot5vGG/zBbFY0tiLVdl60UNR9ewMEe1JtSa99khJIqbfmgweIiuQvcVq 6PJr9i0Uu0Ht+3droZMEWwChAF9FptBdCAY/mQzQKoviCYz4Gz2PeDK601Q6RB5YNs BE8Pulp4aQzRK2dOC+MviIjesVzq2zr0qIk5zDwM= 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.18 0386/1095] drm/vc4: dsi: Release workaround buffer and DMA Date: Mon, 15 Aug 2022 19:56:25 +0200 Message-Id: <20220815180445.652206689@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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