From patchwork Mon Jul 6 12:11:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 50737 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 89418229FC for ; Mon, 6 Jul 2015 12:12:07 +0000 (UTC) Received: by wgjx7 with SMTP id x7sf49153188wgj.3 for ; Mon, 06 Jul 2015 05:12:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=NSWgIm7g9YIAh+l06hPoQfJFCs6Miw4L9BBbaw/sKr8=; b=HHIYyHPptcqGzXvMkUugxrpaZU9ya6obmhFi/KZ9q0K/FlQx6dzMeEUuvhChUyNi25 rMOouYDqKFzbg3w94fOQ8qT8kY2RP5/8jNhVeXTtVLBdk4ZmPqotnqCEdeG+L5miCwl1 xjGwBOclizZvwj+VIz+9A8wz7ErTelw3KSA4hRlw5N3IA4tiP3/Lcq65DC+3nmI8YqpC pdL2tdEmxNWLK7khxgRL+qSH2JTsNSX/QhlRr0TO+xwtk1Ul30ZzUhHQ5fbGDJlG1C1y tR6RAL2vtIh5qUqou+OdzlwFYYOdKhGQxT05LhrKoLdJDdMpBBjIJxERbadlhdL0sHr8 nsHA== X-Gm-Message-State: ALoCoQnF/gQbqYx4/BFd2Ac2lleL6cHSqE/pgXNACEwAhpZ77MaWogzXzMj4xagbJ4EzdD3L14Hj X-Received: by 10.112.85.69 with SMTP id f5mr30381846lbz.23.1436184726862; Mon, 06 Jul 2015 05:12:06 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.1 with SMTP id n1ls581804laa.87.gmail; Mon, 06 Jul 2015 05:12:06 -0700 (PDT) X-Received: by 10.152.5.167 with SMTP id t7mr43290956lat.112.1436184726652; Mon, 06 Jul 2015 05:12:06 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id b5si15113166lbk.87.2015.07.06.05.12.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 05:12:06 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by lagc2 with SMTP id c2so152068069lag.3 for ; Mon, 06 Jul 2015 05:12:06 -0700 (PDT) X-Received: by 10.152.42.177 with SMTP id p17mr48496419lal.29.1436184726394; Mon, 06 Jul 2015 05:12:06 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1684270lbb; Mon, 6 Jul 2015 05:12:05 -0700 (PDT) X-Received: by 10.194.133.73 with SMTP id pa9mr92922172wjb.148.1436184723711; Mon, 06 Jul 2015 05:12:03 -0700 (PDT) Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com. [209.85.212.169]) by mx.google.com with ESMTPS id i7si21338794wiz.121.2015.07.06.05.12.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 05:12:03 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.169 as permitted sender) client-ip=209.85.212.169; Received: by wibdq8 with SMTP id dq8so151299341wib.1 for ; Mon, 06 Jul 2015 05:12:03 -0700 (PDT) X-Received: by 10.194.235.4 with SMTP id ui4mr99979162wjc.0.1436184723349; Mon, 06 Jul 2015 05:12:03 -0700 (PDT) Received: from gnx2579.home (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by mx.google.com with ESMTPSA id v3sm27806709wja.31.2015.07.06.05.12.01 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 05:12:02 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, christoffer.dall@linaro.org, marc.zyngier@arm.com, alex.williamson@redhat.com, pbonzini@redhat.com, avi.kivity@gmail.com, mtosatti@redhat.com, feng.wu@intel.com, joro@8bytes.org, b.reynal@virtualopensystems.com Cc: linux-kernel@vger.kernel.org, patches@linaro.org Subject: [RFC v2 3/6] irq: bypass: Extend skeleton for ARM forwarding control Date: Mon, 6 Jul 2015 14:11:29 +0200 Message-Id: <1436184692-20927-4-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436184692-20927-1-git-send-email-eric.auger@linaro.org> References: <1436184692-20927-1-git-send-email-eric.auger@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , - [add,del]_[consumer,producer] updated to takes both the consumer and producer handles. This is requested to combine info from both, typically to link the source irq owned by the producer with the gsi owned by the consumer (forwarded IRQ setup). - new methods are added: x stop/resume: Those are needed for forwarding since the state change requires to entermingle actions at consumer, producer. x consumer update for posted interrupts - On handshake, we now call connect, disconnect which features the more complex sequence. - add irq on producer side Signed-off-by: Eric Auger --- v1 -> v2: - remove vfio_device, kvm, gsi, opaque fields included in v1 except common - all those in can be retrieved with container_of in callbacks --- include/linux/irqbypass.h | 19 ++++++++++++++++--- kernel/irq/bypass.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 56 insertions(+), 7 deletions(-) diff --git a/include/linux/irqbypass.h b/include/linux/irqbypass.h index 718508e..8f62235 100644 --- a/include/linux/irqbypass.h +++ b/include/linux/irqbypass.h @@ -3,17 +3,30 @@ #include +struct irq_bypass_consumer; + struct irq_bypass_producer { struct list_head node; void *token; - /* TBD */ + int irq; /* linux irq */ + void (*stop)(struct irq_bypass_producer *); + void (*resume)(struct irq_bypass_producer *); + void (*add_consumer)(struct irq_bypass_producer *, + struct irq_bypass_consumer *); + void (*del_consumer)(struct irq_bypass_producer *, + struct irq_bypass_consumer *); }; struct irq_bypass_consumer { struct list_head node; void *token; - void (*add_producer)(struct irq_bypass_producer *); - void (*del_producer)(struct irq_bypass_producer *); + void (*stop)(struct irq_bypass_consumer *); + void (*resume)(struct irq_bypass_consumer *); + void (*add_producer)(struct irq_bypass_consumer *, + struct irq_bypass_producer *); + void (*del_producer)(struct irq_bypass_consumer *, + struct irq_bypass_producer *); + void (*update)(struct irq_bypass_consumer *); }; int irq_bypass_register_producer(struct irq_bypass_producer *); diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c index 5d0f92b..efadbe5 100644 --- a/kernel/irq/bypass.c +++ b/kernel/irq/bypass.c @@ -19,6 +19,42 @@ static LIST_HEAD(producers); static LIST_HEAD(consumers); static DEFINE_MUTEX(lock); +/* lock must be hold when calling connect */ +static void connect(struct irq_bypass_producer *prod, + struct irq_bypass_consumer *cons) +{ + if (prod->stop) + prod->stop(prod); + if (cons->stop) + cons->stop(cons); + if (prod->add_consumer) + prod->add_consumer(prod, cons); + if (cons->add_producer) + cons->add_producer(cons, prod); + if (cons->resume) + cons->resume(cons); + if (prod->resume) + prod->resume(prod); +} + +/* lock must be hold when calling disconnect */ +static void disconnect(struct irq_bypass_producer *prod, + struct irq_bypass_consumer *cons) +{ + if (prod->stop) + prod->stop(prod); + if (cons->stop) + cons->stop(cons); + if (cons->del_producer) + cons->del_producer(cons, prod); + if (prod->del_consumer) + prod->del_consumer(prod, cons); + if (cons->resume) + cons->resume(cons); + if (prod->resume) + prod->resume(prod); +} + int irq_bypass_register_producer(struct irq_bypass_producer *producer) { struct irq_bypass_producer *tmp; @@ -38,7 +74,7 @@ int irq_bypass_register_producer(struct irq_bypass_producer *producer) list_for_each_entry(consumer, &consumers, node) { if (consumer->token == producer->token) { - consumer->add_producer(producer); + connect(producer, consumer); break; } } @@ -56,7 +92,7 @@ void irq_bypass_unregister_producer(struct irq_bypass_producer *producer) list_for_each_entry(consumer, &consumers, node) { if (consumer->token == producer->token) { - consumer->del_producer(producer); + disconnect(producer, consumer); break; } } @@ -86,7 +122,7 @@ int irq_bypass_register_consumer(struct irq_bypass_consumer *consumer) list_for_each_entry(producer, &producers, node) { if (producer->token == consumer->token) { - consumer->add_producer(producer); + connect(producer, consumer); break; } } @@ -104,7 +140,7 @@ void irq_bypass_unregister_consumer(struct irq_bypass_consumer *consumer) list_for_each_entry(producer, &producers, node) { if (producer->token == consumer->token) { - consumer->del_producer(producer); + disconnect(producer, consumer); break; } }