Re: [RFC/PATCH 2/2] usb: dwc3: core: split host address space

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Hi,
>
> On Sun, Apr 15, 2012 at 04:40:24AM -0700, Ido Shayevitz wrote:
>>
>> > This will prevent dwc3.ko from ioremapping
>> > the entire memory space, thus preventing xHCI
>> > from requesting its own part of the address.
>> >
>> > Signed-off-by: Felipe Balbi <balbi@xxxxxx>
>> > ---
>> >  drivers/usb/dwc3/core.c |   26 +++++++---
>> >  drivers/usb/dwc3/core.h |  122
>> > +++++++++++++++++++++++------------------------
>> >  2 files changed, 80 insertions(+), 68 deletions(-)
>> >
>> > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>> > index e7c853a..3c69d1a 100644
>> > --- a/drivers/usb/dwc3/core.c
>> > +++ b/drivers/usb/dwc3/core.c
>> > @@ -405,6 +405,7 @@ static void dwc3_core_exit(struct dwc3 *dwc)
>> >  static int __devinit dwc3_probe(struct platform_device *pdev)
>> >  {
>> >  	struct device_node	*node = pdev->dev.of_node;
>> > +	struct resource		host_resource[2];
>> >  	struct resource		*res;
>> >  	struct dwc3		*dwc;
>> >  	struct device		*dev = &pdev->dev;
>> > @@ -431,7 +432,24 @@ static int __devinit dwc3_probe(struct
>> > platform_device *pdev)
>> >  		return -ENODEV;
>> >  	}
>> >
>> > -	dwc->res = res;
>> > +	irq = platform_get_irq(pdev, 0);
>> > +	if (irq < 0) {
>> > +		dev_err(dev, "missing IRQ\n");
>> > +		return -ENODEV;
>> > +	}
>> > +
>> > +	host_resource[0].start = res->start;
>> > +	host_resource[0].end = res->start + 0x7fff;
>> > +	host_resource[0].flags = IORESOURCE_MEM;
>>
>> You set the memory end region to end after 0x7fff, but later you assign
>> it
>> to dwc->res , meaning that this is memory for all the dwc3 core and not
>> just for the host part.
>
> no dude I guess you misunderstood.
>
> start + 0x7fff is the end of the xHCI address space. dwc->res gets
> passed to xHCI driver on host.c

Yes I know, but host.c only uses dwc->res->start and set the end address
by itself. If you want that the only meaning of dwc->res to pass the
resource to host.c, maybe better rename it, or just pass it as argument to
host_init

>> > +
>> > +	host_resource[1].start = irq;
>> > +	host_resource[1].end = irq;
>> > +	host_resource[1].flags = IORESOURCE_IRQ;
>>
>> Adding the irq to the dwc->res is nice to have but I don't think it is
>> related to this patch and I don't see where you use it. Also it seems
>> redundant since of dwc->irq.
>
> xHCI uses it, dwc->res is the resource which will be passed to xHCI
> driver.
>

I think that host.c pass to the xHCI driver the dwc->irq

>> > +
>> > +	dwc->res = host_resource;
>>
>> I don't like the name host_resource, this array is the resources of all
>> the dwc3 not just the host part. Also seems that you set a pointer to
>> local scoped array, isn't this pointer will be invalid after probe will
>> finish ?
>>
> host_resource is only the part of the address which contains the xHCI
> address space, nothing more.

Yes, but why changing dwc->res, the host.c already got the data it needed
before, the only problem you have is that you don't want to request the
mem region of the xhci here.

>> So, instead, maybe create a local array used for non xhci resource:
>> struct resource	mem_res_exclude_xhci[1];
>> ...
>> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> ...
>> mem_res_exclude_xhci[0].start = res->start + 0xc100;
>> mem_res_exclude_xhci[0].end = res->end;
>> mem_res_exclude_xhci[0].flags = res.flags;
>
> and at which point do we let xHCI know what address it should request
> and ioremap ?

It is already known to the XHCI, isn't it ?

>From host.c :

/* setup resources */
generic_resources[0].start = dwc->irq;

generic_resources[1].start = dwc->res->start;
generic_resources[1].end = dwc->res->start + 0x7fff;

> --
> balbi
>

Ido
-- 
Consultant for Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux