ub: add uobj basic function in uburma to manage resource release process
driver inclusion category: feature bugzilla: NA CVE: NA -------------------------------- Add uobj feature in uburma to manage resource release process together. ** Context to use uobj: ** There are some dependencies between various objects provided by the URMA. Due to active or passive reasons, dependency conditions may not be met during object creation or deletion, or residual objects may fail to be deleted, resulting in unpredictable problems. These objects need to be managed in a unified manner. ** Scenarios: ** - After an object is created, it is not manually released and exits the program. - Program crashes unexpectedly after object creation - After the object is created, the driver is uninstalled. - When an object is being used, other threads delete the object (for example, event processing). - When an object is deleted, other objects depend on the object. ** Design Key Points of uobj: ** - Create urma context/file by process --- open device - UOBJ-related structures are initialized when uburma_open is used. - Stores the uobjects list in the uburma_file structure. - When a user uses the ioctl interface to create, associate, and destroy an object, the uobj object can be created, associated, and destroyed. - Use usecnt to record associations when creating objects. - Record the uobj object to the uobjects list when the creation is successful. - Use the get/put operation to ensure object accessibility. - Number of associated resources that are released when an object is destroyed. - After the object is destroyed, the corresponding uobj object is deleted from the uobjects list. - Invoke the uburma_close function when the process exits normally or abnormally. - Release all undestructed uobj resources in the uburma_close function. - All undestructed UOBJ resources are released during driver uninstallation. ** This patch include: ** - Structure definition of uobj - uobj_alloc(): alloc uobj to associate with an obj of urma. - uobj_alloc_commit(): after obj successfully created, commit the uobj alloc. - uobj_alloc_abort(): abort the uobj alloc when obj failed to create. - uobj_remove_commit(): remove the committed uobj when obj deleted. - uobj_get(): get obj and add refcnt - uobj_put(): sub refcnt and see if uobj can be freed. Signed-off-by:Guoxin Qian <qianguoxin@huawei.com> Signed-off-by:
Yizhen Fan <fanyizhen@huawei.com>
Loading
Please sign in to comment