kernel.h: Add DIV_ROUND_UP_ULL and DIV_ROUND_UP_SECTOR_T macro usage
Subsystems (2)
PATCH v2 1/2 kernel.h: Add DIV_ROUND_UP_ULL and DIV_ROUND_UP_SECTOR_T macro usage
From: Nicholas Bellinger <[email protected]>
Add new DIV_ROUND_UP_SECTOR_T macro usage for 32-bit architectures requiring a new DIV_ROUND_UP_ULL, and existing 64-bit usage with DIV_ROUND_UP.
--- include/linux/kernel.h | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
include/linux/kernel.h +8 -0
@@ -56,6 +56,14 @@#define FIELD_SIZEOF (t, f) (sizeof(((t*)0)->f))#define DIV_ROUND_UP (n,d) (((n) + (d) - 1) / (d)) +#define DIV_ROUND_UP_ULL (ll,d) \ + ({ unsigned long long _tmp = (ll)+(d)-1; do_div(_tmp, d); _tmp; }) + +#if BITS_PER_LONG ==32 +# define DIV_ROUND_UP_SECTOR_T (ll,d) DIV_ROUND_UP_ULL(ll, d) +#else +# define DIV_ROUND_UP_SECTOR_T (ll,d) DIV_ROUND_UP(ll,d) +#endif /* The `const' in roundup() prevents gcc-3.3 from calling __divdi3 */ #define roundup (x, y) ( \
Signature · 1 line
1.7.2.5
PATCH v2 2/2 target: Convert to DIV_ROUND_UP_SECTOR_T usage for sectors / dev_max_sectors
From: Nicholas Bellinger <[email protected]>
This patch adds the new macro usage of include/linux/kernel.h:DIV_ROUND_UP_SECTOR_T usage to use the new DIV_ROUND_UP_ULL() usage for 32-bit architectures with the unsigned long long sector_t division in transport_allocate_data_tasks() usage for target_core_mod v4.1
--- drivers/target/target_core_transport.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
drivers/target/target_core_transport.c +3 -4
@@ -4054,17 +4054,16 @@ static int transport_allocate_data_tasks(struct se_task *task;struct se_device *dev = cmd->se_dev;unsigned long flags; -sector_t sectors;int task_count, i, ret; -sector_t dev_max_sectors = dev->se_sub_dev->se_dev_attrib.max_sectors; +sector_t sectors, dev_max_sectors = dev->se_sub_dev->se_dev_attrib.max_sectors;u32 sector_size = dev->se_sub_dev->se_dev_attrib.block_size;struct scatterlist *sg;struct scatterlist *cmd_sg;WARN_ON (cmd->data_length % sector_size); sectors =DIV_ROUND_UP (cmd->data_length, sector_size); - task_count =DIV_ROUND_UP (sectors, dev_max_sectors); - + task_count =DIV_ROUND_UP_SECTOR_T (sectors, dev_max_sectors); + cmd_sg = sgl;for (i =0 ; i < task_count; i++) {unsigned int task_size;
Signature · 1 line
1.7.2.5
Quoted 19 lines · Nicholas A. Bellinger
From: Nicholas Bellinger <[email protected]>
Add new
DIV_ROUND_UP_SECTOR_Tmacro usage for 32-bit architectures requiring a newDIV_ROUND_UP_ULL, and existing 64-bit usage withDIV_ROUND_UP.Reported-by Linus Torvalds <[email protected]>Reported-by Andrew Morton <[email protected]>Signed-off-by Nicholas A. Bellinger <[email protected]>--- include/linux/kernel.h | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)include/linux/kernel.h +0
-0@@ -56,6 +56,14 @@#define FIELD_SIZEOF (t, f) (sizeof(((t*)0)->f))
include/linux/kernel.h line 67
Quoted 10 lines
include/linux/kernel.h +8
-0#define DIV_ROUND_UP (n,d) (((n) + (d) - 1) / (d)) +#define DIV_ROUND_UP_ULL (ll,d) \ + ({ unsigned long long _tmp = (ll)+(d)-1; do_div(_tmp, d); _tmp; }) + +#if BITS_PER_LONG ==32 +# define DIV_ROUND_UP_SECTOR_T (ll,d) DIV_ROUND_UP_ULL(ll, d) +#else +# define DIV_ROUND_UP_SECTOR_T (ll,d) DIV_ROUND_UP(ll,d) +#endif
Hi Andrew,
Is CONFIG_LBDAF=n usage going to have problems with the above..?
Things are looking as expected AFAICT with some quick tests with CONFIG_LBDAF=y on i386, but still need to verify the CONFIG_LBDAF=n on 32-bit as well. Any more comments here are appercitated.
Thank you,
--nab