From nobody Tue Jun 28 21:18:09 2022 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 694F786CF6A for ; Tue, 28 Jun 2022 21:18:20 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LXcrq4GpNz4WNl for ; Tue, 28 Jun 2022 21:18:19 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-qv1-xf29.google.com with SMTP id cs6so21976193qvb.6 for ; Tue, 28 Jun 2022 14:18:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Ykg53DPnvV49tQK5ztghYO/fIUJKwjjZV3cimgbCd1M=; b=ShOFPe9XGxoiPLjPxWx3ns01RNuU73wD2BE71u49QG2/LRVfgXxdCO+T01JrCdS9xo o2HLOeM+J334A6fdbliWWux+pJQR0hnz7fJ8fJVsaptsbu3DJ5OgZWgB1mWnROmHdIry 7lYTuqMgxy8RZR2UKww9iaBis+uj+kuZH4mPy6Ohj3xD07Nq1YJE7QlvgPfGby9qXY8e w3dTATMNYOaldn5k7tbuRfQMSvdAWoz9V7DQQdMrQqjVNojt5bSOFO9hOPgC2KBf2V7n 5J4m1zr5sUh95PGX3rH07nH3K79/pyPXD2cqLHjrOqLBGYLUzuOGPdhZcSdL8wVNPMgG rGzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=Ykg53DPnvV49tQK5ztghYO/fIUJKwjjZV3cimgbCd1M=; b=BdORJ+IOESf8sP60SLWe0uqkS0JGgxvB1E+R7DZmex7/c98XfEvzHKU5NtTvkwfvb6 NKfzZli4hz2boYjWAwPfDU3u8HEpdpr2RJAUd5fM80DoerUT4DpY3pKbta7MX6l/By/D kN4z3JgL12B/jHC2u+VHBqwH0oHxI70kfzBpUk+x97pGlT6cVOTS+SRPdxgYEQQXFQ8S XY34joQKV7SDd3l6OdlOJcuiaIaQ9Fal62FL8suNJCWWFxMNul5zHp2+Zn3rkA7Mhidr 1SSK31IxZQMIUL+xk+7oajReW0wuGdY6v43oI4EJHtkUW4ZZmx9j7M4wRIxy5qzKJedK QBXw== X-Gm-Message-State: AJIora+PO25cwWXIWAi1/b+4qX5l6ybm/pVaW8Hld/yxwhpgVykLuy9Z XOu9RcBfSKOK5t5IK6xZoHW5tMpt4ko= X-Google-Smtp-Source: AGRyM1sbrVJMj5M0SCrCxBEAxqoZ2Huuo40rhwMF9UpAPPgx9ra7JA1g5hZqm7e1E1/RFrHVS//swA== X-Received: by 2002:ac8:5dce:0:b0:305:300e:146d with SMTP id e14-20020ac85dce000000b00305300e146dmr4881qtx.546.1656451092947; Tue, 28 Jun 2022 14:18:12 -0700 (PDT) Received: from nuc (198-84-189-58.cpe.teksavvy.com. [198.84.189.58]) by smtp.gmail.com with ESMTPSA id n1-20020a05620a294100b006aedbb30947sm2622816qkp.122.2022.06.28.14.18.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 14:18:12 -0700 (PDT) Date: Tue, 28 Jun 2022 17:18:09 -0400 From: Mark Johnston To: Jake Freeland Cc: freebsd-hackers@freebsd.org Subject: Re: LinuxKPI debugfs Port Message-ID: References: List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 4LXcrq4GpNz4WNl X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20210112 header.b=ShOFPe9X; dmarc=none; spf=pass (mx1.freebsd.org: domain of markjdb@gmail.com designates 2607:f8b0:4864:20::f29 as permitted sender) smtp.mailfrom=markjdb@gmail.com X-Spamd-Result: default: False [-1.71 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36:c]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-0.02)[-0.016]; FORGED_SENDER(0.30)[markj@freebsd.org,markjdb@gmail.com]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[markj@freebsd.org,markjdb@gmail.com]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.99)[-0.991]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20210112]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::f29:from]; MLMMJ_DEST(0.00)[freebsd-hackers]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_TLS_ALL(0.00)[] X-ThisMailContainsUnwantedMimeParts: N On Tue, Jun 28, 2022 at 03:38:48PM -0500, Jake Freeland wrote: > Hi there, > > I am working on porting Intel's igt-gpu-tools drm graphics driver testing > suite to FreeBSD and I ran into some issues regarding debugfs. I spoke > to manu@ who told me that CONFIG_DEBUG_FS is required for the > testing to work properly. I started working on a debugfs port and quickly > got confused about what manu@ meant by implementing "CONFIG_DEBUG_FS". I would guess that he meant to compile the i915kms driver with CONFIG_DEBUGFS configured. I'm not sure what the "right" way is to do that, but adding KCONFIG+= DEBUGFS to the end of kconfig.mk in the drm-kmod repository seems to do the trick for me, with the caveat that the driver doesn't compile. :) I think the task is to get it to compile by extending the existing debugfs shims in the LinuxKPI, but see my comments below. There is also a typo in the makefile there, see https://github.com/freebsd/drm-kmod/pull/185 > Some quick internet searching says that CONFIG_DEBUG_FS is a > Linux kernel configuration flag. I am curious how I would go about > implementing this into FreeBSD. I copied the Linux debugfs source > code into a new repository and attempted to compile it on FreeBSD > as a kernel module: > > https://github.com/jakesfreeland/debugfs-freebsd > > Of course I was met with many, many incompatibility errors. I proceeded > to copy the required `sys/compat/linuxkpi/common/include/linux` headers > into my repository and I was met with two options: Yes, that's not going to work and isn't the right approach. > 1. continue modifying the LinuxKPI headers and commit my modifications > to src. > > 2. re-engineer the debugfs source code to comply with the preexisting > LinuxKPI headers. > > Many problems come with both approaches. First, if I modify the LinuxKPI > headers, I'd be "copying" over some code from Linux's GPLv2 headers. > I do not know how much I can "copy" before legal issues arise. Second, > if I re-engineer the debugfs source code, I am revolting against what > LinuxKPI > stands for: running Linux code with little-to-no modification. I don't know > what the correct approach is here. The purpose of the LinuxKPI is to allow Linux _drivers_ to run (mostly) unmodified on FreeBSD. Generic kernel components like debugfs itself are not meant to run under the LinuxKPI and are out of its scope. debugfs provides a set of interfaces used by drivers, including i915, to export debug info. The LinuxKPI provides a partial implementation of that interface already, in debugfs.h and lindebugfs.c, and I think the task ahead of you is to extend it to allow i915 to compile with DEBUGFS configured. (But please double check that!) > I also discovered that lindebugfs, a curtailed version of Linux's debugfs, > already exists in FreeBSD's src. I am led to believe that this is > exclusively > used under the Linuxulator so it wouldn't help me. Is this correct? No, I don't think that's accurate. It's just another pseudo filesystem, it can be used by anything that knows how to open and read files. > Thank you so much, > Jake Freeland