Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1518825ybh; Sun, 8 Mar 2020 06:20:36 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvclaBlea35vmQypk4lsKY2ka1ZpAfOqyHUxdnfrsV+G1IHXKti8SUqqoAAYMUuXnAKaCDD X-Received: by 2002:aca:5408:: with SMTP id i8mr8544345oib.157.1583673636812; Sun, 08 Mar 2020 06:20:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583673636; cv=none; d=google.com; s=arc-20160816; b=GWnlqmXD+NOPY3ylq8k+ssrYYoUeJ/Xl502WaPDcT3lCYyrw0Z0qyHdMPu1RS4Qgpa q+wFZAiJUM0gga9f7hJg2t71SQSP4DIaIfUub7bu4n4UME0UsMXJ30mBCbEFldiH7S3s E5cY4xVJ4TyLUo0kbP/EBj0TuNpDREO9euzuTgWk15CwAeYetvPbGfm90kCTXKofya6d B6EICACUYvdzuKMtt6TO+uxR8TYx99CKYtZ0P4vQQJ3p3zkM188RAi4NZCSV+AwSpRs8 tyLYEK7N0vapcN1U80SCWZn+esro3EC0CGF+2CZ/RUDSbYJ7sS7hArIznEVbth6llPbL 2E5g== 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:cc :to:from:date:dkim-signature; bh=JtE0GdtEt7/HiG2oS0nuHmJGbnr3pvPyW/vanPbcLQY=; b=SbQV3dHYqgusyN9lZ4Bl6JxIW7pf/2EoZgXbwKym7G7WPFe+f/S4E94uNDTcB9ezRu vPirtK+kbZk75KPyz5GrAZk0yUkotOTW6gMRfbrhS1xyvR69EiZsfMuHLEGQlLbCzX/3 /B80+RTVlMipOXxqS62pFnuCY6Scxhl7vFvVtJekTdaW+Ls5LCs9KCuYXq4C2CU9hCoB IRO9E/D+qRSDsOreSYpueP0cyDCyGk+zlOy4AYTAS94o1FpxM9L8ipkZaJBV1yW5Dr2u ozOYI/8qXKgjj5hIKH0aRpSoLPn8bJTRCuQMWHBcfQ/XJW2e+6O2jTPLFH/gGHIqtyB8 185g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p+wh5q8+; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5si4661871otm.88.2020.03.08.06.20.24; Sun, 08 Mar 2020 06:20:36 -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=@gmail.com header.s=20161025 header.b=p+wh5q8+; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726336AbgCHNTv (ORCPT + 99 others); Sun, 8 Mar 2020 09:19:51 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:40831 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726267AbgCHNTv (ORCPT ); Sun, 8 Mar 2020 09:19:51 -0400 Received: by mail-wm1-f68.google.com with SMTP id e26so6991728wme.5 for ; Sun, 08 Mar 2020 06:19:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=JtE0GdtEt7/HiG2oS0nuHmJGbnr3pvPyW/vanPbcLQY=; b=p+wh5q8+v+1S1wIMD6XHhhm0IIIn9o/fOEsKsNUx9IwB/p6NslaqBAkDbaa2J2Etv4 0Cvsb1G9VPt3E5FxC+rx+H512jS68HQebfHiUaIIu1V0LaswF9bKAdJaw+vxa3K1YDO3 hJTFGt6IqxLZQzdfxkbFFeD23dMhqeo3BYnEO5Hj3K5OiMqZhQPdtgW59H+2g9aQs9/Z IZzXMJsCgzP683xnoHaIqv2e/9C7ziDE4VWDe5/arSm3pQCNaOpULJEAn2lsf0FZL/kN sIxSqhi6PuiyI/Z8bcsLMGBVVvepneknq23z9p2PFepNl3tNJ64mgviFpVdn/A23qpA6 /Xlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=JtE0GdtEt7/HiG2oS0nuHmJGbnr3pvPyW/vanPbcLQY=; b=RIkwaeDNVL+e1uuGubt+39AAoaUp0n5apV1AsPwpU2Kb+RLdOx6H+dKjUaPJ51+sJ+ C+yzU3LXCz9oDfL1FLhvor+dXn55JJBPdbcaHbad49MA9qDuCvKRG2y2rkmWn2JcFJOD 0W9WlxB+N6UIzdsVluR6gbQmLb2soIRgtPSzwo6IO08ANZ/h0KPsujLB0gYqdUlEPWvI ApcbyIumlzUd6KlEZDlgrpWZrmM/27kNaypPxb2/t1oEoNYwS5lO9GBi2a2NeUoeVElj ck0B0Rt7MHM+xVB1q3CDxvNkXSDRpQGLBqEOsOD6xZCX8aDmgIyOS4Rs6TMdjSvkF6zW b8jg== X-Gm-Message-State: ANhLgQ2RlL1Pb55IAoitGBHa3BabKeSq3mvreO0Mc6HDrQIJAfX/yeLG EV6Ug4WEWgDDSbhful8VpjA= X-Received: by 2002:a1c:3241:: with SMTP id y62mr11004089wmy.66.1583673588266; Sun, 08 Mar 2020 06:19:48 -0700 (PDT) Received: from kbp1-lhp-F74019 (a81-14-236-68.net-htp.de. [81.14.236.68]) by smtp.gmail.com with ESMTPSA id a26sm22342748wmm.18.2020.03.08.06.19.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 08 Mar 2020 06:19:47 -0700 (PDT) Date: Sun, 8 Mar 2020 15:19:44 +0200 From: Yan Yankovskyi To: Boris Ostrovsky Cc: Jan Beulich , Juergen Gross , Stefano Stabellini , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] xen: Use evtchn_type_t as a type for event channels Message-ID: <20200308131944.GA18740@kbp1-lhp-F74019> References: <20200307134322.GA27756@kbp1-lhp-F74019> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 07, 2020 at 02:41:44PM -0500, Boris Ostrovsky wrote: > > > On 3/7/20 8:43 AM, Yan Yankovskyi wrote: > > Make event channel functions pass event channel port using > > evtchn_port_t type. It eliminates signed <-> unsigned conversion. > > > > > > static int find_virq(unsigned int virq, unsigned int cpu) > > { > > struct evtchn_status status; > > - int port, rc = -ENOENT; > > + evtchn_port_t port; > > + int rc = -ENOENT; > > > > memset(&status, 0, sizeof(status)); > > for (port = 0; port < xen_evtchn_max_channels(); port++) { > > @@ -962,7 +963,8 @@ EXPORT_SYMBOL_GPL(xen_evtchn_nr_channels); > > int bind_virq_to_irq(unsigned int virq, unsigned int cpu, bool percpu) > > { > > struct evtchn_bind_virq bind_virq; > > - int evtchn, irq, ret; > > + evtchn_port_t evtchn = xen_evtchn_max_channels(); > > + int irq, ret; > > > > mutex_lock(&irq_mapping_update_lock); > > > > @@ -990,7 +992,6 @@ int bind_virq_to_irq(unsigned int virq, unsigned int cpu, bool percpu) > > if (ret == -EEXIST) > > ret = find_virq(virq, cpu); > > BUG_ON(ret < 0); > > - evtchn = ret; > > > This looks suspicious. What would you be passing to > xen_irq_info_virq_setup() below? Right, this line should be preserved. > I also think that, given that this patch is trying to get types in > order, find_virq() will need more changes: it is supposed to return > evtchn_port_t. But then it also wants to return a (signed) error. As we don't care which error we got during find_virq call, we can just return 0 in case of error, and port number otherwise. Port 0 is never valid, so this approach can work for the other functions as well. On the other hand, passing port using pointer and returning actual error message, as it's done in xenbus_alloc_evtchn(), sounds like a better approach overall. What do you think? > > } > > > > ret = xen_irq_info_virq_setup(cpu, irq, evtchn, virq); > > @@ -1019,7 +1020,7 @@ static void unbind_from_irq(unsigned int irq) > > mutex_unlock(&irq_mapping_update_lock); > > } > > > > > > > { > > struct evtchn_close close; > > int err; > > @@ -423,7 +423,7 @@ int xenbus_free_evtchn(struct xenbus_device *dev, int port) > > And why not here, especially since you updated format? I missed it. > > > > err = HYPERVISOR_event_channel_op(EVTCHNOP_close, &close); > > if (err) > > - xenbus_dev_error(dev, err, "freeing event channel %d", port); > > + xenbus_dev_error(dev, err, "freeing event channel %u", port); > > > > return err; > > } > > > > > > > diff --git a/include/xen/interface/event_channel.h b/include/xen/interface/event_channel.h > > index 45650c9a06d5..cf80e338fbb0 100644 > > --- a/include/xen/interface/event_channel.h > > +++ b/include/xen/interface/event_channel.h > > @@ -220,7 +220,7 @@ struct evtchn_expand_array { > > #define EVTCHNOP_set_priority 13 > > struct evtchn_set_priority { > > /* IN parameters. */ > > - uint32_t port; > > + evtchn_port_t port; > > This definition comes from Xen so I think it needs to be fixed there first. Will be done. > > --- a/drivers/xen/xenbus/xenbus_client.c > > +++ b/drivers/xen/xenbus/xenbus_client.c > > @@ -391,7 +391,7 @@ EXPORT_SYMBOL_GPL(xenbus_grant_ring); > > * error, the device will switch to XenbusStateClosing, and the error will be > > * saved in the store. > > */ > > -int xenbus_alloc_evtchn(struct xenbus_device *dev, int *port) > > +int xenbus_alloc_evtchn(struct xenbus_device *dev, evtchn_port_t *port) > > Right. But then why is the declaration in include/xen/xenbus.h (at the > very end of the patch) different? > > > { > > struct evtchn_alloc_unbound alloc_unbound; > > int err; > > @@ -414,7 +414,7 @@ EXPORT_SYMBOL_GPL(xenbus_alloc_evtchn); > > /** > > * Free an existing event channel. Returns 0 on success or -errno on error. > > */ > > -int xenbus_free_evtchn(struct xenbus_device *dev, int port) > > +int xenbus_free_evtchn(struct xenbus_device *dev, evtchn_port_t port) > > Here too. > > > uint32_t priority; > > }; > > > > diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h > > index 89a889585ba0..4f35216064ba 100644 > > --- a/include/xen/xenbus.h > > +++ b/include/xen/xenbus.h > > @@ -218,8 +218,8 @@ int xenbus_unmap_ring(struct xenbus_device *dev, > > grant_handle_t *handles, unsigned int nr_handles, > > unsigned long *vaddrs); > > > > -int xenbus_alloc_evtchn(struct xenbus_device *dev, int *port); > > -int xenbus_free_evtchn(struct xenbus_device *dev, int port); > > +int xenbus_alloc_evtchn(struct xenbus_device *dev, unsigned int *port); > > +int xenbus_free_evtchn(struct xenbus_device *dev, unsigned int port); > > These. I was reluctant with inclusion of event channel header into xenbus. Will be fixed. > -boris >