From patchwork Thu Aug 1 10:45:07 2024
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Huan Yang
X-Patchwork-Id: 13750180
Received: from APC01-PSA-obe.outbound.protection.outlook.com
(mail-psaapc01on2087.outbound.protection.outlook.com [40.107.255.87])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED4FA187FF1;
Thu, 1 Aug 2024 10:45:35 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
arc=fail smtp.client-ip=40.107.255.87
ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1722509137; cv=fail;
b=cjjxZmNFS7H220++22IQeLANf6eaAi/nz6zBltZ/IWhdpxcAZC96xrRtnZzrDI1kBGhT+qSb/0tY3OZnZa/z8VidOk4PWp7FW/sCSPDQoW7BqHxvedymP2U93hKEdsjsooPPGy7cdACk1NFSng/RF9XwzuG2ec18qB8i3TmC0fE=
ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1722509137; c=relaxed/simple;
bh=RIDdW9yOOrE8HXcy97wtAPkTcrxg3IgVGYmFHTe68Js=;
h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
Content-Type:MIME-Version;
b=ZlmxLLVYfOsd+/o96VeOakCjpK2UfTkyUb75yLiczglYrguI2BXVVVTCq0qqQkm89LIQ8xzxVZv1ozQzaTIlal/OwIUdrB8ADfT+mJ6yPAKK9Qah8rnght5lnk+MQvR7M95QCw+/Kwe+CnCgC9stOXd9AXu6Lgv1/Ndq4mmzba8=
ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dmarc=pass (p=quarantine dis=none) header.from=vivo.com;
spf=pass smtp.mailfrom=vivo.com;
dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com
header.b=DdOHWUFG; arc=fail smtp.client-ip=40.107.255.87
Authentication-Results: smtp.subspace.kernel.org;
dmarc=pass (p=quarantine dis=none) header.from=vivo.com
Authentication-Results: smtp.subspace.kernel.org;
spf=pass smtp.mailfrom=vivo.com
Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com
header.b="DdOHWUFG"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
b=H+G3EyOEXo73JkPiG1EmoXUjznVxcuxHItWBS2soK8fN7vkc0A0Wt156uTQbaxaiyZYtcgnV8wD8HIHeVSJFxhtMS+8EVY75mkqOgMjf51cu9wySZAFUml8XOJ9fAlaBlbhgGARhQ9P/gGc24NSRVigjCaNwh+pTmv6adRvS/EfSPDvkDGsFw+GjgGFIybZPJEttFVOLOuaLAI0z9Mtreo3aryPFOPt/byIx47wquTui4JnbmEeOPO8SAMFPTEwfOA/9Eq4Bt6Pk6hC3BhFD7gXm8HxTmgaBIx8VsHQmSwwDgFY64/G+qlq47FJJh8e5pUZ7R4FuEeF2ImmZmXKzEA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector10001;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=UWLnCdkp610v5/9iVGLy5wlG5gZLG9AmQrLM+9Xbh9Y=;
b=UJzeqNpBlwWE0mWF21YI4p8pRKUvoiRDoUJtLf7macvMneHxUXS8Ov+uzs58OOWRSP0fKGY3oFVvHr+cRTv4VMNjTW1fhtOtcOCmk3f0ReSSRuE73jU29cJgx2f6ESYV1HOg82bgsrKtKIofHAcNNTMtWg3UPaMWtkDW3DspOCtCP63deBaApXb55hIMOovqz2AFOgPGeplqnnLAXQNZ3l8hRKEVv7vqggCqKWvrb65/QfCPTkf8+hOPOw6xcvKYiYPwc/kkMlJUBLm8PSBUYrG27DkFVXE/mBGKMJ9bAXPT48G3TYSIAv7zYETS1kGEFZnvDMt53G6duH0jU+iIRg==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com;
dkim=pass header.d=vivo.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
bh=UWLnCdkp610v5/9iVGLy5wlG5gZLG9AmQrLM+9Xbh9Y=;
b=DdOHWUFGFVCKodCcWwtLXvRC9jNIy7TmjQaU/ssgEAYr3xc7IAfVJQuKNdm2LMAhauf82Lpr6a35v3fOieX+rOuF0xoK3wua7SFDK/bGU8qHSgpSAUdnhYC6ZXH/tc3FjgUPgClaCbd89m/F1qGFG2fNeFxI+Zgkotqn5rwvB6OjT6l9lnEjLwt5j8DR47O4ne0jWBecHCkEkSBcDRwQt2D7312tEwihhMc3h5r9aXFPHW6cZPB0/SL20gSmprBZ07zQVIxTXiaJTHSqLCb3UGQtyBS7GhqKcQ8Q/SoIqcaCuo6GF4QIOP2xgyFAZgAX5gHp+7Ovm4e8s5ewh08ByQ==
Authentication-Results: dkim=none (message not signed)
header.d=none;dmarc=none action=none header.from=vivo.com;
Received: from PUZPR06MB5676.apcprd06.prod.outlook.com (2603:1096:301:f8::10)
by SEZPR06MB6304.apcprd06.prod.outlook.com (2603:1096:101:10d::6) with
Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7807.28; Thu, 1 Aug
2024 10:45:29 +0000
Received: from PUZPR06MB5676.apcprd06.prod.outlook.com
([fe80::a00b:f422:ac44:636f]) by PUZPR06MB5676.apcprd06.prod.outlook.com
([fe80::a00b:f422:ac44:636f%4]) with mapi id 15.20.7828.021; Thu, 1 Aug 2024
10:45:29 +0000
From: Huan Yang
To: Gerd Hoffmann , Sumit Semwal ,
=?utf-8?q?Christian_K=C3=B6nig?= ,
dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org,
linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org
Cc: opensource.kernel@vivo.com,
Huan Yang
Subject: [PATCH 3/5] udmabuf: fix vmap_udmabuf error page set
Date: Thu, 1 Aug 2024 18:45:07 +0800
Message-ID: <20240801104512.4056860-4-link@vivo.com>
X-Mailer: git-send-email 2.45.2
In-Reply-To: <20240801104512.4056860-1-link@vivo.com>
References: <20240801104512.4056860-1-link@vivo.com>
X-ClientProxiedBy: SG2PR06CA0209.apcprd06.prod.outlook.com
(2603:1096:4:68::17) To PUZPR06MB5676.apcprd06.prod.outlook.com
(2603:1096:301:f8::10)
Precedence: bulk
X-Mailing-List: linux-media@vger.kernel.org
List-Id:
List-Subscribe:
List-Unsubscribe:
MIME-Version: 1.0
X-MS-PublicTrafficType: Email
X-MS-TrafficTypeDiagnostic: PUZPR06MB5676:EE_|SEZPR06MB6304:EE_
X-MS-Office365-Filtering-Correlation-Id: 4719b95b-7ece-48df-94e2-08dcb2170fb6
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam:
BCL:0;ARA:13230040|1800799024|52116014|366016|376014|38350700014;
X-Microsoft-Antispam-Message-Info:
PMm5e6bHf66DsFkQJdP5uAMmAv5EhKxKPkW0s6tEmGaYHBqvjkJVrHrdPY5zy7d/czmrvW9AI9871xjCnpO8sYFQJQfzyR8eeKplur473qUtOOytO7xlHfBF+2wOyjkvEzlXRYoIBZZipp+xiK7pmIyENyYng4oBNwVErc4kEq/G0ZfBPe2bSKdUspapa7WrlcoS4wqVrqj9xryQxXHIMrok3oBzOZ95PtNHEIntMrAKr48VN2jjoQm5/yeNCowQ9S3PCiIUwK796Q6rYCSj6pPaSMZqx71UdR1Eds4Ya7F90QCuuF40NVmse6qWVEEgvqodSw3WssLRE2yclvG+sXTNqrf53B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
X-Forefront-Antispam-Report:
CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR06MB5676.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(52116014)(366016)(376014)(38350700014);DIR:OUT;SFP:1101;
X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-MessageData-0:
utMyP9wT6KRPW0toEjXI93yth4JkGI6xr15Dw28av04eqtuRZc+VCiwXnhXp7lJmdQoxJZcaCt+ZCV1VVdANR6sYEEF4iIx/utEcAUGIlLxomxgR3O7gG4fYwv5I/ifIht8CywWwN4A4axm7Vt4hj7k306Y5YKuvAuA1N6MD50hma/T8Hj/qS5tp54R/ohBSq5eCCU7fKo6XDxL8MmoARLwV/7L5jZ3tVfWyDUKYG0HNPyv8KDvVmogOrm8tH7LL8QpvUAmaVGz6ymSjsMBvcxeUbkkRMtuhUaZ0KJwSjJmFGdSkaeNmQtF5lP7YONMRWBfvcr5po97nImy/eRKFgU3fndpqKeEmF4VuFlzC+UnJUFK+hE/n98h3cET9deGHXuyIvv62k6IJabQoGIWYlLvxbZAd+0YFaGaQxft6oO+YrgYgLhwrocVl+31rgOUJqrhm3lBybb+KsethNjpI5WYGzL67UHnMehH1qevOl2r1tKXsJMQuLeYoBf4uUB6FBhgYGwYiw706fBPwKyddbpB+6+fMWMiW5clQCsc1jKMLjDqOANLF6Hyx53NJ8yyLCDyDxrNtyJhrctkRyNGnEYl3mGrLzuHnCs1HHPNergSxu0gyYaYg6IfriWbZHjnM3gu50AYFc1+rjReBnCtcvvA4P7tZRI1fkIZICmnYJV/1NPVNNLBlk7PMq+2gLgYq6t+H1CfbL3fgWG72m2IvScn8ju4sVQ15EuQoDomBRootH/mhGk7NXeDuWsfA3BiU3XdhSXdtVH/XWLFxmu1VHlFv2AEKsOztpKJBbzvR0wegC6FkOe2dn57H9bhMDFU+foA0QVwNPQTQhOY0ZwUE7z+lUG3zp068U+PlLgVVOmB8b3l729F1KgeD9RD3HRkVHQcsOg9see1iu8FNy3vms3ydP2KD7T8SDGzrPahUMXdgxl8LuBhG9Gq6JR7JW7klEe2Mr6F3QW5C00IKKj5Z4LhIHeUGY7BJpoXqn89zEvFWRMK7YZDf+0lplMDvN0fNiN1qhmVotmK9y+aiZyyv/3H7BHRCN/hwiMoaFzv+FKErFA11rZ39U4x61NvoIux3B7HM9lB23TykJbMJg7DwGbmmnMoctDbXc8NbhHO3c46zt7oKZa3SBmA1UBsScpEVJmHVDaTVPAGhT76HZZK7eSSXj7Kri9wbW/8e8qLH3GlF+AKBZo6ns2O9lTHQajXpPc+KB+7BJrWf3MxLGQ9CflFzvIQhCk46h5+io/x/Xq8S+AqaiXpiZssQ5wZTXqk0dvIYiwB9Wn/JQrJV3mGYrOgCneuHaRXn3XNEy+J3QfXPEC2xkjB51w/vvKHtoh7CJt39CPSdEXoesRwi+ln0QHOv/w9KmTjVhByMFhC5upUn7/Q6eqPg/1ObZaSvkxcVWJAjfcHqZOvjXJ5rV5rEt5mS2uTswCzUdIrp9cyVh5sKw06ZshqpbqurHemH2yX3y3Cod33tF1KndUUyEsaHOPfMwxqaSu7P79K97l9PFp8bN8cXVtnB7dKdWxlNupCT1HB6B/xEgpbMfa16WukidURPCKmANBNN4aFp5tFjBjONPZAoLWjwX7mZxk3ga8CE
X-OriginatorOrg: vivo.com
X-MS-Exchange-CrossTenant-Network-Message-Id:
4719b95b-7ece-48df-94e2-08dcb2170fb6
X-MS-Exchange-CrossTenant-AuthSource: PUZPR06MB5676.apcprd06.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 10:45:29.8643
(UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed
X-MS-Exchange-CrossTenant-MailboxType: HOSTED
X-MS-Exchange-CrossTenant-UserPrincipalName:
9zr45C1J5ovY7QqR15omKBELEuOiRRn/bB7mKz0UmlWfWwpaLnIDuQkvE/AJqF02gI/bA7b15r4kSTDTLeQvOQ==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR06MB6304
Currently vmap_udmabuf set page's array by each folio.
But, ubuf->folios is only contain's the folio's head page.
That mean we repeatedly mapped the folio head page to the vmalloc area.
This patch fix it, set each folio's page correct, so that pages array
contains right page, and then map into vmalloc area
Signed-off-by: Huan Yang
---
drivers/dma-buf/udmabuf.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c
index a915714c5dce..7ed532342d7f 100644
--- a/drivers/dma-buf/udmabuf.c
+++ b/drivers/dma-buf/udmabuf.c
@@ -77,18 +77,27 @@ static int mmap_udmabuf(struct dma_buf *buf, struct vm_area_struct *vma)
static int vmap_udmabuf(struct dma_buf *buf, struct iosys_map *map)
{
struct udmabuf *ubuf = buf->priv;
- struct page **pages;
+ struct page **pages, **tmp;
+ struct sg_table *sg = ubuf->sg;
+ struct sg_page_iter piter;
void *vaddr;
- pgoff_t pg;
dma_resv_assert_held(buf->resv);
+ if (!sg) {
+ sg = get_sg_table(NULL, buf, 0);
+ if (IS_ERR(sg))
+ return PTR_ERR(sg);
+ ubuf->sg = sg;
+ }
+
pages = kvmalloc_array(ubuf->pagecount, sizeof(*pages), GFP_KERNEL);
if (!pages)
return -ENOMEM;
+ tmp = pages;
- for (pg = 0; pg < ubuf->pagecount; pg++)
- pages[pg] = &ubuf->folios[pg]->page;
+ for_each_sgtable_page(sg, &piter, 0)
+ *tmp++ = sg_page_iter_page(&piter);
vaddr = vm_map_ram(pages, ubuf->pagecount, -1);
kvfree(pages);