Page MenuHomeFreeBSD

Add rtsx driver for Realtek SD card readers.
Needs ReviewPublic

Authored by hlh_restart.be on Tue, Sep 15, 10:09 AM.

Details

Reviewers
jkim
imp
Group Reviewers
cam
Summary

The rtsx driver provides support for PCI Realtek SD card reader. Driver
attaches mmc bus on card insertion and detaches it on card removing.
The driver has been tested with RTS5209, RTS5227, RTS5229, RTS522A,
RTS525A and RTL8411B. It should also work with RTS5249, RTL8402 and
RTL8411.

Test Plan
  • insert a card
  • prepare a random file of 8GB for a card >=8GB:
dd if=/dev/random of=/tmp/random0 bs=32768 count=262144
  • test the I/O using the ping-pong buffer (cmd buffer):
dd if=/tmp/random0 of=/dev/mmcsd0 bs=512
dd if=/dev/mmcsd0 of=/tmp/random1 bs=512
md5 /tmp/random0 /tmp/random1
  • test the I/O using the data buffer:
dd if=/tmp/random0 of=/dev/mmcsd0 bs=32768
dd if=/dev/mmcsd0 of=/tmp/random2 bs=8192
md5 /tmp/random0 /tmp/random2
  • create a zpool:
gpart create -s GPT /dev/mmcsd0
gpart add -t freebsd-zfs /dev/mmcsd0
zpool create testpool /dev/mmcsd0p1
rsync -av /usr/src/ /testpool
zpool scrub testpool
zpool status testpool
zpool export testpool
  • remove the card

NOTE
with options MMCCAM replace /dev/mmcsd by /dev/sdda.

PR204521 contains bulk of exchanges for completion of the code.

Diff Detail

Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 33876
Build 31084: arc lint + arc unit

Event Timeline

hlh_restart.be requested review of this revision.Tue, Sep 15, 10:09 AM
hlh_restart.be created this revision.
hlh_restart.be edited the summary of this revision. (Show Details)Tue, Sep 15, 10:12 AM
hlh_restart.be edited the test plan for this revision. (Show Details)
hlh_restart.be edited the summary of this revision. (Show Details)Tue, Sep 15, 10:56 AM
greg_unrelenting.technology added inline comments.
share/man/man4/rtsx.4
112

This really really should be a tunable/sysctl, not a compile time option. Recompiling the kernel just because you have a specific laptop model should not be required.

Update manual to add tunable for inversion.

hlh_restart.be marked an inline comment as done.Tue, Sep 15, 12:27 PM
hlh_restart.be added inline comments.
share/man/man4/rtsx.4
112

I complete the manual with the implemented tunable.

hlh_restart.be marked an inline comment as done.Tue, Sep 15, 12:29 PM
jkim added a reviewer: imp.Tue, Sep 15, 3:45 PM
hlh_restart.be edited the test plan for this revision. (Show Details)Tue, Sep 15, 3:52 PM
hlh_restart.be edited the test plan for this revision. (Show Details)Fri, Sep 18, 7:28 AM

I think you are missing some files in this review that changed, probably got lost when updating the new manpage changes.

imp requested changes to this revision.Mon, Sep 21, 7:24 PM

This review is missing a lot of files (even prior versions). rtsx.c at the very least is missing
Does this driver support MMCCAM?

sys/conf/files
2827

This file is absent from the review.

sys/dev/rtsx/rtsxreg.h
32

Is this really needed? Have you done extensive testing on 11?

This revision now requires changes to proceed.Mon, Sep 21, 7:24 PM
mhorne added a subscriber: mhorne.Mon, Sep 21, 10:40 PM

Add MMCCAM support

hlh_restart.be marked an inline comment as done.Tue, Sep 22, 9:44 AM
hlh_restart.be added inline comments.
sys/conf/files
2827

I am struggling to correctly understand the arc command...

sys/dev/rtsx/rtsxreg.h
32

I can't do testing on 11. I add this after this comment:
PR204521 - comment 101

hlh_restart.be edited the test plan for this revision. (Show Details)Tue, Sep 22, 10:11 AM
hlh_restart.be marked an inline comment as done.Tue, Sep 22, 10:56 AM
hlh_restart.be added inline comments.
sys/dev/rtsx/rtsxreg.h
32

Revision 320844: "Implement the MMC/SD/SDIO protocol within a CAM framework" added
IO_SEND_OP_COND to sys/dev/mmc/mmcreg.h. this was never MFC to 11.

imp added inline comments.Tue, Sep 22, 9:31 PM
share/man/man4/rtsx.4
28

nit: before commit, we'll need to roll this date forward.
More generally, though, please make sure that 'igor' and 'mandoc -Tlint' pass w/o complaint

Amend rtsx.4 and modify Makefile and rtsx.c for MMCCAM better support.

hlh_restart.be marked an inline comment as done.Wed, Sep 23, 12:05 PM
hlh_restart.be added inline comments.
share/man/man4/rtsx.4
28

After this amend of rtsx.4:

[hlh@morzine rtsx]$ igor -D rtsx.4
[hlh@morzine rtsx]$ mandoc -Tlint rtsx.4
[hlh@morzine rtsx]$
hlh_restart.be marked an inline comment as done.

Modify rtsx_cam_* functions to return void and set better ccb status

  • Modify srtlcpy so that the serial number is not truncated.
jkim added inline comments.Tue, Sep 29, 2:21 PM
sys/dev/rtsx/rtsx.c
389

A style(9) nit-picking; `{' should be on a separate line.

The function type should be on a line by itself preceding the function.
The opening brace of the function body should be on a line by itself.
495

Another style nit.

2168

One more nit.

2206

Ditto.

2268

Ditto.

2957

Ditto.

  • Style(9) rtsx.c (function definition).
hlh_restart.be marked 6 inline comments as done.Tue, Sep 29, 2:52 PM