From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pawel Laszczak Subject: RE: [PATCH v9 5/6] usb:cdns3 Add Cadence USB3 DRD Driver Date: Mon, 12 Aug 2019 04:43:16 +0000 Message-ID: References: <1562324238-16655-1-git-send-email-pawell@cadence.com> <1562324238-16655-6-git-send-email-pawell@cadence.com> <877e8tm25r.fsf@linux.intel.com> <8736idnu0q.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org To: Peter Chen , Felipe Balbi , "devicetree@vger.kernel.org" Cc: "gregkh@linuxfoundation.org" , "linux-usb@vger.kernel.org" , "hdegoede@redhat.com" , "heikki.krogerus@linux.intel.com" , "robh+dt@kernel.org" , "rogerq@ti.com" , "linux-kernel@vger.kernel.org" , "jbergsagel@ti.com" , "nsekhar@ti.com" , "nm@ti.com" , Suresh Punnoose , Jayshri Dajiram Pawar , Rahul Kumar List-Id: devicetree@vger.kernel.org > >> >> Yes, driver frees not used buffers here. >> I think that it's the safest place for this purpose. >> >> > >> >>>> + dma_free_coherent(priv_dev->sysdev, buf- >> >size, >> >>>> + buf->buf, >> >>>> + buf->dma); >> >>>> + spin_lock_irqsave(&priv_dev->lock, flags); >> >>>> + >> >>>> + kfree(buf); >> >>> >> >>>why do you even need this "garbage collector"? >> >> >> >> I need to free not used memory. The once allocated buffer will be >> >> associated with request, but if request.length will be increased in >> >> usb_request then driver will must allocate the bigger buffer. As I >> >> remember I couldn't call dma_free_coherent in interrupt context so I >> >> had to move it to thread handled. This flag was used to avoid going t= hrough >> whole aligned_buf_list every time. >> >> In most cases this part will never called int this place >> > >> >Did you try, btw, setting the quirk flag which tells gadget drivers to >> >always allocate buffers aligned to MaxPacketSize? Wouldn't that be enou= gh? >> >> If found only quirk_ep_out_aligned_size flag, but it align only buffer = size. >> >> DMA used by this controller must have buffer address aligned to 8. >> I think that on most architecture kmalloc should guarantee such aligned. >> The problem was detected on NXP testing board. >> On my board all buffer address are alignment at least to 8. >> > >This un-aligned request buffer address for 8 occurs for Ethernet Gadget (e= g, NCM), >it allocates socket buffer with NET_IP_ALIGN, so the last byte of buffer a= ddress >is always 2. Although this can be workaround by setting quirk_avoids_skb_r= eserve, >but we are not sure if all gadget request buffers can be 8 or Max Packet S= ize aligned. > Thanks Peter for explanation.=20 I will add quirk_avoids_skb_reserve to avoid using this extra buffers, but = I leave this=20 code for safety.=20 -- Cheers, Pawell