1001_linux-3.16.2.patch 200 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946
  1. diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt
  2. index 7ccf933bfbe0..48148d6d9307 100644
  3. --- a/Documentation/sound/alsa/ALSA-Configuration.txt
  4. +++ b/Documentation/sound/alsa/ALSA-Configuration.txt
  5. @@ -2026,8 +2026,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
  6. -------------------
  7. Module for sound cards based on the Asus AV66/AV100/AV200 chips,
  8. - i.e., Xonar D1, DX, D2, D2X, DS, Essence ST (Deluxe), Essence STX,
  9. - HDAV1.3 (Deluxe), and HDAV1.3 Slim.
  10. + i.e., Xonar D1, DX, D2, D2X, DS, DSX, Essence ST (Deluxe),
  11. + Essence STX (II), HDAV1.3 (Deluxe), and HDAV1.3 Slim.
  12. This module supports autoprobe and multiple cards.
  13. diff --git a/Documentation/stable_kernel_rules.txt b/Documentation/stable_kernel_rules.txt
  14. index cbc2f03056bd..aee73e78c7d4 100644
  15. --- a/Documentation/stable_kernel_rules.txt
  16. +++ b/Documentation/stable_kernel_rules.txt
  17. @@ -29,6 +29,9 @@ Rules on what kind of patches are accepted, and which ones are not, into the
  18. Procedure for submitting patches to the -stable tree:
  19. + - If the patch covers files in net/ or drivers/net please follow netdev stable
  20. + submission guidelines as described in
  21. + Documentation/networking/netdev-FAQ.txt
  22. - Send the patch, after verifying that it follows the above rules, to
  23. stable@vger.kernel.org. You must note the upstream commit ID in the
  24. changelog of your submission, as well as the kernel version you wish
  25. diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
  26. index 0fe36497642c..612e6e99d1e5 100644
  27. --- a/Documentation/virtual/kvm/api.txt
  28. +++ b/Documentation/virtual/kvm/api.txt
  29. @@ -1869,7 +1869,8 @@ registers, find a list below:
  30. PPC | KVM_REG_PPC_PID | 64
  31. PPC | KVM_REG_PPC_ACOP | 64
  32. PPC | KVM_REG_PPC_VRSAVE | 32
  33. - PPC | KVM_REG_PPC_LPCR | 64
  34. + PPC | KVM_REG_PPC_LPCR | 32
  35. + PPC | KVM_REG_PPC_LPCR_64 | 64
  36. PPC | KVM_REG_PPC_PPR | 64
  37. PPC | KVM_REG_PPC_ARCH_COMPAT 32
  38. PPC | KVM_REG_PPC_DABRX | 32
  39. diff --git a/Makefile b/Makefile
  40. index 87663a2d1d10..c2617526e605 100644
  41. --- a/Makefile
  42. +++ b/Makefile
  43. @@ -1,6 +1,6 @@
  44. VERSION = 3
  45. PATCHLEVEL = 16
  46. -SUBLEVEL = 1
  47. +SUBLEVEL = 2
  48. EXTRAVERSION =
  49. NAME = Museum of Fishiegoodies
  50. diff --git a/arch/arm/boot/dts/am4372.dtsi b/arch/arm/boot/dts/am4372.dtsi
  51. index 49fa59622254..c9aee0e799bb 100644
  52. --- a/arch/arm/boot/dts/am4372.dtsi
  53. +++ b/arch/arm/boot/dts/am4372.dtsi
  54. @@ -168,9 +168,6 @@
  55. ti,hwmods = "mailbox";
  56. ti,mbox-num-users = <4>;
  57. ti,mbox-num-fifos = <8>;
  58. - ti,mbox-names = "wkup_m3";
  59. - ti,mbox-data = <0 0 0 0>;
  60. - status = "disabled";
  61. };
  62. timer1: timer@44e31000 {
  63. diff --git a/arch/arm/include/asm/unistd.h b/arch/arm/include/asm/unistd.h
  64. index 43876245fc57..21ca0cebcab0 100644
  65. --- a/arch/arm/include/asm/unistd.h
  66. +++ b/arch/arm/include/asm/unistd.h
  67. @@ -15,7 +15,17 @@
  68. #include <uapi/asm/unistd.h>
  69. +/*
  70. + * This may need to be greater than __NR_last_syscall+1 in order to
  71. + * account for the padding in the syscall table
  72. + */
  73. #define __NR_syscalls (384)
  74. +
  75. +/*
  76. + * *NOTE*: This is a ghost syscall private to the kernel. Only the
  77. + * __kuser_cmpxchg code in entry-armv.S should be aware of its
  78. + * existence. Don't ever use this from user code.
  79. + */
  80. #define __ARM_NR_cmpxchg (__ARM_NR_BASE+0x00fff0)
  81. #define __ARCH_WANT_STAT64
  82. diff --git a/arch/arm/include/uapi/asm/unistd.h b/arch/arm/include/uapi/asm/unistd.h
  83. index ba94446c72d9..acd5b66ea3aa 100644
  84. --- a/arch/arm/include/uapi/asm/unistd.h
  85. +++ b/arch/arm/include/uapi/asm/unistd.h
  86. @@ -411,11 +411,6 @@
  87. #define __NR_renameat2 (__NR_SYSCALL_BASE+382)
  88. /*
  89. - * This may need to be greater than __NR_last_syscall+1 in order to
  90. - * account for the padding in the syscall table
  91. - */
  92. -
  93. -/*
  94. * The following SWIs are ARM private.
  95. */
  96. #define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000)
  97. @@ -426,12 +421,6 @@
  98. #define __ARM_NR_set_tls (__ARM_NR_BASE+5)
  99. /*
  100. - * *NOTE*: This is a ghost syscall private to the kernel. Only the
  101. - * __kuser_cmpxchg code in entry-armv.S should be aware of its
  102. - * existence. Don't ever use this from user code.
  103. - */
  104. -
  105. -/*
  106. * The following syscalls are obsolete and no longer available for EABI.
  107. */
  108. #if !defined(__KERNEL__)
  109. diff --git a/arch/arm/mach-omap2/control.c b/arch/arm/mach-omap2/control.c
  110. index 751f3549bf6f..acadac0992b6 100644
  111. --- a/arch/arm/mach-omap2/control.c
  112. +++ b/arch/arm/mach-omap2/control.c
  113. @@ -314,7 +314,8 @@ void omap3_save_scratchpad_contents(void)
  114. scratchpad_contents.public_restore_ptr =
  115. virt_to_phys(omap3_restore_3630);
  116. else if (omap_rev() != OMAP3430_REV_ES3_0 &&
  117. - omap_rev() != OMAP3430_REV_ES3_1)
  118. + omap_rev() != OMAP3430_REV_ES3_1 &&
  119. + omap_rev() != OMAP3430_REV_ES3_1_2)
  120. scratchpad_contents.public_restore_ptr =
  121. virt_to_phys(omap3_restore);
  122. else
  123. diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
  124. index 6c074f37cdd2..da1b256caccc 100644
  125. --- a/arch/arm/mach-omap2/omap_hwmod.c
  126. +++ b/arch/arm/mach-omap2/omap_hwmod.c
  127. @@ -2185,6 +2185,8 @@ static int _enable(struct omap_hwmod *oh)
  128. oh->mux->pads_dynamic))) {
  129. omap_hwmod_mux(oh->mux, _HWMOD_STATE_ENABLED);
  130. _reconfigure_io_chain();
  131. + } else if (oh->flags & HWMOD_FORCE_MSTANDBY) {
  132. + _reconfigure_io_chain();
  133. }
  134. _add_initiator_dep(oh, mpu_oh);
  135. @@ -2291,6 +2293,8 @@ static int _idle(struct omap_hwmod *oh)
  136. if (oh->mux && oh->mux->pads_dynamic) {
  137. omap_hwmod_mux(oh->mux, _HWMOD_STATE_IDLE);
  138. _reconfigure_io_chain();
  139. + } else if (oh->flags & HWMOD_FORCE_MSTANDBY) {
  140. + _reconfigure_io_chain();
  141. }
  142. oh->_state = _HWMOD_STATE_IDLE;
  143. diff --git a/arch/arm64/include/asm/cacheflush.h b/arch/arm64/include/asm/cacheflush.h
  144. index a5176cf32dad..f2defe1c380c 100644
  145. --- a/arch/arm64/include/asm/cacheflush.h
  146. +++ b/arch/arm64/include/asm/cacheflush.h
  147. @@ -138,19 +138,10 @@ static inline void __flush_icache_all(void)
  148. #define flush_icache_page(vma,page) do { } while (0)
  149. /*
  150. - * flush_cache_vmap() is used when creating mappings (eg, via vmap,
  151. - * vmalloc, ioremap etc) in kernel space for pages. On non-VIPT
  152. - * caches, since the direct-mappings of these pages may contain cached
  153. - * data, we need to do a full cache flush to ensure that writebacks
  154. - * don't corrupt data placed into these pages via the new mappings.
  155. + * Not required on AArch64 (PIPT or VIPT non-aliasing D-cache).
  156. */
  157. static inline void flush_cache_vmap(unsigned long start, unsigned long end)
  158. {
  159. - /*
  160. - * set_pte_at() called from vmap_pte_range() does not
  161. - * have a DSB after cleaning the cache line.
  162. - */
  163. - dsb(ish);
  164. }
  165. static inline void flush_cache_vunmap(unsigned long start, unsigned long end)
  166. diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
  167. index e0ccceb317d9..2a1508cdead0 100644
  168. --- a/arch/arm64/include/asm/pgtable.h
  169. +++ b/arch/arm64/include/asm/pgtable.h
  170. @@ -138,6 +138,8 @@ extern struct page *empty_zero_page;
  171. #define pte_valid_user(pte) \
  172. ((pte_val(pte) & (PTE_VALID | PTE_USER)) == (PTE_VALID | PTE_USER))
  173. +#define pte_valid_not_user(pte) \
  174. + ((pte_val(pte) & (PTE_VALID | PTE_USER)) == PTE_VALID)
  175. static inline pte_t pte_wrprotect(pte_t pte)
  176. {
  177. @@ -184,6 +186,15 @@ static inline pte_t pte_mkspecial(pte_t pte)
  178. static inline void set_pte(pte_t *ptep, pte_t pte)
  179. {
  180. *ptep = pte;
  181. +
  182. + /*
  183. + * Only if the new pte is valid and kernel, otherwise TLB maintenance
  184. + * or update_mmu_cache() have the necessary barriers.
  185. + */
  186. + if (pte_valid_not_user(pte)) {
  187. + dsb(ishst);
  188. + isb();
  189. + }
  190. }
  191. extern void __sync_icache_dcache(pte_t pteval, unsigned long addr);
  192. @@ -303,6 +314,7 @@ static inline void set_pmd(pmd_t *pmdp, pmd_t pmd)
  193. {
  194. *pmdp = pmd;
  195. dsb(ishst);
  196. + isb();
  197. }
  198. static inline void pmd_clear(pmd_t *pmdp)
  199. @@ -333,6 +345,7 @@ static inline void set_pud(pud_t *pudp, pud_t pud)
  200. {
  201. *pudp = pud;
  202. dsb(ishst);
  203. + isb();
  204. }
  205. static inline void pud_clear(pud_t *pudp)
  206. diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h
  207. index b9349c4513ea..3796ea6bb734 100644
  208. --- a/arch/arm64/include/asm/tlbflush.h
  209. +++ b/arch/arm64/include/asm/tlbflush.h
  210. @@ -122,6 +122,7 @@ static inline void flush_tlb_kernel_range(unsigned long start, unsigned long end
  211. for (addr = start; addr < end; addr += 1 << (PAGE_SHIFT - 12))
  212. asm("tlbi vaae1is, %0" : : "r"(addr));
  213. dsb(ish);
  214. + isb();
  215. }
  216. /*
  217. @@ -131,8 +132,8 @@ static inline void update_mmu_cache(struct vm_area_struct *vma,
  218. unsigned long addr, pte_t *ptep)
  219. {
  220. /*
  221. - * set_pte() does not have a DSB, so make sure that the page table
  222. - * write is visible.
  223. + * set_pte() does not have a DSB for user mappings, so make sure that
  224. + * the page table write is visible.
  225. */
  226. dsb(ishst);
  227. }
  228. diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
  229. index a7fb874b595e..fe5b94078d82 100644
  230. --- a/arch/arm64/kernel/debug-monitors.c
  231. +++ b/arch/arm64/kernel/debug-monitors.c
  232. @@ -315,20 +315,20 @@ static int brk_handler(unsigned long addr, unsigned int esr,
  233. {
  234. siginfo_t info;
  235. - if (call_break_hook(regs, esr) == DBG_HOOK_HANDLED)
  236. - return 0;
  237. + if (user_mode(regs)) {
  238. + info = (siginfo_t) {
  239. + .si_signo = SIGTRAP,
  240. + .si_errno = 0,
  241. + .si_code = TRAP_BRKPT,
  242. + .si_addr = (void __user *)instruction_pointer(regs),
  243. + };
  244. - if (!user_mode(regs))
  245. + force_sig_info(SIGTRAP, &info, current);
  246. + } else if (call_break_hook(regs, esr) != DBG_HOOK_HANDLED) {
  247. + pr_warning("Unexpected kernel BRK exception at EL1\n");
  248. return -EFAULT;
  249. + }
  250. - info = (siginfo_t) {
  251. - .si_signo = SIGTRAP,
  252. - .si_errno = 0,
  253. - .si_code = TRAP_BRKPT,
  254. - .si_addr = (void __user *)instruction_pointer(regs),
  255. - };
  256. -
  257. - force_sig_info(SIGTRAP, &info, current);
  258. return 0;
  259. }
  260. diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
  261. index 14db1f6e8d7f..c0aead7d1a72 100644
  262. --- a/arch/arm64/kernel/efi.c
  263. +++ b/arch/arm64/kernel/efi.c
  264. @@ -464,6 +464,8 @@ static int __init arm64_enter_virtual_mode(void)
  265. set_bit(EFI_RUNTIME_SERVICES, &efi.flags);
  266. + efi.runtime_version = efi.systab->hdr.revision;
  267. +
  268. return 0;
  269. }
  270. early_initcall(arm64_enter_virtual_mode);
  271. diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
  272. index 736c17a226e9..bf0fc6b16ad9 100644
  273. --- a/arch/mips/math-emu/cp1emu.c
  274. +++ b/arch/mips/math-emu/cp1emu.c
  275. @@ -1827,7 +1827,7 @@ dcopuop:
  276. case -1:
  277. if (cpu_has_mips_4_5_r)
  278. - cbit = fpucondbit[MIPSInst_RT(ir) >> 2];
  279. + cbit = fpucondbit[MIPSInst_FD(ir) >> 2];
  280. else
  281. cbit = FPU_CSR_COND;
  282. if (rv.w)
  283. diff --git a/arch/powerpc/include/uapi/asm/kvm.h b/arch/powerpc/include/uapi/asm/kvm.h
  284. index 2bc4a9409a93..de7d426a9b0c 100644
  285. --- a/arch/powerpc/include/uapi/asm/kvm.h
  286. +++ b/arch/powerpc/include/uapi/asm/kvm.h
  287. @@ -548,6 +548,7 @@ struct kvm_get_htab_header {
  288. #define KVM_REG_PPC_VRSAVE (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb4)
  289. #define KVM_REG_PPC_LPCR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb5)
  290. +#define KVM_REG_PPC_LPCR_64 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb5)
  291. #define KVM_REG_PPC_PPR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb6)
  292. /* Architecture compatibility level */
  293. diff --git a/arch/powerpc/kernel/eeh_pe.c b/arch/powerpc/kernel/eeh_pe.c
  294. index fbd01eba4473..94802d267022 100644
  295. --- a/arch/powerpc/kernel/eeh_pe.c
  296. +++ b/arch/powerpc/kernel/eeh_pe.c
  297. @@ -802,53 +802,33 @@ void eeh_pe_restore_bars(struct eeh_pe *pe)
  298. */
  299. const char *eeh_pe_loc_get(struct eeh_pe *pe)
  300. {
  301. - struct pci_controller *hose;
  302. struct pci_bus *bus = eeh_pe_bus_get(pe);
  303. - struct pci_dev *pdev;
  304. - struct device_node *dn;
  305. - const char *loc;
  306. + struct device_node *dn = pci_bus_to_OF_node(bus);
  307. + const char *loc = NULL;
  308. - if (!bus)
  309. - return "N/A";
  310. + if (!dn)
  311. + goto out;
  312. /* PHB PE or root PE ? */
  313. if (pci_is_root_bus(bus)) {
  314. - hose = pci_bus_to_host(bus);
  315. - loc = of_get_property(hose->dn,
  316. - "ibm,loc-code", NULL);
  317. - if (loc)
  318. - return loc;
  319. - loc = of_get_property(hose->dn,
  320. - "ibm,io-base-loc-code", NULL);
  321. + loc = of_get_property(dn, "ibm,loc-code", NULL);
  322. + if (!loc)
  323. + loc = of_get_property(dn, "ibm,io-base-loc-code", NULL);
  324. if (loc)
  325. - return loc;
  326. -
  327. - pdev = pci_get_slot(bus, 0x0);
  328. - } else {
  329. - pdev = bus->self;
  330. - }
  331. -
  332. - if (!pdev) {
  333. - loc = "N/A";
  334. - goto out;
  335. - }
  336. + goto out;
  337. - dn = pci_device_to_OF_node(pdev);
  338. - if (!dn) {
  339. - loc = "N/A";
  340. - goto out;
  341. + /* Check the root port */
  342. + dn = dn->child;
  343. + if (!dn)
  344. + goto out;
  345. }
  346. loc = of_get_property(dn, "ibm,loc-code", NULL);
  347. if (!loc)
  348. loc = of_get_property(dn, "ibm,slot-location-code", NULL);
  349. - if (!loc)
  350. - loc = "N/A";
  351. out:
  352. - if (pci_is_root_bus(bus) && pdev)
  353. - pci_dev_put(pdev);
  354. - return loc;
  355. + return loc ? loc : "N/A";
  356. }
  357. /**
  358. diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
  359. index 7a12edbb61e7..0f3a19237444 100644
  360. --- a/arch/powerpc/kvm/book3s_hv.c
  361. +++ b/arch/powerpc/kvm/book3s_hv.c
  362. @@ -785,7 +785,8 @@ static int kvm_arch_vcpu_ioctl_set_sregs_hv(struct kvm_vcpu *vcpu,
  363. return 0;
  364. }
  365. -static void kvmppc_set_lpcr(struct kvm_vcpu *vcpu, u64 new_lpcr)
  366. +static void kvmppc_set_lpcr(struct kvm_vcpu *vcpu, u64 new_lpcr,
  367. + bool preserve_top32)
  368. {
  369. struct kvmppc_vcore *vc = vcpu->arch.vcore;
  370. u64 mask;
  371. @@ -820,6 +821,10 @@ static void kvmppc_set_lpcr(struct kvm_vcpu *vcpu, u64 new_lpcr)
  372. mask = LPCR_DPFD | LPCR_ILE | LPCR_TC;
  373. if (cpu_has_feature(CPU_FTR_ARCH_207S))
  374. mask |= LPCR_AIL;
  375. +
  376. + /* Broken 32-bit version of LPCR must not clear top bits */
  377. + if (preserve_top32)
  378. + mask &= 0xFFFFFFFF;
  379. vc->lpcr = (vc->lpcr & ~mask) | (new_lpcr & mask);
  380. spin_unlock(&vc->lock);
  381. }
  382. @@ -939,6 +944,7 @@ static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,
  383. *val = get_reg_val(id, vcpu->arch.vcore->tb_offset);
  384. break;
  385. case KVM_REG_PPC_LPCR:
  386. + case KVM_REG_PPC_LPCR_64:
  387. *val = get_reg_val(id, vcpu->arch.vcore->lpcr);
  388. break;
  389. case KVM_REG_PPC_PPR:
  390. @@ -1150,7 +1156,10 @@ static int kvmppc_set_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,
  391. ALIGN(set_reg_val(id, *val), 1UL << 24);
  392. break;
  393. case KVM_REG_PPC_LPCR:
  394. - kvmppc_set_lpcr(vcpu, set_reg_val(id, *val));
  395. + kvmppc_set_lpcr(vcpu, set_reg_val(id, *val), true);
  396. + break;
  397. + case KVM_REG_PPC_LPCR_64:
  398. + kvmppc_set_lpcr(vcpu, set_reg_val(id, *val), false);
  399. break;
  400. case KVM_REG_PPC_PPR:
  401. vcpu->arch.ppr = set_reg_val(id, *val);
  402. diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
  403. index 8eef1e519077..66b7afec250f 100644
  404. --- a/arch/powerpc/kvm/book3s_pr.c
  405. +++ b/arch/powerpc/kvm/book3s_pr.c
  406. @@ -1233,6 +1233,7 @@ static int kvmppc_get_one_reg_pr(struct kvm_vcpu *vcpu, u64 id,
  407. *val = get_reg_val(id, to_book3s(vcpu)->hior);
  408. break;
  409. case KVM_REG_PPC_LPCR:
  410. + case KVM_REG_PPC_LPCR_64:
  411. /*
  412. * We are only interested in the LPCR_ILE bit
  413. */
  414. @@ -1268,6 +1269,7 @@ static int kvmppc_set_one_reg_pr(struct kvm_vcpu *vcpu, u64 id,
  415. to_book3s(vcpu)->hior_explicit = true;
  416. break;
  417. case KVM_REG_PPC_LPCR:
  418. + case KVM_REG_PPC_LPCR_64:
  419. kvmppc_set_lpcr_pr(vcpu, set_reg_val(id, *val));
  420. break;
  421. default:
  422. diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
  423. index de19edeaa7a7..3136ae2f75af 100644
  424. --- a/arch/powerpc/platforms/powernv/pci-ioda.c
  425. +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
  426. @@ -491,6 +491,7 @@ static int pnv_pci_ioda_dma_set_mask(struct pnv_phb *phb,
  427. set_dma_ops(&pdev->dev, &dma_iommu_ops);
  428. set_iommu_table_base(&pdev->dev, &pe->tce32_table);
  429. }
  430. + *pdev->dev.dma_mask = dma_mask;
  431. return 0;
  432. }
  433. diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c
  434. index 203cbf0dc101..89e23811199c 100644
  435. --- a/arch/powerpc/platforms/pseries/pci_dlpar.c
  436. +++ b/arch/powerpc/platforms/pseries/pci_dlpar.c
  437. @@ -118,10 +118,10 @@ int remove_phb_dynamic(struct pci_controller *phb)
  438. }
  439. }
  440. - /* Unregister the bridge device from sysfs and remove the PCI bus */
  441. - device_unregister(b->bridge);
  442. + /* Remove the PCI bus and unregister the bridge device from sysfs */
  443. phb->bus = NULL;
  444. pci_remove_bus(b);
  445. + device_unregister(b->bridge);
  446. /* Now release the IO resource */
  447. if (res->flags & IORESOURCE_IO)
  448. diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c
  449. index 37b8241ec784..f90ad8592b36 100644
  450. --- a/arch/s390/mm/pgtable.c
  451. +++ b/arch/s390/mm/pgtable.c
  452. @@ -1279,6 +1279,7 @@ static unsigned long page_table_realloc_pmd(struct mmu_gather *tlb,
  453. {
  454. unsigned long next, *table, *new;
  455. struct page *page;
  456. + spinlock_t *ptl;
  457. pmd_t *pmd;
  458. pmd = pmd_offset(pud, addr);
  459. @@ -1296,7 +1297,7 @@ again:
  460. if (!new)
  461. return -ENOMEM;
  462. - spin_lock(&mm->page_table_lock);
  463. + ptl = pmd_lock(mm, pmd);
  464. if (likely((unsigned long *) pmd_deref(*pmd) == table)) {
  465. /* Nuke pmd entry pointing to the "short" page table */
  466. pmdp_flush_lazy(mm, addr, pmd);
  467. @@ -1310,7 +1311,7 @@ again:
  468. page_table_free_rcu(tlb, table);
  469. new = NULL;
  470. }
  471. - spin_unlock(&mm->page_table_lock);
  472. + spin_unlock(ptl);
  473. if (new) {
  474. page_table_free_pgste(new);
  475. goto again;
  476. diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
  477. index d24887b645dc..27adfd902c6f 100644
  478. --- a/arch/x86/Kconfig
  479. +++ b/arch/x86/Kconfig
  480. @@ -1537,6 +1537,7 @@ config EFI
  481. config EFI_STUB
  482. bool "EFI stub support"
  483. depends on EFI
  484. + select RELOCATABLE
  485. ---help---
  486. This kernel feature allows a bzImage to be loaded directly
  487. by EFI firmware without the use of a bootloader.
  488. diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
  489. index 49205d01b9ad..9f83c171ac18 100644
  490. --- a/arch/x86/include/asm/kvm_host.h
  491. +++ b/arch/x86/include/asm/kvm_host.h
  492. @@ -95,7 +95,7 @@ static inline gfn_t gfn_to_index(gfn_t gfn, gfn_t base_gfn, int level)
  493. #define KVM_REFILL_PAGES 25
  494. #define KVM_MAX_CPUID_ENTRIES 80
  495. #define KVM_NR_FIXED_MTRR_REGION 88
  496. -#define KVM_NR_VAR_MTRR 10
  497. +#define KVM_NR_VAR_MTRR 8
  498. #define ASYNC_PF_PER_VCPU 64
  499. diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
  500. index 0ec056012618..aa97a070f09f 100644
  501. --- a/arch/x86/include/asm/pgtable.h
  502. +++ b/arch/x86/include/asm/pgtable.h
  503. @@ -131,8 +131,13 @@ static inline int pte_exec(pte_t pte)
  504. static inline int pte_special(pte_t pte)
  505. {
  506. - return (pte_flags(pte) & (_PAGE_PRESENT|_PAGE_SPECIAL)) ==
  507. - (_PAGE_PRESENT|_PAGE_SPECIAL);
  508. + /*
  509. + * See CONFIG_NUMA_BALANCING pte_numa in include/asm-generic/pgtable.h.
  510. + * On x86 we have _PAGE_BIT_NUMA == _PAGE_BIT_GLOBAL+1 ==
  511. + * __PAGE_BIT_SOFTW1 == _PAGE_BIT_SPECIAL.
  512. + */
  513. + return (pte_flags(pte) & _PAGE_SPECIAL) &&
  514. + (pte_flags(pte) & (_PAGE_PRESENT|_PAGE_PROTNONE));
  515. }
  516. static inline unsigned long pte_pfn(pte_t pte)
  517. diff --git a/arch/x86/kernel/cpu/mcheck/mce_intel.c b/arch/x86/kernel/cpu/mcheck/mce_intel.c
  518. index 9a316b21df8b..3bdb95ae8c43 100644
  519. --- a/arch/x86/kernel/cpu/mcheck/mce_intel.c
  520. +++ b/arch/x86/kernel/cpu/mcheck/mce_intel.c
  521. @@ -42,7 +42,7 @@ static DEFINE_PER_CPU(mce_banks_t, mce_banks_owned);
  522. * cmci_discover_lock protects against parallel discovery attempts
  523. * which could race against each other.
  524. */
  525. -static DEFINE_SPINLOCK(cmci_discover_lock);
  526. +static DEFINE_RAW_SPINLOCK(cmci_discover_lock);
  527. #define CMCI_THRESHOLD 1
  528. #define CMCI_POLL_INTERVAL (30 * HZ)
  529. @@ -144,14 +144,14 @@ static void cmci_storm_disable_banks(void)
  530. int bank;
  531. u64 val;
  532. - spin_lock_irqsave(&cmci_discover_lock, flags);
  533. + raw_spin_lock_irqsave(&cmci_discover_lock, flags);
  534. owned = __get_cpu_var(mce_banks_owned);
  535. for_each_set_bit(bank, owned, MAX_NR_BANKS) {
  536. rdmsrl(MSR_IA32_MCx_CTL2(bank), val);
  537. val &= ~MCI_CTL2_CMCI_EN;
  538. wrmsrl(MSR_IA32_MCx_CTL2(bank), val);
  539. }
  540. - spin_unlock_irqrestore(&cmci_discover_lock, flags);
  541. + raw_spin_unlock_irqrestore(&cmci_discover_lock, flags);
  542. }
  543. static bool cmci_storm_detect(void)
  544. @@ -211,7 +211,7 @@ static void cmci_discover(int banks)
  545. int i;
  546. int bios_wrong_thresh = 0;
  547. - spin_lock_irqsave(&cmci_discover_lock, flags);
  548. + raw_spin_lock_irqsave(&cmci_discover_lock, flags);
  549. for (i = 0; i < banks; i++) {
  550. u64 val;
  551. int bios_zero_thresh = 0;
  552. @@ -266,7 +266,7 @@ static void cmci_discover(int banks)
  553. WARN_ON(!test_bit(i, __get_cpu_var(mce_poll_banks)));
  554. }
  555. }
  556. - spin_unlock_irqrestore(&cmci_discover_lock, flags);
  557. + raw_spin_unlock_irqrestore(&cmci_discover_lock, flags);
  558. if (mca_cfg.bios_cmci_threshold && bios_wrong_thresh) {
  559. pr_info_once(
  560. "bios_cmci_threshold: Some banks do not have valid thresholds set\n");
  561. @@ -316,10 +316,10 @@ void cmci_clear(void)
  562. if (!cmci_supported(&banks))
  563. return;
  564. - spin_lock_irqsave(&cmci_discover_lock, flags);
  565. + raw_spin_lock_irqsave(&cmci_discover_lock, flags);
  566. for (i = 0; i < banks; i++)
  567. __cmci_disable_bank(i);
  568. - spin_unlock_irqrestore(&cmci_discover_lock, flags);
  569. + raw_spin_unlock_irqrestore(&cmci_discover_lock, flags);
  570. }
  571. static void cmci_rediscover_work_func(void *arg)
  572. @@ -360,9 +360,9 @@ void cmci_disable_bank(int bank)
  573. if (!cmci_supported(&banks))
  574. return;
  575. - spin_lock_irqsave(&cmci_discover_lock, flags);
  576. + raw_spin_lock_irqsave(&cmci_discover_lock, flags);
  577. __cmci_disable_bank(bank);
  578. - spin_unlock_irqrestore(&cmci_discover_lock, flags);
  579. + raw_spin_unlock_irqrestore(&cmci_discover_lock, flags);
  580. }
  581. static void intel_init_cmci(void)
  582. diff --git a/arch/x86/kernel/resource.c b/arch/x86/kernel/resource.c
  583. index 2a26819bb6a8..80eab01c1a68 100644
  584. --- a/arch/x86/kernel/resource.c
  585. +++ b/arch/x86/kernel/resource.c
  586. @@ -37,10 +37,12 @@ static void remove_e820_regions(struct resource *avail)
  587. void arch_remove_reservations(struct resource *avail)
  588. {
  589. - /* Trim out BIOS areas (low 1MB and high 2MB) and E820 regions */
  590. + /*
  591. + * Trim out BIOS area (high 2MB) and E820 regions. We do not remove
  592. + * the low 1MB unconditionally, as this area is needed for some ISA
  593. + * cards requiring a memory range, e.g. the i82365 PCMCIA controller.
  594. + */
  595. if (avail->flags & IORESOURCE_MEM) {
  596. - if (avail->start < BIOS_END)
  597. - avail->start = BIOS_END;
  598. resource_clip(avail, BIOS_ROM_BASE, BIOS_ROM_END);
  599. remove_e820_regions(avail);
  600. diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
  601. index ea5b5709aa76..e1e1e80fc6a6 100644
  602. --- a/arch/x86/kernel/vsyscall_64.c
  603. +++ b/arch/x86/kernel/vsyscall_64.c
  604. @@ -81,10 +81,10 @@ static void warn_bad_vsyscall(const char *level, struct pt_regs *regs,
  605. if (!show_unhandled_signals)
  606. return;
  607. - pr_notice_ratelimited("%s%s[%d] %s ip:%lx cs:%lx sp:%lx ax:%lx si:%lx di:%lx\n",
  608. - level, current->comm, task_pid_nr(current),
  609. - message, regs->ip, regs->cs,
  610. - regs->sp, regs->ax, regs->si, regs->di);
  611. + printk_ratelimited("%s%s[%d] %s ip:%lx cs:%lx sp:%lx ax:%lx si:%lx di:%lx\n",
  612. + level, current->comm, task_pid_nr(current),
  613. + message, regs->ip, regs->cs,
  614. + regs->sp, regs->ax, regs->si, regs->di);
  615. }
  616. static int addr_to_vsyscall_nr(unsigned long addr)
  617. diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
  618. index e4e833d3d7d7..2d3b8d0efa0f 100644
  619. --- a/arch/x86/kvm/emulate.c
  620. +++ b/arch/x86/kvm/emulate.c
  621. @@ -2017,6 +2017,7 @@ static int em_ret_far(struct x86_emulate_ctxt *ctxt)
  622. {
  623. int rc;
  624. unsigned long cs;
  625. + int cpl = ctxt->ops->cpl(ctxt);
  626. rc = emulate_pop(ctxt, &ctxt->_eip, ctxt->op_bytes);
  627. if (rc != X86EMUL_CONTINUE)
  628. @@ -2026,6 +2027,9 @@ static int em_ret_far(struct x86_emulate_ctxt *ctxt)
  629. rc = emulate_pop(ctxt, &cs, ctxt->op_bytes);
  630. if (rc != X86EMUL_CONTINUE)
  631. return rc;
  632. + /* Outer-privilege level return is not implemented */
  633. + if (ctxt->mode >= X86EMUL_MODE_PROT16 && (cs & 3) > cpl)
  634. + return X86EMUL_UNHANDLEABLE;
  635. rc = load_segment_descriptor(ctxt, (u16)cs, VCPU_SREG_CS);
  636. return rc;
  637. }
  638. diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c
  639. index bd0da433e6d7..a1ec6a50a05a 100644
  640. --- a/arch/x86/kvm/irq.c
  641. +++ b/arch/x86/kvm/irq.c
  642. @@ -108,7 +108,7 @@ int kvm_cpu_get_interrupt(struct kvm_vcpu *v)
  643. vector = kvm_cpu_get_extint(v);
  644. - if (kvm_apic_vid_enabled(v->kvm) || vector != -1)
  645. + if (vector != -1)
  646. return vector; /* PIC */
  647. return kvm_get_apic_interrupt(v); /* APIC */
  648. diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
  649. index 006911858174..453e5fbbb7ae 100644
  650. --- a/arch/x86/kvm/lapic.c
  651. +++ b/arch/x86/kvm/lapic.c
  652. @@ -352,25 +352,46 @@ static inline int apic_find_highest_irr(struct kvm_lapic *apic)
  653. static inline void apic_clear_irr(int vec, struct kvm_lapic *apic)
  654. {
  655. - apic->irr_pending = false;
  656. + struct kvm_vcpu *vcpu;
  657. +
  658. + vcpu = apic->vcpu;
  659. +
  660. apic_clear_vector(vec, apic->regs + APIC_IRR);
  661. - if (apic_search_irr(apic) != -1)
  662. - apic->irr_pending = true;
  663. + if (unlikely(kvm_apic_vid_enabled(vcpu->kvm)))
  664. + /* try to update RVI */
  665. + kvm_make_request(KVM_REQ_EVENT, vcpu);
  666. + else {
  667. + vec = apic_search_irr(apic);
  668. + apic->irr_pending = (vec != -1);
  669. + }
  670. }
  671. static inline void apic_set_isr(int vec, struct kvm_lapic *apic)
  672. {
  673. - /* Note that we never get here with APIC virtualization enabled. */
  674. + struct kvm_vcpu *vcpu;
  675. +
  676. + if (__apic_test_and_set_vector(vec, apic->regs + APIC_ISR))
  677. + return;
  678. +
  679. + vcpu = apic->vcpu;
  680. - if (!__apic_test_and_set_vector(vec, apic->regs + APIC_ISR))
  681. - ++apic->isr_count;
  682. - BUG_ON(apic->isr_count > MAX_APIC_VECTOR);
  683. /*
  684. - * ISR (in service register) bit is set when injecting an interrupt.
  685. - * The highest vector is injected. Thus the latest bit set matches
  686. - * the highest bit in ISR.
  687. + * With APIC virtualization enabled, all caching is disabled
  688. + * because the processor can modify ISR under the hood. Instead
  689. + * just set SVI.
  690. */
  691. - apic->highest_isr_cache = vec;
  692. + if (unlikely(kvm_apic_vid_enabled(vcpu->kvm)))
  693. + kvm_x86_ops->hwapic_isr_update(vcpu->kvm, vec);
  694. + else {
  695. + ++apic->isr_count;
  696. + BUG_ON(apic->isr_count > MAX_APIC_VECTOR);
  697. + /*
  698. + * ISR (in service register) bit is set when injecting an interrupt.
  699. + * The highest vector is injected. Thus the latest bit set matches
  700. + * the highest bit in ISR.
  701. + */
  702. + apic->highest_isr_cache = vec;
  703. + }
  704. }
  705. static inline int apic_find_highest_isr(struct kvm_lapic *apic)
  706. @@ -1627,11 +1648,16 @@ int kvm_get_apic_interrupt(struct kvm_vcpu *vcpu)
  707. int vector = kvm_apic_has_interrupt(vcpu);
  708. struct kvm_lapic *apic = vcpu->arch.apic;
  709. - /* Note that we never get here with APIC virtualization enabled. */
  710. -
  711. if (vector == -1)
  712. return -1;
  713. + /*
  714. + * We get here even with APIC virtualization enabled, if doing
  715. + * nested virtualization and L1 runs with the "acknowledge interrupt
  716. + * on exit" mode. Then we cannot inject the interrupt via RVI,
  717. + * because the process would deliver it through the IDT.
  718. + */
  719. +
  720. apic_set_isr(vector, apic);
  721. apic_update_ppr(apic);
  722. apic_clear_irr(vector, apic);
  723. diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
  724. index a19ed92e74e4..2ae525e0d8ba 100644
  725. --- a/arch/x86/pci/i386.c
  726. +++ b/arch/x86/pci/i386.c
  727. @@ -162,6 +162,10 @@ pcibios_align_resource(void *data, const struct resource *res,
  728. return start;
  729. if (start & 0x300)
  730. start = (start + 0x3ff) & ~0x3ff;
  731. + } else if (res->flags & IORESOURCE_MEM) {
  732. + /* The low 1MB range is reserved for ISA cards */
  733. + if (start < BIOS_END)
  734. + start = BIOS_END;
  735. }
  736. return start;
  737. }
  738. diff --git a/arch/x86/xen/grant-table.c b/arch/x86/xen/grant-table.c
  739. index ebfa9b2c871d..767c9cbb869f 100644
  740. --- a/arch/x86/xen/grant-table.c
  741. +++ b/arch/x86/xen/grant-table.c
  742. @@ -168,6 +168,7 @@ static int __init xlated_setup_gnttab_pages(void)
  743. {
  744. struct page **pages;
  745. xen_pfn_t *pfns;
  746. + void *vaddr;
  747. int rc;
  748. unsigned int i;
  749. unsigned long nr_grant_frames = gnttab_max_grant_frames();
  750. @@ -193,21 +194,20 @@ static int __init xlated_setup_gnttab_pages(void)
  751. for (i = 0; i < nr_grant_frames; i++)
  752. pfns[i] = page_to_pfn(pages[i]);
  753. - rc = arch_gnttab_map_shared(pfns, nr_grant_frames, nr_grant_frames,
  754. - &xen_auto_xlat_grant_frames.vaddr);
  755. -
  756. - if (rc) {
  757. + vaddr = vmap(pages, nr_grant_frames, 0, PAGE_KERNEL);
  758. + if (!vaddr) {
  759. pr_warn("%s Couldn't map %ld pfns rc:%d\n", __func__,
  760. nr_grant_frames, rc);
  761. free_xenballooned_pages(nr_grant_frames, pages);
  762. kfree(pages);
  763. kfree(pfns);
  764. - return rc;
  765. + return -ENOMEM;
  766. }
  767. kfree(pages);
  768. xen_auto_xlat_grant_frames.pfn = pfns;
  769. xen_auto_xlat_grant_frames.count = nr_grant_frames;
  770. + xen_auto_xlat_grant_frames.vaddr = vaddr;
  771. return 0;
  772. }
  773. diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
  774. index 7b78f88c1707..5718b0b58b60 100644
  775. --- a/arch/x86/xen/time.c
  776. +++ b/arch/x86/xen/time.c
  777. @@ -444,7 +444,7 @@ void xen_setup_timer(int cpu)
  778. irq = bind_virq_to_irqhandler(VIRQ_TIMER, cpu, xen_timer_interrupt,
  779. IRQF_PERCPU|IRQF_NOBALANCING|IRQF_TIMER|
  780. - IRQF_FORCE_RESUME,
  781. + IRQF_FORCE_RESUME|IRQF_EARLY_RESUME,
  782. name, NULL);
  783. (void)xen_set_irq_priority(irq, XEN_IRQ_PRIORITY_MAX);
  784. diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c b/drivers/char/tpm/tpm_i2c_stm_st33.c
  785. index 3b7bf2162898..4669e3713428 100644
  786. --- a/drivers/char/tpm/tpm_i2c_stm_st33.c
  787. +++ b/drivers/char/tpm/tpm_i2c_stm_st33.c
  788. @@ -714,6 +714,7 @@ tpm_st33_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
  789. }
  790. tpm_get_timeouts(chip);
  791. + tpm_do_selftest(chip);
  792. dev_info(chip->dev, "TPM I2C Initialized\n");
  793. return 0;
  794. diff --git a/drivers/crypto/ux500/cryp/cryp_core.c b/drivers/crypto/ux500/cryp/cryp_core.c
  795. index a999f537228f..92105f3dc8e0 100644
  796. --- a/drivers/crypto/ux500/cryp/cryp_core.c
  797. +++ b/drivers/crypto/ux500/cryp/cryp_core.c
  798. @@ -190,7 +190,7 @@ static void add_session_id(struct cryp_ctx *ctx)
  799. static irqreturn_t cryp_interrupt_handler(int irq, void *param)
  800. {
  801. struct cryp_ctx *ctx;
  802. - int i;
  803. + int count;
  804. struct cryp_device_data *device_data;
  805. if (param == NULL) {
  806. @@ -215,12 +215,11 @@ static irqreturn_t cryp_interrupt_handler(int irq, void *param)
  807. if (cryp_pending_irq_src(device_data,
  808. CRYP_IRQ_SRC_OUTPUT_FIFO)) {
  809. if (ctx->outlen / ctx->blocksize > 0) {
  810. - for (i = 0; i < ctx->blocksize / 4; i++) {
  811. - *(ctx->outdata) = readl_relaxed(
  812. - &device_data->base->dout);
  813. - ctx->outdata += 4;
  814. - ctx->outlen -= 4;
  815. - }
  816. + count = ctx->blocksize / 4;
  817. +
  818. + readsl(&device_data->base->dout, ctx->outdata, count);
  819. + ctx->outdata += count;
  820. + ctx->outlen -= count;
  821. if (ctx->outlen == 0) {
  822. cryp_disable_irq_src(device_data,
  823. @@ -230,12 +229,12 @@ static irqreturn_t cryp_interrupt_handler(int irq, void *param)
  824. } else if (cryp_pending_irq_src(device_data,
  825. CRYP_IRQ_SRC_INPUT_FIFO)) {
  826. if (ctx->datalen / ctx->blocksize > 0) {
  827. - for (i = 0 ; i < ctx->blocksize / 4; i++) {
  828. - writel_relaxed(ctx->indata,
  829. - &device_data->base->din);
  830. - ctx->indata += 4;
  831. - ctx->datalen -= 4;
  832. - }
  833. + count = ctx->blocksize / 4;
  834. +
  835. + writesl(&device_data->base->din, ctx->indata, count);
  836. +
  837. + ctx->indata += count;
  838. + ctx->datalen -= count;
  839. if (ctx->datalen == 0)
  840. cryp_disable_irq_src(device_data,
  841. diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
  842. index f926b4caf449..56c60552abba 100644
  843. --- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
  844. +++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
  845. @@ -199,7 +199,7 @@ static struct dmm_txn *dmm_txn_init(struct dmm *dmm, struct tcm *tcm)
  846. static void dmm_txn_append(struct dmm_txn *txn, struct pat_area *area,
  847. struct page **pages, uint32_t npages, uint32_t roll)
  848. {
  849. - dma_addr_t pat_pa = 0;
  850. + dma_addr_t pat_pa = 0, data_pa = 0;
  851. uint32_t *data;
  852. struct pat *pat;
  853. struct refill_engine *engine = txn->engine_handle;
  854. @@ -223,7 +223,9 @@ static void dmm_txn_append(struct dmm_txn *txn, struct pat_area *area,
  855. .lut_id = engine->tcm->lut_id,
  856. };
  857. - data = alloc_dma(txn, 4*i, &pat->data_pa);
  858. + data = alloc_dma(txn, 4*i, &data_pa);
  859. + /* FIXME: what if data_pa is more than 32-bit ? */
  860. + pat->data_pa = data_pa;
  861. while (i--) {
  862. int n = i + roll;
  863. diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
  864. index 95dbce286a41..d9f5e5241af4 100644
  865. --- a/drivers/gpu/drm/omapdrm/omap_gem.c
  866. +++ b/drivers/gpu/drm/omapdrm/omap_gem.c
  867. @@ -791,7 +791,7 @@ int omap_gem_get_paddr(struct drm_gem_object *obj,
  868. omap_obj->paddr = tiler_ssptr(block);
  869. omap_obj->block = block;
  870. - DBG("got paddr: %08x", omap_obj->paddr);
  871. + DBG("got paddr: %pad", &omap_obj->paddr);
  872. }
  873. omap_obj->paddr_cnt++;
  874. @@ -985,9 +985,9 @@ void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m)
  875. off = drm_vma_node_start(&obj->vma_node);
  876. - seq_printf(m, "%08x: %2d (%2d) %08llx %08Zx (%2d) %p %4d",
  877. + seq_printf(m, "%08x: %2d (%2d) %08llx %pad (%2d) %p %4d",
  878. omap_obj->flags, obj->name, obj->refcount.refcount.counter,
  879. - off, omap_obj->paddr, omap_obj->paddr_cnt,
  880. + off, &omap_obj->paddr, omap_obj->paddr_cnt,
  881. omap_obj->vaddr, omap_obj->roll);
  882. if (omap_obj->flags & OMAP_BO_TILED) {
  883. @@ -1467,8 +1467,8 @@ void omap_gem_init(struct drm_device *dev)
  884. entry->paddr = tiler_ssptr(block);
  885. entry->block = block;
  886. - DBG("%d:%d: %dx%d: paddr=%08x stride=%d", i, j, w, h,
  887. - entry->paddr,
  888. + DBG("%d:%d: %dx%d: paddr=%pad stride=%d", i, j, w, h,
  889. + &entry->paddr,
  890. usergart[i].stride_pfn << PAGE_SHIFT);
  891. }
  892. }
  893. diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c
  894. index 3cf31ee59aac..6af3398b5278 100644
  895. --- a/drivers/gpu/drm/omapdrm/omap_plane.c
  896. +++ b/drivers/gpu/drm/omapdrm/omap_plane.c
  897. @@ -142,8 +142,8 @@ static void omap_plane_pre_apply(struct omap_drm_apply *apply)
  898. DBG("%dx%d -> %dx%d (%d)", info->width, info->height,
  899. info->out_width, info->out_height,
  900. info->screen_width);
  901. - DBG("%d,%d %08x %08x", info->pos_x, info->pos_y,
  902. - info->paddr, info->p_uv_addr);
  903. + DBG("%d,%d %pad %pad", info->pos_x, info->pos_y,
  904. + &info->paddr, &info->p_uv_addr);
  905. /* TODO: */
  906. ilace = false;
  907. diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
  908. index c0ea66192fe0..767f2cc44bd8 100644
  909. --- a/drivers/gpu/drm/radeon/cik.c
  910. +++ b/drivers/gpu/drm/radeon/cik.c
  911. @@ -3320,6 +3320,7 @@ static void cik_gpu_init(struct radeon_device *rdev)
  912. (rdev->pdev->device == 0x130B) ||
  913. (rdev->pdev->device == 0x130E) ||
  914. (rdev->pdev->device == 0x1315) ||
  915. + (rdev->pdev->device == 0x1318) ||
  916. (rdev->pdev->device == 0x131B)) {
  917. rdev->config.cik.max_cu_per_sh = 4;
  918. rdev->config.cik.max_backends_per_se = 1;
  919. diff --git a/drivers/hid/hid-cherry.c b/drivers/hid/hid-cherry.c
  920. index 1bdcccc54a1d..f745d2c1325e 100644
  921. --- a/drivers/hid/hid-cherry.c
  922. +++ b/drivers/hid/hid-cherry.c
  923. @@ -28,7 +28,7 @@
  924. static __u8 *ch_report_fixup(struct hid_device *hdev, __u8 *rdesc,
  925. unsigned int *rsize)
  926. {
  927. - if (*rsize >= 17 && rdesc[11] == 0x3c && rdesc[12] == 0x02) {
  928. + if (*rsize >= 18 && rdesc[11] == 0x3c && rdesc[12] == 0x02) {
  929. hid_info(hdev, "fixing up Cherry Cymotion report descriptor\n");
  930. rdesc[11] = rdesc[16] = 0xff;
  931. rdesc[12] = rdesc[17] = 0x03;
  932. diff --git a/drivers/hid/hid-kye.c b/drivers/hid/hid-kye.c
  933. index e77696367591..b92bf01a1ae8 100644
  934. --- a/drivers/hid/hid-kye.c
  935. +++ b/drivers/hid/hid-kye.c
  936. @@ -300,7 +300,7 @@ static __u8 *kye_report_fixup(struct hid_device *hdev, __u8 *rdesc,
  937. * - change the button usage range to 4-7 for the extra
  938. * buttons
  939. */
  940. - if (*rsize >= 74 &&
  941. + if (*rsize >= 75 &&
  942. rdesc[61] == 0x05 && rdesc[62] == 0x08 &&
  943. rdesc[63] == 0x19 && rdesc[64] == 0x08 &&
  944. rdesc[65] == 0x29 && rdesc[66] == 0x0f &&
  945. diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c
  946. index a976f48263f6..f91ff145db9a 100644
  947. --- a/drivers/hid/hid-lg.c
  948. +++ b/drivers/hid/hid-lg.c
  949. @@ -345,14 +345,14 @@ static __u8 *lg_report_fixup(struct hid_device *hdev, __u8 *rdesc,
  950. struct usb_device_descriptor *udesc;
  951. __u16 bcdDevice, rev_maj, rev_min;
  952. - if ((drv_data->quirks & LG_RDESC) && *rsize >= 90 && rdesc[83] == 0x26 &&
  953. + if ((drv_data->quirks & LG_RDESC) && *rsize >= 91 && rdesc[83] == 0x26 &&
  954. rdesc[84] == 0x8c && rdesc[85] == 0x02) {
  955. hid_info(hdev,
  956. "fixing up Logitech keyboard report descriptor\n");
  957. rdesc[84] = rdesc[89] = 0x4d;
  958. rdesc[85] = rdesc[90] = 0x10;
  959. }
  960. - if ((drv_data->quirks & LG_RDESC_REL_ABS) && *rsize >= 50 &&
  961. + if ((drv_data->quirks & LG_RDESC_REL_ABS) && *rsize >= 51 &&
  962. rdesc[32] == 0x81 && rdesc[33] == 0x06 &&
  963. rdesc[49] == 0x81 && rdesc[50] == 0x06) {
  964. hid_info(hdev,
  965. diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
  966. index 486dbde2ba2d..b7ba82960c79 100644
  967. --- a/drivers/hid/hid-logitech-dj.c
  968. +++ b/drivers/hid/hid-logitech-dj.c
  969. @@ -238,13 +238,6 @@ static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev,
  970. return;
  971. }
  972. - if ((dj_report->device_index < DJ_DEVICE_INDEX_MIN) ||
  973. - (dj_report->device_index > DJ_DEVICE_INDEX_MAX)) {
  974. - dev_err(&djrcv_hdev->dev, "%s: invalid device index:%d\n",
  975. - __func__, dj_report->device_index);
  976. - return;
  977. - }
  978. -
  979. if (djrcv_dev->paired_dj_devices[dj_report->device_index]) {
  980. /* The device is already known. No need to reallocate it. */
  981. dbg_hid("%s: device is already known\n", __func__);
  982. @@ -557,7 +550,7 @@ static int logi_dj_ll_raw_request(struct hid_device *hid,
  983. if (!out_buf)
  984. return -ENOMEM;
  985. - if (count < DJREPORT_SHORT_LENGTH - 2)
  986. + if (count > DJREPORT_SHORT_LENGTH - 2)
  987. count = DJREPORT_SHORT_LENGTH - 2;
  988. out_buf[0] = REPORT_ID_DJ_SHORT;
  989. @@ -690,6 +683,12 @@ static int logi_dj_raw_event(struct hid_device *hdev,
  990. * device (via hid_input_report() ) and return 1 so hid-core does not do
  991. * anything else with it.
  992. */
  993. + if ((dj_report->device_index < DJ_DEVICE_INDEX_MIN) ||
  994. + (dj_report->device_index > DJ_DEVICE_INDEX_MAX)) {
  995. + dev_err(&hdev->dev, "%s: invalid device index:%d\n",
  996. + __func__, dj_report->device_index);
  997. + return false;
  998. + }
  999. spin_lock_irqsave(&djrcv_dev->lock, flags);
  1000. if (dj_report->report_id == REPORT_ID_DJ_SHORT) {
  1001. diff --git a/drivers/hid/hid-monterey.c b/drivers/hid/hid-monterey.c
  1002. index 9e14c00eb1b6..25daf28b26bd 100644
  1003. --- a/drivers/hid/hid-monterey.c
  1004. +++ b/drivers/hid/hid-monterey.c
  1005. @@ -24,7 +24,7 @@
  1006. static __u8 *mr_report_fixup(struct hid_device *hdev, __u8 *rdesc,
  1007. unsigned int *rsize)
  1008. {
  1009. - if (*rsize >= 30 && rdesc[29] == 0x05 && rdesc[30] == 0x09) {
  1010. + if (*rsize >= 31 && rdesc[29] == 0x05 && rdesc[30] == 0x09) {
  1011. hid_info(hdev, "fixing up button/consumer in HID report descriptor\n");
  1012. rdesc[30] = 0x0c;
  1013. }
  1014. diff --git a/drivers/hid/hid-petalynx.c b/drivers/hid/hid-petalynx.c
  1015. index 736b2502df4f..6aca4f2554bf 100644
  1016. --- a/drivers/hid/hid-petalynx.c
  1017. +++ b/drivers/hid/hid-petalynx.c
  1018. @@ -25,7 +25,7 @@
  1019. static __u8 *pl_report_fixup(struct hid_device *hdev, __u8 *rdesc,
  1020. unsigned int *rsize)
  1021. {
  1022. - if (*rsize >= 60 && rdesc[39] == 0x2a && rdesc[40] == 0xf5 &&
  1023. + if (*rsize >= 62 && rdesc[39] == 0x2a && rdesc[40] == 0xf5 &&
  1024. rdesc[41] == 0x00 && rdesc[59] == 0x26 &&
  1025. rdesc[60] == 0xf9 && rdesc[61] == 0x00) {
  1026. hid_info(hdev, "fixing up Petalynx Maxter Remote report descriptor\n");
  1027. diff --git a/drivers/hid/hid-sunplus.c b/drivers/hid/hid-sunplus.c
  1028. index 87fc91e1c8de..91072fa54663 100644
  1029. --- a/drivers/hid/hid-sunplus.c
  1030. +++ b/drivers/hid/hid-sunplus.c
  1031. @@ -24,7 +24,7 @@
  1032. static __u8 *sp_report_fixup(struct hid_device *hdev, __u8 *rdesc,
  1033. unsigned int *rsize)
  1034. {
  1035. - if (*rsize >= 107 && rdesc[104] == 0x26 && rdesc[105] == 0x80 &&
  1036. + if (*rsize >= 112 && rdesc[104] == 0x26 && rdesc[105] == 0x80 &&
  1037. rdesc[106] == 0x03) {
  1038. hid_info(hdev, "fixing up Sunplus Wireless Desktop report descriptor\n");
  1039. rdesc[105] = rdesc[110] = 0x03;
  1040. diff --git a/drivers/hwmon/ads1015.c b/drivers/hwmon/ads1015.c
  1041. index 7f9dc2f86b63..126516414c11 100644
  1042. --- a/drivers/hwmon/ads1015.c
  1043. +++ b/drivers/hwmon/ads1015.c
  1044. @@ -198,7 +198,7 @@ static int ads1015_get_channels_config_of(struct i2c_client *client)
  1045. }
  1046. channel = be32_to_cpup(property);
  1047. - if (channel > ADS1015_CHANNELS) {
  1048. + if (channel >= ADS1015_CHANNELS) {
  1049. dev_err(&client->dev,
  1050. "invalid channel index %d on %s\n",
  1051. channel, node->full_name);
  1052. @@ -212,6 +212,7 @@ static int ads1015_get_channels_config_of(struct i2c_client *client)
  1053. dev_err(&client->dev,
  1054. "invalid gain on %s\n",
  1055. node->full_name);
  1056. + return -EINVAL;
  1057. }
  1058. }
  1059. @@ -222,6 +223,7 @@ static int ads1015_get_channels_config_of(struct i2c_client *client)
  1060. dev_err(&client->dev,
  1061. "invalid data_rate on %s\n",
  1062. node->full_name);
  1063. + return -EINVAL;
  1064. }
  1065. }
  1066. diff --git a/drivers/hwmon/amc6821.c b/drivers/hwmon/amc6821.c
  1067. index 9f2be3dd28f3..8a67ec6279a4 100644
  1068. --- a/drivers/hwmon/amc6821.c
  1069. +++ b/drivers/hwmon/amc6821.c
  1070. @@ -360,11 +360,13 @@ static ssize_t set_pwm1_enable(
  1071. if (config)
  1072. return config;
  1073. + mutex_lock(&data->update_lock);
  1074. config = i2c_smbus_read_byte_data(client, AMC6821_REG_CONF1);
  1075. if (config < 0) {
  1076. dev_err(&client->dev,
  1077. "Error reading configuration register, aborting.\n");
  1078. - return config;
  1079. + count = config;
  1080. + goto unlock;
  1081. }
  1082. switch (val) {
  1083. @@ -381,14 +383,15 @@ static ssize_t set_pwm1_enable(
  1084. config |= AMC6821_CONF1_FDRC1;
  1085. break;
  1086. default:
  1087. - return -EINVAL;
  1088. + count = -EINVAL;
  1089. + goto unlock;
  1090. }
  1091. - mutex_lock(&data->update_lock);
  1092. if (i2c_smbus_write_byte_data(client, AMC6821_REG_CONF1, config)) {
  1093. dev_err(&client->dev,
  1094. "Configuration register write error, aborting.\n");
  1095. count = -EIO;
  1096. }
  1097. +unlock:
  1098. mutex_unlock(&data->update_lock);
  1099. return count;
  1100. }
  1101. @@ -493,8 +496,9 @@ static ssize_t set_temp_auto_point_temp(
  1102. return -EINVAL;
  1103. }
  1104. - data->valid = 0;
  1105. mutex_lock(&data->update_lock);
  1106. + data->valid = 0;
  1107. +
  1108. switch (ix) {
  1109. case 0:
  1110. ptemp[0] = clamp_val(val / 1000, 0,
  1111. @@ -658,13 +662,14 @@ static ssize_t set_fan1_div(
  1112. if (config)
  1113. return config;
  1114. + mutex_lock(&data->update_lock);
  1115. config = i2c_smbus_read_byte_data(client, AMC6821_REG_CONF4);
  1116. if (config < 0) {
  1117. dev_err(&client->dev,
  1118. "Error reading configuration register, aborting.\n");
  1119. - return config;
  1120. + count = config;
  1121. + goto EXIT;
  1122. }
  1123. - mutex_lock(&data->update_lock);
  1124. switch (val) {
  1125. case 2:
  1126. config &= ~AMC6821_CONF4_PSPR;
  1127. diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c
  1128. index 4ae3fff13f44..bea0a344fab5 100644
  1129. --- a/drivers/hwmon/dme1737.c
  1130. +++ b/drivers/hwmon/dme1737.c
  1131. @@ -247,8 +247,8 @@ struct dme1737_data {
  1132. u8 pwm_acz[3];
  1133. u8 pwm_freq[6];
  1134. u8 pwm_rr[2];
  1135. - u8 zone_low[3];
  1136. - u8 zone_abs[3];
  1137. + s8 zone_low[3];
  1138. + s8 zone_abs[3];
  1139. u8 zone_hyst[2];
  1140. u32 alarms;
  1141. };
  1142. @@ -277,7 +277,7 @@ static inline int IN_FROM_REG(int reg, int nominal, int res)
  1143. return (reg * nominal + (3 << (res - 3))) / (3 << (res - 2));
  1144. }
  1145. -static inline int IN_TO_REG(int val, int nominal)
  1146. +static inline int IN_TO_REG(long val, int nominal)
  1147. {
  1148. return clamp_val((val * 192 + nominal / 2) / nominal, 0, 255);
  1149. }
  1150. @@ -293,7 +293,7 @@ static inline int TEMP_FROM_REG(int reg, int res)
  1151. return (reg * 1000) >> (res - 8);
  1152. }
  1153. -static inline int TEMP_TO_REG(int val)
  1154. +static inline int TEMP_TO_REG(long val)
  1155. {
  1156. return clamp_val((val < 0 ? val - 500 : val + 500) / 1000, -128, 127);
  1157. }
  1158. @@ -308,7 +308,7 @@ static inline int TEMP_RANGE_FROM_REG(int reg)
  1159. return TEMP_RANGE[(reg >> 4) & 0x0f];
  1160. }
  1161. -static int TEMP_RANGE_TO_REG(int val, int reg)
  1162. +static int TEMP_RANGE_TO_REG(long val, int reg)
  1163. {
  1164. int i;
  1165. @@ -331,7 +331,7 @@ static inline int TEMP_HYST_FROM_REG(int reg, int ix)
  1166. return (((ix == 1) ? reg : reg >> 4) & 0x0f) * 1000;
  1167. }
  1168. -static inline int TEMP_HYST_TO_REG(int val, int ix, int reg)
  1169. +static inline int TEMP_HYST_TO_REG(long val, int ix, int reg)
  1170. {
  1171. int hyst = clamp_val((val + 500) / 1000, 0, 15);
  1172. @@ -347,7 +347,7 @@ static inline int FAN_FROM_REG(int reg, int tpc)
  1173. return (reg == 0 || reg == 0xffff) ? 0 : 90000 * 60 / reg;
  1174. }
  1175. -static inline int FAN_TO_REG(int val, int tpc)
  1176. +static inline int FAN_TO_REG(long val, int tpc)
  1177. {
  1178. if (tpc) {
  1179. return clamp_val(val / tpc, 0, 0xffff);
  1180. @@ -379,7 +379,7 @@ static inline int FAN_TYPE_FROM_REG(int reg)
  1181. return (edge > 0) ? 1 << (edge - 1) : 0;
  1182. }
  1183. -static inline int FAN_TYPE_TO_REG(int val, int reg)
  1184. +static inline int FAN_TYPE_TO_REG(long val, int reg)
  1185. {
  1186. int edge = (val == 4) ? 3 : val;
  1187. @@ -402,7 +402,7 @@ static int FAN_MAX_FROM_REG(int reg)
  1188. return 1000 + i * 500;
  1189. }
  1190. -static int FAN_MAX_TO_REG(int val)
  1191. +static int FAN_MAX_TO_REG(long val)
  1192. {
  1193. int i;
  1194. @@ -460,7 +460,7 @@ static inline int PWM_ACZ_FROM_REG(int reg)
  1195. return acz[(reg >> 5) & 0x07];
  1196. }
  1197. -static inline int PWM_ACZ_TO_REG(int val, int reg)
  1198. +static inline int PWM_ACZ_TO_REG(long val, int reg)
  1199. {
  1200. int acz = (val == 4) ? 2 : val - 1;
  1201. @@ -476,7 +476,7 @@ static inline int PWM_FREQ_FROM_REG(int reg)
  1202. return PWM_FREQ[reg & 0x0f];
  1203. }
  1204. -static int PWM_FREQ_TO_REG(int val, int reg)
  1205. +static int PWM_FREQ_TO_REG(long val, int reg)
  1206. {
  1207. int i;
  1208. @@ -510,7 +510,7 @@ static inline int PWM_RR_FROM_REG(int reg, int ix)
  1209. return (rr & 0x08) ? PWM_RR[rr & 0x07] : 0;
  1210. }
  1211. -static int PWM_RR_TO_REG(int val, int ix, int reg)
  1212. +static int PWM_RR_TO_REG(long val, int ix, int reg)
  1213. {
  1214. int i;
  1215. @@ -528,7 +528,7 @@ static inline int PWM_RR_EN_FROM_REG(int reg, int ix)
  1216. return PWM_RR_FROM_REG(reg, ix) ? 1 : 0;
  1217. }
  1218. -static inline int PWM_RR_EN_TO_REG(int val, int ix, int reg)
  1219. +static inline int PWM_RR_EN_TO_REG(long val, int ix, int reg)
  1220. {
  1221. int en = (ix == 1) ? 0x80 : 0x08;
  1222. @@ -1481,13 +1481,16 @@ static ssize_t set_vrm(struct device *dev, struct device_attribute *attr,
  1223. const char *buf, size_t count)
  1224. {
  1225. struct dme1737_data *data = dev_get_drvdata(dev);
  1226. - long val;
  1227. + unsigned long val;
  1228. int err;
  1229. - err = kstrtol(buf, 10, &val);
  1230. + err = kstrtoul(buf, 10, &val);
  1231. if (err)
  1232. return err;
  1233. + if (val > 255)
  1234. + return -EINVAL;
  1235. +
  1236. data->vrm = val;
  1237. return count;
  1238. }
  1239. diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c
  1240. index 2566c43dd1e9..d10aa7b46cca 100644
  1241. --- a/drivers/hwmon/gpio-fan.c
  1242. +++ b/drivers/hwmon/gpio-fan.c
  1243. @@ -173,7 +173,7 @@ static int get_fan_speed_index(struct gpio_fan_data *fan_data)
  1244. return -ENODEV;
  1245. }
  1246. -static int rpm_to_speed_index(struct gpio_fan_data *fan_data, int rpm)
  1247. +static int rpm_to_speed_index(struct gpio_fan_data *fan_data, unsigned long rpm)
  1248. {
  1249. struct gpio_fan_speed *speed = fan_data->speed;
  1250. int i;
  1251. diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
  1252. index 9efadfc851bc..c1eb464f0fd0 100644
  1253. --- a/drivers/hwmon/lm78.c
  1254. +++ b/drivers/hwmon/lm78.c
  1255. @@ -108,7 +108,7 @@ static inline int FAN_FROM_REG(u8 val, int div)
  1256. * TEMP: mC (-128C to +127C)
  1257. * REG: 1C/bit, two's complement
  1258. */
  1259. -static inline s8 TEMP_TO_REG(int val)
  1260. +static inline s8 TEMP_TO_REG(long val)
  1261. {
  1262. int nval = clamp_val(val, -128000, 127000) ;
  1263. return nval < 0 ? (nval - 500) / 1000 : (nval + 500) / 1000;
  1264. diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
  1265. index b0129a54e1a6..ef627ea71cc8 100644
  1266. --- a/drivers/hwmon/lm85.c
  1267. +++ b/drivers/hwmon/lm85.c
  1268. @@ -155,7 +155,7 @@ static inline u16 FAN_TO_REG(unsigned long val)
  1269. /* Temperature is reported in .001 degC increments */
  1270. #define TEMP_TO_REG(val) \
  1271. - clamp_val(SCALE(val, 1000, 1), -127, 127)
  1272. + DIV_ROUND_CLOSEST(clamp_val((val), -127000, 127000), 1000)
  1273. #define TEMPEXT_FROM_REG(val, ext) \
  1274. SCALE(((val) << 4) + (ext), 16, 1000)
  1275. #define TEMP_FROM_REG(val) ((val) * 1000)
  1276. @@ -189,7 +189,7 @@ static const int lm85_range_map[] = {
  1277. 13300, 16000, 20000, 26600, 32000, 40000, 53300, 80000
  1278. };
  1279. -static int RANGE_TO_REG(int range)
  1280. +static int RANGE_TO_REG(long range)
  1281. {
  1282. int i;
  1283. @@ -211,7 +211,7 @@ static const int adm1027_freq_map[8] = { /* 1 Hz */
  1284. 11, 15, 22, 29, 35, 44, 59, 88
  1285. };
  1286. -static int FREQ_TO_REG(const int *map, int freq)
  1287. +static int FREQ_TO_REG(const int *map, unsigned long freq)
  1288. {
  1289. int i;
  1290. @@ -460,6 +460,9 @@ static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr,
  1291. if (err)
  1292. return err;
  1293. + if (val > 255)
  1294. + return -EINVAL;
  1295. +
  1296. data->vrm = val;
  1297. return count;
  1298. }
  1299. diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c
  1300. index d2060e245ff5..cfaf70b9cba7 100644
  1301. --- a/drivers/hwmon/lm92.c
  1302. +++ b/drivers/hwmon/lm92.c
  1303. @@ -74,12 +74,9 @@ static inline int TEMP_FROM_REG(s16 reg)
  1304. return reg / 8 * 625 / 10;
  1305. }
  1306. -static inline s16 TEMP_TO_REG(int val)
  1307. +static inline s16 TEMP_TO_REG(long val)
  1308. {
  1309. - if (val <= -60000)
  1310. - return -60000 * 10 / 625 * 8;
  1311. - if (val >= 160000)
  1312. - return 160000 * 10 / 625 * 8;
  1313. + val = clamp_val(val, -60000, 160000);
  1314. return val * 10 / 625 * 8;
  1315. }
  1316. @@ -206,10 +203,12 @@ static ssize_t set_temp_hyst(struct device *dev,
  1317. if (err)
  1318. return err;
  1319. + val = clamp_val(val, -120000, 220000);
  1320. mutex_lock(&data->update_lock);
  1321. - data->temp[t_hyst] = TEMP_FROM_REG(data->temp[attr->index]) - val;
  1322. + data->temp[t_hyst] =
  1323. + TEMP_TO_REG(TEMP_FROM_REG(data->temp[attr->index]) - val);
  1324. i2c_smbus_write_word_swapped(client, LM92_REG_TEMP_HYST,
  1325. - TEMP_TO_REG(data->temp[t_hyst]));
  1326. + data->temp[t_hyst]);
  1327. mutex_unlock(&data->update_lock);
  1328. return count;
  1329. }
  1330. diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
  1331. index 3532026e25da..bf1d7893d51c 100644
  1332. --- a/drivers/hwmon/sis5595.c
  1333. +++ b/drivers/hwmon/sis5595.c
  1334. @@ -159,7 +159,7 @@ static inline int TEMP_FROM_REG(s8 val)
  1335. {
  1336. return val * 830 + 52120;
  1337. }
  1338. -static inline s8 TEMP_TO_REG(int val)
  1339. +static inline s8 TEMP_TO_REG(long val)
  1340. {
  1341. int nval = clamp_val(val, -54120, 157530) ;
  1342. return nval < 0 ? (nval - 5212 - 415) / 830 : (nval - 5212 + 415) / 830;
  1343. diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
  1344. index e95f9ba96790..83c989382be9 100644
  1345. --- a/drivers/i2c/busses/i2c-at91.c
  1346. +++ b/drivers/i2c/busses/i2c-at91.c
  1347. @@ -210,7 +210,7 @@ static void at91_twi_write_data_dma_callback(void *data)
  1348. struct at91_twi_dev *dev = (struct at91_twi_dev *)data;
  1349. dma_unmap_single(dev->dev, sg_dma_address(&dev->dma.sg),
  1350. - dev->buf_len, DMA_MEM_TO_DEV);
  1351. + dev->buf_len, DMA_TO_DEVICE);
  1352. at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_STOP);
  1353. }
  1354. @@ -289,7 +289,7 @@ static void at91_twi_read_data_dma_callback(void *data)
  1355. struct at91_twi_dev *dev = (struct at91_twi_dev *)data;
  1356. dma_unmap_single(dev->dev, sg_dma_address(&dev->dma.sg),
  1357. - dev->buf_len, DMA_DEV_TO_MEM);
  1358. + dev->buf_len, DMA_FROM_DEVICE);
  1359. /* The last two bytes have to be read without using dma */
  1360. dev->buf += dev->buf_len - 2;
  1361. diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c
  1362. index a9791509966a..69e11853e8bf 100644
  1363. --- a/drivers/i2c/busses/i2c-rk3x.c
  1364. +++ b/drivers/i2c/busses/i2c-rk3x.c
  1365. @@ -399,7 +399,7 @@ static irqreturn_t rk3x_i2c_irq(int irqno, void *dev_id)
  1366. }
  1367. /* is there anything left to handle? */
  1368. - if (unlikely(ipd == 0))
  1369. + if (unlikely((ipd & REG_INT_ALL) == 0))
  1370. goto out;
  1371. switch (i2c->state) {
  1372. diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
  1373. index 59d20c599b16..2da05c0e113d 100644
  1374. --- a/drivers/misc/mei/client.c
  1375. +++ b/drivers/misc/mei/client.c
  1376. @@ -459,7 +459,7 @@ int mei_cl_disconnect(struct mei_cl *cl)
  1377. {
  1378. struct mei_device *dev;
  1379. struct mei_cl_cb *cb;
  1380. - int rets, err;
  1381. + int rets;
  1382. if (WARN_ON(!cl || !cl->dev))
  1383. return -ENODEV;
  1384. @@ -491,6 +491,7 @@ int mei_cl_disconnect(struct mei_cl *cl)
  1385. cl_err(dev, cl, "failed to disconnect.\n");
  1386. goto free;
  1387. }
  1388. + cl->timer_count = MEI_CONNECT_TIMEOUT;
  1389. mdelay(10); /* Wait for hardware disconnection ready */
  1390. list_add_tail(&cb->list, &dev->ctrl_rd_list.list);
  1391. } else {
  1392. @@ -500,23 +501,18 @@ int mei_cl_disconnect(struct mei_cl *cl)
  1393. }
  1394. mutex_unlock(&dev->device_lock);
  1395. - err = wait_event_timeout(dev->wait_recvd_msg,
  1396. + wait_event_timeout(dev->wait_recvd_msg,
  1397. MEI_FILE_DISCONNECTED == cl->state,
  1398. mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT));
  1399. mutex_lock(&dev->device_lock);
  1400. +
  1401. if (MEI_FILE_DISCONNECTED == cl->state) {
  1402. rets = 0;
  1403. cl_dbg(dev, cl, "successfully disconnected from FW client.\n");
  1404. } else {
  1405. - rets = -ENODEV;
  1406. - if (MEI_FILE_DISCONNECTED != cl->state)
  1407. - cl_err(dev, cl, "wrong status client disconnect.\n");
  1408. -
  1409. - if (err)
  1410. - cl_dbg(dev, cl, "wait failed disconnect err=%d\n", err);
  1411. -
  1412. - cl_err(dev, cl, "failed to disconnect from FW client.\n");
  1413. + cl_dbg(dev, cl, "timeout on disconnect from FW client.\n");
  1414. + rets = -ETIME;
  1415. }
  1416. mei_io_list_flush(&dev->ctrl_rd_list, cl);
  1417. @@ -605,6 +601,7 @@ int mei_cl_connect(struct mei_cl *cl, struct file *file)
  1418. cl->timer_count = MEI_CONNECT_TIMEOUT;
  1419. list_add_tail(&cb->list, &dev->ctrl_rd_list.list);
  1420. } else {
  1421. + cl->state = MEI_FILE_INITIALIZING;
  1422. list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
  1423. }
  1424. @@ -616,6 +613,7 @@ int mei_cl_connect(struct mei_cl *cl, struct file *file)
  1425. mutex_lock(&dev->device_lock);
  1426. if (cl->state != MEI_FILE_CONNECTED) {
  1427. + cl->state = MEI_FILE_DISCONNECTED;
  1428. /* something went really wrong */
  1429. if (!cl->status)
  1430. cl->status = -EFAULT;
  1431. diff --git a/drivers/misc/mei/nfc.c b/drivers/misc/mei/nfc.c
  1432. index 3095fc514a65..5ccc23bc7690 100644
  1433. --- a/drivers/misc/mei/nfc.c
  1434. +++ b/drivers/misc/mei/nfc.c
  1435. @@ -342,9 +342,10 @@ static int mei_nfc_send(struct mei_cl_device *cldev, u8 *buf, size_t length)
  1436. ndev = (struct mei_nfc_dev *) cldev->priv_data;
  1437. dev = ndev->cl->dev;
  1438. + err = -ENOMEM;
  1439. mei_buf = kzalloc(length + MEI_NFC_HEADER_SIZE, GFP_KERNEL);
  1440. if (!mei_buf)
  1441. - return -ENOMEM;
  1442. + goto out;
  1443. hdr = (struct mei_nfc_hci_hdr *) mei_buf;
  1444. hdr->cmd = MEI_NFC_CMD_HCI_SEND;
  1445. @@ -354,12 +355,9 @@ static int mei_nfc_send(struct mei_cl_device *cldev, u8 *buf, size_t length)
  1446. hdr->data_size = length;
  1447. memcpy(mei_buf + MEI_NFC_HEADER_SIZE, buf, length);
  1448. -
  1449. err = __mei_cl_send(ndev->cl, mei_buf, length + MEI_NFC_HEADER_SIZE);
  1450. if (err < 0)
  1451. - return err;
  1452. -
  1453. - kfree(mei_buf);
  1454. + goto out;
  1455. if (!wait_event_interruptible_timeout(ndev->send_wq,
  1456. ndev->recv_req_id == ndev->req_id, HZ)) {
  1457. @@ -368,7 +366,8 @@ static int mei_nfc_send(struct mei_cl_device *cldev, u8 *buf, size_t length)
  1458. } else {
  1459. ndev->req_id++;
  1460. }
  1461. -
  1462. +out:
  1463. + kfree(mei_buf);
  1464. return err;
  1465. }
  1466. diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c
  1467. index 1b46c64a649f..4b821b4360e1 100644
  1468. --- a/drivers/misc/mei/pci-me.c
  1469. +++ b/drivers/misc/mei/pci-me.c
  1470. @@ -369,7 +369,7 @@ static int mei_me_pm_runtime_idle(struct device *device)
  1471. if (!dev)
  1472. return -ENODEV;
  1473. if (mei_write_is_idle(dev))
  1474. - pm_schedule_suspend(device, MEI_ME_RPM_TIMEOUT * 2);
  1475. + pm_runtime_autosuspend(device);
  1476. return -EBUSY;
  1477. }
  1478. diff --git a/drivers/misc/mei/pci-txe.c b/drivers/misc/mei/pci-txe.c
  1479. index 2343c6236df9..32fef4d5b0b6 100644
  1480. --- a/drivers/misc/mei/pci-txe.c
  1481. +++ b/drivers/misc/mei/pci-txe.c
  1482. @@ -306,7 +306,7 @@ static int mei_txe_pm_runtime_idle(struct device *device)
  1483. if (!dev)
  1484. return -ENODEV;
  1485. if (mei_write_is_idle(dev))
  1486. - pm_schedule_suspend(device, MEI_TXI_RPM_TIMEOUT * 2);
  1487. + pm_runtime_autosuspend(device);
  1488. return -EBUSY;
  1489. }
  1490. diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
  1491. index 7ad463e9741c..249ab80cbb45 100644
  1492. --- a/drivers/mmc/host/mmci.c
  1493. +++ b/drivers/mmc/host/mmci.c
  1494. @@ -834,6 +834,10 @@ static void
  1495. mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
  1496. unsigned int status)
  1497. {
  1498. + /* Make sure we have data to handle */
  1499. + if (!data)
  1500. + return;
  1501. +
  1502. /* First check for errors */
  1503. if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_STARTBITERR|
  1504. MCI_TXUNDERRUN|MCI_RXOVERRUN)) {
  1505. @@ -902,9 +906,17 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
  1506. unsigned int status)
  1507. {
  1508. void __iomem *base = host->base;
  1509. - bool sbc = (cmd == host->mrq->sbc);
  1510. - bool busy_resp = host->variant->busy_detect &&
  1511. - (cmd->flags & MMC_RSP_BUSY);
  1512. + bool sbc, busy_resp;
  1513. +
  1514. + if (!cmd)
  1515. + return;
  1516. +
  1517. + sbc = (cmd == host->mrq->sbc);
  1518. + busy_resp = host->variant->busy_detect && (cmd->flags & MMC_RSP_BUSY);
  1519. +
  1520. + if (!((status|host->busy_status) & (MCI_CMDCRCFAIL|MCI_CMDTIMEOUT|
  1521. + MCI_CMDSENT|MCI_CMDRESPEND)))
  1522. + return;
  1523. /* Check if we need to wait for busy completion. */
  1524. if (host->busy_status && (status & MCI_ST_CARDBUSY))
  1525. @@ -1132,9 +1144,6 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)
  1526. spin_lock(&host->lock);
  1527. do {
  1528. - struct mmc_command *cmd;
  1529. - struct mmc_data *data;
  1530. -
  1531. status = readl(host->base + MMCISTATUS);
  1532. if (host->singleirq) {
  1533. @@ -1154,16 +1163,8 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)
  1534. dev_dbg(mmc_dev(host->mmc), "irq0 (data+cmd) %08x\n", status);
  1535. - cmd = host->cmd;
  1536. - if ((status|host->busy_status) & (MCI_CMDCRCFAIL|MCI_CMDTIMEOUT|
  1537. - MCI_CMDSENT|MCI_CMDRESPEND) && cmd)
  1538. - mmci_cmd_irq(host, cmd, status);
  1539. -
  1540. - data = host->data;
  1541. - if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_STARTBITERR|
  1542. - MCI_TXUNDERRUN|MCI_RXOVERRUN|MCI_DATAEND|
  1543. - MCI_DATABLOCKEND) && data)
  1544. - mmci_data_irq(host, data, status);
  1545. + mmci_cmd_irq(host, host->cmd, status);
  1546. + mmci_data_irq(host, host->data, status);
  1547. /* Don't poll for busy completion in irq context. */
  1548. if (host->busy_status)
  1549. diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
  1550. index 42914e04d110..056841651a80 100644
  1551. --- a/drivers/pci/hotplug/pciehp_hpc.c
  1552. +++ b/drivers/pci/hotplug/pciehp_hpc.c
  1553. @@ -794,7 +794,7 @@ struct controller *pcie_init(struct pcie_device *dev)
  1554. pcie_capability_write_word(pdev, PCI_EXP_SLTSTA,
  1555. PCI_EXP_SLTSTA_ABP | PCI_EXP_SLTSTA_PFD |
  1556. PCI_EXP_SLTSTA_MRLSC | PCI_EXP_SLTSTA_PDC |
  1557. - PCI_EXP_SLTSTA_CC);
  1558. + PCI_EXP_SLTSTA_CC | PCI_EXP_SLTSTA_DLLSC);
  1559. /* Disable software notification */
  1560. pcie_disable_notification(ctrl);
  1561. diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c
  1562. index a3fbe2012ea3..2ab1b47c7651 100644
  1563. --- a/drivers/pci/pci-label.c
  1564. +++ b/drivers/pci/pci-label.c
  1565. @@ -161,8 +161,8 @@ enum acpi_attr_enum {
  1566. static void dsm_label_utf16s_to_utf8s(union acpi_object *obj, char *buf)
  1567. {
  1568. int len;
  1569. - len = utf16s_to_utf8s((const wchar_t *)obj->string.pointer,
  1570. - obj->string.length,
  1571. + len = utf16s_to_utf8s((const wchar_t *)obj->buffer.pointer,
  1572. + obj->buffer.length,
  1573. UTF16_LITTLE_ENDIAN,
  1574. buf, PAGE_SIZE);
  1575. buf[len] = '\n';
  1576. @@ -187,16 +187,22 @@ static int dsm_get_label(struct device *dev, char *buf,
  1577. tmp = obj->package.elements;
  1578. if (obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 2 &&
  1579. tmp[0].type == ACPI_TYPE_INTEGER &&
  1580. - tmp[1].type == ACPI_TYPE_STRING) {
  1581. + (tmp[1].type == ACPI_TYPE_STRING ||
  1582. + tmp[1].type == ACPI_TYPE_BUFFER)) {
  1583. /*
  1584. * The second string element is optional even when
  1585. * this _DSM is implemented; when not implemented,
  1586. * this entry must return a null string.
  1587. */
  1588. - if (attr == ACPI_ATTR_INDEX_SHOW)
  1589. + if (attr == ACPI_ATTR_INDEX_SHOW) {
  1590. scnprintf(buf, PAGE_SIZE, "%llu\n", tmp->integer.value);
  1591. - else if (attr == ACPI_ATTR_LABEL_SHOW)
  1592. - dsm_label_utf16s_to_utf8s(tmp + 1, buf);
  1593. + } else if (attr == ACPI_ATTR_LABEL_SHOW) {
  1594. + if (tmp[1].type == ACPI_TYPE_STRING)
  1595. + scnprintf(buf, PAGE_SIZE, "%s\n",
  1596. + tmp[1].string.pointer);
  1597. + else if (tmp[1].type == ACPI_TYPE_BUFFER)
  1598. + dsm_label_utf16s_to_utf8s(tmp + 1, buf);
  1599. + }
  1600. len = strlen(buf) > 0 ? strlen(buf) : -1;
  1601. }
  1602. diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
  1603. index 1c8592b0e146..81d49d3ab221 100644
  1604. --- a/drivers/pci/pci.c
  1605. +++ b/drivers/pci/pci.c
  1606. @@ -839,12 +839,6 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
  1607. if (!__pci_complete_power_transition(dev, state))
  1608. error = 0;
  1609. - /*
  1610. - * When aspm_policy is "powersave" this call ensures
  1611. - * that ASPM is configured.
  1612. - */
  1613. - if (!error && dev->bus->self)
  1614. - pcie_aspm_powersave_config_link(dev->bus->self);
  1615. return error;
  1616. }
  1617. @@ -1195,12 +1189,18 @@ int __weak pcibios_enable_device(struct pci_dev *dev, int bars)
  1618. static int do_pci_enable_device(struct pci_dev *dev, int bars)
  1619. {
  1620. int err;
  1621. + struct pci_dev *bridge;
  1622. u16 cmd;
  1623. u8 pin;
  1624. err = pci_set_power_state(dev, PCI_D0);
  1625. if (err < 0 && err != -EIO)
  1626. return err;
  1627. +
  1628. + bridge = pci_upstream_bridge(dev);
  1629. + if (bridge)
  1630. + pcie_aspm_powersave_config_link(bridge);
  1631. +
  1632. err = pcibios_enable_device(dev, bars);
  1633. if (err < 0)
  1634. return err;
  1635. diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
  1636. index caed1ce6facd..481c4e18693a 100644
  1637. --- a/drivers/pci/setup-res.c
  1638. +++ b/drivers/pci/setup-res.c
  1639. @@ -320,9 +320,11 @@ int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsiz
  1640. resource_size_t min_align)
  1641. {
  1642. struct resource *res = dev->resource + resno;
  1643. + unsigned long flags;
  1644. resource_size_t new_size;
  1645. int ret;
  1646. + flags = res->flags;
  1647. res->flags |= IORESOURCE_UNSET;
  1648. if (!res->parent) {
  1649. dev_info(&dev->dev, "BAR %d: can't reassign an unassigned resource %pR\n",
  1650. @@ -339,7 +341,12 @@ int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsiz
  1651. dev_info(&dev->dev, "BAR %d: reassigned %pR\n", resno, res);
  1652. if (resno < PCI_BRIDGE_RESOURCES)
  1653. pci_update_resource(dev, resno);
  1654. + } else {
  1655. + res->flags = flags;
  1656. + dev_info(&dev->dev, "BAR %d: %pR (failed to expand by %#llx)\n",
  1657. + resno, res, (unsigned long long) addsize);
  1658. }
  1659. +
  1660. return ret;
  1661. }
  1662. diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
  1663. index 31184b35370f..489e83b6b5e1 100644
  1664. --- a/drivers/scsi/hpsa.c
  1665. +++ b/drivers/scsi/hpsa.c
  1666. @@ -5092,7 +5092,7 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp)
  1667. }
  1668. if (ioc->Request.Type.Direction & XFER_WRITE) {
  1669. if (copy_from_user(buff[sg_used], data_ptr, sz)) {
  1670. - status = -ENOMEM;
  1671. + status = -EFAULT;
  1672. goto cleanup1;
  1673. }
  1674. } else
  1675. @@ -6365,9 +6365,9 @@ static inline void hpsa_set_driver_support_bits(struct ctlr_info *h)
  1676. {
  1677. u32 driver_support;
  1678. -#ifdef CONFIG_X86
  1679. - /* Need to enable prefetch in the SCSI core for 6400 in x86 */
  1680. driver_support = readl(&(h->cfgtable->driver_support));
  1681. + /* Need to enable prefetch in the SCSI core for 6400 in x86 */
  1682. +#ifdef CONFIG_X86
  1683. driver_support |= ENABLE_SCSI_PREFETCH;
  1684. #endif
  1685. driver_support |= ENABLE_UNIT_ATTN;
  1686. diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c
  1687. index 08356b6955a4..2d36eac6889c 100644
  1688. --- a/drivers/staging/et131x/et131x.c
  1689. +++ b/drivers/staging/et131x/et131x.c
  1690. @@ -1423,22 +1423,16 @@ static int et131x_mii_read(struct et131x_adapter *adapter, u8 reg, u16 *value)
  1691. * @reg: the register to read
  1692. * @value: 16-bit value to write
  1693. */
  1694. -static int et131x_mii_write(struct et131x_adapter *adapter, u8 reg, u16 value)
  1695. +static int et131x_mii_write(struct et131x_adapter *adapter, u8 addr, u8 reg,
  1696. + u16 value)
  1697. {
  1698. struct mac_regs __iomem *mac = &adapter->regs->mac;
  1699. - struct phy_device *phydev = adapter->phydev;
  1700. int status = 0;
  1701. - u8 addr;
  1702. u32 delay = 0;
  1703. u32 mii_addr;
  1704. u32 mii_cmd;
  1705. u32 mii_indicator;
  1706. - if (!phydev)
  1707. - return -EIO;
  1708. -
  1709. - addr = phydev->addr;
  1710. -
  1711. /* Save a local copy of the registers we are dealing with so we can
  1712. * set them back
  1713. */
  1714. @@ -1633,17 +1627,7 @@ static int et131x_mdio_write(struct mii_bus *bus, int phy_addr,
  1715. struct net_device *netdev = bus->priv;
  1716. struct et131x_adapter *adapter = netdev_priv(netdev);
  1717. - return et131x_mii_write(adapter, reg, value);
  1718. -}
  1719. -
  1720. -static int et131x_mdio_reset(struct mii_bus *bus)
  1721. -{
  1722. - struct net_device *netdev = bus->priv;
  1723. - struct et131x_adapter *adapter = netdev_priv(netdev);
  1724. -
  1725. - et131x_mii_write(adapter, MII_BMCR, BMCR_RESET);
  1726. -
  1727. - return 0;
  1728. + return et131x_mii_write(adapter, phy_addr, reg, value);
  1729. }
  1730. /* et1310_phy_power_switch - PHY power control
  1731. @@ -1658,18 +1642,20 @@ static int et131x_mdio_reset(struct mii_bus *bus)
  1732. static void et1310_phy_power_switch(struct et131x_adapter *adapter, bool down)
  1733. {
  1734. u16 data;
  1735. + struct phy_device *phydev = adapter->phydev;
  1736. et131x_mii_read(adapter, MII_BMCR, &data);
  1737. data &= ~BMCR_PDOWN;
  1738. if (down)
  1739. data |= BMCR_PDOWN;
  1740. - et131x_mii_write(adapter, MII_BMCR, data);
  1741. + et131x_mii_write(adapter, phydev->addr, MII_BMCR, data);
  1742. }
  1743. /* et131x_xcvr_init - Init the phy if we are setting it into force mode */
  1744. static void et131x_xcvr_init(struct et131x_adapter *adapter)
  1745. {
  1746. u16 lcr2;
  1747. + struct phy_device *phydev = adapter->phydev;
  1748. /* Set the LED behavior such that LED 1 indicates speed (off =
  1749. * 10Mbits, blink = 100Mbits, on = 1000Mbits) and LED 2 indicates
  1750. @@ -1690,7 +1676,7 @@ static void et131x_xcvr_init(struct et131x_adapter *adapter)
  1751. else
  1752. lcr2 |= (LED_VAL_LINKON << LED_TXRX_SHIFT);
  1753. - et131x_mii_write(adapter, PHY_LED_2, lcr2);
  1754. + et131x_mii_write(adapter, phydev->addr, PHY_LED_2, lcr2);
  1755. }
  1756. }
  1757. @@ -3645,14 +3631,14 @@ static void et131x_adjust_link(struct net_device *netdev)
  1758. et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG,
  1759. &register18);
  1760. - et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,
  1761. - register18 | 0x4);
  1762. - et131x_mii_write(adapter, PHY_INDEX_REG,
  1763. + et131x_mii_write(adapter, phydev->addr,
  1764. + PHY_MPHY_CONTROL_REG, register18 | 0x4);
  1765. + et131x_mii_write(adapter, phydev->addr, PHY_INDEX_REG,
  1766. register18 | 0x8402);
  1767. - et131x_mii_write(adapter, PHY_DATA_REG,
  1768. + et131x_mii_write(adapter, phydev->addr, PHY_DATA_REG,
  1769. register18 | 511);
  1770. - et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,
  1771. - register18);
  1772. + et131x_mii_write(adapter, phydev->addr,
  1773. + PHY_MPHY_CONTROL_REG, register18);
  1774. }
  1775. et1310_config_flow_control(adapter);
  1776. @@ -3664,7 +3650,8 @@ static void et131x_adjust_link(struct net_device *netdev)
  1777. et131x_mii_read(adapter, PHY_CONFIG, &reg);
  1778. reg &= ~ET_PHY_CONFIG_TX_FIFO_DEPTH;
  1779. reg |= ET_PHY_CONFIG_FIFO_DEPTH_32;
  1780. - et131x_mii_write(adapter, PHY_CONFIG, reg);
  1781. + et131x_mii_write(adapter, phydev->addr, PHY_CONFIG,
  1782. + reg);
  1783. }
  1784. et131x_set_rx_dma_timer(adapter);
  1785. @@ -3677,14 +3664,14 @@ static void et131x_adjust_link(struct net_device *netdev)
  1786. et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG,
  1787. &register18);
  1788. - et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,
  1789. - register18 | 0x4);
  1790. - et131x_mii_write(adapter, PHY_INDEX_REG,
  1791. - register18 | 0x8402);
  1792. - et131x_mii_write(adapter, PHY_DATA_REG,
  1793. - register18 | 511);
  1794. - et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,
  1795. - register18);
  1796. + et131x_mii_write(adapter, phydev->addr,
  1797. + PHY_MPHY_CONTROL_REG, register18 | 0x4);
  1798. + et131x_mii_write(adapter, phydev->addr,
  1799. + PHY_INDEX_REG, register18 | 0x8402);
  1800. + et131x_mii_write(adapter, phydev->addr,
  1801. + PHY_DATA_REG, register18 | 511);
  1802. + et131x_mii_write(adapter, phydev->addr,
  1803. + PHY_MPHY_CONTROL_REG, register18);
  1804. }
  1805. /* Free the packets being actively sent & stopped */
  1806. @@ -4646,10 +4633,6 @@ static int et131x_pci_setup(struct pci_dev *pdev,
  1807. /* Copy address into the net_device struct */
  1808. memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN);
  1809. - /* Init variable for counting how long we do not have link status */
  1810. - adapter->boot_coma = 0;
  1811. - et1310_disable_phy_coma(adapter);
  1812. -
  1813. rc = -ENOMEM;
  1814. /* Setup the mii_bus struct */
  1815. @@ -4665,7 +4648,6 @@ static int et131x_pci_setup(struct pci_dev *pdev,
  1816. adapter->mii_bus->priv = netdev;
  1817. adapter->mii_bus->read = et131x_mdio_read;
  1818. adapter->mii_bus->write = et131x_mdio_write;
  1819. - adapter->mii_bus->reset = et131x_mdio_reset;
  1820. adapter->mii_bus->irq = kmalloc_array(PHY_MAX_ADDR, sizeof(int),
  1821. GFP_KERNEL);
  1822. if (!adapter->mii_bus->irq)
  1823. @@ -4689,6 +4671,10 @@ static int et131x_pci_setup(struct pci_dev *pdev,
  1824. /* Setup et1310 as per the documentation */
  1825. et131x_adapter_setup(adapter);
  1826. + /* Init variable for counting how long we do not have link status */
  1827. + adapter->boot_coma = 0;
  1828. + et1310_disable_phy_coma(adapter);
  1829. +
  1830. /* We can enable interrupts now
  1831. *
  1832. * NOTE - Because registration of interrupt handler is done in the
  1833. diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
  1834. index dde04b767a6d..b16687625c44 100644
  1835. --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
  1836. +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
  1837. @@ -35,7 +35,7 @@
  1838. */
  1839. #define DEBUG_SUBSYSTEM S_CLASS
  1840. -# include <asm/atomic.h>
  1841. +# include <linux/atomic.h>
  1842. #include <obd_support.h>
  1843. #include <obd_class.h>
  1844. diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
  1845. index 7526b989dcbf..c4273cd5f7ed 100644
  1846. --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
  1847. +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
  1848. @@ -54,9 +54,11 @@ static struct usb_device_id rtw_usb_id_tbl[] = {
  1849. {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x0179)}, /* 8188ETV */
  1850. /*=== Customer ID ===*/
  1851. /****** 8188EUS ********/
  1852. + {USB_DEVICE(0x056e, 0x4008)}, /* Elecom WDC-150SU2M */
  1853. {USB_DEVICE(0x07b8, 0x8179)}, /* Abocom - Abocom */
  1854. {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */
  1855. {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */
  1856. + {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */
  1857. {} /* Terminating entry */
  1858. };
  1859. diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
  1860. index fbf6c5ad222f..ef2fb367d179 100644
  1861. --- a/drivers/tty/serial/serial_core.c
  1862. +++ b/drivers/tty/serial/serial_core.c
  1863. @@ -243,6 +243,9 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
  1864. /*
  1865. * Turn off DTR and RTS early.
  1866. */
  1867. + if (uart_console(uport) && tty)
  1868. + uport->cons->cflag = tty->termios.c_cflag;
  1869. +
  1870. if (!tty || (tty->termios.c_cflag & HUPCL))
  1871. uart_clear_mctrl(uport, TIOCM_DTR | TIOCM_RTS);
  1872. diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
  1873. index 257876ea03a1..0b59731c3021 100644
  1874. --- a/drivers/usb/core/devio.c
  1875. +++ b/drivers/usb/core/devio.c
  1876. @@ -1509,7 +1509,7 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
  1877. u = (is_in ? URB_DIR_IN : URB_DIR_OUT);
  1878. if (uurb->flags & USBDEVFS_URB_ISO_ASAP)
  1879. u |= URB_ISO_ASAP;
  1880. - if (uurb->flags & USBDEVFS_URB_SHORT_NOT_OK)
  1881. + if (uurb->flags & USBDEVFS_URB_SHORT_NOT_OK && is_in)
  1882. u |= URB_SHORT_NOT_OK;
  1883. if (uurb->flags & USBDEVFS_URB_NO_FSBR)
  1884. u |= URB_NO_FSBR;
  1885. diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
  1886. index 0e950ad8cb25..27f217107ef1 100644
  1887. --- a/drivers/usb/core/hub.c
  1888. +++ b/drivers/usb/core/hub.c
  1889. @@ -1728,8 +1728,14 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
  1890. * - Change autosuspend delay of hub can avoid unnecessary auto
  1891. * suspend timer for hub, also may decrease power consumption
  1892. * of USB bus.
  1893. + *
  1894. + * - If user has indicated to prevent autosuspend by passing
  1895. + * usbcore.autosuspend = -1 then keep autosuspend disabled.
  1896. */
  1897. - pm_runtime_set_autosuspend_delay(&hdev->dev, 0);
  1898. +#ifdef CONFIG_PM_RUNTIME
  1899. + if (hdev->dev.power.autosuspend_delay >= 0)
  1900. + pm_runtime_set_autosuspend_delay(&hdev->dev, 0);
  1901. +#endif
  1902. /*
  1903. * Hubs have proper suspend/resume support, except for root hubs
  1904. @@ -3264,6 +3270,43 @@ static int finish_port_resume(struct usb_device *udev)
  1905. }
  1906. /*
  1907. + * There are some SS USB devices which take longer time for link training.
  1908. + * XHCI specs 4.19.4 says that when Link training is successful, port
  1909. + * sets CSC bit to 1. So if SW reads port status before successful link
  1910. + * training, then it will not find device to be present.
  1911. + * USB Analyzer log with such buggy devices show that in some cases
  1912. + * device switch on the RX termination after long delay of host enabling
  1913. + * the VBUS. In few other cases it has been seen that device fails to
  1914. + * negotiate link training in first attempt. It has been
  1915. + * reported till now that few devices take as long as 2000 ms to train
  1916. + * the link after host enabling its VBUS and termination. Following
  1917. + * routine implements a 2000 ms timeout for link training. If in a case
  1918. + * link trains before timeout, loop will exit earlier.
  1919. + *
  1920. + * FIXME: If a device was connected before suspend, but was removed
  1921. + * while system was asleep, then the loop in the following routine will
  1922. + * only exit at timeout.
  1923. + *
  1924. + * This routine should only be called when persist is enabled for a SS
  1925. + * device.
  1926. + */
  1927. +static int wait_for_ss_port_enable(struct usb_device *udev,
  1928. + struct usb_hub *hub, int *port1,
  1929. + u16 *portchange, u16 *portstatus)
  1930. +{
  1931. + int status = 0, delay_ms = 0;
  1932. +
  1933. + while (delay_ms < 2000) {
  1934. + if (status || *portstatus & USB_PORT_STAT_CONNECTION)
  1935. + break;
  1936. + msleep(20);
  1937. + delay_ms += 20;
  1938. + status = hub_port_status(hub, *port1, portstatus, portchange);
  1939. + }
  1940. + return status;
  1941. +}
  1942. +
  1943. +/*
  1944. * usb_port_resume - re-activate a suspended usb device's upstream port
  1945. * @udev: device to re-activate, not a root hub
  1946. * Context: must be able to sleep; device not locked; pm locks held
  1947. @@ -3359,6 +3402,10 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
  1948. }
  1949. }
  1950. + if (udev->persist_enabled && hub_is_superspeed(hub->hdev))
  1951. + status = wait_for_ss_port_enable(udev, hub, &port1, &portchange,
  1952. + &portstatus);
  1953. +
  1954. status = check_port_resume_type(udev,
  1955. hub, port1, status, portchange, portstatus);
  1956. if (status == 0)
  1957. @@ -4550,6 +4597,7 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
  1958. struct usb_hcd *hcd = bus_to_hcd(hdev->bus);
  1959. struct usb_port *port_dev = hub->ports[port1 - 1];
  1960. struct usb_device *udev = port_dev->child;
  1961. + static int unreliable_port = -1;
  1962. /* Disconnect any existing devices under this port */
  1963. if (udev) {
  1964. @@ -4570,10 +4618,12 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
  1965. USB_PORT_STAT_C_ENABLE)) {
  1966. status = hub_port_debounce_be_stable(hub, port1);
  1967. if (status < 0) {
  1968. - if (status != -ENODEV && printk_ratelimit())
  1969. - dev_err(&port_dev->dev,
  1970. - "connect-debounce failed\n");
  1971. + if (status != -ENODEV &&
  1972. + port1 != unreliable_port &&
  1973. + printk_ratelimit())
  1974. + dev_err(&port_dev->dev, "connect-debounce failed\n");
  1975. portstatus &= ~USB_PORT_STAT_CONNECTION;
  1976. + unreliable_port = port1;
  1977. } else {
  1978. portstatus = status;
  1979. }
  1980. diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
  1981. index cc305c71ac3d..6130b7574908 100644
  1982. --- a/drivers/usb/host/ehci-hub.c
  1983. +++ b/drivers/usb/host/ehci-hub.c
  1984. @@ -1230,7 +1230,7 @@ int ehci_hub_control(
  1985. if (selector == EHSET_TEST_SINGLE_STEP_SET_FEATURE) {
  1986. spin_unlock_irqrestore(&ehci->lock, flags);
  1987. retval = ehset_single_step_set_feature(hcd,
  1988. - wIndex);
  1989. + wIndex + 1);
  1990. spin_lock_irqsave(&ehci->lock, flags);
  1991. break;
  1992. }
  1993. diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
  1994. index 3e86bf4371b3..ca7b964124af 100644
  1995. --- a/drivers/usb/host/ehci-pci.c
  1996. +++ b/drivers/usb/host/ehci-pci.c
  1997. @@ -35,6 +35,21 @@ static const char hcd_name[] = "ehci-pci";
  1998. #define PCI_DEVICE_ID_INTEL_CE4100_USB 0x2e70
  1999. /*-------------------------------------------------------------------------*/
  2000. +#define PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC 0x0939
  2001. +static inline bool is_intel_quark_x1000(struct pci_dev *pdev)
  2002. +{
  2003. + return pdev->vendor == PCI_VENDOR_ID_INTEL &&
  2004. + pdev->device == PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC;
  2005. +}
  2006. +
  2007. +/*
  2008. + * 0x84 is the offset of in/out threshold register,
  2009. + * and it is the same offset as the register of 'hostpc'.
  2010. + */
  2011. +#define intel_quark_x1000_insnreg01 hostpc
  2012. +
  2013. +/* Maximum usable threshold value is 0x7f dwords for both IN and OUT */
  2014. +#define INTEL_QUARK_X1000_EHCI_MAX_THRESHOLD 0x007f007f
  2015. /* called after powerup, by probe or system-pm "wakeup" */
  2016. static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev)
  2017. @@ -50,6 +65,16 @@ static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev)
  2018. if (!retval)
  2019. ehci_dbg(ehci, "MWI active\n");
  2020. + /* Reset the threshold limit */
  2021. + if (is_intel_quark_x1000(pdev)) {
  2022. + /*
  2023. + * For the Intel QUARK X1000, raise the I/O threshold to the
  2024. + * maximum usable value in order to improve performance.
  2025. + */
  2026. + ehci_writel(ehci, INTEL_QUARK_X1000_EHCI_MAX_THRESHOLD,
  2027. + ehci->regs->intel_quark_x1000_insnreg01);
  2028. + }
  2029. +
  2030. return 0;
  2031. }
  2032. diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
  2033. index 45032e933e18..04f2186939d2 100644
  2034. --- a/drivers/usb/host/ohci-dbg.c
  2035. +++ b/drivers/usb/host/ohci-dbg.c
  2036. @@ -236,7 +236,7 @@ ohci_dump_roothub (
  2037. }
  2038. }
  2039. -static void ohci_dump (struct ohci_hcd *controller, int verbose)
  2040. +static void ohci_dump(struct ohci_hcd *controller)
  2041. {
  2042. ohci_dbg (controller, "OHCI controller state\n");
  2043. @@ -464,15 +464,16 @@ show_list (struct ohci_hcd *ohci, char *buf, size_t count, struct ed *ed)
  2044. static ssize_t fill_async_buffer(struct debug_buffer *buf)
  2045. {
  2046. struct ohci_hcd *ohci;
  2047. - size_t temp;
  2048. + size_t temp, size;
  2049. unsigned long flags;
  2050. ohci = buf->ohci;
  2051. + size = PAGE_SIZE;
  2052. /* display control and bulk lists together, for simplicity */
  2053. spin_lock_irqsave (&ohci->lock, flags);
  2054. - temp = show_list(ohci, buf->page, buf->count, ohci->ed_controltail);
  2055. - temp += show_list(ohci, buf->page + temp, buf->count - temp,
  2056. + temp = show_list(ohci, buf->page, size, ohci->ed_controltail);
  2057. + temp += show_list(ohci, buf->page + temp, size - temp,
  2058. ohci->ed_bulktail);
  2059. spin_unlock_irqrestore (&ohci->lock, flags);
  2060. diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
  2061. index f98d03f3144c..a21a36500fd7 100644
  2062. --- a/drivers/usb/host/ohci-hcd.c
  2063. +++ b/drivers/usb/host/ohci-hcd.c
  2064. @@ -76,8 +76,8 @@ static const char hcd_name [] = "ohci_hcd";
  2065. #include "ohci.h"
  2066. #include "pci-quirks.h"
  2067. -static void ohci_dump (struct ohci_hcd *ohci, int verbose);
  2068. -static void ohci_stop (struct usb_hcd *hcd);
  2069. +static void ohci_dump(struct ohci_hcd *ohci);
  2070. +static void ohci_stop(struct usb_hcd *hcd);
  2071. #include "ohci-hub.c"
  2072. #include "ohci-dbg.c"
  2073. @@ -744,7 +744,7 @@ retry:
  2074. ohci->ed_to_check = NULL;
  2075. }
  2076. - ohci_dump (ohci, 1);
  2077. + ohci_dump(ohci);
  2078. return 0;
  2079. }
  2080. @@ -825,7 +825,7 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd)
  2081. usb_hc_died(hcd);
  2082. }
  2083. - ohci_dump (ohci, 1);
  2084. + ohci_dump(ohci);
  2085. ohci_usb_reset (ohci);
  2086. }
  2087. @@ -925,7 +925,7 @@ static void ohci_stop (struct usb_hcd *hcd)
  2088. {
  2089. struct ohci_hcd *ohci = hcd_to_ohci (hcd);
  2090. - ohci_dump (ohci, 1);
  2091. + ohci_dump(ohci);
  2092. if (quirk_nec(ohci))
  2093. flush_work(&ohci->nec_work);
  2094. diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
  2095. index d4253e319428..a8bde5b8cbdd 100644
  2096. --- a/drivers/usb/host/ohci-q.c
  2097. +++ b/drivers/usb/host/ohci-q.c
  2098. @@ -311,8 +311,7 @@ static void periodic_unlink (struct ohci_hcd *ohci, struct ed *ed)
  2099. * - ED_OPER: when there's any request queued, the ED gets rescheduled
  2100. * immediately. HC should be working on them.
  2101. *
  2102. - * - ED_IDLE: when there's no TD queue. there's no reason for the HC
  2103. - * to care about this ED; safe to disable the endpoint.
  2104. + * - ED_IDLE: when there's no TD queue or the HC isn't running.
  2105. *
  2106. * When finish_unlinks() runs later, after SOF interrupt, it will often
  2107. * complete one or more URB unlinks before making that state change.
  2108. @@ -926,6 +925,10 @@ rescan_all:
  2109. int completed, modified;
  2110. __hc32 *prev;
  2111. + /* Is this ED already invisible to the hardware? */
  2112. + if (ed->state == ED_IDLE)
  2113. + goto ed_idle;
  2114. +
  2115. /* only take off EDs that the HC isn't using, accounting for
  2116. * frame counter wraps and EDs with partially retired TDs
  2117. */
  2118. @@ -955,12 +958,20 @@ skip_ed:
  2119. }
  2120. }
  2121. + /* ED's now officially unlinked, hc doesn't see */
  2122. + ed->state = ED_IDLE;
  2123. + if (quirk_zfmicro(ohci) && ed->type == PIPE_INTERRUPT)
  2124. + ohci->eds_scheduled--;
  2125. + ed->hwHeadP &= ~cpu_to_hc32(ohci, ED_H);
  2126. + ed->hwNextED = 0;
  2127. + wmb();
  2128. + ed->hwINFO &= ~cpu_to_hc32(ohci, ED_SKIP | ED_DEQUEUE);
  2129. +ed_idle:
  2130. +
  2131. /* reentrancy: if we drop the schedule lock, someone might
  2132. * have modified this list. normally it's just prepending
  2133. * entries (which we'd ignore), but paranoia won't hurt.
  2134. */
  2135. - *last = ed->ed_next;
  2136. - ed->ed_next = NULL;
  2137. modified = 0;
  2138. /* unlink urbs as requested, but rescan the list after
  2139. @@ -1018,19 +1029,20 @@ rescan_this:
  2140. if (completed && !list_empty (&ed->td_list))
  2141. goto rescan_this;
  2142. - /* ED's now officially unlinked, hc doesn't see */
  2143. - ed->state = ED_IDLE;
  2144. - if (quirk_zfmicro(ohci) && ed->type == PIPE_INTERRUPT)
  2145. - ohci->eds_scheduled--;
  2146. - ed->hwHeadP &= ~cpu_to_hc32(ohci, ED_H);
  2147. - ed->hwNextED = 0;
  2148. - wmb ();
  2149. - ed->hwINFO &= ~cpu_to_hc32 (ohci, ED_SKIP | ED_DEQUEUE);
  2150. -
  2151. - /* but if there's work queued, reschedule */
  2152. - if (!list_empty (&ed->td_list)) {
  2153. - if (ohci->rh_state == OHCI_RH_RUNNING)
  2154. - ed_schedule (ohci, ed);
  2155. + /*
  2156. + * If no TDs are queued, take ED off the ed_rm_list.
  2157. + * Otherwise, if the HC is running, reschedule.
  2158. + * If not, leave it on the list for further dequeues.
  2159. + */
  2160. + if (list_empty(&ed->td_list)) {
  2161. + *last = ed->ed_next;
  2162. + ed->ed_next = NULL;
  2163. + } else if (ohci->rh_state == OHCI_RH_RUNNING) {
  2164. + *last = ed->ed_next;
  2165. + ed->ed_next = NULL;
  2166. + ed_schedule(ohci, ed);
  2167. + } else {
  2168. + last = &ed->ed_next;
  2169. }
  2170. if (modified)
  2171. diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
  2172. index e20520f42753..994a36e582ca 100644
  2173. --- a/drivers/usb/host/xhci-pci.c
  2174. +++ b/drivers/usb/host/xhci-pci.c
  2175. @@ -101,6 +101,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
  2176. /* AMD PLL quirk */
  2177. if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info())
  2178. xhci->quirks |= XHCI_AMD_PLL_FIX;
  2179. +
  2180. + if (pdev->vendor == PCI_VENDOR_ID_AMD)
  2181. + xhci->quirks |= XHCI_TRUST_TX_LENGTH;
  2182. +
  2183. if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
  2184. xhci->quirks |= XHCI_LPM_SUPPORT;
  2185. xhci->quirks |= XHCI_INTEL_HOST;
  2186. @@ -143,6 +147,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
  2187. pdev->device == PCI_DEVICE_ID_ASROCK_P67) {
  2188. xhci->quirks |= XHCI_RESET_ON_RESUME;
  2189. xhci->quirks |= XHCI_TRUST_TX_LENGTH;
  2190. + xhci->quirks |= XHCI_BROKEN_STREAMS;
  2191. }
  2192. if (pdev->vendor == PCI_VENDOR_ID_RENESAS &&
  2193. pdev->device == 0x0015)
  2194. @@ -150,6 +155,11 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
  2195. if (pdev->vendor == PCI_VENDOR_ID_VIA)
  2196. xhci->quirks |= XHCI_RESET_ON_RESUME;
  2197. + /* See https://bugzilla.kernel.org/show_bug.cgi?id=79511 */
  2198. + if (pdev->vendor == PCI_VENDOR_ID_VIA &&
  2199. + pdev->device == 0x3432)
  2200. + xhci->quirks |= XHCI_BROKEN_STREAMS;
  2201. +
  2202. if (xhci->quirks & XHCI_RESET_ON_RESUME)
  2203. xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
  2204. "QUIRK: Resetting on resume");
  2205. @@ -230,7 +240,8 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
  2206. goto put_usb3_hcd;
  2207. /* Roothub already marked as USB 3.0 speed */
  2208. - if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
  2209. + if (!(xhci->quirks & XHCI_BROKEN_STREAMS) &&
  2210. + HCC_MAX_PSA(xhci->hcc_params) >= 4)
  2211. xhci->shared_hcd->can_do_streams = 1;
  2212. /* USB-2 and USB-3 roothubs initialized, allow runtime pm suspend */
  2213. diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
  2214. index 749fc68eb5c1..28a929d45cfe 100644
  2215. --- a/drivers/usb/host/xhci-ring.c
  2216. +++ b/drivers/usb/host/xhci-ring.c
  2217. @@ -364,32 +364,6 @@ static void ring_doorbell_for_active_rings(struct xhci_hcd *xhci,
  2218. }
  2219. }
  2220. -/*
  2221. - * Find the segment that trb is in. Start searching in start_seg.
  2222. - * If we must move past a segment that has a link TRB with a toggle cycle state
  2223. - * bit set, then we will toggle the value pointed at by cycle_state.
  2224. - */
  2225. -static struct xhci_segment *find_trb_seg(
  2226. - struct xhci_segment *start_seg,
  2227. - union xhci_trb *trb, int *cycle_state)
  2228. -{
  2229. - struct xhci_segment *cur_seg = start_seg;
  2230. - struct xhci_generic_trb *generic_trb;
  2231. -
  2232. - while (cur_seg->trbs > trb ||
  2233. - &cur_seg->trbs[TRBS_PER_SEGMENT - 1] < trb) {
  2234. - generic_trb = &cur_seg->trbs[TRBS_PER_SEGMENT - 1].generic;
  2235. - if (generic_trb->field[3] & cpu_to_le32(LINK_TOGGLE))
  2236. - *cycle_state ^= 0x1;
  2237. - cur_seg = cur_seg->next;
  2238. - if (cur_seg == start_seg)
  2239. - /* Looped over the entire list. Oops! */
  2240. - return NULL;
  2241. - }
  2242. - return cur_seg;
  2243. -}
  2244. -
  2245. -
  2246. static struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci,
  2247. unsigned int slot_id, unsigned int ep_index,
  2248. unsigned int stream_id)
  2249. @@ -459,9 +433,12 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci,
  2250. struct xhci_virt_device *dev = xhci->devs[slot_id];
  2251. struct xhci_virt_ep *ep = &dev->eps[ep_index];
  2252. struct xhci_ring *ep_ring;
  2253. - struct xhci_generic_trb *trb;
  2254. + struct xhci_segment *new_seg;
  2255. + union xhci_trb *new_deq;
  2256. dma_addr_t addr;
  2257. u64 hw_dequeue;
  2258. + bool cycle_found = false;
  2259. + bool td_last_trb_found = false;
  2260. ep_ring = xhci_triad_to_transfer_ring(xhci, slot_id,
  2261. ep_index, stream_id);
  2262. @@ -486,45 +463,45 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci,
  2263. hw_dequeue = le64_to_cpu(ep_ctx->deq);
  2264. }
  2265. - /* Find virtual address and segment of hardware dequeue pointer */
  2266. - state->new_deq_seg = ep_ring->deq_seg;
  2267. - state->new_deq_ptr = ep_ring->dequeue;
  2268. - while (xhci_trb_virt_to_dma(state->new_deq_seg, state->new_deq_ptr)
  2269. - != (dma_addr_t)(hw_dequeue & ~0xf)) {
  2270. - next_trb(xhci, ep_ring, &state->new_deq_seg,
  2271. - &state->new_deq_ptr);
  2272. - if (state->new_deq_ptr == ep_ring->dequeue) {
  2273. - WARN_ON(1);
  2274. - return;
  2275. - }
  2276. - }
  2277. + new_seg = ep_ring->deq_seg;
  2278. + new_deq = ep_ring->dequeue;
  2279. + state->new_cycle_state = hw_dequeue & 0x1;
  2280. +
  2281. /*
  2282. - * Find cycle state for last_trb, starting at old cycle state of
  2283. - * hw_dequeue. If there is only one segment ring, find_trb_seg() will
  2284. - * return immediately and cannot toggle the cycle state if this search
  2285. - * wraps around, so add one more toggle manually in that case.
  2286. + * We want to find the pointer, segment and cycle state of the new trb
  2287. + * (the one after current TD's last_trb). We know the cycle state at
  2288. + * hw_dequeue, so walk the ring until both hw_dequeue and last_trb are
  2289. + * found.
  2290. */
  2291. - state->new_cycle_state = hw_dequeue & 0x1;
  2292. - if (ep_ring->first_seg == ep_ring->first_seg->next &&
  2293. - cur_td->last_trb < state->new_deq_ptr)
  2294. - state->new_cycle_state ^= 0x1;
  2295. + do {
  2296. + if (!cycle_found && xhci_trb_virt_to_dma(new_seg, new_deq)
  2297. + == (dma_addr_t)(hw_dequeue & ~0xf)) {
  2298. + cycle_found = true;
  2299. + if (td_last_trb_found)
  2300. + break;
  2301. + }
  2302. + if (new_deq == cur_td->last_trb)
  2303. + td_last_trb_found = true;
  2304. - state->new_deq_ptr = cur_td->last_trb;
  2305. - xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
  2306. - "Finding segment containing last TRB in TD.");
  2307. - state->new_deq_seg = find_trb_seg(state->new_deq_seg,
  2308. - state->new_deq_ptr, &state->new_cycle_state);
  2309. - if (!state->new_deq_seg) {
  2310. - WARN_ON(1);
  2311. - return;
  2312. - }
  2313. + if (cycle_found &&
  2314. + TRB_TYPE_LINK_LE32(new_deq->generic.field[3]) &&
  2315. + new_deq->generic.field[3] & cpu_to_le32(LINK_TOGGLE))
  2316. + state->new_cycle_state ^= 0x1;
  2317. +
  2318. + next_trb(xhci, ep_ring, &new_seg, &new_deq);
  2319. +
  2320. + /* Search wrapped around, bail out */
  2321. + if (new_deq == ep->ring->dequeue) {
  2322. + xhci_err(xhci, "Error: Failed finding new dequeue state\n");
  2323. + state->new_deq_seg = NULL;
  2324. + state->new_deq_ptr = NULL;
  2325. + return;
  2326. + }
  2327. +
  2328. + } while (!cycle_found || !td_last_trb_found);
  2329. - /* Increment to find next TRB after last_trb. Cycle if appropriate. */
  2330. - trb = &state->new_deq_ptr->generic;
  2331. - if (TRB_TYPE_LINK_LE32(trb->field[3]) &&
  2332. - (trb->field[3] & cpu_to_le32(LINK_TOGGLE)))
  2333. - state->new_cycle_state ^= 0x1;
  2334. - next_trb(xhci, ep_ring, &state->new_deq_seg, &state->new_deq_ptr);
  2335. + state->new_deq_seg = new_seg;
  2336. + state->new_deq_ptr = new_deq;
  2337. /* Don't update the ring cycle state for the producer (us). */
  2338. xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
  2339. @@ -2483,7 +2460,8 @@ static int handle_tx_event(struct xhci_hcd *xhci,
  2340. * last TRB of the previous TD. The command completion handle
  2341. * will take care the rest.
  2342. */
  2343. - if (!event_seg && trb_comp_code == COMP_STOP_INVAL) {
  2344. + if (!event_seg && (trb_comp_code == COMP_STOP ||
  2345. + trb_comp_code == COMP_STOP_INVAL)) {
  2346. ret = 0;
  2347. goto cleanup;
  2348. }
  2349. diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
  2350. index 7436d5f5e67a..e32cc6cf86dc 100644
  2351. --- a/drivers/usb/host/xhci.c
  2352. +++ b/drivers/usb/host/xhci.c
  2353. @@ -2891,6 +2891,9 @@ void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci,
  2354. ep_index, ep->stopped_stream, ep->stopped_td,
  2355. &deq_state);
  2356. + if (!deq_state.new_deq_ptr || !deq_state.new_deq_seg)
  2357. + return;
  2358. +
  2359. /* HW with the reset endpoint quirk will use the saved dequeue state to
  2360. * issue a configure endpoint command later.
  2361. */
  2362. @@ -3163,7 +3166,8 @@ int xhci_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev,
  2363. num_streams);
  2364. /* MaxPSASize value 0 (2 streams) means streams are not supported */
  2365. - if (HCC_MAX_PSA(xhci->hcc_params) < 4) {
  2366. + if ((xhci->quirks & XHCI_BROKEN_STREAMS) ||
  2367. + HCC_MAX_PSA(xhci->hcc_params) < 4) {
  2368. xhci_dbg(xhci, "xHCI controller does not support streams.\n");
  2369. return -ENOSYS;
  2370. }
  2371. diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
  2372. index 9ffecd56600d..dace5152e179 100644
  2373. --- a/drivers/usb/host/xhci.h
  2374. +++ b/drivers/usb/host/xhci.h
  2375. @@ -1558,6 +1558,8 @@ struct xhci_hcd {
  2376. #define XHCI_PLAT (1 << 16)
  2377. #define XHCI_SLOW_SUSPEND (1 << 17)
  2378. #define XHCI_SPURIOUS_WAKEUP (1 << 18)
  2379. +/* For controllers with a broken beyond repair streams implementation */
  2380. +#define XHCI_BROKEN_STREAMS (1 << 19)
  2381. unsigned int num_active_eps;
  2382. unsigned int limit_active_eps;
  2383. /* There are two roothubs to keep track of bus suspend info for */
  2384. diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
  2385. index 8a3813be1b28..8b0f517abb6b 100644
  2386. --- a/drivers/usb/serial/ftdi_sio.c
  2387. +++ b/drivers/usb/serial/ftdi_sio.c
  2388. @@ -151,6 +151,7 @@ static const struct usb_device_id id_table_combined[] = {
  2389. { USB_DEVICE(FTDI_VID, FTDI_AMC232_PID) },
  2390. { USB_DEVICE(FTDI_VID, FTDI_CANUSB_PID) },
  2391. { USB_DEVICE(FTDI_VID, FTDI_CANDAPTER_PID) },
  2392. + { USB_DEVICE(FTDI_VID, FTDI_BM_ATOM_NANO_PID) },
  2393. { USB_DEVICE(FTDI_VID, FTDI_NXTCAM_PID) },
  2394. { USB_DEVICE(FTDI_VID, FTDI_EV3CON_PID) },
  2395. { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_0_PID) },
  2396. @@ -673,6 +674,8 @@ static const struct usb_device_id id_table_combined[] = {
  2397. { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_5_PID) },
  2398. { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_6_PID) },
  2399. { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_7_PID) },
  2400. + { USB_DEVICE(XSENS_VID, XSENS_CONVERTER_PID) },
  2401. + { USB_DEVICE(XSENS_VID, XSENS_MTW_PID) },
  2402. { USB_DEVICE(FTDI_VID, FTDI_OMNI1509) },
  2403. { USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) },
  2404. { USB_DEVICE(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID) },
  2405. @@ -945,6 +948,8 @@ static const struct usb_device_id id_table_combined[] = {
  2406. { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_2_PID) },
  2407. { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_3_PID) },
  2408. { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_4_PID) },
  2409. + /* ekey Devices */
  2410. + { USB_DEVICE(FTDI_VID, FTDI_EKEY_CONV_USB_PID) },
  2411. /* Infineon Devices */
  2412. { USB_DEVICE_INTERFACE_NUMBER(INFINEON_VID, INFINEON_TRIBOARD_PID, 1) },
  2413. { } /* Terminating entry */
  2414. diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
  2415. index c4777bc6aee0..70b0b1d88ae9 100644
  2416. --- a/drivers/usb/serial/ftdi_sio_ids.h
  2417. +++ b/drivers/usb/serial/ftdi_sio_ids.h
  2418. @@ -42,6 +42,8 @@
  2419. /* www.candapter.com Ewert Energy Systems CANdapter device */
  2420. #define FTDI_CANDAPTER_PID 0x9F80 /* Product Id */
  2421. +#define FTDI_BM_ATOM_NANO_PID 0xa559 /* Basic Micro ATOM Nano USB2Serial */
  2422. +
  2423. /*
  2424. * Texas Instruments XDS100v2 JTAG / BeagleBone A3
  2425. * http://processors.wiki.ti.com/index.php/XDS100
  2426. @@ -140,12 +142,15 @@
  2427. /*
  2428. * Xsens Technologies BV products (http://www.xsens.com).
  2429. */
  2430. -#define XSENS_CONVERTER_0_PID 0xD388
  2431. -#define XSENS_CONVERTER_1_PID 0xD389
  2432. +#define XSENS_VID 0x2639
  2433. +#define XSENS_CONVERTER_PID 0xD00D /* Xsens USB-serial converter */
  2434. +#define XSENS_MTW_PID 0x0200 /* Xsens MTw */
  2435. +#define XSENS_CONVERTER_0_PID 0xD388 /* Xsens USB converter */
  2436. +#define XSENS_CONVERTER_1_PID 0xD389 /* Xsens Wireless Receiver */
  2437. #define XSENS_CONVERTER_2_PID 0xD38A
  2438. -#define XSENS_CONVERTER_3_PID 0xD38B
  2439. -#define XSENS_CONVERTER_4_PID 0xD38C
  2440. -#define XSENS_CONVERTER_5_PID 0xD38D
  2441. +#define XSENS_CONVERTER_3_PID 0xD38B /* Xsens USB-serial converter */
  2442. +#define XSENS_CONVERTER_4_PID 0xD38C /* Xsens Wireless Receiver */
  2443. +#define XSENS_CONVERTER_5_PID 0xD38D /* Xsens Awinda Station */
  2444. #define XSENS_CONVERTER_6_PID 0xD38E
  2445. #define XSENS_CONVERTER_7_PID 0xD38F
  2446. @@ -1375,3 +1380,8 @@
  2447. #define BRAINBOXES_US_160_6_PID 0x9006 /* US-160 16xRS232 1Mbaud Port 11 and 12 */
  2448. #define BRAINBOXES_US_160_7_PID 0x9007 /* US-160 16xRS232 1Mbaud Port 13 and 14 */
  2449. #define BRAINBOXES_US_160_8_PID 0x9008 /* US-160 16xRS232 1Mbaud Port 15 and 16 */
  2450. +
  2451. +/*
  2452. + * ekey biometric systems GmbH (http://ekey.net/)
  2453. + */
  2454. +#define FTDI_EKEY_CONV_USB_PID 0xCB08 /* Converter USB */
  2455. diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
  2456. index e62f2dff8b7d..6c3734d2b45a 100644
  2457. --- a/drivers/usb/serial/whiteheat.c
  2458. +++ b/drivers/usb/serial/whiteheat.c
  2459. @@ -514,6 +514,10 @@ static void command_port_read_callback(struct urb *urb)
  2460. dev_dbg(&urb->dev->dev, "%s - command_info is NULL, exiting.\n", __func__);
  2461. return;
  2462. }
  2463. + if (!urb->actual_length) {
  2464. + dev_dbg(&urb->dev->dev, "%s - empty response, exiting.\n", __func__);
  2465. + return;
  2466. + }
  2467. if (status) {
  2468. dev_dbg(&urb->dev->dev, "%s - nonzero urb status: %d\n", __func__, status);
  2469. if (status != -ENOENT)
  2470. @@ -534,7 +538,8 @@ static void command_port_read_callback(struct urb *urb)
  2471. /* These are unsolicited reports from the firmware, hence no
  2472. waiting command to wakeup */
  2473. dev_dbg(&urb->dev->dev, "%s - event received\n", __func__);
  2474. - } else if (data[0] == WHITEHEAT_GET_DTR_RTS) {
  2475. + } else if ((data[0] == WHITEHEAT_GET_DTR_RTS) &&
  2476. + (urb->actual_length - 1 <= sizeof(command_info->result_buffer))) {
  2477. memcpy(command_info->result_buffer, &data[1],
  2478. urb->actual_length - 1);
  2479. command_info->command_finished = WHITEHEAT_CMD_COMPLETE;
  2480. diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
  2481. index 511b22953167..3f42785f653c 100644
  2482. --- a/drivers/usb/storage/uas.c
  2483. +++ b/drivers/usb/storage/uas.c
  2484. @@ -1026,7 +1026,7 @@ static int uas_configure_endpoints(struct uas_dev_info *devinfo)
  2485. usb_endpoint_num(&eps[3]->desc));
  2486. if (udev->speed != USB_SPEED_SUPER) {
  2487. - devinfo->qdepth = 256;
  2488. + devinfo->qdepth = 32;
  2489. devinfo->use_streams = 0;
  2490. } else {
  2491. devinfo->qdepth = usb_alloc_streams(devinfo->intf, eps + 1,
  2492. diff --git a/drivers/xen/events/events_fifo.c b/drivers/xen/events/events_fifo.c
  2493. index 84b4bfb84344..500713882ad5 100644
  2494. --- a/drivers/xen/events/events_fifo.c
  2495. +++ b/drivers/xen/events/events_fifo.c
  2496. @@ -67,10 +67,9 @@ static event_word_t *event_array[MAX_EVENT_ARRAY_PAGES] __read_mostly;
  2497. static unsigned event_array_pages __read_mostly;
  2498. /*
  2499. - * sync_set_bit() and friends must be unsigned long aligned on non-x86
  2500. - * platforms.
  2501. + * sync_set_bit() and friends must be unsigned long aligned.
  2502. */
  2503. -#if !defined(CONFIG_X86) && BITS_PER_LONG > 32
  2504. +#if BITS_PER_LONG > 32
  2505. #define BM(w) (unsigned long *)((unsigned long)w & ~0x7UL)
  2506. #define EVTCHN_FIFO_BIT(b, w) \
  2507. diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
  2508. index 5a201d81049c..fbd76ded9a34 100644
  2509. --- a/fs/btrfs/async-thread.c
  2510. +++ b/fs/btrfs/async-thread.c
  2511. @@ -22,7 +22,6 @@
  2512. #include <linux/list.h>
  2513. #include <linux/spinlock.h>
  2514. #include <linux/freezer.h>
  2515. -#include <linux/workqueue.h>
  2516. #include "async-thread.h"
  2517. #include "ctree.h"
  2518. @@ -55,8 +54,39 @@ struct btrfs_workqueue {
  2519. struct __btrfs_workqueue *high;
  2520. };
  2521. -static inline struct __btrfs_workqueue
  2522. -*__btrfs_alloc_workqueue(const char *name, int flags, int max_active,
  2523. +static void normal_work_helper(struct btrfs_work *work);
  2524. +
  2525. +#define BTRFS_WORK_HELPER(name) \
  2526. +void btrfs_##name(struct work_struct *arg) \
  2527. +{ \
  2528. + struct btrfs_work *work = container_of(arg, struct btrfs_work, \
  2529. + normal_work); \
  2530. + normal_work_helper(work); \
  2531. +}
  2532. +
  2533. +BTRFS_WORK_HELPER(worker_helper);
  2534. +BTRFS_WORK_HELPER(delalloc_helper);
  2535. +BTRFS_WORK_HELPER(flush_delalloc_helper);
  2536. +BTRFS_WORK_HELPER(cache_helper);
  2537. +BTRFS_WORK_HELPER(submit_helper);
  2538. +BTRFS_WORK_HELPER(fixup_helper);
  2539. +BTRFS_WORK_HELPER(endio_helper);
  2540. +BTRFS_WORK_HELPER(endio_meta_helper);
  2541. +BTRFS_WORK_HELPER(endio_meta_write_helper);
  2542. +BTRFS_WORK_HELPER(endio_raid56_helper);
  2543. +BTRFS_WORK_HELPER(rmw_helper);
  2544. +BTRFS_WORK_HELPER(endio_write_helper);
  2545. +BTRFS_WORK_HELPER(freespace_write_helper);
  2546. +BTRFS_WORK_HELPER(delayed_meta_helper);
  2547. +BTRFS_WORK_HELPER(readahead_helper);
  2548. +BTRFS_WORK_HELPER(qgroup_rescan_helper);
  2549. +BTRFS_WORK_HELPER(extent_refs_helper);
  2550. +BTRFS_WORK_HELPER(scrub_helper);
  2551. +BTRFS_WORK_HELPER(scrubwrc_helper);
  2552. +BTRFS_WORK_HELPER(scrubnc_helper);
  2553. +
  2554. +static struct __btrfs_workqueue *
  2555. +__btrfs_alloc_workqueue(const char *name, int flags, int max_active,
  2556. int thresh)
  2557. {
  2558. struct __btrfs_workqueue *ret = kzalloc(sizeof(*ret), GFP_NOFS);
  2559. @@ -232,13 +262,11 @@ static void run_ordered_work(struct __btrfs_workqueue *wq)
  2560. spin_unlock_irqrestore(lock, flags);
  2561. }
  2562. -static void normal_work_helper(struct work_struct *arg)
  2563. +static void normal_work_helper(struct btrfs_work *work)
  2564. {
  2565. - struct btrfs_work *work;
  2566. struct __btrfs_workqueue *wq;
  2567. int need_order = 0;
  2568. - work = container_of(arg, struct btrfs_work, normal_work);
  2569. /*
  2570. * We should not touch things inside work in the following cases:
  2571. * 1) after work->func() if it has no ordered_free
  2572. @@ -262,7 +290,7 @@ static void normal_work_helper(struct work_struct *arg)
  2573. trace_btrfs_all_work_done(work);
  2574. }
  2575. -void btrfs_init_work(struct btrfs_work *work,
  2576. +void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t uniq_func,
  2577. btrfs_func_t func,
  2578. btrfs_func_t ordered_func,
  2579. btrfs_func_t ordered_free)
  2580. @@ -270,7 +298,7 @@ void btrfs_init_work(struct btrfs_work *work,
  2581. work->func = func;
  2582. work->ordered_func = ordered_func;
  2583. work->ordered_free = ordered_free;
  2584. - INIT_WORK(&work->normal_work, normal_work_helper);
  2585. + INIT_WORK(&work->normal_work, uniq_func);
  2586. INIT_LIST_HEAD(&work->ordered_list);
  2587. work->flags = 0;
  2588. }
  2589. diff --git a/fs/btrfs/async-thread.h b/fs/btrfs/async-thread.h
  2590. index 9c6b66d15fb0..e9e31c94758f 100644
  2591. --- a/fs/btrfs/async-thread.h
  2592. +++ b/fs/btrfs/async-thread.h
  2593. @@ -19,12 +19,14 @@
  2594. #ifndef __BTRFS_ASYNC_THREAD_
  2595. #define __BTRFS_ASYNC_THREAD_
  2596. +#include <linux/workqueue.h>
  2597. struct btrfs_workqueue;
  2598. /* Internal use only */
  2599. struct __btrfs_workqueue;
  2600. struct btrfs_work;
  2601. typedef void (*btrfs_func_t)(struct btrfs_work *arg);
  2602. +typedef void (*btrfs_work_func_t)(struct work_struct *arg);
  2603. struct btrfs_work {
  2604. btrfs_func_t func;
  2605. @@ -38,11 +40,35 @@ struct btrfs_work {
  2606. unsigned long flags;
  2607. };
  2608. +#define BTRFS_WORK_HELPER_PROTO(name) \
  2609. +void btrfs_##name(struct work_struct *arg)
  2610. +
  2611. +BTRFS_WORK_HELPER_PROTO(worker_helper);
  2612. +BTRFS_WORK_HELPER_PROTO(delalloc_helper);
  2613. +BTRFS_WORK_HELPER_PROTO(flush_delalloc_helper);
  2614. +BTRFS_WORK_HELPER_PROTO(cache_helper);
  2615. +BTRFS_WORK_HELPER_PROTO(submit_helper);
  2616. +BTRFS_WORK_HELPER_PROTO(fixup_helper);
  2617. +BTRFS_WORK_HELPER_PROTO(endio_helper);
  2618. +BTRFS_WORK_HELPER_PROTO(endio_meta_helper);
  2619. +BTRFS_WORK_HELPER_PROTO(endio_meta_write_helper);
  2620. +BTRFS_WORK_HELPER_PROTO(endio_raid56_helper);
  2621. +BTRFS_WORK_HELPER_PROTO(rmw_helper);
  2622. +BTRFS_WORK_HELPER_PROTO(endio_write_helper);
  2623. +BTRFS_WORK_HELPER_PROTO(freespace_write_helper);
  2624. +BTRFS_WORK_HELPER_PROTO(delayed_meta_helper);
  2625. +BTRFS_WORK_HELPER_PROTO(readahead_helper);
  2626. +BTRFS_WORK_HELPER_PROTO(qgroup_rescan_helper);
  2627. +BTRFS_WORK_HELPER_PROTO(extent_refs_helper);
  2628. +BTRFS_WORK_HELPER_PROTO(scrub_helper);
  2629. +BTRFS_WORK_HELPER_PROTO(scrubwrc_helper);
  2630. +BTRFS_WORK_HELPER_PROTO(scrubnc_helper);
  2631. +
  2632. struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name,
  2633. int flags,
  2634. int max_active,
  2635. int thresh);
  2636. -void btrfs_init_work(struct btrfs_work *work,
  2637. +void btrfs_init_work(struct btrfs_work *work, btrfs_work_func_t helper,
  2638. btrfs_func_t func,
  2639. btrfs_func_t ordered_func,
  2640. btrfs_func_t ordered_free);
  2641. diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
  2642. index e25564bfcb46..54a201dac7f9 100644
  2643. --- a/fs/btrfs/backref.c
  2644. +++ b/fs/btrfs/backref.c
  2645. @@ -276,9 +276,8 @@ static int add_all_parents(struct btrfs_root *root, struct btrfs_path *path,
  2646. }
  2647. if (ret > 0)
  2648. goto next;
  2649. - ret = ulist_add_merge(parents, eb->start,
  2650. - (uintptr_t)eie,
  2651. - (u64 *)&old, GFP_NOFS);
  2652. + ret = ulist_add_merge_ptr(parents, eb->start,
  2653. + eie, (void **)&old, GFP_NOFS);
  2654. if (ret < 0)
  2655. break;
  2656. if (!ret && extent_item_pos) {
  2657. @@ -1001,16 +1000,19 @@ again:
  2658. ret = -EIO;
  2659. goto out;
  2660. }
  2661. + btrfs_tree_read_lock(eb);
  2662. + btrfs_set_lock_blocking_rw(eb, BTRFS_READ_LOCK);
  2663. ret = find_extent_in_eb(eb, bytenr,
  2664. *extent_item_pos, &eie);
  2665. + btrfs_tree_read_unlock_blocking(eb);
  2666. free_extent_buffer(eb);
  2667. if (ret < 0)
  2668. goto out;
  2669. ref->inode_list = eie;
  2670. }
  2671. - ret = ulist_add_merge(refs, ref->parent,
  2672. - (uintptr_t)ref->inode_list,
  2673. - (u64 *)&eie, GFP_NOFS);
  2674. + ret = ulist_add_merge_ptr(refs, ref->parent,
  2675. + ref->inode_list,
  2676. + (void **)&eie, GFP_NOFS);
  2677. if (ret < 0)
  2678. goto out;
  2679. if (!ret && extent_item_pos) {
  2680. diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
  2681. index 4794923c410c..43527fd78825 100644
  2682. --- a/fs/btrfs/btrfs_inode.h
  2683. +++ b/fs/btrfs/btrfs_inode.h
  2684. @@ -84,12 +84,6 @@ struct btrfs_inode {
  2685. */
  2686. struct list_head delalloc_inodes;
  2687. - /*
  2688. - * list for tracking inodes that must be sent to disk before a
  2689. - * rename or truncate commit
  2690. - */
  2691. - struct list_head ordered_operations;
  2692. -
  2693. /* node for the red-black tree that links inodes in subvolume root */
  2694. struct rb_node rb_node;
  2695. diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
  2696. index da775bfdebc9..a2e90f855d7d 100644
  2697. --- a/fs/btrfs/delayed-inode.c
  2698. +++ b/fs/btrfs/delayed-inode.c
  2699. @@ -1395,8 +1395,8 @@ static int btrfs_wq_run_delayed_node(struct btrfs_delayed_root *delayed_root,
  2700. return -ENOMEM;
  2701. async_work->delayed_root = delayed_root;
  2702. - btrfs_init_work(&async_work->work, btrfs_async_run_delayed_root,
  2703. - NULL, NULL);
  2704. + btrfs_init_work(&async_work->work, btrfs_delayed_meta_helper,
  2705. + btrfs_async_run_delayed_root, NULL, NULL);
  2706. async_work->nr = nr;
  2707. btrfs_queue_work(root->fs_info->delayed_workers, &async_work->work);
  2708. diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
  2709. index 08e65e9cf2aa..0229c3720b30 100644
  2710. --- a/fs/btrfs/disk-io.c
  2711. +++ b/fs/btrfs/disk-io.c
  2712. @@ -39,7 +39,6 @@
  2713. #include "btrfs_inode.h"
  2714. #include "volumes.h"
  2715. #include "print-tree.h"
  2716. -#include "async-thread.h"
  2717. #include "locking.h"
  2718. #include "tree-log.h"
  2719. #include "free-space-cache.h"
  2720. @@ -60,8 +59,6 @@ static void end_workqueue_fn(struct btrfs_work *work);
  2721. static void free_fs_root(struct btrfs_root *root);
  2722. static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
  2723. int read_only);
  2724. -static void btrfs_destroy_ordered_operations(struct btrfs_transaction *t,
  2725. - struct btrfs_root *root);
  2726. static void btrfs_destroy_ordered_extents(struct btrfs_root *root);
  2727. static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
  2728. struct btrfs_root *root);
  2729. @@ -695,35 +692,41 @@ static void end_workqueue_bio(struct bio *bio, int err)
  2730. {
  2731. struct end_io_wq *end_io_wq = bio->bi_private;
  2732. struct btrfs_fs_info *fs_info;
  2733. + struct btrfs_workqueue *wq;
  2734. + btrfs_work_func_t func;
  2735. fs_info = end_io_wq->info;
  2736. end_io_wq->error = err;
  2737. - btrfs_init_work(&end_io_wq->work, end_workqueue_fn, NULL, NULL);
  2738. if (bio->bi_rw & REQ_WRITE) {
  2739. - if (end_io_wq->metadata == BTRFS_WQ_ENDIO_METADATA)
  2740. - btrfs_queue_work(fs_info->endio_meta_write_workers,
  2741. - &end_io_wq->work);
  2742. - else if (end_io_wq->metadata == BTRFS_WQ_ENDIO_FREE_SPACE)
  2743. - btrfs_queue_work(fs_info->endio_freespace_worker,
  2744. - &end_io_wq->work);
  2745. - else if (end_io_wq->metadata == BTRFS_WQ_ENDIO_RAID56)
  2746. - btrfs_queue_work(fs_info->endio_raid56_workers,
  2747. - &end_io_wq->work);
  2748. - else
  2749. - btrfs_queue_work(fs_info->endio_write_workers,
  2750. - &end_io_wq->work);
  2751. + if (end_io_wq->metadata == BTRFS_WQ_ENDIO_METADATA) {
  2752. + wq = fs_info->endio_meta_write_workers;
  2753. + func = btrfs_endio_meta_write_helper;
  2754. + } else if (end_io_wq->metadata == BTRFS_WQ_ENDIO_FREE_SPACE) {
  2755. + wq = fs_info->endio_freespace_worker;
  2756. + func = btrfs_freespace_write_helper;
  2757. + } else if (end_io_wq->metadata == BTRFS_WQ_ENDIO_RAID56) {
  2758. + wq = fs_info->endio_raid56_workers;
  2759. + func = btrfs_endio_raid56_helper;
  2760. + } else {
  2761. + wq = fs_info->endio_write_workers;
  2762. + func = btrfs_endio_write_helper;
  2763. + }
  2764. } else {
  2765. - if (end_io_wq->metadata == BTRFS_WQ_ENDIO_RAID56)
  2766. - btrfs_queue_work(fs_info->endio_raid56_workers,
  2767. - &end_io_wq->work);
  2768. - else if (end_io_wq->metadata)
  2769. - btrfs_queue_work(fs_info->endio_meta_workers,
  2770. - &end_io_wq->work);
  2771. - else
  2772. - btrfs_queue_work(fs_info->endio_workers,
  2773. - &end_io_wq->work);
  2774. + if (end_io_wq->metadata == BTRFS_WQ_ENDIO_RAID56) {
  2775. + wq = fs_info->endio_raid56_workers;
  2776. + func = btrfs_endio_raid56_helper;
  2777. + } else if (end_io_wq->metadata) {
  2778. + wq = fs_info->endio_meta_workers;
  2779. + func = btrfs_endio_meta_helper;
  2780. + } else {
  2781. + wq = fs_info->endio_workers;
  2782. + func = btrfs_endio_helper;
  2783. + }
  2784. }
  2785. +
  2786. + btrfs_init_work(&end_io_wq->work, func, end_workqueue_fn, NULL, NULL);
  2787. + btrfs_queue_work(wq, &end_io_wq->work);
  2788. }
  2789. /*
  2790. @@ -830,7 +833,7 @@ int btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct inode *inode,
  2791. async->submit_bio_start = submit_bio_start;
  2792. async->submit_bio_done = submit_bio_done;
  2793. - btrfs_init_work(&async->work, run_one_async_start,
  2794. + btrfs_init_work(&async->work, btrfs_worker_helper, run_one_async_start,
  2795. run_one_async_done, run_one_async_free);
  2796. async->bio_flags = bio_flags;
  2797. @@ -3829,34 +3832,6 @@ static void btrfs_error_commit_super(struct btrfs_root *root)
  2798. btrfs_cleanup_transaction(root);
  2799. }
  2800. -static void btrfs_destroy_ordered_operations(struct btrfs_transaction *t,
  2801. - struct btrfs_root *root)
  2802. -{
  2803. - struct btrfs_inode *btrfs_inode;
  2804. - struct list_head splice;
  2805. -
  2806. - INIT_LIST_HEAD(&splice);
  2807. -
  2808. - mutex_lock(&root->fs_info->ordered_operations_mutex);
  2809. - spin_lock(&root->fs_info->ordered_root_lock);
  2810. -
  2811. - list_splice_init(&t->ordered_operations, &splice);
  2812. - while (!list_empty(&splice)) {
  2813. - btrfs_inode = list_entry(splice.next, struct btrfs_inode,
  2814. - ordered_operations);
  2815. -
  2816. - list_del_init(&btrfs_inode->ordered_operations);
  2817. - spin_unlock(&root->fs_info->ordered_root_lock);
  2818. -
  2819. - btrfs_invalidate_inodes(btrfs_inode->root);
  2820. -
  2821. - spin_lock(&root->fs_info->ordered_root_lock);
  2822. - }
  2823. -
  2824. - spin_unlock(&root->fs_info->ordered_root_lock);
  2825. - mutex_unlock(&root->fs_info->ordered_operations_mutex);
  2826. -}
  2827. -
  2828. static void btrfs_destroy_ordered_extents(struct btrfs_root *root)
  2829. {
  2830. struct btrfs_ordered_extent *ordered;
  2831. @@ -4093,8 +4068,6 @@ again:
  2832. void btrfs_cleanup_one_transaction(struct btrfs_transaction *cur_trans,
  2833. struct btrfs_root *root)
  2834. {
  2835. - btrfs_destroy_ordered_operations(cur_trans, root);
  2836. -
  2837. btrfs_destroy_delayed_refs(cur_trans, root);
  2838. cur_trans->state = TRANS_STATE_COMMIT_START;
  2839. diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
  2840. index 813537f362f9..8edb9fcc38d5 100644
  2841. --- a/fs/btrfs/extent-tree.c
  2842. +++ b/fs/btrfs/extent-tree.c
  2843. @@ -552,7 +552,8 @@ static int cache_block_group(struct btrfs_block_group_cache *cache,
  2844. caching_ctl->block_group = cache;
  2845. caching_ctl->progress = cache->key.objectid;
  2846. atomic_set(&caching_ctl->count, 1);
  2847. - btrfs_init_work(&caching_ctl->work, caching_thread, NULL, NULL);
  2848. + btrfs_init_work(&caching_ctl->work, btrfs_cache_helper,
  2849. + caching_thread, NULL, NULL);
  2850. spin_lock(&cache->lock);
  2851. /*
  2852. @@ -2749,8 +2750,8 @@ int btrfs_async_run_delayed_refs(struct btrfs_root *root,
  2853. async->sync = 0;
  2854. init_completion(&async->wait);
  2855. - btrfs_init_work(&async->work, delayed_ref_async_start,
  2856. - NULL, NULL);
  2857. + btrfs_init_work(&async->work, btrfs_extent_refs_helper,
  2858. + delayed_ref_async_start, NULL, NULL);
  2859. btrfs_queue_work(root->fs_info->extent_workers, &async->work);
  2860. diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
  2861. index a389820d158b..09b4e3165e2c 100644
  2862. --- a/fs/btrfs/extent_io.c
  2863. +++ b/fs/btrfs/extent_io.c
  2864. @@ -2532,6 +2532,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err)
  2865. test_bit(BIO_UPTODATE, &bio->bi_flags);
  2866. if (err)
  2867. uptodate = 0;
  2868. + offset += len;
  2869. continue;
  2870. }
  2871. }
  2872. diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
  2873. index f46cfe45d686..54c84daec9b5 100644
  2874. --- a/fs/btrfs/file-item.c
  2875. +++ b/fs/btrfs/file-item.c
  2876. @@ -756,7 +756,7 @@ again:
  2877. found_next = 1;
  2878. if (ret != 0)
  2879. goto insert;
  2880. - slot = 0;
  2881. + slot = path->slots[0];
  2882. }
  2883. btrfs_item_key_to_cpu(path->nodes[0], &found_key, slot);
  2884. if (found_key.objectid != BTRFS_EXTENT_CSUM_OBJECTID ||
  2885. diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
  2886. index 1f2b99cb55ea..ab1fd668020d 100644
  2887. --- a/fs/btrfs/file.c
  2888. +++ b/fs/btrfs/file.c
  2889. @@ -1838,6 +1838,8 @@ out:
  2890. int btrfs_release_file(struct inode *inode, struct file *filp)
  2891. {
  2892. + if (filp->private_data)
  2893. + btrfs_ioctl_trans_end(filp);
  2894. /*
  2895. * ordered_data_close is set by settattr when we are about to truncate
  2896. * a file from a non-zero size to a zero size. This tries to
  2897. @@ -1845,26 +1847,8 @@ int btrfs_release_file(struct inode *inode, struct file *filp)
  2898. * application were using truncate to replace a file in place.
  2899. */
  2900. if (test_and_clear_bit(BTRFS_INODE_ORDERED_DATA_CLOSE,
  2901. - &BTRFS_I(inode)->runtime_flags)) {
  2902. - struct btrfs_trans_handle *trans;
  2903. - struct btrfs_root *root = BTRFS_I(inode)->root;
  2904. -
  2905. - /*
  2906. - * We need to block on a committing transaction to keep us from
  2907. - * throwing a ordered operation on to the list and causing
  2908. - * something like sync to deadlock trying to flush out this
  2909. - * inode.
  2910. - */
  2911. - trans = btrfs_start_transaction(root, 0);
  2912. - if (IS_ERR(trans))
  2913. - return PTR_ERR(trans);
  2914. - btrfs_add_ordered_operation(trans, BTRFS_I(inode)->root, inode);
  2915. - btrfs_end_transaction(trans, root);
  2916. - if (inode->i_size > BTRFS_ORDERED_OPERATIONS_FLUSH_LIMIT)
  2917. + &BTRFS_I(inode)->runtime_flags))
  2918. filemap_flush(inode->i_mapping);
  2919. - }
  2920. - if (filp->private_data)
  2921. - btrfs_ioctl_trans_end(filp);
  2922. return 0;
  2923. }
  2924. diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
  2925. index 3668048e16f8..c6cd34e699d0 100644
  2926. --- a/fs/btrfs/inode.c
  2927. +++ b/fs/btrfs/inode.c
  2928. @@ -709,6 +709,18 @@ retry:
  2929. unlock_extent(io_tree, async_extent->start,
  2930. async_extent->start +
  2931. async_extent->ram_size - 1);
  2932. +
  2933. + /*
  2934. + * we need to redirty the pages if we decide to
  2935. + * fallback to uncompressed IO, otherwise we
  2936. + * will not submit these pages down to lower
  2937. + * layers.
  2938. + */
  2939. + extent_range_redirty_for_io(inode,
  2940. + async_extent->start,
  2941. + async_extent->start +
  2942. + async_extent->ram_size - 1);
  2943. +
  2944. goto retry;
  2945. }
  2946. goto out_free;
  2947. @@ -1084,8 +1096,10 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page,
  2948. async_cow->end = cur_end;
  2949. INIT_LIST_HEAD(&async_cow->extents);
  2950. - btrfs_init_work(&async_cow->work, async_cow_start,
  2951. - async_cow_submit, async_cow_free);
  2952. + btrfs_init_work(&async_cow->work,
  2953. + btrfs_delalloc_helper,
  2954. + async_cow_start, async_cow_submit,
  2955. + async_cow_free);
  2956. nr_pages = (cur_end - start + PAGE_CACHE_SIZE) >>
  2957. PAGE_CACHE_SHIFT;
  2958. @@ -1869,7 +1883,8 @@ static int btrfs_writepage_start_hook(struct page *page, u64 start, u64 end)
  2959. SetPageChecked(page);
  2960. page_cache_get(page);
  2961. - btrfs_init_work(&fixup->work, btrfs_writepage_fixup_worker, NULL, NULL);
  2962. + btrfs_init_work(&fixup->work, btrfs_fixup_helper,
  2963. + btrfs_writepage_fixup_worker, NULL, NULL);
  2964. fixup->page = page;
  2965. btrfs_queue_work(root->fs_info->fixup_workers, &fixup->work);
  2966. return -EBUSY;
  2967. @@ -2810,7 +2825,8 @@ static int btrfs_writepage_end_io_hook(struct page *page, u64 start, u64 end,
  2968. struct inode *inode = page->mapping->host;
  2969. struct btrfs_root *root = BTRFS_I(inode)->root;
  2970. struct btrfs_ordered_extent *ordered_extent = NULL;
  2971. - struct btrfs_workqueue *workers;
  2972. + struct btrfs_workqueue *wq;
  2973. + btrfs_work_func_t func;
  2974. trace_btrfs_writepage_end_io_hook(page, start, end, uptodate);
  2975. @@ -2819,13 +2835,17 @@ static int btrfs_writepage_end_io_hook(struct page *page, u64 start, u64 end,
  2976. end - start + 1, uptodate))
  2977. return 0;
  2978. - btrfs_init_work(&ordered_extent->work, finish_ordered_fn, NULL, NULL);
  2979. + if (btrfs_is_free_space_inode(inode)) {
  2980. + wq = root->fs_info->endio_freespace_worker;
  2981. + func = btrfs_freespace_write_helper;
  2982. + } else {
  2983. + wq = root->fs_info->endio_write_workers;
  2984. + func = btrfs_endio_write_helper;
  2985. + }
  2986. - if (btrfs_is_free_space_inode(inode))
  2987. - workers = root->fs_info->endio_freespace_worker;
  2988. - else
  2989. - workers = root->fs_info->endio_write_workers;
  2990. - btrfs_queue_work(workers, &ordered_extent->work);
  2991. + btrfs_init_work(&ordered_extent->work, func, finish_ordered_fn, NULL,
  2992. + NULL);
  2993. + btrfs_queue_work(wq, &ordered_extent->work);
  2994. return 0;
  2995. }
  2996. @@ -7146,7 +7166,8 @@ again:
  2997. if (!ret)
  2998. goto out_test;
  2999. - btrfs_init_work(&ordered->work, finish_ordered_fn, NULL, NULL);
  3000. + btrfs_init_work(&ordered->work, btrfs_endio_write_helper,
  3001. + finish_ordered_fn, NULL, NULL);
  3002. btrfs_queue_work(root->fs_info->endio_write_workers,
  3003. &ordered->work);
  3004. out_test:
  3005. @@ -7939,27 +7960,6 @@ static int btrfs_truncate(struct inode *inode)
  3006. BUG_ON(ret);
  3007. /*
  3008. - * setattr is responsible for setting the ordered_data_close flag,
  3009. - * but that is only tested during the last file release. That
  3010. - * could happen well after the next commit, leaving a great big
  3011. - * window where new writes may get lost if someone chooses to write
  3012. - * to this file after truncating to zero
  3013. - *
  3014. - * The inode doesn't have any dirty data here, and so if we commit
  3015. - * this is a noop. If someone immediately starts writing to the inode
  3016. - * it is very likely we'll catch some of their writes in this
  3017. - * transaction, and the commit will find this file on the ordered
  3018. - * data list with good things to send down.
  3019. - *
  3020. - * This is a best effort solution, there is still a window where
  3021. - * using truncate to replace the contents of the file will
  3022. - * end up with a zero length file after a crash.
  3023. - */
  3024. - if (inode->i_size == 0 && test_bit(BTRFS_INODE_ORDERED_DATA_CLOSE,
  3025. - &BTRFS_I(inode)->runtime_flags))
  3026. - btrfs_add_ordered_operation(trans, root, inode);
  3027. -
  3028. - /*
  3029. * So if we truncate and then write and fsync we normally would just
  3030. * write the extents that changed, which is a problem if we need to
  3031. * first truncate that entire inode. So set this flag so we write out
  3032. @@ -8106,7 +8106,6 @@ struct inode *btrfs_alloc_inode(struct super_block *sb)
  3033. mutex_init(&ei->delalloc_mutex);
  3034. btrfs_ordered_inode_tree_init(&ei->ordered_tree);
  3035. INIT_LIST_HEAD(&ei->delalloc_inodes);
  3036. - INIT_LIST_HEAD(&ei->ordered_operations);
  3037. RB_CLEAR_NODE(&ei->rb_node);
  3038. return inode;
  3039. @@ -8146,17 +8145,6 @@ void btrfs_destroy_inode(struct inode *inode)
  3040. if (!root)
  3041. goto free;
  3042. - /*
  3043. - * Make sure we're properly removed from the ordered operation
  3044. - * lists.
  3045. - */
  3046. - smp_mb();
  3047. - if (!list_empty(&BTRFS_I(inode)->ordered_operations)) {
  3048. - spin_lock(&root->fs_info->ordered_root_lock);
  3049. - list_del_init(&BTRFS_I(inode)->ordered_operations);
  3050. - spin_unlock(&root->fs_info->ordered_root_lock);
  3051. - }
  3052. -
  3053. if (test_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,
  3054. &BTRFS_I(inode)->runtime_flags)) {
  3055. btrfs_info(root->fs_info, "inode %llu still on the orphan list",
  3056. @@ -8338,12 +8326,10 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
  3057. ret = 0;
  3058. /*
  3059. - * we're using rename to replace one file with another.
  3060. - * and the replacement file is large. Start IO on it now so
  3061. - * we don't add too much work to the end of the transaction
  3062. + * we're using rename to replace one file with another. Start IO on it
  3063. + * now so we don't add too much work to the end of the transaction
  3064. */
  3065. - if (new_inode && S_ISREG(old_inode->i_mode) && new_inode->i_size &&
  3066. - old_inode->i_size > BTRFS_ORDERED_OPERATIONS_FLUSH_LIMIT)
  3067. + if (new_inode && S_ISREG(old_inode->i_mode) && new_inode->i_size)
  3068. filemap_flush(old_inode->i_mapping);
  3069. /* close the racy window with snapshot create/destroy ioctl */
  3070. @@ -8391,12 +8377,6 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
  3071. */
  3072. btrfs_pin_log_trans(root);
  3073. }
  3074. - /*
  3075. - * make sure the inode gets flushed if it is replacing
  3076. - * something.
  3077. - */
  3078. - if (new_inode && new_inode->i_size && S_ISREG(old_inode->i_mode))
  3079. - btrfs_add_ordered_operation(trans, root, old_inode);
  3080. inode_inc_iversion(old_dir);
  3081. inode_inc_iversion(new_dir);
  3082. @@ -8514,7 +8494,9 @@ struct btrfs_delalloc_work *btrfs_alloc_delalloc_work(struct inode *inode,
  3083. work->inode = inode;
  3084. work->wait = wait;
  3085. work->delay_iput = delay_iput;
  3086. - btrfs_init_work(&work->work, btrfs_run_delalloc_work, NULL, NULL);
  3087. + WARN_ON_ONCE(!inode);
  3088. + btrfs_init_work(&work->work, btrfs_flush_delalloc_helper,
  3089. + btrfs_run_delalloc_work, NULL, NULL);
  3090. return work;
  3091. }
  3092. diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
  3093. index 7187b14faa6c..ac734ec4cc20 100644
  3094. --- a/fs/btrfs/ordered-data.c
  3095. +++ b/fs/btrfs/ordered-data.c
  3096. @@ -571,18 +571,6 @@ void btrfs_remove_ordered_extent(struct inode *inode,
  3097. trace_btrfs_ordered_extent_remove(inode, entry);
  3098. - /*
  3099. - * we have no more ordered extents for this inode and
  3100. - * no dirty pages. We can safely remove it from the
  3101. - * list of ordered extents
  3102. - */
  3103. - if (RB_EMPTY_ROOT(&tree->tree) &&
  3104. - !mapping_tagged(inode->i_mapping, PAGECACHE_TAG_DIRTY)) {
  3105. - spin_lock(&root->fs_info->ordered_root_lock);
  3106. - list_del_init(&BTRFS_I(inode)->ordered_operations);
  3107. - spin_unlock(&root->fs_info->ordered_root_lock);
  3108. - }
  3109. -
  3110. if (!root->nr_ordered_extents) {
  3111. spin_lock(&root->fs_info->ordered_root_lock);
  3112. BUG_ON(list_empty(&root->ordered_root));
  3113. @@ -627,6 +615,7 @@ int btrfs_wait_ordered_extents(struct btrfs_root *root, int nr)
  3114. spin_unlock(&root->ordered_extent_lock);
  3115. btrfs_init_work(&ordered->flush_work,
  3116. + btrfs_flush_delalloc_helper,
  3117. btrfs_run_ordered_extent_work, NULL, NULL);
  3118. list_add_tail(&ordered->work_list, &works);
  3119. btrfs_queue_work(root->fs_info->flush_workers,
  3120. @@ -687,81 +676,6 @@ void btrfs_wait_ordered_roots(struct btrfs_fs_info *fs_info, int nr)
  3121. }
  3122. /*
  3123. - * this is used during transaction commit to write all the inodes
  3124. - * added to the ordered operation list. These files must be fully on
  3125. - * disk before the transaction commits.
  3126. - *
  3127. - * we have two modes here, one is to just start the IO via filemap_flush
  3128. - * and the other is to wait for all the io. When we wait, we have an
  3129. - * extra check to make sure the ordered operation list really is empty
  3130. - * before we return
  3131. - */
  3132. -int btrfs_run_ordered_operations(struct btrfs_trans_handle *trans,
  3133. - struct btrfs_root *root, int wait)
  3134. -{
  3135. - struct btrfs_inode *btrfs_inode;
  3136. - struct inode *inode;
  3137. - struct btrfs_transaction *cur_trans = trans->transaction;
  3138. - struct list_head splice;
  3139. - struct list_head works;
  3140. - struct btrfs_delalloc_work *work, *next;
  3141. - int ret = 0;
  3142. -
  3143. - INIT_LIST_HEAD(&splice);
  3144. - INIT_LIST_HEAD(&works);
  3145. -
  3146. - mutex_lock(&root->fs_info->ordered_extent_flush_mutex);
  3147. - spin_lock(&root->fs_info->ordered_root_lock);
  3148. - list_splice_init(&cur_trans->ordered_operations, &splice);
  3149. - while (!list_empty(&splice)) {
  3150. - btrfs_inode = list_entry(splice.next, struct btrfs_inode,
  3151. - ordered_operations);
  3152. - inode = &btrfs_inode->vfs_inode;
  3153. -
  3154. - list_del_init(&btrfs_inode->ordered_operations);
  3155. -
  3156. - /*
  3157. - * the inode may be getting freed (in sys_unlink path).
  3158. - */
  3159. - inode = igrab(inode);
  3160. - if (!inode)
  3161. - continue;
  3162. -
  3163. - if (!wait)
  3164. - list_add_tail(&BTRFS_I(inode)->ordered_operations,
  3165. - &cur_trans->ordered_operations);
  3166. - spin_unlock(&root->fs_info->ordered_root_lock);
  3167. -
  3168. - work = btrfs_alloc_delalloc_work(inode, wait, 1);
  3169. - if (!work) {
  3170. - spin_lock(&root->fs_info->ordered_root_lock);
  3171. - if (list_empty(&BTRFS_I(inode)->ordered_operations))
  3172. - list_add_tail(&btrfs_inode->ordered_operations,
  3173. - &splice);
  3174. - list_splice_tail(&splice,
  3175. - &cur_trans->ordered_operations);
  3176. - spin_unlock(&root->fs_info->ordered_root_lock);
  3177. - ret = -ENOMEM;
  3178. - goto out;
  3179. - }
  3180. - list_add_tail(&work->list, &works);
  3181. - btrfs_queue_work(root->fs_info->flush_workers,
  3182. - &work->work);
  3183. -
  3184. - cond_resched();
  3185. - spin_lock(&root->fs_info->ordered_root_lock);
  3186. - }
  3187. - spin_unlock(&root->fs_info->ordered_root_lock);
  3188. -out:
  3189. - list_for_each_entry_safe(work, next, &works, list) {
  3190. - list_del_init(&work->list);
  3191. - btrfs_wait_and_free_delalloc_work(work);
  3192. - }
  3193. - mutex_unlock(&root->fs_info->ordered_extent_flush_mutex);
  3194. - return ret;
  3195. -}
  3196. -
  3197. -/*
  3198. * Used to start IO or wait for a given ordered extent to finish.
  3199. *
  3200. * If wait is one, this effectively waits on page writeback for all the pages
  3201. @@ -1120,42 +1034,6 @@ out:
  3202. return index;
  3203. }
  3204. -
  3205. -/*
  3206. - * add a given inode to the list of inodes that must be fully on
  3207. - * disk before a transaction commit finishes.
  3208. - *
  3209. - * This basically gives us the ext3 style data=ordered mode, and it is mostly
  3210. - * used to make sure renamed files are fully on disk.
  3211. - *
  3212. - * It is a noop if the inode is already fully on disk.
  3213. - *
  3214. - * If trans is not null, we'll do a friendly check for a transaction that
  3215. - * is already flushing things and force the IO down ourselves.
  3216. - */
  3217. -void btrfs_add_ordered_operation(struct btrfs_trans_handle *trans,
  3218. - struct btrfs_root *root, struct inode *inode)
  3219. -{
  3220. - struct btrfs_transaction *cur_trans = trans->transaction;
  3221. - u64 last_mod;
  3222. -
  3223. - last_mod = max(BTRFS_I(inode)->generation, BTRFS_I(inode)->last_trans);
  3224. -
  3225. - /*
  3226. - * if this file hasn't been changed since the last transaction
  3227. - * commit, we can safely return without doing anything
  3228. - */
  3229. - if (last_mod <= root->fs_info->last_trans_committed)
  3230. - return;
  3231. -
  3232. - spin_lock(&root->fs_info->ordered_root_lock);
  3233. - if (list_empty(&BTRFS_I(inode)->ordered_operations)) {
  3234. - list_add_tail(&BTRFS_I(inode)->ordered_operations,
  3235. - &cur_trans->ordered_operations);
  3236. - }
  3237. - spin_unlock(&root->fs_info->ordered_root_lock);
  3238. -}
  3239. -
  3240. int __init ordered_data_init(void)
  3241. {
  3242. btrfs_ordered_extent_cache = kmem_cache_create("btrfs_ordered_extent",
  3243. diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h
  3244. index 246897058efb..d81a274d621e 100644
  3245. --- a/fs/btrfs/ordered-data.h
  3246. +++ b/fs/btrfs/ordered-data.h
  3247. @@ -190,11 +190,6 @@ int btrfs_ordered_update_i_size(struct inode *inode, u64 offset,
  3248. struct btrfs_ordered_extent *ordered);
  3249. int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr,
  3250. u32 *sum, int len);
  3251. -int btrfs_run_ordered_operations(struct btrfs_trans_handle *trans,
  3252. - struct btrfs_root *root, int wait);
  3253. -void btrfs_add_ordered_operation(struct btrfs_trans_handle *trans,
  3254. - struct btrfs_root *root,
  3255. - struct inode *inode);
  3256. int btrfs_wait_ordered_extents(struct btrfs_root *root, int nr);
  3257. void btrfs_wait_ordered_roots(struct btrfs_fs_info *fs_info, int nr);
  3258. void btrfs_get_logged_extents(struct inode *inode,
  3259. diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
  3260. index 98cb6b2630f9..3eec914710b2 100644
  3261. --- a/fs/btrfs/qgroup.c
  3262. +++ b/fs/btrfs/qgroup.c
  3263. @@ -2551,6 +2551,7 @@ qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid,
  3264. memset(&fs_info->qgroup_rescan_work, 0,
  3265. sizeof(fs_info->qgroup_rescan_work));
  3266. btrfs_init_work(&fs_info->qgroup_rescan_work,
  3267. + btrfs_qgroup_rescan_helper,
  3268. btrfs_qgroup_rescan_worker, NULL, NULL);
  3269. if (ret) {
  3270. diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
  3271. index 4a88f073fdd7..0a6b6e4bcbb9 100644
  3272. --- a/fs/btrfs/raid56.c
  3273. +++ b/fs/btrfs/raid56.c
  3274. @@ -1416,7 +1416,8 @@ cleanup:
  3275. static void async_rmw_stripe(struct btrfs_raid_bio *rbio)
  3276. {
  3277. - btrfs_init_work(&rbio->work, rmw_work, NULL, NULL);
  3278. + btrfs_init_work(&rbio->work, btrfs_rmw_helper,
  3279. + rmw_work, NULL, NULL);
  3280. btrfs_queue_work(rbio->fs_info->rmw_workers,
  3281. &rbio->work);
  3282. @@ -1424,7 +1425,8 @@ static void async_rmw_stripe(struct btrfs_raid_bio *rbio)
  3283. static void async_read_rebuild(struct btrfs_raid_bio *rbio)
  3284. {
  3285. - btrfs_init_work(&rbio->work, read_rebuild_work, NULL, NULL);
  3286. + btrfs_init_work(&rbio->work, btrfs_rmw_helper,
  3287. + read_rebuild_work, NULL, NULL);
  3288. btrfs_queue_work(rbio->fs_info->rmw_workers,
  3289. &rbio->work);
  3290. @@ -1665,7 +1667,8 @@ static void btrfs_raid_unplug(struct blk_plug_cb *cb, bool from_schedule)
  3291. plug = container_of(cb, struct btrfs_plug_cb, cb);
  3292. if (from_schedule) {
  3293. - btrfs_init_work(&plug->work, unplug_work, NULL, NULL);
  3294. + btrfs_init_work(&plug->work, btrfs_rmw_helper,
  3295. + unplug_work, NULL, NULL);
  3296. btrfs_queue_work(plug->info->rmw_workers,
  3297. &plug->work);
  3298. return;
  3299. diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
  3300. index 09230cf3a244..20408c6b665a 100644
  3301. --- a/fs/btrfs/reada.c
  3302. +++ b/fs/btrfs/reada.c
  3303. @@ -798,7 +798,8 @@ static void reada_start_machine(struct btrfs_fs_info *fs_info)
  3304. /* FIXME we cannot handle this properly right now */
  3305. BUG();
  3306. }
  3307. - btrfs_init_work(&rmw->work, reada_start_machine_worker, NULL, NULL);
  3308. + btrfs_init_work(&rmw->work, btrfs_readahead_helper,
  3309. + reada_start_machine_worker, NULL, NULL);
  3310. rmw->fs_info = fs_info;
  3311. btrfs_queue_work(fs_info->readahead_workers, &rmw->work);
  3312. diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
  3313. index b6d198f5181e..8dddedcfa961 100644
  3314. --- a/fs/btrfs/scrub.c
  3315. +++ b/fs/btrfs/scrub.c
  3316. @@ -428,8 +428,8 @@ struct scrub_ctx *scrub_setup_ctx(struct btrfs_device *dev, int is_dev_replace)
  3317. sbio->index = i;
  3318. sbio->sctx = sctx;
  3319. sbio->page_count = 0;
  3320. - btrfs_init_work(&sbio->work, scrub_bio_end_io_worker,
  3321. - NULL, NULL);
  3322. + btrfs_init_work(&sbio->work, btrfs_scrub_helper,
  3323. + scrub_bio_end_io_worker, NULL, NULL);
  3324. if (i != SCRUB_BIOS_PER_SCTX - 1)
  3325. sctx->bios[i]->next_free = i + 1;
  3326. @@ -999,8 +999,8 @@ nodatasum_case:
  3327. fixup_nodatasum->root = fs_info->extent_root;
  3328. fixup_nodatasum->mirror_num = failed_mirror_index + 1;
  3329. scrub_pending_trans_workers_inc(sctx);
  3330. - btrfs_init_work(&fixup_nodatasum->work, scrub_fixup_nodatasum,
  3331. - NULL, NULL);
  3332. + btrfs_init_work(&fixup_nodatasum->work, btrfs_scrub_helper,
  3333. + scrub_fixup_nodatasum, NULL, NULL);
  3334. btrfs_queue_work(fs_info->scrub_workers,
  3335. &fixup_nodatasum->work);
  3336. goto out;
  3337. @@ -1616,7 +1616,8 @@ static void scrub_wr_bio_end_io(struct bio *bio, int err)
  3338. sbio->err = err;
  3339. sbio->bio = bio;
  3340. - btrfs_init_work(&sbio->work, scrub_wr_bio_end_io_worker, NULL, NULL);
  3341. + btrfs_init_work(&sbio->work, btrfs_scrubwrc_helper,
  3342. + scrub_wr_bio_end_io_worker, NULL, NULL);
  3343. btrfs_queue_work(fs_info->scrub_wr_completion_workers, &sbio->work);
  3344. }
  3345. @@ -3203,7 +3204,8 @@ static int copy_nocow_pages(struct scrub_ctx *sctx, u64 logical, u64 len,
  3346. nocow_ctx->len = len;
  3347. nocow_ctx->mirror_num = mirror_num;
  3348. nocow_ctx->physical_for_dev_replace = physical_for_dev_replace;
  3349. - btrfs_init_work(&nocow_ctx->work, copy_nocow_pages_worker, NULL, NULL);
  3350. + btrfs_init_work(&nocow_ctx->work, btrfs_scrubnc_helper,
  3351. + copy_nocow_pages_worker, NULL, NULL);
  3352. INIT_LIST_HEAD(&nocow_ctx->inodes);
  3353. btrfs_queue_work(fs_info->scrub_nocow_workers,
  3354. &nocow_ctx->work);
  3355. diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
  3356. index 5f379affdf23..d89c6d3542ca 100644
  3357. --- a/fs/btrfs/transaction.c
  3358. +++ b/fs/btrfs/transaction.c
  3359. @@ -218,7 +218,6 @@ loop:
  3360. spin_lock_init(&cur_trans->delayed_refs.lock);
  3361. INIT_LIST_HEAD(&cur_trans->pending_snapshots);
  3362. - INIT_LIST_HEAD(&cur_trans->ordered_operations);
  3363. INIT_LIST_HEAD(&cur_trans->pending_chunks);
  3364. INIT_LIST_HEAD(&cur_trans->switch_commits);
  3365. list_add_tail(&cur_trans->list, &fs_info->trans_list);
  3366. @@ -1612,27 +1611,6 @@ static void cleanup_transaction(struct btrfs_trans_handle *trans,
  3367. kmem_cache_free(btrfs_trans_handle_cachep, trans);
  3368. }
  3369. -static int btrfs_flush_all_pending_stuffs(struct btrfs_trans_handle *trans,
  3370. - struct btrfs_root *root)
  3371. -{
  3372. - int ret;
  3373. -
  3374. - ret = btrfs_run_delayed_items(trans, root);
  3375. - if (ret)
  3376. - return ret;
  3377. -
  3378. - /*
  3379. - * rename don't use btrfs_join_transaction, so, once we
  3380. - * set the transaction to blocked above, we aren't going
  3381. - * to get any new ordered operations. We can safely run
  3382. - * it here and no for sure that nothing new will be added
  3383. - * to the list
  3384. - */
  3385. - ret = btrfs_run_ordered_operations(trans, root, 1);
  3386. -
  3387. - return ret;
  3388. -}
  3389. -
  3390. static inline int btrfs_start_delalloc_flush(struct btrfs_fs_info *fs_info)
  3391. {
  3392. if (btrfs_test_opt(fs_info->tree_root, FLUSHONCOMMIT))
  3393. @@ -1653,13 +1631,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
  3394. struct btrfs_transaction *prev_trans = NULL;
  3395. int ret;
  3396. - ret = btrfs_run_ordered_operations(trans, root, 0);
  3397. - if (ret) {
  3398. - btrfs_abort_transaction(trans, root, ret);
  3399. - btrfs_end_transaction(trans, root);
  3400. - return ret;
  3401. - }
  3402. -
  3403. /* Stop the commit early if ->aborted is set */
  3404. if (unlikely(ACCESS_ONCE(cur_trans->aborted))) {
  3405. ret = cur_trans->aborted;
  3406. @@ -1740,7 +1711,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
  3407. if (ret)
  3408. goto cleanup_transaction;
  3409. - ret = btrfs_flush_all_pending_stuffs(trans, root);
  3410. + ret = btrfs_run_delayed_items(trans, root);
  3411. if (ret)
  3412. goto cleanup_transaction;
  3413. @@ -1748,7 +1719,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
  3414. extwriter_counter_read(cur_trans) == 0);
  3415. /* some pending stuffs might be added after the previous flush. */
  3416. - ret = btrfs_flush_all_pending_stuffs(trans, root);
  3417. + ret = btrfs_run_delayed_items(trans, root);
  3418. if (ret)
  3419. goto cleanup_transaction;
  3420. diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h
  3421. index 7dd558ed0716..579be51b27e5 100644
  3422. --- a/fs/btrfs/transaction.h
  3423. +++ b/fs/btrfs/transaction.h
  3424. @@ -55,7 +55,6 @@ struct btrfs_transaction {
  3425. wait_queue_head_t writer_wait;
  3426. wait_queue_head_t commit_wait;
  3427. struct list_head pending_snapshots;
  3428. - struct list_head ordered_operations;
  3429. struct list_head pending_chunks;
  3430. struct list_head switch_commits;
  3431. struct btrfs_delayed_ref_root delayed_refs;
  3432. diff --git a/fs/btrfs/ulist.h b/fs/btrfs/ulist.h
  3433. index 7f78cbf5cf41..4c29db604bbe 100644
  3434. --- a/fs/btrfs/ulist.h
  3435. +++ b/fs/btrfs/ulist.h
  3436. @@ -57,6 +57,21 @@ void ulist_free(struct ulist *ulist);
  3437. int ulist_add(struct ulist *ulist, u64 val, u64 aux, gfp_t gfp_mask);
  3438. int ulist_add_merge(struct ulist *ulist, u64 val, u64 aux,
  3439. u64 *old_aux, gfp_t gfp_mask);
  3440. +
  3441. +/* just like ulist_add_merge() but take a pointer for the aux data */
  3442. +static inline int ulist_add_merge_ptr(struct ulist *ulist, u64 val, void *aux,
  3443. + void **old_aux, gfp_t gfp_mask)
  3444. +{
  3445. +#if BITS_PER_LONG == 32
  3446. + u64 old64 = (uintptr_t)*old_aux;
  3447. + int ret = ulist_add_merge(ulist, val, (uintptr_t)aux, &old64, gfp_mask);
  3448. + *old_aux = (void *)((uintptr_t)old64);
  3449. + return ret;
  3450. +#else
  3451. + return ulist_add_merge(ulist, val, (u64)aux, (u64 *)old_aux, gfp_mask);
  3452. +#endif
  3453. +}
  3454. +
  3455. struct ulist_node *ulist_next(struct ulist *ulist,
  3456. struct ulist_iterator *uiter);
  3457. diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
  3458. index 6cb82f62cb7c..81bec9fd8f19 100644
  3459. --- a/fs/btrfs/volumes.c
  3460. +++ b/fs/btrfs/volumes.c
  3461. @@ -5800,7 +5800,8 @@ struct btrfs_device *btrfs_alloc_device(struct btrfs_fs_info *fs_info,
  3462. else
  3463. generate_random_uuid(dev->uuid);
  3464. - btrfs_init_work(&dev->work, pending_bios_fn, NULL, NULL);
  3465. + btrfs_init_work(&dev->work, btrfs_submit_helper,
  3466. + pending_bios_fn, NULL, NULL);
  3467. return dev;
  3468. }
  3469. diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
  3470. index 8c41b52da358..16a46b6a6fee 100644
  3471. --- a/fs/debugfs/inode.c
  3472. +++ b/fs/debugfs/inode.c
  3473. @@ -534,7 +534,7 @@ EXPORT_SYMBOL_GPL(debugfs_remove);
  3474. */
  3475. void debugfs_remove_recursive(struct dentry *dentry)
  3476. {
  3477. - struct dentry *child, *next, *parent;
  3478. + struct dentry *child, *parent;
  3479. if (IS_ERR_OR_NULL(dentry))
  3480. return;
  3481. @@ -546,30 +546,49 @@ void debugfs_remove_recursive(struct dentry *dentry)
  3482. parent = dentry;
  3483. down:
  3484. mutex_lock(&parent->d_inode->i_mutex);
  3485. - list_for_each_entry_safe(child, next, &parent->d_subdirs, d_u.d_child) {
  3486. + loop:
  3487. + /*
  3488. + * The parent->d_subdirs is protected by the d_lock. Outside that
  3489. + * lock, the child can be unlinked and set to be freed which can
  3490. + * use the d_u.d_child as the rcu head and corrupt this list.
  3491. + */
  3492. + spin_lock(&parent->d_lock);
  3493. + list_for_each_entry(child, &parent->d_subdirs, d_u.d_child) {
  3494. if (!debugfs_positive(child))
  3495. continue;
  3496. /* perhaps simple_empty(child) makes more sense */
  3497. if (!list_empty(&child->d_subdirs)) {
  3498. + spin_unlock(&parent->d_lock);
  3499. mutex_unlock(&parent->d_inode->i_mutex);
  3500. parent = child;
  3501. goto down;
  3502. }
  3503. - up:
  3504. +
  3505. + spin_unlock(&parent->d_lock);
  3506. +
  3507. if (!__debugfs_remove(child, parent))
  3508. simple_release_fs(&debugfs_mount, &debugfs_mount_count);
  3509. +
  3510. + /*
  3511. + * The parent->d_lock protects agaist child from unlinking
  3512. + * from d_subdirs. When releasing the parent->d_lock we can
  3513. + * no longer trust that the next pointer is valid.
  3514. + * Restart the loop. We'll skip this one with the
  3515. + * debugfs_positive() check.
  3516. + */
  3517. + goto loop;
  3518. }
  3519. + spin_unlock(&parent->d_lock);
  3520. mutex_unlock(&parent->d_inode->i_mutex);
  3521. child = parent;
  3522. parent = parent->d_parent;
  3523. mutex_lock(&parent->d_inode->i_mutex);
  3524. - if (child != dentry) {
  3525. - next = list_next_entry(child, d_u.d_child);
  3526. - goto up;
  3527. - }
  3528. + if (child != dentry)
  3529. + /* go up */
  3530. + goto loop;
  3531. if (!__debugfs_remove(child, parent))
  3532. simple_release_fs(&debugfs_mount, &debugfs_mount_count);
  3533. diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
  3534. index 7cc5a0e23688..1bbe7c315138 100644
  3535. --- a/fs/ext4/ext4.h
  3536. +++ b/fs/ext4/ext4.h
  3537. @@ -2144,8 +2144,8 @@ extern ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
  3538. extern int ext4_ind_calc_metadata_amount(struct inode *inode, sector_t lblock);
  3539. extern int ext4_ind_trans_blocks(struct inode *inode, int nrblocks);
  3540. extern void ext4_ind_truncate(handle_t *, struct inode *inode);
  3541. -extern int ext4_free_hole_blocks(handle_t *handle, struct inode *inode,
  3542. - ext4_lblk_t first, ext4_lblk_t stop);
  3543. +extern int ext4_ind_remove_space(handle_t *handle, struct inode *inode,
  3544. + ext4_lblk_t start, ext4_lblk_t end);
  3545. /* ioctl.c */
  3546. extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
  3547. @@ -2453,6 +2453,22 @@ static inline void ext4_update_i_disksize(struct inode *inode, loff_t newsize)
  3548. up_write(&EXT4_I(inode)->i_data_sem);
  3549. }
  3550. +/* Update i_size, i_disksize. Requires i_mutex to avoid races with truncate */
  3551. +static inline int ext4_update_inode_size(struct inode *inode, loff_t newsize)
  3552. +{
  3553. + int changed = 0;
  3554. +
  3555. + if (newsize > inode->i_size) {
  3556. + i_size_write(inode, newsize);
  3557. + changed = 1;
  3558. + }
  3559. + if (newsize > EXT4_I(inode)->i_disksize) {
  3560. + ext4_update_i_disksize(inode, newsize);
  3561. + changed |= 2;
  3562. + }
  3563. + return changed;
  3564. +}
  3565. +
  3566. struct ext4_group_info {
  3567. unsigned long bb_state;
  3568. struct rb_root bb_free_root;
  3569. diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
  3570. index 4da228a0e6d0..7dfd6300e1c2 100644
  3571. --- a/fs/ext4/extents.c
  3572. +++ b/fs/ext4/extents.c
  3573. @@ -4664,7 +4664,8 @@ retry:
  3574. }
  3575. static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,
  3576. - ext4_lblk_t len, int flags, int mode)
  3577. + ext4_lblk_t len, loff_t new_size,
  3578. + int flags, int mode)
  3579. {
  3580. struct inode *inode = file_inode(file);
  3581. handle_t *handle;
  3582. @@ -4673,8 +4674,10 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,
  3583. int retries = 0;
  3584. struct ext4_map_blocks map;
  3585. unsigned int credits;
  3586. + loff_t epos;
  3587. map.m_lblk = offset;
  3588. + map.m_len = len;
  3589. /*
  3590. * Don't normalize the request if it can fit in one extent so
  3591. * that it doesn't get unnecessarily split into multiple
  3592. @@ -4689,9 +4692,7 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,
  3593. credits = ext4_chunk_trans_blocks(inode, len);
  3594. retry:
  3595. - while (ret >= 0 && ret < len) {
  3596. - map.m_lblk = map.m_lblk + ret;
  3597. - map.m_len = len = len - ret;
  3598. + while (ret >= 0 && len) {
  3599. handle = ext4_journal_start(inode, EXT4_HT_MAP_BLOCKS,
  3600. credits);
  3601. if (IS_ERR(handle)) {
  3602. @@ -4708,6 +4709,21 @@ retry:
  3603. ret2 = ext4_journal_stop(handle);
  3604. break;
  3605. }
  3606. + map.m_lblk += ret;
  3607. + map.m_len = len = len - ret;
  3608. + epos = (loff_t)map.m_lblk << inode->i_blkbits;
  3609. + inode->i_ctime = ext4_current_time(inode);
  3610. + if (new_size) {
  3611. + if (epos > new_size)
  3612. + epos = new_size;
  3613. + if (ext4_update_inode_size(inode, epos) & 0x1)
  3614. + inode->i_mtime = inode->i_ctime;
  3615. + } else {
  3616. + if (epos > inode->i_size)
  3617. + ext4_set_inode_flag(inode,
  3618. + EXT4_INODE_EOFBLOCKS);
  3619. + }
  3620. + ext4_mark_inode_dirty(handle, inode);
  3621. ret2 = ext4_journal_stop(handle);
  3622. if (ret2)
  3623. break;
  3624. @@ -4730,7 +4746,8 @@ static long ext4_zero_range(struct file *file, loff_t offset,
  3625. loff_t new_size = 0;
  3626. int ret = 0;
  3627. int flags;
  3628. - int partial;
  3629. + int credits;
  3630. + int partial_begin, partial_end;
  3631. loff_t start, end;
  3632. ext4_lblk_t lblk;
  3633. struct address_space *mapping = inode->i_mapping;
  3634. @@ -4770,7 +4787,8 @@ static long ext4_zero_range(struct file *file, loff_t offset,
  3635. if (start < offset || end > offset + len)
  3636. return -EINVAL;
  3637. - partial = (offset + len) & ((1 << blkbits) - 1);
  3638. + partial_begin = offset & ((1 << blkbits) - 1);
  3639. + partial_end = (offset + len) & ((1 << blkbits) - 1);
  3640. lblk = start >> blkbits;
  3641. max_blocks = (end >> blkbits);
  3642. @@ -4804,7 +4822,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
  3643. * If we have a partial block after EOF we have to allocate
  3644. * the entire block.
  3645. */
  3646. - if (partial)
  3647. + if (partial_end)
  3648. max_blocks += 1;
  3649. }
  3650. @@ -4812,6 +4830,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
  3651. /* Now release the pages and zero block aligned part of pages*/
  3652. truncate_pagecache_range(inode, start, end - 1);
  3653. + inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
  3654. /* Wait all existing dio workers, newcomers will block on i_mutex */
  3655. ext4_inode_block_unlocked_dio(inode);
  3656. @@ -4824,13 +4843,22 @@ static long ext4_zero_range(struct file *file, loff_t offset,
  3657. if (ret)
  3658. goto out_dio;
  3659. - ret = ext4_alloc_file_blocks(file, lblk, max_blocks, flags,
  3660. - mode);
  3661. + ret = ext4_alloc_file_blocks(file, lblk, max_blocks, new_size,
  3662. + flags, mode);
  3663. if (ret)
  3664. goto out_dio;
  3665. }
  3666. + if (!partial_begin && !partial_end)
  3667. + goto out_dio;
  3668. - handle = ext4_journal_start(inode, EXT4_HT_MISC, 4);
  3669. + /*
  3670. + * In worst case we have to writeout two nonadjacent unwritten
  3671. + * blocks and update the inode
  3672. + */
  3673. + credits = (2 * ext4_ext_index_trans_blocks(inode, 2)) + 1;
  3674. + if (ext4_should_journal_data(inode))
  3675. + credits += 2;
  3676. + handle = ext4_journal_start(inode, EXT4_HT_MISC, credits);
  3677. if (IS_ERR(handle)) {
  3678. ret = PTR_ERR(handle);
  3679. ext4_std_error(inode->i_sb, ret);
  3680. @@ -4838,12 +4866,8 @@ static long ext4_zero_range(struct file *file, loff_t offset,
  3681. }
  3682. inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
  3683. -
  3684. if (new_size) {
  3685. - if (new_size > i_size_read(inode))
  3686. - i_size_write(inode, new_size);
  3687. - if (new_size > EXT4_I(inode)->i_disksize)
  3688. - ext4_update_i_disksize(inode, new_size);
  3689. + ext4_update_inode_size(inode, new_size);
  3690. } else {
  3691. /*
  3692. * Mark that we allocate beyond EOF so the subsequent truncate
  3693. @@ -4852,7 +4876,6 @@ static long ext4_zero_range(struct file *file, loff_t offset,
  3694. if ((offset + len) > i_size_read(inode))
  3695. ext4_set_inode_flag(inode, EXT4_INODE_EOFBLOCKS);
  3696. }
  3697. -
  3698. ext4_mark_inode_dirty(handle, inode);
  3699. /* Zero out partial block at the edges of the range */
  3700. @@ -4879,13 +4902,11 @@ out_mutex:
  3701. long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
  3702. {
  3703. struct inode *inode = file_inode(file);
  3704. - handle_t *handle;
  3705. loff_t new_size = 0;
  3706. unsigned int max_blocks;
  3707. int ret = 0;
  3708. int flags;
  3709. ext4_lblk_t lblk;
  3710. - struct timespec tv;
  3711. unsigned int blkbits = inode->i_blkbits;
  3712. /* Return error if mode is not supported */
  3713. @@ -4936,36 +4957,15 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
  3714. goto out;
  3715. }
  3716. - ret = ext4_alloc_file_blocks(file, lblk, max_blocks, flags, mode);
  3717. + ret = ext4_alloc_file_blocks(file, lblk, max_blocks, new_size,
  3718. + flags, mode);
  3719. if (ret)
  3720. goto out;
  3721. - handle = ext4_journal_start(inode, EXT4_HT_INODE, 2);
  3722. - if (IS_ERR(handle))
  3723. - goto out;
  3724. -
  3725. - tv = inode->i_ctime = ext4_current_time(inode);
  3726. -
  3727. - if (new_size) {
  3728. - if (new_size > i_size_read(inode)) {
  3729. - i_size_write(inode, new_size);
  3730. - inode->i_mtime = tv;
  3731. - }
  3732. - if (new_size > EXT4_I(inode)->i_disksize)
  3733. - ext4_update_i_disksize(inode, new_size);
  3734. - } else {
  3735. - /*
  3736. - * Mark that we allocate beyond EOF so the subsequent truncate
  3737. - * can proceed even if the new size is the same as i_size.
  3738. - */
  3739. - if ((offset + len) > i_size_read(inode))
  3740. - ext4_set_inode_flag(inode, EXT4_INODE_EOFBLOCKS);
  3741. + if (file->f_flags & O_SYNC && EXT4_SB(inode->i_sb)->s_journal) {
  3742. + ret = jbd2_complete_transaction(EXT4_SB(inode->i_sb)->s_journal,
  3743. + EXT4_I(inode)->i_sync_tid);
  3744. }
  3745. - ext4_mark_inode_dirty(handle, inode);
  3746. - if (file->f_flags & O_SYNC)
  3747. - ext4_handle_sync(handle);
  3748. -
  3749. - ext4_journal_stop(handle);
  3750. out:
  3751. mutex_unlock(&inode->i_mutex);
  3752. trace_ext4_fallocate_exit(inode, offset, max_blocks, ret);
  3753. diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
  3754. index fd69da194826..e75f840000a0 100644
  3755. --- a/fs/ext4/indirect.c
  3756. +++ b/fs/ext4/indirect.c
  3757. @@ -1295,97 +1295,220 @@ do_indirects:
  3758. }
  3759. }
  3760. -static int free_hole_blocks(handle_t *handle, struct inode *inode,
  3761. - struct buffer_head *parent_bh, __le32 *i_data,
  3762. - int level, ext4_lblk_t first,
  3763. - ext4_lblk_t count, int max)
  3764. +/**
  3765. + * ext4_ind_remove_space - remove space from the range
  3766. + * @handle: JBD handle for this transaction
  3767. + * @inode: inode we are dealing with
  3768. + * @start: First block to remove
  3769. + * @end: One block after the last block to remove (exclusive)
  3770. + *
  3771. + * Free the blocks in the defined range (end is exclusive endpoint of
  3772. + * range). This is used by ext4_punch_hole().
  3773. + */
  3774. +int ext4_ind_remove_space(handle_t *handle, struct inode *inode,
  3775. + ext4_lblk_t start, ext4_lblk_t end)
  3776. {
  3777. - struct buffer_head *bh = NULL;
  3778. + struct ext4_inode_info *ei = EXT4_I(inode);
  3779. + __le32 *i_data = ei->i_data;
  3780. int addr_per_block = EXT4_ADDR_PER_BLOCK(inode->i_sb);
  3781. - int ret = 0;
  3782. - int i, inc;
  3783. - ext4_lblk_t offset;
  3784. - __le32 blk;
  3785. -
  3786. - inc = 1 << ((EXT4_BLOCK_SIZE_BITS(inode->i_sb) - 2) * level);
  3787. - for (i = 0, offset = 0; i < max; i++, i_data++, offset += inc) {
  3788. - if (offset >= count + first)
  3789. - break;
  3790. - if (*i_data == 0 || (offset + inc) <= first)
  3791. - continue;
  3792. - blk = *i_data;
  3793. - if (level > 0) {
  3794. - ext4_lblk_t first2;
  3795. - ext4_lblk_t count2;
  3796. + ext4_lblk_t offsets[4], offsets2[4];
  3797. + Indirect chain[4], chain2[4];
  3798. + Indirect *partial, *partial2;
  3799. + ext4_lblk_t max_block;
  3800. + __le32 nr = 0, nr2 = 0;
  3801. + int n = 0, n2 = 0;
  3802. + unsigned blocksize = inode->i_sb->s_blocksize;
  3803. - bh = sb_bread(inode->i_sb, le32_to_cpu(blk));
  3804. - if (!bh) {
  3805. - EXT4_ERROR_INODE_BLOCK(inode, le32_to_cpu(blk),
  3806. - "Read failure");
  3807. - return -EIO;
  3808. - }
  3809. - if (first > offset) {
  3810. - first2 = first - offset;
  3811. - count2 = count;
  3812. + max_block = (EXT4_SB(inode->i_sb)->s_bitmap_maxbytes + blocksize-1)
  3813. + >> EXT4_BLOCK_SIZE_BITS(inode->i_sb);
  3814. + if (end >= max_block)
  3815. + end = max_block;
  3816. + if ((start >= end) || (start > max_block))
  3817. + return 0;
  3818. +
  3819. + n = ext4_block_to_path(inode, start, offsets, NULL);
  3820. + n2 = ext4_block_to_path(inode, end, offsets2, NULL);
  3821. +
  3822. + BUG_ON(n > n2);
  3823. +
  3824. + if ((n == 1) && (n == n2)) {
  3825. + /* We're punching only within direct block range */
  3826. + ext4_free_data(handle, inode, NULL, i_data + offsets[0],
  3827. + i_data + offsets2[0]);
  3828. + return 0;
  3829. + } else if (n2 > n) {
  3830. + /*
  3831. + * Start and end are on a different levels so we're going to
  3832. + * free partial block at start, and partial block at end of
  3833. + * the range. If there are some levels in between then
  3834. + * do_indirects label will take care of that.
  3835. + */
  3836. +
  3837. + if (n == 1) {
  3838. + /*
  3839. + * Start is at the direct block level, free
  3840. + * everything to the end of the level.
  3841. + */
  3842. + ext4_free_data(handle, inode, NULL, i_data + offsets[0],
  3843. + i_data + EXT4_NDIR_BLOCKS);
  3844. + goto end_range;
  3845. + }
  3846. +
  3847. +
  3848. + partial = ext4_find_shared(inode, n, offsets, chain, &nr);
  3849. + if (nr) {
  3850. + if (partial == chain) {
  3851. + /* Shared branch grows from the inode */
  3852. + ext4_free_branches(handle, inode, NULL,
  3853. + &nr, &nr+1, (chain+n-1) - partial);
  3854. + *partial->p = 0;
  3855. } else {
  3856. - first2 = 0;
  3857. - count2 = count - (offset - first);
  3858. + /* Shared branch grows from an indirect block */
  3859. + BUFFER_TRACE(partial->bh, "get_write_access");
  3860. + ext4_free_branches(handle, inode, partial->bh,
  3861. + partial->p,
  3862. + partial->p+1, (chain+n-1) - partial);
  3863. }
  3864. - ret = free_hole_blocks(handle, inode, bh,
  3865. - (__le32 *)bh->b_data, level - 1,
  3866. - first2, count2,
  3867. - inode->i_sb->s_blocksize >> 2);
  3868. - if (ret) {
  3869. - brelse(bh);
  3870. - goto err;
  3871. + }
  3872. +
  3873. + /*
  3874. + * Clear the ends of indirect blocks on the shared branch
  3875. + * at the start of the range
  3876. + */
  3877. + while (partial > chain) {
  3878. + ext4_free_branches(handle, inode, partial->bh,
  3879. + partial->p + 1,
  3880. + (__le32 *)partial->bh->b_data+addr_per_block,
  3881. + (chain+n-1) - partial);
  3882. + BUFFER_TRACE(partial->bh, "call brelse");
  3883. + brelse(partial->bh);
  3884. + partial--;
  3885. + }
  3886. +
  3887. +end_range:
  3888. + partial2 = ext4_find_shared(inode, n2, offsets2, chain2, &nr2);
  3889. + if (nr2) {
  3890. + if (partial2 == chain2) {
  3891. + /*
  3892. + * Remember, end is exclusive so here we're at
  3893. + * the start of the next level we're not going
  3894. + * to free. Everything was covered by the start
  3895. + * of the range.
  3896. + */
  3897. + return 0;
  3898. + } else {
  3899. + /* Shared branch grows from an indirect block */
  3900. + partial2--;
  3901. }
  3902. + } else {
  3903. + /*
  3904. + * ext4_find_shared returns Indirect structure which
  3905. + * points to the last element which should not be
  3906. + * removed by truncate. But this is end of the range
  3907. + * in punch_hole so we need to point to the next element
  3908. + */
  3909. + partial2->p++;
  3910. }
  3911. - if (level == 0 ||
  3912. - (bh && all_zeroes((__le32 *)bh->b_data,
  3913. - (__le32 *)bh->b_data + addr_per_block))) {
  3914. - ext4_free_data(handle, inode, parent_bh,
  3915. - i_data, i_data + 1);
  3916. +
  3917. + /*
  3918. + * Clear the ends of indirect blocks on the shared branch
  3919. + * at the end of the range
  3920. + */
  3921. + while (partial2 > chain2) {
  3922. + ext4_free_branches(handle, inode, partial2->bh,
  3923. + (__le32 *)partial2->bh->b_data,
  3924. + partial2->p,
  3925. + (chain2+n2-1) - partial2);
  3926. + BUFFER_TRACE(partial2->bh, "call brelse");
  3927. + brelse(partial2->bh);
  3928. + partial2--;
  3929. }
  3930. - brelse(bh);
  3931. - bh = NULL;
  3932. + goto do_indirects;
  3933. }
  3934. -err:
  3935. - return ret;
  3936. -}
  3937. -
  3938. -int ext4_free_hole_blocks(handle_t *handle, struct inode *inode,
  3939. - ext4_lblk_t first, ext4_lblk_t stop)
  3940. -{
  3941. - int addr_per_block = EXT4_ADDR_PER_BLOCK(inode->i_sb);
  3942. - int level, ret = 0;
  3943. - int num = EXT4_NDIR_BLOCKS;
  3944. - ext4_lblk_t count, max = EXT4_NDIR_BLOCKS;
  3945. - __le32 *i_data = EXT4_I(inode)->i_data;
  3946. -
  3947. - count = stop - first;
  3948. - for (level = 0; level < 4; level++, max *= addr_per_block) {
  3949. - if (first < max) {
  3950. - ret = free_hole_blocks(handle, inode, NULL, i_data,
  3951. - level, first, count, num);
  3952. - if (ret)
  3953. - goto err;
  3954. - if (count > max - first)
  3955. - count -= max - first;
  3956. - else
  3957. - break;
  3958. - first = 0;
  3959. - } else {
  3960. - first -= max;
  3961. + /* Punch happened within the same level (n == n2) */
  3962. + partial = ext4_find_shared(inode, n, offsets, chain, &nr);
  3963. + partial2 = ext4_find_shared(inode, n2, offsets2, chain2, &nr2);
  3964. + /*
  3965. + * ext4_find_shared returns Indirect structure which
  3966. + * points to the last element which should not be
  3967. + * removed by truncate. But this is end of the range
  3968. + * in punch_hole so we need to point to the next element
  3969. + */
  3970. + partial2->p++;
  3971. + while ((partial > chain) || (partial2 > chain2)) {
  3972. + /* We're at the same block, so we're almost finished */
  3973. + if ((partial->bh && partial2->bh) &&
  3974. + (partial->bh->b_blocknr == partial2->bh->b_blocknr)) {
  3975. + if ((partial > chain) && (partial2 > chain2)) {
  3976. + ext4_free_branches(handle, inode, partial->bh,
  3977. + partial->p + 1,
  3978. + partial2->p,
  3979. + (chain+n-1) - partial);
  3980. + BUFFER_TRACE(partial->bh, "call brelse");
  3981. + brelse(partial->bh);
  3982. + BUFFER_TRACE(partial2->bh, "call brelse");
  3983. + brelse(partial2->bh);
  3984. + }
  3985. + return 0;
  3986. }
  3987. - i_data += num;
  3988. - if (level == 0) {
  3989. - num = 1;
  3990. - max = 1;
  3991. + /*
  3992. + * Clear the ends of indirect blocks on the shared branch
  3993. + * at the start of the range
  3994. + */
  3995. + if (partial > chain) {
  3996. + ext4_free_branches(handle, inode, partial->bh,
  3997. + partial->p + 1,
  3998. + (__le32 *)partial->bh->b_data+addr_per_block,
  3999. + (chain+n-1) - partial);
  4000. + BUFFER_TRACE(partial->bh, "call brelse");
  4001. + brelse(partial->bh);
  4002. + partial--;
  4003. + }
  4004. + /*
  4005. + * Clear the ends of indirect blocks on the shared branch
  4006. + * at the end of the range
  4007. + */
  4008. + if (partial2 > chain2) {
  4009. + ext4_free_branches(handle, inode, partial2->bh,
  4010. + (__le32 *)partial2->bh->b_data,
  4011. + partial2->p,
  4012. + (chain2+n-1) - partial2);
  4013. + BUFFER_TRACE(partial2->bh, "call brelse");
  4014. + brelse(partial2->bh);
  4015. + partial2--;
  4016. }
  4017. }
  4018. -err:
  4019. - return ret;
  4020. +do_indirects:
  4021. + /* Kill the remaining (whole) subtrees */
  4022. + switch (offsets[0]) {
  4023. + default:
  4024. + if (++n >= n2)
  4025. + return 0;
  4026. + nr = i_data[EXT4_IND_BLOCK];
  4027. + if (nr) {
  4028. + ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 1);
  4029. + i_data[EXT4_IND_BLOCK] = 0;
  4030. + }
  4031. + case EXT4_IND_BLOCK:
  4032. + if (++n >= n2)
  4033. + return 0;
  4034. + nr = i_data[EXT4_DIND_BLOCK];
  4035. + if (nr) {
  4036. + ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 2);
  4037. + i_data[EXT4_DIND_BLOCK] = 0;
  4038. + }
  4039. + case EXT4_DIND_BLOCK:
  4040. + if (++n >= n2)
  4041. + return 0;
  4042. + nr = i_data[EXT4_TIND_BLOCK];
  4043. + if (nr) {
  4044. + ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 3);
  4045. + i_data[EXT4_TIND_BLOCK] = 0;
  4046. + }
  4047. + case EXT4_TIND_BLOCK:
  4048. + ;
  4049. + }
  4050. + return 0;
  4051. }
  4052. -
  4053. diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
  4054. index 8a064734e6eb..e9c9b5bd906a 100644
  4055. --- a/fs/ext4/inode.c
  4056. +++ b/fs/ext4/inode.c
  4057. @@ -1092,27 +1092,11 @@ static int ext4_write_end(struct file *file,
  4058. } else
  4059. copied = block_write_end(file, mapping, pos,
  4060. len, copied, page, fsdata);
  4061. -
  4062. /*
  4063. - * No need to use i_size_read() here, the i_size
  4064. - * cannot change under us because we hole i_mutex.
  4065. - *
  4066. - * But it's important to update i_size while still holding page lock:
  4067. + * it's important to update i_size while still holding page lock:
  4068. * page writeout could otherwise come in and zero beyond i_size.
  4069. */
  4070. - if (pos + copied > inode->i_size) {
  4071. - i_size_write(inode, pos + copied);
  4072. - i_size_changed = 1;
  4073. - }
  4074. -
  4075. - if (pos + copied > EXT4_I(inode)->i_disksize) {
  4076. - /* We need to mark inode dirty even if
  4077. - * new_i_size is less that inode->i_size
  4078. - * but greater than i_disksize. (hint delalloc)
  4079. - */
  4080. - ext4_update_i_disksize(inode, (pos + copied));
  4081. - i_size_changed = 1;
  4082. - }
  4083. + i_size_changed = ext4_update_inode_size(inode, pos + copied);
  4084. unlock_page(page);
  4085. page_cache_release(page);
  4086. @@ -1160,7 +1144,7 @@ static int ext4_journalled_write_end(struct file *file,
  4087. int ret = 0, ret2;
  4088. int partial = 0;
  4089. unsigned from, to;
  4090. - loff_t new_i_size;
  4091. + int size_changed = 0;
  4092. trace_ext4_journalled_write_end(inode, pos, len, copied);
  4093. from = pos & (PAGE_CACHE_SIZE - 1);
  4094. @@ -1183,20 +1167,18 @@ static int ext4_journalled_write_end(struct file *file,
  4095. if (!partial)
  4096. SetPageUptodate(page);
  4097. }
  4098. - new_i_size = pos + copied;
  4099. - if (new_i_size > inode->i_size)
  4100. - i_size_write(inode, pos+copied);
  4101. + size_changed = ext4_update_inode_size(inode, pos + copied);
  4102. ext4_set_inode_state(inode, EXT4_STATE_JDATA);
  4103. EXT4_I(inode)->i_datasync_tid = handle->h_transaction->t_tid;
  4104. - if (new_i_size > EXT4_I(inode)->i_disksize) {
  4105. - ext4_update_i_disksize(inode, new_i_size);
  4106. + unlock_page(page);
  4107. + page_cache_release(page);
  4108. +
  4109. + if (size_changed) {
  4110. ret2 = ext4_mark_inode_dirty(handle, inode);
  4111. if (!ret)
  4112. ret = ret2;
  4113. }
  4114. - unlock_page(page);
  4115. - page_cache_release(page);
  4116. if (pos + len > inode->i_size && ext4_can_truncate(inode))
  4117. /* if we have allocated more blocks and copied
  4118. * less. We will have blocks allocated outside
  4119. @@ -2212,6 +2194,7 @@ static int mpage_map_and_submit_extent(handle_t *handle,
  4120. struct ext4_map_blocks *map = &mpd->map;
  4121. int err;
  4122. loff_t disksize;
  4123. + int progress = 0;
  4124. mpd->io_submit.io_end->offset =
  4125. ((loff_t)map->m_lblk) << inode->i_blkbits;
  4126. @@ -2228,8 +2211,11 @@ static int mpage_map_and_submit_extent(handle_t *handle,
  4127. * is non-zero, a commit should free up blocks.
  4128. */
  4129. if ((err == -ENOMEM) ||
  4130. - (err == -ENOSPC && ext4_count_free_clusters(sb)))
  4131. + (err == -ENOSPC && ext4_count_free_clusters(sb))) {
  4132. + if (progress)
  4133. + goto update_disksize;
  4134. return err;
  4135. + }
  4136. ext4_msg(sb, KERN_CRIT,
  4137. "Delayed block allocation failed for "
  4138. "inode %lu at logical offset %llu with"
  4139. @@ -2246,15 +2232,17 @@ static int mpage_map_and_submit_extent(handle_t *handle,
  4140. *give_up_on_write = true;
  4141. return err;
  4142. }
  4143. + progress = 1;
  4144. /*
  4145. * Update buffer state, submit mapped pages, and get us new
  4146. * extent to map
  4147. */
  4148. err = mpage_map_and_submit_buffers(mpd);
  4149. if (err < 0)
  4150. - return err;
  4151. + goto update_disksize;
  4152. } while (map->m_len);
  4153. +update_disksize:
  4154. /*
  4155. * Update on-disk size after IO is submitted. Races with
  4156. * truncate are avoided by checking i_size under i_data_sem.
  4157. @@ -3624,7 +3612,7 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
  4158. ret = ext4_ext_remove_space(inode, first_block,
  4159. stop_block - 1);
  4160. else
  4161. - ret = ext4_free_hole_blocks(handle, inode, first_block,
  4162. + ret = ext4_ind_remove_space(handle, inode, first_block,
  4163. stop_block);
  4164. up_write(&EXT4_I(inode)->i_data_sem);
  4165. diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
  4166. index 2dcb936be90e..c3e7418a6811 100644
  4167. --- a/fs/ext4/mballoc.c
  4168. +++ b/fs/ext4/mballoc.c
  4169. @@ -1412,6 +1412,8 @@ static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b,
  4170. int last = first + count - 1;
  4171. struct super_block *sb = e4b->bd_sb;
  4172. + if (WARN_ON(count == 0))
  4173. + return;
  4174. BUG_ON(last >= (sb->s_blocksize << 3));
  4175. assert_spin_locked(ext4_group_lock_ptr(sb, e4b->bd_group));
  4176. /* Don't bother if the block group is corrupt. */
  4177. @@ -3216,8 +3218,30 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
  4178. static void ext4_discard_allocated_blocks(struct ext4_allocation_context *ac)
  4179. {
  4180. struct ext4_prealloc_space *pa = ac->ac_pa;
  4181. + struct ext4_buddy e4b;
  4182. + int err;
  4183. - if (pa && pa->pa_type == MB_INODE_PA)
  4184. + if (pa == NULL) {
  4185. + if (ac->ac_f_ex.fe_len == 0)
  4186. + return;
  4187. + err = ext4_mb_load_buddy(ac->ac_sb, ac->ac_f_ex.fe_group, &e4b);
  4188. + if (err) {
  4189. + /*
  4190. + * This should never happen since we pin the
  4191. + * pages in the ext4_allocation_context so
  4192. + * ext4_mb_load_buddy() should never fail.
  4193. + */
  4194. + WARN(1, "mb_load_buddy failed (%d)", err);
  4195. + return;
  4196. + }
  4197. + ext4_lock_group(ac->ac_sb, ac->ac_f_ex.fe_group);
  4198. + mb_free_blocks(ac->ac_inode, &e4b, ac->ac_f_ex.fe_start,
  4199. + ac->ac_f_ex.fe_len);
  4200. + ext4_unlock_group(ac->ac_sb, ac->ac_f_ex.fe_group);
  4201. + ext4_mb_unload_buddy(&e4b);
  4202. + return;
  4203. + }
  4204. + if (pa->pa_type == MB_INODE_PA)
  4205. pa->pa_free += ac->ac_b_ex.fe_len;
  4206. }
  4207. diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
  4208. index 3520ab8a6639..9e6eced1605b 100644
  4209. --- a/fs/ext4/namei.c
  4210. +++ b/fs/ext4/namei.c
  4211. @@ -3128,7 +3128,8 @@ static int ext4_find_delete_entry(handle_t *handle, struct inode *dir,
  4212. return retval;
  4213. }
  4214. -static void ext4_rename_delete(handle_t *handle, struct ext4_renament *ent)
  4215. +static void ext4_rename_delete(handle_t *handle, struct ext4_renament *ent,
  4216. + int force_reread)
  4217. {
  4218. int retval;
  4219. /*
  4220. @@ -3140,7 +3141,8 @@ static void ext4_rename_delete(handle_t *handle, struct ext4_renament *ent)
  4221. if (le32_to_cpu(ent->de->inode) != ent->inode->i_ino ||
  4222. ent->de->name_len != ent->dentry->d_name.len ||
  4223. strncmp(ent->de->name, ent->dentry->d_name.name,
  4224. - ent->de->name_len)) {
  4225. + ent->de->name_len) ||
  4226. + force_reread) {
  4227. retval = ext4_find_delete_entry(handle, ent->dir,
  4228. &ent->dentry->d_name);
  4229. } else {
  4230. @@ -3191,6 +3193,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
  4231. .dentry = new_dentry,
  4232. .inode = new_dentry->d_inode,
  4233. };
  4234. + int force_reread;
  4235. int retval;
  4236. dquot_initialize(old.dir);
  4237. @@ -3246,6 +3249,15 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
  4238. if (retval)
  4239. goto end_rename;
  4240. }
  4241. + /*
  4242. + * If we're renaming a file within an inline_data dir and adding or
  4243. + * setting the new dirent causes a conversion from inline_data to
  4244. + * extents/blockmap, we need to force the dirent delete code to
  4245. + * re-read the directory, or else we end up trying to delete a dirent
  4246. + * from what is now the extent tree root (or a block map).
  4247. + */
  4248. + force_reread = (new.dir->i_ino == old.dir->i_ino &&
  4249. + ext4_test_inode_flag(new.dir, EXT4_INODE_INLINE_DATA));
  4250. if (!new.bh) {
  4251. retval = ext4_add_entry(handle, new.dentry, old.inode);
  4252. if (retval)
  4253. @@ -3256,6 +3268,9 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
  4254. if (retval)
  4255. goto end_rename;
  4256. }
  4257. + if (force_reread)
  4258. + force_reread = !ext4_test_inode_flag(new.dir,
  4259. + EXT4_INODE_INLINE_DATA);
  4260. /*
  4261. * Like most other Unix systems, set the ctime for inodes on a
  4262. @@ -3267,7 +3282,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
  4263. /*
  4264. * ok, that's it
  4265. */
  4266. - ext4_rename_delete(handle, &old);
  4267. + ext4_rename_delete(handle, &old, force_reread);
  4268. if (new.inode) {
  4269. ext4_dec_count(handle, new.inode);
  4270. diff --git a/fs/ext4/super.c b/fs/ext4/super.c
  4271. index 6df7bc611dbd..beeb5c4e1f9d 100644
  4272. --- a/fs/ext4/super.c
  4273. +++ b/fs/ext4/super.c
  4274. @@ -3185,9 +3185,9 @@ static int set_journal_csum_feature_set(struct super_block *sb)
  4275. if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
  4276. EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
  4277. - /* journal checksum v2 */
  4278. + /* journal checksum v3 */
  4279. compat = 0;
  4280. - incompat = JBD2_FEATURE_INCOMPAT_CSUM_V2;
  4281. + incompat = JBD2_FEATURE_INCOMPAT_CSUM_V3;
  4282. } else {
  4283. /* journal checksum v1 */
  4284. compat = JBD2_FEATURE_COMPAT_CHECKSUM;
  4285. @@ -3209,6 +3209,7 @@ static int set_journal_csum_feature_set(struct super_block *sb)
  4286. jbd2_journal_clear_features(sbi->s_journal,
  4287. JBD2_FEATURE_COMPAT_CHECKSUM, 0,
  4288. JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT |
  4289. + JBD2_FEATURE_INCOMPAT_CSUM_V3 |
  4290. JBD2_FEATURE_INCOMPAT_CSUM_V2);
  4291. }
  4292. diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
  4293. index 4556ce1af5b0..5ddaf8625d3b 100644
  4294. --- a/fs/isofs/inode.c
  4295. +++ b/fs/isofs/inode.c
  4296. @@ -61,7 +61,7 @@ static void isofs_put_super(struct super_block *sb)
  4297. return;
  4298. }
  4299. -static int isofs_read_inode(struct inode *);
  4300. +static int isofs_read_inode(struct inode *, int relocated);
  4301. static int isofs_statfs (struct dentry *, struct kstatfs *);
  4302. static struct kmem_cache *isofs_inode_cachep;
  4303. @@ -1259,7 +1259,7 @@ out_toomany:
  4304. goto out;
  4305. }
  4306. -static int isofs_read_inode(struct inode *inode)
  4307. +static int isofs_read_inode(struct inode *inode, int relocated)
  4308. {
  4309. struct super_block *sb = inode->i_sb;
  4310. struct isofs_sb_info *sbi = ISOFS_SB(sb);
  4311. @@ -1404,7 +1404,7 @@ static int isofs_read_inode(struct inode *inode)
  4312. */
  4313. if (!high_sierra) {
  4314. - parse_rock_ridge_inode(de, inode);
  4315. + parse_rock_ridge_inode(de, inode, relocated);
  4316. /* if we want uid/gid set, override the rock ridge setting */
  4317. if (sbi->s_uid_set)
  4318. inode->i_uid = sbi->s_uid;
  4319. @@ -1483,9 +1483,10 @@ static int isofs_iget5_set(struct inode *ino, void *data)
  4320. * offset that point to the underlying meta-data for the inode. The
  4321. * code below is otherwise similar to the iget() code in
  4322. * include/linux/fs.h */
  4323. -struct inode *isofs_iget(struct super_block *sb,
  4324. - unsigned long block,
  4325. - unsigned long offset)
  4326. +struct inode *__isofs_iget(struct super_block *sb,
  4327. + unsigned long block,
  4328. + unsigned long offset,
  4329. + int relocated)
  4330. {
  4331. unsigned long hashval;
  4332. struct inode *inode;
  4333. @@ -1507,7 +1508,7 @@ struct inode *isofs_iget(struct super_block *sb,
  4334. return ERR_PTR(-ENOMEM);
  4335. if (inode->i_state & I_NEW) {
  4336. - ret = isofs_read_inode(inode);
  4337. + ret = isofs_read_inode(inode, relocated);
  4338. if (ret < 0) {
  4339. iget_failed(inode);
  4340. inode = ERR_PTR(ret);
  4341. diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h
  4342. index 99167238518d..0ac4c1f73fbd 100644
  4343. --- a/fs/isofs/isofs.h
  4344. +++ b/fs/isofs/isofs.h
  4345. @@ -107,7 +107,7 @@ extern int iso_date(char *, int);
  4346. struct inode; /* To make gcc happy */
  4347. -extern int parse_rock_ridge_inode(struct iso_directory_record *, struct inode *);
  4348. +extern int parse_rock_ridge_inode(struct iso_directory_record *, struct inode *, int relocated);
  4349. extern int get_rock_ridge_filename(struct iso_directory_record *, char *, struct inode *);
  4350. extern int isofs_name_translate(struct iso_directory_record *, char *, struct inode *);
  4351. @@ -118,9 +118,24 @@ extern struct dentry *isofs_lookup(struct inode *, struct dentry *, unsigned int
  4352. extern struct buffer_head *isofs_bread(struct inode *, sector_t);
  4353. extern int isofs_get_blocks(struct inode *, sector_t, struct buffer_head **, unsigned long);
  4354. -extern struct inode *isofs_iget(struct super_block *sb,
  4355. - unsigned long block,
  4356. - unsigned long offset);
  4357. +struct inode *__isofs_iget(struct super_block *sb,
  4358. + unsigned long block,
  4359. + unsigned long offset,
  4360. + int relocated);
  4361. +
  4362. +static inline struct inode *isofs_iget(struct super_block *sb,
  4363. + unsigned long block,
  4364. + unsigned long offset)
  4365. +{
  4366. + return __isofs_iget(sb, block, offset, 0);
  4367. +}
  4368. +
  4369. +static inline struct inode *isofs_iget_reloc(struct super_block *sb,
  4370. + unsigned long block,
  4371. + unsigned long offset)
  4372. +{
  4373. + return __isofs_iget(sb, block, offset, 1);
  4374. +}
  4375. /* Because the inode number is no longer relevant to finding the
  4376. * underlying meta-data for an inode, we are free to choose a more
  4377. diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c
  4378. index c0bf42472e40..f488bbae541a 100644
  4379. --- a/fs/isofs/rock.c
  4380. +++ b/fs/isofs/rock.c
  4381. @@ -288,12 +288,16 @@ eio:
  4382. goto out;
  4383. }
  4384. +#define RR_REGARD_XA 1
  4385. +#define RR_RELOC_DE 2
  4386. +
  4387. static int
  4388. parse_rock_ridge_inode_internal(struct iso_directory_record *de,
  4389. - struct inode *inode, int regard_xa)
  4390. + struct inode *inode, int flags)
  4391. {
  4392. int symlink_len = 0;
  4393. int cnt, sig;
  4394. + unsigned int reloc_block;
  4395. struct inode *reloc;
  4396. struct rock_ridge *rr;
  4397. int rootflag;
  4398. @@ -305,7 +309,7 @@ parse_rock_ridge_inode_internal(struct iso_directory_record *de,
  4399. init_rock_state(&rs, inode);
  4400. setup_rock_ridge(de, inode, &rs);
  4401. - if (regard_xa) {
  4402. + if (flags & RR_REGARD_XA) {
  4403. rs.chr += 14;
  4404. rs.len -= 14;
  4405. if (rs.len < 0)
  4406. @@ -485,12 +489,22 @@ repeat:
  4407. "relocated directory\n");
  4408. goto out;
  4409. case SIG('C', 'L'):
  4410. - ISOFS_I(inode)->i_first_extent =
  4411. - isonum_733(rr->u.CL.location);
  4412. - reloc =
  4413. - isofs_iget(inode->i_sb,
  4414. - ISOFS_I(inode)->i_first_extent,
  4415. - 0);
  4416. + if (flags & RR_RELOC_DE) {
  4417. + printk(KERN_ERR
  4418. + "ISOFS: Recursive directory relocation "
  4419. + "is not supported\n");
  4420. + goto eio;
  4421. + }
  4422. + reloc_block = isonum_733(rr->u.CL.location);
  4423. + if (reloc_block == ISOFS_I(inode)->i_iget5_block &&
  4424. + ISOFS_I(inode)->i_iget5_offset == 0) {
  4425. + printk(KERN_ERR
  4426. + "ISOFS: Directory relocation points to "
  4427. + "itself\n");
  4428. + goto eio;
  4429. + }
  4430. + ISOFS_I(inode)->i_first_extent = reloc_block;
  4431. + reloc = isofs_iget_reloc(inode->i_sb, reloc_block, 0);
  4432. if (IS_ERR(reloc)) {
  4433. ret = PTR_ERR(reloc);
  4434. goto out;
  4435. @@ -637,9 +651,11 @@ static char *get_symlink_chunk(char *rpnt, struct rock_ridge *rr, char *plimit)
  4436. return rpnt;
  4437. }
  4438. -int parse_rock_ridge_inode(struct iso_directory_record *de, struct inode *inode)
  4439. +int parse_rock_ridge_inode(struct iso_directory_record *de, struct inode *inode,
  4440. + int relocated)
  4441. {
  4442. - int result = parse_rock_ridge_inode_internal(de, inode, 0);
  4443. + int flags = relocated ? RR_RELOC_DE : 0;
  4444. + int result = parse_rock_ridge_inode_internal(de, inode, flags);
  4445. /*
  4446. * if rockridge flag was reset and we didn't look for attributes
  4447. @@ -647,7 +663,8 @@ int parse_rock_ridge_inode(struct iso_directory_record *de, struct inode *inode)
  4448. */
  4449. if ((ISOFS_SB(inode->i_sb)->s_rock_offset == -1)
  4450. && (ISOFS_SB(inode->i_sb)->s_rock == 2)) {
  4451. - result = parse_rock_ridge_inode_internal(de, inode, 14);
  4452. + result = parse_rock_ridge_inode_internal(de, inode,
  4453. + flags | RR_REGARD_XA);
  4454. }
  4455. return result;
  4456. }
  4457. diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
  4458. index 6fac74349856..b73e0215baa7 100644
  4459. --- a/fs/jbd2/commit.c
  4460. +++ b/fs/jbd2/commit.c
  4461. @@ -97,7 +97,7 @@ static void jbd2_commit_block_csum_set(journal_t *j, struct buffer_head *bh)
  4462. struct commit_header *h;
  4463. __u32 csum;
  4464. - if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
  4465. + if (!jbd2_journal_has_csum_v2or3(j))
  4466. return;
  4467. h = (struct commit_header *)(bh->b_data);
  4468. @@ -313,11 +313,11 @@ static __u32 jbd2_checksum_data(__u32 crc32_sum, struct buffer_head *bh)
  4469. return checksum;
  4470. }
  4471. -static void write_tag_block(int tag_bytes, journal_block_tag_t *tag,
  4472. +static void write_tag_block(journal_t *j, journal_block_tag_t *tag,
  4473. unsigned long long block)
  4474. {
  4475. tag->t_blocknr = cpu_to_be32(block & (u32)~0);
  4476. - if (tag_bytes > JBD2_TAG_SIZE32)
  4477. + if (JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_64BIT))
  4478. tag->t_blocknr_high = cpu_to_be32((block >> 31) >> 1);
  4479. }
  4480. @@ -327,7 +327,7 @@ static void jbd2_descr_block_csum_set(journal_t *j,
  4481. struct jbd2_journal_block_tail *tail;
  4482. __u32 csum;
  4483. - if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
  4484. + if (!jbd2_journal_has_csum_v2or3(j))
  4485. return;
  4486. tail = (struct jbd2_journal_block_tail *)(bh->b_data + j->j_blocksize -
  4487. @@ -340,12 +340,13 @@ static void jbd2_descr_block_csum_set(journal_t *j,
  4488. static void jbd2_block_tag_csum_set(journal_t *j, journal_block_tag_t *tag,
  4489. struct buffer_head *bh, __u32 sequence)
  4490. {
  4491. + journal_block_tag3_t *tag3 = (journal_block_tag3_t *)tag;
  4492. struct page *page = bh->b_page;
  4493. __u8 *addr;
  4494. __u32 csum32;
  4495. __be32 seq;
  4496. - if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
  4497. + if (!jbd2_journal_has_csum_v2or3(j))
  4498. return;
  4499. seq = cpu_to_be32(sequence);
  4500. @@ -355,8 +356,10 @@ static void jbd2_block_tag_csum_set(journal_t *j, journal_block_tag_t *tag,
  4501. bh->b_size);
  4502. kunmap_atomic(addr);
  4503. - /* We only have space to store the lower 16 bits of the crc32c. */
  4504. - tag->t_checksum = cpu_to_be16(csum32);
  4505. + if (JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V3))
  4506. + tag3->t_checksum = cpu_to_be32(csum32);
  4507. + else
  4508. + tag->t_checksum = cpu_to_be16(csum32);
  4509. }
  4510. /*
  4511. * jbd2_journal_commit_transaction
  4512. @@ -396,7 +399,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
  4513. LIST_HEAD(io_bufs);
  4514. LIST_HEAD(log_bufs);
  4515. - if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2))
  4516. + if (jbd2_journal_has_csum_v2or3(journal))
  4517. csum_size = sizeof(struct jbd2_journal_block_tail);
  4518. /*
  4519. @@ -690,7 +693,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
  4520. tag_flag |= JBD2_FLAG_SAME_UUID;
  4521. tag = (journal_block_tag_t *) tagp;
  4522. - write_tag_block(tag_bytes, tag, jh2bh(jh)->b_blocknr);
  4523. + write_tag_block(journal, tag, jh2bh(jh)->b_blocknr);
  4524. tag->t_flags = cpu_to_be16(tag_flag);
  4525. jbd2_block_tag_csum_set(journal, tag, wbuf[bufs],
  4526. commit_transaction->t_tid);
  4527. diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
  4528. index 67b8e303946c..19d74d86d99c 100644
  4529. --- a/fs/jbd2/journal.c
  4530. +++ b/fs/jbd2/journal.c
  4531. @@ -124,7 +124,7 @@ EXPORT_SYMBOL(__jbd2_debug);
  4532. /* Checksumming functions */
  4533. static int jbd2_verify_csum_type(journal_t *j, journal_superblock_t *sb)
  4534. {
  4535. - if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
  4536. + if (!jbd2_journal_has_csum_v2or3(j))
  4537. return 1;
  4538. return sb->s_checksum_type == JBD2_CRC32C_CHKSUM;
  4539. @@ -145,7 +145,7 @@ static __be32 jbd2_superblock_csum(journal_t *j, journal_superblock_t *sb)
  4540. static int jbd2_superblock_csum_verify(journal_t *j, journal_superblock_t *sb)
  4541. {
  4542. - if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
  4543. + if (!jbd2_journal_has_csum_v2or3(j))
  4544. return 1;
  4545. return sb->s_checksum == jbd2_superblock_csum(j, sb);
  4546. @@ -153,7 +153,7 @@ static int jbd2_superblock_csum_verify(journal_t *j, journal_superblock_t *sb)
  4547. static void jbd2_superblock_csum_set(journal_t *j, journal_superblock_t *sb)
  4548. {
  4549. - if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
  4550. + if (!jbd2_journal_has_csum_v2or3(j))
  4551. return;
  4552. sb->s_checksum = jbd2_superblock_csum(j, sb);
  4553. @@ -1522,21 +1522,29 @@ static int journal_get_superblock(journal_t *journal)
  4554. goto out;
  4555. }
  4556. - if (JBD2_HAS_COMPAT_FEATURE(journal, JBD2_FEATURE_COMPAT_CHECKSUM) &&
  4557. - JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) {
  4558. + if (jbd2_journal_has_csum_v2or3(journal) &&
  4559. + JBD2_HAS_COMPAT_FEATURE(journal, JBD2_FEATURE_COMPAT_CHECKSUM)) {
  4560. /* Can't have checksum v1 and v2 on at the same time! */
  4561. printk(KERN_ERR "JBD2: Can't enable checksumming v1 and v2 "
  4562. "at the same time!\n");
  4563. goto out;
  4564. }
  4565. + if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2) &&
  4566. + JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V3)) {
  4567. + /* Can't have checksum v2 and v3 at the same time! */
  4568. + printk(KERN_ERR "JBD2: Can't enable checksumming v2 and v3 "
  4569. + "at the same time!\n");
  4570. + goto out;
  4571. + }
  4572. +
  4573. if (!jbd2_verify_csum_type(journal, sb)) {
  4574. printk(KERN_ERR "JBD2: Unknown checksum type\n");
  4575. goto out;
  4576. }
  4577. /* Load the checksum driver */
  4578. - if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2)) {
  4579. + if (jbd2_journal_has_csum_v2or3(journal)) {
  4580. journal->j_chksum_driver = crypto_alloc_shash("crc32c", 0, 0);
  4581. if (IS_ERR(journal->j_chksum_driver)) {
  4582. printk(KERN_ERR "JBD2: Cannot load crc32c driver.\n");
  4583. @@ -1553,7 +1561,7 @@ static int journal_get_superblock(journal_t *journal)
  4584. }
  4585. /* Precompute checksum seed for all metadata */
  4586. - if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2))
  4587. + if (jbd2_journal_has_csum_v2or3(journal))
  4588. journal->j_csum_seed = jbd2_chksum(journal, ~0, sb->s_uuid,
  4589. sizeof(sb->s_uuid));
  4590. @@ -1813,8 +1821,14 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
  4591. if (!jbd2_journal_check_available_features(journal, compat, ro, incompat))
  4592. return 0;
  4593. - /* Asking for checksumming v2 and v1? Only give them v2. */
  4594. - if (incompat & JBD2_FEATURE_INCOMPAT_CSUM_V2 &&
  4595. + /* If enabling v2 checksums, turn on v3 instead */
  4596. + if (incompat & JBD2_FEATURE_INCOMPAT_CSUM_V2) {
  4597. + incompat &= ~JBD2_FEATURE_INCOMPAT_CSUM_V2;
  4598. + incompat |= JBD2_FEATURE_INCOMPAT_CSUM_V3;
  4599. + }
  4600. +
  4601. + /* Asking for checksumming v3 and v1? Only give them v3. */
  4602. + if (incompat & JBD2_FEATURE_INCOMPAT_CSUM_V3 &&
  4603. compat & JBD2_FEATURE_COMPAT_CHECKSUM)
  4604. compat &= ~JBD2_FEATURE_COMPAT_CHECKSUM;
  4605. @@ -1823,8 +1837,8 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
  4606. sb = journal->j_superblock;
  4607. - /* If enabling v2 checksums, update superblock */
  4608. - if (INCOMPAT_FEATURE_ON(JBD2_FEATURE_INCOMPAT_CSUM_V2)) {
  4609. + /* If enabling v3 checksums, update superblock */
  4610. + if (INCOMPAT_FEATURE_ON(JBD2_FEATURE_INCOMPAT_CSUM_V3)) {
  4611. sb->s_checksum_type = JBD2_CRC32C_CHKSUM;
  4612. sb->s_feature_compat &=
  4613. ~cpu_to_be32(JBD2_FEATURE_COMPAT_CHECKSUM);
  4614. @@ -1842,8 +1856,7 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
  4615. }
  4616. /* Precompute checksum seed for all metadata */
  4617. - if (JBD2_HAS_INCOMPAT_FEATURE(journal,
  4618. - JBD2_FEATURE_INCOMPAT_CSUM_V2))
  4619. + if (jbd2_journal_has_csum_v2or3(journal))
  4620. journal->j_csum_seed = jbd2_chksum(journal, ~0,
  4621. sb->s_uuid,
  4622. sizeof(sb->s_uuid));
  4623. @@ -1852,7 +1865,8 @@ int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
  4624. /* If enabling v1 checksums, downgrade superblock */
  4625. if (COMPAT_FEATURE_ON(JBD2_FEATURE_COMPAT_CHECKSUM))
  4626. sb->s_feature_incompat &=
  4627. - ~cpu_to_be32(JBD2_FEATURE_INCOMPAT_CSUM_V2);
  4628. + ~cpu_to_be32(JBD2_FEATURE_INCOMPAT_CSUM_V2 |
  4629. + JBD2_FEATURE_INCOMPAT_CSUM_V3);
  4630. sb->s_feature_compat |= cpu_to_be32(compat);
  4631. sb->s_feature_ro_compat |= cpu_to_be32(ro);
  4632. @@ -2165,16 +2179,20 @@ int jbd2_journal_blocks_per_page(struct inode *inode)
  4633. */
  4634. size_t journal_tag_bytes(journal_t *journal)
  4635. {
  4636. - journal_block_tag_t tag;
  4637. - size_t x = 0;
  4638. + size_t sz;
  4639. +
  4640. + if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V3))
  4641. + return sizeof(journal_block_tag3_t);
  4642. +
  4643. + sz = sizeof(journal_block_tag_t);
  4644. if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2))
  4645. - x += sizeof(tag.t_checksum);
  4646. + sz += sizeof(__u16);
  4647. if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT))
  4648. - return x + JBD2_TAG_SIZE64;
  4649. + return sz;
  4650. else
  4651. - return x + JBD2_TAG_SIZE32;
  4652. + return sz - sizeof(__u32);
  4653. }
  4654. /*
  4655. diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c
  4656. index 3b6bb19d60b1..9b329b55ffe3 100644
  4657. --- a/fs/jbd2/recovery.c
  4658. +++ b/fs/jbd2/recovery.c
  4659. @@ -181,7 +181,7 @@ static int jbd2_descr_block_csum_verify(journal_t *j,
  4660. __be32 provided;
  4661. __u32 calculated;
  4662. - if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
  4663. + if (!jbd2_journal_has_csum_v2or3(j))
  4664. return 1;
  4665. tail = (struct jbd2_journal_block_tail *)(buf + j->j_blocksize -
  4666. @@ -205,7 +205,7 @@ static int count_tags(journal_t *journal, struct buffer_head *bh)
  4667. int nr = 0, size = journal->j_blocksize;
  4668. int tag_bytes = journal_tag_bytes(journal);
  4669. - if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2))
  4670. + if (jbd2_journal_has_csum_v2or3(journal))
  4671. size -= sizeof(struct jbd2_journal_block_tail);
  4672. tagp = &bh->b_data[sizeof(journal_header_t)];
  4673. @@ -338,10 +338,11 @@ int jbd2_journal_skip_recovery(journal_t *journal)
  4674. return err;
  4675. }
  4676. -static inline unsigned long long read_tag_block(int tag_bytes, journal_block_tag_t *tag)
  4677. +static inline unsigned long long read_tag_block(journal_t *journal,
  4678. + journal_block_tag_t *tag)
  4679. {
  4680. unsigned long long block = be32_to_cpu(tag->t_blocknr);
  4681. - if (tag_bytes > JBD2_TAG_SIZE32)
  4682. + if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT))
  4683. block |= (u64)be32_to_cpu(tag->t_blocknr_high) << 32;
  4684. return block;
  4685. }
  4686. @@ -384,7 +385,7 @@ static int jbd2_commit_block_csum_verify(journal_t *j, void *buf)
  4687. __be32 provided;
  4688. __u32 calculated;
  4689. - if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
  4690. + if (!jbd2_journal_has_csum_v2or3(j))
  4691. return 1;
  4692. h = buf;
  4693. @@ -399,17 +400,21 @@ static int jbd2_commit_block_csum_verify(journal_t *j, void *buf)
  4694. static int jbd2_block_tag_csum_verify(journal_t *j, journal_block_tag_t *tag,
  4695. void *buf, __u32 sequence)
  4696. {
  4697. + journal_block_tag3_t *tag3 = (journal_block_tag3_t *)tag;
  4698. __u32 csum32;
  4699. __be32 seq;
  4700. - if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
  4701. + if (!jbd2_journal_has_csum_v2or3(j))
  4702. return 1;
  4703. seq = cpu_to_be32(sequence);
  4704. csum32 = jbd2_chksum(j, j->j_csum_seed, (__u8 *)&seq, sizeof(seq));
  4705. csum32 = jbd2_chksum(j, csum32, buf, j->j_blocksize);
  4706. - return tag->t_checksum == cpu_to_be16(csum32);
  4707. + if (JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V3))
  4708. + return tag3->t_checksum == cpu_to_be32(csum32);
  4709. + else
  4710. + return tag->t_checksum == cpu_to_be16(csum32);
  4711. }
  4712. static int do_one_pass(journal_t *journal,
  4713. @@ -426,6 +431,7 @@ static int do_one_pass(journal_t *journal,
  4714. int tag_bytes = journal_tag_bytes(journal);
  4715. __u32 crc32_sum = ~0; /* Transactional Checksums */
  4716. int descr_csum_size = 0;
  4717. + int block_error = 0;
  4718. /*
  4719. * First thing is to establish what we expect to find in the log
  4720. @@ -512,8 +518,7 @@ static int do_one_pass(journal_t *journal,
  4721. switch(blocktype) {
  4722. case JBD2_DESCRIPTOR_BLOCK:
  4723. /* Verify checksum first */
  4724. - if (JBD2_HAS_INCOMPAT_FEATURE(journal,
  4725. - JBD2_FEATURE_INCOMPAT_CSUM_V2))
  4726. + if (jbd2_journal_has_csum_v2or3(journal))
  4727. descr_csum_size =
  4728. sizeof(struct jbd2_journal_block_tail);
  4729. if (descr_csum_size > 0 &&
  4730. @@ -574,7 +579,7 @@ static int do_one_pass(journal_t *journal,
  4731. unsigned long long blocknr;
  4732. J_ASSERT(obh != NULL);
  4733. - blocknr = read_tag_block(tag_bytes,
  4734. + blocknr = read_tag_block(journal,
  4735. tag);
  4736. /* If the block has been
  4737. @@ -598,7 +603,8 @@ static int do_one_pass(journal_t *journal,
  4738. "checksum recovering "
  4739. "block %llu in log\n",
  4740. blocknr);
  4741. - continue;
  4742. + block_error = 1;
  4743. + goto skip_write;
  4744. }
  4745. /* Find a buffer for the new
  4746. @@ -797,7 +803,8 @@ static int do_one_pass(journal_t *journal,
  4747. success = -EIO;
  4748. }
  4749. }
  4750. -
  4751. + if (block_error && success == 0)
  4752. + success = -EIO;
  4753. return success;
  4754. failed:
  4755. @@ -811,7 +818,7 @@ static int jbd2_revoke_block_csum_verify(journal_t *j,
  4756. __be32 provided;
  4757. __u32 calculated;
  4758. - if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
  4759. + if (!jbd2_journal_has_csum_v2or3(j))
  4760. return 1;
  4761. tail = (struct jbd2_journal_revoke_tail *)(buf + j->j_blocksize -
  4762. diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c
  4763. index 198c9c10276d..d5e95a175c92 100644
  4764. --- a/fs/jbd2/revoke.c
  4765. +++ b/fs/jbd2/revoke.c
  4766. @@ -91,8 +91,8 @@
  4767. #include <linux/list.h>
  4768. #include <linux/init.h>
  4769. #include <linux/bio.h>
  4770. -#endif
  4771. #include <linux/log2.h>
  4772. +#endif
  4773. static struct kmem_cache *jbd2_revoke_record_cache;
  4774. static struct kmem_cache *jbd2_revoke_table_cache;
  4775. @@ -597,7 +597,7 @@ static void write_one_revoke_record(journal_t *journal,
  4776. offset = *offsetp;
  4777. /* Do we need to leave space at the end for a checksum? */
  4778. - if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2))
  4779. + if (jbd2_journal_has_csum_v2or3(journal))
  4780. csum_size = sizeof(struct jbd2_journal_revoke_tail);
  4781. /* Make sure we have a descriptor with space left for the record */
  4782. @@ -644,7 +644,7 @@ static void jbd2_revoke_csum_set(journal_t *j, struct buffer_head *bh)
  4783. struct jbd2_journal_revoke_tail *tail;
  4784. __u32 csum;
  4785. - if (!JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2))
  4786. + if (!jbd2_journal_has_csum_v2or3(j))
  4787. return;
  4788. tail = (struct jbd2_journal_revoke_tail *)(bh->b_data + j->j_blocksize -
  4789. diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c
  4790. index 8f854dde4150..24c6898159cc 100644
  4791. --- a/fs/nfs/nfs3acl.c
  4792. +++ b/fs/nfs/nfs3acl.c
  4793. @@ -129,7 +129,10 @@ static int __nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
  4794. .rpc_argp = &args,
  4795. .rpc_resp = &fattr,
  4796. };
  4797. - int status;
  4798. + int status = 0;
  4799. +
  4800. + if (acl == NULL && (!S_ISDIR(inode->i_mode) || dfacl == NULL))
  4801. + goto out;
  4802. status = -EOPNOTSUPP;
  4803. if (!nfs_server_capable(inode, NFS_CAP_ACLS))
  4804. @@ -256,7 +259,7 @@ nfs3_list_one_acl(struct inode *inode, int type, const char *name, void *data,
  4805. char *p = data + *result;
  4806. acl = get_acl(inode, type);
  4807. - if (!acl)
  4808. + if (IS_ERR_OR_NULL(acl))
  4809. return 0;
  4810. posix_acl_release(acl);
  4811. diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
  4812. index 4bf3d97cc5a0..dac979866f83 100644
  4813. --- a/fs/nfs/nfs4proc.c
  4814. +++ b/fs/nfs/nfs4proc.c
  4815. @@ -2545,6 +2545,7 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
  4816. struct nfs4_closedata *calldata = data;
  4817. struct nfs4_state *state = calldata->state;
  4818. struct nfs_server *server = NFS_SERVER(calldata->inode);
  4819. + nfs4_stateid *res_stateid = NULL;
  4820. dprintk("%s: begin!\n", __func__);
  4821. if (!nfs4_sequence_done(task, &calldata->res.seq_res))
  4822. @@ -2555,12 +2556,12 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
  4823. */
  4824. switch (task->tk_status) {
  4825. case 0:
  4826. - if (calldata->roc)
  4827. + res_stateid = &calldata->res.stateid;
  4828. + if (calldata->arg.fmode == 0 && calldata->roc)
  4829. pnfs_roc_set_barrier(state->inode,
  4830. calldata->roc_barrier);
  4831. - nfs_clear_open_stateid(state, &calldata->res.stateid, 0);
  4832. renew_lease(server, calldata->timestamp);
  4833. - goto out_release;
  4834. + break;
  4835. case -NFS4ERR_ADMIN_REVOKED:
  4836. case -NFS4ERR_STALE_STATEID:
  4837. case -NFS4ERR_OLD_STATEID:
  4838. @@ -2574,7 +2575,7 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
  4839. goto out_release;
  4840. }
  4841. }
  4842. - nfs_clear_open_stateid(state, NULL, calldata->arg.fmode);
  4843. + nfs_clear_open_stateid(state, res_stateid, calldata->arg.fmode);
  4844. out_release:
  4845. nfs_release_seqid(calldata->arg.seqid);
  4846. nfs_refresh_inode(calldata->inode, calldata->res.fattr);
  4847. @@ -2586,6 +2587,7 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
  4848. struct nfs4_closedata *calldata = data;
  4849. struct nfs4_state *state = calldata->state;
  4850. struct inode *inode = calldata->inode;
  4851. + bool is_rdonly, is_wronly, is_rdwr;
  4852. int call_close = 0;
  4853. dprintk("%s: begin!\n", __func__);
  4854. @@ -2593,18 +2595,24 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
  4855. goto out_wait;
  4856. task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE];
  4857. - calldata->arg.fmode = FMODE_READ|FMODE_WRITE;
  4858. spin_lock(&state->owner->so_lock);
  4859. + is_rdwr = test_bit(NFS_O_RDWR_STATE, &state->flags);
  4860. + is_rdonly = test_bit(NFS_O_RDONLY_STATE, &state->flags);
  4861. + is_wronly = test_bit(NFS_O_WRONLY_STATE, &state->flags);
  4862. + /* Calculate the current open share mode */
  4863. + calldata->arg.fmode = 0;
  4864. + if (is_rdonly || is_rdwr)
  4865. + calldata->arg.fmode |= FMODE_READ;
  4866. + if (is_wronly || is_rdwr)
  4867. + calldata->arg.fmode |= FMODE_WRITE;
  4868. /* Calculate the change in open mode */
  4869. if (state->n_rdwr == 0) {
  4870. if (state->n_rdonly == 0) {
  4871. - call_close |= test_bit(NFS_O_RDONLY_STATE, &state->flags);
  4872. - call_close |= test_bit(NFS_O_RDWR_STATE, &state->flags);
  4873. + call_close |= is_rdonly || is_rdwr;
  4874. calldata->arg.fmode &= ~FMODE_READ;
  4875. }
  4876. if (state->n_wronly == 0) {
  4877. - call_close |= test_bit(NFS_O_WRONLY_STATE, &state->flags);
  4878. - call_close |= test_bit(NFS_O_RDWR_STATE, &state->flags);
  4879. + call_close |= is_wronly || is_rdwr;
  4880. calldata->arg.fmode &= ~FMODE_WRITE;
  4881. }
  4882. }
  4883. diff --git a/fs/nfs/super.c b/fs/nfs/super.c
  4884. index 084af1060d79..3fd83327bbad 100644
  4885. --- a/fs/nfs/super.c
  4886. +++ b/fs/nfs/super.c
  4887. @@ -2180,7 +2180,7 @@ out_no_address:
  4888. return -EINVAL;
  4889. }
  4890. -#define NFS_MOUNT_CMP_FLAGMASK ~(NFS_MOUNT_INTR \
  4891. +#define NFS_REMOUNT_CMP_FLAGMASK ~(NFS_MOUNT_INTR \
  4892. | NFS_MOUNT_SECURE \
  4893. | NFS_MOUNT_TCP \
  4894. | NFS_MOUNT_VER3 \
  4895. @@ -2188,15 +2188,16 @@ out_no_address:
  4896. | NFS_MOUNT_NONLM \
  4897. | NFS_MOUNT_BROKEN_SUID \
  4898. | NFS_MOUNT_STRICTLOCK \
  4899. - | NFS_MOUNT_UNSHARED \
  4900. - | NFS_MOUNT_NORESVPORT \
  4901. | NFS_MOUNT_LEGACY_INTERFACE)
  4902. +#define NFS_MOUNT_CMP_FLAGMASK (NFS_REMOUNT_CMP_FLAGMASK & \
  4903. + ~(NFS_MOUNT_UNSHARED | NFS_MOUNT_NORESVPORT))
  4904. +
  4905. static int
  4906. nfs_compare_remount_data(struct nfs_server *nfss,
  4907. struct nfs_parsed_mount_data *data)
  4908. {
  4909. - if ((data->flags ^ nfss->flags) & NFS_MOUNT_CMP_FLAGMASK ||
  4910. + if ((data->flags ^ nfss->flags) & NFS_REMOUNT_CMP_FLAGMASK ||
  4911. data->rsize != nfss->rsize ||
  4912. data->wsize != nfss->wsize ||
  4913. data->version != nfss->nfs_client->rpc_ops->version ||
  4914. diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
  4915. index 2c73cae9899d..0f23ad005826 100644
  4916. --- a/fs/nfsd/nfs4callback.c
  4917. +++ b/fs/nfsd/nfs4callback.c
  4918. @@ -689,7 +689,8 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c
  4919. clp->cl_cb_session = ses;
  4920. args.bc_xprt = conn->cb_xprt;
  4921. args.prognumber = clp->cl_cb_session->se_cb_prog;
  4922. - args.protocol = XPRT_TRANSPORT_BC_TCP;
  4923. + args.protocol = conn->cb_xprt->xpt_class->xcl_ident |
  4924. + XPRT_TRANSPORT_BC;
  4925. args.authflavor = ses->se_cb_sec.flavor;
  4926. }
  4927. /* Create RPC client */
  4928. diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
  4929. index 1879e43f2868..2f2edbb2a4a3 100644
  4930. --- a/fs/nfsd/nfssvc.c
  4931. +++ b/fs/nfsd/nfssvc.c
  4932. @@ -221,7 +221,8 @@ static int nfsd_startup_generic(int nrservs)
  4933. */
  4934. ret = nfsd_racache_init(2*nrservs);
  4935. if (ret)
  4936. - return ret;
  4937. + goto dec_users;
  4938. +
  4939. ret = nfs4_state_start();
  4940. if (ret)
  4941. goto out_racache;
  4942. @@ -229,6 +230,8 @@ static int nfsd_startup_generic(int nrservs)
  4943. out_racache:
  4944. nfsd_racache_shutdown();
  4945. +dec_users:
  4946. + nfsd_users--;
  4947. return ret;
  4948. }
  4949. diff --git a/include/drm/drm_pciids.h b/include/drm/drm_pciids.h
  4950. index 6dfd64b3a604..e973540cd15b 100644
  4951. --- a/include/drm/drm_pciids.h
  4952. +++ b/include/drm/drm_pciids.h
  4953. @@ -17,6 +17,7 @@
  4954. {0x1002, 0x1315, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
  4955. {0x1002, 0x1316, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
  4956. {0x1002, 0x1317, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
  4957. + {0x1002, 0x1318, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
  4958. {0x1002, 0x131B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
  4959. {0x1002, 0x131C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
  4960. {0x1002, 0x131D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
  4961. @@ -164,8 +165,11 @@
  4962. {0x1002, 0x6601, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
  4963. {0x1002, 0x6602, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
  4964. {0x1002, 0x6603, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
  4965. + {0x1002, 0x6604, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
  4966. + {0x1002, 0x6605, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
  4967. {0x1002, 0x6606, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
  4968. {0x1002, 0x6607, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
  4969. + {0x1002, 0x6608, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \
  4970. {0x1002, 0x6610, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \
  4971. {0x1002, 0x6611, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \
  4972. {0x1002, 0x6613, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \
  4973. @@ -175,6 +179,8 @@
  4974. {0x1002, 0x6631, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \
  4975. {0x1002, 0x6640, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
  4976. {0x1002, 0x6641, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
  4977. + {0x1002, 0x6646, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
  4978. + {0x1002, 0x6647, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
  4979. {0x1002, 0x6649, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_NEW_MEMMAP}, \
  4980. {0x1002, 0x6650, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_NEW_MEMMAP}, \
  4981. {0x1002, 0x6651, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_NEW_MEMMAP}, \
  4982. @@ -297,6 +303,7 @@
  4983. {0x1002, 0x6829, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \
  4984. {0x1002, 0x682A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
  4985. {0x1002, 0x682B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
  4986. + {0x1002, 0x682C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \
  4987. {0x1002, 0x682D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
  4988. {0x1002, 0x682F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
  4989. {0x1002, 0x6830, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
  4990. diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
  4991. index d5b50a19463c..0dae71e9971c 100644
  4992. --- a/include/linux/jbd2.h
  4993. +++ b/include/linux/jbd2.h
  4994. @@ -159,7 +159,11 @@ typedef struct journal_header_s
  4995. * journal_block_tag (in the descriptor). The other h_chksum* fields are
  4996. * not used.
  4997. *
  4998. - * Checksum v1 and v2 are mutually exclusive features.
  4999. + * If FEATURE_INCOMPAT_CSUM_V3 is set, the descriptor block uses
  5000. + * journal_block_tag3_t to store a full 32-bit checksum. Everything else
  5001. + * is the same as v2.
  5002. + *
  5003. + * Checksum v1, v2, and v3 are mutually exclusive features.
  5004. */
  5005. struct commit_header {
  5006. __be32 h_magic;
  5007. @@ -179,6 +183,14 @@ struct commit_header {
  5008. * raw struct shouldn't be used for pointer math or sizeof() - use
  5009. * journal_tag_bytes(journal) instead to compute this.
  5010. */
  5011. +typedef struct journal_block_tag3_s
  5012. +{
  5013. + __be32 t_blocknr; /* The on-disk block number */
  5014. + __be32 t_flags; /* See below */
  5015. + __be32 t_blocknr_high; /* most-significant high 32bits. */
  5016. + __be32 t_checksum; /* crc32c(uuid+seq+block) */
  5017. +} journal_block_tag3_t;
  5018. +
  5019. typedef struct journal_block_tag_s
  5020. {
  5021. __be32 t_blocknr; /* The on-disk block number */
  5022. @@ -187,9 +199,6 @@ typedef struct journal_block_tag_s
  5023. __be32 t_blocknr_high; /* most-significant high 32bits. */
  5024. } journal_block_tag_t;
  5025. -#define JBD2_TAG_SIZE32 (offsetof(journal_block_tag_t, t_blocknr_high))
  5026. -#define JBD2_TAG_SIZE64 (sizeof(journal_block_tag_t))
  5027. -
  5028. /* Tail of descriptor block, for checksumming */
  5029. struct jbd2_journal_block_tail {
  5030. __be32 t_checksum; /* crc32c(uuid+descr_block) */
  5031. @@ -284,6 +293,7 @@ typedef struct journal_superblock_s
  5032. #define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002
  5033. #define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004
  5034. #define JBD2_FEATURE_INCOMPAT_CSUM_V2 0x00000008
  5035. +#define JBD2_FEATURE_INCOMPAT_CSUM_V3 0x00000010
  5036. /* Features known to this kernel version: */
  5037. #define JBD2_KNOWN_COMPAT_FEATURES JBD2_FEATURE_COMPAT_CHECKSUM
  5038. @@ -291,7 +301,8 @@ typedef struct journal_superblock_s
  5039. #define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE | \
  5040. JBD2_FEATURE_INCOMPAT_64BIT | \
  5041. JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT | \
  5042. - JBD2_FEATURE_INCOMPAT_CSUM_V2)
  5043. + JBD2_FEATURE_INCOMPAT_CSUM_V2 | \
  5044. + JBD2_FEATURE_INCOMPAT_CSUM_V3)
  5045. #ifdef __KERNEL__
  5046. @@ -1296,6 +1307,15 @@ static inline int tid_geq(tid_t x, tid_t y)
  5047. extern int jbd2_journal_blocks_per_page(struct inode *inode);
  5048. extern size_t journal_tag_bytes(journal_t *journal);
  5049. +static inline int jbd2_journal_has_csum_v2or3(journal_t *journal)
  5050. +{
  5051. + if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2) ||
  5052. + JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V3))
  5053. + return 1;
  5054. +
  5055. + return 0;
  5056. +}
  5057. +
  5058. /*
  5059. * We reserve t_outstanding_credits >> JBD2_CONTROL_BLOCKS_SHIFT for
  5060. * transaction control blocks.
  5061. diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h
  5062. index 7235040a19b2..5d9d6f84b382 100644
  5063. --- a/include/linux/sunrpc/svc_xprt.h
  5064. +++ b/include/linux/sunrpc/svc_xprt.h
  5065. @@ -33,6 +33,7 @@ struct svc_xprt_class {
  5066. struct svc_xprt_ops *xcl_ops;
  5067. struct list_head xcl_list;
  5068. u32 xcl_max_payload;
  5069. + int xcl_ident;
  5070. };
  5071. /*
  5072. diff --git a/kernel/sched/core.c b/kernel/sched/core.c
  5073. index bc1638b33449..0acf96b790c5 100644
  5074. --- a/kernel/sched/core.c
  5075. +++ b/kernel/sched/core.c
  5076. @@ -3558,9 +3558,10 @@ static int _sched_setscheduler(struct task_struct *p, int policy,
  5077. };
  5078. /*
  5079. - * Fixup the legacy SCHED_RESET_ON_FORK hack
  5080. + * Fixup the legacy SCHED_RESET_ON_FORK hack, except if
  5081. + * the policy=-1 was passed by sched_setparam().
  5082. */
  5083. - if (policy & SCHED_RESET_ON_FORK) {
  5084. + if ((policy != -1) && (policy & SCHED_RESET_ON_FORK)) {
  5085. attr.sched_flags |= SCHED_FLAG_RESET_ON_FORK;
  5086. policy &= ~SCHED_RESET_ON_FORK;
  5087. attr.sched_policy = policy;
  5088. diff --git a/mm/memory.c b/mm/memory.c
  5089. index 8b44f765b645..0a21f3d162ae 100644
  5090. --- a/mm/memory.c
  5091. +++ b/mm/memory.c
  5092. @@ -751,7 +751,7 @@ struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
  5093. unsigned long pfn = pte_pfn(pte);
  5094. if (HAVE_PTE_SPECIAL) {
  5095. - if (likely(!pte_special(pte) || pte_numa(pte)))
  5096. + if (likely(!pte_special(pte)))
  5097. goto check_pfn;
  5098. if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
  5099. return NULL;
  5100. @@ -777,15 +777,14 @@ struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
  5101. }
  5102. }
  5103. + if (is_zero_pfn(pfn))
  5104. + return NULL;
  5105. check_pfn:
  5106. if (unlikely(pfn > highest_memmap_pfn)) {
  5107. print_bad_pte(vma, addr, pte, NULL);
  5108. return NULL;
  5109. }
  5110. - if (is_zero_pfn(pfn))
  5111. - return NULL;
  5112. -
  5113. /*
  5114. * NOTE! We still have PageReserved() pages in the page tables.
  5115. * eg. VDSO mappings can cause them to exist.
  5116. diff --git a/mm/util.c b/mm/util.c
  5117. index d5ea733c5082..33e9f4455800 100644
  5118. --- a/mm/util.c
  5119. +++ b/mm/util.c
  5120. @@ -277,17 +277,14 @@ pid_t vm_is_stack(struct task_struct *task,
  5121. if (in_group) {
  5122. struct task_struct *t;
  5123. - rcu_read_lock();
  5124. - if (!pid_alive(task))
  5125. - goto done;
  5126. - t = task;
  5127. - do {
  5128. + rcu_read_lock();
  5129. + for_each_thread(task, t) {
  5130. if (vm_is_stack_for_task(t, vma)) {
  5131. ret = t->pid;
  5132. goto done;
  5133. }
  5134. - } while_each_thread(task, t);
  5135. + }
  5136. done:
  5137. rcu_read_unlock();
  5138. }
  5139. diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
  5140. index b507cd327d9b..b2437ee93657 100644
  5141. --- a/net/sunrpc/svcsock.c
  5142. +++ b/net/sunrpc/svcsock.c
  5143. @@ -692,6 +692,7 @@ static struct svc_xprt_class svc_udp_class = {
  5144. .xcl_owner = THIS_MODULE,
  5145. .xcl_ops = &svc_udp_ops,
  5146. .xcl_max_payload = RPCSVC_MAXPAYLOAD_UDP,
  5147. + .xcl_ident = XPRT_TRANSPORT_UDP,
  5148. };
  5149. static void svc_udp_init(struct svc_sock *svsk, struct svc_serv *serv)
  5150. @@ -1292,6 +1293,7 @@ static struct svc_xprt_class svc_tcp_class = {
  5151. .xcl_owner = THIS_MODULE,
  5152. .xcl_ops = &svc_tcp_ops,
  5153. .xcl_max_payload = RPCSVC_MAXPAYLOAD_TCP,
  5154. + .xcl_ident = XPRT_TRANSPORT_TCP,
  5155. };
  5156. void svc_init_xprt_sock(void)
  5157. diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
  5158. index c3b2b3369e52..51c63165073c 100644
  5159. --- a/net/sunrpc/xprt.c
  5160. +++ b/net/sunrpc/xprt.c
  5161. @@ -1306,7 +1306,7 @@ struct rpc_xprt *xprt_create_transport(struct xprt_create *args)
  5162. }
  5163. }
  5164. spin_unlock(&xprt_list_lock);
  5165. - printk(KERN_ERR "RPC: transport (%d) not supported\n", args->ident);
  5166. + dprintk("RPC: transport (%d) not supported\n", args->ident);
  5167. return ERR_PTR(-EIO);
  5168. found:
  5169. diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
  5170. index e7323fbbd348..06a5d9235107 100644
  5171. --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
  5172. +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
  5173. @@ -92,6 +92,7 @@ struct svc_xprt_class svc_rdma_class = {
  5174. .xcl_owner = THIS_MODULE,
  5175. .xcl_ops = &svc_rdma_ops,
  5176. .xcl_max_payload = RPCSVC_MAXPAYLOAD_TCP,
  5177. + .xcl_ident = XPRT_TRANSPORT_RDMA,
  5178. };
  5179. struct svc_rdma_op_ctxt *svc_rdma_get_context(struct svcxprt_rdma *xprt)
  5180. diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
  5181. index 3a3a3a71088b..50dd0086cfb1 100644
  5182. --- a/sound/pci/Kconfig
  5183. +++ b/sound/pci/Kconfig
  5184. @@ -858,8 +858,8 @@ config SND_VIRTUOSO
  5185. select SND_JACK if INPUT=y || INPUT=SND
  5186. help
  5187. Say Y here to include support for sound cards based on the
  5188. - Asus AV66/AV100/AV200 chips, i.e., Xonar D1, DX, D2, D2X, DS,
  5189. - Essence ST (Deluxe), and Essence STX.
  5190. + Asus AV66/AV100/AV200 chips, i.e., Xonar D1, DX, D2, D2X, DS, DSX,
  5191. + Essence ST (Deluxe), and Essence STX (II).
  5192. Support for the HDAV1.3 (Deluxe) and HDAV1.3 Slim is experimental;
  5193. for the Xense, missing.
  5194. diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
  5195. index 092f2bd030bd..b686aca7f000 100644
  5196. --- a/sound/pci/hda/patch_ca0132.c
  5197. +++ b/sound/pci/hda/patch_ca0132.c
  5198. @@ -4376,6 +4376,9 @@ static void ca0132_download_dsp(struct hda_codec *codec)
  5199. return; /* NOP */
  5200. #endif
  5201. + if (spec->dsp_state == DSP_DOWNLOAD_FAILED)
  5202. + return; /* don't retry failures */
  5203. +
  5204. chipio_enable_clocks(codec);
  5205. spec->dsp_state = DSP_DOWNLOADING;
  5206. if (!ca0132_download_dsp_images(codec))
  5207. @@ -4552,7 +4555,8 @@ static int ca0132_init(struct hda_codec *codec)
  5208. struct auto_pin_cfg *cfg = &spec->autocfg;
  5209. int i;
  5210. - spec->dsp_state = DSP_DOWNLOAD_INIT;
  5211. + if (spec->dsp_state != DSP_DOWNLOAD_FAILED)
  5212. + spec->dsp_state = DSP_DOWNLOAD_INIT;
  5213. spec->curr_chip_addx = INVALID_CHIP_ADDRESS;
  5214. snd_hda_power_up(codec);
  5215. @@ -4663,6 +4667,7 @@ static int patch_ca0132(struct hda_codec *codec)
  5216. codec->spec = spec;
  5217. spec->codec = codec;
  5218. + spec->dsp_state = DSP_DOWNLOAD_INIT;
  5219. spec->num_mixers = 1;
  5220. spec->mixers[0] = ca0132_mixer;
  5221. diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
  5222. index b60824e90408..25728aaacc26 100644
  5223. --- a/sound/pci/hda/patch_realtek.c
  5224. +++ b/sound/pci/hda/patch_realtek.c
  5225. @@ -180,6 +180,8 @@ static void alc_fix_pll(struct hda_codec *codec)
  5226. spec->pll_coef_idx);
  5227. val = snd_hda_codec_read(codec, spec->pll_nid, 0,
  5228. AC_VERB_GET_PROC_COEF, 0);
  5229. + if (val == -1)
  5230. + return;
  5231. snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
  5232. spec->pll_coef_idx);
  5233. snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
  5234. @@ -2784,6 +2786,8 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
  5235. static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
  5236. {
  5237. int val = alc_read_coef_idx(codec, 0x04);
  5238. + if (val == -1)
  5239. + return;
  5240. if (power_up)
  5241. val |= 1 << 11;
  5242. else
  5243. @@ -3242,6 +3246,15 @@ static int alc269_resume(struct hda_codec *codec)
  5244. snd_hda_codec_resume_cache(codec);
  5245. alc_inv_dmic_sync(codec, true);
  5246. hda_call_check_power_status(codec, 0x01);
  5247. +
  5248. + /* on some machine, the BIOS will clear the codec gpio data when enter
  5249. + * suspend, and won't restore the data after resume, so we restore it
  5250. + * in the driver.
  5251. + */
  5252. + if (spec->gpio_led)
  5253. + snd_hda_codec_write(codec, codec->afg, 0, AC_VERB_SET_GPIO_DATA,
  5254. + spec->gpio_led);
  5255. +
  5256. if (spec->has_alc5505_dsp)
  5257. alc5505_dsp_resume(codec);
  5258. @@ -4782,6 +4795,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
  5259. SND_PCI_QUIRK(0x103c, 0x1983, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1),
  5260. SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
  5261. /* ALC282 */
  5262. + SND_PCI_QUIRK(0x103c, 0x2191, "HP Touchsmart 14", ALC269_FIXUP_HP_MUTE_LED_MIC1),
  5263. + SND_PCI_QUIRK(0x103c, 0x2192, "HP Touchsmart 15", ALC269_FIXUP_HP_MUTE_LED_MIC1),
  5264. SND_PCI_QUIRK(0x103c, 0x220d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
  5265. SND_PCI_QUIRK(0x103c, 0x220e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
  5266. SND_PCI_QUIRK(0x103c, 0x220f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
  5267. @@ -5122,27 +5137,30 @@ static void alc269_fill_coef(struct hda_codec *codec)
  5268. if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
  5269. val = alc_read_coef_idx(codec, 0x04);
  5270. /* Power up output pin */
  5271. - alc_write_coef_idx(codec, 0x04, val | (1<<11));
  5272. + if (val != -1)
  5273. + alc_write_coef_idx(codec, 0x04, val | (1<<11));
  5274. }
  5275. if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
  5276. val = alc_read_coef_idx(codec, 0xd);
  5277. - if ((val & 0x0c00) >> 10 != 0x1) {
  5278. + if (val != -1 && (val & 0x0c00) >> 10 != 0x1) {
  5279. /* Capless ramp up clock control */
  5280. alc_write_coef_idx(codec, 0xd, val | (1<<10));
  5281. }
  5282. val = alc_read_coef_idx(codec, 0x17);
  5283. - if ((val & 0x01c0) >> 6 != 0x4) {
  5284. + if (val != -1 && (val & 0x01c0) >> 6 != 0x4) {
  5285. /* Class D power on reset */
  5286. alc_write_coef_idx(codec, 0x17, val | (1<<7));
  5287. }
  5288. }
  5289. val = alc_read_coef_idx(codec, 0xd); /* Class D */
  5290. - alc_write_coef_idx(codec, 0xd, val | (1<<14));
  5291. + if (val != -1)
  5292. + alc_write_coef_idx(codec, 0xd, val | (1<<14));
  5293. val = alc_read_coef_idx(codec, 0x4); /* HP */
  5294. - alc_write_coef_idx(codec, 0x4, val | (1<<11));
  5295. + if (val != -1)
  5296. + alc_write_coef_idx(codec, 0x4, val | (1<<11));
  5297. }
  5298. /*
  5299. diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
  5300. index 3744ea4e843d..4d3a3b932690 100644
  5301. --- a/sound/pci/hda/patch_sigmatel.c
  5302. +++ b/sound/pci/hda/patch_sigmatel.c
  5303. @@ -84,6 +84,7 @@ enum {
  5304. STAC_DELL_EQ,
  5305. STAC_ALIENWARE_M17X,
  5306. STAC_92HD89XX_HP_FRONT_JACK,
  5307. + STAC_92HD89XX_HP_Z1_G2_RIGHT_MIC_JACK,
  5308. STAC_92HD73XX_MODELS
  5309. };
  5310. @@ -1809,6 +1810,11 @@ static const struct hda_pintbl stac92hd89xx_hp_front_jack_pin_configs[] = {
  5311. {}
  5312. };
  5313. +static const struct hda_pintbl stac92hd89xx_hp_z1_g2_right_mic_jack_pin_configs[] = {
  5314. + { 0x0e, 0x400000f0 },
  5315. + {}
  5316. +};
  5317. +
  5318. static void stac92hd73xx_fixup_ref(struct hda_codec *codec,
  5319. const struct hda_fixup *fix, int action)
  5320. {
  5321. @@ -1931,6 +1937,10 @@ static const struct hda_fixup stac92hd73xx_fixups[] = {
  5322. [STAC_92HD89XX_HP_FRONT_JACK] = {
  5323. .type = HDA_FIXUP_PINS,
  5324. .v.pins = stac92hd89xx_hp_front_jack_pin_configs,
  5325. + },
  5326. + [STAC_92HD89XX_HP_Z1_G2_RIGHT_MIC_JACK] = {
  5327. + .type = HDA_FIXUP_PINS,
  5328. + .v.pins = stac92hd89xx_hp_z1_g2_right_mic_jack_pin_configs,
  5329. }
  5330. };
  5331. @@ -1991,6 +2001,8 @@ static const struct snd_pci_quirk stac92hd73xx_fixup_tbl[] = {
  5332. "Alienware M17x", STAC_ALIENWARE_M17X),
  5333. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
  5334. "Alienware M17x R3", STAC_DELL_EQ),
  5335. + SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1927,
  5336. + "HP Z1 G2", STAC_92HD89XX_HP_Z1_G2_RIGHT_MIC_JACK),
  5337. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2b17,
  5338. "unknown HP", STAC_92HD89XX_HP_FRONT_JACK),
  5339. {} /* terminator */
  5340. diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
  5341. index 64b9fda5f04a..dbbbacfd535e 100644
  5342. --- a/sound/pci/oxygen/virtuoso.c
  5343. +++ b/sound/pci/oxygen/virtuoso.c
  5344. @@ -53,6 +53,7 @@ static DEFINE_PCI_DEVICE_TABLE(xonar_ids) = {
  5345. { OXYGEN_PCI_SUBID(0x1043, 0x835e) },
  5346. { OXYGEN_PCI_SUBID(0x1043, 0x838e) },
  5347. { OXYGEN_PCI_SUBID(0x1043, 0x8522) },
  5348. + { OXYGEN_PCI_SUBID(0x1043, 0x85f4) },
  5349. { OXYGEN_PCI_SUBID_BROKEN_EEPROM },
  5350. { }
  5351. };
  5352. diff --git a/sound/pci/oxygen/xonar_pcm179x.c b/sound/pci/oxygen/xonar_pcm179x.c
  5353. index c8c7f2c9b355..e02605931669 100644
  5354. --- a/sound/pci/oxygen/xonar_pcm179x.c
  5355. +++ b/sound/pci/oxygen/xonar_pcm179x.c
  5356. @@ -100,8 +100,8 @@
  5357. */
  5358. /*
  5359. - * Xonar Essence ST (Deluxe)/STX
  5360. - * -----------------------------
  5361. + * Xonar Essence ST (Deluxe)/STX (II)
  5362. + * ----------------------------------
  5363. *
  5364. * CMI8788:
  5365. *
  5366. @@ -1138,6 +1138,14 @@ int get_xonar_pcm179x_model(struct oxygen *chip,
  5367. chip->model.resume = xonar_stx_resume;
  5368. chip->model.set_dac_params = set_pcm1796_params;
  5369. break;
  5370. + case 0x85f4:
  5371. + chip->model = model_xonar_st;
  5372. + /* TODO: daughterboard support */
  5373. + chip->model.shortname = "Xonar STX II";
  5374. + chip->model.init = xonar_stx_init;
  5375. + chip->model.resume = xonar_stx_resume;
  5376. + chip->model.set_dac_params = set_pcm1796_params;
  5377. + break;
  5378. default:
  5379. return -EINVAL;
  5380. }
  5381. diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
  5382. index f652b10ce905..223c47b33ba3 100644
  5383. --- a/sound/usb/quirks-table.h
  5384. +++ b/sound/usb/quirks-table.h
  5385. @@ -1581,6 +1581,35 @@ YAMAHA_DEVICE(0x7010, "UB99"),
  5386. }
  5387. },
  5388. {
  5389. + /* BOSS ME-25 */
  5390. + USB_DEVICE(0x0582, 0x0113),
  5391. + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
  5392. + .ifnum = QUIRK_ANY_INTERFACE,
  5393. + .type = QUIRK_COMPOSITE,
  5394. + .data = (const struct snd_usb_audio_quirk[]) {
  5395. + {
  5396. + .ifnum = 0,
  5397. + .type = QUIRK_AUDIO_STANDARD_INTERFACE
  5398. + },
  5399. + {
  5400. + .ifnum = 1,
  5401. + .type = QUIRK_AUDIO_STANDARD_INTERFACE
  5402. + },
  5403. + {
  5404. + .ifnum = 2,
  5405. + .type = QUIRK_MIDI_FIXED_ENDPOINT,
  5406. + .data = & (const struct snd_usb_midi_endpoint_info) {
  5407. + .out_cables = 0x0001,
  5408. + .in_cables = 0x0001
  5409. + }
  5410. + },
  5411. + {
  5412. + .ifnum = -1
  5413. + }
  5414. + }
  5415. + }
  5416. +},
  5417. +{
  5418. /* only 44.1 kHz works at the moment */
  5419. USB_DEVICE(0x0582, 0x0120),
  5420. .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
  5421. diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
  5422. index 7c57f2268dd7..19a921eb75f1 100644
  5423. --- a/sound/usb/quirks.c
  5424. +++ b/sound/usb/quirks.c
  5425. @@ -670,7 +670,7 @@ static int snd_usb_gamecon780_boot_quirk(struct usb_device *dev)
  5426. /* set the initial volume and don't change; other values are either
  5427. * too loud or silent due to firmware bug (bko#65251)
  5428. */
  5429. - u8 buf[2] = { 0x74, 0xdc };
  5430. + u8 buf[2] = { 0x74, 0xe3 };
  5431. return snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR,
  5432. USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
  5433. UAC_FU_VOLUME << 8, 9 << 8, buf, 2);
  5434. diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
  5435. index 2458a1dc2ba9..e8ce34c9db32 100644
  5436. --- a/virt/kvm/ioapic.c
  5437. +++ b/virt/kvm/ioapic.c
  5438. @@ -254,10 +254,9 @@ void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap,
  5439. spin_lock(&ioapic->lock);
  5440. for (index = 0; index < IOAPIC_NUM_PINS; index++) {
  5441. e = &ioapic->redirtbl[index];
  5442. - if (!e->fields.mask &&
  5443. - (e->fields.trig_mode == IOAPIC_LEVEL_TRIG ||
  5444. - kvm_irq_has_notifier(ioapic->kvm, KVM_IRQCHIP_IOAPIC,
  5445. - index) || index == RTC_GSI)) {
  5446. + if (e->fields.trig_mode == IOAPIC_LEVEL_TRIG ||
  5447. + kvm_irq_has_notifier(ioapic->kvm, KVM_IRQCHIP_IOAPIC, index) ||
  5448. + index == RTC_GSI) {
  5449. if (kvm_apic_match_dest(vcpu, NULL, 0,
  5450. e->fields.dest_id, e->fields.dest_mode)) {
  5451. __set_bit(e->fields.vector,
  5452. diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c
  5453. index 0df7d4b34dfe..714b94932312 100644
  5454. --- a/virt/kvm/iommu.c
  5455. +++ b/virt/kvm/iommu.c
  5456. @@ -61,6 +61,14 @@ static pfn_t kvm_pin_pages(struct kvm_memory_slot *slot, gfn_t gfn,
  5457. return pfn;
  5458. }
  5459. +static void kvm_unpin_pages(struct kvm *kvm, pfn_t pfn, unsigned long npages)
  5460. +{
  5461. + unsigned long i;
  5462. +
  5463. + for (i = 0; i < npages; ++i)
  5464. + kvm_release_pfn_clean(pfn + i);
  5465. +}
  5466. +
  5467. int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot)
  5468. {
  5469. gfn_t gfn, end_gfn;
  5470. @@ -123,6 +131,7 @@ int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot)
  5471. if (r) {
  5472. printk(KERN_ERR "kvm_iommu_map_address:"
  5473. "iommu failed to map pfn=%llx\n", pfn);
  5474. + kvm_unpin_pages(kvm, pfn, page_size);
  5475. goto unmap_pages;
  5476. }
  5477. @@ -134,7 +143,7 @@ int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot)
  5478. return 0;
  5479. unmap_pages:
  5480. - kvm_iommu_put_pages(kvm, slot->base_gfn, gfn);
  5481. + kvm_iommu_put_pages(kvm, slot->base_gfn, gfn - slot->base_gfn);
  5482. return r;
  5483. }
  5484. @@ -266,14 +275,6 @@ out_unlock:
  5485. return r;
  5486. }
  5487. -static void kvm_unpin_pages(struct kvm *kvm, pfn_t pfn, unsigned long npages)
  5488. -{
  5489. - unsigned long i;
  5490. -
  5491. - for (i = 0; i < npages; ++i)
  5492. - kvm_release_pfn_clean(pfn + i);
  5493. -}
  5494. -
  5495. static void kvm_iommu_put_pages(struct kvm *kvm,
  5496. gfn_t base_gfn, unsigned long npages)
  5497. {