mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Madalin Bucur <madalin.bucur@nxp.com>
To: Patrick Havelange <patrick.havelange@essensium.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH net 1/4] net: freescale/fman: Split the main resource region reservation
Date: Thu, 10 Dec 2020 10:46:18 +0000	[thread overview]
Message-ID: <AM6PR04MB3976B3C4CB46CF21CF74403FECCB0@AM6PR04MB3976.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <51b57945-c238-0c58-ef12-562911a56f8a@essensium.com>

> -----Original Message-----
> From: Patrick Havelange <patrick.havelange@essensium.com>
> Sent: 10 December 2020 12:06
> To: Madalin Bucur <madalin.bucur@nxp.com>; David S. Miller
> <davem@davemloft.net>; Jakub Kicinski <kuba@kernel.org>;
> netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH net 1/4] net: freescale/fman: Split the main resource
> region reservation
> 
> On 2020-12-10 10:05, Madalin Bucur wrote:
> >> -----Original Message-----
> >> From: Patrick Havelange <patrick.havelange@essensium.com>
> 
> [snipped]
> 
> >>
> >> But then that change would not be compatible with the existing device
> >> trees in already existing hardware. I'm not sure how to handle that
> case
> >> properly.
> >
> > One needs to be backwards compatible with the old device trees, so we do
> not
> > really have a simple answer, I know.
> >
> >>> If we want to hack it,
> >>> instead of splitting ioremaps, we can reserve 4 kB in the FMan driver,
> >>> and keep the ioremap as it is now, with the benefit of less code churn.
> >>
> >> but then the ioremap and the memory reservation do not match. Why
> bother
> >> at all then with the mem reservation, just ioremap only and be done
> with
> >> it. What I'm saying is, I don't see the point of having a "fake"
> >> reservation call if it does not correspond that what is being used.
> >
> > The reservation is not fake, it just covering the first portion of the
> ioremap.
> > Another hypothetical FMan driver would presumably reserve and ioremap
> starting
> > from the same point, thus the desired error would be met.
> >
> > Regarding removing reservation altogether, yes, we can do that, in the
> child
> > device drivers. That will fix that use after free issue you've found and
> align
> > with the custom, hierarchical structure of the FMan devices/drivers. But
> would
> > leave them without the double use guard we have when using the
> reservation.
> >
> >>> In the end, what the reservation is trying to achieve is to make sure
> >> there
> >>> is a single driver controlling a certain peripeheral, and this basic
> >>> requirement would be addressed by that change plus devm_of_iomap() for
> >> child
> >>> devices (ports, MACs).
> >>
> >> Again, correct me if I'm wrong, but with the fake mem reservation, it
> >> would *not* make sure that a single driver is controlling a certain
> >> peripheral.
> >
> > Actually, it would. If the current FMan driver reserves the first part
> of the FMan
> > memory, then another FMan driver (I do not expect a random driver trying
> to map the
> > FMan register area)
> 
> Ha!, now I understand your point. I still think it is not a clean
> solution, as the reservation do not match the ioremap usage.
> 
> > would likely try to use that same part (with the same or
> > a different size, it does not matter, there will be an error anyway) and
> the
> > reservation attempt will fail. If we fix the child device drivers, then
> they
> > will have normal mappings and reservations.
> >
> >> My point is, either have a *correct* mem reservation, or don't have one
> >> at all. There is no point in trying to cheat the system.
> >
> > Now we do not have correct reservations for the child devices because
> the
> > parent takes it all for himself. Reduce the parent reservation and make
> room
> > for correct reservations for the child. The two-sections change you've
> made may
> > try to be correct but it's overkill for the purpose of detecting double
> use.
> 
> But it is not overkill if we want to detect potential subdrivers mapping
> sections that would not start at the main fman region (but still part of
> the main fman region).
> 
> > And I also find the patch to obfuscate the already not so readable code
> so I'd
> > opt for a simpler fix.
> 
> As said already, I'm not in favor of having a reservation that do not
> match the real usage.
> 
> And in my opinion, having a mismatch with the mem reservation and the
> mem usage is also the kind of obfuscation that we want to avoid.
> 
> Yes now the code is slightly more complex, but it is also slightly more
> correct.
> 
> I'm not seeing currently another way on how to make it simpler *and*
> correct at the same time.


Ok, we've taken note on your report and will put together a fix.

Regards,
Madalin

  reply	other threads:[~2020-12-10 10:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-03 13:50 [PATCH net 0/4] freescale/fman: remove usage of __devm_request_region Patrick Havelange
2020-12-03 13:50 ` [PATCH net 1/4] net: freescale/fman: Split the main resource region reservation Patrick Havelange
2020-12-03 15:47   ` Madalin Bucur
2020-12-08 14:55     ` Patrick Havelange
2020-12-09  9:10       ` Madalin Bucur
2020-12-09 14:16         ` Patrick Havelange
2020-12-09 18:55           ` Madalin Bucur
2020-12-10  8:49             ` Patrick Havelange
2020-12-10  9:05               ` Madalin Bucur
2020-12-10 10:05                 ` Patrick Havelange
2020-12-10 10:46                   ` Madalin Bucur [this message]
2020-12-03 13:50 ` [PATCH net 2/4] net: freescale/fman-port: remove direct use of __devm_request_region Patrick Havelange
2020-12-03 13:50 ` [PATCH net 3/4] net: freescale/fman-mac: " Patrick Havelange
2020-12-03 13:50 ` [PATCH net 4/4] net: freescale/fman: remove fman_get_mem_region Patrick Havelange

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM6PR04MB3976B3C4CB46CF21CF74403FECCB0@AM6PR04MB3976.eurprd04.prod.outlook.com \
    --to=madalin.bucur@nxp.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=patrick.havelange@essensium.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®