2012-06-27 04:50:44 +00:00
|
|
|
/*
|
|
|
|
* QEMU sPAPR IOMMU (TCE) code
|
|
|
|
*
|
|
|
|
* Copyright (c) 2010 David Gibson, IBM Corporation <dwg@au1.ibm.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2020-10-23 12:44:24 +00:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2012-06-27 04:50:44 +00:00
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2019-05-23 14:35:07 +00:00
|
|
|
|
2016-01-26 18:16:58 +00:00
|
|
|
#include "qemu/osdep.h"
|
2016-06-01 08:57:33 +00:00
|
|
|
#include "qemu/error-report.h"
|
2015-12-15 12:16:16 +00:00
|
|
|
#include "qemu/log.h"
|
2019-05-23 14:35:07 +00:00
|
|
|
#include "qemu/module.h"
|
2012-12-17 17:20:04 +00:00
|
|
|
#include "sysemu/kvm.h"
|
2012-06-27 04:50:44 +00:00
|
|
|
#include "kvm_ppc.h"
|
2019-08-12 05:23:45 +00:00
|
|
|
#include "migration/vmstate.h"
|
2012-12-17 17:20:04 +00:00
|
|
|
#include "sysemu/dma.h"
|
2012-12-17 17:19:49 +00:00
|
|
|
#include "exec/address-spaces.h"
|
2013-08-29 08:05:00 +00:00
|
|
|
#include "trace.h"
|
2012-06-27 04:50:44 +00:00
|
|
|
|
2013-02-05 16:06:20 +00:00
|
|
|
#include "hw/ppc/spapr.h"
|
2015-01-29 05:04:58 +00:00
|
|
|
#include "hw/ppc/spapr_vio.h"
|
2012-06-27 04:50:44 +00:00
|
|
|
|
|
|
|
#include <libfdt.h>
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
enum SpaprTceAccess {
|
2012-06-27 04:50:44 +00:00
|
|
|
SPAPR_TCE_FAULT = 0,
|
|
|
|
SPAPR_TCE_RO = 1,
|
|
|
|
SPAPR_TCE_WO = 2,
|
|
|
|
SPAPR_TCE_RW = 3,
|
|
|
|
};
|
|
|
|
|
2014-05-27 05:36:36 +00:00
|
|
|
#define IOMMU_PAGE_SIZE(shift) (1ULL << (shift))
|
|
|
|
#define IOMMU_PAGE_MASK(shift) (~(IOMMU_PAGE_SIZE(shift) - 1))
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
static QLIST_HEAD(, SpaprTceTable) spapr_tce_tables;
|
2012-06-27 04:50:44 +00:00
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
SpaprTceTable *spapr_tce_find_by_liobn(target_ulong liobn)
|
2012-06-27 04:50:44 +00:00
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
SpaprTceTable *tcet;
|
2012-06-27 04:50:44 +00:00
|
|
|
|
2013-04-29 18:33:51 +00:00
|
|
|
if (liobn & 0xFFFFFFFF00000000ULL) {
|
|
|
|
hcall_dprintf("Request for out-of-bounds LIOBN 0x" TARGET_FMT_lx "\n",
|
|
|
|
liobn);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-06-27 04:50:44 +00:00
|
|
|
QLIST_FOREACH(tcet, &spapr_tce_tables, list) {
|
2015-05-07 05:33:38 +00:00
|
|
|
if (tcet->liobn == (uint32_t)liobn) {
|
2012-06-27 04:50:44 +00:00
|
|
|
return tcet;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-07-02 06:23:12 +00:00
|
|
|
static IOMMUAccessFlags spapr_tce_iommu_access_flags(uint64_t tce)
|
|
|
|
{
|
|
|
|
switch (tce & SPAPR_TCE_RW) {
|
|
|
|
case SPAPR_TCE_FAULT:
|
|
|
|
return IOMMU_NONE;
|
|
|
|
case SPAPR_TCE_RO:
|
|
|
|
return IOMMU_RO;
|
|
|
|
case SPAPR_TCE_WO:
|
|
|
|
return IOMMU_WO;
|
|
|
|
default: /* SPAPR_TCE_RW */
|
|
|
|
return IOMMU_RW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-04 06:52:19 +00:00
|
|
|
static uint64_t *spapr_tce_alloc_table(uint32_t liobn,
|
|
|
|
uint32_t page_shift,
|
2017-03-10 01:41:13 +00:00
|
|
|
uint64_t bus_offset,
|
2016-05-04 06:52:19 +00:00
|
|
|
uint32_t nb_table,
|
|
|
|
int *fd,
|
|
|
|
bool need_vfio)
|
|
|
|
{
|
|
|
|
uint64_t *table = NULL;
|
|
|
|
|
2017-03-10 01:41:13 +00:00
|
|
|
if (kvm_enabled()) {
|
|
|
|
table = kvmppc_create_spapr_tce(liobn, page_shift, bus_offset, nb_table,
|
|
|
|
fd, need_vfio);
|
2016-05-04 06:52:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!table) {
|
|
|
|
*fd = -1;
|
2018-11-27 13:05:18 +00:00
|
|
|
table = g_new0(uint64_t, nb_table);
|
2016-05-04 06:52:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
trace_spapr_iommu_new_table(liobn, table, *fd);
|
|
|
|
|
|
|
|
return table;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void spapr_tce_free_table(uint64_t *table, int fd, uint32_t nb_table)
|
|
|
|
{
|
|
|
|
if (!kvm_enabled() ||
|
|
|
|
(kvmppc_remove_spapr_tce(table, fd, nb_table) != 0)) {
|
|
|
|
g_free(table);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-21 11:09:14 +00:00
|
|
|
/* Called from RCU critical section */
|
2017-07-11 03:56:19 +00:00
|
|
|
static IOMMUTLBEntry spapr_tce_translate_iommu(IOMMUMemoryRegion *iommu,
|
|
|
|
hwaddr addr,
|
2018-06-15 13:57:16 +00:00
|
|
|
IOMMUAccessFlags flag,
|
|
|
|
int iommu_idx)
|
2012-06-27 04:50:44 +00:00
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
SpaprTceTable *tcet = container_of(iommu, SpaprTceTable, iommu);
|
2012-06-27 04:50:44 +00:00
|
|
|
uint64_t tce;
|
2013-08-29 08:05:00 +00:00
|
|
|
IOMMUTLBEntry ret = {
|
|
|
|
.target_as = &address_space_memory,
|
|
|
|
.iova = 0,
|
|
|
|
.translated_addr = 0,
|
|
|
|
.addr_mask = ~(hwaddr)0,
|
|
|
|
.perm = IOMMU_NONE,
|
|
|
|
};
|
2012-06-27 04:50:44 +00:00
|
|
|
|
2015-01-29 05:04:58 +00:00
|
|
|
if ((addr >> tcet->page_shift) < tcet->nb_table) {
|
2013-08-29 08:05:00 +00:00
|
|
|
/* Check if we are in bound */
|
2014-05-27 05:36:36 +00:00
|
|
|
hwaddr page_mask = IOMMU_PAGE_MASK(tcet->page_shift);
|
|
|
|
|
|
|
|
tce = tcet->table[addr >> tcet->page_shift];
|
|
|
|
ret.iova = addr & page_mask;
|
|
|
|
ret.translated_addr = tce & page_mask;
|
|
|
|
ret.addr_mask = ~page_mask;
|
2015-07-02 06:23:12 +00:00
|
|
|
ret.perm = spapr_tce_iommu_access_flags(tce);
|
2012-06-27 04:50:44 +00:00
|
|
|
}
|
2019-08-12 05:42:02 +00:00
|
|
|
trace_spapr_iommu_xlate(tcet->liobn, addr, ret.translated_addr, ret.perm,
|
2013-08-29 08:05:00 +00:00
|
|
|
ret.addr_mask);
|
2012-06-27 04:50:44 +00:00
|
|
|
|
2013-08-29 08:05:00 +00:00
|
|
|
return ret;
|
2013-04-16 13:05:06 +00:00
|
|
|
}
|
|
|
|
|
2019-03-07 05:05:16 +00:00
|
|
|
static void spapr_tce_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n)
|
|
|
|
{
|
|
|
|
MemoryRegion *mr = MEMORY_REGION(iommu_mr);
|
|
|
|
IOMMUMemoryRegionClass *imrc = IOMMU_MEMORY_REGION_GET_CLASS(iommu_mr);
|
|
|
|
hwaddr addr, granularity;
|
|
|
|
IOMMUTLBEntry iotlb;
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
SpaprTceTable *tcet = container_of(iommu_mr, SpaprTceTable, iommu);
|
2019-03-07 05:05:16 +00:00
|
|
|
|
|
|
|
if (tcet->skipping_replay) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
granularity = memory_region_iommu_get_min_page_size(iommu_mr);
|
|
|
|
|
|
|
|
for (addr = 0; addr < memory_region_size(mr); addr += granularity) {
|
|
|
|
iotlb = imrc->translate(iommu_mr, addr, IOMMU_NONE, n->iommu_idx);
|
|
|
|
if (iotlb.perm != IOMMU_NONE) {
|
|
|
|
n->notify(n, &iotlb);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if (2^64 - MR size) < granularity, it's possible to get an
|
|
|
|
* infinite loop here. This should catch such a wraparound.
|
|
|
|
*/
|
|
|
|
if ((addr + granularity) < addr) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-25 11:29:12 +00:00
|
|
|
static int spapr_tce_table_pre_save(void *opaque)
|
2016-06-01 08:57:34 +00:00
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
SpaprTceTable *tcet = SPAPR_TCE_TABLE(opaque);
|
2016-06-01 08:57:34 +00:00
|
|
|
|
|
|
|
tcet->mig_table = tcet->table;
|
|
|
|
tcet->mig_nb_table = tcet->nb_table;
|
|
|
|
|
|
|
|
trace_spapr_iommu_pre_save(tcet->liobn, tcet->mig_nb_table,
|
|
|
|
tcet->bus_offset, tcet->page_shift);
|
2017-09-25 11:29:12 +00:00
|
|
|
|
|
|
|
return 0;
|
2016-06-01 08:57:34 +00:00
|
|
|
}
|
|
|
|
|
2017-07-11 03:56:19 +00:00
|
|
|
static uint64_t spapr_tce_get_min_page_size(IOMMUMemoryRegion *iommu)
|
2016-06-21 01:14:01 +00:00
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
SpaprTceTable *tcet = container_of(iommu, SpaprTceTable, iommu);
|
2016-06-21 01:14:01 +00:00
|
|
|
|
|
|
|
return 1ULL << tcet->page_shift;
|
|
|
|
}
|
|
|
|
|
2018-02-06 18:08:24 +00:00
|
|
|
static int spapr_tce_get_attr(IOMMUMemoryRegion *iommu,
|
|
|
|
enum IOMMUMemoryRegionAttr attr, void *data)
|
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
SpaprTceTable *tcet = container_of(iommu, SpaprTceTable, iommu);
|
2018-02-06 18:08:24 +00:00
|
|
|
|
|
|
|
if (attr == IOMMU_ATTR_SPAPR_TCE_FD && kvmppc_has_cap_spapr_vfio()) {
|
|
|
|
*(int *) data = tcet->fd;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:25:17 +00:00
|
|
|
static int spapr_tce_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
|
|
|
IOMMUNotifierFlag old,
|
|
|
|
IOMMUNotifierFlag new,
|
|
|
|
Error **errp)
|
2016-07-04 03:33:03 +00:00
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
struct SpaprTceTable *tbl = container_of(iommu, SpaprTceTable, iommu);
|
2016-07-04 03:33:03 +00:00
|
|
|
|
2016-09-23 05:02:27 +00:00
|
|
|
if (old == IOMMU_NOTIFIER_NONE && new != IOMMU_NOTIFIER_NONE) {
|
|
|
|
spapr_tce_set_need_vfio(tbl, true);
|
|
|
|
} else if (old != IOMMU_NOTIFIER_NONE && new == IOMMU_NOTIFIER_NONE) {
|
|
|
|
spapr_tce_set_need_vfio(tbl, false);
|
|
|
|
}
|
2019-09-24 08:25:17 +00:00
|
|
|
return 0;
|
2016-07-04 03:33:03 +00:00
|
|
|
}
|
|
|
|
|
2015-01-29 05:04:58 +00:00
|
|
|
static int spapr_tce_table_post_load(void *opaque, int version_id)
|
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
SpaprTceTable *tcet = SPAPR_TCE_TABLE(opaque);
|
2016-06-01 08:57:34 +00:00
|
|
|
uint32_t old_nb_table = tcet->nb_table;
|
|
|
|
uint64_t old_bus_offset = tcet->bus_offset;
|
|
|
|
uint32_t old_page_shift = tcet->page_shift;
|
2015-01-29 05:04:58 +00:00
|
|
|
|
|
|
|
if (tcet->vdev) {
|
|
|
|
spapr_vio_set_bypass(tcet->vdev, tcet->bypass);
|
|
|
|
}
|
|
|
|
|
2016-06-01 08:57:34 +00:00
|
|
|
if (tcet->mig_nb_table != tcet->nb_table) {
|
|
|
|
spapr_tce_table_disable(tcet);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tcet->mig_nb_table) {
|
|
|
|
if (!tcet->nb_table) {
|
|
|
|
spapr_tce_table_enable(tcet, old_page_shift, old_bus_offset,
|
|
|
|
tcet->mig_nb_table);
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(tcet->table, tcet->mig_table,
|
|
|
|
tcet->nb_table * sizeof(tcet->table[0]));
|
|
|
|
|
|
|
|
free(tcet->mig_table);
|
|
|
|
tcet->mig_table = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
trace_spapr_iommu_post_load(tcet->liobn, old_nb_table, tcet->nb_table,
|
|
|
|
tcet->bus_offset, tcet->page_shift);
|
|
|
|
|
2015-01-29 05:04:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-06-01 08:57:34 +00:00
|
|
|
static bool spapr_tce_table_ex_needed(void *opaque)
|
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
SpaprTceTable *tcet = opaque;
|
2016-06-01 08:57:34 +00:00
|
|
|
|
|
|
|
return tcet->bus_offset || tcet->page_shift != 0xC;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const VMStateDescription vmstate_spapr_tce_table_ex = {
|
|
|
|
.name = "spapr_iommu_ex",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.needed = spapr_tce_table_ex_needed,
|
|
|
|
.fields = (VMStateField[]) {
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
VMSTATE_UINT64(bus_offset, SpaprTceTable),
|
|
|
|
VMSTATE_UINT32(page_shift, SpaprTceTable),
|
2016-06-01 08:57:34 +00:00
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2013-07-18 19:32:58 +00:00
|
|
|
static const VMStateDescription vmstate_spapr_tce_table = {
|
|
|
|
.name = "spapr_iommu",
|
2014-05-27 05:36:35 +00:00
|
|
|
.version_id = 2,
|
|
|
|
.minimum_version_id = 2,
|
2016-06-01 08:57:34 +00:00
|
|
|
.pre_save = spapr_tce_table_pre_save,
|
2015-01-29 05:04:58 +00:00
|
|
|
.post_load = spapr_tce_table_post_load,
|
2014-05-27 05:36:35 +00:00
|
|
|
.fields = (VMStateField []) {
|
2013-07-18 19:32:58 +00:00
|
|
|
/* Sanity check */
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
VMSTATE_UINT32_EQUAL(liobn, SpaprTceTable, NULL),
|
2013-07-18 19:32:58 +00:00
|
|
|
|
|
|
|
/* IOMMU state */
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
VMSTATE_UINT32(mig_nb_table, SpaprTceTable),
|
|
|
|
VMSTATE_BOOL(bypass, SpaprTceTable),
|
|
|
|
VMSTATE_VARRAY_UINT32_ALLOC(mig_table, SpaprTceTable, mig_nb_table, 0,
|
2016-06-01 08:57:34 +00:00
|
|
|
vmstate_info_uint64, uint64_t),
|
2013-07-18 19:32:58 +00:00
|
|
|
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
},
|
2016-06-01 08:57:34 +00:00
|
|
|
.subsections = (const VMStateDescription*[]) {
|
|
|
|
&vmstate_spapr_tce_table_ex,
|
|
|
|
NULL
|
|
|
|
}
|
2013-07-18 19:32:58 +00:00
|
|
|
};
|
|
|
|
|
2017-07-25 17:59:06 +00:00
|
|
|
static void spapr_tce_table_realize(DeviceState *dev, Error **errp)
|
2012-06-27 04:50:44 +00:00
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
SpaprTceTable *tcet = SPAPR_TCE_TABLE(dev);
|
2016-06-01 08:57:35 +00:00
|
|
|
Object *tcetobj = OBJECT(tcet);
|
2017-07-25 17:58:40 +00:00
|
|
|
gchar *tmp;
|
2012-06-27 04:50:44 +00:00
|
|
|
|
2016-05-04 06:52:19 +00:00
|
|
|
tcet->fd = -1;
|
2016-06-01 08:57:33 +00:00
|
|
|
tcet->need_vfio = false;
|
2017-07-25 17:58:40 +00:00
|
|
|
tmp = g_strdup_printf("tce-root-%x", tcet->liobn);
|
2016-06-01 08:57:35 +00:00
|
|
|
memory_region_init(&tcet->root, tcetobj, tmp, UINT64_MAX);
|
2017-07-25 17:58:40 +00:00
|
|
|
g_free(tmp);
|
2016-06-01 08:57:35 +00:00
|
|
|
|
2017-07-25 17:58:40 +00:00
|
|
|
tmp = g_strdup_printf("tce-iommu-%x", tcet->liobn);
|
2017-07-11 03:56:20 +00:00
|
|
|
memory_region_init_iommu(&tcet->iommu, sizeof(tcet->iommu),
|
|
|
|
TYPE_SPAPR_IOMMU_MEMORY_REGION,
|
|
|
|
tcetobj, tmp, 0);
|
2017-07-25 17:58:40 +00:00
|
|
|
g_free(tmp);
|
2013-04-11 10:35:33 +00:00
|
|
|
|
2012-06-27 04:50:44 +00:00
|
|
|
QLIST_INSERT_HEAD(&spapr_tce_tables, tcet, list);
|
|
|
|
|
2019-08-28 12:02:32 +00:00
|
|
|
vmstate_register(VMSTATE_IF(tcet), tcet->liobn, &vmstate_spapr_tce_table,
|
2014-05-12 08:46:32 +00:00
|
|
|
tcet);
|
2013-07-18 19:32:58 +00:00
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
void spapr_tce_set_need_vfio(SpaprTceTable *tcet, bool need_vfio)
|
2015-10-01 00:46:10 +00:00
|
|
|
{
|
|
|
|
size_t table_size = tcet->nb_table * sizeof(uint64_t);
|
2017-07-20 07:22:29 +00:00
|
|
|
uint64_t *oldtable;
|
|
|
|
int newfd = -1;
|
2015-10-01 00:46:10 +00:00
|
|
|
|
2017-07-20 07:22:29 +00:00
|
|
|
g_assert(need_vfio != tcet->need_vfio);
|
2015-10-01 00:46:10 +00:00
|
|
|
|
2017-07-20 07:22:29 +00:00
|
|
|
tcet->need_vfio = need_vfio;
|
2015-10-01 00:46:10 +00:00
|
|
|
|
2018-02-06 18:08:24 +00:00
|
|
|
if (!need_vfio || (tcet->fd != -1 && kvmppc_has_cap_spapr_vfio())) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-07-20 07:22:29 +00:00
|
|
|
oldtable = tcet->table;
|
2015-10-01 00:46:10 +00:00
|
|
|
|
2017-07-20 07:22:29 +00:00
|
|
|
tcet->table = spapr_tce_alloc_table(tcet->liobn,
|
|
|
|
tcet->page_shift,
|
|
|
|
tcet->bus_offset,
|
|
|
|
tcet->nb_table,
|
|
|
|
&newfd,
|
|
|
|
need_vfio);
|
|
|
|
memcpy(tcet->table, oldtable, table_size);
|
2015-10-01 00:46:10 +00:00
|
|
|
|
2017-07-20 07:22:29 +00:00
|
|
|
spapr_tce_free_table(oldtable, tcet->fd, tcet->nb_table);
|
2015-10-01 00:46:10 +00:00
|
|
|
|
2017-07-20 07:22:29 +00:00
|
|
|
tcet->fd = newfd;
|
2015-10-01 00:46:10 +00:00
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
SpaprTceTable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn)
|
2013-07-18 19:32:58 +00:00
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
SpaprTceTable *tcet;
|
2017-07-25 17:58:40 +00:00
|
|
|
gchar *tmp;
|
2013-07-18 19:32:58 +00:00
|
|
|
|
|
|
|
if (spapr_tce_find_by_liobn(liobn)) {
|
2016-08-02 17:38:00 +00:00
|
|
|
error_report("Attempted to create TCE table with duplicate"
|
|
|
|
" LIOBN 0x%x", liobn);
|
2013-07-18 19:32:58 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
tcet = SPAPR_TCE_TABLE(object_new(TYPE_SPAPR_TCE_TABLE));
|
|
|
|
tcet->liobn = liobn;
|
|
|
|
|
2017-07-25 17:58:40 +00:00
|
|
|
tmp = g_strdup_printf("tce-table-%x", liobn);
|
qom: Drop parameter @errp of object_property_add() & friends
The only way object_property_add() can fail is when a property with
the same name already exists. Since our property names are all
hardcoded, failure is a programming error, and the appropriate way to
handle it is passing &error_abort.
Same for its variants, except for object_property_add_child(), which
additionally fails when the child already has a parent. Parentage is
also under program control, so this is a programming error, too.
We have a bit over 500 callers. Almost half of them pass
&error_abort, slightly fewer ignore errors, one test case handles
errors, and the remaining few callers pass them to their own callers.
The previous few commits demonstrated once again that ignoring
programming errors is a bad idea.
Of the few ones that pass on errors, several violate the Error API.
The Error ** argument must be NULL, &error_abort, &error_fatal, or a
pointer to a variable containing NULL. Passing an argument of the
latter kind twice without clearing it in between is wrong: if the
first call sets an error, it no longer points to NULL for the second
call. ich9_pm_add_properties(), sparc32_ledma_realize(),
sparc32_dma_realize(), xilinx_axidma_realize(), xilinx_enet_realize()
are wrong that way.
When the one appropriate choice of argument is &error_abort, letting
users pick the argument is a bad idea.
Drop parameter @errp and assert the preconditions instead.
There's one exception to "duplicate property name is a programming
error": the way object_property_add() implements the magic (and
undocumented) "automatic arrayification". Don't drop @errp there.
Instead, rename object_property_add() to object_property_try_add(),
and add the obvious wrapper object_property_add().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200505152926.18877-15-armbru@redhat.com>
[Two semantic rebase conflicts resolved]
2020-05-05 15:29:22 +00:00
|
|
|
object_property_add_child(OBJECT(owner), tmp, OBJECT(tcet));
|
2017-07-25 17:58:40 +00:00
|
|
|
g_free(tmp);
|
2017-07-25 18:00:09 +00:00
|
|
|
object_unref(OBJECT(tcet));
|
2013-07-18 19:32:58 +00:00
|
|
|
|
qdev: Convert bus-less devices to qdev_realize() with Coccinelle
All remaining conversions to qdev_realize() are for bus-less devices.
Coccinelle script:
// only correct for bus-less @dev!
@@
expression errp;
expression dev;
@@
- qdev_init_nofail(dev);
+ qdev_realize(dev, NULL, &error_fatal);
@ depends on !(file in "hw/core/qdev.c") && !(file in "hw/core/bus.c")@
expression errp;
expression dev;
symbol true;
@@
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize(DEVICE(dev), NULL, errp);
@ depends on !(file in "hw/core/qdev.c") && !(file in "hw/core/bus.c")@
expression errp;
expression dev;
symbol true;
@@
- object_property_set_bool(dev, true, "realized", errp);
+ qdev_realize(DEVICE(dev), NULL, errp);
Note that Coccinelle chokes on ARMSSE typedef vs. macro in
hw/arm/armsse.c. Worked around by temporarily renaming the macro for
the spatch run.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-57-armbru@redhat.com>
2020-06-10 05:32:45 +00:00
|
|
|
qdev_realize(DEVICE(tcet), NULL, NULL);
|
2013-07-18 19:32:58 +00:00
|
|
|
|
2013-04-10 15:30:48 +00:00
|
|
|
return tcet;
|
2012-06-27 04:50:44 +00:00
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
void spapr_tce_table_enable(SpaprTceTable *tcet,
|
2016-06-01 08:57:33 +00:00
|
|
|
uint32_t page_shift, uint64_t bus_offset,
|
|
|
|
uint32_t nb_table)
|
|
|
|
{
|
|
|
|
if (tcet->nb_table) {
|
2017-07-12 13:57:41 +00:00
|
|
|
warn_report("trying to enable already enabled TCE table");
|
2016-06-01 08:57:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
tcet->bus_offset = bus_offset;
|
|
|
|
tcet->page_shift = page_shift;
|
|
|
|
tcet->nb_table = nb_table;
|
|
|
|
tcet->table = spapr_tce_alloc_table(tcet->liobn,
|
|
|
|
tcet->page_shift,
|
2017-03-10 01:41:13 +00:00
|
|
|
tcet->bus_offset,
|
2016-06-01 08:57:33 +00:00
|
|
|
tcet->nb_table,
|
|
|
|
&tcet->fd,
|
|
|
|
tcet->need_vfio);
|
|
|
|
|
2017-07-11 03:56:19 +00:00
|
|
|
memory_region_set_size(MEMORY_REGION(&tcet->iommu),
|
2016-06-01 08:57:33 +00:00
|
|
|
(uint64_t)tcet->nb_table << tcet->page_shift);
|
2017-07-11 03:56:19 +00:00
|
|
|
memory_region_add_subregion(&tcet->root, tcet->bus_offset,
|
|
|
|
MEMORY_REGION(&tcet->iommu));
|
2016-06-01 08:57:33 +00:00
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
void spapr_tce_table_disable(SpaprTceTable *tcet)
|
2016-06-01 08:57:33 +00:00
|
|
|
{
|
|
|
|
if (!tcet->nb_table) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-07-11 03:56:19 +00:00
|
|
|
memory_region_del_subregion(&tcet->root, MEMORY_REGION(&tcet->iommu));
|
|
|
|
memory_region_set_size(MEMORY_REGION(&tcet->iommu), 0);
|
2016-06-01 08:57:33 +00:00
|
|
|
|
|
|
|
spapr_tce_free_table(tcet->table, tcet->fd, tcet->nb_table);
|
|
|
|
tcet->fd = -1;
|
|
|
|
tcet->table = NULL;
|
|
|
|
tcet->bus_offset = 0;
|
|
|
|
tcet->page_shift = 0;
|
|
|
|
tcet->nb_table = 0;
|
|
|
|
}
|
|
|
|
|
qdev: Unrealize must not fail
Devices may have component devices and buses.
Device realization may fail. Realization is recursive: a device's
realize() method realizes its components, and device_set_realized()
realizes its buses (which should in turn realize the devices on that
bus, except bus_set_realized() doesn't implement that, yet).
When realization of a component or bus fails, we need to roll back:
unrealize everything we realized so far. If any of these unrealizes
failed, the device would be left in an inconsistent state. Must not
happen.
device_set_realized() lets it happen: it ignores errors in the roll
back code starting at label child_realize_fail.
Since realization is recursive, unrealization must be recursive, too.
But how could a partly failed unrealize be rolled back? We'd have to
re-realize, which can fail. This design is fundamentally broken.
device_set_realized() does not roll back at all. Instead, it keeps
unrealizing, ignoring further errors.
It can screw up even for a device with no buses: if the lone
dc->unrealize() fails, it still unregisters vmstate, and calls
listeners' unrealize() callback.
bus_set_realized() does not roll back either. Instead, it stops
unrealizing.
Fortunately, no unrealize method can fail, as we'll see below.
To fix the design error, drop parameter @errp from all the unrealize
methods.
Any unrealize method that uses @errp now needs an update. This leads
us to unrealize() methods that can fail. Merely passing it to another
unrealize method cannot cause failure, though. Here are the ones that
do other things with @errp:
* virtio_serial_device_unrealize()
Fails when qbus_set_hotplug_handler() fails, but still does all the
other work. On failure, the device would stay realized with its
resources completely gone. Oops. Can't happen, because
qbus_set_hotplug_handler() can't actually fail here. Pass
&error_abort to qbus_set_hotplug_handler() instead.
* hw/ppc/spapr_drc.c's unrealize()
Fails when object_property_del() fails, but all the other work is
already done. On failure, the device would stay realized with its
vmstate registration gone. Oops. Can't happen, because
object_property_del() can't actually fail here. Pass &error_abort
to object_property_del() instead.
* spapr_phb_unrealize()
Fails and bails out when remove_drcs() fails, but other work is
already done. On failure, the device would stay realized with some
of its resources gone. Oops. remove_drcs() fails only when
chassis_from_bus()'s object_property_get_uint() fails, and it can't
here. Pass &error_abort to remove_drcs() instead.
Therefore, no unrealize method can fail before this patch.
device_set_realized()'s recursive unrealization via bus uses
object_property_set_bool(). Can't drop @errp there, so pass
&error_abort.
We similarly unrealize with object_property_set_bool() elsewhere,
always ignoring errors. Pass &error_abort instead.
Several unrealize methods no longer handle errors from other unrealize
methods: virtio_9p_device_unrealize(),
virtio_input_device_unrealize(), scsi_qdev_unrealize(), ...
Much of the deleted error handling looks wrong anyway.
One unrealize methods no longer ignore such errors:
usb_ehci_pci_exit().
Several realize methods no longer ignore errors when rolling back:
v9fs_device_realize_common(), pci_qdev_unrealize(),
spapr_phb_realize(), usb_qdev_realize(), vfio_ccw_realize(),
virtio_device_realize().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200505152926.18877-17-armbru@redhat.com>
2020-05-05 15:29:24 +00:00
|
|
|
static void spapr_tce_table_unrealize(DeviceState *dev)
|
2012-06-27 04:50:44 +00:00
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
SpaprTceTable *tcet = SPAPR_TCE_TABLE(dev);
|
2013-07-18 19:32:58 +00:00
|
|
|
|
2019-08-28 12:02:32 +00:00
|
|
|
vmstate_unregister(VMSTATE_IF(tcet), &vmstate_spapr_tce_table, tcet);
|
2017-07-25 18:00:22 +00:00
|
|
|
|
2013-04-10 15:30:48 +00:00
|
|
|
QLIST_REMOVE(tcet, list);
|
2012-06-27 04:50:44 +00:00
|
|
|
|
2016-06-01 08:57:33 +00:00
|
|
|
spapr_tce_table_disable(tcet);
|
2012-06-27 04:50:44 +00:00
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
MemoryRegion *spapr_tce_get_iommu(SpaprTceTable *tcet)
|
2013-04-11 10:35:33 +00:00
|
|
|
{
|
2016-06-01 08:57:35 +00:00
|
|
|
return &tcet->root;
|
2013-04-11 10:35:33 +00:00
|
|
|
}
|
|
|
|
|
2013-07-18 19:32:58 +00:00
|
|
|
static void spapr_tce_reset(DeviceState *dev)
|
2012-09-12 16:57:14 +00:00
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
SpaprTceTable *tcet = SPAPR_TCE_TABLE(dev);
|
2014-05-27 05:36:35 +00:00
|
|
|
size_t table_size = tcet->nb_table * sizeof(uint64_t);
|
2012-09-12 16:57:14 +00:00
|
|
|
|
2016-08-08 00:06:25 +00:00
|
|
|
if (tcet->nb_table) {
|
|
|
|
memset(tcet->table, 0, table_size);
|
|
|
|
}
|
2012-09-12 16:57:14 +00:00
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
static target_ulong put_tce_emu(SpaprTceTable *tcet, target_ulong ioba,
|
2012-06-27 04:50:46 +00:00
|
|
|
target_ulong tce)
|
|
|
|
{
|
2020-11-16 16:55:03 +00:00
|
|
|
IOMMUTLBEvent event;
|
2014-05-27 05:36:36 +00:00
|
|
|
hwaddr page_mask = IOMMU_PAGE_MASK(tcet->page_shift);
|
2014-05-27 05:36:37 +00:00
|
|
|
unsigned long index = (ioba - tcet->bus_offset) >> tcet->page_shift;
|
2012-06-27 04:50:46 +00:00
|
|
|
|
2014-05-27 05:36:37 +00:00
|
|
|
if (index >= tcet->nb_table) {
|
2013-04-29 18:33:52 +00:00
|
|
|
hcall_dprintf("spapr_vio_put_tce on out-of-bounds IOBA 0x"
|
2012-06-27 04:50:46 +00:00
|
|
|
TARGET_FMT_lx "\n", ioba);
|
|
|
|
return H_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2014-05-27 05:36:37 +00:00
|
|
|
tcet->table[index] = tce;
|
2012-06-27 04:50:46 +00:00
|
|
|
|
2020-11-16 16:55:03 +00:00
|
|
|
event.entry.target_as = &address_space_memory,
|
|
|
|
event.entry.iova = (ioba - tcet->bus_offset) & page_mask;
|
|
|
|
event.entry.translated_addr = tce & page_mask;
|
|
|
|
event.entry.addr_mask = ~page_mask;
|
|
|
|
event.entry.perm = spapr_tce_iommu_access_flags(tce);
|
|
|
|
event.type = event.entry.perm ? IOMMU_NOTIFIER_MAP : IOMMU_NOTIFIER_UNMAP;
|
|
|
|
memory_region_notify_iommu(&tcet->iommu, 0, event);
|
2013-04-11 10:35:33 +00:00
|
|
|
|
2012-06-27 04:50:46 +00:00
|
|
|
return H_SUCCESS;
|
|
|
|
}
|
2012-06-27 04:50:44 +00:00
|
|
|
|
2014-05-27 05:36:30 +00:00
|
|
|
static target_ulong h_put_tce_indirect(PowerPCCPU *cpu,
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
SpaprMachineState *spapr,
|
2014-05-27 05:36:30 +00:00
|
|
|
target_ulong opcode, target_ulong *args)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
target_ulong liobn = args[0];
|
|
|
|
target_ulong ioba = args[1];
|
|
|
|
target_ulong ioba1 = ioba;
|
|
|
|
target_ulong tce_list = args[2];
|
|
|
|
target_ulong npages = args[3];
|
2015-05-07 05:33:29 +00:00
|
|
|
target_ulong ret = H_PARAMETER, tce = 0;
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
SpaprTceTable *tcet = spapr_tce_find_by_liobn(liobn);
|
2014-05-27 05:36:30 +00:00
|
|
|
CPUState *cs = CPU(cpu);
|
2014-05-27 05:36:36 +00:00
|
|
|
hwaddr page_mask, page_size;
|
2014-05-27 05:36:30 +00:00
|
|
|
|
|
|
|
if (!tcet) {
|
|
|
|
return H_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2014-05-27 05:36:36 +00:00
|
|
|
if ((npages > 512) || (tce_list & SPAPR_TCE_PAGE_MASK)) {
|
2014-05-27 05:36:30 +00:00
|
|
|
return H_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2014-05-27 05:36:36 +00:00
|
|
|
page_mask = IOMMU_PAGE_MASK(tcet->page_shift);
|
|
|
|
page_size = IOMMU_PAGE_SIZE(tcet->page_shift);
|
|
|
|
ioba &= page_mask;
|
|
|
|
|
|
|
|
for (i = 0; i < npages; ++i, ioba += page_size) {
|
2015-07-02 06:23:11 +00:00
|
|
|
tce = ldq_be_phys(cs->as, tce_list + i * sizeof(target_ulong));
|
2014-05-27 05:36:30 +00:00
|
|
|
|
|
|
|
ret = put_tce_emu(tcet, ioba, tce);
|
|
|
|
if (ret) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Trace last successful or the first problematic entry */
|
|
|
|
i = i ? (i - 1) : 0;
|
2015-05-07 05:33:33 +00:00
|
|
|
if (SPAPR_IS_PCI_LIOBN(liobn)) {
|
|
|
|
trace_spapr_iommu_pci_indirect(liobn, ioba1, tce_list, i, tce, ret);
|
|
|
|
} else {
|
|
|
|
trace_spapr_iommu_indirect(liobn, ioba1, tce_list, i, tce, ret);
|
|
|
|
}
|
2014-05-27 05:36:30 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
static target_ulong h_stuff_tce(PowerPCCPU *cpu, SpaprMachineState *spapr,
|
2014-05-27 05:36:30 +00:00
|
|
|
target_ulong opcode, target_ulong *args)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
target_ulong liobn = args[0];
|
|
|
|
target_ulong ioba = args[1];
|
|
|
|
target_ulong tce_value = args[2];
|
|
|
|
target_ulong npages = args[3];
|
|
|
|
target_ulong ret = H_PARAMETER;
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
SpaprTceTable *tcet = spapr_tce_find_by_liobn(liobn);
|
2014-05-27 05:36:36 +00:00
|
|
|
hwaddr page_mask, page_size;
|
2014-05-27 05:36:30 +00:00
|
|
|
|
|
|
|
if (!tcet) {
|
|
|
|
return H_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (npages > tcet->nb_table) {
|
|
|
|
return H_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2014-05-27 05:36:36 +00:00
|
|
|
page_mask = IOMMU_PAGE_MASK(tcet->page_shift);
|
|
|
|
page_size = IOMMU_PAGE_SIZE(tcet->page_shift);
|
|
|
|
ioba &= page_mask;
|
2014-05-27 05:36:30 +00:00
|
|
|
|
2014-05-27 05:36:36 +00:00
|
|
|
for (i = 0; i < npages; ++i, ioba += page_size) {
|
2014-05-27 05:36:30 +00:00
|
|
|
ret = put_tce_emu(tcet, ioba, tce_value);
|
|
|
|
if (ret) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-05-07 05:33:33 +00:00
|
|
|
if (SPAPR_IS_PCI_LIOBN(liobn)) {
|
|
|
|
trace_spapr_iommu_pci_stuff(liobn, ioba, tce_value, npages, ret);
|
|
|
|
} else {
|
|
|
|
trace_spapr_iommu_stuff(liobn, ioba, tce_value, npages, ret);
|
|
|
|
}
|
2014-05-27 05:36:30 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
static target_ulong h_put_tce(PowerPCCPU *cpu, SpaprMachineState *spapr,
|
2012-06-27 04:50:44 +00:00
|
|
|
target_ulong opcode, target_ulong *args)
|
|
|
|
{
|
|
|
|
target_ulong liobn = args[0];
|
|
|
|
target_ulong ioba = args[1];
|
|
|
|
target_ulong tce = args[2];
|
2013-08-29 08:05:00 +00:00
|
|
|
target_ulong ret = H_PARAMETER;
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
SpaprTceTable *tcet = spapr_tce_find_by_liobn(liobn);
|
2012-06-27 04:50:44 +00:00
|
|
|
|
2012-06-27 04:50:46 +00:00
|
|
|
if (tcet) {
|
2014-05-27 05:36:36 +00:00
|
|
|
hwaddr page_mask = IOMMU_PAGE_MASK(tcet->page_shift);
|
|
|
|
|
|
|
|
ioba &= page_mask;
|
|
|
|
|
2013-08-29 08:05:00 +00:00
|
|
|
ret = put_tce_emu(tcet, ioba, tce);
|
2012-06-27 04:50:46 +00:00
|
|
|
}
|
2015-05-07 05:33:33 +00:00
|
|
|
if (SPAPR_IS_PCI_LIOBN(liobn)) {
|
|
|
|
trace_spapr_iommu_pci_put(liobn, ioba, tce, ret);
|
|
|
|
} else {
|
|
|
|
trace_spapr_iommu_put(liobn, ioba, tce, ret);
|
|
|
|
}
|
2012-06-27 04:50:44 +00:00
|
|
|
|
2013-08-29 08:05:00 +00:00
|
|
|
return ret;
|
2012-06-27 04:50:44 +00:00
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
static target_ulong get_tce_emu(SpaprTceTable *tcet, target_ulong ioba,
|
2014-02-21 09:29:06 +00:00
|
|
|
target_ulong *tce)
|
|
|
|
{
|
2014-05-27 05:36:37 +00:00
|
|
|
unsigned long index = (ioba - tcet->bus_offset) >> tcet->page_shift;
|
|
|
|
|
|
|
|
if (index >= tcet->nb_table) {
|
2014-02-21 09:29:06 +00:00
|
|
|
hcall_dprintf("spapr_iommu_get_tce on out-of-bounds IOBA 0x"
|
|
|
|
TARGET_FMT_lx "\n", ioba);
|
|
|
|
return H_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2014-05-27 05:36:37 +00:00
|
|
|
*tce = tcet->table[index];
|
2014-02-21 09:29:06 +00:00
|
|
|
|
|
|
|
return H_SUCCESS;
|
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
static target_ulong h_get_tce(PowerPCCPU *cpu, SpaprMachineState *spapr,
|
2014-02-21 09:29:06 +00:00
|
|
|
target_ulong opcode, target_ulong *args)
|
|
|
|
{
|
|
|
|
target_ulong liobn = args[0];
|
|
|
|
target_ulong ioba = args[1];
|
|
|
|
target_ulong tce = 0;
|
|
|
|
target_ulong ret = H_PARAMETER;
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
SpaprTceTable *tcet = spapr_tce_find_by_liobn(liobn);
|
2014-02-21 09:29:06 +00:00
|
|
|
|
|
|
|
if (tcet) {
|
2014-05-27 05:36:36 +00:00
|
|
|
hwaddr page_mask = IOMMU_PAGE_MASK(tcet->page_shift);
|
|
|
|
|
|
|
|
ioba &= page_mask;
|
|
|
|
|
2014-02-21 09:29:06 +00:00
|
|
|
ret = get_tce_emu(tcet, ioba, &tce);
|
|
|
|
if (!ret) {
|
|
|
|
args[0] = tce;
|
|
|
|
}
|
|
|
|
}
|
2015-05-07 05:33:33 +00:00
|
|
|
if (SPAPR_IS_PCI_LIOBN(liobn)) {
|
|
|
|
trace_spapr_iommu_pci_get(liobn, ioba, ret, tce);
|
|
|
|
} else {
|
|
|
|
trace_spapr_iommu_get(liobn, ioba, ret, tce);
|
|
|
|
}
|
2014-02-21 09:29:06 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-06-27 04:50:44 +00:00
|
|
|
int spapr_dma_dt(void *fdt, int node_off, const char *propname,
|
2012-08-07 16:10:38 +00:00
|
|
|
uint32_t liobn, uint64_t window, uint32_t size)
|
2012-06-27 04:50:44 +00:00
|
|
|
{
|
2012-08-07 16:10:38 +00:00
|
|
|
uint32_t dma_prop[5];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
dma_prop[0] = cpu_to_be32(liobn);
|
|
|
|
dma_prop[1] = cpu_to_be32(window >> 32);
|
|
|
|
dma_prop[2] = cpu_to_be32(window & 0xFFFFFFFF);
|
|
|
|
dma_prop[3] = 0; /* window size is 32 bits */
|
|
|
|
dma_prop[4] = cpu_to_be32(size);
|
|
|
|
|
|
|
|
ret = fdt_setprop_cell(fdt, node_off, "ibm,#dma-address-cells", 2);
|
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
}
|
2012-06-27 04:50:44 +00:00
|
|
|
|
2012-08-07 16:10:38 +00:00
|
|
|
ret = fdt_setprop_cell(fdt, node_off, "ibm,#dma-size-cells", 2);
|
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
}
|
2012-06-27 04:50:44 +00:00
|
|
|
|
2012-08-07 16:10:38 +00:00
|
|
|
ret = fdt_setprop(fdt, node_off, propname, dma_prop, sizeof(dma_prop));
|
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
2012-06-27 04:50:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2012-08-07 16:10:38 +00:00
|
|
|
|
|
|
|
int spapr_tcet_dma_dt(void *fdt, int node_off, const char *propname,
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
SpaprTceTable *tcet)
|
2012-08-07 16:10:38 +00:00
|
|
|
{
|
2013-04-10 15:30:48 +00:00
|
|
|
if (!tcet) {
|
2012-08-07 16:10:38 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-04-10 15:30:48 +00:00
|
|
|
return spapr_dma_dt(fdt, node_off, propname,
|
2014-05-27 05:36:36 +00:00
|
|
|
tcet->liobn, 0, tcet->nb_table << tcet->page_shift);
|
2012-08-07 16:10:38 +00:00
|
|
|
}
|
2013-07-18 19:32:58 +00:00
|
|
|
|
|
|
|
static void spapr_tce_table_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2017-07-25 17:59:06 +00:00
|
|
|
dc->realize = spapr_tce_table_realize;
|
2013-07-18 19:32:58 +00:00
|
|
|
dc->reset = spapr_tce_reset;
|
2014-12-08 02:48:02 +00:00
|
|
|
dc->unrealize = spapr_tce_table_unrealize;
|
2017-08-17 14:19:16 +00:00
|
|
|
/* Reason: This is just an internal device for handling the hypercalls */
|
|
|
|
dc->user_creatable = false;
|
2013-07-18 19:32:58 +00:00
|
|
|
|
|
|
|
QLIST_INIT(&spapr_tce_tables);
|
|
|
|
|
|
|
|
/* hcall-tce */
|
|
|
|
spapr_register_hypercall(H_PUT_TCE, h_put_tce);
|
2014-02-21 09:29:06 +00:00
|
|
|
spapr_register_hypercall(H_GET_TCE, h_get_tce);
|
2014-05-27 05:36:30 +00:00
|
|
|
spapr_register_hypercall(H_PUT_TCE_INDIRECT, h_put_tce_indirect);
|
|
|
|
spapr_register_hypercall(H_STUFF_TCE, h_stuff_tce);
|
2013-07-18 19:32:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static TypeInfo spapr_tce_table_info = {
|
|
|
|
.name = TYPE_SPAPR_TCE_TABLE,
|
|
|
|
.parent = TYPE_DEVICE,
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 04:35:37 +00:00
|
|
|
.instance_size = sizeof(SpaprTceTable),
|
2013-07-18 19:32:58 +00:00
|
|
|
.class_init = spapr_tce_table_class_init,
|
|
|
|
};
|
|
|
|
|
2017-07-11 03:56:20 +00:00
|
|
|
static void spapr_iommu_memory_region_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
|
|
|
IOMMUMemoryRegionClass *imrc = IOMMU_MEMORY_REGION_CLASS(klass);
|
|
|
|
|
|
|
|
imrc->translate = spapr_tce_translate_iommu;
|
2019-03-07 05:05:16 +00:00
|
|
|
imrc->replay = spapr_tce_replay;
|
2017-07-11 03:56:20 +00:00
|
|
|
imrc->get_min_page_size = spapr_tce_get_min_page_size;
|
|
|
|
imrc->notify_flag_changed = spapr_tce_notify_flag_changed;
|
2018-02-06 18:08:24 +00:00
|
|
|
imrc->get_attr = spapr_tce_get_attr;
|
2017-07-11 03:56:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const TypeInfo spapr_iommu_memory_region_info = {
|
|
|
|
.parent = TYPE_IOMMU_MEMORY_REGION,
|
|
|
|
.name = TYPE_SPAPR_IOMMU_MEMORY_REGION,
|
|
|
|
.class_init = spapr_iommu_memory_region_class_init,
|
|
|
|
};
|
|
|
|
|
2013-07-18 19:32:58 +00:00
|
|
|
static void register_types(void)
|
|
|
|
{
|
|
|
|
type_register_static(&spapr_tce_table_info);
|
2017-07-11 03:56:20 +00:00
|
|
|
type_register_static(&spapr_iommu_memory_region_info);
|
2013-07-18 19:32:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type_init(register_types);
|