Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5B80C433E1 for ; Tue, 25 Aug 2020 13:50:02 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C27C420738 for ; Tue, 25 Aug 2020 13:50:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C27C420738 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kAZKW-0007rP-45; Tue, 25 Aug 2020 13:49:40 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kAZKU-0007rK-28 for xen-devel@lists.xenproject.org; Tue, 25 Aug 2020 13:49:38 +0000 X-Inumbo-ID: a34f89d9-b800-4417-9ce8-dc21ea39430b Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id a34f89d9-b800-4417-9ce8-dc21ea39430b; Tue, 25 Aug 2020 13:49:35 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 93F46ADD6; Tue, 25 Aug 2020 13:50:05 +0000 (UTC) Subject: Re: [PATCH 0/2] Xen: Use a dedicated pointer for IRQ data To: Thomas Gleixner , Stefano Stabellini Cc: Sergei Temerkhanov , xen-devel@lists.xenproject.org References: <20200821071547.18894-1-s.temerkhanov@gmail.com> <871rjzsqyy.fsf@nanos.tec.linutronix.de> <87k0xn5cgl.fsf@nanos.tec.linutronix.de> From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Message-ID: Date: Tue, 25 Aug 2020 15:49:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <87k0xn5cgl.fsf@nanos.tec.linutronix.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 25.08.20 10:58, Thomas Gleixner wrote: > On Mon, Aug 24 2020 at 20:14, Stefano Stabellini wrote: >> On Fri, 21 Aug 2020, Thomas Gleixner wrote: >>> are accessors to handler_data. Am I missing something? >> I think Juergen's suggestion was to use function pointers as accessors. >> >> The underlying problem is that both Xen and GPIO want to use >> handler_data. >> >> Xen comes first and uses handler_data to handle Xen events >> (drivers/xen/events/events_base.c:xen_irq_init). >> >> Then, the GPIO driver probe function >> (drivers/pinctrl/intel/pinctrl-baytrail.c:byt_gpio_probe) calls >> gpiochip_set_chained_irqchip, which eventually calls >> irq_set_chained_handler_and_data, overwriting handler_data without >> checks. >> >> Juergen's suggestion is to replace irq_set_handler_data and >> irq_get_handler_data with function pointers. >> >> Xen could install its own irq_set_handler_data and irq_get_handler_data >> functions. The Xen implementation would take care of saving other >> handler_data pointers on request: when the GPIO driver calls >> irq_set_chained_handler_and_data it would end up calling the Xen >> implementation of the set_handler_data function that would store the >> GPIO pointer in a Xen struct somewhere. > > I don't think that's a good idea. The point is that we have an irq chip > which wants to have per interrupt data and then an interrupt request > which wants that as well. > > Conceptually they are distinct. One belongs to the irq chip and one to > the handler. > > So the straight forward solution is to switch XEN to use the > irqdesc::irq_data::chip_data instead of > irqdesc::irq_data_common::handler_data. Of course. I must have been blind not to spot chip_data to exist. > > Something like the completely untested below. A short test showed no problems. Would you mind sending it as a proper patch? You can add my Reviewed-by: Juergen Gross Juergen > > Thanks, > > tglx > --- > drivers/xen/events/events_base.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > --- a/drivers/xen/events/events_base.c > +++ b/drivers/xen/events/events_base.c > @@ -156,7 +156,7 @@ int get_evtchn_to_irq(evtchn_port_t evtc > /* Get info for IRQ */ > struct irq_info *info_for_irq(unsigned irq) > { > - return irq_get_handler_data(irq); > + return irq_get_chip_data(irq); > } > > /* Constructors for packed IRQ information. */ > @@ -377,7 +377,7 @@ static void xen_irq_init(unsigned irq) > info->type = IRQT_UNBOUND; > info->refcnt = -1; > > - irq_set_handler_data(irq, info); > + irq_set_chip_data(irq, info); > > list_add_tail(&info->list, &xen_irq_list_head); > } > @@ -426,14 +426,14 @@ static int __must_check xen_allocate_irq > > static void xen_free_irq(unsigned irq) > { > - struct irq_info *info = irq_get_handler_data(irq); > + struct irq_info *info = irq_get_chip_data(irq); > > if (WARN_ON(!info)) > return; > > list_del(&info->list); > > - irq_set_handler_data(irq, NULL); > + irq_set_chip_data(irq, NULL); > > WARN_ON(info->refcnt > 0); > > @@ -603,7 +603,7 @@ EXPORT_SYMBOL_GPL(xen_irq_from_gsi); > static void __unbind_from_irq(unsigned int irq) > { > evtchn_port_t evtchn = evtchn_from_irq(irq); > - struct irq_info *info = irq_get_handler_data(irq); > + struct irq_info *info = irq_get_chip_data(irq); > > if (info->refcnt > 0) { > info->refcnt--; > @@ -1108,7 +1108,7 @@ int bind_ipi_to_irqhandler(enum ipi_vect > > void unbind_from_irqhandler(unsigned int irq, void *dev_id) > { > - struct irq_info *info = irq_get_handler_data(irq); > + struct irq_info *info = irq_get_chip_data(irq); > > if (WARN_ON(!info)) > return; > @@ -1142,7 +1142,7 @@ int evtchn_make_refcounted(evtchn_port_t > if (irq == -1) > return -ENOENT; > > - info = irq_get_handler_data(irq); > + info = irq_get_chip_data(irq); > > if (!info) > return -ENOENT; > @@ -1170,7 +1170,7 @@ int evtchn_get(evtchn_port_t evtchn) > if (irq == -1) > goto done; > > - info = irq_get_handler_data(irq); > + info = irq_get_chip_data(irq); > > if (!info) > goto done; >