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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E68E2C433EF for ; Thu, 25 Nov 2021 14:08:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D682D6E0CA; Thu, 25 Nov 2021 14:08:08 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by gabe.freedesktop.org (Postfix) with ESMTP id A1BBC6E0CA for ; Thu, 25 Nov 2021 14:08:07 +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 26E6A1FB; Thu, 25 Nov 2021 06:08:07 -0800 (PST) Received: from [10.57.56.56] (unknown [10.57.56.56]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 777393F66F; Thu, 25 Nov 2021 06:08:04 -0800 (PST) Message-ID: Date: Thu, 25 Nov 2021 14:08:00 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH v2] dma_heap: use for_each_sgtable_sg in sg_table release flow Content-Language: en-GB To: guangming.cao@mediatek.com References: <85eb9053-0ce4-2514-06dc-58b8910dc5f7@arm.com> <20211125134951.62002-1-guangming.cao@mediatek.com> From: Robin Murphy In-Reply-To: <20211125134951.62002-1-guangming.cao@mediatek.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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: wsd_upstream@mediatek.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, christian.koenig@amd.com, linaro-mm-sig@lists.linaro.org, lmark@codeaurora.org, benjamin.gaignard@linaro.org, matthias.bgg@gmail.com, linux-mediatek@lists.infradead.org, labbott@redhat.com, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On 2021-11-25 13:49, guangming.cao@mediatek.com wrote: > From: Guangming > > Use (for_each_sgtable_sg) rather than (for_each_sg) to traverse > sg_table to free sg_table. > Use (for_each_sg) maybe will casuse some pages can't be freed > when send wrong nents number. It's still worth spelling out that this is fixing a bug where the current code should have been using table->orig_nents - it's just that switching to the sgtable helper is the best way to make the fix, since it almost entirely removes the possibility of making that (previously rather common) mistake. If it helps, for the change itself: Reviewed-by: Robin Murphy Thanks, Robin. > Signed-off-by: Guangming > --- > drivers/dma-buf/heaps/system_heap.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c > index 23a7e74ef966..8660508f3684 100644 > --- a/drivers/dma-buf/heaps/system_heap.c > +++ b/drivers/dma-buf/heaps/system_heap.c > @@ -289,7 +289,7 @@ static void system_heap_dma_buf_release(struct dma_buf *dmabuf) > int i; > > table = &buffer->sg_table; > - for_each_sg(table->sgl, sg, table->nents, i) { > + for_each_sgtable_sg(table, sg, i) { > struct page *page = sg_page(sg); > > __free_pages(page, compound_order(page)); > 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4FD82C433EF for ; Thu, 25 Nov 2021 14:08:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=U9kvkMNQZJfKKvQK7tDUoS0xH9UH3Y8tmXhj9jq8e5k=; b=mpfTR776F08ukj fZbINFtCnU0bES64+zYP+7KlFy0PqLc9k6PSlbCdGpne8voII/eEqJKfstc+Go8zOR7rpt3hkqblF yTqhXo673o5zUjcDCuHZbHmwF35RJUPpkiWL59SLYfl1z1L1cSt02dYI4xqni96Fv9GYeTNYubtR5 /L3Cw/TS6S7Lh/ws5no7ezuevoa4LJqdPt/QPNYICfvShsBLEPjq7Vt4Jenxhl94rDXMftdo9FbzC W6JIOeiQnHLjXxSEFB7twK2ijbCRsvSjWGjCct3kV5RffDnvJZ+Na3IHbjlRboTY6KuwmaC7QpjNP Zsb8epP/+k0aY4cZXgtA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqFQE-007lja-II; Thu, 25 Nov 2021 14:08:22 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqFQ0-007ley-GZ; Thu, 25 Nov 2021 14:08:09 +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 26E6A1FB; Thu, 25 Nov 2021 06:08:07 -0800 (PST) Received: from [10.57.56.56] (unknown [10.57.56.56]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 777393F66F; Thu, 25 Nov 2021 06:08:04 -0800 (PST) Message-ID: Date: Thu, 25 Nov 2021 14:08:00 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH v2] dma_heap: use for_each_sgtable_sg in sg_table release flow Content-Language: en-GB To: guangming.cao@mediatek.com Cc: Brian.Starkey@arm.com, benjamin.gaignard@linaro.org, christian.koenig@amd.com, dri-devel@lists.freedesktop.org, john.stultz@linaro.org, labbott@redhat.com, linaro-mm-sig@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org, lmark@codeaurora.org, matthias.bgg@gmail.com, sumit.semwal@linaro.org, wsd_upstream@mediatek.com References: <85eb9053-0ce4-2514-06dc-58b8910dc5f7@arm.com> <20211125134951.62002-1-guangming.cao@mediatek.com> From: Robin Murphy In-Reply-To: <20211125134951.62002-1-guangming.cao@mediatek.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211125_060808_633425_1C732F31 X-CRM114-Status: GOOD ( 15.03 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org On 2021-11-25 13:49, guangming.cao@mediatek.com wrote: > From: Guangming > > Use (for_each_sgtable_sg) rather than (for_each_sg) to traverse > sg_table to free sg_table. > Use (for_each_sg) maybe will casuse some pages can't be freed > when send wrong nents number. It's still worth spelling out that this is fixing a bug where the current code should have been using table->orig_nents - it's just that switching to the sgtable helper is the best way to make the fix, since it almost entirely removes the possibility of making that (previously rather common) mistake. If it helps, for the change itself: Reviewed-by: Robin Murphy Thanks, Robin. > Signed-off-by: Guangming > --- > drivers/dma-buf/heaps/system_heap.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c > index 23a7e74ef966..8660508f3684 100644 > --- a/drivers/dma-buf/heaps/system_heap.c > +++ b/drivers/dma-buf/heaps/system_heap.c > @@ -289,7 +289,7 @@ static void system_heap_dma_buf_release(struct dma_buf *dmabuf) > int i; > > table = &buffer->sg_table; > - for_each_sg(table->sgl, sg, table->nents, i) { > + for_each_sgtable_sg(table, sg, i) { > struct page *page = sg_page(sg); > > __free_pages(page, compound_order(page)); > _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AABA6C433FE for ; Thu, 25 Nov 2021 14:10:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355623AbhKYONT (ORCPT ); Thu, 25 Nov 2021 09:13:19 -0500 Received: from foss.arm.com ([217.140.110.172]:51520 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355362AbhKYOLS (ORCPT ); Thu, 25 Nov 2021 09:11:18 -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 26E6A1FB; Thu, 25 Nov 2021 06:08:07 -0800 (PST) Received: from [10.57.56.56] (unknown [10.57.56.56]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 777393F66F; Thu, 25 Nov 2021 06:08:04 -0800 (PST) Message-ID: Date: Thu, 25 Nov 2021 14:08:00 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH v2] dma_heap: use for_each_sgtable_sg in sg_table release flow Content-Language: en-GB To: guangming.cao@mediatek.com Cc: Brian.Starkey@arm.com, benjamin.gaignard@linaro.org, christian.koenig@amd.com, dri-devel@lists.freedesktop.org, john.stultz@linaro.org, labbott@redhat.com, linaro-mm-sig@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org, lmark@codeaurora.org, matthias.bgg@gmail.com, sumit.semwal@linaro.org, wsd_upstream@mediatek.com References: <85eb9053-0ce4-2514-06dc-58b8910dc5f7@arm.com> <20211125134951.62002-1-guangming.cao@mediatek.com> From: Robin Murphy In-Reply-To: <20211125134951.62002-1-guangming.cao@mediatek.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-11-25 13:49, guangming.cao@mediatek.com wrote: > From: Guangming > > Use (for_each_sgtable_sg) rather than (for_each_sg) to traverse > sg_table to free sg_table. > Use (for_each_sg) maybe will casuse some pages can't be freed > when send wrong nents number. It's still worth spelling out that this is fixing a bug where the current code should have been using table->orig_nents - it's just that switching to the sgtable helper is the best way to make the fix, since it almost entirely removes the possibility of making that (previously rather common) mistake. If it helps, for the change itself: Reviewed-by: Robin Murphy Thanks, Robin. > Signed-off-by: Guangming > --- > drivers/dma-buf/heaps/system_heap.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c > index 23a7e74ef966..8660508f3684 100644 > --- a/drivers/dma-buf/heaps/system_heap.c > +++ b/drivers/dma-buf/heaps/system_heap.c > @@ -289,7 +289,7 @@ static void system_heap_dma_buf_release(struct dma_buf *dmabuf) > int i; > > table = &buffer->sg_table; > - for_each_sg(table->sgl, sg, table->nents, i) { > + for_each_sgtable_sg(table, sg, i) { > struct page *page = sg_page(sg); > > __free_pages(page, compound_order(page)); > 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D0B05C433EF for ; Thu, 25 Nov 2021 14:09:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LSExjBu5zG39KgdvNx+rbl1R2Z0CfRcNaFnkg7OEY4o=; b=LHC9b8VW5Jq6zx dKB/jDX/SLy69ZLoy/JaTFaiPhivh5eLA2h3uLKaq4Nta/RiFreJNkFBWyNYCqa9oJNlrTQeiVusV EGp7wng8XfnexRvYrHeN9nQZ3OTfmdSYdpMb74WIP5OP1i2re34ZxgcFt5ENbq9WRovEHdbmOJPbo A6Jx1S3S14ZG4Hs0Uto82KsaRwgQMHf55gQqFchom8KVeTbuyO733g5bPsO4f8MmDC1xAV6CmaUMj ypwYTPEaDj7flsCSWdi0yi71nbym2L1X+PRvVH/k++eDtzNl85s1l2/KV/8DeKJw4jz7G30Oc3+/f 8eetGZjM45SeQUFpT14Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqFQ4-007lgP-FG; Thu, 25 Nov 2021 14:08:12 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqFQ0-007ley-GZ; Thu, 25 Nov 2021 14:08:09 +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 26E6A1FB; Thu, 25 Nov 2021 06:08:07 -0800 (PST) Received: from [10.57.56.56] (unknown [10.57.56.56]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 777393F66F; Thu, 25 Nov 2021 06:08:04 -0800 (PST) Message-ID: Date: Thu, 25 Nov 2021 14:08:00 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH v2] dma_heap: use for_each_sgtable_sg in sg_table release flow Content-Language: en-GB To: guangming.cao@mediatek.com Cc: Brian.Starkey@arm.com, benjamin.gaignard@linaro.org, christian.koenig@amd.com, dri-devel@lists.freedesktop.org, john.stultz@linaro.org, labbott@redhat.com, linaro-mm-sig@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org, lmark@codeaurora.org, matthias.bgg@gmail.com, sumit.semwal@linaro.org, wsd_upstream@mediatek.com References: <85eb9053-0ce4-2514-06dc-58b8910dc5f7@arm.com> <20211125134951.62002-1-guangming.cao@mediatek.com> From: Robin Murphy In-Reply-To: <20211125134951.62002-1-guangming.cao@mediatek.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211125_060808_633425_1C732F31 X-CRM114-Status: GOOD ( 15.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2021-11-25 13:49, guangming.cao@mediatek.com wrote: > From: Guangming > > Use (for_each_sgtable_sg) rather than (for_each_sg) to traverse > sg_table to free sg_table. > Use (for_each_sg) maybe will casuse some pages can't be freed > when send wrong nents number. It's still worth spelling out that this is fixing a bug where the current code should have been using table->orig_nents - it's just that switching to the sgtable helper is the best way to make the fix, since it almost entirely removes the possibility of making that (previously rather common) mistake. If it helps, for the change itself: Reviewed-by: Robin Murphy Thanks, Robin. > Signed-off-by: Guangming > --- > drivers/dma-buf/heaps/system_heap.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c > index 23a7e74ef966..8660508f3684 100644 > --- a/drivers/dma-buf/heaps/system_heap.c > +++ b/drivers/dma-buf/heaps/system_heap.c > @@ -289,7 +289,7 @@ static void system_heap_dma_buf_release(struct dma_buf *dmabuf) > int i; > > table = &buffer->sg_table; > - for_each_sg(table->sgl, sg, table->nents, i) { > + for_each_sgtable_sg(table, sg, i) { > struct page *page = sg_page(sg); > > __free_pages(page, compound_order(page)); > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel