Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2404610pxb; Tue, 13 Apr 2021 00:40:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJza2+d1f0nKX87N2W1RPQqF6FbCOshxg0qk7J66PtHIP/u+TlD/r0FWbcQWOd6F0cFbDQxP X-Received: by 2002:a05:6402:27ce:: with SMTP id c14mr33247799ede.263.1618299636838; Tue, 13 Apr 2021 00:40:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618299636; cv=none; d=google.com; s=arc-20160816; b=gPlGt4oRNY8riq0+1hZGVbc/HNytQRbPC3toXODlwmyNyOB6X3vxx1ik2jDD7DIRp0 9pvOA0F07G9VX2XF20AS1GgzBeR/Z4hIRjHO4k3qL47GvyoEdOiI7Wk4RsNKbr1kBRKc PCArmioZexoN+IwJgn31ZPdR0u1kzMCti6310OqHAls52seDKqOM214HSWOkaDJMzLQZ PgufKTD29hUnysKP0O2Y911UZa41rUYWQtrH3O0bSIGYwEgtOdcMIXx0OvXYt6/e7cGO VqWNwJys5BL8dZx//fsoXRHJEddSOorJ7UgWxAGxPI/+N75xo3ItMORXdXsobHI77uLT BXqg== 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=ZEOAfWc2o6pGIr7ZhDXLvkAQR9de2nVoIBWHi2Vg+Ss=; b=f/cTi8J1xVA21OpyT2KRHsI2hguXhPJ7o+gyQOZiH6tnAX8Es350mhNrrQ66bK5+V5 lQOmVjORIwK+C6KEdEv/MtC4kraiO01kZmNyC45uoKmaHhourLFmMotqto3zb/YCX6pE RAOyU8pa4DIMidtc0KvlAcPDbPq/ZFL4sISnNF9S2Ju8XdWuimhKJiVLucsoWhhD9JKx HI6FtbW74TXhZe15pejwv2dsCnjULz7l8kq1ZqQ9G1Tq6/fUqMvolMkg7aNklLbdRF7Y ND8tHeDEonY39MMbLmavtIZ8indCQVYe8tlDWsADBrLRDG0g7gSaR+g7HfL5s/OtUSmm 2qdw== 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 hr7si9833765ejc.596.2021.04.13.00.40.13; Tue, 13 Apr 2021 00:40:36 -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 S243808AbhDMBXb (ORCPT + 99 others); Mon, 12 Apr 2021 21:23:31 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:17316 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238132AbhDMBX2 (ORCPT ); Mon, 12 Apr 2021 21:23:28 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4FK78h1kP5z9yyN; Tue, 13 Apr 2021 09:20:52 +0800 (CST) Received: from huawei.com (10.67.165.24) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.498.0; Tue, 13 Apr 2021 09:22:58 +0800 From: Longfang Liu To: CC: , , , Subject: [RFC PATCH 2/3] vfio/hisilicon: register the driver to vfio Date: Tue, 13 Apr 2021 09:20:20 +0800 Message-ID: <1618276821-8320-3-git-send-email-liulongfang@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1618276821-8320-1-git-send-email-liulongfang@huawei.com> References: <1618276821-8320-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 --- 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