From b70267bc59be7dbb2214a43a28a2b727cbb5a782 Mon Sep 17 00:00:00 2001 From: Tedd Ho-Jeong An Date: Tue, 10 Mar 2020 10:00:58 -0700 Subject: [PATCH 1/4] workflow: Add workflow files This patch adds workflow files for ci: [sync.yml] - runs every 30 mins. - sync repo with upstream repo and rebase workflow branch to tip of master. - creates PR after reading patches from patchwork.kernel.org [ci.yml] - Tests the following checks: - checkpatch - gitlint - make - make check [code_scan.yml] - Static code checker: Coverity and Clang - Coverity: Submit the result to the coverity website - Clang Code Scan: Send email with result file to the internal team To simplify the history, new change will amend to this patch without creating new patch. --- .github/workflows/ci.yml | 25 +++++++++++++++++++ .github/workflows/code_scan.yml | 26 ++++++++++++++++++++ .github/workflows/sync.yml | 43 +++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/code_scan.yml create mode 100644 .github/workflows/sync.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..a3a54d1a1b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,25 @@ +name: CI + +on: [pull_request] + +jobs: + ci: + runs-on: ubuntu-latest + name: CI for Pull Request + steps: + - name: Checkout the source code + uses: actions/checkout@v3 + with: + path: src/src + + - name: CI + uses: tedd-an/bzcafe@main + with: + task: ci + base_folder: src + space: user + github_token: ${{ secrets.ACTION_TOKEN }} + email_token: ${{ secrets.EMAIL_TOKEN }} + patchwork_token: ${{ secrets.PATCHWORK_TOKEN }} + patchwork_user: ${{ secrets.PATCHWORK_USER }} + diff --git a/.github/workflows/code_scan.yml b/.github/workflows/code_scan.yml new file mode 100644 index 0000000000..181d08c32d --- /dev/null +++ b/.github/workflows/code_scan.yml @@ -0,0 +1,26 @@ +name: Code Scan + +on: + schedule: + - cron: "40 7 * * FRI" + +jobs: + code-scan: + runs-on: ubuntu-latest + steps: + - name: Checkout the source + uses: actions/checkout@v2 + with: + fetch-depth: 0 + path: src + - name: Code Scan + uses: BluezTestBot/action-code-scan@main + with: + src_path: src + github_token: ${{ secrets.GITHUB_TOKEN }} + email_token: ${{ secrets.EMAIL_TOKEN }} + - uses: actions/upload-artifact@v2 + with: + name: scan_report + path: scan_report.tar.gz + diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml new file mode 100644 index 0000000000..d935cca9fa --- /dev/null +++ b/.github/workflows/sync.yml @@ -0,0 +1,43 @@ +name: Sync + +on: + schedule: + - cron: "*/30 * * * *" + +jobs: + sync_repo: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: master + + - name: Sync Repo + uses: tedd-an/bzcafe@main + with: + task: sync + upstream_repo: 'https://git.kernel.org/pub/scm/bluetooth/bluez.git' + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Cleanup PR + uses: tedd-an/bzcafe@main + with: + task: cleanup + github_token: ${{ secrets.ACTION_TOKEN }} + + sync_patchwork: + needs: sync_repo + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Sync Patchwork + uses: tedd-an/bzcafe@main + with: + task: patchwork + space: user + github_token: ${{ secrets.ACTION_TOKEN }} + email_token: ${{ secrets.EMAIL_TOKEN }} + patchwork_token: ${{ secrets.PATCHWORK_TOKEN }} + patchwork_user: ${{ secrets.PATCHWORK_USER }} + From f81dd7afba7461acbc45f3175c47ce37789d5ca1 Mon Sep 17 00:00:00 2001 From: Ludovico de Nittis Date: Tue, 25 Mar 2025 18:28:44 +0100 Subject: [PATCH 2/4] adapter: Preserve pending flags when setting the Device Privacy Mode If there are already flags that are pending to be applied, we should keep them to avoid overwriting them. At that point we only want to add the Device Privacy Mode on top of the existing flags. --- src/adapter.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/adapter.c b/src/adapter.c index f66024b396..06a937eb76 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -5634,8 +5634,11 @@ static void add_device_complete(uint8_t status, uint16_t length, if (btd_opts.device_privacy) { uint32_t flags = btd_device_get_current_flags(dev); - /* Set Device Privacy Mode has not set the flag yet. */ + /* Set Device Privacy Mode if it has not set the flag yet. */ if (!(flags & DEVICE_FLAG_DEVICE_PRIVACY)) { + /* Include the pending flags, or they may get overwritten. */ + flags |= btd_device_get_pending_flags(dev); + adapter_set_device_flags(adapter, dev, flags | DEVICE_FLAG_DEVICE_PRIVACY, set_device_privacy_complete, From ee17a383c6dbcd340c75f523f700cc0aef37677b Mon Sep 17 00:00:00 2001 From: Ludovico de Nittis Date: Tue, 25 Mar 2025 18:28:45 +0100 Subject: [PATCH 3/4] device: Preserve pending flags when setting the wake allowed If there are already flags that are pending to be applied, we should keep them to avoid overwriting them. In device_set_wake_allowed() we only want to either add or remove the remote wakeup flag, while keeping the existing flags as-is. --- src/device.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/device.c b/src/device.c index 57577e5792..0e563f9615 100644 --- a/src/device.c +++ b/src/device.c @@ -1628,6 +1628,10 @@ void device_set_wake_allowed(struct btd_device *device, bool wake_allowed, device->pending_wake_allowed = wake_allowed; flags = device->current_flags; + + /* Include the pending flags, or they may get overwritten. */ + flags |= device->pending_flags; + if (wake_allowed) flags |= DEVICE_FLAG_REMOTE_WAKEUP; else From 21a5eb63fa8f94870c20a74455dfb80fc0d0fbed Mon Sep 17 00:00:00 2001 From: Ludovico de Nittis Date: Tue, 25 Mar 2025 18:28:46 +0100 Subject: [PATCH 4/4] device: Try to set the wake_allowed property only for bonded devices When the function `device_set_wake_support()` is called, we don't have the guarantees for the device to be already bonded. For example, that function gets called by `hog_probe()`, that is also triggered when bluez scans for new devices. In that instance, we don't want to try setting the `wake_allowed` property, because those devices are only in range of the host and are not connected, paired or bonded yet. This fixes the following Bluez error when we scan for new devices and a new hog or hid is in range: ``` src/device.c:set_wake_allowed_complete() Set device flags return status: Invalid Parameters ``` Additionally, because that initial `device_set_allowed()` call can fail, this commit fixes the issue of hog and hid devices that, after the first pairing, were unexpectedly showing `WakeAllowed: no`. And it required a reboot to let that property be set to the expected `WakeAllowed: yes` by default. --- src/device.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/device.c b/src/device.c index 0e563f9615..1be959491d 100644 --- a/src/device.c +++ b/src/device.c @@ -1548,10 +1548,13 @@ void device_set_wake_support(struct btd_device *device, bool wake_support) if (device->wake_override == WAKE_FLAG_DEFAULT) device_set_wake_override(device, wake_support); - /* Set wake_allowed according to the override value. */ - device_set_wake_allowed(device, - device->wake_override == WAKE_FLAG_ENABLED, - -1U); + /* Set wake_allowed according to the override value. + * Limit this to bonded device to avoid trying to set it + * to new devices that are simply in range. */ + if (device_is_bonded(device, device->bdaddr_type)) + device_set_wake_allowed(device, + device->wake_override == WAKE_FLAG_ENABLED, + -1U); } static bool device_get_wake_allowed(struct btd_device *device) @@ -6698,6 +6701,10 @@ void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type, device_auth_req_free(device); + /* Enable the wake_allowed property if required */ + if (device->wake_override == WAKE_FLAG_ENABLED) + device_set_wake_allowed(device, true, -1U); + /* If we're already paired nothing more is needed */ if (state->paired) return;