Received: by 10.192.165.156 with SMTP id m28csp1238091imm; Fri, 13 Apr 2018 16:10:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx49FNhi6wUOLwVBt03GbKYGFBaU4bTJJQ3dX3qiChmyzURXNAzU72ZDmKtzjkP0SpU4HMbdf X-Received: by 10.99.65.6 with SMTP id o6mr5574762pga.57.1523661049438; Fri, 13 Apr 2018 16:10:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523661049; cv=none; d=google.com; s=arc-20160816; b=YPvW8WObznNZ1sRMPkaX9Inu5bmH4ZZb1ows/IyRGdYVIJSCpdz+kL7Ynk96TOyex9 wDf4GeKOTHBM2WunGAsZVQbA5hWrQkiLu4zkjB+XjqSwTyVdxSCKeyCpNwhZZCPmXdTR xS153SIx2slWFS4IYQnBzp3E07dDhxLpiTu2cDNxlFdi9b/wS6oz7ITtLfyWjDr/F7rm YFOt8Mk5BtcbwlKb3lq4h8VI4836H3ev6n/Z/2aiYM9eBEOw6sYa0GNovaoa+DNkI0Bn 34vFi/YrS5EuEGPP6qWI+94fzg3MZz80neDolg+uXzLqFVWhzbrAk5kTdGTFr4rvMNek uODg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=Dlhv1kgLcN0963BnxrAoW/ysxo4s+qR37tKkoLFoVFM=; b=ZCrybdZXKcIqZzk6Koy2ham9N2BdLKixk2wJ+Dy4ZFk5LfjR2pVbf8uhKRCSQGWLl+ jtCe3IrnT4afj++lb7f9ECZx/JD7vGDDn0F72pY6W6l7jiQ/BcturzjwPbA7tZdZQPA5 u4xNrJuaaFkS5uMQ26fH2SX1m5NySmOn575pbrCwNmKC5NMu1i8fYm4EJodGAcipeDWt htJyehF0qU8hpSYzTOzP6TRekPmGjLU1GW3hpaZg/cMp8W8j8kkE5JnqpjdvOF0uamWm O3Yv86VsHtbPXYknaGizzBqYQ5aBn5A6sOC2MldbxOhC5ay8OuYACbQraVg+8m5Ap78N TaIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=bbSdKQm/; dkim=pass header.i=@codeaurora.org header.s=default header.b=NCvOgFbn; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b34-v6si6542282pld.249.2018.04.13.16.10.24; Fri, 13 Apr 2018 16:10:49 -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=@codeaurora.org header.s=default header.b=bbSdKQm/; dkim=pass header.i=@codeaurora.org header.s=default header.b=NCvOgFbn; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752410AbeDMXIe (ORCPT + 99 others); Fri, 13 Apr 2018 19:08:34 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:33942 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751855AbeDMXIc (ORCPT ); Fri, 13 Apr 2018 19:08:32 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 873766076A; Fri, 13 Apr 2018 23:08:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1523660911; bh=G1ZVvDSdaiOUE3huDu+k0KuKpFKrSDAdli1QewsGqNQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=bbSdKQm/3gXsBFLouWHGzo6yCGZqVuXfaTxDCAiemozazXzgNwT+NNTzAKYokGydY w1Ejv3S4Yv9qQ3p9YLuvB1+TL/NI26lpCm9NIeRa32uHZeHiclbV3g5Q4ErpAGUyzS bNvgAOPl/fp0KAfMyuERMCBIrb66snSE0wCeJ484= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 695F06076A; Fri, 13 Apr 2018 23:08:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1523660910; bh=G1ZVvDSdaiOUE3huDu+k0KuKpFKrSDAdli1QewsGqNQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NCvOgFbnQHgyGjjMWubjXvxshrtgifToIZo2sVyHTOQ6npfCfyvygYxiL+7rGo+G8 R3yGClFws/5Dj2lhKxc6sia+Kpj9WzHvBzLbC4FfB6lO8y04M9QT0IVw9i7dOTUeus BWj7Mrsqd91FQ5RfPaVMWX6CiGmll3xpGZqGfjMQ= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 13 Apr 2018 16:08:30 -0700 From: rishabhb@codeaurora.org To: Evan Green 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 Subject: Re: [PATCH v4 2/2] drivers: soc: Add LLCC driver In-Reply-To: References: <1523390893-10904-1-git-send-email-rishabhb@codeaurora.org> <1523390893-10904-3-git-send-email-rishabhb@codeaurora.org> Message-ID: X-Sender: rishabhb@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-04-12 15:02, Evan Green wrote: > 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? > We need this check and the following one to protect against the null pointer access which might happen if client doesn't get the descriptor before accessing size and slice_id. >> + >> + 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