Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2095856pxb; Mon, 12 Apr 2021 14:21:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxXMgxur41tG3hCaZ+lKmp8YHN+ksAHJZpg1NzVEY4iPACr08t2ljoZL+WR4/+TI6UZHj4 X-Received: by 2002:a17:906:9501:: with SMTP id u1mr28760299ejx.324.1618262517123; Mon, 12 Apr 2021 14:21:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618262517; cv=none; d=google.com; s=arc-20160816; b=ilXivqS0P7dRe64MegQANORgcgAzW4tye/Xu4P6ylqTh9RFA6a0LB4YI5RwSIm174S t2SKYky78/2W3rkWWOEBAM0ThtwX8vIt6Dkp1RItFAVpBAIoG0NRqsZDB3iGoHJzny4L j8aK1ieqRWdE5hu4CJXbkEe935PPjADEeT1WYhJFSjX3MwdmO09nW2LAP0PMC1rzLWpM 2UjOdnv77NYa1z4B16mT3qjbeQDqSWnUxR4YSfjA6510S6KShQbmqT6qWOY9g87Eoacy LSCllJ9K/hLRNEJDddVYR1zOUi3tPU1MbGVd0/HHXgiXfL6V7n6EsMY/Y3h1fMtnMu20 pEyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=bn8SlrVECDrV5FHcB5iWtTenHDJqm10tgxnSRrtMrhc=; b=hSr4JaM+RpIS2Kj5T/wDuObBIwM8Zd0yE+5lEl3w7tymNdCjjj5/+gBgde2TzguPFE ijy5t5bW4cA80Rv/Z7CxJtE8yBHoajbJoOcbn4A1123z2gz0Y63yf2pGFE/XoEuY3n83 BQ6US7DeNyZaID687SwCRXtFqFchmpm5yBDM0o4wjMnOcRU2Xef7rkYjmZHAjR2sgYi3 yTlKavQw4ycr7+WBGncoozKZ2eQd3paxg5IPDdbDfxoIlRynlCqjWB1nUNjVusVLz45D CBI2TjaD8BA3OTUdVKGUxiqghp4WyplumJlhN7qr8tRJEjqi1DFfwndMK5yTGK1NPI3f Dyqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d19si8654782ejp.154.2021.04.12.14.21.34; Mon, 12 Apr 2021 14:21:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241086AbhDLJLm (ORCPT + 99 others); Mon, 12 Apr 2021 05:11:42 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:15665 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238423AbhDLI4X (ORCPT ); Mon, 12 Apr 2021 04:56:23 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FJjF26PsKznZBh; Mon, 12 Apr 2021 16:53:10 +0800 (CST) Received: from huawei.com (10.67.165.24) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Mon, 12 Apr 2021 16:55:52 +0800 From: Longfang Liu To: CC: , , , Subject: [RFC PATCH 2/3] vfio/hisilicon: register the driver to vfio Date: Mon, 12 Apr 2021 16:53:15 +0800 Message-ID: <1618217596-13621-3-git-send-email-liulongfang@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1618217596-13621-1-git-send-email-liulongfang@huawei.com> References: <1618217596-13621-1-git-send-email-liulongfang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Register the live migration driver of the accelerator module to vfio Signed-off-by: Longfang Liu Reviewed-by: Zengtao --- drivers/vfio/pci/vfio_pci.c | 11 +++++++++++ drivers/vfio/pci/vfio_pci_private.h | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index f041b1a..50d1138 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -293,6 +293,17 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev) } } + if (pdev->vendor == PCI_VENDOR_ID_HUAWEI && + IS_ENABLED(CONFIG_VFIO_PCI_HISI_MIGRATION)) { + ret = vfio_pci_hisilicon_acc_init(vdev); + if (ret && ret != -ENODEV) { + dev_warn(&vdev->pdev->dev, + "Failed to setup Hisilicon ACC region\n"); + vfio_pci_disable(vdev); + return ret; + } + } + vfio_pci_probe_mmaps(vdev); return 0; diff --git a/drivers/vfio/pci/vfio_pci_private.h b/drivers/vfio/pci/vfio_pci_private.h index f561ac1..74bb611 100644 --- a/drivers/vfio/pci/vfio_pci_private.h +++ b/drivers/vfio/pci/vfio_pci_private.h @@ -138,4 +138,14 @@ static inline int vfio_pci_igd_init(struct vfio_pci_device *vdev) return -ENODEV; } #endif + +#ifdef CONFIG_VFIO_PCI_HISI_MIGRATION +extern int vfio_pci_hisilicon_acc_init(struct vfio_pci_device *vdev); +#else +static inline int vfio_pci_hisilicon_acc_init(struct vfio_pci_device *vdev) +{ + return -ENODEV; +} +#endif + #endif /* VFIO_PCI_PRIVATE_H */ -- 2.8.1