Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3882497imm; Mon, 4 Jun 2018 10:48:21 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIJpFI41FTsX11kc+BVqeXM4oiwSOccRK/ZNHIeUgCaYB8tSjN1pla6YhYoHAjvFHQ4Jwum X-Received: by 2002:a17:902:bb8a:: with SMTP id m10-v6mr14544179pls.236.1528134501086; Mon, 04 Jun 2018 10:48:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528134501; cv=none; d=google.com; s=arc-20160816; b=VlSv4ID4V6bc7WyNRD0pBZVGnTy5Qrp5jYLkX3gZEgFrjbRD+n0jfw1Gu08X3B1s18 /5QOb56KSBNR2HHjkS8waRmIeC/uyq9BhnR42VPD8or7L9qOqFchopTlMNAqujtoU2lS kvrU3Z3zj9Yk/o9MUhueaCxp/uOEg1wz529q3vDMmUFPN06ZEzjqWpnyo/bJPwr+U7y4 PcIsr9BQ2WnURexTrtIUEm2Rl+CQNn6j6Nco/2bzw4K8Xpl59oET1QN7KxodC/2iN0GH 75UcXA9bc+DbZuwHz2Dbt4SRrJLW63cHpKzkgJn2CX1WMlz1d3jZgrQw78c7HJm5oMqf 0u/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=eQielxFZx1/uHkWjvPbpcjsAG77YbzKjTgjk52FgYTs=; b=wOkZW72A/nSijybGKeX3BGaAnzZtGewhzpJSSsM18rtXf4HFWL5jnOBjf+ctfZ0ZCp T7YYqwIyqsx9G+KBcP5n+1CWtWmNKD6ys9Z2sY+ICucGc4qPxK3mJGP+heDKhaa6zwcC cu0/AhYJ4o/VSoYyOKUr2SJmdw9un0qoQOAAUDPhgDBCD09drWPtwYzrJJLnxCASkZIm nwzTi9clAZy7YfE/R1pDN7lw6CXpBcz9lUzLcF3Hz49APjCRXmsB4obknhFVL/Xpez8s 3pW4BtCHJLtbgCIRRDDy2ASe7idvyGKRf/3EWZn2fgdoB4ab+SJrDyJ84hojxMGQiYTk NTJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@horus.com header.s=20180324 header.b=C1rLjwE4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=horus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b26-v6si20974270pgw.394.2018.06.04.10.48.06; Mon, 04 Jun 2018 10:48:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@horus.com header.s=20180324 header.b=C1rLjwE4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=horus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751369AbeFDRrg (ORCPT + 99 others); Mon, 4 Jun 2018 13:47:36 -0400 Received: from mail.horus.com ([78.46.148.228]:49599 "EHLO mail.horus.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750934AbeFDRre (ORCPT ); Mon, 4 Jun 2018 13:47:34 -0400 Received: from [192.168.1.20] (62-47-200-241.adsl.highway.telekom.at [62.47.200.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "E-Mail Matthias Reichl", Issuer "HiassofT CA 2014" (verified OK)) by mail.horus.com (Postfix) with ESMTPSA id 49BCC6409A; Mon, 4 Jun 2018 19:47:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=horus.com; s=20180324; t=1528134452; bh=eQielxFZx1/uHkWjvPbpcjsAG77YbzKjTgjk52FgYTs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=C1rLjwE4//XtLj4WID0AjXhPrOdR0H7+jwqUXoasyGOrDBI6IXKZZjTC9H/3WkpYc yt05PAZi/y2PUtrbrTVInmt388jcqrNuM66bpcyZfgmd45frJSWdKrFnQ7ZfMO0Ph0 hYjd5S66UptYK7IVA8rxL0DsdmkCt0vCjacxdxnQ= Received: by camel2.lan (Postfix, from userid 1000) id 0DB031C7754; Mon, 4 Jun 2018 19:47:30 +0200 (CEST) Date: Mon, 4 Jun 2018 19:47:30 +0200 From: Matthias Reichl To: Sean Young Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Alexei Starovoitov , Mauro Carvalho Chehab , Daniel Borkmann , netdev@vger.kernel.org, Devin Heitmueller , Y Song , Quentin Monnet Subject: Re: [PATCH v5 2/3] media: rc: introduce BPF_PROG_LIRC_MODE2 Message-ID: <20180604174730.sctfoklq7klswebp@camel2.lan> Mail-Followup-To: Matthias Reichl , Sean Young , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Alexei Starovoitov , Mauro Carvalho Chehab , Daniel Borkmann , netdev@vger.kernel.org, Devin Heitmueller , Y Song , Quentin Monnet References: <9f2c54d4956f962f44fcda739a824397ddea132c.1527419762.git.sean@mess.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9f2c54d4956f962f44fcda739a824397ddea132c.1527419762.git.sean@mess.org> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sean, I finally found the time to test your patch series and noticed 2 issues - comments are inline On Sun, May 27, 2018 at 12:24:09PM +0100, Sean Young wrote: > diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig > index eb2c3b6eca7f..d5b35a6ba899 100644 > --- a/drivers/media/rc/Kconfig > +++ b/drivers/media/rc/Kconfig > @@ -25,6 +25,19 @@ config LIRC > passes raw IR to and from userspace, which is needed for > IR transmitting (aka "blasting") and for the lirc daemon. > > +config BPF_LIRC_MODE2 > + bool "Support for eBPF programs attached to lirc devices" > + depends on BPF_SYSCALL > + depends on RC_CORE=y Requiring rc-core to be built into the kernel could become problematic in the future for people using media_build. Currently the whole media tree (including rc-core) can be built as modules so DVB and IR drivers can be replaced by newer versions. But with rc-core in the kernel things could easily break if internal data structures are changed. Maybe we should add a small layer with a stable API/ABI between bpf-lirc and rc-core to decouple them? Or would it be possible to build rc-core with bpf support as a module? > + depends on LIRC > + help > + Allow attaching eBPF programs to a lirc device using the bpf(2) > + syscall command BPF_PROG_ATTACH. This is supported for raw IR > + receivers. > + > + These eBPF programs can be used to decode IR into scancodes, for > + IR protocols not supported by the kernel decoders. > + > menuconfig RC_DECODERS > bool "Remote controller decoders" > depends on RC_CORE > [...] > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c > index 388d4feda348..3c104113d040 100644 > --- a/kernel/bpf/syscall.c > +++ b/kernel/bpf/syscall.c > @@ -11,6 +11,7 @@ > */ > #include > #include > +#include > #include > #include > #include > @@ -1578,6 +1579,8 @@ static int bpf_prog_attach(const union bpf_attr *attr) > case BPF_SK_SKB_STREAM_PARSER: > case BPF_SK_SKB_STREAM_VERDICT: > return sockmap_get_from_fd(attr, BPF_PROG_TYPE_SK_SKB, true); > + case BPF_LIRC_MODE2: > + return lirc_prog_attach(attr); > default: > return -EINVAL; > } > @@ -1648,6 +1651,8 @@ static int bpf_prog_detach(const union bpf_attr *attr) > case BPF_SK_SKB_STREAM_PARSER: > case BPF_SK_SKB_STREAM_VERDICT: > return sockmap_get_from_fd(attr, BPF_PROG_TYPE_SK_SKB, false); > + case BPF_LIRC_MODE2: > + return lirc_prog_detach(attr); > default: > return -EINVAL; > } > @@ -1695,6 +1700,8 @@ static int bpf_prog_query(const union bpf_attr *attr, > case BPF_CGROUP_SOCK_OPS: > case BPF_CGROUP_DEVICE: > break; > + case BPF_LIRC_MODE2: > + return lirc_prog_query(attr, uattr); When testing this patch series I was wondering why I always got -EINVAL when trying to query the registered programs. Closer inspection revealed that bpf_prog_attach/detach/query and calls to them in the bpf syscall are in "#ifdef CONFIG_CGROUP_BPF" blocks - and as I built the kernel without CONFIG_CGROUP_BPF BPF_PROG_ATTACH/DETACH/QUERY weren't handled in the syscall switch and I got -EINVAL from the bpf syscall function. I haven't checked in detail yet, but it looks to me like bpf_prog_attach/detach/query could always be built (or when either cgroup bpf or lirc bpf are enabled) and the #ifdefs moved inside the switch(). So lirc bpf could be used without cgroup bpf. Or am I missing something? so long, Hias > default: > return -EINVAL; > } > -- > 2.17.0 >