Commit caccddcf authored by Thierry Reding's avatar Thierry Reding
Browse files

gpu: host1x: Request channels for clients, not devices



A struct device doesn't carry much information that a channel might be
interested in, but the client very much does. Request channels for the
clients rather than their parent devices and store a pointer to them
in order to have that information available when needed.

Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
parent 8f45f507
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -40,7 +40,7 @@ static int gr2d_init(struct host1x_client *client)
	struct gr2d *gr2d = to_gr2d(drm);
	struct gr2d *gr2d = to_gr2d(drm);
	int err;
	int err;


	gr2d->channel = host1x_channel_request(client->dev);
	gr2d->channel = host1x_channel_request(client);
	if (!gr2d->channel)
	if (!gr2d->channel)
		return -ENOMEM;
		return -ENOMEM;


+1 −1
Original line number Original line Diff line number Diff line
@@ -49,7 +49,7 @@ static int gr3d_init(struct host1x_client *client)
	struct gr3d *gr3d = to_gr3d(drm);
	struct gr3d *gr3d = to_gr3d(drm);
	int err;
	int err;


	gr3d->channel = host1x_channel_request(client->dev);
	gr3d->channel = host1x_channel_request(client);
	if (!gr3d->channel)
	if (!gr3d->channel)
		return -ENOMEM;
		return -ENOMEM;


+1 −1
Original line number Original line Diff line number Diff line
@@ -198,7 +198,7 @@ static int vic_init(struct host1x_client *client)
		vic->domain = tegra->domain;
		vic->domain = tegra->domain;
	}
	}


	vic->channel = host1x_channel_request(client->dev);
	vic->channel = host1x_channel_request(client);
	if (!vic->channel) {
	if (!vic->channel) {
		err = -ENOMEM;
		err = -ENOMEM;
		goto detach;
		goto detach;
+7 −6
Original line number Original line Diff line number Diff line
@@ -115,14 +115,14 @@ static struct host1x_channel *acquire_unused_channel(struct host1x *host)


/**
/**
 * host1x_channel_request() - Allocate a channel
 * host1x_channel_request() - Allocate a channel
 * @device: Host1x unit this channel will be used to send commands to
 * @client: Host1x client this channel will be used to send commands to
 *
 *
 * Allocates a new host1x channel for @device. May return NULL if CDMA
 * Allocates a new host1x channel for @client. May return NULL if CDMA
 * initialization fails.
 * initialization fails.
 */
 */
struct host1x_channel *host1x_channel_request(struct device *dev)
struct host1x_channel *host1x_channel_request(struct host1x_client *client)
{
{
	struct host1x *host = dev_get_drvdata(dev->parent);
	struct host1x *host = dev_get_drvdata(client->dev->parent);
	struct host1x_channel_list *chlist = &host->channel_list;
	struct host1x_channel_list *chlist = &host->channel_list;
	struct host1x_channel *channel;
	struct host1x_channel *channel;
	int err;
	int err;
@@ -133,7 +133,8 @@ struct host1x_channel *host1x_channel_request(struct device *dev)


	kref_init(&channel->refcount);
	kref_init(&channel->refcount);
	mutex_init(&channel->submitlock);
	mutex_init(&channel->submitlock);
	channel->dev = dev;
	channel->client = client;
	channel->dev = client->dev;


	err = host1x_hw_channel_init(host, channel, channel->id);
	err = host1x_hw_channel_init(host, channel, channel->id);
	if (err < 0)
	if (err < 0)
@@ -148,7 +149,7 @@ struct host1x_channel *host1x_channel_request(struct device *dev)
fail:
fail:
	clear_bit(channel->id, chlist->allocated_channels);
	clear_bit(channel->id, chlist->allocated_channels);


	dev_err(dev, "failed to initialize channel\n");
	dev_err(client->dev, "failed to initialize channel\n");


	return NULL;
	return NULL;
}
}
+1 −0
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@ struct host1x_channel {
	unsigned int id;
	unsigned int id;
	struct mutex submitlock;
	struct mutex submitlock;
	void __iomem *regs;
	void __iomem *regs;
	struct host1x_client *client;
	struct device *dev;
	struct device *dev;
	struct host1x_cdma cdma;
	struct host1x_cdma cdma;
};
};
Loading