Repository navigation
lbc: phytium: Bugfix issue with computing device capacity - #2243
wangchenlu2236 wants to merge 1 commit into
Conversation
This patch fixes the issue of computing device capacity, and adds some debug printing code for debugging. Mainline: NA Signed-off-by: Wang Hanmo <wanghanmo2242@phytium.com.cn> Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn> Signed-off-by: Wang Chenlu <wangchenlu2236@phytium.com.cn>
Reviewer's GuideFixes Phytium local-bus device-capacity encoding by using explicit controller size codes and initializes the device base address from the platform resource; also adds clearer probe diagnostics. Flow diagram for Phytium local-bus device setupflowchart TD
A[Platform resource discovered] --> B[LBC_DEVICE_ADDR = res.start]
B --> C[phytium_lbc_probe]
C --> D[phytium_lbc_calc_device_size]
D --> E{Supported device size?}
E -->|16K to 256M| F[Return controller size code 0x0 to 0xe]
E -->|Unsupported| G[Return -EINVAL and log error]
F --> H[Configure local-bus device capacity]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @wangchenlu2236. Thanks for your PR. I'm waiting for a deepin-community member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="drivers/mtd/maps/phytium_lbc.c" line_range="44" />
<code_context>
#define LBC_FTIM2_CS_GPCM(n) (0x1a4+0xc*n)
-#define LBC_DEVICE_ADDR 0x10000000
+static uint64_t LBC_DEVICE_ADDR;
#define PHYTIUM_MAX_SRAM_BLOCK 8
</code_context>
<issue_to_address>
**Flash maps use wrong base**
When two controllers with different resource bases probe concurrently and one overwrites the global before the other's setup, `phytium_lbc_of_setup()` and `phytium_lbc_acpi_setup()` copy the wrong `LBC_DEVICE_ADDR` into `map->phys` and program the wrong CSAR, so the first MTD device maps the other flash; users of that device can read or modify the other flash.
Store each resource base in its controller's `lbc` instance and have both setup paths use that per-controller value.
Also at `drivers/mtd/maps/phytium_lbc.c:504`.
</issue_to_address>| #define LBC_FTIM2_CS_GPCM(n) (0x1a4+0xc*n) | ||
|
|
||
| #define LBC_DEVICE_ADDR 0x10000000 | ||
| static uint64_t LBC_DEVICE_ADDR; |
There was a problem hiding this comment.
🟠 High · Flash maps use wrong base
When two controllers with different resource bases probe concurrently and one overwrites the global before the other's setup, phytium_lbc_of_setup() and phytium_lbc_acpi_setup() copy the wrong LBC_DEVICE_ADDR into map->phys and program the wrong CSAR, so the first MTD device maps the other flash; users of that device can read or modify the other flash.
Store each resource base in its controller's lbc instance and have both setup paths use that per-controller value.
Also at drivers/mtd/maps/phytium_lbc.c:504.
Prompt for AI agents
In `drivers/mtd/maps/phytium_lbc.c` at line 44:
**Flash maps use wrong base**
When two controllers with different resource bases probe concurrently and one overwrites the global before the other's setup, `phytium_lbc_of_setup()` and `phytium_lbc_acpi_setup()` copy the wrong `LBC_DEVICE_ADDR` into `map->phys` and program the wrong CSAR, so the first MTD device maps the other flash; users of that device can read or modify the other flash.
Store each resource base in its controller's `lbc` instance and have both setup paths use that per-controller value.
Also at `drivers/mtd/maps/phytium_lbc.c:504`.There was a problem hiding this comment.
🟡 Changes recommended
The shared LBC_DEVICE_ADDR can be overwritten by concurrent controller probes, causing an instance to program the wrong physical base and break device access; both setup paths need a per-instance base.
1 open issue
What changed in this PR
This PR corrects device-capacity encoding in the Phytium local bus MTD driver and improves probe diagnostics.
Changes:
- Map supported power-of-two sizes from 16 KiB through 256 MiB to hardware encodings.
- Derive the device base address from the platform memory resource.
- Distinguish device-tree and ACPI probe failures and report unsupported sizes.
| File | Description |
|---|---|
drivers/mtd/maps/phytium_lbc.c |
Updates capacity encoding, resource-based addressing, and probe error messages. |
Review effort: Balanced
| return -ENODEV; | ||
| } | ||
|
|
||
| LBC_DEVICE_ADDR = res->start; |

This patch fixes the issue of computing device capacity, and adds some debug printing code for debugging.
Mainline: NA
Summary by Sourcery
Fix Phytium local bus device capacity detection and improve probe diagnostics.
Bug Fixes:
Enhancements: