GitLab has been upgraded to 13.3.6. If you encounter any issues mail code@riscosopen.org

Commit 49ab6570 authored by ROOL's avatar ROOL 🤖

Revert accidental commits

Admin:
  These changes are currently subject to rework via the normal submissions channel.
parent 8722f4da
......@@ -493,7 +493,6 @@ usbd_status usb_insert_transfer(usbd_xfer_handle xfer)
void usb_transfer_complete(usbd_xfer_handle xfer)
{
((struct dwc_softc_xfer*) xfer)->active = 0;
_swix (USBDriver_TransferComplete, _IN (0), xfer);
}
......
......@@ -243,9 +243,6 @@ void softc_freex(struct usbd_bus *bus, usbd_xfer_handle xfer)
{
struct dwc_softc *sc = (struct dwc_softc *)bus;
struct dwc_softc_xfer* ex = (struct dwc_softc_xfer*) xfer;
DWC_FREE(ex->urb);
SIMPLEQ_INSERT_HEAD(&sc->sc_free_xfers, xfer, next);
}
......@@ -276,16 +273,40 @@ usbd_status softc_open(usbd_pipe_handle pipe)
return USBD_NORMAL_COMPLETION;
}
/* DWCTODO - ISOC needs extra stuff in softc_device_start for urb setup */
if(xfertype == UE_ISOCHRONOUS)
return USBD_INVAL;
epipe->pipe.methods = &softc_device_methods;
if(xfertype == UE_CONTROL) {
/* Allocate URB */
epipe->urb = dwc_otg_hcd_urb_alloc(sc->dwc_dev.hcd,0,0); /* DWCTODO - ISOC */
if(!epipe->urb)
return USBD_NOMEM;
if(xfertype == UE_CONTROL)
{
/* Allocate DMA buffer for request packet */
epipe->request = dwc_dma_alloc(NULL,sizeof(usb_device_request_t),&epipe->dma_req);
if(!epipe->request) return USBD_NOMEM;
} else {
if(!epipe->request)
{
dwc_free(NULL,epipe->urb);
return USBD_NOMEM;
}
}
else
{
/* Set urb pipe info
Note that control transfers do this on a per-xfer basis, as
direction and max packet size is changeable */
dwc_otg_hcd_urb_set_pipeinfo(epipe->urb,dev->address,UE_GET_ADDR(ed->bEndpointAddress),xfertype,UE_GET_DIR(ed->bEndpointAddress),UE_GET_SIZE(UGETW(ed->wMaxPacketSize)));
epipe->request = NULL;
epipe->dma_req = 0;
}
epipe->xfer = NULL;
return USBD_NORMAL_COMPLETION;
}
......@@ -361,6 +382,9 @@ static int hcd_op_complete(dwc_otg_hcd_t *hcd,void *urb_handle,dwc_otg_hcd_urb_t
struct usbd_device *dev = epipe->pipe.device;
dprintf(("","hcd_op_complete xfer %08x DWC status %d\n",ex,status));
dwc_assert(epipe->xfer,"Pipe is idle!");
dwc_assert(epipe->xfer == ex,"Wrong xfer!");
/* Set xfer length, status */
ex->xfer.actlen = dwc_otg_hcd_urb_get_actual_length(dwc_otg_urb);
switch(status)
......@@ -394,16 +418,7 @@ static int hcd_op_complete(dwc_otg_hcd_t *hcd,void *urb_handle,dwc_otg_hcd_urb_t
break;
}
int i;
/* For non isochronous transfers xfer.nframes = 0 */
if (ex->xfer.nframes > 0) {
int actlen = 0;
for (i = 0; i < ex->xfer.nframes; i++) {
ex->xfer.frlengths[i] = dwc_otg_hcd_urb_get_iso_desc_actual_length(ex->urb,i);
actlen += ex->xfer.frlengths[i];
}
ex->xfer.actlen = actlen;
}
/* DWCTODO - Extra isoc stuff */
/* Disable the endpoint after each control transfer
......@@ -424,6 +439,9 @@ static int hcd_op_complete(dwc_otg_hcd_t *hcd,void *urb_handle,dwc_otg_hcd_urb_t
epipe->dwc_priv = 0;
}
/* Mark pipe as idle */
epipe->xfer = NULL;
int s = splusb();
/* Cancel any timeout */
......
......@@ -73,14 +73,6 @@ usbd_status softc_device_transfer(usbd_xfer_handle xfer)
#endif
/* Add transfer to queue */
err = usb_insert_transfer(xfer);
/* to get contiguous isochronous transfers start xfer immediately */
if (UE_GET_XFERTYPE(xfer->pipe->endpoint->edesc->bmAttributes) == UE_ISOCHRONOUS) {
if (err && err != USBD_IN_PROGRESS)
return err;
return softc_device_start(xfer);
}
if (err)
return err;
......@@ -97,57 +89,29 @@ usbd_status softc_device_start(usbd_xfer_handle xfer)
usb_endpoint_descriptor_t *ed = epipe->pipe.endpoint->edesc;
struct usbd_device *dev = epipe->pipe.device;
/* Stop attempts to start an xfer that is already started */
if (ex->active) return USBD_IN_PROGRESS;
DPRINTFN(10,("softc_device_start: xfer=%p pipe=%p urb=%p\n",xfer,xfer->pipe,epipe->urb));
if (ex->urb == NULL) {
ex->urb = dwc_otg_hcd_urb_alloc(sc->dwc_dev.hcd,xfer->nframes,0);
if (ex->urb ==NULL) return USBD_NOMEM;
}
DPRINTFN(10,("softc_device_start: xfer=%p pipe=%p urb=%p\n",xfer,xfer->pipe,ex->urb));
dwc_assert(!epipe->xfer,"Pipe should be idle here");
/* DWCTODO - Hack - reset urb params
DWC layer doesn't (properly) support reuse of urbs, so we must reset
certain key parameters ourselves */
ex->urb->actual_length = 0;
ex->urb->error_count = 0;
ex->urb->status = 0;
ex->urb->packet_count = xfer->nframes;
memset(ex->urb->iso_descs, 0, sizeof(struct dwc_otg_hcd_iso_packet_desc) * xfer->nframes);
int i,offset;
for (i = 0, offset = 0; i < xfer->nframes; offset += xfer->frlengths[i], i++) {
dwc_otg_hcd_urb_set_iso_desc_params(ex->urb, i,offset,xfer->frlengths[i]);
}
epipe->urb->actual_length = 0;
epipe->urb->error_count = 0;
epipe->urb->status = 0;
memset(epipe->urb->iso_descs,0,sizeof(struct dwc_otg_hcd_iso_packet_desc)*epipe->urb->packet_count);
if((ed->bmAttributes & UE_XFERTYPE) == UE_CONTROL) {
if((ed->bmAttributes & UE_XFERTYPE) == UE_CONTROL)
{
/* Set up pipe info. Direction needs to come from request packet instead of pipe. */
dwc_otg_hcd_urb_set_pipeinfo(ex->urb,dev->address,
UE_GET_ADDR(ed->bEndpointAddress),
UE_GET_XFERTYPE(ed->bmAttributes),
ex->xfer.request.bmRequestType & UT_READ,
UE_GET_SIZE(UGETW(ed->wMaxPacketSize)));
dwc_otg_hcd_urb_set_pipeinfo(epipe->urb,dev->address,UE_GET_ADDR(ed->bEndpointAddress),UE_GET_XFERTYPE(ed->bmAttributes),ex->xfer.request.bmRequestType & UT_READ,UE_GET_SIZE(UGETW(ed->wMaxPacketSize)));
/* Copy request packet to our DMA buffer */
memcpy(epipe->request,&ex->xfer.request,sizeof(usb_device_request_t));
DPRINTF(("type %02x req %02x val %04x idx %04x len %04x\n",ex->xfer.request.bmRequestType,
ex->xfer.request.bRequest,
UGETW(ex->xfer.request.wValue),
UGETW(ex->xfer.request.wIndex),
UGETW(ex->xfer.request.wLength)));
} else {
dwc_otg_hcd_urb_set_pipeinfo(ex->urb,dev->address,
UE_GET_ADDR(ed->bEndpointAddress),
UE_GET_XFERTYPE(ed->bmAttributes),
UE_GET_DIR(ed->bEndpointAddress),
UE_GET_SIZE(UGETW(ed->wMaxPacketSize)));
DPRINTF(("type %02x req %02x val %04x idx %04x len %04x\n",ex->xfer.request.bmRequestType,ex->xfer.request.bRequest,UGETW(ex->xfer.request.wValue),UGETW(ex->xfer.request.wIndex),UGETW(ex->xfer.request.wLength)));
}
uint32_t flags = 0;
if((ex->xfer.flags & USBD_FORCE_SHORT_XFER) && !(ex->xfer.length % UGETW(ed->wMaxPacketSize)))
flags |= URB_SEND_ZERO_PACKET;
......@@ -155,18 +119,16 @@ usbd_status softc_device_start(usbd_xfer_handle xfer)
void *buf = KERNADDR(&ex->xfer.dmabuf,0);
dwc_dma_t dma_addr = ((dwc_dma_t) vtophys(buf)) + dma_offset;
DPRINTF(("xfer len %08x buf %08x -> %08x\n",ex->xfer.length, buf, dma_addr));
DPRINTF(("xfer len %08x buf %08x -> %08x\n",ex->xfer.length,buf,dma_addr));
/* Set urb parameters for this xfer */
int interval = ed->bInterval;
dwc_otg_hcd_urb_set_params(epipe->urb,ex,buf,dma_addr,ex->xfer.length,epipe->request,epipe->dma_req,flags,ed->bInterval);
if (UE_GET_XFERTYPE(ed->bmAttributes) == UE_ISOCHRONOUS ||
(UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT && xfer->pipe->device->speed == USB_SPEED_HIGH)) {
interval = (1 << (interval - 1));
}
dwc_otg_hcd_urb_set_params(ex->urb,ex,buf,dma_addr,ex->xfer.length,epipe->request,epipe->dma_req,flags,interval);
/* DWCTODO - Set isoc desc params */
/* Queue and start the urb */
epipe->xfer = ex;
bool timeout = ex->xfer.timeout && !sc->sc_bus.use_polling;
......@@ -178,29 +140,28 @@ usbd_status softc_device_start(usbd_xfer_handle xfer)
callout_reset(&(ex->xfer.timeout_handle), (MS_TO_TICKS(ex->xfer.timeout)), (softc_device_timeout), (ex));
}
int ret = dwc_otg_hcd_urb_enqueue(sc->dwc_dev.hcd,ex->urb,&epipe->dwc_priv,0);
int ret = dwc_otg_hcd_urb_enqueue(sc->dwc_dev.hcd,epipe->urb,&epipe->dwc_priv,0);
if(ret) {
if(ret)
{
dprintf(("","urb_enqueue failed, %d\n",ret));
if(timeout) {
callout_stop(&(ex->xfer.timeout_handle));
/* Just in case ... */
/* Just in case... */
riscos_cancel_abort_pipe(xfer);
}
}
DWC_SPINUNLOCK_IRQRESTORE(sc->dwc_dev.hcd->lock, irqflags);
if (!ret) {
ex->active = 1;
if(!ret)
{
return USBD_IN_PROGRESS;
}
ex->active = 0;
/* If we failed to start we must mark the request as complete, with the appropriate error code */
epipe->xfer = NULL;
/* If we've failed to start we must mark the request as complete, with the appropriate error code */
usbd_status err;
switch(ret)
{
......@@ -214,7 +175,6 @@ usbd_status softc_device_start(usbd_xfer_handle xfer)
err = USBD_IOERROR;
break;
}
xfer->status = err;
usb_transfer_complete(xfer);
/* xfer may have been deleted now */
......@@ -237,9 +197,14 @@ void softc_device_close(usbd_pipe_handle pipe)
dwc_softc_t *sc = (dwc_softc_t *)epipe->pipe.device->bus;
DPRINTF(("softc_device_close: pipe=%p\n",epipe));
dwc_assert(!epipe->xfer,"Pipe should be idle here");
/* Free endpoint */
dwc_otg_hcd_endpoint_disable(sc->dwc_dev.hcd,epipe->dwc_priv,250);
/* Free urb */
dwc_free(NULL,epipe->urb);
/* Free request buffer */
if(epipe->request)
dwc_dma_free(NULL,sizeof(usb_device_request_t),epipe->request,epipe->dma_req);
......@@ -271,12 +236,18 @@ void softc_abort_xfer(usbd_xfer_handle xfer,usbd_status status)
struct dwc_softc_pipe *epipe = (struct dwc_softc_pipe *) xfer->pipe;
dwc_softc_t *sc = (dwc_softc_t *)epipe->pipe.device->bus;
DPRINTFN(10,("softc_abort_xfer: xfer %p status %d\n",xfer,status));
/*
* dwc_otg_hcd_urb_dequeue causes big problems if passed a urb that has already
* been dequeued. ex->active introduced to solve this.
*/
if (ex->active != 0) dwc_otg_hcd_urb_dequeue(sc->dwc_dev.hcd,ex->urb);
if(epipe->xfer == ex)
{
DPRINTFN(10,("dequeing urb\n"));
/* Cancel the urb */
dwc_otg_hcd_urb_dequeue(sc->dwc_dev.hcd,epipe->urb);
/* Mark pipe as idle */
epipe->xfer = NULL;
DPRINTFN(10,("urb dequeued\n"));
}
/* Set status */
xfer->status = status;
......
......@@ -36,12 +36,8 @@ struct dwc_otg_core_if;
struct dwc_otg_hcd;
struct dwc_otg_hcd_urb;
struct dwc_softc_xfer {
struct usbd_xfer xfer; /* Base USBDriver struct */
struct dwc_otg_hcd_urb* urb; /* DWC urb */
int active; /* Xfer active flag */
};
struct dwc_softc_pipe {
......@@ -49,6 +45,10 @@ struct dwc_softc_pipe {
void *dwc_priv; /* DWC endpoint handle */
struct dwc_otg_hcd_urb *urb; /* DWC urb; one per pipe instead of one per xfer, since the BSD layer likes to manage urb/xfer scheduling itself */
struct dwc_softc_xfer *xfer; /* Active xfer (i.e. the one that filled in the urb details) */
usb_device_request_t *request; /* DMA buffer for control endpoint requests */
dwc_dma_t dma_req; /* DMA addr of request */
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment