Messages in this thread Patch in this message | | | Subject | Re: [PATCH 4/4] iommu/arm-smmu-v3: Remove cmpxchg() in arm_smmu_cmdq_issue_cmdlist() | From | John Garry <> | Date | Fri, 26 Jun 2020 11:05:13 +0100 |
| |
On 23/06/2020 14:55, Rikard Falkeborn wrote: > Den tis 23 juni 2020 12:21John Garry <john.garry@huawei.com > <mailto:john.garry@huawei.com>> skrev: > > On 23/06/2020 10:35, Rikard Falkeborn wrote: > > > > I'd say that GENMASK_INPUT_CHECK() should be able to handle a > l=0 and > > h=unsigned value, so I doubt this warn. > > > > Using GENMASK((int)cmdq->q.llq.max_n_shift, 0) resolves it, > but it > > looks > > like GENMASK_INPUT_CHECK() could be improved. > > > > > > Indeed it could, it is fixed in -next. > > ok, thanks for the pointer, but I still see this on today's -next with > this patch: > > make W=1 drivers/iommu/arm-smmu-v3.o > > > Oh, ok thanks for reporting. I guess different gcc versions have > different behaviour. I guess we'll have to change the comparison to > (!((h) == (l) || (h) > (l))) instead (not sure I got all parenthesis and > logic correct but you get the idea). >
Yeah, so this looks to fix it:
--- a/include/linux/bits.h +++ b/include/linux/bits.h @@ -23,7 +23,8 @@ #include <linux/build_bug.h> #define GENMASK_INPUT_CHECK(h, l) \ (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \ - __builtin_constant_p((l) > (h)), (l) > (h), 0))) + __builtin_constant_p(!((h) == (l) ||(h) > (l))), !((h) == (l) ||(h) > (l)), 0))) +
We may be able to just use (h) == (l) as the const expr to make it more concise, but that may be confusing.
I only tested with my toolchain based on 7.5.0
Thanks, John
| |