* [PATCH v2 0/6] fix dma memory allocations, add dma_alloc/dma_free
@ 2012-06-20 11:57 Marc Kleine-Budde
2012-06-20 11:57 ` [PATCH v2 1/6] ARM mmu: don't use CONFIG_MMU to disable mmu code, there are static inline versions Marc Kleine-Budde
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Marc Kleine-Budde @ 2012-06-20 11:57 UTC (permalink / raw)
To: sha; +Cc: barebox
on ARM using dfu mode we've seen problems with dma memory allocations.
Some drivers use dma_inv_range on allocated buffers, which corrupts memory
around the buffer, it it's not aligned to cache lines. This series
introduces: dma_alloc() and dma_free() that allocate memory aligned to
cache lines. This is 64 bytes on ARM (just to be sure) and
DCACHE_LINE_SIZE on nios2. All other arch do a transparent xmalloc.
Feel free to add the appropriate alignment for your architecture to
"include/asm/dma.h". If you do so add a
#define dma_alloc dma_alloc
#define dma_free dma_free
to your "asm/dma.h" so that the generic funtion won't be used.
changes since v1:
- align size to cache line size, too (tnx Sascha)
- provide a generic "include/dma.h" which implements generic fallbacks
using ifndef dma_{alloc,free} magic.
- add includes to arm and nions implementations
regards, Marc
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/6] ARM mmu: don't use CONFIG_MMU to disable mmu code, there are static inline versions
2012-06-20 11:57 [PATCH v2 0/6] fix dma memory allocations, add dma_alloc/dma_free Marc Kleine-Budde
@ 2012-06-20 11:57 ` Marc Kleine-Budde
2012-06-20 11:57 ` [PATCH v2 2/6] blackfin, mips, openrisc, ppc, sandbox, x86: add generic dma_alloc, dma_free inlines Marc Kleine-Budde
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Marc Kleine-Budde @ 2012-06-20 11:57 UTC (permalink / raw)
To: sha; +Cc: barebox
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
arch/arm/cpu/mmu.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index c19f931..55b07a4 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -299,11 +299,9 @@ void *dma_alloc_coherent(size_t size)
size = PAGE_ALIGN(size);
ret = xmemalign(4096, size);
-#ifdef CONFIG_MMU
dma_inv_range((unsigned long)ret, (unsigned long)ret + size);
remap_range(ret, size, PTE_FLAGS_UNCACHED);
-#endif
return ret;
}
@@ -320,9 +318,7 @@ void *phys_to_virt(unsigned long phys)
void dma_free_coherent(void *mem, size_t size)
{
-#ifdef CONFIG_MMU
remap_range(mem, size, PTE_FLAGS_CACHED);
-#endif
free(mem);
}
--
1.7.10
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/6] blackfin, mips, openrisc, ppc, sandbox, x86: add generic dma_alloc, dma_free inlines
2012-06-20 11:57 [PATCH v2 0/6] fix dma memory allocations, add dma_alloc/dma_free Marc Kleine-Budde
2012-06-20 11:57 ` [PATCH v2 1/6] ARM mmu: don't use CONFIG_MMU to disable mmu code, there are static inline versions Marc Kleine-Budde
@ 2012-06-20 11:57 ` Marc Kleine-Budde
2012-06-20 11:57 ` [PATCH v2 3/6] nios: add dma_alloc, asm/dma.h Marc Kleine-Budde
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Marc Kleine-Budde @ 2012-06-20 11:57 UTC (permalink / raw)
To: sha; +Cc: barebox
Some drivers call dma_inv_range() on buffers, on arm these buffers must
be cache line aligned. This patch introduces a generic dma_alloc,
dma_free. Archs can implement in their own functions in "asm/dma.h" and add a:
#define dma_alloc dma_alloc
#define dma_free dma_free
On all other archs the generic versions, which translate into xmalloc
and free are used.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
arch/blackfin/include/asm/dma.h | 13 +++++++++++++
arch/mips/include/asm/dma.h | 13 +++++++++++++
arch/openrisc/include/asm/dma.h | 13 +++++++++++++
arch/ppc/include/asm/dma.h | 13 +++++++++++++
arch/sandbox/include/asm/dma.h | 13 +++++++++++++
arch/x86/include/asm/dma.h | 13 +++++++++++++
include/dma.h | 30 ++++++++++++++++++++++++++++++
7 files changed, 108 insertions(+)
create mode 100644 arch/blackfin/include/asm/dma.h
create mode 100644 arch/mips/include/asm/dma.h
create mode 100644 arch/openrisc/include/asm/dma.h
create mode 100644 arch/ppc/include/asm/dma.h
create mode 100644 arch/sandbox/include/asm/dma.h
create mode 100644 arch/x86/include/asm/dma.h
create mode 100644 include/dma.h
diff --git a/arch/blackfin/include/asm/dma.h b/arch/blackfin/include/asm/dma.h
new file mode 100644
index 0000000..27d269f
--- /dev/null
+++ b/arch/blackfin/include/asm/dma.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2012 by Marc Kleine-Budde <mkl@pengutronix.de>
+ *
+ * This file is released under the GPLv2
+ *
+ */
+
+#ifndef __ASM_DMA_H
+#define __ASM_DMA_H
+
+/* empty */
+
+#endif /* __ASM_DMA_H */
diff --git a/arch/mips/include/asm/dma.h b/arch/mips/include/asm/dma.h
new file mode 100644
index 0000000..27d269f
--- /dev/null
+++ b/arch/mips/include/asm/dma.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2012 by Marc Kleine-Budde <mkl@pengutronix.de>
+ *
+ * This file is released under the GPLv2
+ *
+ */
+
+#ifndef __ASM_DMA_H
+#define __ASM_DMA_H
+
+/* empty */
+
+#endif /* __ASM_DMA_H */
diff --git a/arch/openrisc/include/asm/dma.h b/arch/openrisc/include/asm/dma.h
new file mode 100644
index 0000000..27d269f
--- /dev/null
+++ b/arch/openrisc/include/asm/dma.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2012 by Marc Kleine-Budde <mkl@pengutronix.de>
+ *
+ * This file is released under the GPLv2
+ *
+ */
+
+#ifndef __ASM_DMA_H
+#define __ASM_DMA_H
+
+/* empty */
+
+#endif /* __ASM_DMA_H */
diff --git a/arch/ppc/include/asm/dma.h b/arch/ppc/include/asm/dma.h
new file mode 100644
index 0000000..27d269f
--- /dev/null
+++ b/arch/ppc/include/asm/dma.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2012 by Marc Kleine-Budde <mkl@pengutronix.de>
+ *
+ * This file is released under the GPLv2
+ *
+ */
+
+#ifndef __ASM_DMA_H
+#define __ASM_DMA_H
+
+/* empty */
+
+#endif /* __ASM_DMA_H */
diff --git a/arch/sandbox/include/asm/dma.h b/arch/sandbox/include/asm/dma.h
new file mode 100644
index 0000000..4595367
--- /dev/null
+++ b/arch/sandbox/include/asm/dma.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2012 by Marc Kleine-Budde <mkl@pengutronix.de>
+ *
+ * This file is released under the GPLv2
+ *
+ */
+
+#ifndef __ASM_DMA_H
+#define __ASM_DMA_H
+
+/* empty*/
+
+#endif /* __ASM_DMA_H */
diff --git a/arch/x86/include/asm/dma.h b/arch/x86/include/asm/dma.h
new file mode 100644
index 0000000..27d269f
--- /dev/null
+++ b/arch/x86/include/asm/dma.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2012 by Marc Kleine-Budde <mkl@pengutronix.de>
+ *
+ * This file is released under the GPLv2
+ *
+ */
+
+#ifndef __ASM_DMA_H
+#define __ASM_DMA_H
+
+/* empty */
+
+#endif /* __ASM_DMA_H */
diff --git a/include/dma.h b/include/dma.h
new file mode 100644
index 0000000..899f831
--- /dev/null
+++ b/include/dma.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2012 by Marc Kleine-Budde <mkl@pengutronix.de>
+ *
+ * This file is released under the GPLv2
+ *
+ */
+
+#ifndef __DMA_H
+#define __DMA_H
+
+#include <malloc.h>
+#include <xfuncs.h>
+
+#include <asm/dma.h>
+
+#ifndef dma_alloc
+static inline void *dma_alloc(size_t size)
+{
+ return xmalloc(size);
+}
+#endif
+
+#ifndef dma_free
+static inline void dma_free(void *mem)
+{
+ free(mem);
+}
+#endif
+
+#endif /* __DMA_H */
--
1.7.10
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 3/6] nios: add dma_alloc, asm/dma.h
2012-06-20 11:57 [PATCH v2 0/6] fix dma memory allocations, add dma_alloc/dma_free Marc Kleine-Budde
2012-06-20 11:57 ` [PATCH v2 1/6] ARM mmu: don't use CONFIG_MMU to disable mmu code, there are static inline versions Marc Kleine-Budde
2012-06-20 11:57 ` [PATCH v2 2/6] blackfin, mips, openrisc, ppc, sandbox, x86: add generic dma_alloc, dma_free inlines Marc Kleine-Budde
@ 2012-06-20 11:57 ` Marc Kleine-Budde
2012-06-20 11:57 ` [PATCH v2 4/6] ARM mmu: add dma_alloc Marc Kleine-Budde
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Marc Kleine-Budde @ 2012-06-20 11:57 UTC (permalink / raw)
To: sha; +Cc: barebox
This patch add dma_alloc to existing dma-mapping.h. On nios the mem is
aligned to D_ACHE_LINE_SIZE.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
arch/nios2/include/asm/dma-mapping.h | 10 ++++++++++
arch/nios2/include/asm/dma.h | 8 ++++++++
2 files changed, 18 insertions(+)
create mode 100644 arch/nios2/include/asm/dma.h
diff --git a/arch/nios2/include/asm/dma-mapping.h b/arch/nios2/include/asm/dma-mapping.h
index 5b70f4c..9819a97 100644
--- a/arch/nios2/include/asm/dma-mapping.h
+++ b/arch/nios2/include/asm/dma-mapping.h
@@ -1,8 +1,12 @@
#ifndef __ASM_NIOS2_DMA_MAPPING_H
#define __ASM_NIOS2_DMA_MAPPING_H
+#include <common.h>
+#include <xfuncs.h>
+
#include <asm/cache.h>
+
/* dma_alloc_coherent() return cache-line aligned allocation which is mapped
* to uncached io region.
*
@@ -22,4 +26,10 @@ static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
return (void *)(*handle | IO_REGION_BASE);
}
+#define dma_alloc dma_alloc
+static inline void *dma_alloc(size_t size)
+{
+ return xmemalign(DCACHE_LINE_SIZE, ALIGN(size, DCACHE_LINE_SIZE));
+}
+
#endif /* __ASM_NIOS2_DMA_MAPPING_H */
diff --git a/arch/nios2/include/asm/dma.h b/arch/nios2/include/asm/dma.h
new file mode 100644
index 0000000..8f709d2
--- /dev/null
+++ b/arch/nios2/include/asm/dma.h
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2012 by Marc Kleine-Budde <mkl@pengutronix.de>
+ *
+ * This file is released under the GPLv2
+ *
+ */
+
+#include <asm/dma-mapping.h>
--
1.7.10
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 4/6] ARM mmu: add dma_alloc
2012-06-20 11:57 [PATCH v2 0/6] fix dma memory allocations, add dma_alloc/dma_free Marc Kleine-Budde
` (2 preceding siblings ...)
2012-06-20 11:57 ` [PATCH v2 3/6] nios: add dma_alloc, asm/dma.h Marc Kleine-Budde
@ 2012-06-20 11:57 ` Marc Kleine-Budde
2012-06-20 11:57 ` [PATCH v2 5/6] USB gadget fsl: request cacheline aligned buffer Marc Kleine-Budde
2012-06-20 11:57 ` [PATCH v2 6/6] USB gadget: Fix dma memory allocations Marc Kleine-Budde
5 siblings, 0 replies; 7+ messages in thread
From: Marc Kleine-Budde @ 2012-06-20 11:57 UTC (permalink / raw)
To: sha; +Cc: barebox
dma_alloc() allocates memory aligned to cache lines. We have to use
cache line aligned buffers if a driver calls dma_inv_range on the
buffer.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
arch/arm/include/asm/dma.h | 8 ++++++++
arch/arm/include/asm/mmu.h | 13 +++++++++++--
2 files changed, 19 insertions(+), 2 deletions(-)
create mode 100644 arch/arm/include/asm/dma.h
diff --git a/arch/arm/include/asm/dma.h b/arch/arm/include/asm/dma.h
new file mode 100644
index 0000000..cb9cd1b
--- /dev/null
+++ b/arch/arm/include/asm/dma.h
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2012 by Marc Kleine-Budde <mkl@pengutronix.de>
+ *
+ * This file is released under the GPLv2
+ *
+ */
+
+#include <asm/mmu.h>
diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
index f5ae7a8..a66da8c 100644
--- a/arch/arm/include/asm/mmu.h
+++ b/arch/arm/include/asm/mmu.h
@@ -1,9 +1,12 @@
#ifndef __ASM_MMU_H
#define __ASM_MMU_H
-#include <asm/pgtable.h>
-#include <malloc.h>
+#include <common.h>
#include <errno.h>
+#include <malloc.h>
+#include <xfuncs.h>
+
+#include <asm/pgtable.h>
#define PMD_SECT_DEF_UNCACHED (PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | PMD_TYPE_SECT)
#define PMD_SECT_DEF_CACHED (PMD_SECT_WB | PMD_SECT_DEF_UNCACHED)
@@ -23,6 +26,12 @@ static inline void setup_dma_coherent(unsigned long offset)
{
}
+#define dma_alloc dma_alloc
+static inline void *dma_alloc(size_t size)
+{
+ return xmemalign(64, ALIGN(size, 64));
+}
+
#ifdef CONFIG_MMU
void *dma_alloc_coherent(size_t size);
void dma_free_coherent(void *mem, size_t size);
--
1.7.10
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 5/6] USB gadget fsl: request cacheline aligned buffer
2012-06-20 11:57 [PATCH v2 0/6] fix dma memory allocations, add dma_alloc/dma_free Marc Kleine-Budde
` (3 preceding siblings ...)
2012-06-20 11:57 ` [PATCH v2 4/6] ARM mmu: add dma_alloc Marc Kleine-Budde
@ 2012-06-20 11:57 ` Marc Kleine-Budde
2012-06-20 11:57 ` [PATCH v2 6/6] USB gadget: Fix dma memory allocations Marc Kleine-Budde
5 siblings, 0 replies; 7+ messages in thread
From: Marc Kleine-Budde @ 2012-06-20 11:57 UTC (permalink / raw)
To: sha; +Cc: barebox
From: Sascha Hauer <s.hauer@pengutronix.de>
The fsl udc driver allocates a buffer for small requests. The
driver then calls dma_inv_range later on it. This buffer happens
to be not cacheline aligned which means that a dma_inv_range can
corrupt other memory around the buffer.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
[mkl: use dma_alloc]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/usb/gadget/fsl_udc.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/fsl_udc.c b/drivers/usb/gadget/fsl_udc.c
index 5b64ec2..627e417 100644
--- a/drivers/usb/gadget/fsl_udc.c
+++ b/drivers/usb/gadget/fsl_udc.c
@@ -1,5 +1,6 @@
#include <common.h>
#include <errno.h>
+#include <dma.h>
#include <init.h>
#include <clock.h>
#include <usb/ch9.h>
@@ -8,7 +9,6 @@
#include <io.h>
#include <poller.h>
#include <asm/byteorder.h>
-#include <asm/mmu.h>
/* ### define USB registers here
*/
@@ -2109,7 +2109,8 @@ static int struct_udc_setup(struct fsl_udc *udc,
udc->status_req = container_of(fsl_alloc_request(NULL),
struct fsl_req, req);
/* allocate a small amount of memory to get valid address */
- udc->status_req->req.buf = xmalloc(8);
+ udc->status_req->req.buf = dma_alloc(8);
+ udc->status_req->req.length = 8;
udc->resume_state = USB_STATE_NOTATTACHED;
udc->usb_state = USB_STATE_POWERED;
udc->ep0_dir = 0;
--
1.7.10
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 6/6] USB gadget: Fix dma memory allocations
2012-06-20 11:57 [PATCH v2 0/6] fix dma memory allocations, add dma_alloc/dma_free Marc Kleine-Budde
` (4 preceding siblings ...)
2012-06-20 11:57 ` [PATCH v2 5/6] USB gadget fsl: request cacheline aligned buffer Marc Kleine-Budde
@ 2012-06-20 11:57 ` Marc Kleine-Budde
5 siblings, 0 replies; 7+ messages in thread
From: Marc Kleine-Budde @ 2012-06-20 11:57 UTC (permalink / raw)
To: sha; +Cc: barebox
From: Sascha Hauer <s.hauer@pengutronix.de>
This is another variant of:
USB gadget fsl: request cacheline aligned buffer
The fsl udc driver allocates a buffer for small requests. The
driver then calls dma_inv_range later on it. This buffer happens
to be not cacheline aligned which means that a dma_inv_range can
corrupt other memory around the buffer.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
[mkl: use dma_alloc]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/usb/gadget/composite.c | 5 +++--
drivers/usb/gadget/dfu.c | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index fd70e62..44e58d7 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -22,6 +22,7 @@
#include <common.h>
#include <errno.h>
+#include <dma.h>
#include <usb/composite.h>
#include <asm/byteorder.h>
@@ -867,7 +868,7 @@ composite_unbind(struct usb_gadget *gadget)
composite->unbind(cdev);
if (cdev->req) {
- kfree(cdev->req->buf);
+ dma_free(cdev->req->buf);
usb_ep_free_request(gadget->ep0, cdev->req);
}
kfree(cdev);
@@ -911,7 +912,7 @@ static int __init composite_bind(struct usb_gadget *gadget)
cdev->req = usb_ep_alloc_request(gadget->ep0);
if (!cdev->req)
goto fail;
- cdev->req->buf = malloc(USB_BUFSIZ);
+ cdev->req->buf = dma_alloc(USB_BUFSIZ);
if (!cdev->req->buf)
goto fail;
cdev->req->complete = composite_setup_complete;
diff --git a/drivers/usb/gadget/dfu.c b/drivers/usb/gadget/dfu.c
index f26c1e4..e205c65 100644
--- a/drivers/usb/gadget/dfu.c
+++ b/drivers/usb/gadget/dfu.c
@@ -40,6 +40,7 @@
* - make 'dnstate' attached to 'struct usb_device_instance'
*/
+#include <dma.h>
#include <asm/byteorder.h>
#include <usb/composite.h>
#include <linux/types.h>
@@ -183,7 +184,7 @@ dfu_unbind(struct usb_configuration *c, struct usb_function *f)
if (gadget_is_dualspeed(c->cdev->gadget))
free(f->hs_descriptors);
- free(dfu->dnreq->buf);
+ dma_free(dfu->dnreq->buf);
usb_ep_free_request(c->cdev->gadget->ep0, dfu->dnreq);
free(dfu);
}
@@ -602,7 +603,7 @@ static int dfu_bind_config(struct usb_configuration *c)
dfu->dnreq = usb_ep_alloc_request(c->cdev->gadget->ep0);
if (!dfu->dnreq)
printf("usb_ep_alloc_request failed\n");
- dfu->dnreq->buf = xmalloc(CONFIG_USBD_DFU_XFER_SIZE);
+ dfu->dnreq->buf = dma_alloc(CONFIG_USBD_DFU_XFER_SIZE);
dfu->dnreq->complete = dn_complete;
dfu->dnreq->zero = 0;
--
1.7.10
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-06-20 11:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-20 11:57 [PATCH v2 0/6] fix dma memory allocations, add dma_alloc/dma_free Marc Kleine-Budde
2012-06-20 11:57 ` [PATCH v2 1/6] ARM mmu: don't use CONFIG_MMU to disable mmu code, there are static inline versions Marc Kleine-Budde
2012-06-20 11:57 ` [PATCH v2 2/6] blackfin, mips, openrisc, ppc, sandbox, x86: add generic dma_alloc, dma_free inlines Marc Kleine-Budde
2012-06-20 11:57 ` [PATCH v2 3/6] nios: add dma_alloc, asm/dma.h Marc Kleine-Budde
2012-06-20 11:57 ` [PATCH v2 4/6] ARM mmu: add dma_alloc Marc Kleine-Budde
2012-06-20 11:57 ` [PATCH v2 5/6] USB gadget fsl: request cacheline aligned buffer Marc Kleine-Budde
2012-06-20 11:57 ` [PATCH v2 6/6] USB gadget: Fix dma memory allocations Marc Kleine-Budde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox