dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sibi S <sibis-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
To: architt-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
	robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 2/5] drm/msm/dsi: add implementation for helper functions
Date: Tue, 13 Mar 2018 12:27:44 +0530	[thread overview]
Message-ID: <8cb1c036-d4b9-2994-685f-883088130f74@codeaurora.org> (raw)
In-Reply-To: <20180312151352.GA28808-9PYrDHPZ2Orvke4nUoYGnHL1okKdlPRT@public.gmane.org>

Hi Jordan,
Thanks for the review. Will incorporate the suggested changes in v2.

On 03/12/2018 08:43 PM, Jordan Crouse wrote:
> On Mon, Mar 12, 2018 at 06:53:11PM +0530, Sibi S wrote:
>> Add dsi host helper function implementation for DSI v2
>> and DSI 6G 1.x controllers
>>
>> Signed-off-by: Sibi S <sibis@codeaurora.org>
>> ---
>>   drivers/gpu/drm/msm/dsi/dsi.h      |  15 +++
>>   drivers/gpu/drm/msm/dsi/dsi_cfg.c  |  44 +++++--
>>   drivers/gpu/drm/msm/dsi/dsi_host.c | 250 ++++++++++++++++++++++++++++++++++++-
>>   3 files changed, 298 insertions(+), 11 deletions(-)
> 
> <snip>
>>   static int dsi_calc_clk_rate(struct msm_dsi_host *msm_host)
>>   {
>>   	struct drm_display_mode *mode = msm_host->mode;
>> @@ -1008,6 +1161,59 @@ static void dsi_wait4video_eng_busy(struct msm_dsi_host *msm_host)
>>   	}
>>   }
>>   
>> +int dsi_tx_buf_alloc_6g(struct msm_dsi_host *msm_host, int size)
>> +{
>> +	struct drm_device *dev = msm_host->dev;
>> +	struct msm_drm_private *priv = dev->dev_private;
>> +	int ret;
>> +	uint64_t iova;
>> +
>> +	msm_host->tx_gem_obj = msm_gem_new(dev, size, MSM_BO_UNCACHED);
>> +	if (IS_ERR(msm_host->tx_gem_obj)) {
>> +		ret = PTR_ERR(msm_host->tx_gem_obj);
>> +		pr_err("%s: failed to allocate gem, %d\n",
>> +			__func__, ret);
>> +		msm_host->tx_gem_obj = NULL;
>> +		return ret;
>> +	}
>> +
>> +	ret = msm_gem_get_iova(msm_host->tx_gem_obj,
>> +			priv->kms->aspace, &iova);
>> +	mutex_unlock(&dev->struct_mutex);
>> +	if (ret) {
>> +		pr_err("%s: failed to get iova, %d\n", __func__, ret);
>> +		return ret;
>> +	}
>> +
>> +	if (iova & 0x07) {
>> +		pr_err("%s: buf NOT 8 bytes aligned\n", __func__);
>> +		return -EINVAL;
>> +	}
> 
> This is impossible - new allocations will always be page aligned.
> 

Its always good to review and remove older code paths :).
Sure will remove this check.

>> +	msm_host->tx_size = msm_host->tx_gem_obj->size;
>> +
>> +	return 0;
>> +}
>> +
>> +int dsi_tx_buf_alloc_v2(struct msm_dsi_host *msm_host, int size)
>> +{
>> +	struct drm_device *dev = msm_host->dev;
>> +	int ret;
>> +
>> +	msm_host->tx_buf = dma_alloc_coherent(dev->dev, size,
>> +					&msm_host->tx_buf_paddr, GFP_KERNEL);
>> +	if (!msm_host->tx_buf) {
>> +		ret = -ENOMEM;
>> +		pr_err("%s: failed to allocate tx buf, %d\n",
>> +			__func__, ret);
> 
> You don't need to print ret here, it isn't a mystery what it is.  In fact, you
> probably don't need to print anything here at all because dma_alloc_coherent
> should be pretty noisy when it fails.
> 
>> +		return ret;
> 
> This can just be return -ENOMEM and you can lose 'ret'.
> 

yep makes sense, will replace it.

>> +	}
>> +
>> +	msm_host->tx_size = size;
>> +
>> +	return 0;
>> +}
>> +
>>   /* dsi_cmd */
>>   static int dsi_tx_buf_alloc(struct msm_dsi_host *msm_host, int size)
>>   {
>> @@ -1072,6 +1278,21 @@ static void dsi_tx_buf_free(struct msm_dsi_host *msm_host)
>>   			msm_host->tx_buf_paddr);
>>   }
>>   
>> +void *dsi_tx_buf_get_6g(struct msm_dsi_host *msm_host)
>> +{
>> +	return msm_gem_get_vaddr(msm_host->tx_gem_obj);
>> +}
>> +
>> +void *dsi_tx_buf_get_v2(struct msm_dsi_host *msm_host)
>> +{
>> +	return msm_host->tx_buf;
>> +}
>> +
>> +void dsi_tx_buf_put_6g(struct msm_dsi_host *msm_host)
>> +{
>> +	msm_gem_put_vaddr(msm_host->tx_gem_obj);
>> +}
>> +
>>   /*
>>    * prepare cmd buffer to be txed
>>    */
>> @@ -1173,6 +1394,31 @@ static int dsi_long_read_resp(u8 *buf, const struct mipi_dsi_msg *msg)
>>   	return msg->rx_len;
>>   }
>>   
>> +int dsi_dma_base_get_6g(struct msm_dsi_host *msm_host, uint64_t *dma_base)
>> +{
>> +	struct drm_device *dev = msm_host->dev;
>> +	struct msm_drm_private *priv = dev->dev_private;
>> +	uint64_t **iova;
>> +	int ret;
>> +
>> +	if (!dma_base)
>> +		return -EINVAL;
>> +
>> +	iova = &dma_base;
> 
> This is a convoluted way of passing in the pointer and I doubt even the compiler
> can see through it.
> 
>> +	ret = msm_gem_get_iova(msm_host->tx_gem_obj,
>> +				priv->kms->aspace, *iova);
> 
> ret = msm_gem_get_iova(msm_host->tx_gem_obj, priv->kms->aspace, dma_base);
> 
> Easy, safe effective
> 
>> +	return ret;
> 
> If you put a return on the front of the msm_gem_get_iova you can eliminate the
> need for 'ret'.
> 

ok will do just that.

> Jordan
> 

-- 
Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc, is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno

  parent reply	other threads:[~2018-03-13  6:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-12 13:23 [PATCH 0/5] Cleanup excessive DSI host controller version checks Sibi S
2018-03-12 13:23 ` [PATCH 1/5] drm/msm/dsi: add dsi host helper functions support Sibi S
2018-03-12 13:23 ` [PATCH 2/5] drm/msm/dsi: add implementation for helper functions Sibi S
     [not found]   ` <1520860994-23334-3-git-send-email-sibis-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-03-12 15:13     ` Jordan Crouse
     [not found]       ` <20180312151352.GA28808-9PYrDHPZ2Orvke4nUoYGnHL1okKdlPRT@public.gmane.org>
2018-03-13  6:57         ` Sibi S [this message]
2018-03-13  5:19     ` Archit Taneja
     [not found]       ` <1091cdf6-7322-17ad-f156-c65cfe7df87a-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-03-13  7:01         ` Sibi S
2018-03-12 13:23 ` [PATCH 3/5] drm/msm/dsi: replace version checks with " Sibi S
     [not found]   ` <1520860994-23334-4-git-send-email-sibis-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-03-13  5:20     ` Archit Taneja
2018-03-12 13:23 ` [PATCH 4/5] drm/msm/dsi: implement 6G v2.0+ DSI command broadcast Sibi S
     [not found]   ` <1520860994-23334-5-git-send-email-sibis-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-03-13  5:30     ` Archit Taneja
2018-03-12 13:23 ` [PATCH 5/5] drm/msm/dsi: replace version checks for commmand broadcast Sibi S

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8cb1c036-d4b9-2994-685f-883088130f74@codeaurora.org \
    --to=sibis-sgv2jx0feol9jmxxk+q4oq@public.gmane.org \
    --cc=architt-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox