Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

fs/sysfs: MIPS: Don't translate all IOCTLs #402

Merged
merged 3 commits into from
Feb 18, 2019

Conversation

svenschwermer
Copy link
Contributor

Some IOCTLs are fixed, e.g. i2c-dev. There, we must not translate the
IOCTLs. Instead, the IOCTLs are generated arch-dependent in the fs
package.

Fixes #361

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

1 similar comment
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@svenschwermer
Copy link
Contributor Author

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

1 similar comment
@googlebot
Copy link

CLAs look good, thanks!

Copy link
Contributor

@maruel maruel left a comment

Choose a reason for hiding this comment

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

Thanks a lot for verifying and working on a fix. That's really appreciated.

Exporting these function was something I discussed with @NeuralSpaz but wasn't sure about it up to now.

Please try to make the travis check pass.

host/fs/ioctl.go Outdated Show resolved Hide resolved
host/fs/ioctl.go Outdated Show resolved Hide resolved
host/sysfs/spi.go Show resolved Hide resolved
host/sysfs/spi.go Outdated Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented Feb 14, 2019

Codecov Report

Merging #402 into master will increase coverage by 0.31%.
The diff coverage is 40%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #402      +/-   ##
==========================================
+ Coverage   64.39%   64.71%   +0.31%     
==========================================
  Files         118      116       -2     
  Lines       11806    11726      -80     
==========================================
- Hits         7603     7588      -15     
+ Misses       4001     3937      -64     
+ Partials      202      201       -1
Impacted Files Coverage Δ
host/videocore/videocore.go 81.08% <ø> (ø) ⬆️
host/sysfs/spi.go 83.98% <40%> (+0.71%) ⬆️
host/fs/fs_linux.go
host/sysfs/thermal_sensor.go 83.84% <0%> (+2.3%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6a024e5...f7eb31d. Read the comment docs.

host/fs/ioctl.go Outdated Show resolved Hide resolved
host/sysfs/spi.go Outdated Show resolved Hide resolved
}
}

func TestSPIIOCTx(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

That test should fail on mips, right? We should delete this then, because anyway we have gohci workers that ensure that SPI works for real.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, they do fail. I verified this by cross-compiling the test and then running it on the target. I wasn't sure how to test this. Should we include arch-specific unit tests or just rely on the gohci tests?

Copy link
Contributor

Choose a reason for hiding this comment

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

No need to test for the constants, integration testing will suffice here. Maybe the only thing that would be cool is to add a test to spismoketest: read the values back via an ioctl on the file handle to confirm that the values were setup properly; that's the reason why the "read value back to confirm" code was written, as a long time ago the code was trying to write value and was silently failing (oops).

Copy link
Contributor

Choose a reason for hiding this comment

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

FTR, I don't ask you to do the spismoketest check here, what you did is already great.

I still think the dead code and const checks should be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a check to read back the mode flag since that's the only flag we set during initialization. SPI_IOC_MESSAGE doesn't have a corresponding _IOR ioctl, so we can't verify the message ioctl.
I'm unsure if the GetFlag approach is the right one here, what do you think?

@maruel
Copy link
Contributor

maruel commented Feb 14, 2019

gohci

host/fs/ioctl.go Show resolved Hide resolved
}
}

func TestSPIIOCTx(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

FTR, I don't ask you to do the spismoketest check here, what you did is already great.

I still think the dead code and const checks should be removed.

Some IOCTLs are fixed, e.g. i2c-dev. There, we must not translate the
IOCTLs. Instead, the IOCTLs are generated arch-dependent in the fs
package.
Beside being clearer, the comment in the code was incorrect. The message
box magic is in fact 'd' = 100 = 0x64, not 0x100.
host/videocore/videocore.go Outdated Show resolved Hide resolved
Copy link
Contributor

@maruel maruel left a comment

Choose a reason for hiding this comment

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

It's great, will merge a bit later I have to go

@maruel
Copy link
Contributor

maruel commented Feb 17, 2019

Sorry for the delay, but can you fix https://github.com/google/periph/blob/master/host/sysfs/i2c.go#L205 too? Otherwise I²C will be broken.

@maruel
Copy link
Contributor

maruel commented Feb 17, 2019

gohci

@svenschwermer
Copy link
Contributor Author

Sorry for the delay, but can you fix https://github.com/google/periph/blob/master/host/sysfs/i2c.go#L205 too? Otherwise I²C will be broken.

Are you sure? The whole point of this PR was to not translate the IOCTLs for I2C on MIPS because they're fixed and not dependent on the _IO{R,W,} macros. See https://github.com/torvalds/linux/blob/master/include/uapi/linux/i2c-dev.h#L36

Perhaps I am misunderstanding you here?

@maruel
Copy link
Contributor

maruel commented Feb 18, 2019

Duh, sorry.

@maruel maruel merged commit df7c7a4 into google:master Feb 18, 2019
@maruel
Copy link
Contributor

maruel commented Feb 18, 2019

\o/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sysfs: Omega2+ I²C failure due to MIPS ioctl encoding
4 participants