From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::244; helo=mail-wm0-x244.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 62153210F3D6C for ; Wed, 22 Aug 2018 12:19:54 -0700 (PDT) Received: by mail-wm0-x244.google.com with SMTP id o18-v6so3334296wmc.0 for ; Wed, 22 Aug 2018 12:19:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=agqNn5Luzsgz3/4c1ayxzAl/xRUe/vI3HO0+dTyPm2A=; b=khgae4EDQ3/Z4yCXWJavpqiPB8/0dwiBCX6NyRPzWmIA8ZvVuIFbQ00Ece/N6pmoJc Db7/sBs6QJkGg4sSMAtMzxVBHwfoJM0y/LwEu9OzIsf6WfQJ6taF3EmpbH1VP/PwaIQ1 3kXfBv04kULPUQvL+2AExmUhwOhXhuGntzCBk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=agqNn5Luzsgz3/4c1ayxzAl/xRUe/vI3HO0+dTyPm2A=; b=O2OdEvo98rPh00e2Q9bPMCs2Ty0jQ0TmFjs4d4RqVOel8URZjR5rerwLgJ5bWKkiV+ RdxmFeI9Yv47JnGzN8Ti0pnvvaDEIpHcqkQ9XD2Q8ixvI2CzqiRWo8L/iygQCQqHbZge PUQiNsnzlJ7ZHUZ+FGfUPUsjEshC7im9nKgfcfj0zqtH/lQyR8pLDNVovVM+j+D7+bw/ gnEW51Y0G8w/T9WQaCqyK7o8glz44OuGrhGj6RUaf6ZACZ3/+yAixqUpSGwv3yGCrWbg rviePbDfnyt+0MaTjJC46eawPihtJHtrbw5KpOqL9TmqTSGyZAhhnvzDUATZJHKU+n3i H0Xw== X-Gm-Message-State: APzg51Dd62b7lnjmqse95dT+h8mEh7CB4SXC1hZGeBW0fr8nboQCsHZN PF3ntBjg5JvK+l1NKxZULQCTvw== X-Google-Smtp-Source: ANB0VdbO4EQWiVL4P5tKempIwxEHfKyDxFqvsMQP/32IpCp1U3UqrKGjYnEN8r+dmhTITnCeB6aaAg== X-Received: by 2002:a1c:230f:: with SMTP id j15-v6mr3184424wmj.124.1534965592809; Wed, 22 Aug 2018 12:19:52 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id w204-v6sm3373058wmw.5.2018.08.22.12.19.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 22 Aug 2018 12:19:51 -0700 (PDT) Date: Wed, 22 Aug 2018 20:19:49 +0100 From: Leif Lindholm To: Sami Mujawar Cc: edk2-devel@lists.01.org, ard.biesheuvel@linaro.org, Matteo.Carlini@arm.com, Stephanie.Hughes-Fitt@arm.com, evan.lloyd@arm.com, nd@arm.com Message-ID: <20180822191949.3up22exss5ka2qwd@bivouac.eciton.net> References: <20180821101443.31636-1-sami.mujawar@arm.com> MIME-Version: 1.0 In-Reply-To: <20180821101443.31636-1-sami.mujawar@arm.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH v1 1/1] ArmPkg: Add support for GICv4 X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Aug 2018 19:19:54 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Sami, On Tue, Aug 21, 2018 at 11:14:43AM +0100, Sami Mujawar wrote: > Updated Redistributor base calculation to allow for the fact that > GICv4 has 2 additional 64KB frames (for VLPI and a reserved frame). > The code now tests the VLPIS bit in the GICR_TYPER register Can you expand the name for this register (GIC Redistributor Type Register)? > and calculates the Redistributor granularity accordingly. > > The code changes are: > GICR_TYPER register fields, etc, added to the header. > Loop updated to pay attention to GICR_TYPER.Last. > Derive frame "stride" size from GICR_TYPER.VLPIS. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Sami Mujawar > --- > The changes can be seen at: > https://github.com/samimujawar/edk2/tree/329_gicv4_granularity_v1 > > Notes: > v1: > - Added support for initializing GICv4 [SAMI] > > ArmPkg/Drivers/ArmGic/ArmGicLib.c | 37 ++++++++++++-------- > ArmPkg/Include/Library/ArmGicLib.h | 19 ++++++++-- Can you add a sort order file in your working tree (git config diff.orderFile) with the contents in Laszlo's unkempt guide? > 2 files changed, 39 insertions(+), 17 deletions(-) > > diff --git a/ArmPkg/Drivers/ArmGic/ArmGicLib.c b/ArmPkg/Drivers/ArmGic/ArmGicLib.c > index 0087399fb1dba0e697f7a6ccd6f7432a59311ac6..033d98b75c1fc0414e7b70be1ca53d5c91cb6f3c 100644 > --- a/ArmPkg/Drivers/ArmGic/ArmGicLib.c > +++ b/ArmPkg/Drivers/ArmGic/ArmGicLib.c > @@ -1,6 +1,6 @@ > /** @file > * > -* Copyright (c) 2011-2017, ARM Limited. All rights reserved. > +* Copyright (c) 2011-2018, ARM Limited. All rights reserved. > * > * This program and the accompanying materials > * are licensed and made available under the terms and conditions of the BSD License > @@ -19,6 +19,16 @@ > #include > #include > > +// In GICv3, there are 2 x 64KB frames: > +// Redistributor control frame + SGI Control & Generation frame > +#define GIC_V3_REDISTRIBUTOR_GRANULARITY (ARM_GICR_CTLR_FRAME_SIZE \ > + + ARM_GICR_SGI_PPI_FRAME_SIZE) > + > +// In GICv4, there are 2 additional 64KB frames: > +// VLPI frame + Reserved page frame > +#define GIC_V4_REDISTRIBUTOR_GRANULARITY (GIC_V3_REDISTRIBUTOR_GRANULARITY \ > + + ARM_GICR_SGI_VLPI_FRAME_SIZE \ > + + ARM_GICR_SGI_RESERVED_FRAME_SIZE) > > #define ISENABLER_ADDRESS(base,offset) ((base) + \ > ARM_GICR_CTLR_FRAME_SIZE + ARM_GICR_ISENABLER + (4 * offset)) > @@ -54,12 +64,11 @@ GicGetCpuRedistributorBase ( > IN ARM_GIC_ARCH_REVISION Revision > ) > { > - UINTN Index; > UINTN MpId; > UINTN CpuAffinity; > UINTN Affinity; > - UINTN GicRedistributorGranularity; > UINTN GicCpuRedistributorBase; > + UINT64 GicRTyper; I know this is the official name of the register, but this is a local variable in a function specific to the redistributor, so could you change it to be just TypeRegister? > > MpId = ArmReadMpidr (); > // Define CPU affinity as: > @@ -68,27 +77,27 @@ GicGetCpuRedistributorBase ( > CpuAffinity = (MpId & (ARM_CORE_AFF0 | ARM_CORE_AFF1 | ARM_CORE_AFF2)) | > ((MpId & ARM_CORE_AFF3) >> 8); > > - if (Revision == ARM_GIC_ARCH_REVISION_3) { > - // 2 x 64KB frame: > - // Redistributor control frame + SGI Control & Generation frame > - GicRedistributorGranularity = ARM_GICR_CTLR_FRAME_SIZE > - + ARM_GICR_SGI_PPI_FRAME_SIZE; > - } else { > + if (Revision < ARM_GIC_ARCH_REVISION_3) { > ASSERT_EFI_ERROR (EFI_UNSUPPORTED); > return 0; > } > > GicCpuRedistributorBase = GicRedistributorBase; > > - for (Index = 0; Index < PcdGet32 (PcdCoreCount); Index++) { > - Affinity = MmioRead64 (GicCpuRedistributorBase + ARM_GICR_TYPER) >> 32; > + do { > + GicRTyper = MmioRead64 (GicCpuRedistributorBase + ARM_GICR_TYPER); > + Affinity = GicRTyper >> 32; Could you add a macro for that >> 32? ARM_GICR_TYPER_AFFINITY(...) ? Hah, no, that's already used for the other way :) _GET_AFFINITY? > if (Affinity == CpuAffinity) { > return GicCpuRedistributorBase; > } > > - // Move to the next GIC Redistributor frame > - GicCpuRedistributorBase += GicRedistributorGranularity; > - } > + // Move to the next GIC Redistributor frame. > + // The GIC specification does not forbid a mixture of v3 and v4 frames, > + // so we test VLPIS for each frame. Could you expand VLPIS (Virtual LPIs Supported or somesuch)? "v3 and v4" frames ... is that a correct architectural description? / Leif > + GicCpuRedistributorBase += (((ARM_GICR_TYPER_VLPIS & GicRTyper) != 0) > + ? GIC_V4_REDISTRIBUTOR_GRANULARITY > + : GIC_V3_REDISTRIBUTOR_GRANULARITY); > + } while ((GicRTyper & ARM_GICR_TYPER_LAST) == 0); > > // The Redistributor has not been found for the current CPU > ASSERT_EFI_ERROR (EFI_NOT_FOUND); > diff --git a/ArmPkg/Include/Library/ArmGicLib.h b/ArmPkg/Include/Library/ArmGicLib.h > index 4b21ea9e4e76cb83c0c3421c1d9d88b456192687..4e3468648b255efa247dc4176ce4688986fcb226 100644 > --- a/ArmPkg/Include/Library/ArmGicLib.h > +++ b/ArmPkg/Include/Library/ArmGicLib.h > @@ -1,6 +1,6 @@ > /** @file > * > -* Copyright (c) 2011-2017, ARM Limited. All rights reserved. > +* Copyright (c) 2011-2018, ARM Limited. All rights reserved. > * > * This program and the accompanying materials > * are licensed and made available under the terms and conditions of the BSD License > @@ -60,12 +60,25 @@ > > > // GIC Redistributor > -#define ARM_GICR_CTLR_FRAME_SIZE SIZE_64KB > -#define ARM_GICR_SGI_PPI_FRAME_SIZE SIZE_64KB > +#define ARM_GICR_CTLR_FRAME_SIZE SIZE_64KB > +#define ARM_GICR_SGI_PPI_FRAME_SIZE SIZE_64KB > +#define ARM_GICR_SGI_VLPI_FRAME_SIZE SIZE_64KB > +#define ARM_GICR_SGI_RESERVED_FRAME_SIZE SIZE_64KB > > // GIC Redistributor Control frame > #define ARM_GICR_TYPER 0x0008 // Redistributor Type Register > > +// GIC Redistributor TYPER bit assignments > +#define ARM_GICR_TYPER_PLPIS (1 << 0) // Physical LPIs > +#define ARM_GICR_TYPER_VLPIS (1 << 1) // Virtual LPIs > +#define ARM_GICR_TYPER_DIRECTLPI (1 << 3) // Direct LPIs > +#define ARM_GICR_TYPER_LAST (1 << 4) // Last Redistributor in series > +#define ARM_GICR_TYPER_DPGS (1 << 5) // Disable Processor Group > + // Selection Support > +#define ARM_GICR_TYPER_PROCNO (0xFFFF << 8) // Processor Number > +#define ARM_GICR_TYPER_COMMONLPIAFF (0x3 << 24) // Common LPI Affinity > +#define ARM_GICR_TYPER_AFFINITY (0xFFFFFFFFULL << 32) // Redistributor Affinity > + > // GIC SGI & PPI Redistributor frame > #define ARM_GICR_ISENABLER 0x0100 // Interrupt Set-Enable Registers > #define ARM_GICR_ICENABLER 0x0180 // Interrupt Clear-Enable Registers > -- > 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' > >