Received: by 10.192.165.156 with SMTP id m28csp7051imm; Thu, 12 Apr 2018 15:22:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx48VPlL/uODAQ63+kMAwAmqyMlAuC7ag55r24XiqEgmhasNNoFpjjV7VBwe1HZxZoyr0i5+z X-Received: by 2002:a17:902:4225:: with SMTP id g34-v6mr2783692pld.297.1523571766903; Thu, 12 Apr 2018 15:22:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523571766; cv=none; d=google.com; s=arc-20160816; b=p2HUog7Gei3lnfOW71m2K0p9Gzn6fsMoVnUMnvz/Hwr8BhpEU1jgE/Gzk1irkpi4IV fmGCGBTgxIjJxe2M9nTXjGF1Wit/0nC5u8eTpoJ9enAi3yHS6wkOIbqJtcz++niIQoe8 ycqADohLnpTTSozHc7vHoIseR/GHBUPzyH53Oqk7uDGVUoBfa5dEY4zkEUR+qYVZpkHN j7KR7n98xOUiJqBUFwkOT9MgHjrpGtHFj4mbfC4yNpCJ7H0yAmGQIsxqGVm8urRewTR+ PIRT1k00Scv26kLq88XBzPtG0L3RpmUOxe2lUPdaocnDYaIQoip/EJAbXPfpeclB71Pb NeaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=dGW7jyjSvX5Dct98TUSR2pIKeaBMHMywwGZmfPokgNw=; b=YWajUcy2EEKj0+xjnhZJu1nBdBEZn36cpx1RoxT3nDXqaChyKlN7LBrsYwOoX8e8Hq sGn5+kN/iRA7JmMI7EsI+vToTOa82q+Cx8uz362laTuFLDTeT8HBrpUQVXsVAPbIYbbd iZF3IUdfdFSPavLdWEd/blcRbG9XDhTe1b8yCIVtHVj2Wl62IOJjYVz3jWYV3WANv9mR LciSKdu429b7IMrSF5aEFw1uNdk9hdMhijQBOpeL25vKhUuow+nhwr7qKVDjVPGwoMbb Jp78FN3do3XuOr3ge84IdQ+WStzVsXNmcU/mL5OTuKgjg+WuWRfHoyqIcK4YV/c87IJa r9YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kOTVJydJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w8-v6si3263461plp.521.2018.04.12.15.22.18; Thu, 12 Apr 2018 15:22:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kOTVJydJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753691AbeDLWEI (ORCPT + 99 others); Thu, 12 Apr 2018 18:04:08 -0400 Received: from mail-ot0-f193.google.com ([74.125.82.193]:33429 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752464AbeDLWEH (ORCPT ); Thu, 12 Apr 2018 18:04:07 -0400 Received: by mail-ot0-f193.google.com with SMTP id 23-v6so7760388otj.0 for ; Thu, 12 Apr 2018 15:04:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dGW7jyjSvX5Dct98TUSR2pIKeaBMHMywwGZmfPokgNw=; b=kOTVJydJiGq1VpzAy+8WUYrGm0wPQU9WeB5vnXXoUP6xq9omI9ElbIiwfviuXwO/rT AXOyNx/T4r5aOlxCxGk7t5cCHQVKVn+ei8XHC7FrDaScocC4QGYKFYeQ4J+7hvl3gAvm KHCp+2jL6Nsp+skidyHy6npdhEHfrM0HGB/eI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dGW7jyjSvX5Dct98TUSR2pIKeaBMHMywwGZmfPokgNw=; b=JNnTvllNOUsK95TREQDFVhAr517od4IcftJzTDpn5Xnc5wpbqDa1Zti4GRWaJ4eGNu wEcHyQ6ml1c+Av7HyPvAbYMkxXKNlTSljT0A3LBuwH5up2kqFfL0lVXm7f2wRhfE2p1O 5f0c1SI+8GF0Wvqmr6Dz0zcUKUvKL/UeOkRsbQ2Db3u8S0OBj0p/2sKtEX8/5jSAsS/F pYf7pf5VvUHWuBK1ha3ErEKEFKFV+gRkBseqKq4mBYCaaM1LHegsv4UZ1K7lHyobSbl+ rWTzL5q1R+EAdQDHbeT9LDlVIf8nymKZ4fEfg4zzk4SOGgQntlBvx9GzsK4CvGWJVRgo i+Sw== X-Gm-Message-State: ALQs6tADraANfHe/zSnwFkbmXWtBnW5lxFTgEM/bSTyC5IQOTKwrGBUw vRPmORvOcsivrvWVZbGQpoDK6n+/sf8= X-Received: by 2002:a9d:c86:: with SMTP id b6-v6mr1987401otb.91.1523570646433; Thu, 12 Apr 2018 15:04:06 -0700 (PDT) Received: from mail-oi0-f48.google.com (mail-oi0-f48.google.com. [209.85.218.48]) by smtp.gmail.com with ESMTPSA id d40-v6sm2824356otf.20.2018.04.12.15.03.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Apr 2018 15:03:33 -0700 (PDT) Received: by mail-oi0-f48.google.com with SMTP id 71-v6so6633185oie.12 for ; Thu, 12 Apr 2018 15:03:33 -0700 (PDT) X-Received: by 2002:aca:b3d6:: with SMTP id c205-v6mr6390169oif.266.1523570612652; Thu, 12 Apr 2018 15:03:32 -0700 (PDT) MIME-Version: 1.0 References: <1523390893-10904-1-git-send-email-rishabhb@codeaurora.org> <1523390893-10904-3-git-send-email-rishabhb@codeaurora.org> In-Reply-To: <1523390893-10904-3-git-send-email-rishabhb@codeaurora.org> From: Evan Green Date: Thu, 12 Apr 2018 22:02:57 +0000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 2/2] drivers: soc: Add LLCC driver To: rishabhb@codeaurora.org Cc: linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm@lists.infradead.org, linux-kernel@vger.kernel.org, tsoni@codeaurora.org, kyan@codeaurora.org, ckadabi@codeaurora.org, stanimir.varbanov@linaro.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Rishabh, On Tue, Apr 10, 2018 at 1:09 PM Rishabh Bhatnagar wrote: > LLCC (Last Level Cache Controller) provides additional cache memory > in the system. LLCC is partitioned into multiple slices and each > slice gets its own priority, size, ID and other config parameters. > LLCC driver programs these parameters for each slice. Clients that > are assigned to use LLCC need to get information such size & ID of the > slice they get and activate or deactivate the slice as needed. LLCC driver > provides API for the clients to perform these operations. > Signed-off-by: Channagoud Kadabi > Signed-off-by: Rishabh Bhatnagar > --- > drivers/soc/qcom/Kconfig | 17 ++ > drivers/soc/qcom/Makefile | 2 + > drivers/soc/qcom/llcc-sdm845.c | 110 ++++++++++ > drivers/soc/qcom/llcc-slice.c | 404 +++++++++++++++++++++++++++++++++++++ > include/linux/soc/qcom/llcc-qcom.h | 168 +++++++++++++++ > 5 files changed, 701 insertions(+) > create mode 100644 drivers/soc/qcom/llcc-sdm845.c > create mode 100644 drivers/soc/qcom/llcc-slice.c > create mode 100644 include/linux/soc/qcom/llcc-qcom.h [...] > diff --git a/drivers/soc/qcom/llcc-sdm845.c b/drivers/soc/qcom/llcc-sdm845.c > new file mode 100644 > index 0000000..619b226 > --- /dev/null > +++ b/drivers/soc/qcom/llcc-sdm845.c > @@ -0,0 +1,110 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. > + * > + */ > + > +#include > +#include > +#include > +#include > +#include > + > +/* > + * SCT(System Cache Table) entry contains of the following parameters contains the following members: > + * name: Name of the client's use case for which the llcc slice is used > + * uid: Unique id for the client's use case s/uid/usecase_id/ > + * slice_id: llcc slice id for each client > + * max_cap: The maximum capacity of the cache slice provided in KB > + * priority: Priority of the client used to select victim line for replacement > + * fixed_size: Determine if the slice has a fixed capacity "Boolean indicating if the slice has a fixed capacity" might be better > diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c > new file mode 100644 > index 0000000..67a81b0 > --- /dev/null > +++ b/drivers/soc/qcom/llcc-slice.c ... > +static int llcc_update_act_ctrl(struct llcc_drv_data *drv, u32 sid, > + u32 act_ctrl_reg_val, u32 status) > +{ > + u32 act_ctrl_reg; > + u32 status_reg; > + u32 slice_status; > + int ret = 0; > + > + act_ctrl_reg = drv->bcast_off + LLCC_TRP_ACT_CTRLn(sid); > + status_reg = drv->bcast_off + LLCC_TRP_STATUSn(sid); > + > + /*Set the ACTIVE trigger*/ Add spaces around /* */ > + act_ctrl_reg_val |= ACT_CTRL_ACT_TRIG; > + ret = regmap_write(drv->regmap, act_ctrl_reg, act_ctrl_reg_val); > + if (ret) > + return ret; > + > + /* Clear the ACTIVE trigger */ > + act_ctrl_reg_val &= ~ACT_CTRL_ACT_TRIG; > + ret = regmap_write(drv->regmap, act_ctrl_reg, act_ctrl_reg_val); > + if (ret) > + return ret; > + > + ret = regmap_read_poll_timeout(drv->regmap, status_reg, slice_status, > + !(slice_status & status), 0, LLCC_STATUS_READ_DELAY); > + return ret; > +} > + > +/** > + * llcc_slice_activate - Activate the llcc slice > + * @desc: Pointer to llcc slice descriptor > + * > + * A value zero will be returned on success and a negative errno will a value of zero > + * be returned in error cases > + */ > +int llcc_slice_activate(struct llcc_slice_desc *desc) > +{ > + int ret; > + u32 act_ctrl_val; > + struct llcc_drv_data *drv; > + > + if (desc == NULL) > + return -EINVAL; I think we can remove this check, right? > + > + drv = dev_get_drvdata(desc->dev); > + if (!drv) > + return -EINVAL; > + > + mutex_lock(&drv->lock); > + if (test_bit(desc->slice_id, drv->bitmap)) { > + mutex_unlock(&drv->lock); > + return 0; > + } > + > + act_ctrl_val = ACT_CTRL_OPCODE_ACTIVATE << ACT_CTRL_OPCODE_SHIFT; > + > + ret = llcc_update_act_ctrl(drv, desc->slice_id, act_ctrl_val, > + DEACTIVATE); > + > + __set_bit(desc->slice_id, drv->bitmap); > + mutex_unlock(&drv->lock); > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(llcc_slice_activate); > + > +/** > + * llcc_slice_deactivate - Deactivate the llcc slice > + * @desc: Pointer to llcc slice descriptor > + * > + * A value zero will be returned on success and a negative errno will > + * be returned in error cases > + */ > +int llcc_slice_deactivate(struct llcc_slice_desc *desc) > +{ > + u32 act_ctrl_val; > + int ret; > + struct llcc_drv_data *drv; > + > + if (desc == NULL) > + return -EINVAL; > + > + drv = dev_get_drvdata(desc->dev); > + if (!drv) > + return -EINVAL; > + > + mutex_lock(&drv->lock); > + if (!test_bit(desc->slice_id, drv->bitmap)) { > + mutex_unlock(&drv->lock); > + return 0; > + } > + act_ctrl_val = ACT_CTRL_OPCODE_DEACTIVATE << ACT_CTRL_OPCODE_SHIFT; > + > + ret = llcc_update_act_ctrl(drv, desc->slice_id, act_ctrl_val, > + ACTIVATE); > + > + __clear_bit(desc->slice_id, drv->bitmap); > + mutex_unlock(&drv->lock); > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(llcc_slice_deactivate); > + > +/** > + * llcc_get_slice_id - return the slice id > + * @desc: Pointer to llcc slice descriptor > + * > + * A positive value will be returned on success and a negative errno will > + * be returned on error > + */ > +int llcc_get_slice_id(struct llcc_slice_desc *desc) > +{ > + if (!desc) > + return -EINVAL; Can we remove this check too? > + > + return desc->slice_id; > +} > +EXPORT_SYMBOL_GPL(llcc_get_slice_id); > + > +/** > + * llcc_get_slice_size - return the slice id > + * @desc: Pointer to llcc slice descriptor > + * > + * A positive value will be returned on success and zero will returned on > + * error > + */ > +size_t llcc_get_slice_size(struct llcc_slice_desc *desc) > +{ > + if (!desc) > + return 0; And this one? -Evan