mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC] pci_dma_set_mask()
@ 2001-02-28 15:37 Zach Brown
  2001-02-28 16:26 ` Jeff Garzik
  0 siblings, 1 reply; 5+ messages in thread
From: Zach Brown @ 2001-02-28 15:37 UTC (permalink / raw)
  To: linux-kernel

This patch really has two parts.  Most of it adds a helper function that
does the 

	if(pci_dma_supported()) { ->dma_mask = mask }

code path.  I was using the api today and didn't realize that I had to
set the mask myself, I assumed the _supported call would do it.   If
people prefer the struct setting api, thats fine with me :)  

It also seems goofy that pci_dma_supported() unconditionally return true
on x86.  If a device needs a mask smaller than GFP_DMA (admitedly probably
won't exist in the real world, one hopes), they're going to have troubles
because x86 just falls back to GFP_DMA when the mask isn't 0xffffffff..

all totally untested, of course..

-- 
 zach

--- linux-2.4.2/include/linux/pci.h.dmasup	Wed Feb 28 10:26:14 2001
+++ linux-2.4.2/include/linux/pci.h	Wed Feb 28 10:30:12 2001
@@ -527,6 +527,7 @@
 
 int pci_enable_device(struct pci_dev *dev);
 void pci_set_master(struct pci_dev *dev);
+int pci_set_dma_mask(struct pci_dev *dev, dma_addr_t mask);
 int pci_set_power_state(struct pci_dev *dev, int state);
 int pci_assign_resource(struct pci_dev *dev, int i);
 
--- linux-2.4.2/include/asm-i386/pci.h.dmasup	Wed Feb 28 10:19:01 2001
+++ linux-2.4.2/include/asm-i386/pci.h	Wed Feb 28 10:25:40 2001
@@ -152,6 +152,14 @@
  */
 extern inline int pci_dma_supported(struct pci_dev *hwdev, dma_addr_t mask)
 {
+        /*
+         * we fall back to GFP_DMA when the mask isn't all 1s,
+         * so we can't guarantee allocations that must be
+         * within a tighter range than GFP_DMA..
+         */
+        if(mask < 0x00ffffff)
+                return 0;
+
 	return 1;
 }
 
--- linux-2.4.2/drivers/pci/pci.c.dmasup	Wed Feb 28 10:26:34 2001
+++ linux-2.4.2/drivers/pci/pci.c	Wed Feb 28 10:27:34 2001
@@ -518,6 +518,18 @@
 	pcibios_set_master(dev);
 }
 
+int
+pci_set_dma_mask(struct pci_dev *dev, dma_addr_t mask)
+{
+    if(! pci_dma_supported(dev, mask))
+        return 0;
+
+    dev->dma_mask = mask;
+
+    return 1;
+}
+    
+
 /*
  * Translate the low bits of the PCI base
  * to the resource type
@@ -1206,6 +1218,7 @@
 EXPORT_SYMBOL(pci_find_slot);
 EXPORT_SYMBOL(pci_find_subsys);
 EXPORT_SYMBOL(pci_set_master);
+EXPORT_SYMBOL(pci_set_dma_mask);
 EXPORT_SYMBOL(pci_set_power_state);
 EXPORT_SYMBOL(pci_assign_resource);
 EXPORT_SYMBOL(pci_register_driver);


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

* Re: [RFC] pci_dma_set_mask()
  2001-02-28 15:37 [RFC] pci_dma_set_mask() Zach Brown
@ 2001-02-28 16:26 ` Jeff Garzik
  2001-02-28 21:14   ` Zach Brown
  2001-02-28 23:23   ` David S. Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Jeff Garzik @ 2001-02-28 16:26 UTC (permalink / raw)
  To: Zach Brown; +Cc: linux-kernel

Zach Brown wrote:
> +int
> +pci_set_dma_mask(struct pci_dev *dev, dma_addr_t mask)
> +{
> +    if(! pci_dma_supported(dev, mask))
> +        return 0;
> +
> +    dev->dma_mask = mask;
> +
> +    return 1;
> +}

pci_dma_supported has a boolean return, but the kernel norm is to return
zero on success, and -EFOO on error.  I like your proposal with the
extremely minor nit that I think pci_set_dma_mask should return ENODEV
or EIO or something on error, and zero on success.

	Jeff



-- 
Jeff Garzik       | "You see, in this world there's two kinds of
Building 1024     |  people, my friend: Those with loaded guns
MandrakeSoft      |  and those who dig. You dig."  --Blondie

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

* Re: [RFC] pci_dma_set_mask()
  2001-02-28 16:26 ` Jeff Garzik
@ 2001-02-28 21:14   ` Zach Brown
  2001-02-28 23:23   ` David S. Miller
  1 sibling, 0 replies; 5+ messages in thread
From: Zach Brown @ 2001-02-28 21:14 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-kernel

> pci_dma_supported has a boolean return, but the kernel norm is to return
> zero on success, and -EFOO on error.  I like your proposal with the

*nod*  I just followed pci_dma_supported().

> extremely minor nit that I think pci_set_dma_mask should return ENODEV
> or EIO or something on error, and zero on success.

I agree, though I'd like to leave the decision up to people who live and
breathe this stuff.

please feel free to make minor adjustments and submit :)

- z

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

* Re: [RFC] pci_dma_set_mask()
  2001-02-28 16:26 ` Jeff Garzik
  2001-02-28 21:14   ` Zach Brown
@ 2001-02-28 23:23   ` David S. Miller
  2001-02-28 23:37     ` Zach Brown
  1 sibling, 1 reply; 5+ messages in thread
From: David S. Miller @ 2001-02-28 23:23 UTC (permalink / raw)
  To: Zach Brown; +Cc: Jeff Garzik, linux-kernel


Zach Brown writes:
 > > extremely minor nit that I think pci_set_dma_mask should return ENODEV
 > > or EIO or something on error, and zero on success.
 > 
 > I agree, though I'd like to leave the decision up to people who live and
 > breathe this stuff.
 > 
 > please feel free to make minor adjustments and submit :)

Jeff/Zach, I agree, I'm fully for such a patch, but please update the
documentation!  It is the most important part of the patch.

Later,
David S. Miller
davem@redhat.com

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

* Re: [RFC] pci_dma_set_mask()
  2001-02-28 23:23   ` David S. Miller
@ 2001-02-28 23:37     ` Zach Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Zach Brown @ 2001-02-28 23:37 UTC (permalink / raw)
  To: David S. Miller; +Cc: Jeff Garzik, linux-kernel

On Wed, Feb 28, 2001 at 03:23:53PM -0800, David S. Miller wrote:

> Jeff/Zach, I agree, I'm fully for such a patch, but please update the
> documentation!  It is the most important part of the patch.

Very good point.  I'll add Jeff's error returning and spin some minor
docs and resend.

thanks.

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

end of thread, other threads:[~2001-02-28 23:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-28 15:37 [RFC] pci_dma_set_mask() Zach Brown
2001-02-28 16:26 ` Jeff Garzik
2001-02-28 21:14   ` Zach Brown
2001-02-28 23:23   ` David S. Miller
2001-02-28 23:37     ` Zach Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®