From patchwork Thu Sep 8 18:34:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 12970502 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 1BAD6C6FA86 for ; Thu, 8 Sep 2022 18:36:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232241AbiIHSgU (ORCPT ); Thu, 8 Sep 2022 14:36:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232154AbiIHSfw (ORCPT ); Thu, 8 Sep 2022 14:35:52 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2058.outbound.protection.outlook.com [40.107.93.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41B0BE917C; Thu, 8 Sep 2022 11:35:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bXTz56kc/dTXWrIOme2nR8NEkJiABVSxHw8HY4VJ3pmNFJLIfdq+m5ldd39vG+IALI2wfrlAFBh/kw8ZaNTxmxMGUUVbY6G4uxBQ0TkrfIcWWqJAllNGXoqcOXBXqpficJnACaq0c0d5Rb7lOHcpiVVCInhUn2YBs0hoZKM5Lg6Gm0j4Nx8/ionbsOWzxrvBM3i4Qr1qMYEl1YH7xY7oPRMz2lVPnTTlOLnNBY663MamkSlXymwHjomSgUEoi0SUYYoh7w+teXs1aNhVkB4hqaWYRrg7rSboX31C743jfuG45xqs+cU0WF6V/vZD/iPG6VP0QQEbDJrzoVjPbV0Q9Q== 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=uE6sjx0oSA79BfIgkJVMlmUd3p6BL3oGNTJ2eCqwAtA=; b=VGG7vzWBeCkye0aGMcHdo3n7UgHnAXdNc0QEu4bzmqnOBd/i0rpJN+3garc6bPQDn71YGk3+VacUnTp5zqKFjmFCEcjHx5xdkPsCmF5JLFNu17SXQl1B4xkhG0s/cwRStYxPC9OBfjI+ugQno+sekBOIjTwZHOV3tcZ5mpbacFkgBRNSKvJVPHTqN9dyhy0G7gkH2T7YUp6f7Yb6ijQcobDDIzSiLXElFMKa+xvKZ+tK6r31HV7r9ayUxzp+Au5YqQT2qmDEDI4w3ArRb43NsYQMmPlTtWd5HnhWghwAMf4BZW7sUEeCijlJkiE/EVdIgIQPGVCnPOTfbCGD4uQUCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) smtp.rcpttodomain=intel.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=uE6sjx0oSA79BfIgkJVMlmUd3p6BL3oGNTJ2eCqwAtA=; b=SqgLQSbPzqm6f4H8XOz2352RSKOkSWJV3Tluasd2uOJ/GaagZ7led0YuR+mHsCn0ysVtwN5MO7H1uuoQS/jwZ8tk2quhSiAQVzaegH00xDF/z9Nt73mqtPN2U3x5MYVSRXLGWPn/8EMv3dkXZhhjDLYldGm1jW2QxVLx3IJfh74a/s0VQr9HC5vas6o3ZDIAzE1REsI/mw9IwPDOmQDJHkuXwg4QOW+hTvi6g0TRub7QBWREgxqbv23ZaNbTprQ586+k8TW3f2fvVvmArQ7H9YIBexJOxklVkLnsXCyxdYfM/LScsaveaqHZhwKffVMDFd0be7qud9/XMu/JImy30w== Received: from MW4PR04CA0091.namprd04.prod.outlook.com (2603:10b6:303:83::6) by PH0PR12MB5419.namprd12.prod.outlook.com (2603:10b6:510:e9::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.16; Thu, 8 Sep 2022 18:35:49 +0000 Received: from CO1NAM11FT078.eop-nam11.prod.protection.outlook.com (2603:10b6:303:83:cafe::6c) by MW4PR04CA0091.outlook.office365.com (2603:10b6:303:83::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.14 via Frontend Transport; Thu, 8 Sep 2022 18:35:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) 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.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.235) by CO1NAM11FT078.mail.protection.outlook.com (10.13.175.177) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5612.13 via Frontend Transport; Thu, 8 Sep 2022 18:35:49 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Thu, 8 Sep 2022 18:35:48 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Thu, 8 Sep 2022 11:35:47 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.29 via Frontend Transport; Thu, 8 Sep 2022 11:35:44 -0700 From: Yishai Hadas To: , CC: , , , , , , , , , Subject: [PATCH V7 vfio 10/10] vfio/mlx5: Set the driver DMA logging callbacks Date: Thu, 8 Sep 2022 21:34:48 +0300 Message-ID: <20220908183448.195262-11-yishaih@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220908183448.195262-1-yishaih@nvidia.com> References: <20220908183448.195262-1-yishaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT078:EE_|PH0PR12MB5419:EE_ X-MS-Office365-Filtering-Correlation-Id: c3bcc088-9880-4401-63e9-08da91c8f387 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: L0osUvJovlBl0ydftER/7Z86efzpLfP/Bq5qLtD+NvVVLxXDfPnjgEHuNXrowleDzu+G/JC2i/6R0TCDXwC9tOUbZbkBU41Ij2MBo7YzaAgg0i6vnspGeC1EQpx2n9w9OwouLYa+DgiMBTCEJQ2a0OUMYEhUYLrayQr7Y1KJUGJ3kK+1fYat0oRsCSCCBTunDG+6xmCbtnp8MdO4fPZiTbyEHVn3mezI6A31/GavN4oPOqIxtwrH73i7gjcUxKHWgtY0kfFPk1mdQnsrRQ21y2osrGTFE+je6doVpssmi/I65FzJvQx/tSxCOXgR4sbr8V9sHLUKxNT9phkH1S/csWv82zXuRDu4n4rRHxFc9dftzJ0ue7cP/GvtQQvU0T4s1pQhq8TpoX4KvWNzj9eIaci7KhUFYMMuW6TW9UOzBKKvSJuiIGxz2yh1fEcPvTnwtrkZEEv2T1PhSmMiVQo18+LyjNhfBaaj9dJP0w8dgbP4g8y+Huy2cQhHU94Paba4YLYNCwSRBMKMQsOkNCT3pRUNqvQBirShr6Z/voS2sXTEtwSbMePJGwcJ5B1+UQEOioRIDzJ39m5F3gY/NwDNy3la4MMVugSWx96QHDXxIIz5pLnxbpZ02HR9KJhk20iZ4yjk3OM39W1hFVh6Vq7FAsT7ooPdpqsLhMRQZmmJxA3chSE/XOaKBYkg2RmEcKAT0SAFqog8zBX2LMiSAQcGtcfBCaO0xQe1mgNb72f+TdPmS3kPbGdQqI9LMlhQZgoEEngl3AJdqdd+hbpSOmLuM22jjOXXf5vk39RwFV/0WqnB7vebrBs+9WnbU1uN3hJj X-Forefront-Antispam-Report: CIP:12.22.5.235;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230016)(4636009)(376002)(136003)(39860400002)(396003)(346002)(46966006)(36840700001)(40470700004)(478600001)(81166007)(26005)(356005)(36860700001)(7696005)(41300700001)(426003)(83380400001)(47076005)(186003)(6636002)(1076003)(336012)(2616005)(82740400003)(8936002)(8676002)(70586007)(4326008)(86362001)(70206006)(40480700001)(82310400005)(36756003)(2906002)(54906003)(316002)(110136005)(5660300002)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2022 18:35:49.0319 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c3bcc088-9880-4401-63e9-08da91c8f387 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.235];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT078.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5419 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Now that everything is ready set the driver DMA logging callbacks if supported by the device. Signed-off-by: Yishai Hadas --- drivers/vfio/pci/mlx5/cmd.c | 5 ++++- drivers/vfio/pci/mlx5/cmd.h | 3 ++- drivers/vfio/pci/mlx5/main.c | 9 ++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/pci/mlx5/cmd.c b/drivers/vfio/pci/mlx5/cmd.c index 3e92b4d92be2..c604b70437a5 100644 --- a/drivers/vfio/pci/mlx5/cmd.c +++ b/drivers/vfio/pci/mlx5/cmd.c @@ -126,7 +126,8 @@ void mlx5vf_cmd_remove_migratable(struct mlx5vf_pci_core_device *mvdev) } void mlx5vf_cmd_set_migratable(struct mlx5vf_pci_core_device *mvdev, - const struct vfio_migration_ops *mig_ops) + const struct vfio_migration_ops *mig_ops, + const struct vfio_log_ops *log_ops) { struct pci_dev *pdev = mvdev->core_device.pdev; int ret; @@ -169,6 +170,8 @@ void mlx5vf_cmd_set_migratable(struct mlx5vf_pci_core_device *mvdev, VFIO_MIGRATION_P2P; mvdev->core_device.vdev.mig_ops = mig_ops; init_completion(&mvdev->tracker_comp); + if (MLX5_CAP_GEN(mvdev->mdev, adv_virtualization)) + mvdev->core_device.vdev.log_ops = log_ops; end: mlx5_vf_put_core_dev(mvdev->mdev); diff --git a/drivers/vfio/pci/mlx5/cmd.h b/drivers/vfio/pci/mlx5/cmd.h index 8b0ae40c620c..921d5720a1e5 100644 --- a/drivers/vfio/pci/mlx5/cmd.h +++ b/drivers/vfio/pci/mlx5/cmd.h @@ -118,7 +118,8 @@ int mlx5vf_cmd_resume_vhca(struct mlx5vf_pci_core_device *mvdev, u16 op_mod); int mlx5vf_cmd_query_vhca_migration_state(struct mlx5vf_pci_core_device *mvdev, size_t *state_size); void mlx5vf_cmd_set_migratable(struct mlx5vf_pci_core_device *mvdev, - const struct vfio_migration_ops *mig_ops); + const struct vfio_migration_ops *mig_ops, + const struct vfio_log_ops *log_ops); void mlx5vf_cmd_remove_migratable(struct mlx5vf_pci_core_device *mvdev); void mlx5vf_cmd_close_migratable(struct mlx5vf_pci_core_device *mvdev); int mlx5vf_cmd_save_vhca_state(struct mlx5vf_pci_core_device *mvdev, diff --git a/drivers/vfio/pci/mlx5/main.c b/drivers/vfio/pci/mlx5/main.c index a9b63d15c5d3..759a5f5f7b3f 100644 --- a/drivers/vfio/pci/mlx5/main.c +++ b/drivers/vfio/pci/mlx5/main.c @@ -579,6 +579,12 @@ static const struct vfio_migration_ops mlx5vf_pci_mig_ops = { .migration_get_state = mlx5vf_pci_get_device_state, }; +static const struct vfio_log_ops mlx5vf_pci_log_ops = { + .log_start = mlx5vf_start_page_tracker, + .log_stop = mlx5vf_stop_page_tracker, + .log_read_and_clear = mlx5vf_tracker_read_and_clear, +}; + static const struct vfio_device_ops mlx5vf_pci_ops = { .name = "mlx5-vfio-pci", .open_device = mlx5vf_pci_open_device, @@ -602,7 +608,8 @@ static int mlx5vf_pci_probe(struct pci_dev *pdev, if (!mvdev) return -ENOMEM; vfio_pci_core_init_device(&mvdev->core_device, pdev, &mlx5vf_pci_ops); - mlx5vf_cmd_set_migratable(mvdev, &mlx5vf_pci_mig_ops); + mlx5vf_cmd_set_migratable(mvdev, &mlx5vf_pci_mig_ops, + &mlx5vf_pci_log_ops); dev_set_drvdata(&pdev->dev, &mvdev->core_device); ret = vfio_pci_core_register_device(&mvdev->core_device); if (ret)