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

Change DMA API to use embedded-dma traits #274

Merged
merged 3 commits into from
Oct 15, 2020

Conversation

thalesfragoso
Copy link
Member

Fixes #270

This PR is pretty much done, but it would be nice to test at least the affected examples on hardware. Unfortunately, I don't have the time to do it right now, I would appreciate some help.

CC @TheZoq2 and @mitchmindtree

@TheZoq2
Copy link
Member

TheZoq2 commented Oct 3, 2020

Awesome, i'll have a look at it tomorrow :)

Copy link
Member

@TheZoq2 TheZoq2 left a comment

Choose a reason for hiding this comment

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

Looked through the code and added a few nitpicks/questions.

I'll do some testing of the examples now

Comment on lines +322 to +332
unsafe {
let buffer = ptr::read(&self.buffer);
let payload = ptr::read(&self.payload);
mem::forget(self);
(buffer, payload)
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm probably missing something here, but why is this required? It seems like this would be the smae as just moving self.buffer and self.payload into the tuple directly?

Copy link
Member Author

Choose a reason for hiding this comment

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

Transfer now implements Drop, so we can't move out of its fields.

Copy link
Member

Choose a reason for hiding this comment

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

Ah right. Could you add a comment clarifying that in the code? Seems like something that will come up in the future

src/dma.rs Show resolved Hide resolved
src/serial.rs Outdated Show resolved Hide resolved
src/spi.rs Show resolved Hide resolved
@TheZoq2
Copy link
Member

TheZoq2 commented Oct 4, 2020

Alright, tested the serial TX and spi TX examples and they still work. The rx examples are a bit more tricky, but I'll try to get something working

@thalesfragoso
Copy link
Member Author

@TheZoq2 Alright, I'm marking this as ready for review, but if you could test the circular adc example (adding some prints to check it), it would be great.

@thalesfragoso thalesfragoso marked this pull request as ready for review October 11, 2020 01:07
@TheZoq2
Copy link
Member

TheZoq2 commented Oct 15, 2020

Finally got around to testing the circular ADC DMA. Looks like things work as expected 🎉

@TheZoq2 TheZoq2 merged commit 2f7c45e into stm32-rs:master Oct 15, 2020
@TheZoq2
Copy link
Member

TheZoq2 commented Oct 15, 2020

I guess the question that remains is what we should do with the previous versions.

Given the severity, it might make sense to yank the affected version. According to crates.io, we still have plenty of people on 0.6, 0.5 and older versions, and we have quite a few breaking changes lined up.

Would it make sense to yank the latest versions of 0.4, 0.5 and 0.6, then release a new version of them with the DMA things marked as deprecated? That way people who don't use DMA can avoid upgrading right now, while people who do get notified about the problem.

@therealprof
Copy link
Member

Hm, the yanking mechanics is subtle. I'm not sure it would have the intended effect if we did that. But I'll leave that decision up to you.

@TheZoq2
Copy link
Member

TheZoq2 commented Oct 16, 2020

In what way is it subtle. I have not dealt much with yanking so I may be missing something here.

As I understand it the effect will be that people who clean build their project will either get bumped to the patched version and see the deprecation warning, or get a message about the version they are using (in the lockfile or Cargo.toml) being yanked. Obviously we can't do much for people who don't do a clean build

@thalesfragoso
Copy link
Member Author

then release a new version of them with the DMA things marked as deprecated

I don't think deprecation conveys the right idea here, so not sure if it's worth it, and I guess people can still use yanked versions without problems (if they want to), no ?

@therealprof
Copy link
Member

In what way is it subtle. I have not dealt much with yanking so I may be missing something here.

Me neither but the exact workings are a mystery to pretty much everyone which is why it is subtle.

As I understand it the effect will be that people who clean build their project will either get bumped to the patched version and see the deprecation warning, or get a message about the version they are using (in the lockfile or Cargo.toml) being yanked. Obviously we can't do much for people who don't do a clean build

My understanding is that it pretty much only works for clean builds without Cargo.lock. If you have a Cargo.lock it'll continue working, if you don't then I think it depends on what the and previous versions are and what is specified in the Cargo.toml: If you have a minor specified and there's a minor update it'll fall forward, if the minor version is the last one in row (which is typical if you have breaking changes due to ) it'll fall back to the previous patch version (which typically has the same problem). To upgrade the minor you need to change the Cargo.toml.

@TheZoq2
Copy link
Member

TheZoq2 commented Oct 16, 2020

I don't think deprecation conveys the right idea here, so not sure if it's worth it, and I guess people can still use yanked versions without problems (if they want to), no ?

I'm not sure, I thought yanked versions are not distributed anymore? As for conveying the right idea, I figure a correctly worded deprecation message should give roughly the right idea.

My understanding is that it pretty much only works for clean builds without Cargo.lock.

Yea, i'm not sure how cargo.lock will affect things with yanked versions.

and there's a minor update it'll fall forward, if the minor version is the last one in row (which is typical if you have breaking changes due to ) it'll fall back to the previous patch version

This will not be a problem if we release this new version with deprecated DMA though.

To upgrade the minor you need to change the Cargo.toml.
I don't believe so, unless you have explicitly requested a specific version. The default of
x.y.z actually x.y.z^ as I understand it.

@therealprof
Copy link
Member

x.y.z actually x.y.z^ as I understand it.

You probably mean ^x.y.z.

But minor level means y, not z which is the patch level. Below 1.0 the Rust compatibility rules say that only the patch level may automatically change to a higher version. Unfortunately tools like cargo add always add a patch version so you can't even fall back to a previous patch version (if such a version would exist, that is).

@TheZoq2
Copy link
Member

TheZoq2 commented Oct 17, 2020

Oh right, I may be getting things confused with the patch vs minor version thing then since I'm so used to 0.x crates

What I'm suggesting is that we release a

0.7.0: with fixed DMA
0.6.2: 0.6.1 with DMA deprecated
0.5.3: 0.5.2 with DMA deprecated

As I understand it, that would automatically bump clean builds of 0.6.x and 0.5.x users to a non-breaking version with a deprecation message, while new users would get the 0.7 version

@TheZoq2
Copy link
Member

TheZoq2 commented Oct 17, 2020

Alright, 0.7 has been released 🎉

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

Successfully merging this pull request may close these issues.

dma::WriteDma::write is unsound.
3 participants