drm/msm/dsi: Don’t store dsi host mode_flags in msm_dsi [Linux 5.3]

This Linux kernel change "drm/msm/dsi: Don’t store dsi host mode_flags in msm_dsi" is included in the Linux 5.3 release. This change is authored by Sean Paul <seanpaul [at] chromium.org> on Mon Jun 17 16:12:53 2019 -0400. The commit for this change in Linux stable tree is 09951aa (patch).

drm/msm/dsi: Don't store dsi host mode_flags in msm_dsi

It's a bit dangerous to store the flags in msm_dsi since there's no way to
tell when they're populated. Fortunately the only place that uses them
is the same place that fills them. So just use a local variable and
delete the struct member.

Reviewed-by: Rob Clark <robdclark@chromium.org>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20190617201301.133275-5-sean@poorly.run

There are 18 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/gpu/drm/msm/dsi/dsi.h         |  1 -
 drivers/gpu/drm/msm/dsi/dsi_manager.c | 17 +++++++++--------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi.h b/drivers/gpu/drm/msm/dsi/dsi.h
index 8bdc48c..e0bbe81 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.h
+++ b/drivers/gpu/drm/msm/dsi/dsi.h
@@ -79,7 +79,6 @@ struct msm_dsi {
     */
    struct drm_panel *panel;
    struct drm_bridge *external_bridge;
-   unsigned long device_flags;

    struct device *phy_dev;
    bool phy_enabled;
diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c
index 47b349a..ffc0955 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_manager.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c
@@ -233,6 +233,12 @@ static int dsi_mgr_bridge_get_id(struct drm_bridge *bridge)
    return dsi_bridge->id;
 }

+static bool dsi_mgr_is_cmd_mode(struct msm_dsi *msm_dsi)
+{
+   unsigned long host_flags = msm_dsi_host_get_mode_flags(msm_dsi->host);
+   return !(host_flags & MIPI_DSI_MODE_VIDEO);
+}
+
 static enum drm_connector_status dsi_mgr_connector_detect(
        struct drm_connector *connector, bool force)
 {
@@ -241,17 +247,15 @@ static enum drm_connector_status dsi_mgr_connector_detect(
    struct msm_dsi *other_dsi = dsi_mgr_get_other_dsi(id);
    struct msm_drm_private *priv = connector->dev->dev_private;
    struct msm_kms *kms = priv->kms;
+   bool cmd_mode;

    DBG("id=%d", id);
    if (!msm_dsi->panel) {
        msm_dsi->panel = msm_dsi_host_get_panel(msm_dsi->host);
-       msm_dsi->device_flags = msm_dsi_host_get_mode_flags(
-                       msm_dsi->host);

        /* There is only 1 panel in the global panel list
         * for dual DSI mode. Therefore slave dsi should get
-        * the drm_panel instance from master dsi, and
-        * keep using the panel flags got from the current DSI link.
+        * the drm_panel instance from master dsi.
         */
        if (!msm_dsi->panel && IS_DUAL_DSI() &&
            !IS_MASTER_DSI_LINK(id) && other_dsi)
@@ -259,9 +263,8 @@ static enum drm_connector_status dsi_mgr_connector_detect(
                        other_dsi->host);

+       cmd_mode = dsi_mgr_is_cmd_mode(msm_dsi);
        if (msm_dsi->panel && kms->funcs->set_encoder_mode) {
-           bool cmd_mode = !(msm_dsi->device_flags &
-                     MIPI_DSI_MODE_VIDEO);
            struct drm_encoder *encoder =
                    msm_dsi_get_encoder(msm_dsi);

@@ -277,8 +280,6 @@ static enum drm_connector_status dsi_mgr_connector_detect(
         */
        if (msm_dsi->panel && IS_DUAL_DSI() &&
            other_dsi && other_dsi->panel) {
-           bool cmd_mode = !(msm_dsi->device_flags &
-                       MIPI_DSI_MODE_VIDEO);
            struct drm_encoder *encoder = msm_dsi_get_encoder(
                    dsi_mgr_get_dsi(DSI_ENCODER_MASTER));
            struct drm_encoder *slave_enc = msm_dsi_get_encoder(

Leave a Reply

Your email address will not be published. Required fields are marked *