Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add patch to fix Kingston eMMC compatibility with ODROID-N2 #3619

Closed
wants to merge 1 commit into from

Conversation

sairon
Copy link
Member

@sairon sairon commented Oct 10, 2024

Testing shows that the 24MHz cap is problematic for Kingston. Bumping this cap to 40 MHz in #3319 fixed Kingston but reintroduced issues with some other eMMCs that the frequency cap was supposed to fix.

This commit adds another patch that selects a different clock for eMMC. While it's still unclear why Kingston fails with the frequencies of slightly below 24 MHz (see patch message why it's below), using 24 MHz from xtal seems to be fine and hopefully shouldn't introduce regressions for old eMMCs.

Alternative approach would be using the same clock source but setting the frequency cap to 25 MHz. This results in exact 25 MHz from PLL which is even the defined frequency for some eMMC modes, Kingston eMMC works fine with it and the difference from the previously used value wouldn't be too high, but with 24 MHz we're even closer.

refs #3250, refs #3227

Summary by CodeRabbit

  • Bug Fixes
    • Resolved communication issues with Kingston eMMCs by ensuring precise clock rates at 24 MHz.
    • Improved compatibility with other eMMCs by adjusting the clock source configuration.

Testing shows that the 24MHz cap is problematic for Kingston. Bumping this cap
to 40 MHz in #3319 fixed Kingston but reintroduced issues with some other eMMCs
that the frequency cap was supposed to fix.

This commit adds another patch that selects a different clock for eMMC. While
it's still unclear why Kingston fails with the frequencies of slightly below 24
MHz (see patch message why it's below), using 24 MHz from xtal seems to be fine
and hopefully shouldn't introduce regressions for old eMMCs.

Alternative approach would be using the same clock source but setting the
frequency cap to 25 MHz. This results in exact 25 MHz from PLL which is even
the defined frequency for some eMMC modes, Kingston eMMC works fine with it and
the difference from the previously used value wouldn't be too high, but with 24
MHz we're even closer.

refs #3250, refs #3227
@sairon sairon added the board/odroid Hardkernel's ODROID Boards label Oct 10, 2024
Copy link

coderabbitai bot commented Oct 10, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request involve a patch to the Meson GX MMC driver, specifically modifying the clock configuration to utilize the crystal oscillator (xtal) as the clock source for frequencies up to 24 MHz. This adjustment addresses issues with imprecise clock rates that affected communication with certain Kingston eMMCs, ensuring a precise 24 MHz frequency. The implementation includes a conditional check in the meson_mmc_config_clock function to set the clock source appropriately.

Changes

File Path Change Summary
buildroot-external/board/hardkernel/patches/uboot/0002-mmc-meson-gx-use-xtal-as-clock... Modified clock configuration to use xtal for frequencies up to 24 MHz, resolving communication issues with Kingston eMMCs.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MesonGX_MMC_Driver
    participant Clock_Source

    User->>MesonGX_MMC_Driver: Request clock configuration
    MesonGX_MMC_Driver->>Clock_Source: Check requested frequency
    alt Frequency > 24 MHz
        Clock_Source-->>MesonGX_MMC_Driver: Set clock source to xtal
    else
        Clock_Source-->>MesonGX_MMC_Driver: Use previous clock source
    end
    MesonGX_MMC_Driver-->>User: Clock configuration applied
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
buildroot-external/board/hardkernel/patches/uboot/0002-mmc-meson-gx-use-xtal-as-clock-for-frequencies-24MHz.patch (2)

44-44: Consider addressing the TODO comment

The comment "TOFIX This should use the proper clock taken from DT" remains unchanged. Consider creating a follow-up task to address this TODO, as it might be important for proper device tree support.

Would you like me to create a GitHub issue to track this TODO item?


48-53: Fix indentation of the new comment block

The new comment block is indented with one space less than the surrounding code. Please adjust the indentation to match the rest of the function for consistency.

Apply this diff to fix the indentation:

-	/*
-	 * With f_max=24M, we almost always end up with 24M anyway and
-	 * granularity between 24M and 12M isn't needed, so try to use
-	 * xtal clock source directly.
-	 */
+	/*
+	 * With f_max=24M, we almost always end up with 24M anyway and
+	 * granularity between 24M and 12M isn't needed, so try to use
+	 * xtal clock source directly.
+	 */
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1b6b40e and 6bd7128.

📒 Files selected for processing (1)
  • buildroot-external/board/hardkernel/patches/uboot/0002-mmc-meson-gx-use-xtal-as-clock-for-frequencies-24MHz.patch (1 hunks)
🧰 Additional context used
🔇 Additional comments (3)
buildroot-external/board/hardkernel/patches/uboot/0002-mmc-meson-gx-use-xtal-as-clock-for-frequencies-24MHz.patch (3)

9-33: Well-documented commit message

The commit message provides a comprehensive explanation of the issue, the proposed solution, and its rationale. It also acknowledges potential future improvements, which is valuable for maintainers and other developers.


46-53: Improved code readability with named constant

The replacement of the magic number 16000000 with the named constant SD_EMMC_CLKSRC_24M improves code readability and maintainability. This change is appreciated.


1-56: Overall assessment: Patch looks good with minor improvements suggested

The patch successfully implements the intended fix for the Kingston eMMC compatibility issue with ODROID-N2. The changes are well-documented, minimal, and focused. The use of a named constant improves code readability.

A few minor improvements have been suggested:

  1. Correcting the commit date in the patch header.
  2. Addressing the existing TODO comment about using the proper clock from the device tree.
  3. Fixing the indentation of the new comment block.

Once these minor issues are addressed, the patch should be ready for merging.

Comment on lines +1 to +8
From 77ec70c4d73c772b7da0d007946f697f7d27a7a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20=C4=8Cerm=C3=A1k?= <sairon@sairon.cz>
Date: Thu, 10 Oct 2024 19:06:24 +0200
Subject: [PATCH] mmc: meson-gx: use xtal as clock for frequencies <= 24MHz
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Incorrect commit date in the patch header

The commit date is set to October 10, 2024, which is in the future. This could cause issues with version control and should be corrected to the current date.

Please update the commit date to the current date:

-Date: Thu, 10 Oct 2024 19:06:24 +0200
+Date: <current_date_and_time>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
From 77ec70c4d73c772b7da0d007946f697f7d27a7a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20=C4=8Cerm=C3=A1k?= <sairon@sairon.cz>
Date: Thu, 10 Oct 2024 19:06:24 +0200
Subject: [PATCH] mmc: meson-gx: use xtal as clock for frequencies <= 24MHz
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From 77ec70c4d73c772b7da0d007946f697f7d27a7a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20=C4=8Cerm=C3=A1k?= <sairon@sairon.cz>
Date: <current_date_and_time>
Subject: [PATCH] mmc: meson-gx: use xtal as clock for frequencies <= 24MHz
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Copy link
Member

@agners agners left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

The 24MHz directly from XTAL potentially is the better clock source indeed, so let's try how this works out in practice on some eMMC modules!

@sairon
Copy link
Member Author

sairon commented Oct 14, 2024

Unfortunately, this doesn't work as good as I initially thought 😢 I will try few more things and run some automated test to test the patch works reliably the next time.

@sairon sairon closed this Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants