Skip to content

Commit 4fb7d08

Browse files
mike-travisIngo Molnar
authored andcommitted
x86/platform/uv: Account for UV Hubless in is_uvX_hub Ops
The references in the is_uvX_hub() function uses the hub_info pointer which will be NULL when the system is hubless. This change avoids that NULL dereference. It is also an optimization in performance. Signed-off-by: Mike Travis <[email protected]> Reviewed-by: Steve Wahl <[email protected]> Reviewed-by: Dimitri Sivanich <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Hedi Berriche <[email protected]> Cc: Justin Ernst <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Russ Anderson <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent df55029 commit 4fb7d08

File tree

1 file changed

+20
-41
lines changed

1 file changed

+20
-41
lines changed

arch/x86/include/asm/uv/uv_hub.h

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/topology.h>
2020
#include <asm/types.h>
2121
#include <asm/percpu.h>
22+
#include <asm/uv/uv.h>
2223
#include <asm/uv/uv_mmrs.h>
2324
#include <asm/uv/bios.h>
2425
#include <asm/irq_vectors.h>
@@ -243,83 +244,61 @@ static inline int uv_hub_info_check(int version)
243244
#define UV4_HUB_REVISION_BASE 7
244245
#define UV4A_HUB_REVISION_BASE 8 /* UV4 (fixed) rev 2 */
245246

246-
#ifdef UV1_HUB_IS_SUPPORTED
247+
/* WARNING: UVx_HUB_IS_SUPPORTED defines are deprecated and will be removed */
247248
static inline int is_uv1_hub(void)
248249
{
249-
return uv_hub_info->hub_revision < UV2_HUB_REVISION_BASE;
250-
}
250+
#ifdef UV1_HUB_IS_SUPPORTED
251+
return is_uv_hubbed(uv(1));
251252
#else
252-
static inline int is_uv1_hub(void)
253-
{
254253
return 0;
255-
}
256254
#endif
255+
}
257256

258-
#ifdef UV2_HUB_IS_SUPPORTED
259257
static inline int is_uv2_hub(void)
260258
{
261-
return ((uv_hub_info->hub_revision >= UV2_HUB_REVISION_BASE) &&
262-
(uv_hub_info->hub_revision < UV3_HUB_REVISION_BASE));
263-
}
259+
#ifdef UV2_HUB_IS_SUPPORTED
260+
return is_uv_hubbed(uv(2));
264261
#else
265-
static inline int is_uv2_hub(void)
266-
{
267262
return 0;
268-
}
269263
#endif
264+
}
270265

271-
#ifdef UV3_HUB_IS_SUPPORTED
272266
static inline int is_uv3_hub(void)
273267
{
274-
return ((uv_hub_info->hub_revision >= UV3_HUB_REVISION_BASE) &&
275-
(uv_hub_info->hub_revision < UV4_HUB_REVISION_BASE));
276-
}
268+
#ifdef UV3_HUB_IS_SUPPORTED
269+
return is_uv_hubbed(uv(3));
277270
#else
278-
static inline int is_uv3_hub(void)
279-
{
280271
return 0;
281-
}
282272
#endif
273+
}
283274

284275
/* First test "is UV4A", then "is UV4" */
285-
#ifdef UV4A_HUB_IS_SUPPORTED
286-
static inline int is_uv4a_hub(void)
287-
{
288-
return (uv_hub_info->hub_revision >= UV4A_HUB_REVISION_BASE);
289-
}
290-
#else
291276
static inline int is_uv4a_hub(void)
292277
{
278+
#ifdef UV4A_HUB_IS_SUPPORTED
279+
if (is_uv_hubbed(uv(4)))
280+
return (uv_hub_info->hub_revision == UV4A_HUB_REVISION_BASE);
281+
#endif
293282
return 0;
294283
}
295-
#endif
296284

297-
#ifdef UV4_HUB_IS_SUPPORTED
298285
static inline int is_uv4_hub(void)
299286
{
300-
return uv_hub_info->hub_revision >= UV4_HUB_REVISION_BASE;
301-
}
287+
#ifdef UV4_HUB_IS_SUPPORTED
288+
return is_uv_hubbed(uv(4));
302289
#else
303-
static inline int is_uv4_hub(void)
304-
{
305290
return 0;
306-
}
307291
#endif
292+
}
308293

309294
static inline int is_uvx_hub(void)
310295
{
311-
if (uv_hub_info->hub_revision >= UV2_HUB_REVISION_BASE)
312-
return uv_hub_info->hub_revision;
313-
314-
return 0;
296+
return (is_uv_hubbed(-2) >= uv(2));
315297
}
316298

317299
static inline int is_uv_hub(void)
318300
{
319-
#ifdef UV1_HUB_IS_SUPPORTED
320-
return uv_hub_info->hub_revision;
321-
#endif
322-
return is_uvx_hub();
301+
return is_uv1_hub() || is_uvx_hub();
323302
}
324303

325304
union uvh_apicid {

0 commit comments

Comments
 (0)