Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp347401ybh; Mon, 9 Mar 2020 23:22:39 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtn1vzEJYnNrTJ17tiV1PRKwhRr93HVbQw8vp7/pCbEIp+JnBHm1EosizFCy8T8mulG0j/z X-Received: by 2002:a9d:750d:: with SMTP id r13mr4930952otk.321.1583821359387; Mon, 09 Mar 2020 23:22:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583821359; cv=none; d=google.com; s=arc-20160816; b=gJbBsbaWiYs48ABXf9YEvQ13mZxiJnR4wvfo+dP1yqoGPl4YDHvk1ev3h30RaXDqZh 33jcbAybwCyrlH/d6aHO21B/Z7/vX2jQ+CD1R/H+Jy0ClwcFAiFeF8KZqLhptW/WXxnp RyuaU+Wz7R/JYor/YJVr4dY2BL3aEX4lg0tro34W4MARWW8+uPQOLDc8JiSlchghRxGQ ax5towZrWYftnCWKTq1Zke2xMgFwD/AdlMBby3iPoq63u0CJSIp2Wu4S7yssmwuvmDx2 R6qEDvYFNH7FWwP1Xszq/dotMatoXeqQx0msq60ya+vGgLce5/2xc95F3bN3uiPvDrjs cMJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=8bzqofIcPY4kQAcdiidiAtLF8Psx4Yn25+oiPMXQdls=; b=bbLMzeiGr8VqjOhjjXms8RamhQdv3hYOgYR3go7Dcs0zeetB+v4dsBjjDkWemq8iQc /T62HEL6V+4G074hoohfbIjPzsM63NfD3mGWStTF+GBczYRVesON9is0y6DpS/88TSZm hZspJf8tU2B1FjS6p6JdLvxA0KSrWwkGjDslbON1qAO4CYP6L+33v+mG6HQ0qbanco4o wgfw2Tr7bR9J9s2W9uPKv9UpxykDoGfM/0bRu+qtgRzQzLrGwVP8V9cgmPW9R70knmmx IDZIGmq0tVVGyzN4syq89ifdi9EpDGbO+ENP9sg+lNY2WhZBbvOvYpr3kZuvv8QiejVv f7jw== 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 e6si4710432oig.223.2020.03.09.23.22.27; Mon, 09 Mar 2020 23:22:39 -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 S1726293AbgCJGWC (ORCPT + 99 others); Tue, 10 Mar 2020 02:22:02 -0400 Received: from mx2.suse.de ([195.135.220.15]:38100 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726252AbgCJGWB (ORCPT ); Tue, 10 Mar 2020 02:22:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CC0BBB35A; Tue, 10 Mar 2020 06:21:59 +0000 (UTC) Subject: Re: [PATCH v2] xen: Use evtchn_type_t as a type for event channels To: Yan Yankovskyi , Boris Ostrovsky Cc: Jan Beulich , Stefano Stabellini , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org References: <20200307134322.GA27756@kbp1-lhp-F74019> <20200308131944.GA18740@kbp1-lhp-F74019> From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Message-ID: Date: Tue, 10 Mar 2020 07:21:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200308131944.GA18740@kbp1-lhp-F74019> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08.03.20 14:19, Yan Yankovskyi wrote: > 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? You can use the same approach as Xen tools do and define something like: typedef int evtchn_port_or_error_t; Juergen