From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Huth Subject: Re: [PATCH RFC 09/15] pci: Add pci_bar_set() Date: Wed, 13 Apr 2016 17:01:26 +0200 Message-ID: <570E5F46.8070302@redhat.com> References: <6f9eacb97be8b97e89c4d630ccc6795e8a6bc47d.1460190352.git.agordeev@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Andrew Jones To: Alexander Gordeev , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:55260 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759042AbcDMPBa (ORCPT ); Wed, 13 Apr 2016 11:01:30 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7E14E63165 for ; Wed, 13 Apr 2016 15:01:29 +0000 (UTC) In-Reply-To: <6f9eacb97be8b97e89c4d630ccc6795e8a6bc47d.1460190352.git.agordeev@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 11.04.2016 13:04, Alexander Gordeev wrote: > Cc: Thomas Huth > Cc: Andrew Jones > Signed-off-by: Alexander Gordeev > --- > lib/pci.c | 8 ++++++++ > lib/pci.h | 1 + > 2 files changed, 9 insertions(+) > > diff --git a/lib/pci.c b/lib/pci.c > index 43e9c0c38434..46aee60e0f90 100644 > --- a/lib/pci.c > +++ b/lib/pci.c > @@ -84,6 +84,14 @@ phys_addr_t pci_bar_size(pcidevaddr_t dev, int bar_num) > } > } > > +void pci_bar_set(pcidevaddr_t dev, int bar_num, uint64_t addr) > +{ > + int off = PCI_BASE_ADDRESS_0 + bar_num * 4; > + pci_config_writel(dev, off, (uint32_t)addr); > + if (pci_bar_is64(dev, bar_num)) > + pci_config_writel(dev, (uint32_t)(addr >> 32), off + 4); > +} > + > bool pci_bar_is_memory(pcidevaddr_t dev, int bar_num) > { > uint32_t bar = pci_config_readl(dev, PCI_BASE_ADDRESS_0 + bar_num * 4); > diff --git a/lib/pci.h b/lib/pci.h > index 09b500ea19f0..69d2a62f1b32 100644 > --- a/lib/pci.h > +++ b/lib/pci.h > @@ -15,6 +15,7 @@ enum { > PCIDEVADDR_INVALID = 0xffff, > }; > pcidevaddr_t pci_find_dev(uint16_t vendor_id, uint16_t device_id); > +void pci_bar_set(pcidevaddr_t dev, int bar_num, uint64_t addr); > phys_addr_t pci_bar_addr(pcidevaddr_t dev, int bar_num); > phys_addr_t pci_bar_size(pcidevaddr_t dev, int bar_num); > bool pci_bar_is64(pcidevaddr_t dev, int bar_num); > Reviewed-by: Thomas Huth