[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <05460d58380b435fb629d2e04a83a1aa@huawei.com>
Date: Tue, 8 Feb 2022 14:49:48 +0000
From: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@...wei.com>
To: Jason Gunthorpe <jgg@...dia.com>
CC: "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-crypto@...r.kernel.org" <linux-crypto@...r.kernel.org>,
"alex.williamson@...hat.com" <alex.williamson@...hat.com>,
"cohuck@...hat.com" <cohuck@...hat.com>,
"mgurtovoy@...dia.com" <mgurtovoy@...dia.com>,
"yishaih@...dia.com" <yishaih@...dia.com>,
Linuxarm <linuxarm@...wei.com>,
liulongfang <liulongfang@...wei.com>,
"Zengtao (B)" <prime.zeng@...ilicon.com>,
Jonathan Cameron <jonathan.cameron@...wei.com>,
"Wangzhou (B)" <wangzhou1@...ilicon.com>
Subject: RE: [RFC v4 6/8] crypto: hisilicon/qm: Add helper to retrieve the PF
qm data
> -----Original Message-----
> From: Jason Gunthorpe [mailto:jgg@...dia.com]
> Sent: 08 February 2022 14:25
> To: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@...wei.com>
> Cc: kvm@...r.kernel.org; linux-kernel@...r.kernel.org;
> linux-crypto@...r.kernel.org; alex.williamson@...hat.com;
> cohuck@...hat.com; mgurtovoy@...dia.com; yishaih@...dia.com; Linuxarm
> <linuxarm@...wei.com>; liulongfang <liulongfang@...wei.com>; Zengtao (B)
> <prime.zeng@...ilicon.com>; Jonathan Cameron
> <jonathan.cameron@...wei.com>; Wangzhou (B) <wangzhou1@...ilicon.com>
> Subject: Re: [RFC v4 6/8] crypto: hisilicon/qm: Add helper to retrieve the PF
> qm data
>
> On Tue, Feb 08, 2022 at 01:34:23PM +0000, Shameer Kolothum wrote:
>
> > +struct hisi_qm *hisi_qm_get_pf_qm(struct pci_dev *pdev)
> > +{
> > + struct hisi_qm *pf_qm;
> > + struct pci_driver *(*fn)(void) = NULL;
> > +
> > + if (!pdev->is_virtfn)
> > + return NULL;
> > +
> > + switch (pdev->device) {
> > + case PCI_DEVICE_ID_HUAWEI_SEC_VF:
> > + fn = symbol_get(hisi_sec_get_pf_driver);
> > + break;
> > + case PCI_DEVICE_ID_HUAWEI_HPRE_VF:
> > + fn = symbol_get(hisi_hpre_get_pf_driver);
> > + break;
> > + case PCI_DEVICE_ID_HUAWEI_ZIP_VF:
> > + fn = symbol_get(hisi_zip_get_pf_driver);
> > + break;
> > + default:
> > + return NULL;
> > + }
> > +
> > + if (!fn)
> > + return NULL;
> > +
> > + pf_qm = pci_iov_get_pf_drvdata(pdev, fn());
> > +
> > + if (pdev->device == PCI_DEVICE_ID_HUAWEI_SEC_VF)
> > + symbol_put(hisi_sec_get_pf_driver);
> > + else if (pdev->device == PCI_DEVICE_ID_HUAWEI_HPRE_VF)
> > + symbol_put(hisi_hpre_get_pf_driver);
> > + else
> > + symbol_put(hisi_zip_get_pf_driver);
> > +
> > + return !IS_ERR(pf_qm) ? pf_qm : NULL;
> > +}
> > +EXPORT_SYMBOL_GPL(hisi_qm_get_pf_qm);
>
> Why put this in this driver, why not in the vfio driver? And why use
> symbol_get ?
QM driver provides a generic common interface for all HiSilicon ACC
drivers. So thought of placing it here. And symbol_get/put is used
to avoid having dependency of all the ACC drivers being built along
with the vfio driver. Is there a better way to retrieve the struct pci_driver *
associated with each ACC PF driver? Please let me know.
Thanks,
Shameer
Powered by blists - more mailing lists