{"action":"created","issue":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/4866","repository_url":"https://api.github.com/repos/RIOT-OS/RIOT","labels_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/4866/labels{/name}","comments_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/4866/comments","events_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/4866/events","html_url":"https://github.com/RIOT-OS/RIOT/issues/4866","id":135205864,"number":4866,"title":"periph: GPIO drivers are not thread safe","user":{"login":"haukepetersen","id":620834,"avatar_url":"https://avatars.githubusercontent.com/u/620834?v=3","gravatar_id":"","url":"https://api.github.com/users/haukepetersen","html_url":"https://github.com/haukepetersen","followers_url":"https://api.github.com/users/haukepetersen/followers","following_url":"https://api.github.com/users/haukepetersen/following{/other_user}","gists_url":"https://api.github.com/users/haukepetersen/gists{/gist_id}","starred_url":"https://api.github.com/users/haukepetersen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haukepetersen/subscriptions","organizations_url":"https://api.github.com/users/haukepetersen/orgs","repos_url":"https://api.github.com/users/haukepetersen/repos","events_url":"https://api.github.com/users/haukepetersen/events{/privacy}","received_events_url":"https://api.github.com/users/haukepetersen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/RIOT-OS/RIOT/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":{"login":"haukepetersen","id":620834,"avatar_url":"https://avatars.githubusercontent.com/u/620834?v=3","gravatar_id":"","url":"https://api.github.com/users/haukepetersen","html_url":"https://github.com/haukepetersen","followers_url":"https://api.github.com/users/haukepetersen/followers","following_url":"https://api.github.com/users/haukepetersen/following{/other_user}","gists_url":"https://api.github.com/users/haukepetersen/gists{/gist_id}","starred_url":"https://api.github.com/users/haukepetersen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haukepetersen/subscriptions","organizations_url":"https://api.github.com/users/haukepetersen/orgs","repos_url":"https://api.github.com/users/haukepetersen/repos","events_url":"https://api.github.com/users/haukepetersen/events{/privacy}","received_events_url":"https://api.github.com/users/haukepetersen/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/milestones/13","html_url":"https://github.com/RIOT-OS/RIOT/milestones/Release%202016.03","labels_url":"https://api.github.com/repos/RIOT-OS/RIOT/milestones/13/labels","id":1447832,"number":13,"title":"Release 2016.03","description":"The next major release.","creator":{"login":"OlegHahm","id":1590423,"avatar_url":"https://avatars.githubusercontent.com/u/1590423?v=3","gravatar_id":"","url":"https://api.github.com/users/OlegHahm","html_url":"https://github.com/OlegHahm","followers_url":"https://api.github.com/users/OlegHahm/followers","following_url":"https://api.github.com/users/OlegHahm/following{/other_user}","gists_url":"https://api.github.com/users/OlegHahm/gists{/gist_id}","starred_url":"https://api.github.com/users/OlegHahm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OlegHahm/subscriptions","organizations_url":"https://api.github.com/users/OlegHahm/orgs","repos_url":"https://api.github.com/users/OlegHahm/repos","events_url":"https://api.github.com/users/OlegHahm/events{/privacy}","received_events_url":"https://api.github.com/users/OlegHahm/received_events","type":"User","site_admin":false},"open_issues":230,"closed_issues":134,"state":"open","created_at":"2015-12-07T14:56:18Z","updated_at":"2016-02-21T22:33:06Z","due_on":"2016-03-17T23:00:00Z","closed_at":null},"comments":9,"created_at":"2016-02-21T13:28:19Z","updated_at":"2016-02-21T23:10:14Z","closed_at":null,"body":"From #4830: The implementation of almost all our GPIO drivers is not thread safe. Though we have not seen the effect of this somewhere, there are possibilities that pin configurations (or for some boards also set/clear operations) might be lost. Example are lines like these:\r\n```c\r\n// from stm32f4 gpio.c -> gpio_init()\r\nport->MODER |= (1 << (2 * pin_num));\r\n```\r\nThis is compiled into a non atomic read-modify-store sequence. So if interrupted and the same register is modified by a different thread, this modification will be lost.\r\n\r\nIt would be good to find a global solution/best practice on how to mitigate this. My first quick thought would be to actually disable interrupts while writing this reg, as these sequences are very small and mutexes would be too much overhead.\r\n\r\nNOTE: The same issue might also effect other peripheral driver than GPIO ones, but as most work on a device-level without (many) shared global registers, the chances are not quite as high."},"comment":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/comments/186940379","html_url":"https://github.com/RIOT-OS/RIOT/issues/4866#issuecomment-186940379","issue_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/4866","id":186940379,"user":{"login":"OlegHahm","id":1590423,"avatar_url":"https://avatars.githubusercontent.com/u/1590423?v=3","gravatar_id":"","url":"https://api.github.com/users/OlegHahm","html_url":"https://github.com/OlegHahm","followers_url":"https://api.github.com/users/OlegHahm/followers","following_url":"https://api.github.com/users/OlegHahm/following{/other_user}","gists_url":"https://api.github.com/users/OlegHahm/gists{/gist_id}","starred_url":"https://api.github.com/users/OlegHahm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OlegHahm/subscriptions","organizations_url":"https://api.github.com/users/OlegHahm/orgs","repos_url":"https://api.github.com/users/OlegHahm/repos","events_url":"https://api.github.com/users/OlegHahm/events{/privacy}","received_events_url":"https://api.github.com/users/OlegHahm/received_events","type":"User","site_admin":false},"created_at":"2016-02-21T23:10:14Z","updated_at":"2016-02-21T23:10:14Z","body":"@kaspar030, so what's your message? People should keep their silence when they observe that changes may have an effect on real-time guarantees? I agree 100% with you that it **is** sometimes annoying that you want to do one contribution and are suddenly facing several other more or less related other issues that slow down the process of your original task. However, I really appreciate people looking thoroughly at these implications **and** stating them instead of simply waving things through.\r\n\r\nDisclaimer: this has little to do with the actual PR here."}}