All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/3] PCI: export pci_get_dma_device() helper to other users
@ 2014-07-25 13:31 ` Andy Shevchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2014-07-25 13:31 UTC (permalink / raw)
  To: Alex Williamson, linux-pci-u79uwXL29TY76Z2rM5mHXA, Bjorn Helgaas,
	Mark Brown, Greg Kroah-Hartman, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-serial-u79uwXL29TY76Z2rM5mHXA
  Cc: Andy Shevchenko

Some chipsets use the function 0 for DMA on other functions of a
multifunctional device. One of the example is Intel EG20T PCH. This is also
applicable to Lynxpoint PCH when LPSS devices are switched to PCI mode.

This patch exports a useful helper to get a device of the DMA. This device is
needed to request a DMA channel from a proper controller.

Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 drivers/pci/quirks.c | 2 +-
 include/linux/pci.h  | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 80c2d01..8352e5b 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3517,7 +3517,7 @@ static struct pci_dev *pci_func_0_dma_source(struct pci_dev *dev)
 	if (!PCI_FUNC(dev->devfn))
 		return pci_dev_get(dev);
 
-	return pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
+	return pci_get_dma_device(dev);
 }
 
 static const struct pci_dev_dma_source {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 61978a4..86caab7 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1575,6 +1575,15 @@ static inline int pci_dev_specific_acs_enabled(struct pci_dev *dev,
 static inline void pci_dev_specific_enable_acs(struct pci_dev *dev) { }
 #endif
 
+/*
+ * Some chipsets use the function 0 for DMA on other functions of a
+ * multifunctional device.
+ */
+static inline struct pci_dev *pci_get_dma_device(struct pci_dev *dev)
+{
+	return pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
+}
+
 void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen);
 void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);
 void __iomem * const *pcim_iomap_table(struct pci_dev *pdev);
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 1/3] PCI: export pci_get_dma_device() helper to other users
@ 2014-07-25 13:31 ` Andy Shevchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2014-07-25 13:31 UTC (permalink / raw)
  To: Alex Williamson, linux-pci, Bjorn Helgaas, Mark Brown,
	Greg Kroah-Hartman, linux-spi, linux-serial
  Cc: Andy Shevchenko

Some chipsets use the function 0 for DMA on other functions of a
multifunctional device. One of the example is Intel EG20T PCH. This is also
applicable to Lynxpoint PCH when LPSS devices are switched to PCI mode.

This patch exports a useful helper to get a device of the DMA. This device is
needed to request a DMA channel from a proper controller.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pci/quirks.c | 2 +-
 include/linux/pci.h  | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 80c2d01..8352e5b 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3517,7 +3517,7 @@ static struct pci_dev *pci_func_0_dma_source(struct pci_dev *dev)
 	if (!PCI_FUNC(dev->devfn))
 		return pci_dev_get(dev);
 
-	return pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
+	return pci_get_dma_device(dev);
 }
 
 static const struct pci_dev_dma_source {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 61978a4..86caab7 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1575,6 +1575,15 @@ static inline int pci_dev_specific_acs_enabled(struct pci_dev *dev,
 static inline void pci_dev_specific_enable_acs(struct pci_dev *dev) { }
 #endif
 
+/*
+ * Some chipsets use the function 0 for DMA on other functions of a
+ * multifunctional device.
+ */
+static inline struct pci_dev *pci_get_dma_device(struct pci_dev *dev)
+{
+	return pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
+}
+
 void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen);
 void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);
 void __iomem * const *pcim_iomap_table(struct pci_dev *pdev);
-- 
2.0.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 2/3] pch_uart: use pci_get_dma_device() helper
  2014-07-25 13:31 ` Andy Shevchenko
@ 2014-07-25 13:31     ` Andy Shevchenko
  -1 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2014-07-25 13:31 UTC (permalink / raw)
  To: Alex Williamson, linux-pci-u79uwXL29TY76Z2rM5mHXA, Bjorn Helgaas,
	Mark Brown, Greg Kroah-Hartman, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-serial-u79uwXL29TY76Z2rM5mHXA
  Cc: Andy Shevchenko

Since we have pci_get_dma_device() public we may use it in the drivers. It
considers the function 0 as a DMA controller.

Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 drivers/tty/serial/pch_uart.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index 2f06e5a..c38fdee 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -736,9 +736,8 @@ static void pch_request_dma(struct uart_port *port)
 	dma_cap_zero(mask);
 	dma_cap_set(DMA_SLAVE, mask);
 
-	dma_dev = pci_get_bus_and_slot(priv->pdev->bus->number,
-				       PCI_DEVFN(0xa, 0)); /* Get DMA's dev
-								information */
+	dma_dev = pci_get_dma_device(priv->pdev); /* Get DMA's dev information */
+
 	/* Set Tx DMA */
 	param = &priv->param_tx;
 	param->dma_dev = &dma_dev->dev;
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 2/3] pch_uart: use pci_get_dma_device() helper
@ 2014-07-25 13:31     ` Andy Shevchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2014-07-25 13:31 UTC (permalink / raw)
  To: Alex Williamson, linux-pci, Bjorn Helgaas, Mark Brown,
	Greg Kroah-Hartman, linux-spi, linux-serial
  Cc: Andy Shevchenko

Since we have pci_get_dma_device() public we may use it in the drivers. It
considers the function 0 as a DMA controller.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/tty/serial/pch_uart.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index 2f06e5a..c38fdee 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -736,9 +736,8 @@ static void pch_request_dma(struct uart_port *port)
 	dma_cap_zero(mask);
 	dma_cap_set(DMA_SLAVE, mask);
 
-	dma_dev = pci_get_bus_and_slot(priv->pdev->bus->number,
-				       PCI_DEVFN(0xa, 0)); /* Get DMA's dev
-								information */
+	dma_dev = pci_get_dma_device(priv->pdev); /* Get DMA's dev information */
+
 	/* Set Tx DMA */
 	param = &priv->param_tx;
 	param->dma_dev = &dma_dev->dev;
-- 
2.0.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 3/3] spi: topcliff-pch: use pci_get_dma_device() helper
  2014-07-25 13:31 ` Andy Shevchenko
  (?)
  (?)
@ 2014-07-25 13:31 ` Andy Shevchenko
  -1 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2014-07-25 13:31 UTC (permalink / raw)
  To: Alex Williamson, linux-pci, Bjorn Helgaas, Mark Brown,
	Greg Kroah-Hartman, linux-spi, linux-serial
  Cc: Andy Shevchenko

Since we have pci_get_dma_device() public we may use it in the drivers. It
considers the function 0 as a DMA controller.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-topcliff-pch.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
index af51d6a..fe868ce 100644
--- a/drivers/spi/spi-topcliff-pch.c
+++ b/drivers/spi/spi-topcliff-pch.c
@@ -874,8 +874,7 @@ static void pch_spi_request_dma(struct pch_spi_data *data, int bpw)
 	dma_cap_set(DMA_SLAVE, mask);
 
 	/* Get DMA's dev information */
-	dma_dev = pci_get_bus_and_slot(data->board_dat->pdev->bus->number,
-				       PCI_DEVFN(12, 0));
+	dma_dev = pci_get_dma_device(data->board_dat->pdev);
 
 	/* Set Tx DMA */
 	param = &dma->param_tx;
-- 
2.0.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 1/3] PCI: export pci_get_dma_device() helper to other users
  2014-07-25 13:31 ` Andy Shevchenko
                   ` (2 preceding siblings ...)
  (?)
@ 2014-07-25 16:58 ` Alex Williamson
       [not found]   ` <1406307516.1011.21.camel-85EaTFmN5p//9pzu0YdTqQ@public.gmane.org>
  -1 siblings, 1 reply; 9+ messages in thread
From: Alex Williamson @ 2014-07-25 16:58 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-pci, Bjorn Helgaas, Mark Brown, Greg Kroah-Hartman,
	linux-spi, linux-serial

On Fri, 2014-07-25 at 16:31 +0300, Andy Shevchenko wrote:
> Some chipsets use the function 0 for DMA on other functions of a
> multifunctional device. One of the example is Intel EG20T PCH. This is also
> applicable to Lynxpoint PCH when LPSS devices are switched to PCI mode.
> 
> This patch exports a useful helper to get a device of the DMA. This device is
> needed to request a DMA channel from a proper controller.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/pci/quirks.c | 2 +-
>  include/linux/pci.h  | 9 +++++++++
>  2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> index 80c2d01..8352e5b 100644
> --- a/drivers/pci/quirks.c
> +++ b/drivers/pci/quirks.c
> @@ -3517,7 +3517,7 @@ static struct pci_dev *pci_func_0_dma_source(struct pci_dev *dev)
>  	if (!PCI_FUNC(dev->devfn))
>  		return pci_dev_get(dev);
>  
> -	return pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
> +	return pci_get_dma_device(dev);
>  }
>  
>  static const struct pci_dev_dma_source {
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 61978a4..86caab7 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1575,6 +1575,15 @@ static inline int pci_dev_specific_acs_enabled(struct pci_dev *dev,
>  static inline void pci_dev_specific_enable_acs(struct pci_dev *dev) { }
>  #endif
>  
> +/*
> + * Some chipsets use the function 0 for DMA on other functions of a
> + * multifunctional device.
> + */
> +static inline struct pci_dev *pci_get_dma_device(struct pci_dev *dev)
> +{
> +	return pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
> +}
> +
>  void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen);
>  void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);
>  void __iomem * const *pcim_iomap_table(struct pci_dev *pdev);

You've created a very generic function for a very specific problem.  I
can't just call this on any random device and expect it to work
correctly.  What about all the other device which use function 1 for
their DMA alias.  We've just added infrastructure in PCI to support DMA
aliases, see pci_for_each_dma_alias().  Please use this instead.  Quirks
can be added to set the dma_alias_devfn and
PCI_DEV_FLAGS_DMA_ALIAS_DEVFN to indicate that it's valid.  Thanks,

Alex


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 1/3] PCI: export pci_get_dma_device() helper to other users
  2014-07-25 16:58 ` [PATCH v1 1/3] PCI: export pci_get_dma_device() helper to other users Alex Williamson
@ 2014-07-28  9:26       ` Andy Shevchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2014-07-28  9:26 UTC (permalink / raw)
  To: Alex Williamson
  Cc: linux-pci-u79uwXL29TY76Z2rM5mHXA, Bjorn Helgaas, Mark Brown,
	Greg Kroah-Hartman, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-serial-u79uwXL29TY76Z2rM5mHXA

On Fri, 2014-07-25 at 10:58 -0600, Alex Williamson wrote:
> On Fri, 2014-07-25 at 16:31 +0300, Andy Shevchenko wrote:
> > Some chipsets use the function 0 for DMA on other functions of a
> > multifunctional device. One of the example is Intel EG20T PCH. This is also
> > applicable to Lynxpoint PCH when LPSS devices are switched to PCI mode.
> > 
> > This patch exports a useful helper to get a device of the DMA. This device is
> > needed to request a DMA channel from a proper controller.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> > ---
> >  drivers/pci/quirks.c | 2 +-
> >  include/linux/pci.h  | 9 +++++++++
> >  2 files changed, 10 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> > index 80c2d01..8352e5b 100644
> > --- a/drivers/pci/quirks.c
> > +++ b/drivers/pci/quirks.c
> > @@ -3517,7 +3517,7 @@ static struct pci_dev *pci_func_0_dma_source(struct pci_dev *dev)
> >  	if (!PCI_FUNC(dev->devfn))
> >  		return pci_dev_get(dev);
> >  
> > -	return pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
> > +	return pci_get_dma_device(dev);
> >  }
> >  
> >  static const struct pci_dev_dma_source {
> > diff --git a/include/linux/pci.h b/include/linux/pci.h
> > index 61978a4..86caab7 100644
> > --- a/include/linux/pci.h
> > +++ b/include/linux/pci.h
> > @@ -1575,6 +1575,15 @@ static inline int pci_dev_specific_acs_enabled(struct pci_dev *dev,
> >  static inline void pci_dev_specific_enable_acs(struct pci_dev *dev) { }
> >  #endif
> >  
> > +/*
> > + * Some chipsets use the function 0 for DMA on other functions of a
> > + * multifunctional device.
> > + */
> > +static inline struct pci_dev *pci_get_dma_device(struct pci_dev *dev)
> > +{
> > +	return pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
> > +}
> > +
> >  void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen);
> >  void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);
> >  void __iomem * const *pcim_iomap_table(struct pci_dev *pdev);
> 
> You've created a very generic function for a very specific problem.  I
> can't just call this on any random device and expect it to work
> correctly.

Right.

>   What about all the other device which use function 1 for
> their DMA alias.

Hmm... I would like to understand what the difference between DMA alias
and the case when we have MFD where function 0 is real DMA controller
which serves the other devices in that block is?

Another (probably minor) question, why do you still have
pci_get_dma_source() function in quirks.c?

>   We've just added infrastructure in PCI to support DMA
> aliases, see pci_for_each_dma_alias().  Please use this instead.  Quirks
> can be added to set the dma_alias_devfn and
> PCI_DEV_FLAGS_DMA_ALIAS_DEVFN to indicate that it's valid.  Thanks,

Do you mean I have to list all devices that, for example, are listed in
the spi-topcliff-pch.c?


-- 
Andy Shevchenko <andriy.shevchenko-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Intel Finland Oy

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 1/3] PCI: export pci_get_dma_device() helper to other users
@ 2014-07-28  9:26       ` Andy Shevchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2014-07-28  9:26 UTC (permalink / raw)
  To: Alex Williamson
  Cc: linux-pci, Bjorn Helgaas, Mark Brown, Greg Kroah-Hartman,
	linux-spi, linux-serial

On Fri, 2014-07-25 at 10:58 -0600, Alex Williamson wrote:
> On Fri, 2014-07-25 at 16:31 +0300, Andy Shevchenko wrote:
> > Some chipsets use the function 0 for DMA on other functions of a
> > multifunctional device. One of the example is Intel EG20T PCH. This is also
> > applicable to Lynxpoint PCH when LPSS devices are switched to PCI mode.
> > 
> > This patch exports a useful helper to get a device of the DMA. This device is
> > needed to request a DMA channel from a proper controller.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> >  drivers/pci/quirks.c | 2 +-
> >  include/linux/pci.h  | 9 +++++++++
> >  2 files changed, 10 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> > index 80c2d01..8352e5b 100644
> > --- a/drivers/pci/quirks.c
> > +++ b/drivers/pci/quirks.c
> > @@ -3517,7 +3517,7 @@ static struct pci_dev *pci_func_0_dma_source(struct pci_dev *dev)
> >  	if (!PCI_FUNC(dev->devfn))
> >  		return pci_dev_get(dev);
> >  
> > -	return pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
> > +	return pci_get_dma_device(dev);
> >  }
> >  
> >  static const struct pci_dev_dma_source {
> > diff --git a/include/linux/pci.h b/include/linux/pci.h
> > index 61978a4..86caab7 100644
> > --- a/include/linux/pci.h
> > +++ b/include/linux/pci.h
> > @@ -1575,6 +1575,15 @@ static inline int pci_dev_specific_acs_enabled(struct pci_dev *dev,
> >  static inline void pci_dev_specific_enable_acs(struct pci_dev *dev) { }
> >  #endif
> >  
> > +/*
> > + * Some chipsets use the function 0 for DMA on other functions of a
> > + * multifunctional device.
> > + */
> > +static inline struct pci_dev *pci_get_dma_device(struct pci_dev *dev)
> > +{
> > +	return pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
> > +}
> > +
> >  void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen);
> >  void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);
> >  void __iomem * const *pcim_iomap_table(struct pci_dev *pdev);
> 
> You've created a very generic function for a very specific problem.  I
> can't just call this on any random device and expect it to work
> correctly.

Right.

>   What about all the other device which use function 1 for
> their DMA alias.

Hmm... I would like to understand what the difference between DMA alias
and the case when we have MFD where function 0 is real DMA controller
which serves the other devices in that block is?

Another (probably minor) question, why do you still have
pci_get_dma_source() function in quirks.c?

>   We've just added infrastructure in PCI to support DMA
> aliases, see pci_for_each_dma_alias().  Please use this instead.  Quirks
> can be added to set the dma_alias_devfn and
> PCI_DEV_FLAGS_DMA_ALIAS_DEVFN to indicate that it's valid.  Thanks,

Do you mean I have to list all devices that, for example, are listed in
the spi-topcliff-pch.c?


-- 
Andy Shevchenko <andriy.shevchenko@intel.com>
Intel Finland Oy


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 1/3] PCI: export pci_get_dma_device() helper to other users
  2014-07-28  9:26       ` Andy Shevchenko
  (?)
@ 2014-07-28 14:19       ` Alex Williamson
  -1 siblings, 0 replies; 9+ messages in thread
From: Alex Williamson @ 2014-07-28 14:19 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-pci, Bjorn Helgaas, Mark Brown, Greg Kroah-Hartman,
	linux-spi, linux-serial

On Mon, 2014-07-28 at 12:26 +0300, Andy Shevchenko wrote:
> On Fri, 2014-07-25 at 10:58 -0600, Alex Williamson wrote:
> > On Fri, 2014-07-25 at 16:31 +0300, Andy Shevchenko wrote:
> > > Some chipsets use the function 0 for DMA on other functions of a
> > > multifunctional device. One of the example is Intel EG20T PCH. This is also
> > > applicable to Lynxpoint PCH when LPSS devices are switched to PCI mode.
> > > 
> > > This patch exports a useful helper to get a device of the DMA. This device is
> > > needed to request a DMA channel from a proper controller.
> > > 
> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > > ---
> > >  drivers/pci/quirks.c | 2 +-
> > >  include/linux/pci.h  | 9 +++++++++
> > >  2 files changed, 10 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> > > index 80c2d01..8352e5b 100644
> > > --- a/drivers/pci/quirks.c
> > > +++ b/drivers/pci/quirks.c
> > > @@ -3517,7 +3517,7 @@ static struct pci_dev *pci_func_0_dma_source(struct pci_dev *dev)
> > >  	if (!PCI_FUNC(dev->devfn))
> > >  		return pci_dev_get(dev);
> > >  
> > > -	return pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
> > > +	return pci_get_dma_device(dev);
> > >  }
> > >  
> > >  static const struct pci_dev_dma_source {
> > > diff --git a/include/linux/pci.h b/include/linux/pci.h
> > > index 61978a4..86caab7 100644
> > > --- a/include/linux/pci.h
> > > +++ b/include/linux/pci.h
> > > @@ -1575,6 +1575,15 @@ static inline int pci_dev_specific_acs_enabled(struct pci_dev *dev,
> > >  static inline void pci_dev_specific_enable_acs(struct pci_dev *dev) { }
> > >  #endif
> > >  
> > > +/*
> > > + * Some chipsets use the function 0 for DMA on other functions of a
> > > + * multifunctional device.
> > > + */
> > > +static inline struct pci_dev *pci_get_dma_device(struct pci_dev *dev)
> > > +{
> > > +	return pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
> > > +}
> > > +
> > >  void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen);
> > >  void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);
> > >  void __iomem * const *pcim_iomap_table(struct pci_dev *pdev);
> > 
> > You've created a very generic function for a very specific problem.  I
> > can't just call this on any random device and expect it to work
> > correctly.
> 
> Right.
> 
> >   What about all the other device which use function 1 for
> > their DMA alias.
> 
> Hmm... I would like to understand what the difference between DMA alias
> and the case when we have MFD where function 0 is real DMA controller
> which serves the other devices in that block is?

There is no difference, the PCI DMA alias code is meant to handle any
case where the requester ID of a DMA is different from the device that
actually initiates the DMA.  That may be a different function on a MFD,
it may be a non-existent devfn, or it may be an upstream device.  Note
that using function 0 as the DMA controller for other functions of a MFD
is a broken design in a world of IOMMUs.  It means that we cannot
distinguish transactions from different functions and we need to
pre-enable these aliases for the device to work correctly.  There's
nothing in the PCIe spec that allows an MFD to use the wrong requester
ID for DMA.

> Another (probably minor) question, why do you still have
> pci_get_dma_source() function in quirks.c?

It's in the process of being removed https://lkml.org/lkml/2014/5/22/725

> >   We've just added infrastructure in PCI to support DMA
> > aliases, see pci_for_each_dma_alias().  Please use this instead.  Quirks
> > can be added to set the dma_alias_devfn and
> > PCI_DEV_FLAGS_DMA_ALIAS_DEVFN to indicate that it's valid.  Thanks,
> 
> Do you mean I have to list all devices that, for example, are listed in
> the spi-topcliff-pch.c?

I'm not sure how you'll incorporate it, but creating a
pci_get_dma_device() helper which assumes a specific broken relationship
for DMA is clearly not a supportable solution.  Thanks,

Alex


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-07-28 14:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-25 13:31 [PATCH v1 1/3] PCI: export pci_get_dma_device() helper to other users Andy Shevchenko
2014-07-25 13:31 ` Andy Shevchenko
     [not found] ` <1406295104-20082-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-07-25 13:31   ` [PATCH v1 2/3] pch_uart: use pci_get_dma_device() helper Andy Shevchenko
2014-07-25 13:31     ` Andy Shevchenko
2014-07-25 13:31 ` [PATCH v1 3/3] spi: topcliff-pch: " Andy Shevchenko
2014-07-25 16:58 ` [PATCH v1 1/3] PCI: export pci_get_dma_device() helper to other users Alex Williamson
     [not found]   ` <1406307516.1011.21.camel-85EaTFmN5p//9pzu0YdTqQ@public.gmane.org>
2014-07-28  9:26     ` Andy Shevchenko
2014-07-28  9:26       ` Andy Shevchenko
2014-07-28 14:19       ` Alex Williamson

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.