sync with OpenBSD -current

This commit is contained in:
purplerain 2024-03-28 05:02:39 +00:00
parent 0189975fb5
commit cc5edceac3
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
87 changed files with 1329 additions and 4278 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: bcm2711_pcie.c,v 1.12 2024/02/03 10:37:26 kettenis Exp $ */
/* $OpenBSD: bcm2711_pcie.c,v 1.13 2024/03/27 15:15:00 patrick Exp $ */
/*
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
*
@ -24,6 +24,7 @@
#include <machine/intr.h>
#include <machine/bus.h>
#include <machine/fdt.h>
#include <machine/simplebusvar.h>
#include <dev/pci/pcidevs.h>
#include <dev/pci/pcireg.h>
@ -57,7 +58,7 @@ struct bcmpcie_range {
};
struct bcmpcie_softc {
struct device sc_dev;
struct simplebus_softc sc_sbus;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
bus_dma_tag_t sc_dmat;
@ -97,9 +98,11 @@ bcmpcie_match(struct device *parent, void *match, void *aux)
{
struct fdt_attach_args *faa = aux;
return OF_is_compatible(faa->fa_node, "brcm,bcm2711-pcie");
return OF_is_compatible(faa->fa_node, "brcm,bcm2711-pcie") ||
OF_is_compatible(faa->fa_node, "brcm,bcm2712-pcie");
}
int bcmpcie_submatch(struct device *, void *, void *);
void bcmpcie_attach_hook(struct device *, struct device *,
struct pcibus_attach_args *);
int bcmpcie_bus_maxdevs(void *, int);
@ -272,8 +275,6 @@ bcmpcie_attach(struct device *parent, struct device *self, void *aux)
}
}
printf("\n");
memcpy(&sc->sc_bus_iot, sc->sc_iot, sizeof(sc->sc_bus_iot));
sc->sc_bus_iot.bus_private = sc;
sc->sc_bus_iot._space_map = bcmpcie_bs_iomap;
@ -314,7 +315,22 @@ bcmpcie_attach(struct device *parent, struct device *self, void *aux)
pba.pba_domain = pci_ndomains++;
pba.pba_bus = 0;
config_found(self, &pba, NULL);
/* Attach device tree nodes enumerating PCIe bus */
simplebus_attach(parent, &sc->sc_sbus.sc_dev, faa);
config_found_sm(self, &pba, NULL, bcmpcie_submatch);
}
int
bcmpcie_submatch(struct device *self, void *match, void *aux)
{
struct cfdata *cf = match;
struct pcibus_attach_args *pba = aux;
if (strcmp(pba->pba_busname, cf->cf_driver->cd_name) != 0)
return 0;
return (*cf->cf_attach->ca_match)(self, match, aux);
}
void

View file

@ -1,4 +1,4 @@
# $OpenBSD: files.fdt,v 1.201 2024/03/02 19:52:41 kettenis Exp $
# $OpenBSD: files.fdt,v 1.202 2024/03/27 15:15:00 patrick Exp $
#
# Config file and device description for machine-independent FDT code.
# Included by ports that need it.
@ -132,7 +132,7 @@ device bcmmbox
attach bcmmbox at fdt
file dev/fdt/bcm2835_mbox.c bcmmbox
device bcmpcie: pcibus
device bcmpcie: pcibus, fdt
attach bcmpcie at fdt
file dev/fdt/bcm2711_pcie.c bcmpcie

View file

@ -1,4 +1,4 @@
/* $OpenBSD: fdt.c,v 1.34 2023/04/26 14:39:42 kettenis Exp $ */
/* $OpenBSD: fdt.c,v 1.35 2024/03/27 23:05:27 kettenis Exp $ */
/*
* Copyright (c) 2009 Dariusz Swiderski <sfires@sfires.net>
@ -501,6 +501,7 @@ fdt_find_node(char *name)
while (*p) {
void *child;
const char *q;
const char *s;
while (*p == '/')
p++;
@ -510,18 +511,33 @@ fdt_find_node(char *name)
if (q == NULL)
q = p + strlen(p);
/* Check for a complete match. */
for (child = fdt_child_node(node); child;
child = fdt_next_node(child)) {
if (strncmp(p, fdt_node_name(child), q - p) == 0) {
node = child;
s = fdt_node_name(child);
if (strncmp(p, s, q - p) == 0 && s[q - p] == '\0')
break;
}
}
if (child) {
node = child;
p = q;
continue;
}
if (child == NULL)
return NULL; /* No match found. */
/* Check for a match without the unit name. */
for (child = fdt_child_node(node); child;
child = fdt_next_node(child)) {
s = fdt_node_name(child);
if (strncmp(p, s, q - p) == 0 && s[q - p] == '@')
break;
}
if (child) {
node = child;
p = q;
continue;
}
p = q;
return NULL; /* No match found. */
}
return node;

View file

@ -317,7 +317,7 @@ static uint32_t atom_get_src_int(atom_exec_context *ctx, uint8_t attr,
DEBUG("IMM 0x%02X\n", val);
return val;
}
return 0;
break;
case ATOM_ARG_PLL:
idx = U8(*ptr);
(*ptr)++;

View file

@ -1287,11 +1287,10 @@ static int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
* 0b10 : encode is disabled
* 0b01 : decode is disabled
*/
adev->vcn.vcn_config[adev->vcn.num_vcn_inst] =
ip->revision & 0xc0;
ip->revision &= ~0xc0;
if (adev->vcn.num_vcn_inst <
AMDGPU_MAX_VCN_INSTANCES) {
adev->vcn.vcn_config[adev->vcn.num_vcn_inst] =
ip->revision & 0xc0;
adev->vcn.num_vcn_inst++;
adev->vcn.inst_mask |=
(1U << ip->instance_number);
@ -1302,6 +1301,7 @@ static int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
adev->vcn.num_vcn_inst + 1,
AMDGPU_MAX_VCN_INSTANCES);
}
ip->revision &= ~0xc0;
}
if (le16_to_cpu(ip->hw_id) == SDMA0_HWID ||
le16_to_cpu(ip->hw_id) == SDMA1_HWID ||

View file

@ -574,11 +574,34 @@ soc15_asic_reset_method(struct amdgpu_device *adev)
return AMD_RESET_METHOD_MODE1;
}
static bool soc15_need_reset_on_resume(struct amdgpu_device *adev)
{
u32 sol_reg;
sol_reg = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81);
/* Will reset for the following suspend abort cases.
* 1) Only reset limit on APU side, dGPU hasn't checked yet.
* 2) S3 suspend abort and TOS already launched.
*/
if (adev->flags & AMD_IS_APU && adev->in_s3 &&
!adev->suspend_complete &&
sol_reg)
return true;
return false;
}
static int soc15_asic_reset(struct amdgpu_device *adev)
{
/* original raven doesn't have full asic reset */
if ((adev->apu_flags & AMD_APU_IS_RAVEN) ||
(adev->apu_flags & AMD_APU_IS_RAVEN2))
/* On the latest Raven, the GPU reset can be performed
* successfully. So now, temporarily enable it for the
* S3 suspend abort case.
*/
if (((adev->apu_flags & AMD_APU_IS_RAVEN) ||
(adev->apu_flags & AMD_APU_IS_RAVEN2)) &&
!soc15_need_reset_on_resume(adev))
return 0;
switch (soc15_asic_reset_method(adev)) {
@ -1296,24 +1319,6 @@ static int soc15_common_suspend(void *handle)
return soc15_common_hw_fini(adev);
}
static bool soc15_need_reset_on_resume(struct amdgpu_device *adev)
{
u32 sol_reg;
sol_reg = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81);
/* Will reset for the following suspend abort cases.
* 1) Only reset limit on APU side, dGPU hasn't checked yet.
* 2) S3 suspend abort and TOS already launched.
*/
if (adev->flags & AMD_IS_APU && adev->in_s3 &&
!adev->suspend_complete &&
sol_reg)
return true;
return false;
}
static int soc15_common_resume(void *handle)
{
struct amdgpu_device *adev = (struct amdgpu_device *)handle;

View file

@ -1906,17 +1906,15 @@ static void amdgpu_dm_fini(struct amdgpu_device *adev)
adev->dm.hdcp_workqueue = NULL;
}
if (adev->dm.dc)
if (adev->dm.dc) {
dc_deinit_callbacks(adev->dm.dc);
if (adev->dm.dc)
dc_dmub_srv_destroy(&adev->dm.dc->ctx->dmub_srv);
if (dc_enable_dmub_notifications(adev->dm.dc)) {
kfree(adev->dm.dmub_notify);
adev->dm.dmub_notify = NULL;
destroy_workqueue(adev->dm.delayed_hpd_wq);
adev->dm.delayed_hpd_wq = NULL;
if (dc_enable_dmub_notifications(adev->dm.dc)) {
kfree(adev->dm.dmub_notify);
adev->dm.dmub_notify = NULL;
destroy_workqueue(adev->dm.delayed_hpd_wq);
adev->dm.delayed_hpd_wq = NULL;
}
}
if (adev->dm.dmub_bo)

View file

@ -1453,7 +1453,7 @@ static ssize_t dp_dsc_clock_en_read(struct file *f, char __user *buf,
const uint32_t rd_buf_size = 10;
struct pipe_ctx *pipe_ctx;
ssize_t result = 0;
int i, r, str_len = 30;
int i, r, str_len = 10;
rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL);

View file

@ -1832,6 +1832,9 @@ bool dcn10_set_output_transfer_func(struct dc *dc, struct pipe_ctx *pipe_ctx,
{
struct dpp *dpp = pipe_ctx->plane_res.dpp;
if (!stream)
return false;
if (dpp == NULL)
return false;
@ -1854,8 +1857,8 @@ bool dcn10_set_output_transfer_func(struct dc *dc, struct pipe_ctx *pipe_ctx,
} else
dpp->funcs->dpp_program_regamma_pwl(dpp, NULL, OPP_REGAMMA_BYPASS);
if (stream != NULL && stream->ctx != NULL &&
stream->out_transfer_func != NULL) {
if (stream->ctx &&
stream->out_transfer_func) {
log_tf(stream->ctx,
stream->out_transfer_func,
dpp->regamma_params.hw_points_num);

View file

@ -882,7 +882,8 @@ bool edp_set_replay_allow_active(struct dc_link *link, const bool *allow_active,
/* Set power optimization flag */
if (power_opts && link->replay_settings.replay_power_opt_active != *power_opts) {
if (link->replay_settings.replay_feature_enabled && replay->funcs->replay_set_power_opt) {
if (replay != NULL && link->replay_settings.replay_feature_enabled &&
replay->funcs->replay_set_power_opt) {
replay->funcs->replay_set_power_opt(replay, *power_opts, panel_inst);
link->replay_settings.replay_power_opt_active = *power_opts;
}

View file

@ -2358,8 +2358,8 @@ static uint16_t arcturus_get_current_pcie_link_speed(struct smu_context *smu)
/* TODO: confirm this on real target */
esm_ctrl = RREG32_PCIE(smnPCIE_ESM_CTRL);
if ((esm_ctrl >> 15) & 0x1FFFF)
return (uint16_t)(((esm_ctrl >> 8) & 0x3F) + 128);
if ((esm_ctrl >> 15) & 0x1)
return (uint16_t)(((esm_ctrl >> 8) & 0x7F) + 128);
return smu_v11_0_get_current_pcie_link_speed(smu);
}

View file

@ -1722,8 +1722,8 @@ static int aldebaran_get_current_pcie_link_speed(struct smu_context *smu)
/* TODO: confirm this on real target */
esm_ctrl = RREG32_PCIE(smnPCIE_ESM_CTRL);
if ((esm_ctrl >> 15) & 0x1FFFF)
return (((esm_ctrl >> 8) & 0x3F) + 128);
if ((esm_ctrl >> 15) & 0x1)
return (((esm_ctrl >> 8) & 0x7F) + 128);
return smu_v13_0_get_current_pcie_link_speed(smu);
}

View file

@ -1943,8 +1943,8 @@ static int smu_v13_0_6_get_current_pcie_link_speed(struct smu_context *smu)
/* TODO: confirm this on real target */
esm_ctrl = RREG32_PCIE(smnPCIE_ESM_CTRL);
if ((esm_ctrl >> 15) & 0x1FFFF)
return (((esm_ctrl >> 8) & 0x3F) + 128);
if ((esm_ctrl >> 15) & 0x1)
return (((esm_ctrl >> 8) & 0x7F) + 128);
speed_level = (RREG32_PCIE(smnPCIE_LC_SPEED_CNTL) &
PCIE_LC_SPEED_CNTL__LC_CURRENT_DATA_RATE_MASK)

View file

@ -136,7 +136,7 @@ static void huc_delayed_load_timer_callback(void *arg)
static void huc_delayed_load_start(struct intel_huc *huc)
{
int delay;
ktime_t delay;
GEM_BUG_ON(intel_huc_is_authenticated(huc, INTEL_HUC_AUTH_BY_GSC));
@ -146,10 +146,10 @@ static void huc_delayed_load_start(struct intel_huc *huc)
*/
switch (huc->delayed_load.status) {
case INTEL_HUC_WAITING_ON_GSC:
delay = GSC_INIT_TIMEOUT_MS;
delay = ms_to_ktime(GSC_INIT_TIMEOUT_MS);
break;
case INTEL_HUC_WAITING_ON_PXP:
delay = PXP_INIT_TIMEOUT_MS;
delay = ms_to_ktime(PXP_INIT_TIMEOUT_MS);
break;
default:
gsc_init_error(huc);
@ -171,7 +171,7 @@ static void huc_delayed_load_start(struct intel_huc *huc)
#ifdef __linux__
hrtimer_start(&huc->delayed_load.timer, delay, HRTIMER_MODE_REL);
#else
timeout_add_msec(&huc->delayed_load.timer, delay);
timeout_add_nsec(&huc->delayed_load.timer, ktime_to_ns(delay));
#endif
}

View file

@ -71,7 +71,6 @@ static inline u32 dfixed_div(fixed20_12 A, fixed20_12 B)
}
#define DRM_FIXED_POINT 32
#define DRM_FIXED_POINT_HALF 16
#define DRM_FIXED_ONE (1ULL << DRM_FIXED_POINT)
#define DRM_FIXED_DECIMAL_MASK (DRM_FIXED_ONE - 1)
#define DRM_FIXED_DIGITS_MASK (~DRM_FIXED_DECIMAL_MASK)
@ -90,12 +89,12 @@ static inline int drm_fixp2int(s64 a)
static inline int drm_fixp2int_round(s64 a)
{
return drm_fixp2int(a + (1 << (DRM_FIXED_POINT_HALF - 1)));
return drm_fixp2int(a + DRM_FIXED_ONE / 2);
}
static inline int drm_fixp2int_ceil(s64 a)
{
if (a > 0)
if (a >= 0)
return drm_fixp2int(a + DRM_FIXED_ALMOST_ONE);
else
return drm_fixp2int(a - DRM_FIXED_ALMOST_ONE);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ktime.h,v 1.7 2023/01/01 01:34:58 jsg Exp $ */
/* $OpenBSD: ktime.h,v 1.8 2024/03/28 02:36:38 jsg Exp $ */
/*
* Copyright (c) 2013, 2014, 2015 Mark Kettenis
*
@ -150,6 +150,12 @@ ns_to_ktime(uint64_t ns)
return ns;
}
static inline ktime_t
ms_to_ktime(uint64_t ms)
{
return ms * NSEC_PER_MSEC;
}
static inline int64_t
ktime_divns(ktime_t a, int64_t ns)
{

View file

@ -813,7 +813,7 @@ int ni_init_microcode(struct radeon_device *rdev)
err = 0;
} else if (rdev->smc_fw->size != smc_req_size) {
pr_err("ni_mc: Bogus length %zu in firmware \"%s\"\n",
rdev->mc_fw->size, fw_name);
rdev->smc_fw->size, fw_name);
err = -EINVAL;
}
}