On Tue, 25 Nov 2014, Sebastian Andrzej Siewior wrote: > On 11/24/2014 11:00 PM, Alan Stern wrote: > >> diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c > >> index 684ef70dc09d..a80d1ec8b1b0 100644 > >> --- a/drivers/usb/core/buffer.c > >> +++ b/drivers/usb/core/buffer.c > >> @@ -26,7 +26,11 @@ static const size_t pool_max[HCD_BUFFER_POOLS] = { > >> /* platforms without dma-friendly caches might need to > >> * prevent cacheline sharing... > >> */ > >> +#if ARCH_KMALLOC_MINALIGN <= 32 > >> 32, > >> +#elif ARCH_KMALLOC_MINALIGN <= 64 > >> + 64, > >> +#endif > >> 128, > >> 512, > >> PAGE_SIZE / 2 > >> @@ -58,6 +62,7 @@ int hcd_buffer_create(struct usb_hcd *hcd) > >> !(hcd->driver->flags & HCD_LOCAL_MEM)) > >> return 0; > >> > >> + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN > 128); > >> for (i = 0; i < HCD_BUFFER_POOLS; i++) { > >> size = pool_max[i]; > >> if (!size) > >> diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h > >> index cd96a2bc3388..1e2234ca448d 100644 > >> --- a/include/linux/usb/hcd.h > >> +++ b/include/linux/usb/hcd.h > >> @@ -23,6 +23,7 @@ > >> > >> #include <linux/rwsem.h> > >> #include <linux/interrupt.h> > >> +#include <linux/slab.h> > >> > >> #define MAX_TOPO_LEVEL 6 > >> > >> @@ -171,8 +172,11 @@ struct usb_hcd { > >> struct usb_hcd *shared_hcd; > >> struct usb_hcd *primary_hcd; > >> > >> - > >> -#define HCD_BUFFER_POOLS 4 > >> +#if ARCH_KMALLOC_MINALIGN <= 64 > >> + #define HCD_BUFFER_POOLS 4 > >> +#else > >> + #define HCD_BUFFER_POOLS 3 > >> +#endif > >> struct dma_pool *pool[HCD_BUFFER_POOLS]; > > > > What about the ARCH_KMALLOC_MINALIGN <= 32 case? > > since <= 32 is also <= 64 there will be 4 pools. The first pool will > have 32 bytes in size, there will be no 64byte pool (it will behave > like it does now). > But this does not really answer your question, does it? I assume I > overlook the obvious thing. Ah, okay, now I see. The code is a slightly confusing, but correct. How about refactoring it a little to make it clearer? Like this: static const size_t pool_max[HCD_BUFFER_POOLS] = { #if ARCH_KMALLOC_MINALIGN <= 32 32, 128, 512, PAGE_SIZE / 2 #elif ARCH_KMALLOC_MINALIGN <= 64 64, 128, 512, PAGE_SIZE / 2 #else 128, 512, PAGE_SIZE / 2 #endif }; /* If ARCH_KMALLOC_MINALIGN > 128 we will cause a BUILD_BUG */ Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html