From patchwork Sat Apr 18 04:51:11 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 18788 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n3I4pWLA025096 for ; Sat, 18 Apr 2009 04:51:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751099AbZDREvb (ORCPT ); Sat, 18 Apr 2009 00:51:31 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750766AbZDREvb (ORCPT ); Sat, 18 Apr 2009 00:51:31 -0400 Received: from ti-out-0910.google.com ([209.85.142.186]:11360 "EHLO ti-out-0910.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750755AbZDREv2 convert rfc822-to-8bit (ORCPT ); Sat, 18 Apr 2009 00:51:28 -0400 Received: by ti-out-0910.google.com with SMTP id 11so737252tim.23 for ; Fri, 17 Apr 2009 21:51:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type:content-transfer-encoding; bh=NxRFUuxZCaEiPdQZXrcIkxRZYcW6blv7EuPQ2grT+HM=; b=BU0OQi8wYzfQVnpl4EMdgB2uVl5xxAm1p94zx9qhXjnnC30f78uueNkcpoMhlcgg5K g7Ypa24PcDBHeIL81xXjjfaB+5e2vhvreBMVqR8forXTGi+hqag5lPDLpXDuYfZzgYky 2IZtp7azHa6cT9ZTBa4MLd+AqV+o1KrXKZn4Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; b=pQBb2yA8vsMV1RMolOibuszUFgBdLAOSw6SXWia4hFGYtvcjG5vXlSnWjg8/elydfb 2TGFeUOnj3BGD+r3FBUMmZ0Btnr359LHB60rx2UMsWRFFkkalG7dWmYqOucMvZWG8/Fw NhQUHYBNW0T9BCB84Bo9Mlj3OaiqjSPErYExo= Received: by 10.110.10.16 with SMTP id 16mr3664121tij.18.1240030286040; Fri, 17 Apr 2009 21:51:26 -0700 (PDT) Received: from linux-lm ([119.123.207.185]) by mx.google.com with ESMTPS id u8sm2683070tia.26.2009.04.17.21.51.22 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 17 Apr 2009 21:51:24 -0700 (PDT) Date: Sat, 18 Apr 2009 12:51:11 +0800 From: leiming To: Linus Torvalds Cc: "Rafael J. Wysocki" , Linux Kernel Mailing List , Adrian Bunk , Andrew Morton , Natalie Protasevich , Kernel Testers List , Network Development , Linux ACPI , Linux PM List , Linux SCSI List , video4linux-list@redhat.com, laurent.pinchart@skynet.be, mchehab@infradead.org Subject: Re: 2.6.30-rc2-git2: Reported regressions from 2.6.29 Message-ID: <20090418125111.6646e997@linux-lm> In-Reply-To: References: <200904172336.12414.rjw@sisk.pl> <20090418103226.54250420@linux-lm> X-Mailer: Claws Mail 3.7.1 (GTK+ 2.14.4; x86_64-unknown-linux-gnu) Mime-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On Fri, 17 Apr 2009 19:55:29 -0700 (PDT) Linus Torvalds wrote: > > @@ -742,7 +742,7 @@ static int uvc_alloc_urb_buffers(struct > > uvc_video_device *video, > > /* Buffers are already allocated, bail out. */ > > if (video->urb_size) > > - return 0; > > + return DIV_ROUND_UP(video->urb_size, psize); > > I don't think this is right. It should round _down_. > > It's supposed to return 'npackets', but if you pass it a different > packet size than it was passed originally, it can now return a > potentially bigger number than the already allocated buffer, no? > > So I think it should round down (ie use a regular divide). No? Yes,you are correct, please ignore my last reply, and following is the fixed patch. Thanks. From a3b3d72cdd57a0699fb643b41b78eb7beb211ff5 Mon Sep 17 00:00:00 2001 From: Ming Lei Date: Wed, 15 Apr 2009 22:32:51 +0800 Subject: [PATCH] V4L/DVB:usbvideo:fix uvc resume failed(v2) Now urb buffers is not freed before suspend, so uvc_alloc_urb_buffers should return packet counts allocated originally during uvc resume , instead of zero. This version uses round down to return packet counts on Linus's suggestions, or else may lead to buffer destructed if packet size is changed before calling uvc_alloc_urb_buffers() in this kind of case. This patch is against v2.6.30-rc2. Signed-off-by: Ming Lei --- drivers/media/video/uvc/uvc_video.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c index a95e173..6ce974d 100644 --- a/drivers/media/video/uvc/uvc_video.c +++ b/drivers/media/video/uvc/uvc_video.c @@ -742,7 +742,7 @@ static int uvc_alloc_urb_buffers(struct uvc_video_device *video, /* Buffers are already allocated, bail out. */ if (video->urb_size) - return 0; + return video->urb_size / psize; /* Compute the number of packets. Bulk endpoints might transfer UVC * payloads accross multiple URBs.