Skip to content

video: driver: use global UBWC config on KLM platforms#100

Open
venvenk wants to merge 1 commit intoqualcomm-linux:video.qclinux.mainfrom
venvenk:video.qclinux.main
Open

video: driver: use global UBWC config on KLM platforms#100
venvenk wants to merge 1 commit intoqualcomm-linux:video.qclinux.mainfrom
venvenk:video.qclinux.main

Conversation

@venvenk
Copy link
Copy Markdown
Contributor

@venvenk venvenk commented May 4, 2026

  • Use kernel global UBWC config database for kodiak/lemans/monaco
  • Fall back to existing per-platform UBWC defaults when global data is unavailable.

@venvenk venvenk requested a review from lumag May 5, 2026 10:42
@venvenk
Copy link
Copy Markdown
Contributor Author

venvenk commented May 5, 2026

Hi @lumag,

Implemented to pick UBWC values from central database for overlay driver, could you please help to review?

Comment thread driver/platform/kodiak/src/kodiak.c Outdated

static int msm_vidc_kodiak_set_ubwc_config(void)
{
#if MSM_VIDC_HAS_QCOM_UBWC_HEADER
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No spaghetti, thanks. Please put #if outside of the function body. Ideally you might want to provide a compat layer for the upstream functionality as a separate source file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creased separate source file as suggested.

Comment thread driver/platform/kodiak/src/kodiak.c Outdated
ubwc_cfg = qcom_ubwc_config_get_data();
if (IS_ERR(ubwc_cfg)) {
d_vpr_h("%s: global UBWC config not available, using local defaults\n", __func__);
return 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, return the error to the caller.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    ubwc_cfg = qcom_ubwc_config_get_data();
    if (IS_ERR(ubwc_cfg)) {
            long rc = PTR_ERR(ubwc_cfg);

            if (rc == -EINVAL) {
                    d_vpr_h("%s: no global UBWC config for this platform, using platform defaults\n",
                            __func__);
                    return 0;
            }

            d_vpr_e("%s: failed to get global UBWC config: %ld\n",
                    __func__, rc);
            return rc;
    }

Addressed return values in new patch set.

If some platform data is not available in central database, then fallback to static UBWC configs, so returning 0 if return value is "-EINVAL" (match not available in database).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. All data must be in the database. Otherwise the platform will have the GPU driver broken.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an example, consider the UBWC database for kodiak, lemans, and monaco.

The initial UBWC database patches were merged in Linux v6.17.

In that version, UBWC data was available for kodiak and lemans, but monaco data was not included.

Support for monaco was added later, starting from Linux v6.19.

If we return an error from qcom_ubwc_config_get_data() when the database entry is missing, the probe would fail on kernels where monaco support is not yet present.

To avoid breaking valid platforms on earlier kernel versions, the current implementation falls back to platform default UBWC configurations in this scenario.

Please let me if there is any alternate approach for this scenario.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this fallback should be implemented only for monaco, providing a default implementation for that platform.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have taken Monaco as an example,

There are other platforms as well which got added in other kernel versions,

Monaco, Kaanapali -> added in v6.19
glymur -> added in v7.0
mahua, eliza -> added in v7.1

Like this, new platforms will get added in kernel stage by stage.

In this scenario, if these platforms are tried to compile with kernel v6.18 then fallback is necessary for all these platforms.

It would be difficult to maintain fallback mechanism for all these platforms and upcoming platforms with older kernels.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no Iris DT entry for those platforms in 6.18, so the kernel needs to be patched anyway (in the qcom-6.18 tree) to let this driver to be bound at all. So, corresponding DB entries also can be backported to qcom-6.18.

Comment thread driver/platform/kodiak/src/kodiak.c Outdated
ubwc_config.bank_spreading =
msm_vidc_qcom_ubwc_bank_spread(ubwc_cfg);

ubwc_config_kodiak[0] = ubwc_config;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other way around. Drop msm_vidc_ubwc_config_data and use qcom_ubwc_cfg_data inside the driver code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qcom_ubwc_cfg_data was merged from specific kernel version.
So, I am updating msm_vidc_ubwc_config_data from qcom_ubwc_cfg_data based on kernel version check.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be done other way around. Drop msm_vidc_ubwc_config_data, provide compatibility entry for qcom_ubwc_cfg_data if it is not supported by the kernel. Once we drop support for older kernels, compat code can be removed too. With you approach, the compat code remains the main codepoint. Dropping it would be much harder. Also, with this approach we don't know if the in-kernel DB is complete or not.

Comment thread driver/platform/lemans/src/lemans.c Outdated
ubwc_config.bank_spreading =
msm_vidc_qcom_ubwc_bank_spread(ubwc_cfg);

ubwc_config_lemans[0] = ubwc_config;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. C&P of the kodiak function? Why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used common api now

Copy link
Copy Markdown
Contributor

@lumag lumag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Use kernel global UBWC config database for kodiak/lemans/monaco

No, it should not be limited to KLM. It should be used globally by the driver.

- Use kernel global UBWC config database for kodiak/lemans/monaco
- Fall back to existing per-platform UBWC defaults when global
  data is unavailable.

Signed-off-by: Venkata Siva Pavan KumarVenkatapatigari <venvenk@qti.qualcomm.com>
@venvenk venvenk force-pushed the video.qclinux.main branch from c0fb9d3 to 8cb1da8 Compare May 6, 2026 09:10
int msm_vidc_update_ubwc_config(struct msm_vidc_core *core)
{
const struct qcom_ubwc_cfg_data *ubwc_cfg;
struct msm_vidc_ubwc_config_data *ubwc_config;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You definitely don't follow the reviews. Stop using msm_vidc_ubwc_config_data, and switch to qcom_ubwc_cfg_data. Provide necessary kludges (and definitions) if the struct is not available (because of the kernel being too old).

struct msm_vidc_ubwc_config_data *ubwc_config;
u32 swizzle;

if (!core || !core->platform || !core->platform->data.ubwc_config)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defensive coding. Why? Can core be NULL here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants