From patchwork Wed Jul 31 09:02:32 2024
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Huan Yang
X-Patchwork-Id: 13748289
Received: from APC01-SG2-obe.outbound.protection.outlook.com
(mail-sgaapc01on2086.outbound.protection.outlook.com [40.107.215.86])
(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 93D5A1A8C0D;
Wed, 31 Jul 2024 09:02:55 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
arc=fail smtp.client-ip=40.107.215.86
ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1722416577; cv=fail;
b=cGrpvIVWFoWZyQIBlBn8B5GdGKecVDbhERCc3diKY5yTQnv627mUD3tqdJ6kZQof0+3BSlANzMbRCn5umZx7zC8xKw5jcv0KgnCR+duyoGReRrRFEnbWBbvNWNlyvN2Xm4J74DyP55FgSETQw+PAaBai9WIZiJ4XaJ+jlYu8qTs=
ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1722416577; c=relaxed/simple;
bh=SYaCxHWFz0QAlE8Zqrx/JmcpheGIMc52C/nmS59sBuI=;
h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version;
b=d7On5sO6K3pHo0Zhozs+7usZxgsUn43P21oHJmja7nH8w/esChwi4DKSrOKyh6QVs8EDBfDLhgHWK6Yvvdj5RgpRF/dSwabCa5kETsUnVYCzLNiQjOGiugeerPCg84I73zPPpsPK2QjnZKPYmgEzKny81j8WDC8DQWq1I/tcJPo=
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=Mp7UU5oK; arc=fail smtp.client-ip=40.107.215.86
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="Mp7UU5oK"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
b=CS2oL8DDGp5lpQpEetRgcfLQK9B0Yl13+oyUx3fGlXq27aupo0oE+hnhOxgTWLRF7TyWUGKaPaF1qJV2vNdTGFNDT8K/Df8wsRt0WJsfezUvm8MT0IcExyL1cdB8ehbD7C02h48Sh2EbgOz1XAsV9xpBJHDO+m44iuY2T6CkAMf/C0NcvLTycjdMNdSwrlwKx3v7qSW+j1SNAvxYNirZO8jito49hsU7F+R1mbgpqtAeBFAyxvC9jfnvi8IS0CI+UQF392FU7f4CrHTP/XGDIDpEAFTVz/3kkZARN23+wVE8Nr/vItLVe9EVXt0leFKo5zjHOHqwTDlST57OXYCBcQ==
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=3nn5gEFQG3ouo3UIbgc1txXVuZpkTgkwJnnt2k//NsA=;
b=iN5KV08zmxmc61NOep59GgSGcB0pYsus2qU9yQCi0Trr9dRZ3rmKjAfYwRivHp5sKYbu0fnD3sGiDtXL1rf46kJOkP2A1pltfDmaHXGnopkJhYsiuQMt1ZVEvBirdulanPRtErlRfKOmEVlzfuRzvSmxFS3YMPuQm0iKTBrJoWnQ8sQ2QMyY00ju0M5Kevv9SP1zzjaEUEVTG9KURGQC3dSORrmFbUfFXd8Ejm+Gwffh5j1Jc7l2KYG3X4t/vhDr7VwtaeiqpBp99HDZO527gHZpUomBc1mFOFtoINBzRTU/dylNgmle9hOV492mo3E+CZjmy/4pQirfql0Aqg5Wqg==
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=3nn5gEFQG3ouo3UIbgc1txXVuZpkTgkwJnnt2k//NsA=;
b=Mp7UU5oK/uelY6JD+jYF5eTgVgbGrHCcA1kFb2DMeP3iGRGRl0C472/MhINz8G4IHz/wDuC+L1JP5Pw/B5SURz561ZuG5Xh/NTy08CexB+T/A3Rb9xT3BL0EiZyDfqErJfM8/nQ/dEmvZVeBTn2PXW3mmTzuVkds6VjxNm8AHR2CFuxt7xh/+1sIRtVw8kLP2t+BfdTap4VikqfbKoVlZKTFWE0E6iS9gdfL1USE5SyEibXqs7xjIX/GHINVe5bSAeUUcEJgfm2KHHHqhvbyqCOEtGbBApeBv2weggIfFWuv6Yq8Gx1QL3+yl3zNBTAYYuW0PeOcqsxMYMKmt1kBJw==
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 SEYPR06MB7027.apcprd06.prod.outlook.com (2603:1096:101:1e3::11) with
Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.33; Wed, 31 Jul
2024 09:02:45 +0000
Received: from PUZPR06MB5676.apcprd06.prod.outlook.com
([fe80::a00b:f422:ac44:636f]) by PUZPR06MB5676.apcprd06.prod.outlook.com
([fe80::a00b:f422:ac44:636f%6]) with mapi id 15.20.7807.026; Wed, 31 Jul 2024
09:02:45 +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 1/2] udmabuf: fix vmap_udmabuf error page set
Date: Wed, 31 Jul 2024 17:02:32 +0800
Message-ID: <20240731090233.1343559-1-link@vivo.com>
X-Mailer: git-send-email 2.45.2
X-ClientProxiedBy: SI2PR01CA0035.apcprd01.prod.exchangelabs.com
(2603:1096:4:192::13) 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_|SEYPR06MB7027:EE_
X-MS-Office365-Filtering-Correlation-Id: da3641f9-83ca-4682-8275-08dcb13f8ae6
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam:
BCL:0;ARA:13230040|366016|376014|1800799024|52116014|38350700014;
X-Microsoft-Antispam-Message-Info:
7xb+3cbzTmXGoIndO2ZS3oaGa5ldAwJvUaUNE969nomGhzL62CcdiqJ3vCq/iokYKiW8sLqcY7M98KK4qShObLz9jT65jc7vc38mqav9iY81dcg7MyJ2Hd7glD0vScVkY7mi1opfhxLyItcsR7cRv3u/nMzlMdbigE7K7C5HUvg2R1zdcCzawMlA+ZKEIbKRaT50ZLp6L7y9+IanaMDIre5vp0gNG0Or8V69Ez2Zvg/XQOsNEhrxjZV5/H8LbbbeaDRm/rWfVD+SAhKbw82ddimoMfdqmbTniIR9AShrg6SxYdTfqgZKAiC3F5PlcSXXI/DYBTlr/keZG5JaWaZiLIxEdag5yIaCgr9QqJ6FVDlq0v/aMjYMMiUkld66W1UAH/Gd1paEQqWyEoVX4foXVhMcqBcRc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FV:NSPM;H:PUZPR06MB5676.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(1800799024)(52116014)(38350700014);DIR:OUT;SFP:1101;
X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-MessageData-0:
q5KE05wV1J/YUUcn+hVGAIeQQbhBzuKBCd1fXgDHuCmdk2uQJqY/qnidX0AEqyPAwDolr13CiMX+foUFyv0yQYChnxHv5V7OkddX7T40vHsXZeeqwpGa5UJFTCp2TbNcR8cr04Y84zzFot2MgWJBWvBUZvoMr5lakxGIz0be0Z8jsYRrY/sYIk6n/2remusV03mpv1ubIP+hi48dqhux0TUn3Y+asWrP6khnD5BP7a1s390xxc8x/GXtTQ5WU/BlkWLuMAMZk7xVyzlK2pawnvFd9EXTEdGi7/0DSWdbNM3f5iaqfzYiI9hPC5jkoOkM1LSWt1E7Olr/4Yo+NhB5ZeSAuG5iuB9Xz1QRMswb3DPdhObzRjvqdPoY8pOBrw79Ox9dTo/CWlgFoBv+p7IAqJIckPI2JqHnl0qabo5bpLIJMVgv5G3XbsRQwYeKVJli7G9d8eFrGB/l1bNBmLH16tA9bp62CSJA6GGOh8dF5bDKZ6iVThVHl2bO8Ic8/o5tgDjsRQr0IvcJincD8t3R9lfO+JzYbpw3ymnUaeHAlRLDjbIHleGaQZVifwy+4b51LviAaMRhTTAD2lLIpJmn5Np168IQijbxHB5ESAXCjunOLkLJ5295y0l+wztY12vXy0IDfyzJG6tMOHqRvhX0B8/VA0G6fkaolcdiNOrg53JNdSplZRKLQgysbGUWAItuL5b0PdiAsF7ggrh60do/7BXGSpMCV17zFEeTBRA+/tI6FAx9UeXr0UQs6QV+XRMiIs7MaqcRDrLqHzN6Ay8TTnxz02k/WM5TejgQlp4R7to8+zAEY9q9/rfgME0AnTwesJfAs0CBEe75opgEUPT9YMqFYTL1B0pTip8gcm61EmqDsjCiRdjiHQoti0V14i32W4dxLBTjcw+ZWO3btFDG1fYKGEiuibRakreWOnlx3+s9qI7HGM3I5rY6bjzLaK8xkr/Wl22fkVVkNOlVIhWN+B3mmkqJNM/0rHZE6YEmT8WNC7wLGLXBdyabsUkI1XA1Z0fdPwKbcepNnH3xjjx8plOPxlLMVBlv080ngID1VkpJ7K+0ybqJbVBOfqFPAlSg/1q9MZQRszKvNxGeW28Bt+cEZHxO8LHTf+BA5ENr4l6Jd2aw59PEqtxbVWVOMQ+2dGzW4GQt6lry/6yyzr3Qw8xrpNb9wO6YI6gPXKu1t77zbltJjHXkZIe/RUDVInwChck8NJ7cQYeTOORlZIpXre/LFAbjJxFEjx+H3GTGcQ9qF/KJWlWb51YarmEJ1R2Ve3CrZZlD9wiDA8MNxJcP2i576jT0izjaPoeCNreP1q6GadBeGVYQGc8QWkM5CvNCM9g8BDYtwooaHIbmz7zNRcOgAFDB78EIeS56Qcc5FEvMKRdNAmT1fEvX/FEpq8AYxvrtGsGwDPQDOtyYuzFY/z/7XkY5Nx/za75eTroCAUHqOyzv/Nz2pZFloJve4PEZH/csXLVXrxEUO1GaX91K3xDx1P+M09/w9aHiQbJ3rX2chbN+w1X+s7hN4ozMwN7gbf6/5im4ts6TCKjB7ZLjGeiQvaw4N0KlNgOGZQa08FmzqpOaRbDBlnztIo9L267W
X-OriginatorOrg: vivo.com
X-MS-Exchange-CrossTenant-Network-Message-Id:
da3641f9-83ca-4682-8275-08dcb13f8ae6
X-MS-Exchange-CrossTenant-AuthSource: PUZPR06MB5676.apcprd06.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2024 09:02:45.3951
(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:
BuiiuONYAJJpJ6oaMvXtUSeObgbbVwFbpebQVfbLa0SVrAjg6Qf6DMAzBYSFrdbT8x/lVwkz6X5vDwNVYmMIbA==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB7027
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 | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
base-commit: cd19ac2f903276b820f5d0d89de0c896c27036ed
diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c
index 047c3cd2ceff..6604d91e7072 100644
--- a/drivers/dma-buf/udmabuf.c
+++ b/drivers/dma-buf/udmabuf.c
@@ -85,7 +85,8 @@ static int vmap_udmabuf(struct dma_buf *buf, struct iosys_map *map)
return -ENOMEM;
for (pg = 0; pg < ubuf->pagecount; pg++)
- pages[pg] = &ubuf->folios[pg]->page;
+ pages[pg] = folio_page(ubuf->folios[pg],
+ ubuf->offsets[pg] >> PAGE_SHIFT);
vaddr = vm_map_ram(pages, ubuf->pagecount, -1);
kfree(pages);
From patchwork Wed Jul 31 09:02:33 2024
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Huan Yang
X-Patchwork-Id: 13748288
Received: from APC01-SG2-obe.outbound.protection.outlook.com
(mail-sgaapc01on2086.outbound.protection.outlook.com [40.107.215.86])
(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 CFD791CF93;
Wed, 31 Jul 2024 09:02:52 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
arc=fail smtp.client-ip=40.107.215.86
ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1722416574; cv=fail;
b=BJudVpank4mnTUK68TL4SF0vXBcapqyVTbREqLqPuq492QTcAIulwHDplUdK/psiZvltjING7ALUMp7KjAsPHaDIWwaE4oaZH5muYBbrZeS7hedfr5hRbRzrtKvMHcO+rMXHgNy5lib1ZuxGSpdpdslE3EeXywg4f8/2qzN0kQs=
ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1722416574; c=relaxed/simple;
bh=BjdyK/sz5gEkEg7fImNeX7lKO3p1NfDSawwj+nib05A=;
h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
Content-Type:MIME-Version;
b=VzEFo6FVhVhcTa58N5XBJE/MlZySvxipZsiuGodSFrQQUanlvNBkOJpiIh2fxPspJrrfwIwNcLAULgnk0Lsgx2qhFNlGjqoAs5T6mgkJSr5emPctiqfcAp7B2sqPr/um3HApdQLp22/HRTIPUQYvtUAwqockeToMdozuoOW+dO4=
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=i4SncwO2; arc=fail smtp.client-ip=40.107.215.86
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="i4SncwO2"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
b=RD+I1+ebJ93/Ea0CceJgc3Eyc2Y4D8E6ZfnmxQtJqpiotAwYBcvzwweOo8tyr3lE1tIx24/tqnXE7RIY1amW1MSGEy3ThJ94SkYR61UEu8bYN1yA7/h0eWjmu9NM2EfEviXYCEURb9k5thuy9iohCz3sRbnjEpKMn/xRWfafLUsajKWRWahvOq/B2QuXpoMHjXEqN3CVv+Lm6veuA1k+4GzrrkWybiaAmKaXPnu+wHJ59MAKR/uLz0jEUkSS8Yeyf1d1xeOtdQMj1ceQ1KbhMqf7gClgLKxH3wxfyUIEWzCAsGWz7Ija41eBhDNftdn3ywjFw7DY5E8lvtkrZh69hA==
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=rh6mMFBK64P5wZb+ppyB0dcKV5TjJKuBEtiJnIYiZwg=;
b=F2e8sbXoam2w4QSAxEqQw+7WPAibiONsYdsjF2RFlibiuQ/5juoI6l5rO1PHBQSb9ijQ2Gs5fxQlVAXhOFtcs39R0P3HeNZy9859ui3UmqRyRLBclXwlqxkO6cdb0rITU4/1szGV8tSe5SjImVCp09zo93cRn3WxXSCE60xO9HErKlDYFee/AQ2VG4hlaFCOiLv8qPB+TEeHb2Bl+0KpxGEL7XS/yjrnz+aAc+vIVj8dT0XWU7XbVUtvbAIr+zgTeCmxH5shqD1+jEr1ZDJTuIwehouDq+WA1YQyU8zPbgaZ9YjM4nwdY4StslTJgYfnk1jJ5gWjlT3Fwx8tdUVfbA==
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=rh6mMFBK64P5wZb+ppyB0dcKV5TjJKuBEtiJnIYiZwg=;
b=i4SncwO2w6IeBvbOznB5aociyshFbEhiWlnoLrcNJxTF2pgIL9Kj84z++Fjhq30Eyv62Awu2YfNHlMAxnLalS55AmxPAoXd5rNy0NGAlns5rRWMEHmD0YDYzayXet7+MEix0llOtFBdAsCQsbm0tUc1Yt1on6arBJxLmPvoV4WnYZAuLHjbugiBHQ7IDHFxc3gZw4K5LFytN17c81TKRwmumljOSH+0pQqzczpGHs2hgPUTlXSZmM4ZUjotAwcdwDMYYcTEkmTuGVCvPsVVbRoejgLxTm0Oxkagx8v0DviXvwcKX3ib2SGUI8qM63Tx1O+2g0UvvsYiSuhEljxYs/w==
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 SEYPR06MB7027.apcprd06.prod.outlook.com (2603:1096:101:1e3::11) with
Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.33; Wed, 31 Jul
2024 09:02:47 +0000
Received: from PUZPR06MB5676.apcprd06.prod.outlook.com
([fe80::a00b:f422:ac44:636f]) by PUZPR06MB5676.apcprd06.prod.outlook.com
([fe80::a00b:f422:ac44:636f%6]) with mapi id 15.20.7807.026; Wed, 31 Jul 2024
09:02:47 +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 2/2] udmabuf: make udmabuf folios and offsets set more
readable
Date: Wed, 31 Jul 2024 17:02:33 +0800
Message-ID: <20240731090233.1343559-2-link@vivo.com>
X-Mailer: git-send-email 2.45.2
In-Reply-To: <20240731090233.1343559-1-link@vivo.com>
References: <20240731090233.1343559-1-link@vivo.com>
X-ClientProxiedBy: SI2PR01CA0035.apcprd01.prod.exchangelabs.com
(2603:1096:4:192::13) 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_|SEYPR06MB7027:EE_
X-MS-Office365-Filtering-Correlation-Id: 6c10943a-cf4a-4452-c13e-08dcb13f8c1a
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam:
BCL:0;ARA:13230040|366016|376014|1800799024|52116014|38350700014;
X-Microsoft-Antispam-Message-Info:
lHQCp9t2YyrcqD4kPKk49qgMEHLFvgAlxq120pTPBAaczC+NRMnwum/VBJcpM3qXVaJZMn/iMkSpegyF3DAAT/xj7a0Qt3tj4zJN18BQ7wBMY/hBPePedvelLOphFH8xgoDkXHr4iLMK2yz0gRgzTB3qXe2BSdzQXzMBUgcl0ROjp13i+Qz7mKhrYRZULc4qVJBryT6l9HZiqDIKKxVHzsK87TF8AF+Kxzj7/AgmmaDgkRrlj6Lht6p3pYVWxnLZgRLixT+/cR/6l3Dx409lTcfavuSnKsxKPSLNyuqImo/3M5zZPD0tIomXeaN9vshuItiN0o2DH+WRlOoXMuLhRlfbAYTdtqFSX4+etPwuUXMjdQ9BjpH7idWD32z4TLs92gmjkVL6KfuChKQet+Rsaxskb1+Nnw5BTZhgcMrVdv1UQKnz7TOl8GFf2gCZYVjmlpWYUdUXm550vzOm3wEuGqTtNLWGPM+SbfMWXeV2X3lYNKLeRsWsDmfRwstQGiFvPmlpEDcRSL0RcvLWYhSroLFdcPWS64wJNpyzJg5ev36BfSyWuqRnWE57x1ViY+OT2dF0yqWAf98lofNpDF8AbECMs+wuR5ohk3BTEpm7vyc8JC1GAdzNwhKJVdSjMB0qF7NqkCt6CiuyLo+izJsOs5//Qkwsxn2r9voEjpcZiWpqBy/S4fUy1vLqs2jWHBzseaNGNMQptyNT/YzPn4+cIDNZUfe/loc/auKa6Lu1eZ2MsrX86oO0hQls0+0D3rxLAw5VkqF/lkwX2prcHMyvh9f4muatOALg7p/pw6WL9hrHWBBJbSRO+Jic6W2I42xikiJecZuJE8sBN1vXA2GHH6AijwLqIy7LAeUKtt4mBRjl2XIA1/G4cbhg/hyZ5Eze4f3jXOsOPpBalCv25xnaSHuqiX7ol84vIstlVfDb6URvziwuN/ZR9uxPS9G1XZChuTxYRjDd/qQ4e0cZPeiGA7OSE/RDaQlwi7aOwWqr5Mi0Oce7Hn2eeMIAdXr52ptPftjLwuaQ+Eva/Ib/WDGYxMGP6u/Yj+aEna0oxMUs3skuHZx8QLxzakmk6aA7w7KptXysN3ro77bJbvB1k/oQd4S8CuXBGreCDvKIopnPsUlEpzUifagGaUrTqQ3n8XZtylmgjLTqBA7H4K17ps1LsncfttbqG+EqhxT5URmfh0rZVQ1fGsOz7yGe6Cuv8D/gHwLrBj+pL9+UoXZSd5+PMQjRjLfUkJsN4bLX0NNvEoGS3EG6N9mFIzYQlvvHjEdAw5sD06utjijW7Nj4rN2rS60XA0j8/KuuzuRIeBEvAxsvLMGHd2Lv6KiSfvTKIwYT1RQvuNkFLGOi/U8k9isftM/zc6SX8cRL13/I/yZDgMWk3z8Ils4osIFF1tobJtyoTuIkyuatucd0tlBV41z1bQ==
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)(366016)(376014)(1800799024)(52116014)(38350700014);DIR:OUT;SFP:1101;
X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-MessageData-0:
lQ02AiDFhOE6uoaxFqHPB795rw8PpaESQzi/1bHUxYFkr5dnUBVEkUE7v4eDTIZYMQuNNm9VNhBEzDLOY7u8fFnYyyRg9DjPPvTS8+C6Q+6onF1t5Dy999n9znIri4oKAdo9jTcWzpdEH91updM8BLfcPYeZGXz56UGTunSQj9qit8msAkj6OJMnI8kg3yZN50lUZxQmPHz314v/rBJ+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xM/FDEc0/jxioqf7psVoW1xUH1Tr6r7U9f9ihS3JD/Q4zWqIywn2k6ruD7UH0AeoNRXJqeT0dDmoxWL+9cm+P0iPrLm1txS6vNjlkRyqtHGIymXXJY6fz44V2/+mhNncR/xfwH3I1GwqSodpZWz+RE6MJ2IBIl98Z/6+/cMf9VhT3O+twnFbBr4qeK2AodjqCU7/9Ha4vxmy7g2ZunQjKKp2bLQVn1zi+vJUG0XGSYlrljHOeVzj03HpIDOevHw6NSqPUhplsvqJ5Ma6zbxFzZwJpjjBc8cJG19eQINbEq/A5eeh90Bt4FcO
X-OriginatorOrg: vivo.com
X-MS-Exchange-CrossTenant-Network-Message-Id:
6c10943a-cf4a-4452-c13e-08dcb13f8c1a
X-MS-Exchange-CrossTenant-AuthSource: PUZPR06MB5676.apcprd06.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2024 09:02:47.2708
(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:
zqZ8EUSKMSj5uuje2ME9i8oo+xM+JpttON2kqXir4SDtqmRIllSvVNFLpy95XOj9b7WcWy1eQ+MZJTVHQ6kh3g==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB7027
The current code for setting folios and offsets is not very readable.
In fact, udmabuf->folios represents the head page of each folio, while
the offset indicates the PAGE_SIZE offset within the folio for the
corresponding pgcnt. And folios only add head page(the folio) into unpin
list.
This patch changes the loop condition to use folios as the outer loop
and sets the subpages of the folio in the inner loop, making it easier
to understand the relationship between unpin and folios/offset.
The loop conditions for j and k are actually only used in the head loop,
so they can be turned into loop variables.
Signed-off-by: Huan Yang
---
drivers/dma-buf/udmabuf.c | 40 ++++++++++++++++++++-------------------
1 file changed, 21 insertions(+), 19 deletions(-)
diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c
index 6604d91e7072..0285194e6b51 100644
--- a/drivers/dma-buf/udmabuf.c
+++ b/drivers/dma-buf/udmabuf.c
@@ -301,7 +301,7 @@ static long udmabuf_create(struct miscdevice *device,
struct file *memfd = NULL;
struct folio **folios;
struct udmabuf *ubuf;
- u32 i, j, k, flags;
+ u32 i, flags;
loff_t end;
ubuf = kzalloc(sizeof(*ubuf), GFP_KERNEL);
@@ -338,6 +338,7 @@ static long udmabuf_create(struct miscdevice *device,
pgbuf = 0;
for (i = 0; i < head->count; i++) {
+ u32 j, k;
memfd = fget(list[i].memfd);
ret = check_memfd_seals(memfd);
if (ret < 0)
@@ -360,26 +361,27 @@ static long udmabuf_create(struct miscdevice *device,
goto err;
}
- nr_folios = ret;
- pgoff >>= PAGE_SHIFT;
- for (j = 0, k = 0; j < pgcnt; j++) {
- ubuf->folios[pgbuf] = folios[k];
- ubuf->offsets[pgbuf] = pgoff << PAGE_SHIFT;
-
- if (j == 0 || ubuf->folios[pgbuf-1] != folios[k]) {
- ret = add_to_unpin_list(&ubuf->unpin_list,
- folios[k]);
- if (ret < 0) {
- kfree(folios);
- goto err;
- }
+ /**
+ * Iter each folios we got from pin, add each folio into unpin
+ * list and setup each folio and page offset into folio into
+ * corrent page count position.
+ * So that we can iter any offset in size and get correctly
+ * page.
+ */
+ for (j = 0, pgoff >>= PAGE_SHIFT, nr_folios = ret;
+ j < nr_folios; ++j, pgoff = 0) {
+ long nr_pages;
+
+ ret = add_to_unpin_list(&ubuf->unpin_list, folios[j]);
+ if (ret < 0) {
+ kfree(folios);
+ goto err;
}
- pgbuf++;
- if (++pgoff == folio_nr_pages(folios[k])) {
- pgoff = 0;
- if (++k == nr_folios)
- break;
+ for (k = 0, nr_pages = folio_nr_pages(folios[j]);
+ k < nr_pages; ++k, ++pgoff, ++pgbuf) {
+ ubuf->folios[pgbuf] = folios[j];
+ ubuf->offsets[pgbuf] = pgoff << PAGE_SHIFT;
}
}