From patchwork Tue Oct 28 03:25:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Munsie X-Patchwork-Id: 404046 X-Patchwork-Delegate: michael@ellerman.id.au Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 473B314007F for ; Tue, 28 Oct 2014 14:29:39 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id 31F4E1A1DAC for ; Tue, 28 Oct 2014 14:29:39 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id C1DB11A19DA for ; Tue, 28 Oct 2014 14:26:32 +1100 (AEDT) Received: by ozlabs.org (Postfix) id A918014009A; Tue, 28 Oct 2014 14:26:32 +1100 (AEDT) Delivered-To: linuxppc-dev@ozlabs.org Received: from e23smtp04.au.ibm.com (e23smtp04.au.ibm.com [202.81.31.146]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 99898140082 for ; Tue, 28 Oct 2014 14:26:32 +1100 (AEDT) Received: from /spool/local by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 28 Oct 2014 13:26:32 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp04.au.ibm.com (202.81.31.210) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 28 Oct 2014 13:26:29 +1000 Received: from d23relay07.au.ibm.com (d23relay07.au.ibm.com [9.190.26.37]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 8C2C02BB0023; Tue, 28 Oct 2014 14:26:29 +1100 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s9S3QHUO42401942; Tue, 28 Oct 2014 14:26:25 +1100 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s9S3PubW013870; Tue, 28 Oct 2014 14:25:57 +1100 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.190.163.12]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s9S3PuMr013184; Tue, 28 Oct 2014 14:25:56 +1100 Received: from dukhat.ozlabs.ibm.com (haven.au.ibm.com [9.190.164.82]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id D2545A028C; Tue, 28 Oct 2014 14:25:31 +1100 (AEDT) From: "Ian Munsie" To: mpe Subject: [PATCH v2 2/4] CXL: Refactor cxl_load_segment and find_free_sste Date: Tue, 28 Oct 2014 14:25:28 +1100 Message-Id: <1414466730-15591-3-git-send-email-imunsie@au.ibm.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1414466730-15591-1-git-send-email-imunsie@au.ibm.com> References: <1414466730-15591-1-git-send-email-imunsie@au.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14102803-0013-0000-0000-0000006D2AC6 Cc: cbe-oss-dev , mikey , arnd , "Aneesh Kumar K.V" , greg , linux-kernel , linuxppc-dev , anton , imunsie , jk X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Ian Munsie This moves the segment table hash calculation from cxl_load_segment into find_free_sste since that is the only place it is actually used. Signed-off-by: Ian Munsie Reviewed-by: Aneesh Kumar K.V --- drivers/misc/cxl/fault.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/drivers/misc/cxl/fault.c b/drivers/misc/cxl/fault.c index d0e97fd..cb4f323 100644 --- a/drivers/misc/cxl/fault.c +++ b/drivers/misc/cxl/fault.c @@ -21,20 +21,30 @@ #include "cxl.h" -static struct cxl_sste* find_free_sste(struct cxl_sste *primary_group, - unsigned int *lru) +/* This finds a free SSTE for the given SLB */ +static struct cxl_sste* find_free_sste(struct cxl_context *ctx, + struct copro_slb *slb) { + struct cxl_sste *primary, *sste; + unsigned int mask = (ctx->sst_size >> 7) - 1; /* SSTP0[SegTableSize] */ unsigned int entry; - struct cxl_sste *sste, *group = primary_group; + unsigned int hash; + + if (slb->vsid & SLB_VSID_B_1T) + hash = (slb->esid >> SID_SHIFT_1T) & mask; + else /* 256M */ + hash = (slb->esid >> SID_SHIFT) & mask; - for (entry = 0; entry < 8; entry++) { - sste = group + entry; + primary = ctx->sstp + (hash << 3); + + for (entry = 0, sste = primary; entry < 8; entry++, sste++) { if (!(be64_to_cpu(sste->esid_data) & SLB_ESID_V)) return sste; } + /* Nothing free, select an entry to cast out */ - sste = primary_group + *lru; - *lru = (*lru + 1) & 0x7; + sste = primary + ctx->sst_lru; + ctx->sst_lru = (ctx->sst_lru + 1) & 0x7; return sste; } @@ -42,19 +52,11 @@ static struct cxl_sste* find_free_sste(struct cxl_sste *primary_group, static void cxl_load_segment(struct cxl_context *ctx, struct copro_slb *slb) { /* mask is the group index, we search primary and secondary here. */ - unsigned int mask = (ctx->sst_size >> 7)-1; /* SSTP0[SegTableSize] */ struct cxl_sste *sste; - unsigned int hash; unsigned long flags; - - if (slb->vsid & SLB_VSID_B_1T) - hash = (slb->esid >> SID_SHIFT_1T) & mask; - else /* 256M */ - hash = (slb->esid >> SID_SHIFT) & mask; - spin_lock_irqsave(&ctx->sste_lock, flags); - sste = find_free_sste(ctx->sstp + (hash << 3), &ctx->sst_lru); + sste = find_free_sste(ctx, slb); pr_devel("CXL Populating SST[%li]: %#llx %#llx\n", sste - ctx->sstp, slb->vsid, slb->esid);