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 1490CA00C2 for ; Thu, 21 Jul 2022 07:43:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DA66740A87; Thu, 21 Jul 2022 07:43:03 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2078.outbound.protection.outlook.com [40.107.237.78]) by mails.dpdk.org (Postfix) with ESMTP id 6F55740A7A for ; Thu, 21 Jul 2022 07:43:02 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I3mqiqvsUd4X8KsGuPENgMBObui3GTNrq3caqqz0p5+BKY2J6WgboSL9z8QG3pY/7BUFOOOjKp1AgxjjYVStju0hmigY6BpzmFCHllWF7aOj8enaq9KWdAb90GDXwxEsU7vO5W5aoRd/BSMp7SuMx+/pchxrcLrcFD4UQemUrKel4LVSCXrPHIYehkfPxFBYWf8VaaLdhP59kX5oeIJ80n0/p/3R2YAMGqa9H5+TOtVA3s08NThC6MTxOk4VnnawClRPBP4hGVe/kUlBBTi4xbNmrj3SO5LTj1ClXAQOcvfISjPbKOqvo6ga1fYPVfOcW6ke+iWb6S3CZmpeSd0gyQ== 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=ZDkvdKsr3kSd2LVtKuKcEwLBGMHjZ0nSsXc1sVUY17JSnc4YxRsJzJFgeQHtv4iddK9sw411UqnOLH7F39ZPvcgJFuAEZG8SSk1OjHaeAQeXJDMZNyu9oPYgC/CPNPUMcK7pwik4EfWh9TWLMpsUstOxTJDrRmfpcYiZMlgi/znjSGyyTEMyfFlqdapwe3++Jh0GUqDyNcq3c8GzuLPAkJnjLG4GH/HZz2nA9FmAAbvdVxU3wWr49zmMQBFyHNM8heWJ3LKtChiRpFSTQHKMRNiu+bh93OAD2Yr8v69JAhnpD5x3FKEYJNtPjxGmDagSDcdg15wiXve4kyMICc0zUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) 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=ozaehqkJ3MvcqGLBDYKTg/od/FCVdEATo/7kMPKcq5GjhEtiWTa+t9Tzt9vB/Tk62KkTuSB8qmaR6u8RzZkudRBw0/vebthsbikTVpDXA14xPd3BpM/8LXVZtqECzBiCNRbrjbE0NNjKARsi+k+UI8s+E7/yMMRld3eCxy5tvRxLgyeB49XWt+mEW4DEtU37l98QuJ4KM72kC25E6vOIzPqwc2mbBmJT7KauPEUVP1kEC1qTNQ1fuvE5LhP/DtQqFIkWAH10tNjE997q2Q2YK653kQQszLWxnryQpv06RRTcijFVCwqv9+7JXiis6Wjb33LnDrz52uzxA/H4WE8s/A== Received: from DS7PR05CA0073.namprd05.prod.outlook.com (2603:10b6:8:57::27) by BN9PR12MB5161.namprd12.prod.outlook.com (2603:10b6:408:11a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.17; Thu, 21 Jul 2022 05:43:01 +0000 Received: from DM6NAM11FT037.eop-nam11.prod.protection.outlook.com (2603:10b6:8:57:cafe::ec) by DS7PR05CA0073.outlook.office365.com (2603:10b6:8:57::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.1 via Frontend Transport; Thu, 21 Jul 2022 05:43:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) 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.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.238) by DM6NAM11FT037.mail.protection.outlook.com (10.13.172.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5458.17 via Frontend Transport; Thu, 21 Jul 2022 05:43:00 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Thu, 21 Jul 2022 05:43:00 +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; Wed, 20 Jul 2022 22:42:57 -0700 From: Yajun Wu To: CC: Matan Azrad , Maxime Coquelin Subject: [PATCH 20.11] vdpa/mlx5: workaround var offset within page Date: Thu, 21 Jul 2022 08:42:39 +0300 Message-ID: <20220721054239.378884-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: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7e9ecb07-35f9-4472-590a-08da6adbdfa7 X-MS-TrafficTypeDiagnostic: BN9PR12MB5161:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Yzz6FlrZGl/G+DUi1Gvz+QSDko8dVUfgWEA36ZihjS0To5yiNFQ+PkqBQnufRi3NC6sdNvu812y5/GayMB9wcZZYmD6vxtH8qt3JFm8q2/bW4/a/uvJjAgSjKdZO4mLWcA7M73uSESqjRE2QdsNgDUNOg+zn6SIeCeDyD1eBML91R7SwdU4g7zheLz02YDi9ar9bMlaiaFaj5Yr7vsopw6oynrtmweGu8ACWbnYM5+k2mg3m73Zatfqls4YALNOA/AT6d+iqRImKy4zwzuGqy339kGkTuY7Uj+JyLgoliCy8OsRh2yxnCx3KwHrfHkGECyjSBXHuVUmXd3xLDgj6j4f6hLygPYGHphxXT1krH619gSJLiKDq4J4Mtepur2SW/PTGkeE7llgw0Mg/SPW0TEbpUT2M6kc+nN08eHRfCRGStkjrBAGKTH09hV4zmkKrztKHReuBaceaRpiXoAFebSmIplUmiJmDjLp9pXTjwspGsuGqA4OjgXkvVjwzKko6fzzrhXe+tf3zxj44oO12c4zMJZEIroVU4Ol2f6DVR9y2Je0ErDWrOzlKt7xs53DE5AiSHWqv63orJjcicQTp85u4HoEK2QZneW2ZLBQftCmZnnSZGp0m+beTqk2NBzsouKsBdrgEq8QgoHfyaIoNCevwfmpeYSADruNygVyQwT9suzhBDnVskmGmjp47STiP21cZ1N81JH/9XP1i/KJpujVXczQf30InHMneeEM0WpBPzFYdc2K0htacdxeeCYUATBEqEzuTNC9i1XHXPVuoohtMuPWW+L5lhP2Ww45UvVgSPkXDkUjVHA7wETvkGyIfQ+ohOW9u1I1vCXH61kOY+g== X-Forefront-Antispam-Report: CIP:12.22.5.238; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230016)(4636009)(39860400002)(396003)(136003)(376002)(346002)(46966006)(40470700004)(36840700001)(7696005)(26005)(16526019)(41300700001)(356005)(336012)(83380400001)(478600001)(40460700003)(2616005)(426003)(186003)(1076003)(40480700001)(82310400005)(6286002)(36860700001)(55016003)(6916009)(8676002)(70586007)(6666004)(54906003)(8936002)(36756003)(4326008)(316002)(5660300002)(70206006)(47076005)(81166007)(2906002)(82740400003)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2022 05:43:00.7608 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e9ecb07-35f9-4472-590a-08da6adbdfa7 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.238]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT037.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5161 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