Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp712697imm; Tue, 5 Jun 2018 03:17:23 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL2eX2Op7MDDcebQwigPhfu+47NICy+K7ypRHV+5mJefeT4aWcULbugMDHUpMZTkV5IBTas X-Received: by 2002:a63:9543:: with SMTP id t3-v6mr16422813pgn.77.1528193843819; Tue, 05 Jun 2018 03:17:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528193843; cv=none; d=google.com; s=arc-20160816; b=yRki6Ets8bK5WF4LWbNW9nQHh5BtlU9mcnZhWTPYFl/leZANOFuvDCHnFSv2MEw3wk 9PyBbBIxqfwgUFeYTdOoqsjAX/a3NGmOSbRyq41f+TJw8iY3fblPbGK8H15SMuBiGY2p ayXFvq5TuJXfpV17PRBcihnKXB/03B/sARtNYxONVWKJKSBaNPJKlgvhpGzKcev2ejj8 00WJvUL3hU84Igem6Pz9fNo30RcwkoV8vEGufJG0WjnfAMHLCurScNEP+4iYi8GNXIQw +oatQzLiV+PfWtmiRkKUuLkGqMUrAtjY3dcSyQarJlLMHRVvUl3panFqpdXD8f1wOtSn cV8Q== 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:message-id:subject:to :from:date:arc-authentication-results; bh=ob6RCDtRG3J3lCvVBAEfBNgQzn9yByB31FEO+HgQziM=; b=MKt6Sw57ELUDo4aa+u/AN1OpxOgUBr+C15ESwkeXl3bqtOXmHz4Al4P4lTX/aQFtQd oWxOFYyjgC0mJ8ioOs1j4D2j/WXSnDwof7707sMTLGylFRaQS4Y+Cxedc7r+TyRMjYf3 OZT9YNXihu5zdGBu+JY0fB89Qq6dtZawCs7hH5Rm8qEvrd0y/D9uJlQE5rFbABklURCE 96soDJ7xhGoa+xHDh47U66NzdMe6dH7m1qe05i3TesvW/G9AzB8oZUvB0bpNMr8ASnXP 9fhzxkPdvQ1NkSq8EBxD24E14jyRQ0RXTkeM38LLk8DNQW0lHI7FB93VnOQPkdl03SV5 iIxA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u22-v6si25466313pfg.62.2018.06.05.03.17.08; Tue, 05 Jun 2018 03:17:23 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751840AbeFEKQf (ORCPT + 99 others); Tue, 5 Jun 2018 06:16:35 -0400 Received: from gofer.mess.org ([88.97.38.141]:47537 "EHLO gofer.mess.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751765AbeFEKQc (ORCPT ); Tue, 5 Jun 2018 06:16:32 -0400 Received: by gofer.mess.org (Postfix, from userid 1000) id 8ACEE60442; Tue, 5 Jun 2018 11:16:29 +0100 (BST) Date: Tue, 5 Jun 2018 11:16:29 +0100 From: Sean Young To: Matthias Reichl , 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: <20180605101629.yffyp64o7adg6hu5@gofer.mess.org> References: <9f2c54d4956f962f44fcda739a824397ddea132c.1527419762.git.sean@mess.org> <20180604174730.sctfoklq7klswebp@camel2.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180604174730.sctfoklq7klswebp@camel2.lan> 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 On Mon, Jun 04, 2018 at 07:47:30PM +0200, Matthias Reichl wrote: > 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? Unfortunately bpf cannot be built 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? You are right, this features depends on CONFIG_CGROUP_BPF right now. This also affects the BPF_SK_MSG_VERDICT, BPF_SK_SKB_STREAM_VERDICT and BPF_SK_SKB_STREAM_PARSER type bpf attachments, and as far as I know these shouldn't depend on CONFIG_CGROUP_BPF either. Sean