[PATCH v2 5/8] drm/amdgpu: Refactor sysfs removal
Andrey Grodzovsky
Andrey.Grodzovsky at amd.com
Wed Nov 11 16:34:08 UTC 2020
On 11/11/20 11:06 AM, Greg KH wrote:
> On Wed, Nov 11, 2020 at 10:45:53AM -0500, Andrey Grodzovsky wrote:
>> On 11/11/20 10:34 AM, Greg KH wrote:
>>> On Wed, Nov 11, 2020 at 10:13:13AM -0500, Andrey Grodzovsky wrote:
>>>> On 11/10/20 12:59 PM, Greg KH wrote:
>>>>> On Tue, Nov 10, 2020 at 12:54:21PM -0500, Andrey Grodzovsky wrote:
>>>>>> Hi, back to this after a long context switch for some higher priority stuff.
>>>>>>
>>>>>> So here I was able eventually to drop all this code and this change here https://nam11.safelinks.protection.outlook.com/?url=https:%2F%2Fcgit.freedesktop.org%2F~agrodzov%2Flinux%2Fcommit%2F%3Fh%3Damd-staging-drm-next-device-unplug%26id%3D61852c8a59b4dd89d637693552c73175b9f2ccd6&data=04%7C01%7CAndrey.Grodzovsky%40amd.com%7C3e019e2780114b696b4f08d8865bac36%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637407075579242822%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=E%2FIZmVeJDvHiY2xSaaPaay4mXN49EbhSJaJ4zlt6WKk%3D&reserved=0
>>>>>> was enough for me. Seems like while device_remove_file can handle the use
>>>>>> case where the file and the parent directory already gone,
>>>>>> sysfs_remove_group goes down in flames in that case
>>>>>> due to kobj->sd being unset on device removal.
>>>>> A driver shouldn't ever have to remove individual sysfs groups, the
>>>>> driver core/bus logic should do it for them automatically.
>>>>>
>>>>> And whenever a driver calls a sysfs_* call, that's a hint that something
>>>>> is not working properly.
>>>>
>>>> Do you mean that while the driver creates the groups and files explicitly
>>>> from it's different subsystems it should not explicitly remove each
>>>> one of them because all of them should be removed at once (and
>>>> recursively) when the device is being removed ?
>>> Individual drivers should never add groups/files in sysfs, the driver
>>> core should do it properly for you if you have everything set up
>>> properly. And yes, the driver core will automatically remove them as
>>> well.
>>>
>>> Please use the default groups attribute for your bus/subsystem and this
>>> will happen automagically.
>> Googling for default groups attributes i found this - https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.linuxfoundation.org%2Fblog%2F2013%2F06%2Fhow-to-create-a-sysfs-file-correctly%2F&data=04%7C01%7CAndrey.Grodzovsky%40amd.com%7C3e019e2780114b696b4f08d8865bac36%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637407075579252818%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=AVhdi%2BcKeFXM8CBv%2BhRNTCYX2XSS8oo0so6mB%2BPuEfk%3D&reserved=0
> Odd, mirror of the original article:
> https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fkroah.com%2Flog%2Fblog%2F2013%2F06%2F26%2Fhow-to-create-a-sysfs-file-correctly%2F&data=04%7C01%7CAndrey.Grodzovsky%40amd.com%7C3e019e2780114b696b4f08d8865bac36%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637407075579252818%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=lGMd3PJOWIlKUpvbV3Zz%2FvbBIRwz6%2BlJ%2BS%2BiVcXxuzM%3D&reserved=0
>
>> Would this be what you suggest for us ? Specifically for our case the struct
>> device's groups seems the right solution as different devices
>> might have slightly diffreent sysfs attributes.
> That's what the is_visable() callback in your attribute group is for, to
> tell the kernel if an individual sysfs attribute should be created or
> not.
I see, this looks like a good improvement to our current way of managing sysfs.
Since this
change is somewhat fundamental and requires good testing I prefer to deal with
it separately from my current
work on device unplug and so I will put it on TODO right after finishing this work.
Andrey
>
> thanks,
>
> greg k-h
More information about the amd-gfx
mailing list