Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3923266ybl; Mon, 3 Feb 2020 09:05:15 -0800 (PST) X-Google-Smtp-Source: APXvYqyZN5UU2P+n/J5Ag5Q1qLk02rstG60ZkPcMmKisKD4UXyNHrbbu1q6JTJG4W6CeDubrWUwM X-Received: by 2002:a54:468a:: with SMTP id k10mr27997oic.3.1580749515394; Mon, 03 Feb 2020 09:05:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580749515; cv=none; d=google.com; s=arc-20160816; b=u0iZGBOGLPW1QWRHxFWlokapdV2E8/i2hHtIyFXNnUkD6Q+v0IrKBkawDh3Z6CDmC5 pPYcCHKATwOlIrmetVMRHh1Fe8Bfj7yovvYNIbqUgIQtxCceYenutu9y8iXLvrfpN7dH SGoZQX/mesU84qmyKLL6yPSRMWukiaQoEBhAJ9qTqdNBSEBQTpyBLh/wo/1sEITwi7Gi e1QEnPhyrM31A/f7Uq7wJY7YPZIDmOzmnMhAkncibPpTyZCJEFDuVVEUUSMdM/YMfOsJ uD/NZBtxKAQzhWZFsHo0ucBDEBsof5iasRAoXI1bhHs2RxxyQmaBbRde4q9qsp+32gws 0fQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=pHZXEZfxcArrJOwFLOO5B25gH5Nf7M6GMePV8H95wz8=; b=S5ApVbcEVubrcFtKZ80FGX0lH4f13ELVGp13MCemrE6EYusknApYc9pmOPntKWyRWe 0bdNHeHKv3hU3w0MLG/p9alWlvCRgiWyyT6Gsv4lh+dfSYRpvYQAikb7E16yAYQW7Yqb hcDRUF49j7xT5pE0gER8YTf30/A1AkiXQD2gWBmQPb826uSmp5iE9ZWCmwwnXYvHXgaU jZn3qWTa5+2MT6yTUpfHA+XC6525AmMt31O4HBMIGOpXtMYbuU3wYgwn21qH/3oMeeZH YWS+nN8XqfJVa+wTLnCdp3/OJb6GwlpNUUvnl8qJFbYGqqtcCBXKsY+kXG3KxtACMXS+ uO2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AN4jrTsY; 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 w2si9465005otk.126.2020.02.03.09.05.01; Mon, 03 Feb 2020 09:05:15 -0800 (PST) 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=AN4jrTsY; 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 S1728471AbgBCOf4 (ORCPT + 99 others); Mon, 3 Feb 2020 09:35:56 -0500 Received: from mail-qv1-f67.google.com ([209.85.219.67]:39481 "EHLO mail-qv1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728090AbgBCOfz (ORCPT ); Mon, 3 Feb 2020 09:35:55 -0500 Received: by mail-qv1-f67.google.com with SMTP id y8so6882741qvk.6; Mon, 03 Feb 2020 06:35:54 -0800 (PST) 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; bh=pHZXEZfxcArrJOwFLOO5B25gH5Nf7M6GMePV8H95wz8=; b=AN4jrTsY0Be0qFeBI9ikRLgxslO22TK9D1lt7ekoGyu3ID/zgEWhSNVupxjTkfAwxZ RyklxvFtDIJzsnMWV9zv2YBMZWMtNgNTSG0RhwM7waizdUZJv4Yolq1UseGtKmfN4AlG 523oxjEUuqbaxJghOAZ2wLYFOObEbNB8BYnW43sb7bdgk+n6zPYYiiGZrSiXYaZAJF5U D4dnArJCuHz5mLrlCfrFE5sAmPQcA6ikoOOc/SmeiOyF6oLimoxK+FiVMdIY1FjMIbbp 0XLFnJjUPmrI4YCpuDOGG2azN0IBRGLHF7Ee7qkkwezHahQF5sj8HAx2FTsGIQDMI92c qHFw== 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; bh=pHZXEZfxcArrJOwFLOO5B25gH5Nf7M6GMePV8H95wz8=; b=Qj4R9ps0BbKwstnXV53H/CEEx9XMMpxoLxXjXK4g2U1mMuMKxkYXQYmwB6ErziT2iV L4KnFG12bTN+Rj8OBTICLdtfoOwSbd76r2F8CETQ4l7SWV7r1vROkkITKOWDmMUv/OLn OgYGoqadk/WIl/ppftN3FTCwc/zA8bqSp/1OYcQob/Kl5dYEtVejNIzq6QmyuM0H5RCc ahpnaTAvnIhaxt81rqeEoG2iKmdFnWEK4y7A381Cy2XIelDCJe/KI36XXXV/zg32NrkX Wh/FfdfE1zO7/gMsRmMHMKujAr9/ve0e9nVdc4+PBmpxwUUtTQBYTzYnnwNWkWp5jvI6 MEjg== X-Gm-Message-State: APjAAAUZIqXn/OnYtzF8R+yPMXpceN7WMd+mNjsQQAbnaBt59ReJsFOR Gdv6gZr75mB/KEo/zSVGjzY= X-Received: by 2002:ad4:4b08:: with SMTP id r8mr23469453qvw.250.1580740554339; Mon, 03 Feb 2020 06:35:54 -0800 (PST) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com. [66.111.4.228]) by smtp.gmail.com with ESMTPSA id y26sm10320882qtc.94.2020.02.03.06.35.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Feb 2020 06:35:53 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id F307E22076; Mon, 3 Feb 2020 09:35:52 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 03 Feb 2020 09:35:53 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrgeejgdeihecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhunhcu hfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucfkphephedvrd duheehrdduuddurdejudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgr ihhlfhhrohhmpegsohhquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqd eiledvgeehtdeigedqudejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhl rdgtohhmsehfihigmhgvrdhnrghmvg X-ME-Proxy: Received: from localhost (unknown [52.155.111.71]) by mail.messagingengine.com (Postfix) with ESMTPA id BFF233060272; Mon, 3 Feb 2020 09:35:50 -0500 (EST) Date: Mon, 3 Feb 2020 22:35:49 +0800 From: Boqun Feng To: Andrew Murray Cc: linux-pci@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Michael Kelley , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Sasha Levin , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, Lorenzo Pieralisi , Andrew Murray , Bjorn Helgaas Subject: Re: [PATCH v2 3/3] PCI: hv: Introduce hv_msi_entry Message-ID: <20200203143549.GG83200@debian-boqun.qqnc3lrjykvubdpftowmye0fmh.lx.internal.cloudapp.net> References: <20200203050313.69247-1-boqun.feng@gmail.com> <20200203050313.69247-4-boqun.feng@gmail.com> <20200203095140.GE20189@big-machine> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200203095140.GE20189@big-machine> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 03, 2020 at 09:51:40AM +0000, Andrew Murray wrote: > On Mon, Feb 03, 2020 at 01:03:13PM +0800, Boqun Feng wrote: > > Add a new structure (hv_msi_entry), which is also defined int tlfs, to > > s/int/in the/ ? > Good catch, will fix. > > describe the msi entry for HVCALL_RETARGET_INTERRUPT. The structure is > > needed because its layout may be different from architecture to > > architecture. > > > > Also add a new generic interface hv_set_msi_address_from_desc() to allow > > different archs to set the msi address from msi_desc. > > > > No functional change, only preparation for the future support of virtual > > PCI on non-x86 architectures. > > > > Signed-off-by: Boqun Feng (Microsoft) > > --- > > arch/x86/include/asm/hyperv-tlfs.h | 11 +++++++++-- > > arch/x86/include/asm/mshyperv.h | 5 +++++ > > drivers/pci/controller/pci-hyperv.c | 4 ++-- > > 3 files changed, 16 insertions(+), 4 deletions(-) > > > > diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h > > index 4a76e442481a..953b3ad38746 100644 > > --- a/arch/x86/include/asm/hyperv-tlfs.h > > +++ b/arch/x86/include/asm/hyperv-tlfs.h > > @@ -912,11 +912,18 @@ struct hv_partition_assist_pg { > > u32 tlb_lock_count; > > }; > > > > +union hv_msi_entry { > > + u64 as_uint64; > > + struct { > > + u32 address; > > + u32 data; > > + } __packed; > > +}; > > + > > struct hv_interrupt_entry { > > u32 source; /* 1 for MSI(-X) */ > > u32 reserved1; > > - u32 address; > > - u32 data; > > + union hv_msi_entry msi_entry; > > } __packed; > > > > /* > > diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h > > index 6b79515abb82..3bdaa3b6e68f 100644 > > --- a/arch/x86/include/asm/mshyperv.h > > +++ b/arch/x86/include/asm/mshyperv.h > > @@ -240,6 +240,11 @@ bool hv_vcpu_is_preempted(int vcpu); > > static inline void hv_apic_init(void) {} > > #endif > > > > +#define hv_set_msi_address_from_desc(msi_entry, msi_desc) \ > > +do { \ > > + (msi_entry)->address = (msi_desc)->msg.address_lo; \ > > +} while (0) > > Given that this is a single statement, is there really a need for the do ; while(0) ? > I choose to use do ; while (0) because I don't want code like the following to be able to compile: hv_set_msi_address_from_desc(...) /* semicolon is missing */ a = b; But now think more about this, I think it's probably better to define this as a function.. > > > + > > #else /* CONFIG_HYPERV */ > > static inline void hyperv_init(void) {} > > static inline void hyperv_setup_mmu_ops(void) {} > > diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c > > index 0d9b74503577..2240f2b3643e 100644 > > --- a/drivers/pci/controller/pci-hyperv.c > > +++ b/drivers/pci/controller/pci-hyperv.c > > @@ -1170,8 +1170,8 @@ static void hv_irq_unmask(struct irq_data *data) > > memset(params, 0, sizeof(*params)); > > params->partition_id = HV_PARTITION_ID_SELF; > > params->int_entry.source = 1; /* MSI(-X) */ > > - params->int_entry.address = msi_desc->msg.address_lo; > > - params->int_entry.data = msi_desc->msg.data; > > + hv_set_msi_address_from_desc(¶ms->int_entry.msi_entry, msi_desc); > > + params->int_entry.msi_entry.data = msi_desc->msg.data; > > If the layout may differ, then don't we also need a wrapper for data? > On x86 hv_msi_entry is: { u32 address; u32 data; } and on ARM64 it is: { u64 address; u32 data; u32 reserved; } So currently, setting msi_entry.data doesn't need a wrapper for different archs. But now you mention it, probably a better way is to provide a wrapper hv_set_msi_entry_from_desc(), which sets both address and data instead of hv_set_msi_address_from_desc(). Thanks for looking into the whole patchset! Regards, Boqun > Thanks, > > Andrew Murray > > > params->device_id = (hbus->hdev->dev_instance.b[5] << 24) | > > (hbus->hdev->dev_instance.b[4] << 16) | > > (hbus->hdev->dev_instance.b[7] << 8) | > > -- > > 2.24.1 > >