linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Zhang <nvmarkzhang@gmail.com>
To: Terje Bergstrom <tbergstrom@nvidia.com>
Cc: thierry.reding@avionic-design.de, linux-tegra@vger.kernel.org,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC,v2,3/8] video: tegra: host: Add channel and client support
Date: Thu, 29 Nov 2012 18:01:03 +0800	[thread overview]
Message-ID: <50B7325F.20002@gmail.com> (raw)
In-Reply-To: <1353935954-13763-4-git-send-email-tbergstrom@nvidia.com>

On 11/26/2012 09:19 PM, Terje Bergström <tbergstrom@nvidia.com> wrote:
> Add support for host1x client modules, and host1x channels to submit
> work to the clients. The work is submitted in dmabuf buffers, so add
> support for dmabuf memory management, too.
[...]
> diff --git a/drivers/video/tegra/host/bus_client.c b/drivers/video/tegra/host/bus_client.c
[...]
> +int nvhost_client_device_init(struct platform_device *dev)
> +{
> +	int err;
> +	struct nvhost_master *nvhost_master = nvhost_get_host(dev);
> +	struct nvhost_channel *ch;
> +	struct nvhost_device_data *pdata = platform_get_drvdata(dev);
> +
> +	ch = nvhost_alloc_channel(dev);
> +	if (ch == NULL)
> +		return -ENODEV;
> +
> +	/* store the pointer to this device for channel */
> +	ch->dev = dev;
> +
> +	err = nvhost_channel_init(ch, nvhost_master, pdata->index);
> +	if (err)
> +		goto fail;
> +
> +	err = nvhost_module_init(dev);
> +	if (err)
> +		goto fail;
> +
> +	err = nvhost_device_list_add(dev);
> +	if (err)
> +		goto fail;
> +
> +	dev_info(&dev->dev, "initialized\n");
> +
> +	return 0;
> +
> +fail:
> +	/* Add clean-up */

Yes, add "nvhost_module_deinit" here?

> +	nvhost_free_channel(ch);
> +	return err;
> +}
> +EXPORT_SYMBOL(nvhost_client_device_init);
> +
> +int nvhost_client_device_suspend(struct platform_device *dev)
> +{
> +	int ret = 0;
> +	struct nvhost_device_data *pdata = platform_get_drvdata(dev);
> +
> +	ret = nvhost_channel_suspend(pdata->channel);
> +	dev_info(&dev->dev, "suspend status: %d\n", ret);
> +	if (ret)
> +		return ret;
> +
> +	return ret;

Minor issue: just "return ret" is OK. That "if" doesn't make sense.

> +}
> +EXPORT_SYMBOL(nvhost_client_device_suspend);
> diff --git a/drivers/video/tegra/host/chip_support.c b/drivers/video/tegra/host/chip_support.c
> index 5a44147..8765c83 100644
> --- a/drivers/video/tegra/host/chip_support.c
> +++ b/drivers/video/tegra/host/chip_support.c
> @@ -25,7 +25,7 @@
>  #include "chip_support.h"
>  #include "host1x/host1x01.h"
>  
> -struct nvhost_chip_support *nvhost_chip_ops;
> +static struct nvhost_chip_support *nvhost_chip_ops;
>  

All right, already fixed here. Sorry, so just ignore what I said about
this in my reply to your patch 1.

[...]
> +
> +struct mem_handle *nvhost_dmabuf_get(u32 id, struct platform_device *dev)
> +{
> +	struct mem_handle *h;
> +	struct dma_buf *buf;
> +
> +	buf = dma_buf_get(to_dmabuf_fd(id));
> +	if (IS_ERR_OR_NULL(buf))
> +		return (struct mem_handle *)buf;
> +
> +	h = (struct mem_handle *)dma_buf_attach(buf, &dev->dev);
> +	if (IS_ERR_OR_NULL(h))
> +		dma_buf_put(buf);

Return an error here.

> +
> +	return (struct mem_handle *) ((u32)h | mem_mgr_type_dmabuf);
> +}
> +
[...]
>  int nvhost_init_host1x01_support(struct nvhost_master *host,
>  	struct nvhost_chip_support *op)
>  {
> +	op->channel = host1x_channel_ops;
> +	op->cdma = host1x_cdma_ops;
> +	op->push_buffer = host1x_pushbuffer_ops;
>  	host->sync_aperture = host->aperture + HOST1X_CHANNEL_SYNC_REG_BASE;
>  	op->syncpt = host1x_syncpt_ops;
>  	op->intr = host1x_intr_ops;
>  
> +	op->nvhost_dev.alloc_nvhost_channel = t20_alloc_nvhost_channel;
> +	op->nvhost_dev.free_nvhost_channel = t20_free_nvhost_channel;
> +

I recall in previous version, there is t30-related alloc_nvhost_channel
& free_nvhost_channel. Why remove them?

>  	return 0;
>  }
[...]
> +static int push_buffer_init(struct push_buffer *pb)
> +{
> +	struct nvhost_cdma *cdma = pb_to_cdma(pb);
> +	struct nvhost_master *master = cdma_to_dev(cdma);
> +	pb->mapped = NULL;
> +	pb->phys = 0;
> +	pb->handle = NULL;
> +
> +	cdma_pb_op().reset(pb);
> +
> +	/* allocate and map pushbuffer memory */
> +	pb->mapped = dma_alloc_writecombine(&master->dev->dev,
> +			PUSH_BUFFER_SIZE + 4, &pb->phys, GFP_KERNEL);
> +	if (IS_ERR_OR_NULL(pb->mapped)) {
> +		pb->mapped = NULL;
> +		goto fail;

Return directly here. "goto fail" makes "push_buffer_destroy" get called.

> +	}
> +
> +	/* memory for storing mem client and handles for each opcode pair */
> +	pb->handle = kzalloc(NVHOST_GATHER_QUEUE_SIZE *
> +				sizeof(struct mem_handle *),
> +			GFP_KERNEL);
> +	if (!pb->handle)
> +		goto fail;
> +
> +	/* put the restart at the end of pushbuffer memory */

Just for curious, why "pb->mapped + 1K" is the end of a 4K pushbuffer?

> +	*(pb->mapped + (PUSH_BUFFER_SIZE >> 2)) =
> +		nvhost_opcode_restart(pb->phys);
> +
> +	return 0;
> +
> +fail:
> +	push_buffer_destroy(pb);
> +	return -ENOMEM;
> +}
> +
[...]
> +
> +/**
> + * Sleep (if necessary) until the requested event happens
> + *   - CDMA_EVENT_SYNC_QUEUE_EMPTY : sync queue is completely empty.
> + *     - Returns 1
> + *   - CDMA_EVENT_PUSH_BUFFER_SPACE : there is space in the push buffer
> + *     - Return the amount of space (> 0)
> + * Must be called with the cdma lock held.
> + */
> +unsigned int nvhost_cdma_wait_locked(struct nvhost_cdma *cdma,
> +		enum cdma_event event)
> +{
> +	for (;;) {
> +		unsigned int space = cdma_status_locked(cdma, event);
> +		if (space)
> +			return space;
> +
> +		/* If somebody has managed to already start waiting, yield */
> +		if (cdma->event != CDMA_EVENT_NONE) {
> +			mutex_unlock(&cdma->lock);
> +			schedule();
> +			mutex_lock(&cdma->lock);
> +			continue;
> +		}
> +		cdma->event = event;
> +
> +		mutex_unlock(&cdma->lock);
> +		down(&cdma->sem);
> +		mutex_lock(&cdma->lock);

I'm newbie of nvhost but I feel here is very tricky, about the lock and
unlock of this mutex: cdma->lock. Does it require this mutex is locked
before calling this function? And do we need to unlock it before the
code: "return space;" above? IMHO, this is not a good design and can we
find out a better solution?

> +	}
> +	return 0;
> +}
[...]

> +/*
> + * Dump contents of job to debug output.
> + */
> +void nvhost_job_dump(struct device *dev, struct nvhost_job *job);
> +
>  #endif
> 

  reply	other threads:[~2012-11-29 10:01 UTC|newest]

Thread overview: 145+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-26 13:19 [RFC v2 0/8] Support for Tegra 2D hardware Terje Bergstrom
2012-11-26 13:19 ` [RFC v2 1/8] video: tegra: Add nvhost driver Terje Bergstrom
2012-11-27 10:52   ` Sivaram Nair
2012-11-28 21:23   ` Thierry Reding
2012-11-29 10:21     ` Terje Bergström
2012-11-29 11:47       ` Thierry Reding
2012-11-29 18:38         ` Stephen Warren
2012-11-30  6:52           ` Thierry Reding
2012-11-30  8:50           ` Lucas Stach
2012-12-01 11:44             ` Terje Bergström
2012-12-01 15:10               ` Thierry Reding
2012-12-01 16:55                 ` Terje Bergström
2012-12-01 17:34                   ` Lucas Stach
2012-12-01 19:29                     ` Terje Bergström
2012-12-01 21:42                       ` Dave Airlie
2012-12-01 22:39                         ` Thierry Reding
2012-12-02 11:24                         ` Terje Bergström
2012-12-02 20:55                           ` Thierry Reding
2012-12-03  6:26                             ` Terje Bergström
2012-11-30  8:56         ` Terje Bergström
2012-11-30 10:38           ` Thierry Reding
2012-12-01 11:31             ` Terje Bergström
2012-12-01 13:42               ` Daniel Vetter
2012-12-01 16:22                 ` Terje Bergström
2012-12-01 14:58               ` Thierry Reding
2012-12-01 17:13                 ` Terje Bergström
2012-12-03 19:23                 ` Stephen Warren
2012-12-04 21:31                   ` Thierry Reding
2012-12-03 19:20             ` Stephen Warren
2012-12-03 21:03               ` Thierry Reding
2012-12-04  2:08                 ` Mark Zhang
2012-12-04  2:11                 ` Mark Zhang
2012-12-04  6:17                 ` Terje Bergström
2012-11-29 18:34       ` Stephen Warren
2012-11-30  6:54         ` Terje Bergström
2012-11-30  6:53           ` Thierry Reding
2012-11-29  9:10   ` [RFC,v2,1/8] " Mark Zhang
2012-12-10 10:28     ` Terje Bergström
2012-11-26 13:19 ` [RFC v2 2/8] video: tegra: Add syncpoint wait and interrupts Terje Bergstrom
2012-11-27 11:02   ` Sivaram Nair
2012-11-29  8:44   ` Thierry Reding
2012-11-29 10:39     ` Terje Bergström
2012-11-30  7:22       ` Thierry Reding
2012-11-30  7:41         ` Terje Bergström
2012-11-29 18:41     ` Stephen Warren
2012-11-30  7:23       ` Thierry Reding
2012-11-26 13:19 ` [RFC v2 3/8] video: tegra: host: Add channel and client support Terje Bergstrom
2012-11-29 10:01   ` Mark Zhang [this message]
2012-11-29 10:46     ` [RFC,v2,3/8] " Terje Bergström
2012-11-30  6:13       ` Mark Zhang
2012-11-29 10:04   ` [RFC v2 3/8] " Thierry Reding
2012-11-29 11:00     ` Terje Bergström
2012-11-30  7:46       ` Thierry Reding
2012-11-26 13:19 ` [RFC v2 4/8] video: tegra: Add debug support Terje Bergstrom
2012-11-26 13:19 ` [RFC v2 5/8] ARM: tegra: Add auxiliary data for nvhost Terje Bergstrom
2012-11-26 23:39   ` Stephen Warren
2012-11-27  6:33     ` Terje Bergström
2012-11-27 17:17       ` Stephen Warren
2012-11-26 13:19 ` [RFC v2 6/8] gpu: drm: tegra: Remove redundant host1x Terje Bergstrom
2012-12-05  8:33   ` Thierry Reding
2012-12-05 10:10     ` Terje Bergström
2012-12-05 11:13       ` Thierry Reding
2012-12-05 11:47         ` Terje Bergström
2012-12-05 12:02           ` Lucas Stach
2012-12-05 12:03           ` Daniel Vetter
2012-12-05 12:08             ` Daniel Vetter
2012-12-05 12:22             ` Thierry Reding
2012-12-05 12:31               ` Daniel Vetter
2012-12-05 13:28                 ` Thierry Reding
2012-12-05 16:34                   ` Daniel Vetter
2012-12-05 20:44                     ` Thierry Reding
2012-12-05 12:04           ` Thierry Reding
2012-12-05 15:43             ` Terje Bergström
2012-12-10 11:42             ` Terje Bergström
2012-12-12 16:08               ` Thierry Reding
2012-12-12 16:56                 ` Terje Bergström
2012-12-13  8:48                 ` Terje Bergström
2012-12-13  8:57                   ` Thierry Reding
2012-12-13 17:58                     ` Stephen Warren
2012-12-13 20:32                       ` Thierry Reding
2012-12-14  6:09                       ` Terje Bergström
2012-12-14 16:21                         ` Stephen Warren
2012-12-14 19:59                           ` Terje Bergström
2012-12-16 12:16                             ` Thierry Reding
2012-12-16 16:37                               ` Terje Bergström
2012-12-17 20:55                                 ` Stephen Warren
2012-12-18  6:37                                   ` Terje Bergström
2012-12-20  9:17                               ` Terje Bergström
2012-12-20 17:14                                 ` Stephen Warren
2012-12-20 17:46                                   ` Terje Bergström
2012-12-20 17:55                                     ` Stephen Warren
2012-12-20 18:01                                       ` Terje Bergström
2012-12-20 20:30                                         ` Thierry Reding
2012-12-20 21:34                                           ` Terje Bergström
2012-12-20 21:50                                             ` Thierry Reding
2012-12-20 22:29                                               ` Stephen Warren
2012-12-20 22:28                                             ` Stephen Warren
2012-12-21  6:31                                               ` Terje Bergström
2012-12-21  8:57                                   ` Arto Merilainen
2012-12-21 21:19                                     ` Stephen Warren
2013-01-02  5:41                                       ` Terje Bergström
2013-01-04 10:09                                       ` Terje Bergström
2013-01-04 20:25                                         ` Stephen Warren
2013-01-07  8:20                                           ` Terje Bergström
2013-01-07 17:07                                             ` Stephen Warren
2013-01-15 11:30                                           ` Thierry Reding
2013-01-15 11:41                                             ` Terje Bergström
2012-11-26 13:19 ` [RFC v2 7/8] gpu: drm: tegra: Prime support Terje Bergstrom
2012-11-26 13:19 ` [RFC v2 8/8] drm: tegra: Add gr2d device Terje Bergstrom
2012-11-26 21:59   ` Rob Clark
2012-11-26 22:15   ` Dave Airlie
2012-11-27  6:52     ` Terje Bergström
2012-11-27  7:33       ` Dave Airlie
2012-11-27  8:16         ` Terje Bergström
2012-11-27  8:32           ` Dave Airlie
2012-11-27  8:45             ` Terje Bergström
2012-11-27 10:22               ` Lucas Stach
2012-11-27 10:37                 ` Thierry Reding
2012-11-27 11:31                   ` Terje Bergström
2012-11-27 11:47                     ` Lucas Stach
2012-11-27 12:59                       ` Terje Bergström
2012-11-27 23:00                     ` Dave Airlie
2012-11-28 13:17                       ` Terje Bergström
2012-11-28 13:33                         ` Lucas Stach
2012-11-28 13:57                           ` Terje Bergström
2012-11-28 14:06                             ` Lucas Stach
2012-11-28 14:45                               ` Terje Bergström
2012-11-28 15:13                                 ` Lucas Stach
2012-11-28 16:23                                   ` Terje Bergström
2012-11-28 18:46                                     ` Lucas Stach
2012-11-29  8:17                                       ` Terje Bergström
2012-11-29  9:09                                         ` Lucas Stach
2012-11-29 12:14                                           ` Thierry Reding
2012-11-30  7:44                                             ` Terje Bergström
2012-11-30  7:53                                               ` Lucas Stach
2012-11-29 13:36                                           ` Terje Bergström
2012-11-28 16:24                                 ` Stephen Warren
2012-11-28 20:53                           ` Thomas Hellstrom
2012-12-03  9:30     ` Mark Zhang
2012-12-03  9:40       ` Daniel Vetter
2012-12-04  1:49         ` Mark Zhang
2012-11-29  7:37   ` [RFC,v2,8/8] " Mark Zhang
2012-12-01 14:45 ` [RFC v2 0/8] Support for Tegra 2D hardware Thierry Reding
2012-12-01 17:08   ` Terje Bergström
2012-12-01 19:29     ` Thierry Reding

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=50B7325F.20002@gmail.com \
    --to=nvmarkzhang@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=tbergstrom@nvidia.com \
    --cc=thierry.reding@avionic-design.de \
    /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;
as well as URLs for NNTP newsgroup(s).