* a few trivial dma-mapping header cleanups
@ 2020-09-22 13:39 Christoph Hellwig
2020-09-22 13:40 ` [PATCH 1/3] dma-mapping: remove DMA_MASK_NONE Christoph Hellwig
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Christoph Hellwig @ 2020-09-22 13:39 UTC (permalink / raw)
To: iommu; +Cc: linux-kernel, Dominik Brodowski
Hi all,
these three patches clean up dma-mapping.h a little bit
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] dma-mapping: remove DMA_MASK_NONE
2020-09-22 13:39 a few trivial dma-mapping header cleanups Christoph Hellwig
@ 2020-09-22 13:40 ` Christoph Hellwig
2020-09-22 13:59 ` Dominik Brodowski
2020-09-22 13:40 ` [PATCH 2/3] dma-mapping: move valid_dma_direction to dma-direction.h Christoph Hellwig
2020-09-22 13:40 ` [PATCH 3/3] dma-mapping: better document dma_addr_t and DMA_MAPPING_ERROR Christoph Hellwig
2 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2020-09-22 13:40 UTC (permalink / raw)
To: iommu; +Cc: linux-kernel, Dominik Brodowski
This value is only used by a PCMCIA driver and not very useful.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/pcmcia/ds.c | 2 +-
include/linux/dma-mapping.h | 2 --
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 09d06b082f8b8c..72114907c0e4d2 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -516,7 +516,7 @@ static struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s,
p_dev->dev.parent = s->dev.parent;
p_dev->dev.release = pcmcia_release_dev;
/* by default don't allow DMA */
- p_dev->dma_mask = DMA_MASK_NONE;
+ p_dev->dma_mask = 0;
p_dev->dev.dma_mask = &p_dev->dma_mask;
dev_set_name(&p_dev->dev, "%d.%d", p_dev->socket->sock, p_dev->device_no);
if (!dev_name(&p_dev->dev))
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index bb138ac6f5e63e..e074588d753ff6 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -138,8 +138,6 @@ extern const struct dma_map_ops dma_dummy_ops;
#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
-#define DMA_MASK_NONE 0x0ULL
-
static inline int valid_dma_direction(int dma_direction)
{
return ((dma_direction == DMA_BIDIRECTIONAL) ||
--
2.28.0
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] dma-mapping: move valid_dma_direction to dma-direction.h
2020-09-22 13:39 a few trivial dma-mapping header cleanups Christoph Hellwig
2020-09-22 13:40 ` [PATCH 1/3] dma-mapping: remove DMA_MASK_NONE Christoph Hellwig
@ 2020-09-22 13:40 ` Christoph Hellwig
2020-09-22 13:40 ` [PATCH 3/3] dma-mapping: better document dma_addr_t and DMA_MAPPING_ERROR Christoph Hellwig
2 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2020-09-22 13:40 UTC (permalink / raw)
To: iommu; +Cc: linux-kernel, Dominik Brodowski
Move the valid_dma_direction helper to a more suitable header, and
clean it up to use the proper enum as well as removing pointless braces.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
include/linux/dma-direction.h | 8 +++++++-
include/linux/dma-mapping.h | 7 -------
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/include/linux/dma-direction.h b/include/linux/dma-direction.h
index 9c96e30e6a0bb0..a2fe4571bc9279 100644
--- a/include/linux/dma-direction.h
+++ b/include/linux/dma-direction.h
@@ -9,4 +9,10 @@ enum dma_data_direction {
DMA_NONE = 3,
};
-#endif
+static inline int valid_dma_direction(enum dma_data_direction dir)
+{
+ return dir == DMA_BIDIRECTIONAL || dir == DMA_TO_DEVICE ||
+ dir == DMA_FROM_DEVICE;
+}
+
+#endif /* _LINUX_DMA_DIRECTION_H */
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index e074588d753ff6..51e93d44b826c8 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -138,13 +138,6 @@ extern const struct dma_map_ops dma_dummy_ops;
#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
-static inline int valid_dma_direction(int dma_direction)
-{
- return ((dma_direction == DMA_BIDIRECTIONAL) ||
- (dma_direction == DMA_TO_DEVICE) ||
- (dma_direction == DMA_FROM_DEVICE));
-}
-
#ifdef CONFIG_DMA_DECLARE_COHERENT
/*
* These three functions are only for dma allocator.
--
2.28.0
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] dma-mapping: better document dma_addr_t and DMA_MAPPING_ERROR
2020-09-22 13:39 a few trivial dma-mapping header cleanups Christoph Hellwig
2020-09-22 13:40 ` [PATCH 1/3] dma-mapping: remove DMA_MASK_NONE Christoph Hellwig
2020-09-22 13:40 ` [PATCH 2/3] dma-mapping: move valid_dma_direction to dma-direction.h Christoph Hellwig
@ 2020-09-22 13:40 ` Christoph Hellwig
2020-09-22 13:56 ` David Laight
2 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2020-09-22 13:40 UTC (permalink / raw)
To: iommu; +Cc: linux-kernel, Dominik Brodowski
Move the comment documenting dma_addr_t away from the dma_map_ops
definition which isn't very related to it, and toward DMA_MAPPING_ERROR,
which is somewhat related. Add a little blurb about DMA_MAPPING_ERROR
as well.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
include/linux/dma-mapping.h | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 51e93d44b826c8..c4395cf7e265dd 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -67,12 +67,6 @@
*/
#define DMA_ATTR_PRIVILEGED (1UL << 9)
-/*
- * A dma_addr_t can hold any valid DMA or bus address for the platform.
- * It can be given to a device to use as a DMA source or target. A CPU cannot
- * reference a dma_addr_t directly because there may be translation between
- * its physical address space and the bus address space.
- */
struct dma_map_ops {
void* (*alloc)(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t gfp,
@@ -131,6 +125,16 @@ struct dma_map_ops {
unsigned long (*get_merge_boundary)(struct device *dev);
};
+/*
+ * A dma_addr_t can hold any valid DMA or bus address for the platform. It can
+ * be given to a device to use as a DMA source or target. A CPU cannot
+ * reference a dma_addr_t directly because there may be translation between its
+ * physical address space and the bus address space.
+ *
+ * DMA_MAPPING_ERROR is the magic error code if a mapping failed. It should not
+ * be used directly in drivers, but checked for using dma_mapping_error()
+ * instead.
+ */
#define DMA_MAPPING_ERROR (~(dma_addr_t)0)
extern const struct dma_map_ops dma_virt_ops;
--
2.28.0
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply related [flat|nested] 7+ messages in thread
* RE: [PATCH 3/3] dma-mapping: better document dma_addr_t and DMA_MAPPING_ERROR
2020-09-22 13:40 ` [PATCH 3/3] dma-mapping: better document dma_addr_t and DMA_MAPPING_ERROR Christoph Hellwig
@ 2020-09-22 13:56 ` David Laight
2020-09-25 4:14 ` 'Christoph Hellwig'
0 siblings, 1 reply; 7+ messages in thread
From: David Laight @ 2020-09-22 13:56 UTC (permalink / raw)
To: 'Christoph Hellwig', iommu; +Cc: linux-kernel, Dominik Brodowski
From: Christoph Hellwig
> Sent: 22 September 2020 14:40
...
> @@ -131,6 +125,16 @@ struct dma_map_ops {
> unsigned long (*get_merge_boundary)(struct device *dev);
> };
>
> +/*
> + * A dma_addr_t can hold any valid DMA or bus address for the platform. It can
> + * be given to a device to use as a DMA source or target. A CPU cannot
> + * reference a dma_addr_t directly because there may be translation between its
> + * physical address space and the bus address space.
It can't access it 'directly' because it isn't a virtual address....
> + *
> + * DMA_MAPPING_ERROR is the magic error code if a mapping failed. It should not
> + * be used directly in drivers, but checked for using dma_mapping_error()
> + * instead.
> + */
I think it might be worth adding:
A dma_addr_t value may be device dependant and differ from the
'physical address' of the memory.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] dma-mapping: remove DMA_MASK_NONE
2020-09-22 13:40 ` [PATCH 1/3] dma-mapping: remove DMA_MASK_NONE Christoph Hellwig
@ 2020-09-22 13:59 ` Dominik Brodowski
0 siblings, 0 replies; 7+ messages in thread
From: Dominik Brodowski @ 2020-09-22 13:59 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: iommu, linux-kernel
On Tue, Sep 22, 2020 at 03:40:00PM +0200, Christoph Hellwig wrote:
> This value is only used by a PCMCIA driver and not very useful.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Dominik Brodowski <linux@dominikbrodwski.net>
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] dma-mapping: better document dma_addr_t and DMA_MAPPING_ERROR
2020-09-22 13:56 ` David Laight
@ 2020-09-25 4:14 ` 'Christoph Hellwig'
0 siblings, 0 replies; 7+ messages in thread
From: 'Christoph Hellwig' @ 2020-09-25 4:14 UTC (permalink / raw)
To: David Laight
Cc: iommu, 'Christoph Hellwig', Dominik Brodowski, linux-kernel
On Tue, Sep 22, 2020 at 01:56:46PM +0000, David Laight wrote:
> > +/*
> > + * A dma_addr_t can hold any valid DMA or bus address for the platform. It can
> > + * be given to a device to use as a DMA source or target. A CPU cannot
> > + * reference a dma_addr_t directly because there may be translation between its
> > + * physical address space and the bus address space.
>
> It can't access it 'directly' because it isn't a virtual address....
>
> > + *
> > + * DMA_MAPPING_ERROR is the magic error code if a mapping failed. It should not
> > + * be used directly in drivers, but checked for using dma_mapping_error()
> > + * instead.
> > + */
>
> I think it might be worth adding:
>
> A dma_addr_t value may be device dependant and differ from the
> 'physical address' of the memory.
This is what I've committed:
* A dma_addr_t can hold any valid DMA or bus address for the platform. It can
* be given to a device to use as a DMA source or target. It is specific to a
* given device and there may be a translation between the CPU physical address
* space and the bus address space.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-09-25 4:14 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-22 13:39 a few trivial dma-mapping header cleanups Christoph Hellwig
2020-09-22 13:40 ` [PATCH 1/3] dma-mapping: remove DMA_MASK_NONE Christoph Hellwig
2020-09-22 13:59 ` Dominik Brodowski
2020-09-22 13:40 ` [PATCH 2/3] dma-mapping: move valid_dma_direction to dma-direction.h Christoph Hellwig
2020-09-22 13:40 ` [PATCH 3/3] dma-mapping: better document dma_addr_t and DMA_MAPPING_ERROR Christoph Hellwig
2020-09-22 13:56 ` David Laight
2020-09-25 4:14 ` 'Christoph Hellwig'
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).