From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A147CC3F2CD for ; Thu, 5 Mar 2020 10:05:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7718B208CD for ; Thu, 5 Mar 2020 10:05:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726974AbgCEKFM (ORCPT ); Thu, 5 Mar 2020 05:05:12 -0500 Received: from foss.arm.com ([217.140.110.172]:46648 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725880AbgCEKFM (ORCPT ); Thu, 5 Mar 2020 05:05:12 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C89F331B; Thu, 5 Mar 2020 02:05:11 -0800 (PST) Received: from [10.37.12.115] (unknown [10.37.12.115]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 73E993F6C4; Thu, 5 Mar 2020 02:05:07 -0800 (PST) Subject: Re: [PATCH] drm/exynos: Fix memory leak and release IOMMU mapping structures To: Marek Szyprowski , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: inki.dae@samsung.com, jy0922.shim@samsung.com, sw0312.kim@samsung.com, kyungmin.park@samsung.com, airlied@linux.ie, daniel@ffwll.ch, kgene@kernel.org, krzk@kernel.org, b.zolnierkie@samsung.com, a.hajda@samsung.com, Dietmar.Eggemann@arm.com References: <20200304220022.8003-1-lukasz.luba@arm.com> <684ef9fb-eafb-22d3-40c1-50f596211d85@samsung.com> From: Lukasz Luba Message-ID: <1044756c-39cf-9fea-4338-40e5a68349a9@arm.com> Date: Thu, 5 Mar 2020 10:05:03 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <684ef9fb-eafb-22d3-40c1-50f596211d85@samsung.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marek, On 3/5/20 7:07 AM, Marek Szyprowski wrote: > Hi Lukasz, > > On 04.03.2020 23:00, Lukasz Luba wrote: >> There is a memory leak which left some objects not freed. The reference >> counter of mapping: 'mapping->kref' was 2 when calling >> arm_iommu_detach_device(), so the release_iommu_mapping() won't be called. >> Since the old mapping structure is not going to be used any more (because >> it is detached and new one attached), call arm_iommu_release_mapping() >> to trigger cleanup. > > This will break IOMMU support in Exynos DRM if deferred probe happens. > Here is a proper fix: I forgot about the deferred probe. > > https://patchwork.kernel.org/patch/11415715/ > > The mapping initially created by DMA-mapping framework should be > attached back when Exynos DRM releases the subdev device. > Indeed, as you responded in that thread with the example, there is more dependencies and attaching back the old mapping will work. I am going add my reviewed-by to your patch. Regards, Lukasz From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8FC4C3F2D1 for ; Thu, 5 Mar 2020 10:05:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B31E7208CD for ; Thu, 5 Mar 2020 10:05:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jX+PLaV+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B31E7208CD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=DGXefS0zf3sVxp9/MbtrkFUM8H+VEVscWWGvQKS2EHY=; b=jX+PLaV+UmIWAwch6tnGUvqGT dB3GtIcDCc+bJ3ilEkiyiI/DJa348q+KZ5gv4XojYQeFh84VFd0X4Wr7/2J8ZJdyoBAV4+7mLtpR7 AVsNWh84++GhkDqqy+OTQU6akTL9qBAc0t+WVs6Qy7RolGPiNK012M3aUJq/UyCMKPHlHUXf2SfuV k4/Bje/f+Ev3EWHOapsxl030xNEszYbNxre/ri9oNh7tK4KX/nH56q2nJLwbLsLwlyVYcxHPCIXkF 8D+jrGo8upZEK19Fz5E+4/DdRZYf8Nxxzr73H9qk+klOP9Z84grPuffEtJMVIZdISiYSUlDwQjmf3 mDDsl98XA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j9nNT-0006EE-P2; Thu, 05 Mar 2020 10:05:15 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j9nNQ-0006Dc-LE for linux-arm-kernel@lists.infradead.org; Thu, 05 Mar 2020 10:05:14 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C89F331B; Thu, 5 Mar 2020 02:05:11 -0800 (PST) Received: from [10.37.12.115] (unknown [10.37.12.115]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 73E993F6C4; Thu, 5 Mar 2020 02:05:07 -0800 (PST) Subject: Re: [PATCH] drm/exynos: Fix memory leak and release IOMMU mapping structures To: Marek Szyprowski , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org References: <20200304220022.8003-1-lukasz.luba@arm.com> <684ef9fb-eafb-22d3-40c1-50f596211d85@samsung.com> From: Lukasz Luba Message-ID: <1044756c-39cf-9fea-4338-40e5a68349a9@arm.com> Date: Thu, 5 Mar 2020 10:05:03 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <684ef9fb-eafb-22d3-40c1-50f596211d85@samsung.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200305_020512_738146_3F524653 X-CRM114-Status: GOOD ( 14.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jy0922.shim@samsung.com, b.zolnierkie@samsung.com, airlied@linux.ie, sw0312.kim@samsung.com, krzk@kernel.org, inki.dae@samsung.com, a.hajda@samsung.com, kyungmin.park@samsung.com, kgene@kernel.org, daniel@ffwll.ch, Dietmar.Eggemann@arm.com Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Marek, On 3/5/20 7:07 AM, Marek Szyprowski wrote: > Hi Lukasz, > > On 04.03.2020 23:00, Lukasz Luba wrote: >> There is a memory leak which left some objects not freed. The reference >> counter of mapping: 'mapping->kref' was 2 when calling >> arm_iommu_detach_device(), so the release_iommu_mapping() won't be called. >> Since the old mapping structure is not going to be used any more (because >> it is detached and new one attached), call arm_iommu_release_mapping() >> to trigger cleanup. > > This will break IOMMU support in Exynos DRM if deferred probe happens. > Here is a proper fix: I forgot about the deferred probe. > > https://patchwork.kernel.org/patch/11415715/ > > The mapping initially created by DMA-mapping framework should be > attached back when Exynos DRM releases the subdev device. > Indeed, as you responded in that thread with the example, there is more dependencies and attaching back the old mapping will work. I am going add my reviewed-by to your patch. Regards, Lukasz _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EABC7C10F27 for ; Fri, 6 Mar 2020 08:03:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C1B932146E for ; Fri, 6 Mar 2020 08:03:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C1B932146E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3B9AB6EC78; Fri, 6 Mar 2020 08:03:11 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by gabe.freedesktop.org (Postfix) with ESMTP id 5AC446E09C for ; Thu, 5 Mar 2020 10:05:12 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C89F331B; Thu, 5 Mar 2020 02:05:11 -0800 (PST) Received: from [10.37.12.115] (unknown [10.37.12.115]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 73E993F6C4; Thu, 5 Mar 2020 02:05:07 -0800 (PST) Subject: Re: [PATCH] drm/exynos: Fix memory leak and release IOMMU mapping structures To: Marek Szyprowski , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org References: <20200304220022.8003-1-lukasz.luba@arm.com> <684ef9fb-eafb-22d3-40c1-50f596211d85@samsung.com> From: Lukasz Luba Message-ID: <1044756c-39cf-9fea-4338-40e5a68349a9@arm.com> Date: Thu, 5 Mar 2020 10:05:03 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <684ef9fb-eafb-22d3-40c1-50f596211d85@samsung.com> Content-Language: en-US X-Mailman-Approved-At: Fri, 06 Mar 2020 08:03:01 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jy0922.shim@samsung.com, b.zolnierkie@samsung.com, airlied@linux.ie, sw0312.kim@samsung.com, krzk@kernel.org, a.hajda@samsung.com, kyungmin.park@samsung.com, kgene@kernel.org, Dietmar.Eggemann@arm.com Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Marek, On 3/5/20 7:07 AM, Marek Szyprowski wrote: > Hi Lukasz, > > On 04.03.2020 23:00, Lukasz Luba wrote: >> There is a memory leak which left some objects not freed. The reference >> counter of mapping: 'mapping->kref' was 2 when calling >> arm_iommu_detach_device(), so the release_iommu_mapping() won't be called. >> Since the old mapping structure is not going to be used any more (because >> it is detached and new one attached), call arm_iommu_release_mapping() >> to trigger cleanup. > > This will break IOMMU support in Exynos DRM if deferred probe happens. > Here is a proper fix: I forgot about the deferred probe. > > https://patchwork.kernel.org/patch/11415715/ > > The mapping initially created by DMA-mapping framework should be > attached back when Exynos DRM releases the subdev device. > Indeed, as you responded in that thread with the example, there is more dependencies and attaching back the old mapping will work. I am going add my reviewed-by to your patch. Regards, Lukasz _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel