~kennylevinsen/seatd-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 2

[PATCH seatd] drm: Support drm-subtree drivers on FreeBSD

Details
Message ID
<166917232683.22022.1443597072848699835-0@git.sr.ht>
DKIM signature
missing
Download raw message
Patch: +10 -10
From: Jessica Clarke <jrtc27@jrtc27.com>

The drm-kmod drivers use linuxkpi and end up with /dev/drm being the
canonical path for the devices, but the drm-subtree drivers use drmkpi
which has them appear under /dev/dri like Linux. Thus, adapt path_is_drm
to recognise both on FreeBSD.
---
 common/drm.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/common/drm.c b/common/drm.c
index 45ed7e5..cb57a0f 100644
--- a/common/drm.c
+++ b/common/drm.c
@@ -11,6 +11,7 @@
#define DRM_IOCTL_DROP_MASTER DRM_IO(0x1f)

#define STRLEN(s) ((sizeof(s) / sizeof(s[0])) - 1)
#define STR_HAS_PREFIX(prefix, s) (strncmp(prefix, s, STRLEN(prefix)) == 0)

int drm_set_master(int fd) {
	return ioctl(fd, DRM_IOCTL_SET_MASTER, 0);
@@ -20,17 +21,16 @@ int drm_drop_master(int fd) {
	return ioctl(fd, DRM_IOCTL_DROP_MASTER, 0);
}

#if defined(__linux__) || defined(__NetBSD__)
#if defined(__linux__) || defined(__NetBSD__) || defined(__FreeBSD__)
int path_is_drm(const char *path) {
	static const char prefix[] = "/dev/dri/";
	static const int prefixlen = STRLEN(prefix);
	return strncmp(prefix, path, prefixlen) == 0;
}
#elif defined(__FreeBSD__)
int path_is_drm(const char *path) {
	static const char prefix[] = "/dev/drm/";
	static const int prefixlen = STRLEN(prefix);
	return strncmp(prefix, path, prefixlen) == 0;
	if (STR_HAS_PREFIX("/dev/dri/", path))
		return 1;
#ifdef __FreeBSD__
	/* Some drivers have /dev/dri/X symlinked to /dev/drm/X */
	if (STR_HAS_PREFIX("/dev/drm/", path))
		return 1;
#endif
	return 0;
}
#else
#error Unsupported platform
-- 
2.34.5
Details
Message ID
<HCE6MR.W02SU6H431T3@kl.wtf>
In-Reply-To
<166917232683.22022.1443597072848699835-0@git.sr.ht> (view parent)
DKIM signature
missing
Download raw message
Ah, is this something new or did I just completely miss it when working 
on FreeBSD?

CI on mailing list patches was down for a moment, but here is a manual 
rerun on alpine: https://builds.sr.ht/~kennylevinsen/job/895142 - fails 
on check-format.

On Wed, Nov 23 2022 at 02:12:42 AM +00:00:00, ~jrtc27 
<jrtc27@git.sr.ht> wrote:
> +#ifdef __FreeBSD__
> +	/* Some drivers have /dev/dri/X symlinked to /dev/drm/X */
> +	if (STR_HAS_PREFIX("/dev/drm/", path))
> +		return 1;
> +#endif

I think it would be much more readable if left as two flat #if's like 
before but with the new code added to the freebsd version, even if it 
leads to a duplicated check for /dev/dri. #ifdefs are not great for 
readability, nested #ifdefs even less so.
Details
Message ID
<D70F9B16-D60D-4880-BA34-6EAE0CA9CA46@jrtc27.com>
In-Reply-To
<HCE6MR.W02SU6H431T3@kl.wtf> (view parent)
DKIM signature
missing
Download raw message
On 30 Nov 2022, at 19:33, Kenny Levinsen <kl@kl.wtf> wrote:
> 
> Ah, is this something new or did I just completely miss it when working on FreeBSD?

The dam-subtree drivers are used for various Arm-based SoCs, though I think the Panfrost GPU driver might be the only one where you’d actually be able to do more than get a video console (what we’re using). Intel/AMD/Nvidia are still in drm-kmod and as far as I know haven’t changed behaviour.

> CI on mailing list patches was down for a moment, but here is a manual rerun on alpine: https://builds.sr.ht/~kennylevinsen/job/895142 - fails on check-format.

I see; is it better to separate out the two #defines so (presumably) it won’t enforce aligning them, or should I align them as suggested by the diff?

> On Wed, Nov 23 2022 at 02:12:42 AM +00:00:00, ~jrtc27 <jrtc27@git.sr.ht> wrote:
>> +#ifdef __FreeBSD__
>> +	/* Some drivers have /dev/dri/X symlinked to /dev/drm/X */
>> +	if (STR_HAS_PREFIX("/dev/drm/", path))
>> +		return 1;
>> +#endif
> 
> I think it would be much more readable if left as two flat #if's like before but with the new code added to the freebsd version, even if it leads to a duplicated check for /dev/dri. #ifdefs are not great for readability, nested #ifdefs even less so.

Sure, if that’s what you’d prefer.

Jess
Details
Message ID
<V9F6MR.6URN2HBUVI752@kl.wtf>
In-Reply-To
<D70F9B16-D60D-4880-BA34-6EAE0CA9CA46@jrtc27.com> (view parent)
DKIM signature
missing
Download raw message
On Wed, Nov 30 2022 at 07:43:32 PM +00:00:00, Jessica Clarke 
<jrtc27@jrtc27.com> wrote:
> The dam-subtree drivers are used for various Arm-based SoCs, though I 
> think the Panfrost GPU driver might be the only one where you’d 
> actually be able to do more than get a video console (what we’re 
> using). Intel/AMD/Nvidia are still in drm-kmod and as far as I know 
> haven’t changed behaviour.

Fair enough, just curious. :)

> I see; is it better to separate out the two #defines so (presumably) 
> it won’t enforce aligning them, or should I align them as suggested 
> by the diff?

Following the diff is fine, just like the other stuff it aligned.
Reply to thread Export thread (mbox)