2022-01-14 23:06:51

by Matthew Rosato

[permalink] [raw]
Subject: [PATCH v2 11/30] s390/pci: add helper function to find device by handle

Intercepted zPCI instructions will specify the desired function via a
function handle. Add a routine to find the device with the specified
handle.

Acked-by: Niklas Schnelle <[email protected]>
Reviewed-by: Christian Borntraeger <[email protected]>
Reviewed-by: Eric Farman <[email protected]>
Signed-off-by: Matthew Rosato <[email protected]>
---
arch/s390/include/asm/pci.h | 1 +
arch/s390/pci/pci.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+)

diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h
index 1a8f9f42da3a..00a2c24d6d2b 100644
--- a/arch/s390/include/asm/pci.h
+++ b/arch/s390/include/asm/pci.h
@@ -275,6 +275,7 @@ static inline struct zpci_dev *to_zpci_dev(struct device *dev)
}

struct zpci_dev *get_zdev_by_fid(u32);
+struct zpci_dev *get_zdev_by_fh(u32 fh);

/* DMA */
int zpci_dma_init(void);
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 0c9879dae752..1e939b4cf25e 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -76,6 +76,22 @@ struct zpci_dev *get_zdev_by_fid(u32 fid)
return zdev;
}

+struct zpci_dev *get_zdev_by_fh(u32 fh)
+{
+ struct zpci_dev *tmp, *zdev = NULL;
+
+ spin_lock(&zpci_list_lock);
+ list_for_each_entry(tmp, &zpci_list, entry) {
+ if (tmp->fh == fh) {
+ zdev = tmp;
+ break;
+ }
+ }
+ spin_unlock(&zpci_list_lock);
+ return zdev;
+}
+EXPORT_SYMBOL_GPL(get_zdev_by_fh);
+
void zpci_remove_reserved_devices(void)
{
struct zpci_dev *tmp, *zdev;
--
2.27.0


2022-01-20 02:10:32

by Pierre Morel

[permalink] [raw]
Subject: Re: [PATCH v2 11/30] s390/pci: add helper function to find device by handle



On 1/14/22 21:31, Matthew Rosato wrote:
> Intercepted zPCI instructions will specify the desired function via a
> function handle. Add a routine to find the device with the specified
> handle.
>
> Acked-by: Niklas Schnelle <[email protected]>
> Reviewed-by: Christian Borntraeger <[email protected]>
> Reviewed-by: Eric Farman <[email protected]>
> Signed-off-by: Matthew Rosato <[email protected]>

Reviewed-by: Pierre Morel <[email protected]>


> ---
> arch/s390/include/asm/pci.h | 1 +
> arch/s390/pci/pci.c | 16 ++++++++++++++++
> 2 files changed, 17 insertions(+)
>
> diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h
> index 1a8f9f42da3a..00a2c24d6d2b 100644
> --- a/arch/s390/include/asm/pci.h
> +++ b/arch/s390/include/asm/pci.h
> @@ -275,6 +275,7 @@ static inline struct zpci_dev *to_zpci_dev(struct device *dev)
> }
>
> struct zpci_dev *get_zdev_by_fid(u32);
> +struct zpci_dev *get_zdev_by_fh(u32 fh);
>
> /* DMA */
> int zpci_dma_init(void);
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index 0c9879dae752..1e939b4cf25e 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -76,6 +76,22 @@ struct zpci_dev *get_zdev_by_fid(u32 fid)
> return zdev;
> }
>
> +struct zpci_dev *get_zdev_by_fh(u32 fh)
> +{
> + struct zpci_dev *tmp, *zdev = NULL;
> +
> + spin_lock(&zpci_list_lock);
> + list_for_each_entry(tmp, &zpci_list, entry) {
> + if (tmp->fh == fh) {
> + zdev = tmp;
> + break;
> + }
> + }
> + spin_unlock(&zpci_list_lock);
> + return zdev;
> +}
> +EXPORT_SYMBOL_GPL(get_zdev_by_fh);
> +
> void zpci_remove_reserved_devices(void)
> {
> struct zpci_dev *tmp, *zdev;
>

--
Pierre Morel
IBM Lab Boeblingen