From: Matthew Rosato <mjrosato@linux.ibm.com> To: sebott@linux.ibm.com Cc: gerald.schaefer@de.ibm.com, pasic@linux.ibm.com, borntraeger@de.ibm.com, walling@linux.ibm.com, linux-s390@vger.kernel.org, iommu@lists.linux-foundation.org, joro@8bytes.org, linux-kernel@vger.kernel.org, alex.williamson@redhat.com, kvm@vger.kernel.org, heiko.carstens@de.ibm.com, robin.murphy@arm.com, gor@linux.ibm.com, cohuck@redhat.com, pmorel@linux.ibm.com Subject: [PATCH v4 1/4] s390: pci: Exporting access to CLP PCI function and PCI group Date: Fri, 6 Sep 2019 20:13:48 -0400 [thread overview] Message-ID: <1567815231-17940-2-git-send-email-mjrosato@linux.ibm.com> (raw) In-Reply-To: <1567815231-17940-1-git-send-email-mjrosato@linux.ibm.com> From: Pierre Morel <pmorel@linux.ibm.com> For the generic implementation of VFIO PCI we need to retrieve the hardware configuration for the PCI functions and the PCI function groups. We modify the internal function using CLP Query PCI function and CLP query PCI function group so that they can be called from outside the S390 architecture PCI code and prefix the two functions with "zdev" to make clear that they can be called knowing only the associated zdevice. Signed-off-by: Pierre Morel <pmorel@linux.ibm.com> Reviewed-by: Sebastian Ott <sebott@linux.ibm.com> --- arch/s390/include/asm/pci.h | 3 ++ arch/s390/pci/pci_clp.c | 71 +++++++++++++++++++++++---------------------- 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h index a2399ef..dd03212 100644 --- a/arch/s390/include/asm/pci.h +++ b/arch/s390/include/asm/pci.h @@ -266,4 +266,7 @@ static inline int __pcibus_to_node(const struct pci_bus *bus) #endif /* CONFIG_NUMA */ +int zdev_query_pci_fngrp(struct zpci_dev *zdev, + struct clp_req_rsp_query_pci_grp *rrb); +int zdev_query_pci_fn(struct zpci_dev *zdev, struct clp_req_rsp_query_pci *rrb); #endif diff --git a/arch/s390/pci/pci_clp.c b/arch/s390/pci/pci_clp.c index 9bdff4d..df06fdf 100644 --- a/arch/s390/pci/pci_clp.c +++ b/arch/s390/pci/pci_clp.c @@ -113,32 +113,18 @@ static void clp_store_query_pci_fngrp(struct zpci_dev *zdev, } } -static int clp_query_pci_fngrp(struct zpci_dev *zdev, u8 pfgid) +int zdev_query_pci_fngrp(struct zpci_dev *zdev, + struct clp_req_rsp_query_pci_grp *rrb) { - struct clp_req_rsp_query_pci_grp *rrb; - int rc; - - rrb = clp_alloc_block(GFP_KERNEL); - if (!rrb) - return -ENOMEM; - memset(rrb, 0, sizeof(*rrb)); rrb->request.hdr.len = sizeof(rrb->request); rrb->request.hdr.cmd = CLP_QUERY_PCI_FNGRP; rrb->response.hdr.len = sizeof(rrb->response); - rrb->request.pfgid = pfgid; + rrb->request.pfgid = zdev->pfgid; - rc = clp_req(rrb, CLP_LPS_PCI); - if (!rc && rrb->response.hdr.rsp == CLP_RC_OK) - clp_store_query_pci_fngrp(zdev, &rrb->response); - else { - zpci_err("Q PCI FGRP:\n"); - zpci_err_clp(rrb->response.hdr.rsp, rc); - rc = -EIO; - } - clp_free_block(rrb); - return rc; + return clp_req(rrb, CLP_LPS_PCI); } +EXPORT_SYMBOL(zdev_query_pci_fngrp); static int clp_store_query_pci_fn(struct zpci_dev *zdev, struct clp_rsp_query_pci *response) @@ -174,32 +160,49 @@ static int clp_store_query_pci_fn(struct zpci_dev *zdev, return 0; } -static int clp_query_pci_fn(struct zpci_dev *zdev, u32 fh) +int zdev_query_pci_fn(struct zpci_dev *zdev, struct clp_req_rsp_query_pci *rrb) +{ + + memset(rrb, 0, sizeof(*rrb)); + rrb->request.hdr.len = sizeof(rrb->request); + rrb->request.hdr.cmd = CLP_QUERY_PCI_FN; + rrb->response.hdr.len = sizeof(rrb->response); + rrb->request.fh = zdev->fh; + + return clp_req(rrb, CLP_LPS_PCI); +} + +static int clp_query_pci(struct zpci_dev *zdev) { struct clp_req_rsp_query_pci *rrb; + struct clp_req_rsp_query_pci_grp *grrb; int rc; rrb = clp_alloc_block(GFP_KERNEL); if (!rrb) return -ENOMEM; - memset(rrb, 0, sizeof(*rrb)); - rrb->request.hdr.len = sizeof(rrb->request); - rrb->request.hdr.cmd = CLP_QUERY_PCI_FN; - rrb->response.hdr.len = sizeof(rrb->response); - rrb->request.fh = fh; - - rc = clp_req(rrb, CLP_LPS_PCI); - if (!rc && rrb->response.hdr.rsp == CLP_RC_OK) { - rc = clp_store_query_pci_fn(zdev, &rrb->response); - if (rc) - goto out; - rc = clp_query_pci_fngrp(zdev, rrb->response.pfgid); - } else { + rc = zdev_query_pci_fn(zdev, rrb); + if (rc || rrb->response.hdr.rsp != CLP_RC_OK) { zpci_err("Q PCI FN:\n"); zpci_err_clp(rrb->response.hdr.rsp, rc); rc = -EIO; + goto out; } + rc = clp_store_query_pci_fn(zdev, &rrb->response); + if (rc) + goto out; + + grrb = (struct clp_req_rsp_query_pci_grp *)rrb; + rc = zdev_query_pci_fngrp(zdev, grrb); + if (rc || grrb->response.hdr.rsp != CLP_RC_OK) { + zpci_err("Q PCI FGRP:\n"); + zpci_err_clp(grrb->response.hdr.rsp, rc); + rc = -EIO; + goto out; + } + clp_store_query_pci_fngrp(zdev, &grrb->response); + out: clp_free_block(rrb); return rc; @@ -219,7 +222,7 @@ int clp_add_pci_device(u32 fid, u32 fh, int configured) zdev->fid = fid; /* Query function properties and update zdev */ - rc = clp_query_pci_fn(zdev, fh); + rc = clp_query_pci(zdev); if (rc) goto error; -- 1.8.3.1
WARNING: multiple messages have this Message-ID (diff)
From: Matthew Rosato <mjrosato@linux.ibm.com> To: sebott@linux.ibm.com Cc: linux-s390@vger.kernel.org, walling@linux.ibm.com, alex.williamson@redhat.com, gor@linux.ibm.com, kvm@vger.kernel.org, pmorel@linux.ibm.com, cohuck@redhat.com, heiko.carstens@de.ibm.com, linux-kernel@vger.kernel.org, pasic@linux.ibm.com, borntraeger@de.ibm.com, iommu@lists.linux-foundation.org, robin.murphy@arm.com, gerald.schaefer@de.ibm.com Subject: [PATCH v4 1/4] s390: pci: Exporting access to CLP PCI function and PCI group Date: Fri, 6 Sep 2019 20:13:48 -0400 [thread overview] Message-ID: <1567815231-17940-2-git-send-email-mjrosato@linux.ibm.com> (raw) In-Reply-To: <1567815231-17940-1-git-send-email-mjrosato@linux.ibm.com> From: Pierre Morel <pmorel@linux.ibm.com> For the generic implementation of VFIO PCI we need to retrieve the hardware configuration for the PCI functions and the PCI function groups. We modify the internal function using CLP Query PCI function and CLP query PCI function group so that they can be called from outside the S390 architecture PCI code and prefix the two functions with "zdev" to make clear that they can be called knowing only the associated zdevice. Signed-off-by: Pierre Morel <pmorel@linux.ibm.com> Reviewed-by: Sebastian Ott <sebott@linux.ibm.com> --- arch/s390/include/asm/pci.h | 3 ++ arch/s390/pci/pci_clp.c | 71 +++++++++++++++++++++++---------------------- 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h index a2399ef..dd03212 100644 --- a/arch/s390/include/asm/pci.h +++ b/arch/s390/include/asm/pci.h @@ -266,4 +266,7 @@ static inline int __pcibus_to_node(const struct pci_bus *bus) #endif /* CONFIG_NUMA */ +int zdev_query_pci_fngrp(struct zpci_dev *zdev, + struct clp_req_rsp_query_pci_grp *rrb); +int zdev_query_pci_fn(struct zpci_dev *zdev, struct clp_req_rsp_query_pci *rrb); #endif diff --git a/arch/s390/pci/pci_clp.c b/arch/s390/pci/pci_clp.c index 9bdff4d..df06fdf 100644 --- a/arch/s390/pci/pci_clp.c +++ b/arch/s390/pci/pci_clp.c @@ -113,32 +113,18 @@ static void clp_store_query_pci_fngrp(struct zpci_dev *zdev, } } -static int clp_query_pci_fngrp(struct zpci_dev *zdev, u8 pfgid) +int zdev_query_pci_fngrp(struct zpci_dev *zdev, + struct clp_req_rsp_query_pci_grp *rrb) { - struct clp_req_rsp_query_pci_grp *rrb; - int rc; - - rrb = clp_alloc_block(GFP_KERNEL); - if (!rrb) - return -ENOMEM; - memset(rrb, 0, sizeof(*rrb)); rrb->request.hdr.len = sizeof(rrb->request); rrb->request.hdr.cmd = CLP_QUERY_PCI_FNGRP; rrb->response.hdr.len = sizeof(rrb->response); - rrb->request.pfgid = pfgid; + rrb->request.pfgid = zdev->pfgid; - rc = clp_req(rrb, CLP_LPS_PCI); - if (!rc && rrb->response.hdr.rsp == CLP_RC_OK) - clp_store_query_pci_fngrp(zdev, &rrb->response); - else { - zpci_err("Q PCI FGRP:\n"); - zpci_err_clp(rrb->response.hdr.rsp, rc); - rc = -EIO; - } - clp_free_block(rrb); - return rc; + return clp_req(rrb, CLP_LPS_PCI); } +EXPORT_SYMBOL(zdev_query_pci_fngrp); static int clp_store_query_pci_fn(struct zpci_dev *zdev, struct clp_rsp_query_pci *response) @@ -174,32 +160,49 @@ static int clp_store_query_pci_fn(struct zpci_dev *zdev, return 0; } -static int clp_query_pci_fn(struct zpci_dev *zdev, u32 fh) +int zdev_query_pci_fn(struct zpci_dev *zdev, struct clp_req_rsp_query_pci *rrb) +{ + + memset(rrb, 0, sizeof(*rrb)); + rrb->request.hdr.len = sizeof(rrb->request); + rrb->request.hdr.cmd = CLP_QUERY_PCI_FN; + rrb->response.hdr.len = sizeof(rrb->response); + rrb->request.fh = zdev->fh; + + return clp_req(rrb, CLP_LPS_PCI); +} + +static int clp_query_pci(struct zpci_dev *zdev) { struct clp_req_rsp_query_pci *rrb; + struct clp_req_rsp_query_pci_grp *grrb; int rc; rrb = clp_alloc_block(GFP_KERNEL); if (!rrb) return -ENOMEM; - memset(rrb, 0, sizeof(*rrb)); - rrb->request.hdr.len = sizeof(rrb->request); - rrb->request.hdr.cmd = CLP_QUERY_PCI_FN; - rrb->response.hdr.len = sizeof(rrb->response); - rrb->request.fh = fh; - - rc = clp_req(rrb, CLP_LPS_PCI); - if (!rc && rrb->response.hdr.rsp == CLP_RC_OK) { - rc = clp_store_query_pci_fn(zdev, &rrb->response); - if (rc) - goto out; - rc = clp_query_pci_fngrp(zdev, rrb->response.pfgid); - } else { + rc = zdev_query_pci_fn(zdev, rrb); + if (rc || rrb->response.hdr.rsp != CLP_RC_OK) { zpci_err("Q PCI FN:\n"); zpci_err_clp(rrb->response.hdr.rsp, rc); rc = -EIO; + goto out; } + rc = clp_store_query_pci_fn(zdev, &rrb->response); + if (rc) + goto out; + + grrb = (struct clp_req_rsp_query_pci_grp *)rrb; + rc = zdev_query_pci_fngrp(zdev, grrb); + if (rc || grrb->response.hdr.rsp != CLP_RC_OK) { + zpci_err("Q PCI FGRP:\n"); + zpci_err_clp(grrb->response.hdr.rsp, rc); + rc = -EIO; + goto out; + } + clp_store_query_pci_fngrp(zdev, &grrb->response); + out: clp_free_block(rrb); return rc; @@ -219,7 +222,7 @@ int clp_add_pci_device(u32 fid, u32 fh, int configured) zdev->fid = fid; /* Query function properties and update zdev */ - rc = clp_query_pci_fn(zdev, fh); + rc = clp_query_pci(zdev); if (rc) goto error; -- 1.8.3.1 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2019-09-07 0:14 UTC|newest] Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-09-07 0:13 [PATCH v4 0/4] Retrieving zPCI specific info with VFIO Matthew Rosato 2019-09-07 0:13 ` Matthew Rosato 2019-09-07 0:13 ` Matthew Rosato [this message] 2019-09-07 0:13 ` [PATCH v4 1/4] s390: pci: Exporting access to CLP PCI function and PCI group Matthew Rosato 2019-09-07 0:13 ` [PATCH v4 2/4] s390: pci: Define the maxstbl CLP response entry Matthew Rosato 2019-09-07 0:13 ` Matthew Rosato 2019-09-07 0:13 ` [PATCH v4 3/4] vfio: zpci: defining the VFIO headers Matthew Rosato 2019-09-07 0:13 ` Matthew Rosato 2019-09-19 15:20 ` Cornelia Huck 2019-09-19 15:20 ` Cornelia Huck 2019-09-19 20:55 ` Matthew Rosato 2019-09-19 20:55 ` Matthew Rosato 2019-09-19 22:27 ` Alex Williamson 2019-09-19 22:27 ` Alex Williamson 2019-09-19 22:49 ` Alex Williamson 2019-09-19 22:49 ` Alex Williamson 2019-09-20 14:46 ` Matthew Rosato 2019-09-20 14:46 ` Matthew Rosato 2019-09-20 14:02 ` Cornelia Huck 2019-09-20 14:02 ` Cornelia Huck 2019-09-20 15:14 ` Matthew Rosato 2019-09-20 15:14 ` Matthew Rosato 2019-10-08 13:30 ` Cornelia Huck 2019-10-08 13:30 ` Cornelia Huck 2019-09-07 0:13 ` [PATCH v4 4/4] vfio: pci: Using a device region to retrieve zPCI information Matthew Rosato 2019-09-07 0:13 ` Matthew Rosato 2019-09-19 15:25 ` Cornelia Huck 2019-09-19 15:25 ` Cornelia Huck 2019-09-19 20:57 ` Matthew Rosato 2019-09-19 20:57 ` Matthew Rosato 2019-09-19 20:57 ` Matthew Rosato 2019-09-20 14:26 ` Cornelia Huck 2019-09-20 14:26 ` Cornelia Huck 2019-09-20 15:53 ` Matthew Rosato 2019-09-20 15:53 ` Matthew Rosato 2019-09-19 22:57 ` Alex Williamson 2019-09-19 22:57 ` Alex Williamson 2019-09-20 14:57 ` Matthew Rosato 2019-09-20 14:57 ` Matthew Rosato 2019-09-19 1:36 ` [PATCH v4 0/4] Retrieving zPCI specific info with VFIO Matthew Rosato 2019-09-19 1:36 ` Matthew Rosato
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1567815231-17940-2-git-send-email-mjrosato@linux.ibm.com \ --to=mjrosato@linux.ibm.com \ --cc=alex.williamson@redhat.com \ --cc=borntraeger@de.ibm.com \ --cc=cohuck@redhat.com \ --cc=gerald.schaefer@de.ibm.com \ --cc=gor@linux.ibm.com \ --cc=heiko.carstens@de.ibm.com \ --cc=iommu@lists.linux-foundation.org \ --cc=joro@8bytes.org \ --cc=kvm@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-s390@vger.kernel.org \ --cc=pasic@linux.ibm.com \ --cc=pmorel@linux.ibm.com \ --cc=robin.murphy@arm.com \ --cc=sebott@linux.ibm.com \ --cc=walling@linux.ibm.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.