Merge ^/head r363583 through r364040.

This commit is contained in:
Dimitry Andric 2020-08-07 19:33:54 +00:00
commit b7f46c9348
5 changed files with 55 additions and 13 deletions

View File

@ -348,7 +348,7 @@ apei_ge_handler(struct apei_ge *ge, bool copy)
uint32_t sev;
int i, c, off;
if (ges->BlockStatus == 0)
if (ges == NULL || ges->BlockStatus == 0)
return (0);
c = (ges->BlockStatus >> 4) & 0x3ff;
@ -363,7 +363,8 @@ apei_ge_handler(struct apei_ge *ge, bool copy)
/* Acknowledge the error has been processed. */
ges->BlockStatus = 0;
if (!copy && ge->v1.Header.Type == ACPI_HEST_TYPE_GENERIC_ERROR_V2) {
if (!copy && ge->v1.Header.Type == ACPI_HEST_TYPE_GENERIC_ERROR_V2 &&
ge->res2) {
uint64_t val = READ8(ge->res2, 0);
val &= ge->v2.ReadAckPreserve;
val |= ge->v2.ReadAckWrite;
@ -395,7 +396,7 @@ apei_nmi_handler(void)
return (0);
ges = (ACPI_HEST_GENERIC_STATUS *)ge->buf;
if (ges->BlockStatus == 0)
if (ges == NULL || ges->BlockStatus == 0)
return (0);
/* If ACPI told the error is fatal -- make it so. */
@ -409,7 +410,8 @@ apei_nmi_handler(void)
/* Acknowledge the error has been processed. */
ges->BlockStatus = 0;
if (ge->v1.Header.Type == ACPI_HEST_TYPE_GENERIC_ERROR_V2) {
if (ge->v1.Header.Type == ACPI_HEST_TYPE_GENERIC_ERROR_V2 &&
ge->res2) {
uint64_t val = READ8(ge->res2, 0);
val &= ge->v2.ReadAckPreserve;
val |= ge->v2.ReadAckWrite;
@ -608,13 +610,19 @@ apei_attach(device_t dev)
ge->res_rid = rid++;
acpi_bus_alloc_gas(dev, &ge->res_type, &ge->res_rid,
&ge->v1.ErrorStatusAddress, &ge->res, 0);
if (ge->res) {
ge->buf = pmap_mapdev_attr(READ8(ge->res, 0),
ge->v1.ErrorBlockLength, VM_MEMATTR_WRITE_COMBINING);
} else {
device_printf(dev, "Can't allocate status resource.\n");
}
if (ge->v1.Header.Type == ACPI_HEST_TYPE_GENERIC_ERROR_V2) {
ge->res2_rid = rid++;
acpi_bus_alloc_gas(dev, &ge->res2_type, &ge->res2_rid,
&ge->v2.ReadAckRegister, &ge->res2, 0);
if (ge->res2 == NULL)
device_printf(dev, "Can't allocate ack resource.\n");
}
ge->buf = pmap_mapdev_attr(READ8(ge->res, 0),
ge->v1.ErrorBlockLength, VM_MEMATTR_WRITE_COMBINING);
if (ge->v1.Notify.Type == ACPI_HEST_NOTIFY_POLLED) {
callout_init(&ge->poll, 1);
callout_reset(&ge->poll,
@ -652,7 +660,10 @@ apei_detach(device_t dev)
while ((ge = TAILQ_FIRST(&sc->ges)) != NULL) {
TAILQ_REMOVE(&sc->ges, ge, link);
bus_release_resource(dev, ge->res_type, ge->res_rid, ge->res);
if (ge->res) {
bus_release_resource(dev, ge->res_type,
ge->res_rid, ge->res);
}
if (ge->res2) {
bus_release_resource(dev, ge->res2_type,
ge->res2_rid, ge->res2);
@ -663,7 +674,10 @@ apei_detach(device_t dev)
swi_remove(&ge->swi_ih);
free(ge->copybuf, M_DEVBUF);
}
pmap_unmapdev((vm_offset_t)ge->buf, ge->v1.ErrorBlockLength);
if (ge->buf) {
pmap_unmapdev((vm_offset_t)ge->buf,
ge->v1.ErrorBlockLength);
}
free(ge, M_DEVBUF);
}
return (0);

View File

@ -408,7 +408,7 @@ static int pci_enable_ari = 1;
SYSCTL_INT(_hw_pci, OID_AUTO, enable_ari, CTLFLAG_RDTUN, &pci_enable_ari,
0, "Enable support for PCIe Alternative RID Interpretation");
int pci_enable_aspm;
int pci_enable_aspm = 1;
SYSCTL_INT(_hw_pci, OID_AUTO, enable_aspm, CTLFLAG_RDTUN, &pci_enable_aspm,
0, "Enable support for PCIe Active State Power Management");

View File

@ -860,8 +860,6 @@ sysctl_devctl_queue(SYSCTL_HANDLER_ARGS)
* The devctl protocol relies on quoted strings having matching quotes.
* This routine quotes any internal quotes so the resulting string
* is safe to pass to snprintf to construct, for example pnp info strings.
* Strings are always terminated with a NUL, but may be truncated if longer
* than @p len bytes after quotes.
*
* @param sb sbuf to place the characters into
* @param src Original buffer.

View File

@ -183,7 +183,7 @@ ttusync(void)
* Invalidate a range of translations
*/
static __inline void
static __always_inline void
radix_tlbie(uint8_t ric, uint8_t prs, uint16_t is, uint32_t pid, uint32_t lpid,
vm_offset_t va, uint16_t ap)
{
@ -715,7 +715,7 @@ static struct md_page pv_dummy;
static int powernv_enabled = 1;
static inline void
static __always_inline void
tlbiel_radix_set_isa300(uint32_t set, uint32_t is,
uint32_t pid, uint32_t ric, uint32_t prs)
{

View File

@ -427,6 +427,33 @@ consume(FILE *fp, off_t len, char *buf, int reg)
} \
} while (0/*CONSTCOND*/)
static void
termset(void)
{
struct termios traw;
if (tcgetattr(STDOUT_FILENO, &tt) == -1) {
if (errno == EBADF)
err(1, "%d not valid fd", STDOUT_FILENO);
/* errno == ENOTTY */
return;
}
ttyflg = 1;
traw = tt;
cfmakeraw(&traw);
traw.c_lflag |= ISIG;
(void)tcsetattr(STDOUT_FILENO, TCSANOW, &traw);
}
static void
termreset(void)
{
if (ttyflg) {
tcsetattr(STDOUT_FILENO, TCSADRAIN, &tt);
ttyflg = 0;
}
}
static void
playback(FILE *fp)
{
@ -470,8 +497,11 @@ playback(FILE *fp)
ctime(&tclock));
tsi = tso;
(void)consume(fp, stamp.scr_len, buf, reg);
termset();
atexit(termreset);
break;
case 'e':
termreset();
if (!qflg)
(void)printf("\nScript done on %s",
ctime(&tclock));