8000 sys/external/bsd/drm2/dist/drm/i915 subdirectory: Linux 5.6.19 merge by dettus · Pull Request #44 · NetBSD/src · GitHub
[go: up one dir, main page]

Skip to content

sys/external/bsd/drm2/dist/drm/i915 subdirectory: Linux 5.6.19 merge #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: trunk
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
At Linux 5.6.6, and it compiles and boots.
  • Loading branch information
dettus committed Mar 3, 2025
commit 90cf5908615dfc26d426acf2f10622014209352f
79 changes: 65 additions & 14 deletions sys/external/bsd/drm2/dist/drm/i915/i915_perf.c
8000
Original file line number Diff line number Diff line change
Expand Up @@ -3023,20 +3023,75 @@ static int i915_perf_read(struct file *file,
struct uio *buf,
kauth_cred_t count, /* XXX dummy */
int ppos) /* XXX dummy */
{
struct i915_perf_stream *stream = file->f_data;
struct i915_perf *perf = stream->perf;
int ret;
size_t offset_delta = 0;

/* To ensure it's handled consistently we simply treat all reads of a
* disabled stream as an error. In particular it might otherwise lead
* to a deadlock for blocking file descriptors...
*/
if (!stream->enabled)
return -EIO;

buf->uio_offset = *offset;
if (!(file->f_flag & FNONBLOCK))
{
/* There's the small chance of false positives from
* stream->ops->wait_unlocked.
*
* E.g. with single context filtering since we only wait until
* oabuffer has >= 1 report we don't immediately know whether
* any reports really belong to the current context
*/
do {
ret = stream->ops->wait_unlocked(stream);
if (ret)
return ret;

mutex_lock(&perf->lock);
offset_delta=buf->uio_offset;
ret = stream->ops->read(stream, buf, count, 0);
offset_delta=buf->uio_offset-offset_delta;
mutex_unlock(&perf->lock);
} while (!(*offset) && !ret);
} else {
mutex_lock(&perf->lock);
offset_delta=buf->uio_offset;
ret = stream->ops->read(stream, buf, count, 0);
offset_delta=buf->uio_offset-offset_delta;
mutex_unlock(&perf->lock);
}

/* We allow the poll checking to sometimes report false positive EPOLLIN
* events where we might actually report EAGAIN on read() if there's
* not really any data available. In this situation though we don't
* want to enter a busy loop between poll() reporting a EPOLLIN event
* and read() returning -EAGAIN. Clearing the oa.pollin state here
* effectively ensures we back off until the next hrtimer callback
* before reporting another EPOLLIN event.
* The exception to this is if ops->read() returned -ENOSPC which means
* that more OA data is available than could fit in the user provided
* buffer. In this case we want the next poll() call to not block.
*/
if (ret != -ENOSPC)
stream->pollin = false;

/* Possible values for ret are 0, -EFAULT, -ENOSPC, -EIO, ... */
return (offset_delta) ?: (ret ?: -EAGAIN);
}

#else
static ssize_t i915_perf_read(struct file *file,
char __user *buf,
size_t count,
loff_t *ppos)
#endif
{
#ifdef __NetBSD__
struct i915_perf_stream *stream = file->f_data;
#else
struct i915_perf_stream *stream = file->private_data;
#endif
struct i915_perf *perf = stream->perf;
size_t offset2 = 0;
size_t offset = 0;
int ret;

/* To ensure it's handled consistently we simply treat all reads of a
Expand All @@ -3046,12 +3101,7 @@ static ssize_t i915_perf_read(struct file *file,
if (!stream->enabled)
return -EIO;

#ifdef __NetBSD__
buf->uio_offset = *offset;
if (!(file->f_flag & FNONBLOCK))
#else
if (!(file->f_flags & O_NONBLOCK))
#endif
{
/* There's the small chance of false positives from
* stream->ops->wait_unlocked.
Expand All @@ -3066,12 +3116,12 @@ static ssize_t i915_perf_read(struct file *file,
return ret;

mutex_lock(&perf->lock);
ret = stream->ops->read(stream, buf, count, &offset2);
ret = stream->ops->read(stream, buf, count, &offset);
mutex_unlock(&perf->lock);
} while (!offset2 && !ret);
} else {
mutex_lock(&perf->lock);
ret = stream->ops->read(stream, buf, count, &offset2);
ret = stream->ops->read(stream, buf, count, &offset);
mutex_unlock(&perf->lock);
}

Expand All @@ -3090,8 +3140,9 @@ static ssize_t i915_perf_read(struct file *file,
stream->pollin = false;

/* Possible values for ret are 0, -EFAULT, -ENOSPC, -EIO, ... */
return offset2 ?: (ret ?: -EAGAIN);
return offset ?: (ret ?: -EAGAIN);
}
#endif

static enum hrtimer_restart oa_poll_check_timer_cb(struct hrtimer *hrtimer)
{
Expand Down
0