From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 89A5EA034C for ; Tue, 28 Jun 2022 04:49:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4DE68400D6; Tue, 28 Jun 2022 04:49:24 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2068.outbound.protection.outlook.com [40.107.220.68]) by mails.dpdk.org (Postfix) with ESMTP id ABB46400D6 for ; Tue, 28 Jun 2022 04:49:22 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=doGoBN9i65YVp3Qvf6xtkPiELJ+uQW+nD2rGvdvyf1a0VM0iUKU4rgQ+5quGgOeWREjhP14pGiWxGT1l1SFUsYQz1J0XJ8/YFMU7Q9ak39kXsPRPBoLojAdNsqSlLwCMoPmrof7iLalB9hlOLgONv0r+5xrAHQS+XG6UT8dLq06snuVfIckIq3Dk9xynjAW213DfiiEqJnHT1ECs1fV2uPv/RHrdU6bZNGP+TM8AWRT8Zayquri0TCCM1f8mV52mkcEZ01ngjUpqnusN1hVkYcpmIbXehQ8hcYcHlCnJPpSE45h6tr4lPlIw1WVgI3asuSvE+xcp6cLekyP6z5F5jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=LTYgqP6vVGNqib1u1pYQB70DPc0f9BVig9jKCt3zVwY=; b=c5jMjFwndWRmpRO6qiFAJdDSeIIhqhshak8wmdvtH8/f0/JQYGm1refCyhuHZF89AtLfH42DEGGuYLtfDnPqwH4EBZpe5y/0ZmUV6KRTQ8WNMb6g0M4rFRHRp5G1smPx8goYSZEWr36WoYxsbR6sl35Y+TbLSUysRHnqAFOPZnTDrfcS4VZRq8rTCUSqWQ5ld/flSLtE/pIk0Q9UCDziA0uhUoKNoYhI1wemZQ0m5UC9qCRv2guDRfb4a7RRzvSJzxzBzXS8Ng6rNRWYypAkve3gexJ5iy+XITBfTi6L4vIsKZc8P+mM5aDqHdEETZPogHg3pPFVkn6agqGexilCRA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LTYgqP6vVGNqib1u1pYQB70DPc0f9BVig9jKCt3zVwY=; b=N+DABB5ONopZnrwKR4O62PCPL+aBMy//UTxKg6Vgepw5NsbwCNHL+AN0KP4Lzoq4PObz6cyV1AxPpYzWvKa8bLwfrhHN5cKdUCFUWo5vwfHtAHKn5Gou9S3QR54OX3utVuE+GP5d2h043nFmUIDzk8UNE6y8NXXCsL7sol9/LPtmpj4bW0lIOa17dyusTrJJDykbzNU2X2w5MUah7NpyEkbo0D+qeTjn9sReeWDlib1fD3PZTPc/FjR8sSceb9RaObwPF/pJJtNyv/K1QdLZT4ff/T1rT8Nh8d90iQGdIR60BtYScbJeOk+MoaSn5b45JIbe1v/Ybc0F8HwC86V+Pg== Received: from BN1PR13CA0019.namprd13.prod.outlook.com (2603:10b6:408:e2::24) by CY5PR12MB6623.namprd12.prod.outlook.com (2603:10b6:930:41::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.15; Tue, 28 Jun 2022 02:49:19 +0000 Received: from BN8NAM11FT009.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e2:cafe::63) by BN1PR13CA0019.outlook.office365.com (2603:10b6:408:e2::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.14 via Frontend Transport; Tue, 28 Jun 2022 02:49:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.234) by BN8NAM11FT009.mail.protection.outlook.com (10.13.176.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5373.15 via Frontend Transport; Tue, 28 Jun 2022 02:49:19 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Tue, 28 Jun 2022 02:49:18 +0000 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Mon, 27 Jun 2022 19:49:16 -0700 From: Yajun Wu To: CC: Matan Azrad , Maxime Coquelin Subject: [PATCH 21.11] vdpa/mlx5: workaround var offset within page Date: Tue, 28 Jun 2022 05:47:49 +0300 Message-ID: <20220628024748.2424880-1-yajunw@nvidia.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 69d9fca8-b162-4cfa-b6ef-08da58b0cc62 X-MS-TrafficTypeDiagnostic: CY5PR12MB6623:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vppPAA+Zg2u3JnCITkoq4WBmDNIWs89Hg5/oSME5ByE+Ic8qHpylgv5rN8WLe+5dyg8jbpsb4cT58WuhdOGR2q3PxB4ZnmIt5P7VN1lYvv7/OEgU+QOxV1WDTuceXIs52U6LtH/aSlsjVVm++c8QeaD6SJuDV6OU1lsNZi+x2l22LWuYopTVysgflPMGdmyklMz/3JRU0IKxKvdsqFgGQvoq5M/ELUxduP3AEqK5jvYeQHNd+kx9igL6BY3kQLhh2MexaCOBUWV2F9GhWRUpXLW78raOJgrqKqDclnACYW19JWrzwgMV7Z3ml0aO/FJJ4FT7qxZ21PWDf5rdoIVh+qQeud3IxskNr0QkP7OGNuQI1dTJohTdN4L78mX9zVrvTdgA4UhvwWSangaHSOyxYu6Ldt0jpDOzWzUQOd6TreRHjjgYJ/A9deSfztCLOEtjY/c8ujzx9PnijmnBYds2ciNspi5XU3u4tZE1OCI0B8WPq1h7I8JscB6/fZ0g8askslF4C3/8R9JBmvnfHpiL158m0wbLjCiUeg3udCxTGA1+xOyjteCrXT1Tjpm0UgWLDqqa47qx74Zk70AQmG56ftiUeQzE2vHmuTG67Ka800891uMD4456wQt3uncqUivXZXvUQxmNPZd5VaKjpKHsiGcaumoce3kIFDYXsqHlMjAHFVXO0H3tNGq0zAYk9z0Imr5CCJwl1AoNoUgSU2XQV2jNrX01xDfKSmerk0knE/A1Kv718X7Ir6KMA1BF3WdJarFcd+lZgz8XI8y1+n3Kn+hz1y4E41Bqdf5wBRERNe4Gx+2P3D7FyELKyKa39zYtmumER+hbVJLdHg63FoZJUA== X-Forefront-Antispam-Report: CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230016)(4636009)(396003)(346002)(39860400002)(376002)(136003)(40470700004)(36840700001)(46966006)(36756003)(36860700001)(41300700001)(40480700001)(55016003)(478600001)(6666004)(8676002)(4326008)(2616005)(82740400003)(356005)(7696005)(70206006)(1076003)(54906003)(6916009)(2906002)(86362001)(81166007)(336012)(16526019)(5660300002)(8936002)(186003)(47076005)(82310400005)(83380400001)(70586007)(316002)(40460700003)(26005)(426003)(6286002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2022 02:49:19.1137 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 69d9fca8-b162-4cfa-b6ef-08da58b0cc62 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.234]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT009.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6623 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org [ upstream commit 95af59b7ad9f6a465de2ead9ef709429678e750d ] vDPA driver first uses kernel driver to allocate doorbell(VAR) area for each device. Then uses var->mmap_off and var->length to mmap uverbs device file as doorbell userspace virtual address. Current kernel driver provides var->mmap_off equal to page start of VAR. It's fine with x86 4K page server, because VAR physical address is only 4K aligned thus locate in 4K page start. But with aarch64 64K page server, the actual VAR physical address has offset within page(not locate in 64K page start). So vDPA driver need add this within page offset(caps.doorbell_bar_offset) to get right VAR virtual address. Fixes: 62c813706e4 ("vdpa/mlx5: map doorbell") Signed-off-by: Yajun Wu Acked-by: Matan Azrad Reviewed-by: Maxime Coquelin --- drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c index 0ef7ed0e4a..952e641425 100644 --- a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c +++ b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -122,7 +123,9 @@ mlx5_vdpa_virtqs_release(struct mlx5_vdpa_priv *priv) priv->td = NULL; } if (priv->virtq_db_addr) { - claim_zero(munmap(priv->virtq_db_addr, priv->var->length)); + /* Mask out the within page offset for munmap. */ + claim_zero(munmap((void *)((uintptr_t)priv->virtq_db_addr & + ~(rte_mem_page_size() - 1)), priv->var->length)); priv->virtq_db_addr = NULL; } priv->features = 0; @@ -485,6 +488,10 @@ mlx5_vdpa_virtqs_prepare(struct mlx5_vdpa_priv *priv) priv->virtq_db_addr = NULL; goto error; } else { + /* Add within page offset for 64K page system. */ + priv->virtq_db_addr = (char *)priv->virtq_db_addr + + ((rte_mem_page_size() - 1) & + priv->caps.doorbell_bar_offset); DRV_LOG(DEBUG, "VAR address of doorbell mapping is %p.", priv->virtq_db_addr); } -- 2.27.0