Adding private objects to atomic state
Subsystems (5)
v2 cover Adding private objects to atomic state
Link bandwidth is shared between multiple display streams in DP MST configurations. The DP MST topology manager structure maintains the shared link bandwidth for a primary link directly connected to the GPU. For atomic modesetting drivers, checking if there is sufficient link bandwidth for a mode needs to be done during the atomic_check phase to avoid failed modesets.
But adding objects like DP MST link bandwidth to drm_atomic_state would mean that a non-core object will be modified by the core helper functions for swapping and clearing it's state. So, this series adds void * objects to drm_atomic_state and helper functions that operate on void * types to keep these objects and states private to the core. Drivers can then implement specific functions to swap and clear states. The other advantage having just void * for these objects in drm_atomic_state is that objects of different types can be managed in the same state array.
This series also includes some necessary cleanups.
Dhinakaran Pandiyan (9):
drm/dp: Store drm_device in MST topology manager
drm/dp: Kill unused MST vcpi slot availability tracking drm/dp: Split drm_dp_mst_allocate_vcpi
drm: Add driver private objects to atomic state
drm/dp: Introduce MST topology state
drm/dp: Add DP MST helpers to atomically find and release vcpi slots
drm: Connector helper function to release atomic state drm/dp: Release DP MST shared link bandwidth
drm/dp: Track MST link bandwidth
drivers/gpu/drm/drm_atomic.c | 55 ++++++++++++ drivers/gpu/drm/drm_atomic_helper.c | 15 +++- drivers/gpu/drm/drm_dp_mst_topology.c | 143 ++++++++++++++++++++++++++----- drivers/gpu/drm/i915/intel_dp_mst.c | 48 ++++++++++- drivers/gpu/drm/nouveau/nv50_display.c | 5 +- drivers/gpu/drm/radeon/radeon_dp_mst.c | 6 +- include/drm/drm_atomic.h | 30 +++++++ include/drm/drm_dp_mst_helper.h | 37 +++++--- include/drm/drm_modeset_helper_vtables.h | 15 ++++ 9 files changed, 313 insertions(+), 41 deletions(-)
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 1/9 drm/dp: Store drm_device in MST topology manager
struct drm_dp_mst_topology_mgr currently stores a pointer to struct dev. Changing this to instead hold a pointer to drm_device is more useful as it gives access to DRM structures. This also makes it consistent with other DRM structures like drm_crtc, drm_connector etc.
--- drivers/gpu/drm/drm_dp_mst_topology.c | 6 +++--- drivers/gpu/drm/i915/intel_dp_mst.c | 3 ++- drivers/gpu/drm/nouveau/nv50_display.c | 2 +- drivers/gpu/drm/radeon/radeon_dp_mst.c | 2 +- include/drm/drm_dp_mst_helper.h | 7 +++++-- 5 files changed, 12 insertions(+), 8 deletions(-)
drivers/gpu/drm/drm_dp_mst_topology.c +3 -3
@@ -1086,7 +1086,7 @@ static void build_mst_prop_path(const struct drm_dp_mst_branch *mstb, }static void drm_dp_add_port (struct drm_dp_mst_branch *mstb, -struct device *dev, +struct drm_device *dev,struct drm_dp_link_addr_reply_port *port_msg) {struct drm_dp_mst_port *port;
@@ -1104,7 +1104,7 @@ static void drm_dp_add_port(struct drm_dp_mst_branch *mstb, port->port_num = port_msg->port_number; port->mgr = mstb->mgr; port->aux.name ="DPMST" ; - port->aux.dev = dev; + port->aux.dev = dev->dev; created = true; }else { old_pdt = port->pdt;
@@ -2949,7 +2949,7 @@ static void drm_dp_destroy_connector_work(struct work_struct *work)* Return 0 for success, or negative error code on failure */ int drm_dp_mst_topology_mgr_init (struct drm_dp_mst_topology_mgr *mgr, -struct device *dev,struct drm_dp_aux *aux, +struct drm_device *dev,struct drm_dp_aux *aux,int max_dpcd_transaction_bytes,int max_payloads,int conn_base_id) {
drivers/gpu/drm/i915/intel_dp_mst.c +2 -1
@@ -587,7 +587,8 @@ intel_dp_mst_encoder_init(struct intel_digital_port *intel_dig_port, int conn_ba/* create encoders */ intel_dp_create_fake_mst_encoders (intel_dig_port); - ret =drm_dp_mst_topology_mgr_init (&intel_dp->mst_mgr, dev->dev, &intel_dp->aux,16 ,3 , conn_base_id); + ret =drm_dp_mst_topology_mgr_init (&intel_dp->mst_mgr, dev, + &intel_dp->aux,16 ,3 , conn_base_id);if (ret) { intel_dp->can_mst = false;return ret;
drivers/gpu/drm/nouveau/nv50_display.c +1 -1
@@ -3417,7 +3417,7 @@ nv50_mstm_new(struct nouveau_encoder *outp, struct drm_dp_aux *aux, int aux_max, mstm->outp = outp; mstm->mgr.cbs = &nv50_mstm; - ret =drm_dp_mst_topology_mgr_init (&mstm->mgr, dev->dev, aux, aux_max, + ret =drm_dp_mst_topology_mgr_init (&mstm->mgr, dev, aux, aux_max, max_payloads, conn_base_id);if (ret)return ret;
drivers/gpu/drm/radeon/radeon_dp_mst.c +1 -1
@@ -667,7 +667,7 @@ radeon_dp_mst_init(struct radeon_connector *radeon_connector)return 0 ; radeon_connector->mst_mgr.cbs = &mst_cbs; -return drm_dp_mst_topology_mgr_init (&radeon_connector->mst_mgr, dev->dev, +return drm_dp_mst_topology_mgr_init (&radeon_connector->mst_mgr, dev, &radeon_connector->ddc_bus->aux,16 ,6 , radeon_connector->base.base.id); }
include/drm/drm_dp_mst_helper.h +5 -2
@@ -414,7 +414,7 @@ struct drm_dp_mst_topology_mgr {/** * @dev: device pointer for adding i2c devices etc. */ -struct device *dev; +struct drm_device *dev;/** * @cbs: callbacks for connector addition and destruction. */
@@ -556,7 +556,10 @@ struct drm_dp_mst_topology_mgr {struct work_struct destroy_connector_work; }; -int drm_dp_mst_topology_mgr_init (struct drm_dp_mst_topology_mgr *mgr,struct device *dev,struct drm_dp_aux *aux,int max_dpcd_transaction_bytes,int max_payloads,int conn_base_id); +int drm_dp_mst_topology_mgr_init (struct drm_dp_mst_topology_mgr *mgr, +struct drm_device *dev,struct drm_dp_aux *aux, +int max_dpcd_transaction_bytes, +int max_payloads,int conn_base_id);void drm_dp_mst_topology_mgr_destroy (struct drm_dp_mst_topology_mgr *mgr);
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v2 1/9] drm/dp: Store drm_device in MST topology manager
Quoted 6 lines · Dhinakaran Pandiyan
struct
drm_dp_mst_topology_mgrcurrently stores a pointer to struct dev. Changing this to instead hold a pointer todrm_deviceis more useful as it gives access to DRM structures. This also makes it consistent with other DRM structures likedrm_crtc,drm_connectoretc.Signed-off-by Dhinakaran Pandiyan <[email protected]>
Makes sense, can't think of any reason I initially didn't do this.
Quoted 107 lines
--- drivers/gpu/drm/drm_dp_mst_topology.c | 6 +++--- drivers/gpu/drm/i915/intel_dp_mst.c | 3 ++- drivers/gpu/drm/nouveau/nv50_display.c | 2 +- drivers/gpu/drm/radeon/radeon_dp_mst.c | 2 +- include/drm/drm_dp_mst_helper.h | 7 +++++-- 5 files changed, 12 insertions(+), 8 deletions(-)drivers/gpu/drm/drm_dp_mst_topology.c +3
-3@@ -1086,7 +1086,7 @@ static void build_mst_prop_path(const struct drm_dp_mst_branch *mstb, }static void drm_dp_add_port (struct drm_dp_mst_branch *mstb, -struct device *dev, +struct drm_device *dev,struct drm_dp_link_addr_reply_port *port_msg) {struct drm_dp_mst_port *port;@@ -1104,7 +1104,7 @@ static void drm_dp_add_port(struct drm_dp_mst_branch *mstb, port->port_num = port_msg->port_number; port->mgr = mstb->mgr; port->aux.name ="DPMST" ; - port->aux.dev = dev; + port->aux.dev = dev->dev; created = true; }else { old_pdt = port->pdt;@@ -2949,7 +2949,7 @@ static void drm_dp_destroy_connector_work(struct work_struct *work)* Return 0 for success, or negative error code on failure */ int drm_dp_mst_topology_mgr_init (struct drm_dp_mst_topology_mgr *mgr, -struct device *dev,struct drm_dp_aux *aux, +struct drm_device *dev,struct drm_dp_aux *aux,int max_dpcd_transaction_bytes,int max_payloads,int conn_base_id) {drivers/gpu/drm/i915/intel_dp_mst.c +2
-1@@ -587,7 +587,8 @@ intel_dp_mst_encoder_init(struct intel_digital_port *intel_dig_port, int conn_ba/* create encoders */ intel_dp_create_fake_mst_encoders (intel_dig_port); - ret =drm_dp_mst_topology_mgr_init (&intel_dp->mst_mgr, dev->dev, &intel_dp->aux,16 ,3 , conn_base_id); + ret =drm_dp_mst_topology_mgr_init (&intel_dp->mst_mgr, dev, + &intel_dp->aux,16 ,3 , conn_base_id);if (ret) { intel_dp->can_mst = false;return ret;drivers/gpu/drm/nouveau/nv50_display.c +1
-1@@ -3417,7 +3417,7 @@ nv50_mstm_new(struct nouveau_encoder *outp, struct drm_dp_aux *aux, int aux_max, mstm->outp = outp; mstm->mgr.cbs = &nv50_mstm; - ret =drm_dp_mst_topology_mgr_init (&mstm->mgr, dev->dev, aux, aux_max, + ret =drm_dp_mst_topology_mgr_init (&mstm->mgr, dev, aux, aux_max, max_payloads, conn_base_id);if (ret)return ret;drivers/gpu/drm/radeon/radeon_dp_mst.c +1
-1@@ -667,7 +667,7 @@ radeon_dp_mst_init(struct radeon_connector *radeon_connector)return 0 ; radeon_connector->mst_mgr.cbs = &mst_cbs; -return drm_dp_mst_topology_mgr_init (&radeon_connector->mst_mgr, dev->dev, +return drm_dp_mst_topology_mgr_init (&radeon_connector->mst_mgr, dev, &radeon_connector->ddc_bus->aux,16 ,6 , radeon_connector->base.base.id); }include/drm/drm_dp_mst_helper.h +5
-3@@ -414,7 +414,7 @@ struct drm_dp_mst_topology_mgr {/** * @dev: device pointer for adding i2c devices etc. */ -struct device *dev; +struct drm_device *dev;/** * @cbs: callbacks for connector addition and destruction. */ @@ -556,7 +556,10 @@ struct drm_dp_mst_topology_mgr {struct work_struct destroy_connector_work; }; -int drm_dp_mst_topology_mgr_init (struct drm_dp_mst_topology_mgr *mgr,struct device *dev,struct drm_dp_aux *aux,int max_dpcd_transaction_bytes,int max_payloads,int conn_base_id); +int drm_dp_mst_topology_mgr_init (struct drm_dp_mst_topology_mgr *mgr, +struct drm_device *dev,struct drm_dp_aux *aux, +int max_dpcd_transaction_bytes, +int max_payloads,int conn_base_id);void drm_dp_mst_topology_mgr_destroy (struct drm_dp_mst_topology_mgr *mgr); --2.7.4
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 2/9 drm/dp: Kill unused MST vcpi slot availability tracking
In reply to Dhinakaran PandiyanThe avail_slots member in the MST topology manager is never updated to reflect the available vcpi slots. The check is effectively against total_slots. So, let's make that check obvious. Secondly, since the total vcpi time slots is always 63 and does not depend on the link BW, remove total_slots from MST topology manager struct. The third change is to remove total_pbn which is hardcoded to 2560. The total PBN that the topology manager allocates from depends on the link rate and is not a constant. So, fix this by removing the total_pbn member itself. Finally, make debug messages more descriptive.
--- drivers/gpu/drm/drm_dp_mst_topology.c | 16 ++++++++-------- include/drm/drm_dp_mst_helper.h | 12 ------------ 2 files changed, 8 insertions(+), 20 deletions(-)
drivers/gpu/drm/drm_dp_mst_topology.c +8 -8
@@ -2042,10 +2042,6 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms goto out_unlock; } - mgr->total_pbn =2560 ; - mgr->total_slots =DIV_ROUND_UP (mgr->total_pbn, mgr->pbn_div); - mgr->avail_slots = mgr->total_slots; -/* add initial branch device at LCT 1 */ mstb =drm_dp_add_mst_branch_device (1 ,NULL );if (mstb ==NULL ) {
@@ -2475,7 +2471,8 @@ int drm_dp_find_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr, num_slots =DIV_ROUND_UP (pbn, mgr->pbn_div); -if (num_slots > mgr->avail_slots) +/* max. time slots - one slot for MTP header */ +if (num_slots >63 )return -ENOSPC ;return num_slots; }
@@ -2489,7 +2486,8 @@ static int drm_dp_init_vcpi(struct drm_dp_mst_topology_mgr *mgr, num_slots =DIV_ROUND_UP (pbn, mgr->pbn_div); -if (num_slots > mgr->avail_slots) +/* max. time slots - one slot for MTP header */ +if (num_slots >63 )return -ENOSPC ; vcpi->pbn = pbn;
@@ -2528,10 +2526,12 @@ bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp ret =drm_dp_init_vcpi (mgr, &port->vcpi, pbn);if (ret) { -DRM_DEBUG_KMS ("failed to init vcpi %d %d %d\n" ,DIV_ROUND_UP (pbn, mgr->pbn_div), mgr->avail_slots, ret); +DRM_DEBUG_KMS ("failed to init vcpi slots=%d max=63 ret=%d\n" , +DIV_ROUND_UP (pbn, mgr->pbn_div), ret); goto out; } -DRM_DEBUG_KMS ("initing vcpi for %d %d\n" , pbn, port->vcpi.num_slots); +DRM_DEBUG_KMS ("initing vcpi for pbn=%d slots=%d\n" , + pbn, port->vcpi.num_slots); *slots = port->vcpi.num_slots;drm_dp_put_port (port);
include/drm/drm_dp_mst_helper.h +0 -12
@@ -479,18 +479,6 @@ struct drm_dp_mst_topology_mgr {* @pbn_div: PBN to slots divisor. */ int pbn_div; -/** -* @total_slots: Total slots that can be allocated. -*/ -int total_slots; -/** -* @avail_slots: Still available slots that can be allocated. -*/ -int avail_slots; -/** -* @total_pbn: Total PBN count. -*/ -int total_pbn;/** * @qlock: protects @tx_msg_downq, the tx_slots in struct
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 2/9] drm/dp: Kill unused MST vcpi slot availability tracking
Quoted 9 lines · Dhinakaran Pandiyan
The
avail_slotsmember in the MST topology manager is never updated to reflect the available vcpi slots. The check is effectively againsttotal_slots. So, let's make that check obvious. Secondly, since the total vcpi time slots is always 63 and does not depend on the link BW, removetotal_slotsfrom MST topology manager struct. The third change is to removetotal_pbnwhich is hardcoded to 2560. The total PBN that the topology manager allocates from depends on the link rate and is not a constant. So, fix this by removing thetotal_pbnmember itself. Finally, make debug messages more descriptive.
Ok, these are 3 different changes, and they need to be split up. Well, at least in 2 patches, to get the functional change out of there:
- First hardcode avail_slots to 63, with the commit message explaining in detail why that's the right thing. You can already remove total_pbn and total_slots in that patch, since they will be unused. The commit message should have a reference to the DP spec to support that "it's always 63" claim.
- Then garbage-collect ->avail_slots in a 2nd patch.
If you smash these together it's a lot less obvious that this is not just a pure refactoring.
Thanks, Daniel
Quoted 83 lines
Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/drm_dp_mst_topology.c | 16 ++++++++-------- include/drm/drm_dp_mst_helper.h | 12 ------------ 2 files changed, 8 insertions(+), 20 deletions(-)drivers/gpu/drm/drm_dp_mst_topology.c +8
-8@@ -2042,10 +2042,6 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms goto out_unlock; } - mgr->total_pbn =2560 ; - mgr->total_slots =DIV_ROUND_UP (mgr->total_pbn, mgr->pbn_div); - mgr->avail_slots = mgr->total_slots; -/* add initial branch device at LCT 1 */ mstb =drm_dp_add_mst_branch_device (1 ,NULL );if (mstb ==NULL ) {@@ -2475,7 +2471,8 @@ int drm_dp_find_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr, num_slots =DIV_ROUND_UP (pbn, mgr->pbn_div); -if (num_slots > mgr->avail_slots) +/* max. time slots - one slot for MTP header */ +if (num_slots >63 )return -ENOSPC ;return num_slots; }@@ -2489,7 +2486,8 @@ static int drm_dp_init_vcpi(struct drm_dp_mst_topology_mgr *mgr, num_slots =DIV_ROUND_UP (pbn, mgr->pbn_div); -if (num_slots > mgr->avail_slots) +/* max. time slots - one slot for MTP header */ +if (num_slots >63 )return -ENOSPC ; vcpi->pbn = pbn;@@ -2528,10 +2526,12 @@ bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp ret =drm_dp_init_vcpi (mgr, &port->vcpi, pbn);if (ret) { -DRM_DEBUG_KMS ("failed to init vcpi %d %d %d\n" ,DIV_ROUND_UP (pbn, mgr->pbn_div), mgr->avail_slots, ret); +DRM_DEBUG_KMS ("failed to init vcpi slots=%d max=63 ret=%d\n" , +DIV_ROUND_UP (pbn, mgr->pbn_div), ret); goto out; } -DRM_DEBUG_KMS ("initing vcpi for %d %d\n" , pbn, port->vcpi.num_slots); +DRM_DEBUG_KMS ("initing vcpi for pbn=%d slots=%d\n" , + pbn, port->vcpi.num_slots); *slots = port->vcpi.num_slots;drm_dp_put_port (port);include/drm/drm_dp_mst_helper.h +0
-12@@ -479,18 +479,6 @@ struct drm_dp_mst_topology_mgr {* @pbn_div: PBN to slots divisor. */ int pbn_div; -/** -* @total_slots: Total slots that can be allocated. -*/ -int total_slots; -/** -* @avail_slots: Still available slots that can be allocated. -*/ -int avail_slots; -/** -* @total_pbn: Total PBN count. -*/ -int total_pbn;/** * @qlock: protects @tx_msg_downq, the tx_slots in struct Signature · 1 line
2.7.4
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 2/9] drm/dp: Kill unused MST vcpi slot availability tracking
Quoted 20 lines · Daniel Vetter
Quoted 9 lines · Dhinakaran Pandiyan
The
avail_slotsmember in the MST topology manager is never updated to reflect the available vcpi slots. The check is effectively againsttotal_slots. So, let's make that check obvious. Secondly, since the total vcpi time slots is always 63 and does not depend on the link BW, removetotal_slotsfrom MST topology manager struct. The third change is to removetotal_pbnwhich is hardcoded to 2560. The total PBN that the topology manager allocates from depends on the link rate and is not a constant. So, fix this by removing thetotal_pbnmember itself. Finally, make debug messages more descriptive.Ok, these are 3 different changes, and they need to be split up. Well, at least in 2 patches, to get the functional change out of there:
- First hardcodeavail_slotsto 63, with the commit message explaining in detail why that's the right thing. You can already removetotal_pbnandtotal_slotsin that patch, since they will be unused. The commit message should have a reference to the DP spec to support that "it's always 63" claim.
- Then garbage-collect ->avail_slots in a 2nd patch.
Quoted 5 lines
If you smash these together it's a lot less obvious that this is not just a pure refactoring.
Thanks, Daniel
Makes sense, will do this in the next revision.
-DK
Quoted 78 lines
Quoted 78 lines
Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/drm_dp_mst_topology.c | 16 ++++++++-------- include/drm/drm_dp_mst_helper.h | 12 ------------ 2 files changed, 8 insertions(+), 20 deletions(-)drivers/gpu/drm/drm_dp_mst_topology.c +8
-8@@ -2042,10 +2042,6 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms goto out_unlock; } - mgr->total_pbn =2560 ; - mgr->total_slots =DIV_ROUND_UP (mgr->total_pbn, mgr->pbn_div); - mgr->avail_slots = mgr->total_slots; -/* add initial branch device at LCT 1 */ mstb =drm_dp_add_mst_branch_device (1 ,NULL );if (mstb ==NULL ) {@@ -2475,7 +2471,8 @@ int drm_dp_find_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr, num_slots =DIV_ROUND_UP (pbn, mgr->pbn_div); -if (num_slots > mgr->avail_slots) +/* max. time slots - one slot for MTP header */ +if (num_slots >63 )return -ENOSPC ;return num_slots; }@@ -2489,7 +2486,8 @@ static int drm_dp_init_vcpi(struct drm_dp_mst_topology_mgr *mgr, num_slots =DIV_ROUND_UP (pbn, mgr->pbn_div); -if (num_slots > mgr->avail_slots) +/* max. time slots - one slot for MTP header */ +if (num_slots >63 )return -ENOSPC ; vcpi->pbn = pbn;@@ -2528,10 +2526,12 @@ bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp ret =drm_dp_init_vcpi (mgr, &port->vcpi, pbn);if (ret) { -DRM_DEBUG_KMS ("failed to init vcpi %d %d %d\n" ,DIV_ROUND_UP (pbn, mgr->pbn_div), mgr->avail_slots, ret); +DRM_DEBUG_KMS ("failed to init vcpi slots=%d max=63 ret=%d\n" , +DIV_ROUND_UP (pbn, mgr->pbn_div), ret); goto out; } -DRM_DEBUG_KMS ("initing vcpi for %d %d\n" , pbn, port->vcpi.num_slots); +DRM_DEBUG_KMS ("initing vcpi for pbn=%d slots=%d\n" , + pbn, port->vcpi.num_slots); *slots = port->vcpi.num_slots;drm_dp_put_port (port);include/drm/drm_dp_mst_helper.h +0
-12@@ -479,18 +479,6 @@ struct drm_dp_mst_topology_mgr {* @pbn_div: PBN to slots divisor. */ int pbn_div; -/** -* @total_slots: Total slots that can be allocated. -*/ -int total_slots; -/** -* @avail_slots: Still available slots that can be allocated. -*/ -int avail_slots; -/** -* @total_pbn: Total PBN count. -*/ -int total_pbn;
Quoted 6 lines
Quoted 5 lines
include/drm/drm_dp_mst_helper.h +0
-0/** * @qlock: protects @tx_msg_downq, the tx_slots in struct Signature · 1 line
2.7.4
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 3/9 drm/dp: Split drm_dp_mst_allocate_vcpi
In reply to Dhinakaran Pandiyandrm_dp_mst_allocate_vcpi() apart from setting up the vcpi structure, also finds if there are enough slots available. This check is a duplicate of that implemented in drm_dp_mst_find_vcpi_slots(). Let's move this check out and reuse the existing drm_dp_mst_find_vcpi_slots() function to check if there are enough vcpi slots before allocating them.
This brings the check to one place. Additionally drivers that will use MST state tracking for atomic modesets can use the atomic version of find_vcpi_slots() and reuse drm_dp_mst_allocate_vcpi()
--- drivers/gpu/drm/drm_dp_mst_topology.c | 20 +++++++++----------- drivers/gpu/drm/i915/intel_dp_mst.c | 4 ++-- drivers/gpu/drm/nouveau/nv50_display.c | 3 ++- drivers/gpu/drm/radeon/radeon_dp_mst.c | 4 +++- include/drm/drm_dp_mst_helper.h | 2 +- 5 files changed, 17 insertions(+), 16 deletions(-)
drivers/gpu/drm/drm_dp_mst_topology.c +9 -11
@@ -2479,20 +2479,17 @@ int drm_dp_find_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr,EXPORT_SYMBOL (drm_dp_find_vcpi_slots);static int drm_dp_init_vcpi (struct drm_dp_mst_topology_mgr *mgr, -struct drm_dp_vcpi *vcpi,int pbn) +struct drm_dp_vcpi *vcpi,int pbn,int slots) { -int num_slots;int ret; - num_slots =DIV_ROUND_UP (pbn, mgr->pbn_div); -/* max. time slots - one slot for MTP header */ -if (num_slots >63 ) +if (slots >63 )return -ENOSPC ; vcpi->pbn = pbn; - vcpi->aligned_pbn = num_slots * mgr->pbn_div; - vcpi->num_slots = num_slots; + vcpi->aligned_pbn = slots * mgr->pbn_div; + vcpi->num_slots = slots; ret =drm_dp_mst_assign_payload_id (mgr, vcpi);if (ret <0 )
@@ -2507,7 +2504,7 @@ static int drm_dp_init_vcpi(struct drm_dp_mst_topology_mgr *mgr,* @pbn: payload bandwidth number to request * @slots: returned number of slots for this PBN. */ -bool drm_dp_mst_allocate_vcpi (struct drm_dp_mst_topology_mgr *mgr,struct drm_dp_mst_port *port,int pbn,int *slots) +bool drm_dp_mst_allocate_vcpi (struct drm_dp_mst_topology_mgr *mgr,struct drm_dp_mst_port *port,int pbn,int slots) {int ret;
@@ -2515,16 +2512,18 @@ bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, struct drm_dpif (!port)return false; +if (slots <0 ) +return false; +if (port->vcpi.vcpi >0 ) {DRM_DEBUG_KMS ("payload: vcpi %d already allocated for pbn %d - requested pbn %d\n" , port->vcpi.vcpi, port->vcpi.pbn, pbn);if (pbn == port->vcpi.pbn) { - *slots = port->vcpi.num_slots;drm_dp_put_port (port);return true; } } - ret =drm_dp_init_vcpi (mgr, &port->vcpi, pbn); + ret =drm_dp_init_vcpi (mgr, &port->vcpi, pbn, slots);if (ret) {DRM_DEBUG_KMS ("failed to init vcpi slots=%d max=63 ret=%d\n" ,DIV_ROUND_UP (pbn, mgr->pbn_div), ret);
@@ -2532,7 +2531,6 @@ bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp }DRM_DEBUG_KMS ("initing vcpi for pbn=%d slots=%d\n" , pbn, port->vcpi.num_slots); - *slots = port->vcpi.num_slots;drm_dp_put_port (port);return true;
drivers/gpu/drm/i915/intel_dp_mst.c +2 -2
@@ -147,7 +147,6 @@ static void intel_mst_pre_enable_dp(struct intel_encoder *encoder,to_intel_connector (conn_state->connector);int ret;uint32_t temp; -int slots;/* MST encoders are bound to a crtc, not to a connector, * force the mapping here for get_hw_state.
@@ -177,7 +176,8 @@ static void intel_mst_pre_enable_dp(struct intel_encoder *encoder, ret =drm_dp_mst_allocate_vcpi (&intel_dp->mst_mgr, connector->port, - pipe_config->pbn, &slots); + pipe_config->pbn, + pipe_config->dp_m_n.tu);if (ret == false) {DRM_ERROR ("failed to allocate vcpi\n" );return ;
drivers/gpu/drm/nouveau/nv50_display.c +2 -1
@@ -2959,7 +2959,8 @@ nv50_msto_enable(struct drm_encoder *encoder)if (WARN_ON (!mstc))return ; - r =drm_dp_mst_allocate_vcpi (&mstm->mgr, mstc->port, mstc->pbn, &slots); + slots =drm_dp_find_vcpi_slots (&mstm->mgr, mstc->pbn); + r =drm_dp_mst_allocate_vcpi (&mstm->mgr, mstc->port, mstc->pbn, slots);WARN_ON (!r);if (mstm->outp->dcb->sorconf.link &1 )
drivers/gpu/drm/radeon/radeon_dp_mst.c +3 -1
@@ -453,9 +453,11 @@ radeon_mst_encoder_dpms(struct drm_encoder *encoder, int mode)DRM_DEBUG_KMS ("dig encoder is %d %d %d\n" , dig_enc->dig_encoder, dig_enc->linkb, radeon_crtc->crtc_id); + slots =drm_dp_find_vcpi_slots (&radeon_connector->mst_port->mst_mgr, + mst_enc->pbn); ret =drm_dp_mst_allocate_vcpi (&radeon_connector->mst_port->mst_mgr, radeon_connector->port, - mst_enc->pbn, &slots); + mst_enc->pbn, slots); ret =drm_dp_update_payload_part1 (&radeon_connector->mst_port->mst_mgr); radeon_dp_mst_set_be_cntl(primary, mst_enc,
include/drm/drm_dp_mst_helper.h +1 -1
@@ -568,7 +568,7 @@ struct edid *drm_dp_mst_get_edid(struct drm_connector *connector, struct drm_dp_int drm_dp_calc_pbn_mode (int clock,int bpp); -bool drm_dp_mst_allocate_vcpi (struct drm_dp_mst_topology_mgr *mgr,struct drm_dp_mst_port *port,int pbn,int *slots); +bool drm_dp_mst_allocate_vcpi (struct drm_dp_mst_topology_mgr *mgr,struct drm_dp_mst_port *port,int pbn,int slots);int drm_dp_mst_get_vcpi_slots (struct drm_dp_mst_topology_mgr *mgr,struct drm_dp_mst_port *port);
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 3/9] drm/dp: Split drm_dp_mst_allocate_vcpi
Quoted 10 lines · Dhinakaran Pandiyan
drm_dp_mst_allocate_vcpi()apart from setting up the vcpi structure, also finds if there are enough slots available. This check is a duplicate of that implemented indrm_dp_mst_find_vcpi_slots(). Let's move this check out and reuse the existingdrm_dp_mst_find_vcpi_slots()function to check if there are enough vcpi slots before allocating them.This brings the check to one place. Additionally drivers that will use MST state tracking for atomic modesets can use the atomic version of
find_vcpi_slots()and reusedrm_dp_mst_allocate_vcpi()
Also seem sane, at least for the core bits,
Quoted 145 lines
Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/drm_dp_mst_topology.c | 20 +++++++++----------- drivers/gpu/drm/i915/intel_dp_mst.c | 4 ++-- drivers/gpu/drm/nouveau/nv50_display.c | 3 ++- drivers/gpu/drm/radeon/radeon_dp_mst.c | 4 +++- include/drm/drm_dp_mst_helper.h | 2 +- 5 files changed, 17 insertions(+), 16 deletions(-)drivers/gpu/drm/drm_dp_mst_topology.c +9
-11@@ -2479,20 +2479,17 @@ int drm_dp_find_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr,EXPORT_SYMBOL (drm_dp_find_vcpi_slots);static int drm_dp_init_vcpi (struct drm_dp_mst_topology_mgr *mgr, -struct drm_dp_vcpi *vcpi,int pbn) +struct drm_dp_vcpi *vcpi,int pbn,int slots) { -int num_slots;int ret; - num_slots =DIV_ROUND_UP (pbn, mgr->pbn_div); -/* max. time slots - one slot for MTP header */ -if (num_slots >63 ) +if (slots >63 )return -ENOSPC ; vcpi->pbn = pbn; - vcpi->aligned_pbn = num_slots * mgr->pbn_div; - vcpi->num_slots = num_slots; + vcpi->aligned_pbn = slots * mgr->pbn_div; + vcpi->num_slots = slots; ret =drm_dp_mst_assign_payload_id (mgr, vcpi);if (ret <0 )@@ -2507,7 +2504,7 @@ static int drm_dp_init_vcpi(struct drm_dp_mst_topology_mgr *mgr,* @pbn: payload bandwidth number to request * @slots: returned number of slots for this PBN. */ -bool drm_dp_mst_allocate_vcpi (struct drm_dp_mst_topology_mgr *mgr,struct drm_dp_mst_port *port,int pbn,int *slots) +bool drm_dp_mst_allocate_vcpi (struct drm_dp_mst_topology_mgr *mgr,struct drm_dp_mst_port *port,int pbn,int slots) {int ret;@@ -2515,16 +2512,18 @@ bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, struct drm_dpif (!port)return false; +if (slots <0 ) +return false; +if (port->vcpi.vcpi >0 ) {DRM_DEBUG_KMS ("payload: vcpi %d already allocated for pbn %d - requested pbn %d\n" , port->vcpi.vcpi, port->vcpi.pbn, pbn);if (pbn == port->vcpi.pbn) { - *slots = port->vcpi.num_slots;drm_dp_put_port (port);return true; } } - ret =drm_dp_init_vcpi (mgr, &port->vcpi, pbn); + ret =drm_dp_init_vcpi (mgr, &port->vcpi, pbn, slots);if (ret) {DRM_DEBUG_KMS ("failed to init vcpi slots=%d max=63 ret=%d\n" ,DIV_ROUND_UP (pbn, mgr->pbn_div), ret);@@ -2532,7 +2531,6 @@ bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp }DRM_DEBUG_KMS ("initing vcpi for pbn=%d slots=%d\n" , pbn, port->vcpi.num_slots); - *slots = port->vcpi.num_slots;drm_dp_put_port (port);return true;drivers/gpu/drm/i915/intel_dp_mst.c +2
-2@@ -147,7 +147,6 @@ static void intel_mst_pre_enable_dp(struct intel_encoder *encoder,to_intel_connector (conn_state->connector);int ret;uint32_t temp; -int slots;/* MST encoders are bound to a crtc, not to a connector, * force the mapping here for get_hw_state. @@ -177,7 +176,8 @@ static void intel_mst_pre_enable_dp(struct intel_encoder *encoder, ret =drm_dp_mst_allocate_vcpi (&intel_dp->mst_mgr, connector->port, - pipe_config->pbn, &slots); + pipe_config->pbn, + pipe_config->dp_m_n.tu);if (ret == false) {DRM_ERROR ("failed to allocate vcpi\n" );return ;drivers/gpu/drm/nouveau/nv50_display.c +2
-1@@ -2959,7 +2959,8 @@ nv50_msto_enable(struct drm_encoder *encoder)if (WARN_ON (!mstc))return ; - r =drm_dp_mst_allocate_vcpi (&mstm->mgr, mstc->port, mstc->pbn, &slots); + slots =drm_dp_find_vcpi_slots (&mstm->mgr, mstc->pbn); + r =drm_dp_mst_allocate_vcpi (&mstm->mgr, mstc->port, mstc->pbn, slots);WARN_ON (!r);if (mstm->outp->dcb->sorconf.link &1 )drivers/gpu/drm/radeon/radeon_dp_mst.c +3
-1@@ -453,9 +453,11 @@ radeon_mst_encoder_dpms(struct drm_encoder *encoder, int mode)DRM_DEBUG_KMS ("dig encoder is %d %d %d\n" , dig_enc->dig_encoder, dig_enc->linkb, radeon_crtc->crtc_id); + slots =drm_dp_find_vcpi_slots (&radeon_connector->mst_port->mst_mgr, + mst_enc->pbn); ret =drm_dp_mst_allocate_vcpi (&radeon_connector->mst_port->mst_mgr, radeon_connector->port, - mst_enc->pbn, &slots); + mst_enc->pbn, slots); ret =drm_dp_update_payload_part1 (&radeon_connector->mst_port->mst_mgr); radeon_dp_mst_set_be_cntl(primary, mst_enc,include/drm/drm_dp_mst_helper.h +1
-2@@ -568,7 +568,7 @@ struct edid *drm_dp_mst_get_edid(struct drm_connector *connector, struct drm_dp_int drm_dp_calc_pbn_mode (int clock,int bpp); -bool drm_dp_mst_allocate_vcpi (struct drm_dp_mst_topology_mgr *mgr,struct drm_dp_mst_port *port,int pbn,int *slots); +bool drm_dp_mst_allocate_vcpi (struct drm_dp_mst_topology_mgr *mgr,struct drm_dp_mst_port *port,int pbn,int slots);int drm_dp_mst_get_vcpi_slots (struct drm_dp_mst_topology_mgr *mgr,struct drm_dp_mst_port *port); --2.7.4
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 3/9] drm/dp: Split drm_dp_mst_allocate_vcpi
Quoted 8 lines · Dave Airlie
Quoted 6 lines · Dhinakaran Pandiyan
drm_dp_mst_allocate_vcpi()apart from setting up the vcpi structure, also finds if there are enough slots available. This check is a duplicate of that implemented indrm_dp_mst_find_vcpi_slots(). Let's move this check out and reuse the existingdrm_dp_mst_find_vcpi_slots()function to check if there are enough vcpi slots before allocating them.
Quoted 9 lines
Quoted 4 lines
This brings the check to one place. Additionally drivers that will use MST state tracking for atomic modesets can use the atomic version of
find_vcpi_slots()and reusedrm_dp_mst_allocate_vcpi()Also seem sane, at least for the core bits,
Reviewed-by Dave Airlie <[email protected]>
Thanks for the review.
-DK
Quoted 145 lines
Quoted 145 lines
Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/drm_dp_mst_topology.c | 20 +++++++++----------- drivers/gpu/drm/i915/intel_dp_mst.c | 4 ++-- drivers/gpu/drm/nouveau/nv50_display.c | 3 ++- drivers/gpu/drm/radeon/radeon_dp_mst.c | 4 +++- include/drm/drm_dp_mst_helper.h | 2 +- 5 files changed, 17 insertions(+), 16 deletions(-)drivers/gpu/drm/drm_dp_mst_topology.c +9
-11@@ -2479,20 +2479,17 @@ int drm_dp_find_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr,EXPORT_SYMBOL (drm_dp_find_vcpi_slots);static int drm_dp_init_vcpi (struct drm_dp_mst_topology_mgr *mgr, -struct drm_dp_vcpi *vcpi,int pbn) +struct drm_dp_vcpi *vcpi,int pbn,int slots) { -int num_slots;int ret; - num_slots =DIV_ROUND_UP (pbn, mgr->pbn_div); -/* max. time slots - one slot for MTP header */ -if (num_slots >63 ) +if (slots >63 )return -ENOSPC ; vcpi->pbn = pbn; - vcpi->aligned_pbn = num_slots * mgr->pbn_div; - vcpi->num_slots = num_slots; + vcpi->aligned_pbn = slots * mgr->pbn_div; + vcpi->num_slots = slots; ret =drm_dp_mst_assign_payload_id (mgr, vcpi);if (ret <0 )@@ -2507,7 +2504,7 @@ static int drm_dp_init_vcpi(struct drm_dp_mst_topology_mgr *mgr,* @pbn: payload bandwidth number to request * @slots: returned number of slots for this PBN. */ -bool drm_dp_mst_allocate_vcpi (struct drm_dp_mst_topology_mgr *mgr,struct drm_dp_mst_port *port,int pbn,int *slots) +bool drm_dp_mst_allocate_vcpi (struct drm_dp_mst_topology_mgr *mgr,struct drm_dp_mst_port *port,int pbn,int slots) {int ret;@@ -2515,16 +2512,18 @@ bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, struct drm_dpif (!port)return false; +if (slots <0 ) +return false; +if (port->vcpi.vcpi >0 ) {DRM_DEBUG_KMS ("payload: vcpi %d already allocated for pbn %d - requested pbn %d\n" , port->vcpi.vcpi, port->vcpi.pbn, pbn);if (pbn == port->vcpi.pbn) { - *slots = port->vcpi.num_slots;drm_dp_put_port (port);return true; } } - ret =drm_dp_init_vcpi (mgr, &port->vcpi, pbn); + ret =drm_dp_init_vcpi (mgr, &port->vcpi, pbn, slots);if (ret) {DRM_DEBUG_KMS ("failed to init vcpi slots=%d max=63 ret=%d\n" ,DIV_ROUND_UP (pbn, mgr->pbn_div), ret);@@ -2532,7 +2531,6 @@ bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp }DRM_DEBUG_KMS ("initing vcpi for pbn=%d slots=%d\n" , pbn, port->vcpi.num_slots); - *slots = port->vcpi.num_slots;drm_dp_put_port (port);return true;drivers/gpu/drm/i915/intel_dp_mst.c +2
-2@@ -147,7 +147,6 @@ static void intel_mst_pre_enable_dp(struct intel_encoder *encoder,to_intel_connector (conn_state->connector);int ret;uint32_t temp; -int slots;/* MST encoders are bound to a crtc, not to a connector, * force the mapping here for get_hw_state. @@ -177,7 +176,8 @@ static void intel_mst_pre_enable_dp(struct intel_encoder *encoder, ret =drm_dp_mst_allocate_vcpi (&intel_dp->mst_mgr, connector->port, - pipe_config->pbn, &slots); + pipe_config->pbn, + pipe_config->dp_m_n.tu);if (ret == false) {DRM_ERROR ("failed to allocate vcpi\n" );return ;drivers/gpu/drm/nouveau/nv50_display.c +2
-1@@ -2959,7 +2959,8 @@ nv50_msto_enable(struct drm_encoder *encoder)if (WARN_ON (!mstc))return ; - r =drm_dp_mst_allocate_vcpi (&mstm->mgr, mstc->port, mstc->pbn, &slots); + slots =drm_dp_find_vcpi_slots (&mstm->mgr, mstc->pbn); + r =drm_dp_mst_allocate_vcpi (&mstm->mgr, mstc->port, mstc->pbn, slots);WARN_ON (!r);if (mstm->outp->dcb->sorconf.link &1 )drivers/gpu/drm/radeon/radeon_dp_mst.c +3
-1@@ -453,9 +453,11 @@ radeon_mst_encoder_dpms(struct drm_encoder *encoder, int mode)DRM_DEBUG_KMS ("dig encoder is %d %d %d\n" , dig_enc->dig_encoder, dig_enc->linkb, radeon_crtc->crtc_id); + slots =drm_dp_find_vcpi_slots (&radeon_connector->mst_port->mst_mgr, + mst_enc->pbn); ret =drm_dp_mst_allocate_vcpi (&radeon_connector->mst_port->mst_mgr, radeon_connector->port, - mst_enc->pbn, &slots); + mst_enc->pbn, slots); ret =drm_dp_update_payload_part1 (&radeon_connector->mst_port->mst_mgr); radeon_dp_mst_set_be_cntl(primary, mst_enc,include/drm/drm_dp_mst_helper.h +1
-2@@ -568,7 +568,7 @@ struct edid *drm_dp_mst_get_edid(struct drm_connector *connector, struct drm_dp_int drm_dp_calc_pbn_mode (int clock,int bpp); -bool drm_dp_mst_allocate_vcpi (struct drm_dp_mst_topology_mgr *mgr,struct drm_dp_mst_port *port,int pbn,int *slots); +bool drm_dp_mst_allocate_vcpi (struct drm_dp_mst_topology_mgr *mgr,struct drm_dp_mst_port *port,int pbn,int slots);int drm_dp_mst_get_vcpi_slots (struct drm_dp_mst_topology_mgr *mgr,struct drm_dp_mst_port *port); --2.7.4
Quoted 8 lines
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 4/9 drm: Add driver private objects to atomic state
In reply to Dhinakaran PandiyanIt is necessary to track states for objects other than connector, crtc and plane for atomic modesets. But adding objects like DP MST link bandwidth to drm_atomic_state would mean that a non-core object will be modified by the core helper functions for swapping and clearing it's state. So, lets add void * objects and helper functions that operate on void * types to keep these objects and states private to the core. Drivers can then implement specific functions to swap and clear states. The other advantage having just void * for these objects in drm_atomic_state is that objects of different types can be managed in the same state array.
--- drivers/gpu/drm/drm_atomic.c | 55 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_atomic_helper.c | 6 ++++ include/drm/drm_atomic.h | 30 ++++++++++++++++++++ 3 files changed, 91 insertions(+)
drivers/gpu/drm/drm_atomic.c +55 -0
@@ -57,6 +57,7 @@ void drm_atomic_state_default_release(struct drm_atomic_state *state)kfree (state->connectors);kfree (state->crtcs);kfree (state->planes); +kfree (state->private_objs); }EXPORT_SYMBOL (drm_atomic_state_default_release);
@@ -184,6 +185,20 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state) state->planes[i].ptr =NULL ; state->planes[i].state =NULL ; } + +for (i =0 ; i < state->num_private_objs; i++) { +void *priv_obj = state->private_objs[i].obj; +void *obj_state = state->private_objs[i].obj_state; + +if (!priv_obj) +continue ; + + state->private_objs[i].funcs->destroy_state (obj_state); + state->private_objs[i].obj =NULL ; + state->private_objs[i].obj_state =NULL ; + state->private_objs[i].funcs =NULL ; + } + }EXPORT_SYMBOL (drm_atomic_state_default_clear);
@@ -976,6 +991,46 @@ static void drm_atomic_plane_print_state(struct drm_printer *p, plane->funcs->atomic_print_state (p, state); } + +void * +drm_atomic_get_priv_obj_state (struct drm_atomic_state *state,void *obj, +const struct drm_private_state_funcs *funcs) +{ +int index, num_objs, i; +size_t size; +struct __drm_private_objs_state *arr; + +for (i =0 ; i < state->num_private_objs; i++) +if (obj == state->private_objs[i].obj && + state->private_objs[i].obj_state) +return state->private_objs[i].obj_state; + + num_objs = state->num_private_objs +1 ; + size =sizeof (*state->private_objs) * num_objs; + arr =krealloc (state->private_objs, size,GFP_KERNEL ); +if (!arr) +return ERR_PTR (-ENOMEM ); + + state->private_objs = arr; + index = state->num_private_objs; +memset (&state->private_objs[index],0 ,sizeof (*state->private_objs)); + + state->private_objs[index].obj_state = funcs->duplicate_state (state, obj); +if (!state->private_objs[index].obj_state) +return ERR_PTR (-ENOMEM ); + + state->private_objs[index].obj = obj; + state->private_objs[index].funcs = funcs; + state->num_private_objs = num_objs; + +DRM_DEBUG_ATOMIC ("Added new private object state %p to %p\n" , + state->private_objs[index].obj_state, state); + +return state->private_objs[index].obj_state; +} +EXPORT_SYMBOL (drm_atomic_get_priv_obj_state); + +/** * drm_atomic_get_connector_state - get connector state * @state: global atomic state object
drivers/gpu/drm/drm_atomic_helper.c +6 -0
@@ -1977,6 +1977,8 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,struct drm_plane *plane;struct drm_plane_state *plane_state;struct drm_crtc_commit *commit; +void *obj, *obj_state; +const struct drm_private_state_funcs *funcs;if (stall) {for_each_crtc_in_state (state, crtc, crtc_state, i) {
@@ -2025,6 +2027,10 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,swap (state->planes[i].state, plane->state); plane->state->state =NULL ; } + +for_each_private_obj (state, obj, obj_state, i, funcs) { + funcs->swap_state (obj, &state->private_objs[i].obj_state); + } }EXPORT_SYMBOL (drm_atomic_helper_swap_state);
include/drm/drm_atomic.h +30 -0
@@ -153,6 +153,18 @@ struct __drm_connnectors_state {struct drm_connector_state *state; }; +struct drm_private_state_funcs { +void (*swap_state)(void *obj,void **obj_state_ptr); +void (*destroy_state)(void *obj_state); +void *(*duplicate_state)(struct drm_atomic_state *state,void *obj); +}; + +struct __drm_private_objs_state { +void *obj; +void *obj_state; +const struct drm_private_state_funcs *funcs; +}; +/** * struct drm_atomic_state - the global state object for atomic updates * @ref: count of all references to this state (will not be freed until zero)
@@ -164,6 +176,8 @@ struct __drm_connnectors_state {* @crtcs: pointer to array of CRTC pointers * @num_connector: size of the @connectors and @connector_states arrays * @connectors: pointer to array of structures with per-connector data +* @num_private_objs: size of the @private_objs array +* @private_objs: pointer to array of private object pointers * @acquire_ctx: acquire context for this atomic modeset state update */ struct drm_atomic_state {
@@ -177,6 +191,8 @@ struct drm_atomic_state {struct __drm_crtcs_state *crtcs;int num_connector;struct __drm_connnectors_state *connectors; +int num_private_objs; +struct __drm_private_objs_state *private_objs;struct drm_modeset_acquire_ctx *acquire_ctx;
@@ -269,6 +285,11 @@ int drm_atomic_connector_set_property(struct drm_connector *connector, struct drm_connector_state *state, struct drm_property *property, uint64_t val); +void *__must_check +drm_atomic_get_priv_obj_state (struct drm_atomic_state *state, +void *obj, +const struct drm_private_state_funcs *funcs); +/** * drm_atomic_get_existing_crtc_state - get crtc state, if it exists * @state: global atomic state object
@@ -413,6 +434,15 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p); (__i)++) \ for_each_if (plane_state) +#define for_each_private_obj (__state, obj, obj_state, __i, __funcs) \ + for ((__i) = 0; \ + (__i) < (__state)->num_private_objs && \ + ((obj) = (__state)->private_objs[__i].obj, \ + (__funcs) = (__state)->private_objs[__i].funcs, \ + (obj_state) = (__state)->private_objs[__i].obj_state, 1); \ + (__i)++) \ + for_each_if (__funcs) +/** * drm_atomic_crtc_needs_modeset - compute combined modeset need * @state: &drm_crtc_state for the CRTC
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 4/9] drm: Add driver private objects to atomic state
Quoted 11 lines · Dhinakaran Pandiyan
It is necessary to track states for objects other than connector, crtc and plane for atomic modesets. But adding objects like DP MST link bandwidth to
drm_atomic_statewould mean that a non-core object will be modified by the core helper functions for swapping and clearing it's state. So, lets add void * objects and helper functions that operate on void * types to keep these objects and states private to the core. Drivers can then implement specific functions to swap and clear states. The other advantage having just void * for these objects indrm_atomic_stateis that objects of different types can be managed in the same state array.
Quoted 2 lines
Suggested-by Daniel Vetter <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>
I think an overview DOC: section to explain how to subclass atomic state and how to do private state objects would be great. But I can do that once your patch has landed, since it'd be much more about the overall design of atomic (and I promised to do that anyway).
Looks pretty good, a few nits below still. I'll also ask amd folks to check this out, and I think Ville could use it for his cdclk stuff.
Quoted 40 lines
--- drivers/gpu/drm/drm_atomic.c | 55 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_atomic_helper.c | 6 ++++ include/drm/drm_atomic.h | 30 ++++++++++++++++++++ 3 files changed, 91 insertions(+)drivers/gpu/drm/drm_atomic.c +15
-0@@ -57,6 +57,7 @@ void drm_atomic_state_default_release(struct drm_atomic_state *state)kfree (state->connectors);kfree (state->crtcs);kfree (state->planes); +kfree (state->private_objs); }EXPORT_SYMBOL (drm_atomic_state_default_release);@@ -184,6 +185,20 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state) state->planes[i].ptr =NULL ; state->planes[i].state =NULL ; } + +for (i =0 ; i < state->num_private_objs; i++) { +void *priv_obj = state->private_objs[i].obj; +void *obj_state = state->private_objs[i].obj_state; + +if (!priv_obj) +continue ; + + state->private_objs[i].funcs->destroy_state (obj_state); + state->private_objs[i].obj =NULL ; + state->private_objs[i].obj_state =NULL ; + state->private_objs[i].funcs =NULL ; + } + }EXPORT_SYMBOL (drm_atomic_state_default_clear);
drivers/gpu/drm/drm_atomic.c static void drm_atomic_plane_print_state(struct drm_printer *p, · line 994
Quoted 4 lines
drivers/gpu/drm/drm_atomic.c +1
-0@@ -976,6 +991,46 @@ static void drm_atomic_plane_print_state(struct drm_printer *p, plane->funcs->atomic_print_state (p, state); } +
Needs kerneldoc here.
drivers/gpu/drm/drm_atomic.c static void drm_atomic_plane_print_state(struct drm_printer *p, · line 996
Quoted 2 lines
drivers/gpu/drm/drm_atomic.c +2
-0+void * +drm_atomic_get_priv_obj_state(struct drm_atomic_state *state, void *obj,
ocd bikeshed: priv_obj vs private_obj inconsistency here, please stick to one (I don't care which one).
Quoted 14 lines
drivers/gpu/drm/drm_atomic.c +14
-0+ const struct drm_private_state_funcs *funcs) +{ +int index, num_objs, i; +size_t size; +struct __drm_private_objs_state *arr; + +for (i =0 ; i < state->num_private_objs; i++) +if (obj == state->private_objs[i].obj && + state->private_objs[i].obj_state) +return state->private_objs[i].obj_state; + + num_objs = state->num_private_objs +1 ; + size =sizeof (*state->private_objs) * num_objs; + arr =krealloc (state->private_objs, size,GFP_KERNEL );
drivers/gpu/drm/drm_atomic.c static void drm_atomic_plane_print_state(struct drm_printer *p, · line 1020
Quoted 10 lines
drivers/gpu/drm/drm_atomic.c +10
-0+if (!arr) +return ERR_PTR (-ENOMEM ); + + state->private_objs = arr; + index = state->num_private_objs; +memset (&state->private_objs[index],0 ,sizeof (*state->private_objs)); + + state->private_objs[index].obj_state = funcs->duplicate_state (state, obj); +if (!state->private_objs[index].obj_state) +return ERR_PTR (-ENOMEM );
I wondered whether we need to allow other error codes than ENOMEM, e.g. if duplicate_state needs to acquire a ww_mutex. But we can always acquire the necessary locks outside of drm_atomic_get_priv_obj_state in some helper/driver wrapper. So no big deal, but worth explaining that drm_atomic_get_priv_obj_state won't acquire necessarily locsk (since it doesn't know about them) in the kernel-doc.
Quoted 45 lines
drivers/gpu/drm/drm_atomic.c +13
-0+ + state->private_objs[index].obj = obj; + state->private_objs[index].funcs = funcs; + state->num_private_objs = num_objs; + +DRM_DEBUG_ATOMIC ("Added new private object state %p to %p\n" , + state->private_objs[index].obj_state, state); + +return state->private_objs[index].obj_state; +} +EXPORT_SYMBOL (drm_atomic_get_priv_obj_state); + +/** * drm_atomic_get_connector_state - get connector state * @state: global atomic state object drivers/gpu/drm/drm_atomic_helper.c +6
-0@@ -1977,6 +1977,8 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,struct drm_plane *plane;struct drm_plane_state *plane_state;struct drm_crtc_commit *commit; +void *obj, *obj_state; +const struct drm_private_state_funcs *funcs;if (stall) {for_each_crtc_in_state (state, crtc, crtc_state, i) {@@ -2025,6 +2027,10 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,swap (state->planes[i].state, plane->state); plane->state->state =NULL ; } + +for_each_private_obj (state, obj, obj_state, i, funcs) { + funcs->swap_state (obj, &state->private_objs[i].obj_state); + } }EXPORT_SYMBOL (drm_atomic_helper_swap_state);include/drm/drm_atomic.h +0
-0
include/drm/drm_atomic.h struct __drm_connnectors_state { · line 155
Quoted 3 lines
include/drm/drm_atomic.h +0
-0@@ -153,6 +153,18 @@ struct __drm_connnectors_state {struct drm_connector_state *state; };
This one needs kernel-doc too, since it's a struct that drivers/helpers will need to implement. Please use the inline style and document expected semantics in detail, like we do for other vfunc tables.
include/drm/drm_atomic.h struct __drm_connnectors_state { · line 156
Quoted 1 line
include/drm/drm_atomic.h +1
-0+struct drm_private_state_funcs {
I also wonder whether we shouldn't give this a drm_atomic_ prefix ...
Quoted 46 lines
include/drm/drm_atomic.h +20
-0+void (*swap_state)(void *obj,void **obj_state_ptr); +void (*destroy_state)(void *obj_state); +void *(*duplicate_state)(struct drm_atomic_state *state,void *obj); +}; + +struct __drm_private_objs_state { +void *obj; +void *obj_state; +const struct drm_private_state_funcs *funcs; +}; +/** * struct drm_atomic_state - the global state object for atomic updates * @ref: count of all references to this state (will not be freed until zero) @@ -164,6 +176,8 @@ struct __drm_connnectors_state {* @crtcs: pointer to array of CRTC pointers * @num_connector: size of the @connectors and @connector_states arrays * @connectors: pointer to array of structures with per-connector data +* @num_private_objs: size of the @private_objs array +* @private_objs: pointer to array of private object pointers * @acquire_ctx: acquire context for this atomic modeset state update */ struct drm_atomic_state {@@ -177,6 +191,8 @@ struct drm_atomic_state {struct __drm_crtcs_state *crtcs;int num_connector;struct __drm_connnectors_state *connectors; +int num_private_objs; +struct __drm_private_objs_state *private_objs;struct drm_modeset_acquire_ctx *acquire_ctx;@@ -269,6 +285,11 @@ int drm_atomic_connector_set_property(struct drm_connector *connector, struct drm_connector_state *state, struct drm_property *property, uint64_t val); +void *__must_check +drm_atomic_get_priv_obj_state (struct drm_atomic_state *state, +void *obj, +const struct drm_private_state_funcs *funcs); +/** * drm_atomic_get_existing_crtc_state - get crtc state, if it exists * @state: global atomic state object @@ -413,6 +434,15 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p); (__i)++) \
include/drm/drm_atomic.h void drm_state_dump(struct drm_device *dev, struct drm_printer *p); · line 444
Quoted 10 lines
include/drm/drm_atomic.h +8
-0for_each_if (plane_state) +#define for_each_private_obj (__state, obj, obj_state, __i, __funcs) \ + for ((__i) = 0; \ + (__i) < (__state)->num_private_objs && \ + ((obj) = (__state)->private_objs[__i].obj, \ + (__funcs) = (__state)->private_objs[__i].funcs, \ + (obj_state) = (__state)->private_objs[__i].obj_state, 1); \ + (__i)++) \ + for_each_if (__funcs)
You are not filtering for the function table here, which is important to make sure that this can be used to only walk over objects with a given vtable. With that we can then #define specific macros for e.g. mst:
struct drm_private_state_funcs mst_state_funcs;
#define for_each_mst_state(__state, obj, obj_state, __i, __funcs) \ for_each_private_obj(__state, &mst_state_funcs, obj, obj_state, __i, __funcs)
I'd place the vfunc right after the state, since those are both input parameters to the macro, and specify what exactly we're looping over. To make this work you need something like:
#define for_each_private_obj(__state, obj_funcs, obj, obj_state, __i, __funcs) \ for ((__i) = 0; \ (__i) < (__state)->num_private_objs && \ ((obj) = (__state)->private_objs[__i].obj, \ (__funcs) = (__state)->private_objs[__i].funcs, \ (obj_state) = (__state)->private_objs[__i].obj_state, 1); \ (__i)++) \ for_each_if (__funcs == obj_funcs)
Note the check to compare __funcs == obj_funcs.
With that other subsytem can the filter for their own objects only with e.g.
#define intel_for_each_cdclk_state(__state, obj, obj_state, __i, __funcs) \
for_each_private_obj(__state, &intel_cdclk_state_funcs, obj, obj_state, __i, __funcs)
Would be good to also then have kerneldoc for this iterator, to explain how to use it.
-Daniel
Quoted 6 lines
include/drm/drm_atomic.h +0
-0/** * drm_atomic_crtc_needs_modeset - compute combined modeset need * @state: &drm_crtc_state for the CRTC Signature · 1 line
2.7.4
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 4/9] drm: Add driver private objects to atomic state
Quoted 99 lines · Daniel Vetter
Quoted 11 lines · Dhinakaran Pandiyan
It is necessary to track states for objects other than connector, crtc and plane for atomic modesets. But adding objects like DP MST link bandwidth to
drm_atomic_statewould mean that a non-core object will be modified by the core helper functions for swapping and clearing it's state. So, lets add void * objects and helper functions that operate on void * types to keep these objects and states private to the core. Drivers can then implement specific functions to swap and clear states. The other advantage having just void * for these objects indrm_atomic_stateis that objects of different types can be managed in the same state array.Quoted 2 lines
Suggested-by Daniel Vetter <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>I think an overview DOC: section to explain how to subclass atomic state and how to do private state objects would be great. But I can do that once your patch has landed, since it'd be much more about the overall design of atomic (and I promised to do that anyway).
Looks pretty good, a few nits below still. I'll also ask amd folks to check this out, and I think Ville could use it for his cdclk stuff.
Quoted 40 lines
--- drivers/gpu/drm/drm_atomic.c | 55 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_atomic_helper.c | 6 ++++ include/drm/drm_atomic.h | 30 ++++++++++++++++++++ 3 files changed, 91 insertions(+)drivers/gpu/drm/drm_atomic.c +15
-0@@ -57,6 +57,7 @@ void drm_atomic_state_default_release(struct drm_atomic_state *state)kfree (state->connectors);kfree (state->crtcs);kfree (state->planes); +kfree (state->private_objs); }EXPORT_SYMBOL (drm_atomic_state_default_release);@@ -184,6 +185,20 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state) state->planes[i].ptr =NULL ; state->planes[i].state =NULL ; } + +for (i =0 ; i < state->num_private_objs; i++) { +void *priv_obj = state->private_objs[i].obj; +void *obj_state = state->private_objs[i].obj_state; + +if (!priv_obj) +continue ; + + state->private_objs[i].funcs->destroy_state (obj_state); + state->private_objs[i].obj =NULL ; + state->private_objs[i].obj_state =NULL ; + state->private_objs[i].funcs =NULL ; + } + }EXPORT_SYMBOL (drm_atomic_state_default_clear);drivers/gpu/drm/drm_atomic.c static void drm_atomic_plane_print_state(struct drm_printer *p, · line 994
Quoted 4 lines
drivers/gpu/drm/drm_atomic.c +1
-0@@ -976,6 +991,46 @@ static void drm_atomic_plane_print_state(struct drm_printer *p, plane->funcs->atomic_print_state (p, state); } +Needs kerneldoc here.
drivers/gpu/drm/drm_atomic.c static void drm_atomic_plane_print_state(struct drm_printer *p, · line 996
Quoted 2 lines
drivers/gpu/drm/drm_atomic.c +2
-0+void * +drm_atomic_get_priv_obj_state(struct drm_atomic_state *state, void *obj,ocd bikeshed:
priv_objvsprivate_objinconsistency here, please stick to one (I don't care which one).Quoted 23 lines
drivers/gpu/drm/drm_atomic.c +23
-0+ const struct drm_private_state_funcs *funcs) +{ +int index, num_objs, i; +size_t size; +struct __drm_private_objs_state *arr; + +for (i =0 ; i < state->num_private_objs; i++) +if (obj == state->private_objs[i].obj && + state->private_objs[i].obj_state) +return state->private_objs[i].obj_state; + + num_objs = state->num_private_objs +1 ; + size =sizeof (*state->private_objs) * num_objs; + arr =krealloc (state->private_objs, size,GFP_KERNEL ); +if (!arr) +return ERR_PTR (-ENOMEM ); + + state->private_objs = arr; + index = state->num_private_objs; +memset (&state->private_objs[index],0 ,sizeof (*state->private_objs)); + + state->private_objs[index].obj_state = funcs->duplicate_state (state, obj); +if (!state->private_objs[index].obj_state)
Quoted 9 lines
drivers/gpu/drm/drm_atomic.c static void drm_atomic_plane_print_state(struct drm_printer *p, · line 1020
Quoted 1 line
drivers/gpu/drm/drm_atomic.c +1
-0+return ERR_PTR (-ENOMEM );I wondered whether we need to allow other error codes than ENOMEM, e.g. if
duplicate_stateneeds to acquire aww_mutex. But we can always acquire the necessary locks outside ofdrm_atomic_get_priv_obj_statein some helper/driver wrapper. So no big deal, but worth explaining thatdrm_atomic_get_priv_obj_statewon't acquire necessarily locsk (since it doesn't know about them) in the kernel-doc.
Got it, will include that.
Quoted 141 lines
Quoted 45 lines
drivers/gpu/drm/drm_atomic.c +13
-0+ + state->private_objs[index].obj = obj; + state->private_objs[index].funcs = funcs; + state->num_private_objs = num_objs; + +DRM_DEBUG_ATOMIC ("Added new private object state %p to %p\n" , + state->private_objs[index].obj_state, state); + +return state->private_objs[index].obj_state; +} +EXPORT_SYMBOL (drm_atomic_get_priv_obj_state); + +/** * drm_atomic_get_connector_state - get connector state * @state: global atomic state object drivers/gpu/drm/drm_atomic_helper.c +6
-0@@ -1977,6 +1977,8 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,struct drm_plane *plane;struct drm_plane_state *plane_state;struct drm_crtc_commit *commit; +void *obj, *obj_state; +const struct drm_private_state_funcs *funcs;if (stall) {for_each_crtc_in_state (state, crtc, crtc_state, i) {@@ -2025,6 +2027,10 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,swap (state->planes[i].state, plane->state); plane->state->state =NULL ; } + +for_each_private_obj (state, obj, obj_state, i, funcs) { + funcs->swap_state (obj, &state->private_objs[i].obj_state); + } }EXPORT_SYMBOL (drm_atomic_helper_swap_state);include/drm/drm_atomic.h +0
-0include/drm/drm_atomic.h struct __drm_connnectors_state { · line 155
Quoted 3 lines
include/drm/drm_atomic.h +0
-0@@ -153,6 +153,18 @@ struct __drm_connnectors_state {struct drm_connector_state *state; };This one needs kernel-doc too, since it's a struct that
drivers/helperswill need to implement. Please use the inline style and document expected semantics in detail, like we do for other vfunc tables.include/drm/drm_atomic.h struct __drm_connnectors_state { · line 156
Quoted 1 line
include/drm/drm_atomic.h +1
-0+struct drm_private_state_funcs {I also wonder whether we shouldn't give this a
drm_atomic_prefix ...Quoted 46 lines
include/drm/drm_atomic.h +20
-0+void (*swap_state)(void *obj,void **obj_state_ptr); +void (*destroy_state)(void *obj_state); +void *(*duplicate_state)(struct drm_atomic_state *state,void *obj); +}; + +struct __drm_private_objs_state { +void *obj; +void *obj_state; +const struct drm_private_state_funcs *funcs; +}; +/** * struct drm_atomic_state - the global state object for atomic updates * @ref: count of all references to this state (will not be freed until zero) @@ -164,6 +176,8 @@ struct __drm_connnectors_state {* @crtcs: pointer to array of CRTC pointers * @num_connector: size of the @connectors and @connector_states arrays * @connectors: pointer to array of structures with per-connector data +* @num_private_objs: size of the @private_objs array +* @private_objs: pointer to array of private object pointers * @acquire_ctx: acquire context for this atomic modeset state update */ struct drm_atomic_state {@@ -177,6 +191,8 @@ struct drm_atomic_state {struct __drm_crtcs_state *crtcs;int num_connector;struct __drm_connnectors_state *connectors; +int num_private_objs; +struct __drm_private_objs_state *private_objs;struct drm_modeset_acquire_ctx *acquire_ctx;@@ -269,6 +285,11 @@ int drm_atomic_connector_set_property(struct drm_connector *connector, struct drm_connector_state *state, struct drm_property *property, uint64_t val); +void *__must_check +drm_atomic_get_priv_obj_state (struct drm_atomic_state *state, +void *obj, +const struct drm_private_state_funcs *funcs); +/** * drm_atomic_get_existing_crtc_state - get crtc state, if it exists * @state: global atomic state object @@ -413,6 +434,15 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p); (__i)++) \include/drm/drm_atomic.h void drm_state_dump(struct drm_device *dev, struct drm_printer *p); · line 444
Quoted 10 lines
include/drm/drm_atomic.h +8
-0for_each_if (plane_state) +#define for_each_private_obj (__state, obj, obj_state, __i, __funcs) \ + for ((__i) = 0; \ + (__i) < (__state)->num_private_objs && \ + ((obj) = (__state)->private_objs[__i].obj, \ + (__funcs) = (__state)->private_objs[__i].funcs, \ + (obj_state) = (__state)->private_objs[__i].obj_state, 1); \ + (__i)++) \ + for_each_if (__funcs)You are not filtering for the function table here, which is important to make sure that this can be used to only walk over objects with a given vtable. With that we can then #define specific macros for e.g. mst:
struct
drm_private_state_funcsmst_state_funcs;#define for_each_mst_state(__state, obj, obj_state, __i, __funcs) \ for_each_private_obj(__state, &mst_state_funcs, obj, obj_state, __i, __funcs)I'd place the vfunc right after the state, since those are both input parameters to the macro, and specify what exactly we're looping over. To make this work you need something like:
#define for_each_private_obj(__state, obj_funcs, obj, obj_state, __i, __funcs) \ for ((__i) = 0; \ (__i) < (__state)->num_private_objs && \ ((obj) = (__state)->private_objs[__i].obj, \ (__funcs) = (__state)->private_objs[__i].funcs, \ (obj_state) = (__state)->private_objs[__i].obj_state, 1); \ (__i)++) \ for_each_if (__funcs == obj_funcs)Note the check to compare
__funcs==obj_funcs.With that other subsytem can the filter for their own objects only with e.g.
Quoted 7 lines
#define
intel_for_each_cdclk_state(__state, obj, obj_state, __i, __funcs)\
for_each_private_obj(__state, &intel_cdclk_state_funcs, obj, obj_state, __i, __funcs)Would be good to also then have kerneldoc for this iterator, to explain how to use it.
-Daniel
I see your point but we can't use this iterator in the swap_state() helper if we do that. I have used it to swap states for all objects using this version without filtering.
I guess, I can just code the iterator explicitly for swap_state() and re-write the iterator with the filtering.
-DK
Quoted 7 lines
Quoted 6 lines
include/drm/drm_atomic.h +0
-0/** * drm_atomic_crtc_needs_modeset - compute combined modeset need * @state: &drm_crtc_state for the CRTC Signature · 1 line
2.7.4
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v2 4/9] drm: Add driver private objects to atomic state
Quoted 46 lines · Dhinakaran
Quoted 37 lines · Daniel Vetter
include/drm/drm_atomic.h void drm_state_dump(struct drm_device *dev, struct drm_printer *p); · line 444
Quoted 8 lines · Dhinakaran Pandiyan
include/drm/drm_atomic.h +8
-0+#define for_each_private_obj (__state, obj, obj_state, __i, __funcs) \ + for ((__i) = 0; \ + (__i) < (__state)->num_private_objs && \ + ((obj) = (__state)->private_objs[__i].obj, \ + (__funcs) = (__state)->private_objs[__i].funcs, \ + (obj_state) = (__state)->private_objs[__i].obj_state, 1); \ + (__i)++) \ + for_each_if (__funcs)You are not filtering for the function table here, which is important to make sure that this can be used to only walk over objects with a given vtable. With that we can then #define specific macros for e.g. mst:
struct
drm_private_state_funcsmst_state_funcs;#define for_each_mst_state(__state, obj, obj_state, __i, __funcs) \ for_each_private_obj(__state, &mst_state_funcs, obj, obj_state, __i, __funcs)I'd place the vfunc right after the state, since those are both input parameters to the macro, and specify what exactly we're looping over. To make this work you need something like:
#define for_each_private_obj(__state, obj_funcs, obj, obj_state, __i, __funcs) \ for ((__i) = 0; \ (__i) < (__state)->num_private_objs && \ ((obj) = (__state)->private_objs[__i].obj, \ (__funcs) = (__state)->private_objs[__i].funcs, \ (obj_state) = (__state)->private_objs[__i].obj_state, 1); \ (__i)++) \ for_each_if (__funcs == obj_funcs)Note the check to compare
__funcs==obj_funcs.With that other subsytem can the filter for their own objects only with e.g.
Quoted 7 lines
#define
intel_for_each_cdclk_state(__state, obj, obj_state, __i, __funcs)\
for_each_private_obj(__state, &intel_cdclk_state_funcs, obj, obj_state, __i, __funcs)Would be good to also then have kerneldoc for this iterator, to explain how to use it.
-Daniel
Quoted 6 lines
I see your point but we can't use this iterator in the
swap_state()helper if we do that. I have used it to swap states for all objects using this version without filtering.I guess, I can just code the iterator explicitly for
swap_state()and re-write the iterator with the filtering.
For swap states I'd use a raw iterator with a __ prefix, which does not have the vtable check. So yes, you need two I think.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 4/9] drm: Add driver private objects to atomic state
In reply to Daniel VetterQuoted 15 lines · Daniel Vetter
Quoted 11 lines · Dhinakaran Pandiyan
It is necessary to track states for objects other than connector, crtc and plane for atomic modesets. But adding objects like DP MST link bandwidth to
drm_atomic_statewould mean that a non-core object will be modified by the core helper functions for swapping and clearing it's state. So, lets add void * objects and helper functions that operate on void * types to keep these objects and states private to the core. Drivers can then implement specific functions to swap and clear states. The other advantage having just void * for these objects indrm_atomic_stateis that objects of different types can be managed in the same state array.Quoted 2 lines
Suggested-by Daniel Vetter <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>
Quoted 7 lines
I think an overview DOC: section to explain how to subclass atomic state and how to do private state objects would be great. But I can do that once your patch has landed, since it'd be much more about the overall design of atomic (and I promised to do that anyway).
Looks pretty good, a few nits below still. I'll also ask amd folks to check this out, and I think Ville could use it for his cdclk stuff.
Thanks for pinging me again about this. This should help with attaching our context to atomic_state in a clean fashion. I hope to show some patches of it soon after I rebase on top of drm-next + these patches.
Quoted 126 lines
Quoted 41 lines
--- drivers/gpu/drm/drm_atomic.c | 55 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_atomic_helper.c | 6 ++++ include/drm/drm_atomic.h | 30 ++++++++++++++++++++ 3 files changed, 91 insertions(+)drivers/gpu/drm/drm_atomic.c +15
-0@@ -57,6 +57,7 @@ void drm_atomic_state_default_release(struct drm_atomic_state *state)kfree (state->connectors);kfree (state->crtcs);kfree (state->planes); +kfree (state->private_objs); }EXPORT_SYMBOL (drm_atomic_state_default_release);@@ -184,6 +185,20 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state) state->planes[i].ptr =NULL ; state->planes[i].state =NULL ; } + +for (i =0 ; i < state->num_private_objs; i++) { +void *priv_obj = state->private_objs[i].obj; +void *obj_state = state->private_objs[i].obj_state; + +if (!priv_obj) +continue ; + + state->private_objs[i].funcs->destroy_state (obj_state); + state->private_objs[i].obj =NULL ; + state->private_objs[i].obj_state =NULL ; + state->private_objs[i].funcs =NULL ; + } + }EXPORT_SYMBOL (drm_atomic_state_default_clear);drivers/gpu/drm/drm_atomic.c static void drm_atomic_plane_print_state(struct drm_printer *p, · line 994
Quoted 4 lines
drivers/gpu/drm/drm_atomic.c +1
-0@@ -976,6 +991,46 @@ static void drm_atomic_plane_print_state(struct drm_printer *p, plane->funcs->atomic_print_state (p, state); } +Needs kerneldoc here.
drivers/gpu/drm/drm_atomic.c static void drm_atomic_plane_print_state(struct drm_printer *p, · line 996
Quoted 2 lines
drivers/gpu/drm/drm_atomic.c +2
-0+void * +drm_atomic_get_priv_obj_state(struct drm_atomic_state *state, void *obj,ocd bikeshed:
priv_objvsprivate_objinconsistency here, please stick to one (I don't care which one).Quoted 14 lines
drivers/gpu/drm/drm_atomic.c +14
-0+ const struct drm_private_state_funcs *funcs) +{ +int index, num_objs, i; +size_t size; +struct __drm_private_objs_state *arr; + +for (i =0 ; i < state->num_private_objs; i++) +if (obj == state->private_objs[i].obj && + state->private_objs[i].obj_state) +return state->private_objs[i].obj_state; + + num_objs = state->num_private_objs +1 ; + size =sizeof (*state->private_objs) * num_objs; + arr =krealloc (state->private_objs, size,GFP_KERNEL );drivers/gpu/drm/drm_atomic.c static void drm_atomic_plane_print_state(struct drm_printer *p, · line 1020
Quoted 10 lines
drivers/gpu/drm/drm_atomic.c +10
-0+if (!arr) +return ERR_PTR (-ENOMEM ); + + state->private_objs = arr; + index = state->num_private_objs; +memset (&state->private_objs[index],0 ,sizeof (*state->private_objs)); + + state->private_objs[index].obj_state = funcs->duplicate_state (state, obj); +if (!state->private_objs[index].obj_state) +return ERR_PTR (-ENOMEM );I wondered whether we need to allow other error codes than ENOMEM, e.g. if
duplicate_stateneeds to acquire aww_mutex. But we can always acquire the necessary locks outside ofdrm_atomic_get_priv_obj_statein some helper/driver wrapper. So no big deal, but worth explaining thatdrm_atomic_get_priv_obj_statewon't acquire necessarily locsk (since it doesn't know about them) in the kernel-doc.Quoted 40 lines
drivers/gpu/drm/drm_atomic.c +13
-0+ + state->private_objs[index].obj = obj; + state->private_objs[index].funcs = funcs; + state->num_private_objs = num_objs; + +DRM_DEBUG_ATOMIC ("Added new private object state %p to %p\n" , + state->private_objs[index].obj_state, state); + +return state->private_objs[index].obj_state; +} +EXPORT_SYMBOL (drm_atomic_get_priv_obj_state); + +/** * drm_atomic_get_connector_state - get connector state * @state: global atomic state object drivers/gpu/drm/drm_atomic_helper.c +6
-0@@ -1977,6 +1977,8 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,struct drm_plane *plane;struct drm_plane_state *plane_state;struct drm_crtc_commit *commit; +void *obj, *obj_state; +const struct drm_private_state_funcs *funcs;if (stall) {for_each_crtc_in_state (state, crtc, crtc_state, i) {@@ -2025,6 +2027,10 @@ void drm_atomic_helper_swap_state(struct drm_atomic_state *state,swap (state->planes[i].state, plane->state); plane->state->state =NULL ; } + +for_each_private_obj (state, obj, obj_state, i, funcs) { + funcs->swap_state (obj, &state->private_objs[i].obj_state); + } }EXPORT_SYMBOL (drm_atomic_helper_swap_state);
Quoted 13 lines
include/drm/drm_atomic.h struct __drm_connnectors_state { · line 155
Quoted 8 lines
include/drm/drm_atomic.h +0
-0@@ -153,6 +153,18 @@ struct __drm_connnectors_state {struct drm_connector_state *state; };This one needs kernel-doc too, since it's a struct that
drivers/helperswill need to implement. Please use the inline style and document expected semantics in detail, like we do for other vfunc tables.
Kerneldocs would definitely help.
Quoted 3 lines
include/drm/drm_atomic.h struct __drm_connnectors_state { · line 156
Quoted 1 line
include/drm/drm_atomic.h +1
-0+struct drm_private_state_funcs {I also wonder whether we shouldn't give this a
drm_atomic_prefix ...
I think leaving the atomic prefix out is more consistent with the other atomic state objects (drm_crtc_state, etc). drm_xyz_state seems to apply atomic.
I don't have a strong preference either way, though.
Harry
Quoted 85 lines
Quoted 47 lines
include/drm/drm_atomic.h +20
-0+void (*swap_state)(void *obj,void **obj_state_ptr); +void (*destroy_state)(void *obj_state); +void *(*duplicate_state)(struct drm_atomic_state *state,void *obj); +}; + +struct __drm_private_objs_state { +void *obj; +void *obj_state; +const struct drm_private_state_funcs *funcs; +}; +/** * struct drm_atomic_state - the global state object for atomic updates * @ref: count of all references to this state (will not be freed until zero) @@ -164,6 +176,8 @@ struct __drm_connnectors_state {* @crtcs: pointer to array of CRTC pointers * @num_connector: size of the @connectors and @connector_states arrays * @connectors: pointer to array of structures with per-connector data +* @num_private_objs: size of the @private_objs array +* @private_objs: pointer to array of private object pointers * @acquire_ctx: acquire context for this atomic modeset state update */ struct drm_atomic_state {@@ -177,6 +191,8 @@ struct drm_atomic_state {struct __drm_crtcs_state *crtcs;int num_connector;struct __drm_connnectors_state *connectors; +int num_private_objs; +struct __drm_private_objs_state *private_objs;struct drm_modeset_acquire_ctx *acquire_ctx;@@ -269,6 +285,11 @@ int drm_atomic_connector_set_property(struct drm_connector *connector, struct drm_connector_state *state, struct drm_property *property, uint64_t val); +void *__must_check +drm_atomic_get_priv_obj_state (struct drm_atomic_state *state, +void *obj, +const struct drm_private_state_funcs *funcs); +/** * drm_atomic_get_existing_crtc_state - get crtc state, if it exists * @state: global atomic state object @@ -413,6 +434,15 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p); (__i)++) \include/drm/drm_atomic.h void drm_state_dump(struct drm_device *dev, struct drm_printer *p); · line 444
Quoted 10 lines
include/drm/drm_atomic.h +8
-0for_each_if (plane_state) +#define for_each_private_obj (__state, obj, obj_state, __i, __funcs) \ + for ((__i) = 0; \ + (__i) < (__state)->num_private_objs && \ + ((obj) = (__state)->private_objs[__i].obj, \ + (__funcs) = (__state)->private_objs[__i].funcs, \ + (obj_state) = (__state)->private_objs[__i].obj_state, 1); \ + (__i)++) \ + for_each_if (__funcs)You are not filtering for the function table here, which is important to make sure that this can be used to only walk over objects with a given vtable. With that we can then #define specific macros for e.g. mst:
struct
drm_private_state_funcsmst_state_funcs;#define for_each_mst_state(__state, obj, obj_state, __i, __funcs) \ for_each_private_obj(__state, &mst_state_funcs, obj, obj_state, __i, __funcs)I'd place the vfunc right after the state, since those are both input parameters to the macro, and specify what exactly we're looping over. To make this work you need something like:
#define for_each_private_obj(__state, obj_funcs, obj, obj_state, __i, __funcs) \ for ((__i) = 0; \ (__i) < (__state)->num_private_objs && \ ((obj) = (__state)->private_objs[__i].obj, \ (__funcs) = (__state)->private_objs[__i].funcs, \ (obj_state) = (__state)->private_objs[__i].obj_state, 1); \ (__i)++) \ for_each_if (__funcs == obj_funcs)Note the check to compare
__funcs==obj_funcs.With that other subsytem can the filter for their own objects only with e.g.
Quoted 14 lines
#define
intel_for_each_cdclk_state(__state, obj, obj_state, __i, __funcs)\
for_each_private_obj(__state, &intel_cdclk_state_funcs, obj, obj_state, __i, __funcs)Would be good to also then have kerneldoc for this iterator, to explain how to use it.
-DanielQuoted 6 lines
include/drm/drm_atomic.h +0
-0/** * drm_atomic_crtc_needs_modeset - compute combined modeset need * @state: &drm_crtc_state for the CRTC Signature · 1 line
2.7.4
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 4/9] drm: Add driver private objects to atomic state
Quoted 11 lines · Harry Wentland
Quoted 4 lines · Daniel Vetter
Quoted 1 line · Dhinakaran Pandiyan
+struct
drm_private_state_funcs{I also wonder whether we shouldn't give this a
drm_atomic_prefix ...I think leaving the atomic prefix out is more consistent with the other atomic state objects (
drm_crtc_state, etc).drm_xyz_stateseems to apply atomic.I don't have a strong preference either way, though.
Yeah, makes sense ... I suggested the atomic prefix since it's (at least right now) only used for atomic updates. But just calling them drm_private_{state,obj} makes sense too.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 5/9 drm/dp: Introduce MST topology state
In reply to Dhinakaran PandiyanLink bandwidth is shared between multiple display streams in DP MST configurations. The DP MST topology manager structure maintains the shared link bandwidth for a primary link directly connected to the GPU. For atomic modesetting drivers, checking if there is sufficient link bandwidth for a mode needs to be done during the atomic_check phase to avoid failed modesets. Let's encsapsulate the available link bw information in a private state structure so that bw can be allocated and released atomically for each of the ports sharing the primary link.
--- drivers/gpu/drm/drm_dp_mst_topology.c | 60 +++++++++++++++++++++++++++++++++++ include/drm/drm_dp_mst_helper.h | 20 ++++++++++++ 2 files changed, 80 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +60 -0
@@ -2042,6 +2042,8 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms goto out_unlock; } +/* max. time slots - one slot for MTP header */ + mgr->state->avail_slots =63 ;/* add initial branch device at LCT 1 */ mstb =drm_dp_add_mst_branch_device (1 ,NULL );if (mstb ==NULL ) {
@@ -2935,6 +2937,55 @@ static void drm_dp_destroy_connector_work(struct work_struct *work) (*mgr->cbs->hotplug)(mgr); } +void drm_dp_mst_destroy_state (void *obj_state) +{ +kfree (obj_state); +} + +void drm_dp_mst_swap_state (void *obj,void **obj_state_ptr) +{ +struct drm_dp_mst_topology_mgr *mgr = obj; +struct drm_dp_mst_topology_state **topology_state_ptr; + + topology_state_ptr = (struct drm_dp_mst_topology_state **)obj_state_ptr; + + mgr->state->state = (*topology_state_ptr)->state; +swap (*topology_state_ptr, mgr->state); + mgr->state->state =NULL ; +} + +void *drm_dp_mst_duplicate_state (struct drm_atomic_state *state,void *obj) +{ +struct drm_dp_mst_topology_mgr *mgr = obj; +struct drm_dp_mst_topology_state *new_mst_state; + +if (WARN_ON (!mgr->state)) +return NULL ; + + new_mst_state =kmalloc (sizeof (*new_mst_state),GFP_KERNEL ); +if (new_mst_state) { + new_mst_state->avail_slots = mgr->state->avail_slots; + new_mst_state->mgr = mgr; + new_mst_state->state = state; + } + +return new_mst_state; +} + +static const struct drm_private_state_funcs mst_state_funcs = { + .swap_state = drm_dp_mst_swap_state, + .destroy_state = drm_dp_mst_destroy_state, + .duplicate_state = drm_dp_mst_duplicate_state, +}; + +struct drm_dp_mst_topology_state *drm_atomic_get_mst_topology_state (struct drm_atomic_state *state, +struct drm_dp_mst_topology_mgr *mgr) +{ +return drm_atomic_get_priv_obj_state (state, mgr, + &mst_state_funcs); +} +EXPORT_SYMBOL (drm_atomic_get_mst_topology_state); +/** * drm_dp_mst_topology_mgr_init - initialise a topology manager * @mgr: manager struct to initialise
@@ -2979,6 +3030,12 @@ int drm_dp_mst_topology_mgr_init(struct drm_dp_mst_topology_mgr *mgr,if (test_calc_pbn_mode () <0 )DRM_ERROR ("MST PBN self-test failed\n" ); + mgr->state =kzalloc (sizeof (*mgr->state),GFP_KERNEL ); +if (mgr->state ==NULL ) +return -ENOMEM ; + mgr->state->mgr = mgr; + mgr->funcs = &mst_state_funcs; +return 0 ; }EXPORT_SYMBOL (drm_dp_mst_topology_mgr_init);
@@ -2999,6 +3056,9 @@ void drm_dp_mst_topology_mgr_destroy(struct drm_dp_mst_topology_mgr *mgr)mutex_unlock (&mgr->payload_lock); mgr->dev =NULL ; mgr->aux =NULL ; +kfree (mgr->state); + mgr->state =NULL ; + mgr->funcs =NULL ; }EXPORT_SYMBOL (drm_dp_mst_topology_mgr_destroy);
include/drm/drm_dp_mst_helper.h +20 -0
@@ -24,6 +24,7 @@#include <linux/types.h> #include <drm/drm_dp_helper.h> +#include <drm/drm_atomic.h> struct drm_dp_mst_branch ;
@@ -403,6 +404,12 @@ struct drm_dp_payload {int vcpi; }; +struct drm_dp_mst_topology_state { +int avail_slots; +struct drm_atomic_state *state; +struct drm_dp_mst_topology_mgr *mgr; +}; +/** * struct drm_dp_mst_topology_mgr - DisplayPort MST manager *
@@ -481,6 +488,16 @@ struct drm_dp_mst_topology_mgr {int pbn_div;/** +* @state: State information for topology manager +*/ +struct drm_dp_mst_topology_state *state; + +/** +* @funcs: Atomic helper callbacks +*/ +const struct drm_private_state_funcs *funcs; + +/** * @qlock: protects @tx_msg_downq, the tx_slots in struct * &drm_dp_mst_branch and txmsg->state once they are queued */
@@ -596,4 +613,7 @@ void drm_dp_mst_dump_topology(struct seq_file *m,void drm_dp_mst_topology_mgr_suspend (struct drm_dp_mst_topology_mgr *mgr);int drm_dp_mst_topology_mgr_resume (struct drm_dp_mst_topology_mgr *mgr); +struct drm_dp_mst_topology_state *drm_atomic_get_mst_topology_state (struct drm_atomic_state *state, +struct drm_dp_mst_topology_mgr *mgr); +#endif
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 5/9] drm/dp: Introduce MST topology state
Quoted 10 lines · Dhinakaran Pandiyan
Link bandwidth is shared between multiple display streams in DP MST configurations. The DP MST topology manager structure maintains the shared link bandwidth for a primary link directly connected to the GPU. For atomic modesetting drivers, checking if there is sufficient link bandwidth for a mode needs to be done during the
atomic_checkphase to avoid failed modesets. Let's encsapsulate the available link bw information in a private state structure so that bw can be allocated and released atomically for each of the ports sharing the primary link.Signed-off-by Dhinakaran Pandiyan <[email protected]>
Yeah, I like how this neatly hides all the atomic state tracking now, and just leaves the mst specific logic in the mst helpers.
Quoted 10 lines
--- drivers/gpu/drm/drm_dp_mst_topology.c | 60 +++++++++++++++++++++++++++++++++++ include/drm/drm_dp_mst_helper.h | 20 ++++++++++++ 2 files changed, 80 insertions(+)drivers/gpu/drm/drm_dp_mst_topology.c +0
-0
drivers/gpu/drm/drm_dp_mst_topology.c int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms · line 2046
Quoted 5 lines
drivers/gpu/drm/drm_dp_mst_topology.c +2
-0@@ -2042,6 +2042,8 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms goto out_unlock; } +/* max. time slots - one slot for MTP header */ + mgr->state->avail_slots =63 ;
We can't reset atomic state on each hotplug, that would wreak the atomic tracking. E.g. there might still be a pipe around running on this output, and then we'd go above 63 slots when we release that one. You need to init this once in drm_dp_mst_topology_mgr_init() and then make sure it's always accurate.
Quoted 28 lines
drivers/gpu/drm/drm_dp_mst_topology.c +21
-0/* add initial branch device at LCT 1 */ mstb =drm_dp_add_mst_branch_device (1 ,NULL );if (mstb ==NULL ) {@@ -2935,6 +2937,55 @@ static void drm_dp_destroy_connector_work(struct work_struct *work) (*mgr->cbs->hotplug)(mgr); } +void drm_dp_mst_destroy_state (void *obj_state) +{ +kfree (obj_state); +} + +void drm_dp_mst_swap_state (void *obj,void **obj_state_ptr) +{ +struct drm_dp_mst_topology_mgr *mgr = obj; +struct drm_dp_mst_topology_state **topology_state_ptr; + + topology_state_ptr = (struct drm_dp_mst_topology_state **)obj_state_ptr; + + mgr->state->state = (*topology_state_ptr)->state; +swap (*topology_state_ptr, mgr->state); + mgr->state->state =NULL ; +} + +void *drm_dp_mst_duplicate_state (struct drm_atomic_state *state,void *obj) +{ +struct drm_dp_mst_topology_mgr *mgr = obj; +struct drm_dp_mst_topology_state *new_mst_state;
drivers/gpu/drm/drm_dp_mst_topology.c static void drm_dp_destroy_connector_work(struct work_struct *work) · line 2970
Quoted 10 lines
drivers/gpu/drm/drm_dp_mst_topology.c +10
-0+ +if (WARN_ON (!mgr->state)) +return NULL ; + + new_mst_state =kmalloc (sizeof (*new_mst_state),GFP_KERNEL ); +if (new_mst_state) { + new_mst_state->avail_slots = mgr->state->avail_slots; + new_mst_state->mgr = mgr; + new_mst_state->state = state; + }
kmemdup is less code :-)
drivers/gpu/drm/drm_dp_mst_topology.c static void drm_dp_destroy_connector_work(struct work_struct *work) · line 2980
Quoted 10 lines
drivers/gpu/drm/drm_dp_mst_topology.c +10
-0+ +return new_mst_state; +} + +static const struct drm_private_state_funcs mst_state_funcs = { + .swap_state = drm_dp_mst_swap_state, + .destroy_state = drm_dp_mst_destroy_state, + .duplicate_state = drm_dp_mst_duplicate_state, +}; +
Needs a few lines of kernel-doc here since it's an exported function.
Cheers, Daniel
Quoted 87 lines
drivers/gpu/drm/drm_dp_mst_topology.c +17
-0+struct drm_dp_mst_topology_state *drm_atomic_get_mst_topology_state (struct drm_atomic_state *state, +struct drm_dp_mst_topology_mgr *mgr) +{ +return drm_atomic_get_priv_obj_state (state, mgr, + &mst_state_funcs); +} +EXPORT_SYMBOL (drm_atomic_get_mst_topology_state); +/** * drm_dp_mst_topology_mgr_init - initialise a topology manager * @mgr: manager struct to initialise @@ -2979,6 +3030,12 @@ int drm_dp_mst_topology_mgr_init(struct drm_dp_mst_topology_mgr *mgr,if (test_calc_pbn_mode () <0 )DRM_ERROR ("MST PBN self-test failed\n" ); + mgr->state =kzalloc (sizeof (*mgr->state),GFP_KERNEL ); +if (mgr->state ==NULL ) +return -ENOMEM ; + mgr->state->mgr = mgr; + mgr->funcs = &mst_state_funcs; +return 0 ; }EXPORT_SYMBOL (drm_dp_mst_topology_mgr_init);@@ -2999,6 +3056,9 @@ void drm_dp_mst_topology_mgr_destroy(struct drm_dp_mst_topology_mgr *mgr)mutex_unlock (&mgr->payload_lock); mgr->dev =NULL ; mgr->aux =NULL ; +kfree (mgr->state); + mgr->state =NULL ; + mgr->funcs =NULL ; }EXPORT_SYMBOL (drm_dp_mst_topology_mgr_destroy);include/drm/drm_dp_mst_helper.h +20
-0@@ -24,6 +24,7 @@#include <linux/types.h> #include <drm/drm_dp_helper.h> +#include <drm/drm_atomic.h> struct drm_dp_mst_branch ;@@ -403,6 +404,12 @@ struct drm_dp_payload {int vcpi; }; +struct drm_dp_mst_topology_state { +int avail_slots; +struct drm_atomic_state *state; +struct drm_dp_mst_topology_mgr *mgr; +}; +/** * struct drm_dp_mst_topology_mgr - DisplayPort MST manager * @@ -481,6 +488,16 @@ struct drm_dp_mst_topology_mgr {int pbn_div;/** +* @state: State information for topology manager +*/ +struct drm_dp_mst_topology_state *state; + +/** +* @funcs: Atomic helper callbacks +*/ +const struct drm_private_state_funcs *funcs; + +/** * @qlock: protects @tx_msg_downq, the tx_slots in struct * &drm_dp_mst_branch and txmsg->state once they are queued */ @@ -596,4 +613,7 @@ void drm_dp_mst_dump_topology(struct seq_file *m,void drm_dp_mst_topology_mgr_suspend (struct drm_dp_mst_topology_mgr *mgr);int drm_dp_mst_topology_mgr_resume (struct drm_dp_mst_topology_mgr *mgr); +struct drm_dp_mst_topology_state *drm_atomic_get_mst_topology_state (struct drm_atomic_state *state, +struct drm_dp_mst_topology_mgr *mgr); +#endif Signature · 1 line
2.7.4
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 6/9 drm/dp: Add DP MST helpers to atomically find and release vcpi slots
In reply to Dhinakaran Pandiyandrm_dp_atomic_find_vcpi_slots() should be called from ->atomic_check() to check there are sufficient vcpi slots for a mode and to add that to the state. This should be followed by a call to drm_dp_mst_allocate_vcpi() in ->atomic_commit() to initialize a struct vcpi for the port.
drm_dp_atomic_release_vcpi_slots() should be called from ->atomic_check() to release a port's vcpi slot allocation from the state.
Drivers that do not make use of this atomic helper are expected to call drm_dp_find_vcpi_slots() instead before calling drm_dp_mst_allocate_vcpi().
--- drivers/gpu/drm/drm_dp_mst_topology.c | 43 +++++++++++++++++++++++++++++++++++ include/drm/drm_dp_mst_helper.h | 4 ++++ 2 files changed, 47 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +43 -0
@@ -2500,6 +2500,49 @@ static int drm_dp_init_vcpi(struct drm_dp_mst_topology_mgr *mgr, }/** +* drm_dp_atomic_release_vcpi_slots() - Release allocated vcpi slots +* @topology_state: MST topology state +* @port: port to release the vcpi slots for +*/ +int drm_dp_atomic_release_vcpi_slots (struct drm_dp_mst_topology_state *topology_state, +struct drm_dp_mst_port *port) +{ +int alloc =drm_dp_mst_get_vcpi_slots (topology_state->mgr, port); + + topology_state->avail_slots += alloc; +DRM_DEBUG_KMS ("vcpi slots released=%d, avail=%d\n" , + alloc, topology_state->avail_slots); +return alloc; +} +EXPORT_SYMBOL (drm_dp_atomic_release_vcpi_slots); + +/** +* drm_dp_atomic_find_vcpi_slots() - Find and add vcpi slots to the state +* @topology_state: MST topology state +* @port: port to find vcpi slots for +* @pbn: bandwidth required for the mode in PBN +*/ +int drm_dp_atomic_find_vcpi_slots (struct drm_dp_mst_topology_state *topology_state, +struct drm_dp_mst_port *port,int pbn) +{ +int num_slots, curr_alloc; +struct drm_dp_mst_topology_mgr *mgr = topology_state->mgr; + + num_slots =DIV_ROUND_UP (pbn, mgr->pbn_div); + curr_alloc =drm_dp_mst_get_vcpi_slots (mgr, port); +DRM_DEBUG_KMS ("vcpi slots req=%d, curr=%d, avail=%d\n" , + num_slots, curr_alloc, topology_state->avail_slots); + +if (num_slots - curr_alloc > topology_state->avail_slots) +return -ENOSPC ; + + topology_state->avail_slots -= (num_slots - curr_alloc); +DRM_DEBUG_KMS ("vcpi slots avail=%d" , topology_state->avail_slots); +return num_slots; +} +EXPORT_SYMBOL (drm_dp_atomic_find_vcpi_slots); + +/** * drm_dp_mst_allocate_vcpi() - Allocate a virtual channel * @mgr: manager for this port * @port: port to allocate a virtual channel for.
include/drm/drm_dp_mst_helper.h +4 -0
@@ -615,5 +615,9 @@ void drm_dp_mst_topology_mgr_suspend(struct drm_dp_mst_topology_mgr *mgr);int drm_dp_mst_topology_mgr_resume (struct drm_dp_mst_topology_mgr *mgr);struct drm_dp_mst_topology_state *drm_atomic_get_mst_topology_state (struct drm_atomic_state *state,struct drm_dp_mst_topology_mgr *mgr); +int drm_dp_atomic_find_vcpi_slots (struct drm_dp_mst_topology_state *topology_state, +struct drm_dp_mst_port *port,int pbn); +int drm_dp_atomic_release_vcpi_slots (struct drm_dp_mst_topology_state *topology_state, +struct drm_dp_mst_port *port);#endif
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 7/9 drm: Connector helper function to release atomic state
In reply to Dhinakaran PandiyanHaving a ->atomic_release callback is useful to release shared resources that get allocated in compute_config().
--- include/drm/drm_modeset_helper_vtables.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
include/drm/drm_modeset_helper_vtables.h +15 -0
@@ -831,6 +831,21 @@ struct drm_connector_helper_funcs {*/ struct drm_encoder *(*atomic_best_encoder)(struct drm_connector *connector,struct drm_connector_state *connector_state); + +/** +* @atomic_release: +* +* This function is used to release shared resources that were +* previously acquired. For example, resources acquired in +* encoder->compute_config() can be released by calling this function +* from mode_fixup() +* +* NOTE: +* +* This function is called in the check phase of an atomic update. +*/ +void (*atomic_release)(struct drm_connector *connector, +struct drm_connector_state *connector_state); };/**
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 7/9] drm: Connector helper function to release atomic state
Quoted 14 lines · Dhinakaran Pandiyan
Having a ->atomic_release callback is useful to release shared resources that get allocated in
compute_config().Suggested-by Daniel Vetter <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>--- include/drm/drm_modeset_helper_vtables.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)include/drm/drm_modeset_helper_vtables.h +0
-0
include/drm/drm_modeset_helper_vtables.h struct drm_connector_helper_funcs { · line 840
Quoted 10 lines
include/drm/drm_modeset_helper_vtables.h +7
-0@@ -831,6 +831,21 @@ struct drm_connector_helper_funcs {*/ struct drm_encoder *(*atomic_best_encoder)(struct drm_connector *connector,struct drm_connector_state *connector_state); + +/** +* @atomic_release: +* +* This function is used to release shared resources that were +* previously acquired. For example, resources acquired in +* encoder->compute_config() can be released by calling this function
@compute_config is the right way to do references within the same struct.
include/drm/drm_modeset_helper_vtables.h struct drm_connector_helper_funcs { · line 841
Quoted 1 line
include/drm/drm_modeset_helper_vtables.h +1
-0+* from mode_fixup()
Same here.
Patch split up is a bit strange, hence why my review of the design is in later patches.
Thanks, Daniel
Quoted 13 lines
include/drm/drm_modeset_helper_vtables.h +7
-0+* +* NOTE: +* +* This function is called in the check phase of an atomic update. +*/ +void (*atomic_release)(struct drm_connector *connector, +struct drm_connector_state *connector_state); };/** Signature · 1 line
2.7.4
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 7/9] drm: Connector helper function to release atomic state
Quoted 28 lines · Daniel Vetter
Quoted 14 lines · Dhinakaran Pandiyan
Having a ->atomic_release callback is useful to release shared resources that get allocated in
compute_config().Suggested-by Daniel Vetter <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>--- include/drm/drm_modeset_helper_vtables.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)include/drm/drm_modeset_helper_vtables.h +0
-0include/drm/drm_modeset_helper_vtables.h struct drm_connector_helper_funcs { · line 840
Quoted 10 lines
include/drm/drm_modeset_helper_vtables.h +7
-0@@ -831,6 +831,21 @@ struct drm_connector_helper_funcs {*/ struct drm_encoder *(*atomic_best_encoder)(struct drm_connector *connector,struct drm_connector_state *connector_state); + +/** +* @atomic_release: +* +* This function is used to release shared resources that were +* previously acquired. For example, resources acquired in +* encoder->compute_config() can be released by calling this function @compute_config is the right way to do references within the same struct.
Quoted 9 lines
include/drm/drm_modeset_helper_vtables.h struct drm_connector_helper_funcs { · line 841
Quoted 1 line
include/drm/drm_modeset_helper_vtables.h +1
-0+* from mode_fixup() Same here.
Patch split up is a bit strange, hence why my review of the design is in later patches.
Thanks, Daniel
I'll squash them appropriately, thanks for the review.
-DK
Quoted 9 lines
Quoted 9 lines
include/drm/drm_modeset_helper_vtables.h +7
-0+* +* NOTE: +* +* This function is called in the check phase of an atomic update. +*/ +void (*atomic_release)(struct drm_connector *connector, +struct drm_connector_state *connector_state); };
Quoted 5 lines
Quoted 4 lines
include/drm/drm_modeset_helper_vtables.h +0
-0/** Signature · 1 line
2.7.4
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 7/9] drm: Connector helper function to release atomic state
In reply to Daniel VetterQuoted 19 lines · Daniel Vetter
Quoted 18 lines · Dhinakaran Pandiyan
Having a ->atomic_release callback is useful to release shared resources that get allocated in
compute_config().Suggested-by Daniel Vetter <[email protected]>Signed-off-by Dhinakaran Pandiyan <[email protected]>--- include/drm/drm_modeset_helper_vtables.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)include/drm/drm_modeset_helper_vtables.h +1
-0@@ -831,6 +831,21 @@ struct drm_connector_helper_funcs {*/ struct drm_encoder *(*atomic_best_encoder)(struct drm_connector *connector,struct drm_connector_state *connector_state); +
Quoted 8 lines
include/drm/drm_modeset_helper_vtables.h struct drm_connector_helper_funcs { · line 840
Quoted 6 lines
include/drm/drm_modeset_helper_vtables.h +6
-0+/** +* @atomic_release: +* +* This function is used to release shared resources that were +* previously acquired. For example, resources acquired in +* encoder->compute_config() can be released by calling this function @compute_config is the right way to do references within the same struct.
compute_config is not in the same structure, which made me realize I should not be referring to compute_config() at all, as it is a helper for struct intel_encoder.
-DK
Quoted 19 lines
include/drm/drm_modeset_helper_vtables.h struct drm_connector_helper_funcs { · line 841
Quoted 2 lines
include/drm/drm_modeset_helper_vtables.h +1
-0+* from mode_fixup() Same here.
Patch split up is a bit strange, hence why my review of the design is in later patches.
Thanks, Daniel
Quoted 9 lines
include/drm/drm_modeset_helper_vtables.h +7
-0+* +* NOTE: +* +* This function is called in the check phase of an atomic update. +*/ +void (*atomic_release)(struct drm_connector *connector, +struct drm_connector_state *connector_state); };
Quoted 5 lines
Quoted 4 lines
include/drm/drm_modeset_helper_vtables.h +0
-0/** Signature · 1 line
2.7.4
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 8/9 drm/dp: Release DP MST shared link bandwidth
In reply to Dhinakaran PandiyanImplement the ->atomic_release() callback to release the shared link bandwidth that was originally acquired during compute_config()
--- drivers/gpu/drm/i915/intel_dp_mst.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/gpu/drm/i915/intel_dp_mst.c +28 -0
@@ -78,6 +78,33 @@ static bool intel_dp_mst_compute_config(struct intel_encoder *encoder, } +static void intel_dp_mst_atomic_release (struct drm_connector *connector, +struct drm_connector_state *conn_state) +{ +struct intel_dp_mst_encoder *intel_mst; +struct drm_dp_mst_topology_mgr *mgr; +struct drm_dp_mst_topology_state *topology_state; +struct drm_encoder *encoder; +struct intel_connector *intel_connector =to_intel_connector (connector); + + encoder = connector->state->best_encoder; +if (!encoder ||to_intel_encoder (encoder)->type !=INTEL_OUTPUT_DP_MST ) +return ; + + intel_mst =enc_to_mst (encoder); + mgr = &intel_mst->primary->dp.mst_mgr; + + topology_state =drm_atomic_get_mst_topology_state (conn_state->state, + mgr); +if (IS_ERR (topology_state)) { +DRM_DEBUG_KMS ("failed to create MST topology state %ld\n" , +PTR_ERR (topology_state)); +return ; + } + +drm_dp_atomic_release_vcpi_slots (topology_state, intel_connector->port); +} +static void intel_mst_disable_dp (struct intel_encoder *encoder,struct intel_crtc_state *old_crtc_state,struct drm_connector_state *old_conn_state)
@@ -401,6 +428,7 @@ static const struct drm_connector_helper_funcs intel_dp_mst_connector_helper_fun .mode_valid = intel_dp_mst_mode_valid, .atomic_best_encoder = intel_mst_atomic_best_encoder, .best_encoder = intel_mst_best_encoder, + .atomic_release = intel_dp_mst_atomic_release, };static void intel_dp_mst_encoder_destroy (struct drm_encoder *encoder)
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 8/9] drm/dp: Release DP MST shared link bandwidth
Quoted 18 lines · Dhinakaran Pandiyan
Implement the ->atomic_release() callback to release the shared link bandwidth that was originally acquired during
compute_config()Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/i915/intel_dp_mst.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/gpu/drm/i915/intel_dp_mst.c +2
-0@@ -78,6 +78,33 @@ static bool intel_dp_mst_compute_config(struct intel_encoder *encoder, } +static void intel_dp_mst_atomic_release (struct drm_connector *connector, +struct drm_connector_state *conn_state)
drivers/gpu/drm/i915/intel_dp_mst.c static bool intel_dp_mst_compute_config(struct intel_encoder *encoder, · line 92
Quoted 10 lines
drivers/gpu/drm/i915/intel_dp_mst.c +10
-0+{ +struct intel_dp_mst_encoder *intel_mst; +struct drm_dp_mst_topology_mgr *mgr; +struct drm_dp_mst_topology_state *topology_state; +struct drm_encoder *encoder; +struct intel_connector *intel_connector =to_intel_connector (connector); + + encoder = connector->state->best_encoder; +if (!encoder ||to_intel_encoder (encoder)->type !=INTEL_OUTPUT_DP_MST ) +return ;
NULL encoder should imo be caught in core. Type != DP_MST is impossible, if you're unsure make it into a BUG_ON for testing.
drivers/gpu/drm/i915/intel_dp_mst.c static bool intel_dp_mst_compute_config(struct intel_encoder *encoder, · line 105
Quoted 13 lines
drivers/gpu/drm/i915/intel_dp_mst.c +13
-0+ + intel_mst =enc_to_mst (encoder); + mgr = &intel_mst->primary->dp.mst_mgr; + + topology_state =drm_atomic_get_mst_topology_state (conn_state->state, + mgr); +if (IS_ERR (topology_state)) { +DRM_DEBUG_KMS ("failed to create MST topology state %ld\n" , +PTR_ERR (topology_state)); +return ; + } + +drm_dp_atomic_release_vcpi_slots (topology_state, intel_connector->port);
I think it'd be great to merge this together into 1 helper that both gets the state and releases the vcpi, for less code in drivers.
Quoted 16 lines
drivers/gpu/drm/i915/intel_dp_mst.c +3
-0+} +static void intel_mst_disable_dp (struct intel_encoder *encoder,struct intel_crtc_state *old_crtc_state,struct drm_connector_state *old_conn_state)@@ -401,6 +428,7 @@ static const struct drm_connector_helper_funcs intel_dp_mst_connector_helper_fun .mode_valid = intel_dp_mst_mode_valid, .atomic_best_encoder = intel_mst_atomic_best_encoder, .best_encoder = intel_mst_best_encoder, + .atomic_release = intel_dp_mst_atomic_release, };static void intel_dp_mst_encoder_destroy (struct drm_encoder *encoder)Signature · 1 line
2.7.4
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 8/9] drm/dp: Release DP MST shared link bandwidth
Quoted 17 lines · Daniel Vetter
Quoted 16 lines · Dhinakaran Pandiyan
Implement the ->atomic_release() callback to release the shared link bandwidth that was originally acquired during
compute_config()Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/i915/intel_dp_mst.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/gpu/drm/i915/intel_dp_mst.c +0
-0@@ -78,6 +78,33 @@ static bool intel_dp_mst_compute_config(struct intel_encoder *encoder, }
Quoted 15 lines
drivers/gpu/drm/i915/intel_dp_mst.c static bool intel_dp_mst_compute_config(struct intel_encoder *encoder, · line 92
Quoted 12 lines
drivers/gpu/drm/i915/intel_dp_mst.c +12
-0+static void intel_dp_mst_atomic_release (struct drm_connector *connector, +struct drm_connector_state *conn_state) +{ +struct intel_dp_mst_encoder *intel_mst; +struct drm_dp_mst_topology_mgr *mgr; +struct drm_dp_mst_topology_state *topology_state; +struct drm_encoder *encoder; +struct intel_connector *intel_connector =to_intel_connector (connector); + + encoder = connector->state->best_encoder; +if (!encoder ||to_intel_encoder (encoder)->type !=INTEL_OUTPUT_DP_MST ) +return ;NULL encoder should imo be caught in core. Type !=
DP_MSTis impossible, if you're unsure make it into aBUG_ONfor testing.
I don't get why (type != INTEL_OUTPUT_DP_MST) is impossible. Is that because we have the implementation for atomic_release() only for MST connectors? But, that is only for now.
-DK
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_dp_mst.c +8
-0+ + intel_mst =enc_to_mst (encoder); + mgr = &intel_mst->primary->dp.mst_mgr; + + topology_state =drm_atomic_get_mst_topology_state (conn_state->state, + mgr); +if (IS_ERR (topology_state)) { + DRM_DEBUG_KMS("failed to create MST topology state %ld\n",
Quoted 8 lines
drivers/gpu/drm/i915/intel_dp_mst.c static bool intel_dp_mst_compute_config(struct intel_encoder *encoder, · line 105
Quoted 5 lines
drivers/gpu/drm/i915/intel_dp_mst.c +5
-0+ PTR_ERR(topology_state)); +return ; + } + +drm_dp_atomic_release_vcpi_slots (topology_state, intel_connector->port);I think it'd be great to merge this together into 1 helper that both gets the state and releases the vcpi, for less code in drivers.
Agreed.
Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/i915/intel_dp_mst.c +3
-0+} +static void intel_mst_disable_dp (struct intel_encoder *encoder,struct intel_crtc_state *old_crtc_state,struct drm_connector_state *old_conn_state)@@ -401,6 +428,7 @@ static const struct drm_connector_helper_funcs intel_dp_mst_connector_helper_fun .mode_valid = intel_dp_mst_mode_valid, .atomic_best_encoder = intel_mst_atomic_best_encoder, .best_encoder = intel_mst_best_encoder, + .atomic_release = intel_dp_mst_atomic_release, };
Quoted 5 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_dp_mst.c +0
-0static void intel_dp_mst_encoder_destroy (struct drm_encoder *encoder)Signature · 1 line
2.7.4
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v2 8/9] drm/dp: Release DP MST shared link bandwidth
Quoted 35 lines · Dhinakaran
Quoted 17 lines · Daniel Vetter
Quoted 16 lines · Dhinakaran Pandiyan
Implement the ->atomic_release() callback to release the shared link bandwidth that was originally acquired during
compute_config()Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/i915/intel_dp_mst.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/gpu/drm/i915/intel_dp_mst.c +0
-0@@ -78,6 +78,33 @@ static bool intel_dp_mst_compute_config(struct intel_encoder *encoder, }Quoted 15 lines
drivers/gpu/drm/i915/intel_dp_mst.c static bool intel_dp_mst_compute_config(struct intel_encoder *encoder, · line 92
Quoted 12 lines
drivers/gpu/drm/i915/intel_dp_mst.c +12
-0+static void intel_dp_mst_atomic_release (struct drm_connector *connector, +struct drm_connector_state *conn_state) +{ +struct intel_dp_mst_encoder *intel_mst; +struct drm_dp_mst_topology_mgr *mgr; +struct drm_dp_mst_topology_state *topology_state; +struct drm_encoder *encoder; +struct intel_connector *intel_connector =to_intel_connector (connector); + + encoder = connector->state->best_encoder; +if (!encoder ||to_intel_encoder (encoder)->type !=INTEL_OUTPUT_DP_MST ) +return ;NULL encoder should imo be caught in core. Type !=
DP_MSTis impossible, if you're unsure make it into aBUG_ONfor testing.
Quoted 3 lines
I don't get why (type !=
INTEL_OUTPUT_DP_MST) is impossible. Is that because we have the implementation foratomic_release()only for MST connectors? But, that is only for now.
Yes. And if we add atomic_release for other encoders, then ofcourse we will not reuse the mst one there. See all the other intel_dp_mst_* hooks in the same vfunc table, those also don't check for the encoder type. This would be like doing a runtime type check in C++ for the "this" pointer :-) -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 9/9 drm/dp: Track MST link bandwidth
In reply to Dhinakaran PandiyanUse the added helpers to track MST link bandwidth for atomic modesets. Link bw is acquired in the ->atomic_check() phase when CRTCs are being enabled with drm_atomic_find_vcpi_slots() instead of drm_find_vcpi_slots(). Similarly, link bw is released during ->atomic_check() with the connector helper callback ->atomic_release() when CRTCs are disabled.
--- drivers/gpu/drm/drm_atomic_helper.c | 9 ++++++++- drivers/gpu/drm/i915/intel_dp_mst.c | 13 ++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +8 -1
@@ -385,8 +385,15 @@ mode_fixup(struct drm_atomic_state *state)WARN_ON (!!conn_state->best_encoder != !!conn_state->crtc); -if (!conn_state->crtc || !conn_state->best_encoder) +if (!conn_state->crtc || !conn_state->best_encoder) { +const struct drm_connector_helper_funcs *conn_funcs; + + conn_funcs = connector->helper_private; +if (conn_funcs->atomic_release) + conn_funcs->atomic_release (connector, + conn_state);continue ; + } crtc_state =drm_atomic_get_existing_crtc_state (state, conn_state->crtc);
drivers/gpu/drm/i915/intel_dp_mst.c +12 -1
@@ -44,6 +44,7 @@ static bool intel_dp_mst_compute_config(struct intel_encoder *encoder,int lane_count, slots;const struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;int mst_pbn; +struct drm_dp_mst_topology_state *topology_state; pipe_config->has_pch_encoder = false; bpp =24 ;
@@ -65,7 +66,17 @@ static bool intel_dp_mst_compute_config(struct intel_encoder *encoder, mst_pbn =drm_dp_calc_pbn_mode (adjusted_mode->crtc_clock, bpp); pipe_config->pbn = mst_pbn; - slots =drm_dp_find_vcpi_slots (&intel_dp->mst_mgr, mst_pbn); + topology_state =drm_atomic_get_mst_topology_state (state, + &intel_dp->mst_mgr); +if (topology_state ==NULL ) +return false; + + slots =drm_dp_atomic_find_vcpi_slots (topology_state, connector->port, + mst_pbn); +if (slots <0 ) { +DRM_DEBUG_KMS ("not enough link bw for this mode\n" ); +return false; + } intel_link_compute_m_n(bpp, lane_count, adjusted_mode->crtc_clock,
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 9/9] drm/dp: Track MST link bandwidth
Quoted 18 lines · Dhinakaran Pandiyan
Use the added helpers to track MST link bandwidth for atomic modesets. Link bw is acquired in the ->atomic_check() phase when CRTCs are being enabled with
drm_atomic_find_vcpi_slots()instead ofdrm_find_vcpi_slots(). Similarly, link bw is released during ->atomic_check() with the connector helper callback ->atomic_release() when CRTCs are disabled.Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 9 ++++++++- drivers/gpu/drm/i915/intel_dp_mst.c | 13 ++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_atomic_helper.c +0
-0@@ -385,8 +385,15 @@ mode_fixup(struct drm_atomic_state *state)
drivers/gpu/drm/drm_atomic_helper.c mode_fixup(struct drm_atomic_state *state) · line 394
Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +7
-1WARN_ON (!!conn_state->best_encoder != !!conn_state->crtc); -if (!conn_state->crtc || !conn_state->best_encoder) +if (!conn_state->crtc || !conn_state->best_encoder) { +const struct drm_connector_helper_funcs *conn_funcs; + + conn_funcs = connector->helper_private; +if (conn_funcs->atomic_release) + conn_funcs->atomic_release (connector, + conn_state);
I wonder whether this won't surprise drivers: The way you coded this release only gets called when the connector is fully disabled. But it does not get called when you atomically switch it from one crtc to the other (in which case you also might want to release resources, before allocating new ones). I think that case of directly switching stuff is even a bug in your current atomic tracking code ...
We also need to extract the release calls into a separate loop which runs _before_ we allocate any resources. Otherwise if you do an atomic commit where you disable connector2 and enable connector1 and they can't run both at the same time it'll fail, because we'll release the vcpi for connector2 only after we've tried to get it for connnector1.
drivers/gpu/drm/drm_atomic_helper.c mode_fixup(struct drm_atomic_state *state) · line 399
Quoted 5 lines
drivers/gpu/drm/drm_atomic_helper.c +1
-0continue ; + } crtc_state =drm_atomic_get_existing_crtc_state (state, conn_state->crtc);
Misplaced hunk, this needs to be in the patch that adds the ->atomic_release callback.
Quoted 14 lines
drivers/gpu/drm/i915/intel_dp_mst.c +1
-0@@ -44,6 +44,7 @@ static bool intel_dp_mst_compute_config(struct intel_encoder *encoder,int lane_count, slots;const struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;int mst_pbn; +struct drm_dp_mst_topology_state *topology_state; pipe_config->has_pch_encoder = false; bpp =24 ;@@ -65,7 +66,17 @@ static bool intel_dp_mst_compute_config(struct intel_encoder *encoder, mst_pbn =drm_dp_calc_pbn_mode (adjusted_mode->crtc_clock, bpp);
drivers/gpu/drm/i915/intel_dp_mst.c static bool intel_dp_mst_compute_config(struct intel_encoder *encoder, · line 75
Quoted 10 lines
drivers/gpu/drm/i915/intel_dp_mst.c +7
-1pipe_config->pbn = mst_pbn; - slots =drm_dp_find_vcpi_slots (&intel_dp->mst_mgr, mst_pbn); + topology_state =drm_atomic_get_mst_topology_state (state, + &intel_dp->mst_mgr); +if (topology_state ==NULL ) +return false; + + slots =drm_dp_atomic_find_vcpi_slots (topology_state, connector->port, + mst_pbn);
Can we merge the get_mst_topology_state and find_vcpi_slots functions together? Would be less code in drivers ...
drivers/gpu/drm/i915/intel_dp_mst.c static bool intel_dp_mst_compute_config(struct intel_encoder *encoder, · line 79
Quoted 4 lines
drivers/gpu/drm/i915/intel_dp_mst.c +4
-0+if (slots <0 ) { +DRM_DEBUG_KMS ("not enough link bw for this mode\n" ); +return false; + }
And then also stuff the error checking in there, and just have a return -EINVAL when there's not enough bw.
I think this should be together with the previous patch, to wire up the entire mst state tracking for i915 at the same time. Atm the previous patch just wires up dead code, which is a bit backwards. -Daniel
Quoted 6 lines
drivers/gpu/drm/i915/intel_dp_mst.c +0
-0intel_link_compute_m_n(bpp, lane_count, adjusted_mode->crtc_clock,Signature · 1 line
2.7.4
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 9/9] drm/dp: Track MST link bandwidth
Quoted 37 lines · Daniel Vetter
Quoted 18 lines · Dhinakaran Pandiyan
Use the added helpers to track MST link bandwidth for atomic modesets. Link bw is acquired in the ->atomic_check() phase when CRTCs are being enabled with
drm_atomic_find_vcpi_slots()instead ofdrm_find_vcpi_slots(). Similarly, link bw is released during ->atomic_check() with the connector helper callback ->atomic_release() when CRTCs are disabled.Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 9 ++++++++- drivers/gpu/drm/i915/intel_dp_mst.c | 13 ++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_atomic_helper.c +0
-0@@ -385,8 +385,15 @@ mode_fixup(struct drm_atomic_state *state)drivers/gpu/drm/drm_atomic_helper.c mode_fixup(struct drm_atomic_state *state) · line 394
Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +7
-1WARN_ON (!!conn_state->best_encoder != !!conn_state->crtc); -if (!conn_state->crtc || !conn_state->best_encoder) +if (!conn_state->crtc || !conn_state->best_encoder) { +const struct drm_connector_helper_funcs *conn_funcs; + + conn_funcs = connector->helper_private; +if (conn_funcs->atomic_release) + conn_funcs->atomic_release (connector, + conn_state);I wonder whether this won't surprise drivers: The way you coded this release only gets called when the connector is fully disabled. But it does not get called when you atomically switch it from one crtc to the other (in which case you also might want to release resources, before allocating new ones). I think that case of directly switching stuff is even a bug in your current atomic tracking code ...
Quoted 6 lines
We also need to extract the release calls into a separate loop which runs _before_ we allocate any resources. Otherwise if you do an atomic commit where you disable connector2 and enable connector1 and they can't run both at the same time it'll fail, because we'll release the vcpi for connector2 only after we've tried to get it for connnector1.
Yeah, you are right. I thought of this problem and then forgot about it. Is there any igt test to test the switching?
-DK
Quoted 45 lines
drivers/gpu/drm/drm_atomic_helper.c mode_fixup(struct drm_atomic_state *state) · line 399
Quoted 5 lines
drivers/gpu/drm/drm_atomic_helper.c +1
-0continue ; + } crtc_state =drm_atomic_get_existing_crtc_state (state, conn_state->crtc);Misplaced hunk, this needs to be in the patch that adds the ->atomic_release callback.
Quoted 14 lines
drivers/gpu/drm/i915/intel_dp_mst.c +1
-0@@ -44,6 +44,7 @@ static bool intel_dp_mst_compute_config(struct intel_encoder *encoder,int lane_count, slots;const struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;int mst_pbn; +struct drm_dp_mst_topology_state *topology_state; pipe_config->has_pch_encoder = false; bpp =24 ;@@ -65,7 +66,17 @@ static bool intel_dp_mst_compute_config(struct intel_encoder *encoder, mst_pbn =drm_dp_calc_pbn_mode (adjusted_mode->crtc_clock, bpp);drivers/gpu/drm/i915/intel_dp_mst.c static bool intel_dp_mst_compute_config(struct intel_encoder *encoder, · line 75
Quoted 10 lines
drivers/gpu/drm/i915/intel_dp_mst.c +7
-1pipe_config->pbn = mst_pbn; - slots =drm_dp_find_vcpi_slots (&intel_dp->mst_mgr, mst_pbn); + topology_state =drm_atomic_get_mst_topology_state (state, + &intel_dp->mst_mgr); +if (topology_state ==NULL ) +return false; + + slots =drm_dp_atomic_find_vcpi_slots (topology_state, connector->port, + mst_pbn);Can we merge the
get_mst_topology_stateandfind_vcpi_slotsfunctions together? Would be less code in drivers ...drivers/gpu/drm/i915/intel_dp_mst.c static bool intel_dp_mst_compute_config(struct intel_encoder *encoder, · line 79
Quoted 4 lines
drivers/gpu/drm/i915/intel_dp_mst.c +4
-0+if (slots <0 ) { +DRM_DEBUG_KMS ("not enough link bw for this mode\n" ); +return false; + }And then also stuff the error checking in there, and just have a return
-EINVALwhen there's not enough bw.
Quoted 12 lines
I think this should be together with the previous patch, to wire up the entire mst state tracking for i915 at the same time. Atm the previous patch just wires up dead code, which is a bit backwards. -Daniel
Quoted 6 lines
drivers/gpu/drm/i915/intel_dp_mst.c +0
-0intel_link_compute_m_n(bpp, lane_count, adjusted_mode->crtc_clock,Signature · 1 line
2.7.4
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v2 9/9] drm/dp: Track MST link bandwidth
Quoted 46 lines · Dhinakaran
Quoted 37 lines · Daniel Vetter
Quoted 18 lines · Dhinakaran Pandiyan
Use the added helpers to track MST link bandwidth for atomic modesets. Link bw is acquired in the ->atomic_check() phase when CRTCs are being enabled with
drm_atomic_find_vcpi_slots()instead ofdrm_find_vcpi_slots(). Similarly, link bw is released during ->atomic_check() with the connector helper callback ->atomic_release() when CRTCs are disabled.Signed-off-by Dhinakaran Pandiyan <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 9 ++++++++- drivers/gpu/drm/i915/intel_dp_mst.c | 13 ++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_atomic_helper.c +0
-0@@ -385,8 +385,15 @@ mode_fixup(struct drm_atomic_state *state)drivers/gpu/drm/drm_atomic_helper.c mode_fixup(struct drm_atomic_state *state) · line 394
Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +7
-1WARN_ON (!!conn_state->best_encoder != !!conn_state->crtc); -if (!conn_state->crtc || !conn_state->best_encoder) +if (!conn_state->crtc || !conn_state->best_encoder) { +const struct drm_connector_helper_funcs *conn_funcs; + + conn_funcs = connector->helper_private; +if (conn_funcs->atomic_release) + conn_funcs->atomic_release (connector, + conn_state);I wonder whether this won't surprise drivers: The way you coded this release only gets called when the connector is fully disabled. But it does not get called when you atomically switch it from one crtc to the other (in which case you also might want to release resources, before allocating new ones). I think that case of directly switching stuff is even a bug in your current atomic tracking code ...
Quoted 6 lines
We also need to extract the release calls into a separate loop which runs _before_ we allocate any resources. Otherwise if you do an atomic commit where you disable connector2 and enable connector1 and they can't run both at the same time it'll fail, because we'll release the vcpi for connector2 only after we've tried to get it for connnector1.
Quoted 2 lines
Yeah, you are right. I thought of this problem and then forgot about it. Is there any igt test to test the switching?
Not sure we have any direct mode-switching tests. Please chat with Mika Kahola and make sure we do have that test coverage. Mika is working on atomic test coverage, and having this would be good in general (not just for mst).
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Patchwork
CI✓ Fi.CI.BAT: success for Adding private objects to atomic state
In reply to Dhinakaran Pandiyan== Series Details ==
== Series Details ==
Series: Adding private objects to atomic state
URL : https://patchwork.freedesktop.org/series/18523/
State : success
== Summary ==
Series 18523v1 Adding private objects to atomic state
https://patchwork.freedesktop.org/api/1.0/series/18523/revisions/1/mbox/
fi-bdw-5557u total:247 pass:233 dwarn:0 dfail:0 fail:0 skip:14 fi-bsw-n3050 total:247 pass:208 dwarn:0 dfail:0 fail:0 skip:39 fi-bxt-j4205 total:247 pass:225 dwarn:0 dfail:0 fail:0 skip:22 fi-bxt-t5700 total:79 pass:66 dwarn:0 dfail:0 fail:0 skip:12 fi-byt-j1900 total:247 pass:220 dwarn:0 dfail:0 fail:0 skip:27 fi-byt-n2820 total:247 pass:216 dwarn:0 dfail:0 fail:0 skip:31 fi-hsw-4770 total:247 pass:228 dwarn:0 dfail:0 fail:0 skip:19 fi-hsw-4770r total:247 pass:228 dwarn:0 dfail:0 fail:0 skip:19 fi-ivb-3520m total:247 pass:226 dwarn:0 dfail:0 fail:0 skip:21 fi-ivb-3770 total:247 pass:226 dwarn:0 dfail:0 fail:0 skip:21 fi-kbl-7500u total:247 pass:226 dwarn:0 dfail:0 fail:0 skip:21 fi-skl-6260u total:247 pass:234 dwarn:0 dfail:0 fail:0 skip:13 fi-skl-6700hq total:247 pass:227 dwarn:0 dfail:0 fail:0 skip:20 fi-skl-6700k total:247 pass:222 dwarn:4 dfail:0 fail:0 skip:21 fi-skl-6770hq total:247 pass:234 dwarn:0 dfail:0 fail:0 skip:13 fi-snb-2520m total:247 pass:216 dwarn:0 dfail:0 fail:0 skip:31 fi-snb-2600 total:247 pass:215 dwarn:0 dfail:0 fail:0 skip:32
cdab47465a54c45bdf4e9708e39c61d38c7a41ba drm-tip: 2017y-01m-24d-18h-30m-06s UTC integration manifest c9d9fd4 drm/dp: Track MST link bandwidth
801f665 drm/dp: Release DP MST shared link bandwidth
1e2d33d drm: Connector helper function to release atomic state
e4c117e drm/dp: Add DP MST helpers to atomically find and release vcpi slots
82eca9e drm/dp: Introduce MST topology state
8aed66f drm: Add driver private objects to atomic state
376710f drm/dp: Split drm_dp_mst_allocate_vcpi
ba89d0f drm/dp: Kill unused MST vcpi slot availability tracking
371f5e5 drm/dp: Store drm_device in MST topology manager
== Logs ==
For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3597/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx