Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp189066imm; Mon, 21 May 2018 04:33:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoXT/LNysa+y5vYCbDG983Edc2GMCVx8mJ0iCVNSpXDHOA941AXq+b3CuvWLJbHWx7cwZ04 X-Received: by 2002:a62:965c:: with SMTP id c89-v6mr19732299pfe.37.1526902429414; Mon, 21 May 2018 04:33:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526902429; cv=none; d=google.com; s=arc-20160816; b=YdIkMoxQ223TxVCKenR95HY68vvNgXy6MxDHPZA1CtIDMrF2R1+0xi8vpSSfFq+d1Y Pxi9GZnheHm2IuvM+v0wMfBu5Wtnp8ggPrv9aohqQkjQwWtbYizQYHj/AsT9XFfN8iVY O7jt3DnDAp65u2B4gMffXT14H2/0RJ2PoOEArIezdKZyJZBeMHGk90wn7wSt9KjDkdKO w+XIY86NQgVCqyLBLWO+6QX3lzYnbmHrrWWN7LwuuHP/Z8Xc6eHa/Ub96yy8jqnVs5fY dd3IFBUoX+NIId0ATuLcIUGjQzWEJqbXGqByZDc5G9kPlLYxSM584jFKI8/E6aKgxEcy 5mjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=MIc25OFHAcFp641OgJ7BTXRVKtJIwZbXwBbmmMZ/sdI=; b=tYcSsziE+3kf/M0gBGlcwboMi0P+UbRgh6fM9A5vsD6zDl0u+tCjbhWGMJAe61zBKN /sxf42C//1HM2zpXbLJaq31Ce3QLUX8F9hPVyVI+gvbX1frg0vfmbI4HM1tefZO50oLt jVtXF6eh2QxQxtYt+J1EaV9xVAQq/y3yXCjgDPo6m5JC7N84bqc7nHWyRda6W1d9bINF 66XQ6YzXGRPQypvZCB/eqUQe93vxXERQmsDXo7kfLqeiuzxYQb5WB6/q6hf1ZhL0nJ7n d06gcuMSLv1EC8k1VGlP9/LVFncVsunTiHQ9n+4zKOp5wIZSXKuzMGlbJ5Tnv9xaM4Ro kTrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RD8wZt4G; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g2-v6si14389808pli.48.2018.05.21.04.33.35; Mon, 21 May 2018 04:33: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=@kernel.org header.s=default header.b=RD8wZt4G; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751895AbeEULdW (ORCPT + 99 others); Mon, 21 May 2018 07:33:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:43392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750773AbeEULdT (ORCPT ); Mon, 21 May 2018 07:33:19 -0400 Received: from localhost (unknown [171.76.76.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2A3E82086A; Mon, 21 May 2018 11:33:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526902399; bh=rrpXTbeUUAvNwI+rwkEjYIJnYP9Tgt5hVpt1OXOo4pg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RD8wZt4G+xxuMun7zbTU4rpf08fbAd4bOMd/Eocn1PpVqaiCzhjQ6hkrw93d7hhmF 9IYTMHIEZfS+GNA3W0L8CUoMEFYcohFq0R1r1pGm9qo/ZWh4Wg/ey/C95afJRGNbM8 TbKCdrQcny0yaMXYa6/tXZb1pj0FgGtyS236X/I0= Date: Mon, 21 May 2018 17:03:14 +0530 From: Vinod To: Srinivas Kandagatla Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org, kramasub@codeaurora.org, sdharia@quicinc.com, girishm@quicinc.com, linux-kernel@vger.kernel.org, mark.rutland@arm.com, bgoswami@codeaurora.org, devicetree@vger.kernel.org, broonie@kernel.org, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org Subject: Re: [PATCH 2/2] slimbus: ngd: Add qcom SLIMBus NGD driver Message-ID: <20180521113314.GC14654@vkoul-mobl> References: <20180516165118.16551-1-srinivas.kandagatla@linaro.org> <20180516165118.16551-3-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180516165118.16551-3-srinivas.kandagatla@linaro.org> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16-05-18, 17:51, Srinivas Kandagatla wrote: > This patch adds suppor to Qualcomm SLIMBus Non-Generic Device (NGD) /s/suppor/support > +/* NGD (Non-ported Generic Device) registers */ > +#define NGD_CFG 0x0 > +#define NGD_CFG_ENABLE BIT(0) > +#define NGD_CFG_RX_MSGQ_EN BIT(1) > +#define NGD_CFG_TX_MSGQ_EN BIT(2) > +#define NGD_STATUS 0x4 > +#define NGD_LADDR BIT(1) > +#define NGD_RX_MSGQ_CFG 0x8 > +#define NGD_INT_EN 0x10 > +#define NGD_INT_RECFG_DONE BIT(24) > +#define NGD_INT_TX_NACKED_2 BIT(25) > +#define NGD_INT_MSG_BUF_CONTE BIT(26) > +#define NGD_INT_MSG_TX_INVAL BIT(27) > +#define NGD_INT_IE_VE_CHG BIT(28) > +#define NGD_INT_DEV_ERR BIT(29) > +#define NGD_INT_RX_MSG_RCVD BIT(30) > +#define NGD_INT_TX_MSG_SENT BIT(31) > +#define NGD_INT_STAT 0x14 > +#define NGD_INT_CLR 0x18 > +#define DEF_NGD_INT_MASK (NGD_INT_TX_NACKED_2 | NGD_INT_MSG_BUF_CONTE | \ > + NGD_INT_MSG_TX_INVAL | NGD_INT_IE_VE_CHG | \ > + NGD_INT_DEV_ERR | NGD_INT_TX_MSG_SENT | \ > + NGD_INT_RX_MSG_RCVD) > + > +/* Slimbus QMI service */ > +#define SLIMBUS_QMI_SVC_ID 0x0301 > +#define SLIMBUS_QMI_SVC_V1 1 > +#define SLIMBUS_QMI_INS_ID 0 > +#define SLIMBUS_QMI_SELECT_INSTANCE_REQ_V01 0x0020 > +#define SLIMBUS_QMI_SELECT_INSTANCE_RESP_V01 0x0020 > +#define SLIMBUS_QMI_POWER_REQ_V01 0x0021 > +#define SLIMBUS_QMI_POWER_RESP_V01 0x0021 > +#define SLIMBUS_QMI_CHECK_FRAMER_STATUS_REQ 0x0022 > +#define SLIMBUS_QMI_CHECK_FRAMER_STATUS_RESP 0x0022 > +#define SLIMBUS_QMI_POWER_REQ_MAX_MSG_LEN 14 > +#define SLIMBUS_QMI_POWER_RESP_MAX_MSG_LEN 7 > +#define SLIMBUS_QMI_SELECT_INSTANCE_REQ_MAX_MSG_LEN 14 > +#define SLIMBUS_QMI_SELECT_INSTANCE_RESP_MAX_MSG_LEN 7 > +#define SLIMBUS_QMI_CHECK_FRAMER_STAT_RESP_MAX_MSG_LEN 7 > +/* QMI response timeout of 500ms */ > +#define SLIMBUS_QMI_RESP_TOUT 1000 Tabs or spaces, take your pick and use one, not both... > +static void qcom_slim_qmi_power_resp_cb(struct qmi_handle *handle, > + struct sockaddr_qrtr *sq, > + struct qmi_txn *txn, const void *data) > +{ > + struct slimbus_power_resp_msg_v01 *resp; > + > + resp = (struct slimbus_power_resp_msg_v01 *)data; you dont need cast away from void > + if (resp->resp.result != QMI_RESULT_SUCCESS_V01) > + pr_err("%s: QMI power request failed 0x%x\n", __func__, > + resp->resp.result); cant we use dev_err? > +static int qcom_slim_qmi_send_power_request(struct qcom_slim_ngd_ctrl *ctrl, > + struct slimbus_power_req_msg_v01 *req) > +{ > + struct slimbus_power_resp_msg_v01 resp = { { 0, 0 } }; > + struct qmi_txn txn; > + int rc; > + > + rc = qmi_txn_init(ctrl->qmi.handle, &txn, > + slimbus_power_resp_msg_v01_ei, &resp); > + > + rc = qmi_send_request(ctrl->qmi.handle, NULL, &txn, > + SLIMBUS_QMI_POWER_REQ_V01, > + SLIMBUS_QMI_POWER_REQ_MAX_MSG_LEN, > + slimbus_power_req_msg_v01_ei, req); > + if (rc < 0) { > + dev_err(ctrl->dev, "%s: QMI send req fail %d\n", __func__, rc); > + qmi_txn_cancel(&txn); > + } > + > + if (rc < 0) > + return rc; why not add this is prev error check? > +static int qcom_slim_qmi_init(struct qcom_slim_ngd_ctrl *ctrl, > + bool apps_is_master) > +{ > + int rc = 0; superfluous init > +static u32 *qcom_slim_ngd_tx_msg_get(struct qcom_slim_ngd_ctrl *ctrl, int len, > + struct completion *comp) > +{ > + struct qcom_slim_ngd_dma_desc *desc; > + unsigned long flags; > + > + spin_lock_irqsave(&ctrl->tx_buf_lock, flags); > + > + if ((ctrl->tx_tail + 1) % QCOM_SLIM_NGD_DESC_NUM == ctrl->tx_head) { > + spin_unlock_irqrestore(&ctrl->tx_buf_lock, flags); > + return NULL; > + } > + desc = &ctrl->txdesc[ctrl->tx_tail]; > + desc->base = (u32 *)((u8 *)ctrl->tx_base + > + (ctrl->tx_tail * SLIM_MSGQ_BUF_LEN)); too many casts > +static int qcom_slim_ngd_post_rx_msgq(struct qcom_slim_ngd_ctrl *ctrl) > +{ > + struct qcom_slim_ngd_dma_desc *desc; > + struct dma_slave_config conf = { > + .direction = DMA_DEV_TO_MEM, > + }; > + int ret, i; > + > + ret = dmaengine_slave_config(ctrl->dma_rx_channel, &conf); so you are only setting direction for conf, not any other parameters? If not why bother setting direction > + if (ret) > + dev_err(ctrl->dev, "Error Configuring rx dma\n"); > + > + for (i = 0; i < QCOM_SLIM_NGD_DESC_NUM; i++) { > + desc = &ctrl->rx_desc[i]; > + desc->phys = ctrl->rx_phys_base + i * SLIM_MSGQ_BUF_LEN; > + desc->ctrl = ctrl; > + desc->base = ctrl->rx_base + i * SLIM_MSGQ_BUF_LEN; > + desc->desc = dmaengine_prep_slave_single(ctrl->dma_rx_channel, > + desc->phys, SLIM_MSGQ_BUF_LEN, > + DMA_DEV_TO_MEM, > + DMA_PREP_INTERRUPT); why issue multiple slave_single to dmaengine, you can bundle them and issue dmaengine_prep_slave_sg().. > +static int qcom_slim_ngd_qmi_svc_event_init(struct qcom_slim_ngd_qmi *qmi) > +{ > + int ret = 0; superfluous init here too > +static int qcom_slim_ngd_runtime_idle(struct device *dev) > +{ > + struct qcom_slim_ngd_ctrl *ctrl = dev_get_drvdata(dev); > + > + if (ctrl->state == QCOM_SLIM_NGD_CTRL_AWAKE) > + ctrl->state = QCOM_SLIM_NGD_CTRL_IDLE; > + pm_request_autosuspend(dev); > + return -EAGAIN; > +} > + > + double empty lines, here -- ~Vinod