Re: [PATCH 6/8] x86/platform/uv: Decode UVsystab Info

From: Mike Travis
Date: Thu Sep 05 2019 - 18:42:46 EST




On 9/5/2019 2:40 PM, Sasha Levin wrote:
On Thu, Sep 05, 2019 at 04:16:34PM +0200, Greg KH wrote:
On Thu, Sep 05, 2019 at 08:02:58AM -0500, Mike Travis wrote:
--- linux.orig/arch/x86/kernel/apic/x2apic_uv_x.c
+++ linux/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -1303,7 +1303,8 @@ static int __init decode_uv_systab(void)
     struct uv_systab *st;
     int i;

-    if (uv_hub_info->hub_revision < UV4_HUB_REVISION_BASE)
+    /* Select only UV4 (hubbed or hubless) and higher */
+    if (is_uv_hubbed(-2) < uv(4) && is_uv_hubless(-2) < uv(4))

For someone not too familiar with the code, this is completely
unreadable. There must be a nicer way to do this.

--
Thanks,
Sasha

Hi Sasha,

I can put in further explanation but first the uv() function returns 1 left shifted by the UV #:

static inline int uv(int uvtype)
{
/* uv(0) is "any" */
if (uvtype >= 0 && uvtype <= 30)
return 1 << uvtype;
return 1;
}

The "is_uv_hubbed(x)" and "is_uv_hubless(x)" AND's the incoming arg with the actual uv type:

int is_uv_hubbed(int uvtype)
{
return (uv_hubbed_system & uvtype);
}

The uv_hub{bed,less}_system is set to 1 left shifted by the UV # plus in bit 0 is a '1' to indicate "any" UV (as in "is_uv_hubbed(1)" is any UV hubbed system). Hubbed indicates a hubbed system, and hubless indicates a hubless system, it cannot be both but can be neither.

/* UV4 Hubless, (0x11:UV4+Any) */
if (strncmp(oem_id, "NSGI4", 5) == 0)
uv_hubless_system = 0x11;

/* UV3 Hubless, UV300/MC990X w/o hub (0x9:UV3+Any) */
else
uv_hubless_system = 0x9;


(There are only hubbed versions of UV1 and UV2.)

Lastly (-2) translates to 0xffff...fffe (note bit 0 is clear to avoid the "any" bit. So it is looking for a a hubbed or hubless UV system that is less than UV4 meaning only UV4,5,6...qualify, hence this comment:

>>> + /* Select only UV4 (hubbed or hubless) and higher */
if (UV is less than UV4 either hubbed or hubless)
return; /* does not have an extended UVsystab */

Have you a suggestion on what would make it more clear? Perhaps instead of -2 I should use a hex mask?

Thanks,
Mike