Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3602921ybl; Mon, 3 Feb 2020 03:19:45 -0800 (PST) X-Google-Smtp-Source: APXvYqzJgZgp2pTN4+R1AZkp2imVFU17YwUTQuvYb031I1z6yIxX7J9TItVeg9z6IVfseEahWaup X-Received: by 2002:a05:6830:22cc:: with SMTP id q12mr17850019otc.110.1580728784937; Mon, 03 Feb 2020 03:19:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580728784; cv=none; d=google.com; s=arc-20160816; b=Pt7W/pNG+RvsYkfkWSac3S9Rev+aVsoWHRcHW00kQZLPFjXY4cB7WatsgXtN7dNlWF VZzsKYpdcr9TRQ65UVf4BnfeFbZwiH2mlaLbOn9dotK1EfO7+xkA6dx6zjmQ9VsW80+r YytmjEZl/VWzojPWiA6BBLDBKKDGp2SrQH/LFt5D/vrHeMoILWp4CXfgEcgDyLSb5Wiy 1t1NKH9h/8CFRdbv25YmS+Pq6okq564KwmkflykUAZmwsLc2DFpb/l/S/D2n8Vg7F3Pd aB+JeSgbPJ1qQpzSeikPRpwlDnsg1XABrihhfNk4vL2eiD80LLmWWaSz/lQTZhKCKoa5 kVkg== 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=rnDPBSUuVuYgxfTH/LE+fCmpX3/NqS6sW9R93j88kKg=; b=rQ9ZwDFMMT8ZuLsMgigk12ScMyX2UOn2VEmqn+hCpTxjk/sgx/Rzt2vFe4k0CxD+aN dFNQ1MxbhL97SHIGYnsxuEOXF+cQ9DioRbgSzzg7NmAK7OrUtdyA49kBcu9kM6zykwQ8 4alZ8MvFV0//UqKtagPZdetI2N+2P92yEHVE7gEaaX1ax09ILHLTgcq0esbPeirt6ESU IwTADcDTdF6bu/sBXKZwDRvzzr+LrpqFk5xsQF7eZ617i3J083r7wy1Db2vWOTWqOkjy mLZQnhLsGvjNHchhBPHEXnILHgphe7jYrWeOgkxOARCp/dmRlrvvaVj5nOvAiLujRgJD MNPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@thegoodpenguin-co-uk.20150623.gappssmtp.com header.s=20150623 header.b=CPpgzeMv; 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 d199si8521884oib.135.2020.02.03.03.19.33; Mon, 03 Feb 2020 03:19:44 -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=@thegoodpenguin-co-uk.20150623.gappssmtp.com header.s=20150623 header.b=CPpgzeMv; 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 S1727180AbgBCJvp (ORCPT + 99 others); Mon, 3 Feb 2020 04:51:45 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:44247 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726268AbgBCJvp (ORCPT ); Mon, 3 Feb 2020 04:51:45 -0500 Received: by mail-wr1-f66.google.com with SMTP id m16so17060964wrx.11 for ; Mon, 03 Feb 2020 01:51:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thegoodpenguin-co-uk.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=rnDPBSUuVuYgxfTH/LE+fCmpX3/NqS6sW9R93j88kKg=; b=CPpgzeMv6frDZeN7Ohf8Ni6aGL9A7BPf33E1PJD2dRObj80331n8Tq2PNB26N3uflb v9XTi3vrj3ujEYXIplN6/HZBrorzao1cmnSQi44JxS3QX/7z9dFujRdPvBiGo1NcQXTO AHWfYj4HJylTEAucXZWvYAKMaKJfFZWOq14wL5mPKmOZlY86fUtKOyMu8uws9LgHG8Qj 2EAlBBbFhM1XtHjw0KrqvrlqeQB5+4Iusl/A7bEqPeIvYsmjcYW3Cj3LH6i3v5EJpKMY k+JfJnBM/NxsO0ke0m6V+TCXaADzCwbqK4KVb4EU08drZwMQsMJZ/dYnmsfdmAX2rTZu VYzA== 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=rnDPBSUuVuYgxfTH/LE+fCmpX3/NqS6sW9R93j88kKg=; b=HLUKrzZjaBXTDT8W6nLKR3zGOlR+5FBv+/1o3mMJIXvXnrXKn208zds9TIVsLyzBCF KHVGVo0pIZYOyv1TlyeF28T4rSOFbqgFeIblb/8VzocFEo94qAae0DKHpKS3QZ585o6g b5rU5go0zMN6JcmeGynzP+9NwkBReBR9R/O8PBLRg1zgNdy9AiQvoT61cTgAtB/m3q03 a9DuXkdDuRz4nK4lN43aVxK5EiCTKWMyAkLTkVAlogg/ZTjszZhe1nfBIyBQtXTTRoaM 6rhvR1e21kK5WN94ig0th9mTWcYCZ2oZUura5Vi4xRnBzho8DQbJ9wNJbpO3gGT3NLVX IoCA== X-Gm-Message-State: APjAAAXnJ+vkcci4PcmTVpoKRexwnMJYwBPjyRosY5XXSlFNFG+yEyMk ngPqukIa0mI4JAMjE0zK0hDnGQ== X-Received: by 2002:adf:ca07:: with SMTP id o7mr14000110wrh.49.1580723502887; Mon, 03 Feb 2020 01:51:42 -0800 (PST) Received: from big-machine ([2a00:23c5:dd80:8400:459c:4174:f0ee:1b26]) by smtp.gmail.com with ESMTPSA id t1sm23821080wma.43.2020.02.03.01.51.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 01:51:41 -0800 (PST) Date: Mon, 3 Feb 2020 09:51:40 +0000 From: Andrew Murray To: Boqun Feng 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: <20200203095140.GE20189@big-machine> References: <20200203050313.69247-1-boqun.feng@gmail.com> <20200203050313.69247-4-boqun.feng@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200203050313.69247-4-boqun.feng@gmail.com> 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 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/ ? > 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) ? > + > #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? 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 >