···28682868 },28692869 .driver_data = "F.23", /* cutoff BIOS version */28702870 },28712871+ /*28722872+ * Acer eMachines G725 has the same problem. BIOS28732873+ * V1.03 is known to be broken. V3.04 is known to28742874+ * work. Inbetween, there are V1.06, V2.06 and V3.0328752875+ * that we don't have much idea about. For now,28762876+ * blacklist anything older than V3.04.28772877+ */28782878+ {28792879+ .ident = "G725",28802880+ .matches = {28812881+ DMI_MATCH(DMI_SYS_VENDOR, "eMachines"),28822882+ DMI_MATCH(DMI_PRODUCT_NAME, "eMachines G725"),28832883+ },28842884+ .driver_data = "V3.04", /* cutoff BIOS version */28852885+ },28712886 { } /* terminate list */28722887 };28732888 const struct dmi_system_id *dmi = dmi_first_match(sysids);
+1-1
drivers/ata/libata-scsi.c
···28752875 * write indication (used for PIO/DMA setup), result TF is28762876 * copied back and we don't whine too much about its failure.28772877 */28782878- tf->flags = ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;28782878+ tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;28792879 if (scmd->sc_data_direction == DMA_TO_DEVICE)28802880 tf->flags |= ATA_TFLAG_WRITE;28812881
···4848 */4949#define RS_DEFAULT (RS_DUAL)50505151+/* A bitmask with bits enough for enum sh_dmae_slave_chan_id */5252+static unsigned long sh_dmae_slave_used[BITS_TO_LONGS(SHDMA_SLAVE_NUMBER)];5353+5154static void sh_dmae_chan_ld_cleanup(struct sh_dmae_chan *sh_chan, bool all);52555356#define SH_DMAC_CHAN_BASE(id) (dma_base_addr[id])5457static void sh_dmae_writel(struct sh_dmae_chan *sh_dc, u32 data, u32 reg)5558{5656- ctrl_outl(data, (SH_DMAC_CHAN_BASE(sh_dc->id) + reg));5959+ ctrl_outl(data, SH_DMAC_CHAN_BASE(sh_dc->id) + reg);5760}58615962static u32 sh_dmae_readl(struct sh_dmae_chan *sh_dc, u32 reg)6063{6161- return ctrl_inl((SH_DMAC_CHAN_BASE(sh_dc->id) + reg));6262-}6363-6464-static void dmae_init(struct sh_dmae_chan *sh_chan)6565-{6666- u32 chcr = RS_DEFAULT; /* default is DUAL mode */6767- sh_dmae_writel(sh_chan, chcr, CHCR);6464+ return ctrl_inl(SH_DMAC_CHAN_BASE(sh_dc->id) + reg);6865}69667067/*···9295 return 0;9396}94979595-static int dmae_is_busy(struct sh_dmae_chan *sh_chan)9898+static bool dmae_is_busy(struct sh_dmae_chan *sh_chan)9699{97100 u32 chcr = sh_dmae_readl(sh_chan, CHCR);9898- if (chcr & CHCR_DE) {9999- if (!(chcr & CHCR_TE))100100- return -EBUSY; /* working */101101- }102102- return 0; /* waiting */101101+102102+ if ((chcr & (CHCR_DE | CHCR_TE)) == CHCR_DE)103103+ return true; /* working */104104+105105+ return false; /* waiting */103106}104107105105-static inline unsigned int calc_xmit_shift(struct sh_dmae_chan *sh_chan)108108+static unsigned int ts_shift[] = TS_SHIFT;109109+static inline unsigned int calc_xmit_shift(u32 chcr)106110{107107- u32 chcr = sh_dmae_readl(sh_chan, CHCR);108108- return ts_shift[(chcr & CHCR_TS_MASK) >> CHCR_TS_SHIFT];111111+ int cnt = ((chcr & CHCR_TS_LOW_MASK) >> CHCR_TS_LOW_SHIFT) |112112+ ((chcr & CHCR_TS_HIGH_MASK) >> CHCR_TS_HIGH_SHIFT);113113+114114+ return ts_shift[cnt];109115}110116111117static void dmae_set_reg(struct sh_dmae_chan *sh_chan, struct sh_dmae_regs *hw)112118{113119 sh_dmae_writel(sh_chan, hw->sar, SAR);114120 sh_dmae_writel(sh_chan, hw->dar, DAR);115115- sh_dmae_writel(sh_chan, hw->tcr >> calc_xmit_shift(sh_chan), TCR);121121+ sh_dmae_writel(sh_chan, hw->tcr >> sh_chan->xmit_shift, TCR);116122}117123118124static void dmae_start(struct sh_dmae_chan *sh_chan)···123123 u32 chcr = sh_dmae_readl(sh_chan, CHCR);124124125125 chcr |= CHCR_DE | CHCR_IE;126126- sh_dmae_writel(sh_chan, chcr, CHCR);126126+ sh_dmae_writel(sh_chan, chcr & ~CHCR_TE, CHCR);127127}128128129129static void dmae_halt(struct sh_dmae_chan *sh_chan)···134134 sh_dmae_writel(sh_chan, chcr, CHCR);135135}136136137137+static void dmae_init(struct sh_dmae_chan *sh_chan)138138+{139139+ u32 chcr = RS_DEFAULT; /* default is DUAL mode */140140+ sh_chan->xmit_shift = calc_xmit_shift(chcr);141141+ sh_dmae_writel(sh_chan, chcr, CHCR);142142+}143143+137144static int dmae_set_chcr(struct sh_dmae_chan *sh_chan, u32 val)138145{139139- int ret = dmae_is_busy(sh_chan);140146 /* When DMA was working, can not set data to CHCR */141141- if (ret)142142- return ret;147147+ if (dmae_is_busy(sh_chan))148148+ return -EBUSY;143149150150+ sh_chan->xmit_shift = calc_xmit_shift(val);144151 sh_dmae_writel(sh_chan, val, CHCR);152152+145153 return 0;146154}147155148148-#define DMARS1_ADDR 0x04149149-#define DMARS2_ADDR 0x08150150-#define DMARS_SHIFT 8151151-#define DMARS_CHAN_MSK 0x01156156+#define DMARS_SHIFT 8157157+#define DMARS_CHAN_MSK 0x01152158static int dmae_set_dmars(struct sh_dmae_chan *sh_chan, u16 val)153159{154160 u32 addr;155161 int shift = 0;156156- int ret = dmae_is_busy(sh_chan);157157- if (ret)158158- return ret;162162+163163+ if (dmae_is_busy(sh_chan))164164+ return -EBUSY;159165160166 if (sh_chan->id & DMARS_CHAN_MSK)161167 shift = DMARS_SHIFT;162168163163- switch (sh_chan->id) {164164- /* DMARS0 */165165- case 0:166166- case 1:167167- addr = SH_DMARS_BASE;168168- break;169169- /* DMARS1 */170170- case 2:171171- case 3:172172- addr = (SH_DMARS_BASE + DMARS1_ADDR);173173- break;174174- /* DMARS2 */175175- case 4:176176- case 5:177177- addr = (SH_DMARS_BASE + DMARS2_ADDR);178178- break;179179- default:169169+ if (sh_chan->id < 6)170170+ /* DMA0RS0 - DMA0RS2 */171171+ addr = SH_DMARS_BASE0 + (sh_chan->id / 2) * 4;172172+#ifdef SH_DMARS_BASE1173173+ else if (sh_chan->id < 12)174174+ /* DMA1RS0 - DMA1RS2 */175175+ addr = SH_DMARS_BASE1 + ((sh_chan->id - 6) / 2) * 4;176176+#endif177177+ else180178 return -EINVAL;181181- }182179183183- ctrl_outw((val << shift) |184184- (ctrl_inw(addr) & (shift ? 0xFF00 : 0x00FF)),185185- addr);180180+ ctrl_outw((val << shift) | (ctrl_inw(addr) & (0xFF00 >> shift)), addr);186181187182 return 0;188183}···245250 return NULL;246251}247252253253+static struct sh_dmae_slave_config *sh_dmae_find_slave(254254+ struct sh_dmae_chan *sh_chan, enum sh_dmae_slave_chan_id slave_id)255255+{256256+ struct dma_device *dma_dev = sh_chan->common.device;257257+ struct sh_dmae_device *shdev = container_of(dma_dev,258258+ struct sh_dmae_device, common);259259+ struct sh_dmae_pdata *pdata = &shdev->pdata;260260+ int i;261261+262262+ if ((unsigned)slave_id >= SHDMA_SLAVE_NUMBER)263263+ return NULL;264264+265265+ for (i = 0; i < pdata->config_num; i++)266266+ if (pdata->config[i].slave_id == slave_id)267267+ return pdata->config + i;268268+269269+ return NULL;270270+}271271+248272static int sh_dmae_alloc_chan_resources(struct dma_chan *chan)249273{250274 struct sh_dmae_chan *sh_chan = to_sh_chan(chan);251275 struct sh_desc *desc;276276+ struct sh_dmae_slave *param = chan->private;277277+278278+ /*279279+ * This relies on the guarantee from dmaengine that alloc_chan_resources280280+ * never runs concurrently with itself or free_chan_resources.281281+ */282282+ if (param) {283283+ struct sh_dmae_slave_config *cfg;284284+285285+ cfg = sh_dmae_find_slave(sh_chan, param->slave_id);286286+ if (!cfg)287287+ return -EINVAL;288288+289289+ if (test_and_set_bit(param->slave_id, sh_dmae_slave_used))290290+ return -EBUSY;291291+292292+ param->config = cfg;293293+294294+ dmae_set_dmars(sh_chan, cfg->mid_rid);295295+ dmae_set_chcr(sh_chan, cfg->chcr);296296+ } else {297297+ if ((sh_dmae_readl(sh_chan, CHCR) & 0x700) != 0x400)298298+ dmae_set_chcr(sh_chan, RS_DEFAULT);299299+ }252300253301 spin_lock_bh(&sh_chan->desc_lock);254302 while (sh_chan->descs_allocated < NR_DESCS_PER_CHANNEL) {···324286 struct sh_desc *desc, *_desc;325287 LIST_HEAD(list);326288289289+ dmae_halt(sh_chan);290290+327291 /* Prepared and not submitted descriptors can still be on the queue */328292 if (!list_empty(&sh_chan->ld_queue))329293 sh_dmae_chan_ld_cleanup(sh_chan, true);294294+295295+ if (chan->private) {296296+ /* The caller is holding dma_list_mutex */297297+ struct sh_dmae_slave *param = chan->private;298298+ clear_bit(param->slave_id, sh_dmae_slave_used);299299+ }330300331301 spin_lock_bh(&sh_chan->desc_lock);332302···347301 kfree(desc);348302}349303350350-static struct dma_async_tx_descriptor *sh_dmae_prep_memcpy(351351- struct dma_chan *chan, dma_addr_t dma_dest, dma_addr_t dma_src,352352- size_t len, unsigned long flags)304304+/**305305+ * sh_dmae_add_desc - get, set up and return one transfer descriptor306306+ * @sh_chan: DMA channel307307+ * @flags: DMA transfer flags308308+ * @dest: destination DMA address, incremented when direction equals309309+ * DMA_FROM_DEVICE or DMA_BIDIRECTIONAL310310+ * @src: source DMA address, incremented when direction equals311311+ * DMA_TO_DEVICE or DMA_BIDIRECTIONAL312312+ * @len: DMA transfer length313313+ * @first: if NULL, set to the current descriptor and cookie set to -EBUSY314314+ * @direction: needed for slave DMA to decide which address to keep constant,315315+ * equals DMA_BIDIRECTIONAL for MEMCPY316316+ * Returns 0 or an error317317+ * Locks: called with desc_lock held318318+ */319319+static struct sh_desc *sh_dmae_add_desc(struct sh_dmae_chan *sh_chan,320320+ unsigned long flags, dma_addr_t *dest, dma_addr_t *src, size_t *len,321321+ struct sh_desc **first, enum dma_data_direction direction)353322{354354- struct sh_dmae_chan *sh_chan;355355- struct sh_desc *first = NULL, *prev = NULL, *new;323323+ struct sh_desc *new;356324 size_t copy_size;325325+326326+ if (!*len)327327+ return NULL;328328+329329+ /* Allocate the link descriptor from the free list */330330+ new = sh_dmae_get_desc(sh_chan);331331+ if (!new) {332332+ dev_err(sh_chan->dev, "No free link descriptor available\n");333333+ return NULL;334334+ }335335+336336+ copy_size = min(*len, (size_t)SH_DMA_TCR_MAX + 1);337337+338338+ new->hw.sar = *src;339339+ new->hw.dar = *dest;340340+ new->hw.tcr = copy_size;341341+342342+ if (!*first) {343343+ /* First desc */344344+ new->async_tx.cookie = -EBUSY;345345+ *first = new;346346+ } else {347347+ /* Other desc - invisible to the user */348348+ new->async_tx.cookie = -EINVAL;349349+ }350350+351351+ dev_dbg(sh_chan->dev,352352+ "chaining (%u/%u)@%x -> %x with %p, cookie %d, shift %d\n",353353+ copy_size, *len, *src, *dest, &new->async_tx,354354+ new->async_tx.cookie, sh_chan->xmit_shift);355355+356356+ new->mark = DESC_PREPARED;357357+ new->async_tx.flags = flags;358358+ new->direction = direction;359359+360360+ *len -= copy_size;361361+ if (direction == DMA_BIDIRECTIONAL || direction == DMA_TO_DEVICE)362362+ *src += copy_size;363363+ if (direction == DMA_BIDIRECTIONAL || direction == DMA_FROM_DEVICE)364364+ *dest += copy_size;365365+366366+ return new;367367+}368368+369369+/*370370+ * sh_dmae_prep_sg - prepare transfer descriptors from an SG list371371+ *372372+ * Common routine for public (MEMCPY) and slave DMA. The MEMCPY case is also373373+ * converted to scatter-gather to guarantee consistent locking and a correct374374+ * list manipulation. For slave DMA direction carries the usual meaning, and,375375+ * logically, the SG list is RAM and the addr variable contains slave address,376376+ * e.g., the FIFO I/O register. For MEMCPY direction equals DMA_BIDIRECTIONAL377377+ * and the SG list contains only one element and points at the source buffer.378378+ */379379+static struct dma_async_tx_descriptor *sh_dmae_prep_sg(struct sh_dmae_chan *sh_chan,380380+ struct scatterlist *sgl, unsigned int sg_len, dma_addr_t *addr,381381+ enum dma_data_direction direction, unsigned long flags)382382+{383383+ struct scatterlist *sg;384384+ struct sh_desc *first = NULL, *new = NULL /* compiler... */;357385 LIST_HEAD(tx_list);358358- int chunks = (len + SH_DMA_TCR_MAX) / (SH_DMA_TCR_MAX + 1);386386+ int chunks = 0;387387+ int i;359388360360- if (!chan)389389+ if (!sg_len)361390 return NULL;362391363363- if (!len)364364- return NULL;365365-366366- sh_chan = to_sh_chan(chan);392392+ for_each_sg(sgl, sg, sg_len, i)393393+ chunks += (sg_dma_len(sg) + SH_DMA_TCR_MAX) /394394+ (SH_DMA_TCR_MAX + 1);367395368396 /* Have to lock the whole loop to protect against concurrent release */369397 spin_lock_bh(&sh_chan->desc_lock);···453333 * only during this function, then they are immediately spliced454334 * back onto the free list in form of a chain455335 */456456- do {457457- /* Allocate the link descriptor from the free list */458458- new = sh_dmae_get_desc(sh_chan);459459- if (!new) {460460- dev_err(sh_chan->dev,461461- "No free memory for link descriptor\n");462462- list_for_each_entry(new, &tx_list, node)463463- new->mark = DESC_IDLE;464464- list_splice(&tx_list, &sh_chan->ld_free);465465- spin_unlock_bh(&sh_chan->desc_lock);466466- return NULL;467467- }336336+ for_each_sg(sgl, sg, sg_len, i) {337337+ dma_addr_t sg_addr = sg_dma_address(sg);338338+ size_t len = sg_dma_len(sg);468339469469- copy_size = min(len, (size_t)SH_DMA_TCR_MAX + 1);340340+ if (!len)341341+ goto err_get_desc;470342471471- new->hw.sar = dma_src;472472- new->hw.dar = dma_dest;473473- new->hw.tcr = copy_size;474474- if (!first) {475475- /* First desc */476476- new->async_tx.cookie = -EBUSY;477477- first = new;478478- } else {479479- /* Other desc - invisible to the user */480480- new->async_tx.cookie = -EINVAL;481481- }343343+ do {344344+ dev_dbg(sh_chan->dev, "Add SG #%d@%p[%d], dma %llx\n",345345+ i, sg, len, (unsigned long long)sg_addr);482346483483- dev_dbg(sh_chan->dev,484484- "chaining %u of %u with %p, dst %x, cookie %d\n",485485- copy_size, len, &new->async_tx, dma_dest,486486- new->async_tx.cookie);347347+ if (direction == DMA_FROM_DEVICE)348348+ new = sh_dmae_add_desc(sh_chan, flags,349349+ &sg_addr, addr, &len, &first,350350+ direction);351351+ else352352+ new = sh_dmae_add_desc(sh_chan, flags,353353+ addr, &sg_addr, &len, &first,354354+ direction);355355+ if (!new)356356+ goto err_get_desc;487357488488- new->mark = DESC_PREPARED;489489- new->async_tx.flags = flags;490490- new->chunks = chunks--;491491-492492- prev = new;493493- len -= copy_size;494494- dma_src += copy_size;495495- dma_dest += copy_size;496496- /* Insert the link descriptor to the LD ring */497497- list_add_tail(&new->node, &tx_list);498498- } while (len);358358+ new->chunks = chunks--;359359+ list_add_tail(&new->node, &tx_list);360360+ } while (len);361361+ }499362500363 if (new != first)501364 new->async_tx.cookie = -ENOSPC;···489386 spin_unlock_bh(&sh_chan->desc_lock);490387491388 return &first->async_tx;389389+390390+err_get_desc:391391+ list_for_each_entry(new, &tx_list, node)392392+ new->mark = DESC_IDLE;393393+ list_splice(&tx_list, &sh_chan->ld_free);394394+395395+ spin_unlock_bh(&sh_chan->desc_lock);396396+397397+ return NULL;398398+}399399+400400+static struct dma_async_tx_descriptor *sh_dmae_prep_memcpy(401401+ struct dma_chan *chan, dma_addr_t dma_dest, dma_addr_t dma_src,402402+ size_t len, unsigned long flags)403403+{404404+ struct sh_dmae_chan *sh_chan;405405+ struct scatterlist sg;406406+407407+ if (!chan || !len)408408+ return NULL;409409+410410+ chan->private = NULL;411411+412412+ sh_chan = to_sh_chan(chan);413413+414414+ sg_init_table(&sg, 1);415415+ sg_set_page(&sg, pfn_to_page(PFN_DOWN(dma_src)), len,416416+ offset_in_page(dma_src));417417+ sg_dma_address(&sg) = dma_src;418418+ sg_dma_len(&sg) = len;419419+420420+ return sh_dmae_prep_sg(sh_chan, &sg, 1, &dma_dest, DMA_BIDIRECTIONAL,421421+ flags);422422+}423423+424424+static struct dma_async_tx_descriptor *sh_dmae_prep_slave_sg(425425+ struct dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len,426426+ enum dma_data_direction direction, unsigned long flags)427427+{428428+ struct sh_dmae_slave *param;429429+ struct sh_dmae_chan *sh_chan;430430+431431+ if (!chan)432432+ return NULL;433433+434434+ sh_chan = to_sh_chan(chan);435435+ param = chan->private;436436+437437+ /* Someone calling slave DMA on a public channel? */438438+ if (!param || !sg_len) {439439+ dev_warn(sh_chan->dev, "%s: bad parameter: %p, %d, %d\n",440440+ __func__, param, sg_len, param ? param->slave_id : -1);441441+ return NULL;442442+ }443443+444444+ /*445445+ * if (param != NULL), this is a successfully requested slave channel,446446+ * therefore param->config != NULL too.447447+ */448448+ return sh_dmae_prep_sg(sh_chan, sgl, sg_len, ¶m->config->addr,449449+ direction, flags);450450+}451451+452452+static void sh_dmae_terminate_all(struct dma_chan *chan)453453+{454454+ struct sh_dmae_chan *sh_chan = to_sh_chan(chan);455455+456456+ if (!chan)457457+ return;458458+459459+ sh_dmae_chan_ld_cleanup(sh_chan, true);492460}493461494462static dma_async_tx_callback __ld_cleanup(struct sh_dmae_chan *sh_chan, bool all)···593419 cookie = tx->cookie;594420595421 if (desc->mark == DESC_COMPLETED && desc->chunks == 1) {596596- BUG_ON(sh_chan->completed_cookie != desc->cookie - 1);422422+ if (sh_chan->completed_cookie != desc->cookie - 1)423423+ dev_dbg(sh_chan->dev,424424+ "Completing cookie %d, expected %d\n",425425+ desc->cookie,426426+ sh_chan->completed_cookie + 1);597427 sh_chan->completed_cookie = desc->cookie;598428 }599429···670492 return;671493 }672494673673- /* Find the first un-transfer desciptor */495495+ /* Find the first not transferred desciptor */674496 list_for_each_entry(sd, &sh_chan->ld_queue, node)675497 if (sd->mark == DESC_SUBMITTED) {676498 /* Get the ld start address from ld_queue */···737559738560 /* IRQ Multi */739561 if (shdev->pdata.mode & SHDMA_MIX_IRQ) {740740- int cnt = 0;562562+ int __maybe_unused cnt = 0;741563 switch (irq) {742564#if defined(DMTE6_IRQ) && defined(DMAE1_IRQ)743565 case DMTE6_IRQ:···774596 struct sh_dmae_chan *sh_chan = (struct sh_dmae_chan *)data;775597 struct sh_desc *desc;776598 u32 sar_buf = sh_dmae_readl(sh_chan, SAR);599599+ u32 dar_buf = sh_dmae_readl(sh_chan, DAR);777600778601 spin_lock(&sh_chan->desc_lock);779602 list_for_each_entry(desc, &sh_chan->ld_queue, node) {780780- if ((desc->hw.sar + desc->hw.tcr) == sar_buf &&781781- desc->mark == DESC_SUBMITTED) {603603+ if (desc->mark == DESC_SUBMITTED &&604604+ ((desc->direction == DMA_FROM_DEVICE &&605605+ (desc->hw.dar + desc->hw.tcr) == dar_buf) ||606606+ (desc->hw.sar + desc->hw.tcr) == sar_buf)) {782607 dev_dbg(sh_chan->dev, "done #%d@%p dst %u\n",783608 desc->async_tx.cookie, &desc->async_tx,784609 desc->hw.dar);···854673 }855674856675 snprintf(new_sh_chan->dev_id, sizeof(new_sh_chan->dev_id),857857- "sh-dmae%d", new_sh_chan->id);676676+ "sh-dmae%d", new_sh_chan->id);858677859678 /* set up channel irq */860679 err = request_irq(irq, &sh_dmae_interrupt, irqflags,···864683 "with return %d\n", id, err);865684 goto err_no_irq;866685 }867867-868868- /* CHCR register control function */869869- new_sh_chan->set_chcr = dmae_set_chcr;870870- /* DMARS register control function */871871- new_sh_chan->set_dmars = dmae_set_dmars;872686873687 shdev->chan[id] = new_sh_chan;874688 return 0;···935759 INIT_LIST_HEAD(&shdev->common.channels);936760937761 dma_cap_set(DMA_MEMCPY, shdev->common.cap_mask);762762+ dma_cap_set(DMA_SLAVE, shdev->common.cap_mask);763763+938764 shdev->common.device_alloc_chan_resources939765 = sh_dmae_alloc_chan_resources;940766 shdev->common.device_free_chan_resources = sh_dmae_free_chan_resources;941767 shdev->common.device_prep_dma_memcpy = sh_dmae_prep_memcpy;942768 shdev->common.device_is_tx_complete = sh_dmae_is_complete;943769 shdev->common.device_issue_pending = sh_dmae_memcpy_issue_pending;770770+771771+ /* Compulsory for DMA_SLAVE fields */772772+ shdev->common.device_prep_slave_sg = sh_dmae_prep_slave_sg;773773+ shdev->common.device_terminate_all = sh_dmae_terminate_all;774774+944775 shdev->common.dev = &pdev->dev;945776 /* Default transfer size of 32 bytes requires 32-byte alignment */946777 shdev->common.copy_align = 5;
+2-5
drivers/dma/shdma.h
···2929 struct sh_dmae_regs hw;3030 struct list_head node;3131 struct dma_async_tx_descriptor async_tx;3232+ enum dma_data_direction direction;3233 dma_cookie_t cookie;3334 int chunks;3435 int mark;···4645 struct device *dev; /* Channel device */4746 struct tasklet_struct tasklet; /* Tasklet */4847 int descs_allocated; /* desc count */4848+ int xmit_shift; /* log_2(bytes_per_xfer) */4949 int id; /* Raw id of this channel */5050 char dev_id[16]; /* unique name per DMAC of channel */5151-5252- /* Set chcr */5353- int (*set_chcr)(struct sh_dmae_chan *sh_chan, u32 regs);5454- /* Set DMA resource */5555- int (*set_dmars)(struct sh_dmae_chan *sh_chan, u16 res);5651};57525853struct sh_dmae_device {
+1-1
drivers/gpu/drm/ati_pcigart.c
···113113114114 if (pci_set_dma_mask(dev->pdev, gart_info->table_mask)) {115115 DRM_ERROR("fail to set dma mask to 0x%Lx\n",116116- gart_info->table_mask);116116+ (unsigned long long)gart_info->table_mask);117117 ret = 1;118118 goto done;119119 }
···35643564 uint32_t reloc_count = 0, i;35653565 int ret = 0;3566356635673567+ if (relocs == NULL)35683568+ return 0;35693569+35673570 for (i = 0; i < buffer_count; i++) {35683571 struct drm_i915_gem_relocation_entry __user *user_relocs;35693572 int unwritten;···36563653 struct drm_gem_object *batch_obj;36573654 struct drm_i915_gem_object *obj_priv;36583655 struct drm_clip_rect *cliprects = NULL;36593659- struct drm_i915_gem_relocation_entry *relocs;36563656+ struct drm_i915_gem_relocation_entry *relocs = NULL;36603657 int ret = 0, ret2, i, pinned = 0;36613658 uint64_t exec_offset;36623659 uint32_t seqno, flush_domains, reloc_index;···37253722 if (object_list[i] == NULL) {37263723 DRM_ERROR("Invalid object handle %d at index %d\n",37273724 exec_list[i].handle, i);37253725+ /* prevent error path from reading uninitialized data */37263726+ args->buffer_count = i + 1;37283727 ret = -EBADF;37293728 goto err;37303729 }···37353730 if (obj_priv->in_execbuffer) {37363731 DRM_ERROR("Object %p appears more than once in object list\n",37373732 object_list[i]);37333733+ /* prevent error path from reading uninitialized data */37343734+ args->buffer_count = i + 1;37383735 ret = -EBADF;37393736 goto err;37403737 }···3933392639343927 mutex_unlock(&dev->struct_mutex);3935392839293929+pre_mutex_err:39363930 /* Copy the updated relocations out regardless of current error39373931 * state. Failure to update the relocs would mean that the next39383932 * time userland calls execbuf, it would do so with presumed offset···39483940 ret = ret2;39493941 }3950394239513951-pre_mutex_err:39523943 drm_free_large(object_list);39533944 kfree(cliprects);39543945
···661661 void (*hpd_fini)(struct radeon_device *rdev);662662 bool (*hpd_sense)(struct radeon_device *rdev, enum radeon_hpd_id hpd);663663 void (*hpd_set_polarity)(struct radeon_device *rdev, enum radeon_hpd_id hpd);664664+ /* ioctl hw specific callback. Some hw might want to perform special665665+ * operation on specific ioctl. For instance on wait idle some hw666666+ * might want to perform and HDP flush through MMIO as it seems that667667+ * some R6XX/R7XX hw doesn't take HDP flush into account if programmed668668+ * through ring.669669+ */670670+ void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo *bo);664671};665672666673/*···11501143extern void r600_cp_stop(struct radeon_device *rdev);11511144extern void r600_ring_init(struct radeon_device *rdev, unsigned ring_size);11521145extern int r600_cp_resume(struct radeon_device *rdev);11461146+extern void r600_cp_fini(struct radeon_device *rdev);11531147extern int r600_count_pipe_bits(uint32_t val);11541148extern int r600_gart_clear_page(struct radeon_device *rdev, int i);11551149extern int r600_mc_wait_for_idle(struct radeon_device *rdev);
···308308 }309309 robj = gobj->driver_private;310310 r = radeon_bo_wait(robj, NULL, false);311311+ /* callback hw specific functions if any */312312+ if (robj->rdev->asic->ioctl_wait_idle)313313+ robj->rdev->asic->ioctl_wait_idle(robj->rdev, robj);311314 mutex_lock(&dev->struct_mutex);312315 drm_gem_object_unreference(gobj);313316 mutex_unlock(&dev->struct_mutex);
+21-7
drivers/gpu/drm/radeon/rs400.c
···223223 return 0;224224}225225226226+int rs400_mc_wait_for_idle(struct radeon_device *rdev)227227+{228228+ unsigned i;229229+ uint32_t tmp;230230+231231+ for (i = 0; i < rdev->usec_timeout; i++) {232232+ /* read MC_STATUS */233233+ tmp = RREG32(0x0150);234234+ if (tmp & (1 << 2)) {235235+ return 0;236236+ }237237+ DRM_UDELAY(1);238238+ }239239+ return -1;240240+}241241+226242void rs400_gpu_init(struct radeon_device *rdev)227243{228244 /* FIXME: HDP same place on rs400 ? */229245 r100_hdp_reset(rdev);230246 /* FIXME: is this correct ? */231247 r420_pipes_init(rdev);232232- if (r300_mc_wait_for_idle(rdev)) {233233- printk(KERN_WARNING "Failed to wait MC idle while "234234- "programming pipes. Bad things might happen.\n");248248+ if (rs400_mc_wait_for_idle(rdev)) {249249+ printk(KERN_WARNING "rs400: Failed to wait MC idle while "250250+ "programming pipes. Bad things might happen. %08x\n", RREG32(0x150));235251 }236252}237253···386370 r100_mc_stop(rdev, &save);387371388372 /* Wait for mc idle */389389- if (r300_mc_wait_for_idle(rdev))390390- dev_warn(rdev->dev, "Wait MC idle timeout before updating MC.\n");373373+ if (rs400_mc_wait_for_idle(rdev))374374+ dev_warn(rdev->dev, "rs400: Wait MC idle timeout before updating MC.\n");391375 WREG32(R_000148_MC_FB_LOCATION,392376 S_000148_MC_FB_START(rdev->mc.vram_start >> 16) |393377 S_000148_MC_FB_TOP(rdev->mc.vram_end >> 16));···464448465449void rs400_fini(struct radeon_device *rdev)466450{467467- rs400_suspend(rdev);468451 r100_cp_fini(rdev);469452 r100_wb_fini(rdev);470453 r100_ib_fini(rdev);···542527 if (r) {543528 /* Somethings want wront with the accel init stop accel */544529 dev_err(rdev->dev, "Disabling GPU acceleration\n");545545- rs400_suspend(rdev);546530 r100_cp_fini(rdev);547531 r100_wb_fini(rdev);548532 r100_ib_fini(rdev);
-2
drivers/gpu/drm/radeon/rs600.c
···610610611611void rs600_fini(struct radeon_device *rdev)612612{613613- rs600_suspend(rdev);614613 r100_cp_fini(rdev);615614 r100_wb_fini(rdev);616615 r100_ib_fini(rdev);···688689 if (r) {689690 /* Somethings want wront with the accel init stop accel */690691 dev_err(rdev->dev, "Disabling GPU acceleration\n");691691- rs600_suspend(rdev);692692 r100_cp_fini(rdev);693693 r100_wb_fini(rdev);694694 r100_ib_fini(rdev);
-2
drivers/gpu/drm/radeon/rs690.c
···676676677677void rs690_fini(struct radeon_device *rdev)678678{679679- rs690_suspend(rdev);680679 r100_cp_fini(rdev);681680 r100_wb_fini(rdev);682681 r100_ib_fini(rdev);···755756 if (r) {756757 /* Somethings want wront with the accel init stop accel */757758 dev_err(rdev->dev, "Disabling GPU acceleration\n");758758- rs690_suspend(rdev);759759 r100_cp_fini(rdev);760760 r100_wb_fini(rdev);761761 r100_ib_fini(rdev);
···887887 return r;888888 }889889 rv770_gpu_init(rdev);890890+ r = r600_blit_init(rdev);891891+ if (r) {892892+ r600_blit_fini(rdev);893893+ rdev->asic->copy = NULL;894894+ dev_warn(rdev->dev, "failed blitter (%d) falling back to memcpy\n", r);895895+ }890896 /* pin copy shader into vram */891897 if (rdev->r600_blit.shader_obj) {892898 r = radeon_bo_reserve(rdev->r600_blit.shader_obj, false);···10611055 r = r600_pcie_gart_init(rdev);10621056 if (r)10631057 return r;10641064- r = r600_blit_init(rdev);10651065- if (r) {10661066- r600_blit_fini(rdev);10671067- rdev->asic->copy = NULL;10681068- dev_warn(rdev->dev, "failed blitter (%d) falling back to memcpy\n", r);10691069- }1070105810711059 rdev->accel_working = true;10721060 r = rv770_startup(rdev);10731061 if (r) {10741074- rv770_suspend(rdev);10621062+ dev_err(rdev->dev, "disabling GPU acceleration\n");10631063+ r600_cp_fini(rdev);10751064 r600_wb_fini(rdev);10761076- radeon_ring_fini(rdev);10651065+ r600_irq_fini(rdev);10661066+ radeon_irq_kms_fini(rdev);10771067 rv770_pcie_gart_fini(rdev);10781068 rdev->accel_working = false;10791069 }···1091108910921090void rv770_fini(struct radeon_device *rdev)10931091{10941094- rv770_suspend(rdev);10951095-10961092 r600_blit_fini(rdev);10931093+ r600_cp_fini(rdev);10941094+ r600_wb_fini(rdev);10971095 r600_irq_fini(rdev);10981096 radeon_irq_kms_fini(rdev);10991099- radeon_ring_fini(rdev);11001100- r600_wb_fini(rdev);11011097 rv770_pcie_gart_fini(rdev);11021098 radeon_gem_fini(rdev);11031099 radeon_fence_driver_fini(rdev);
+1-1
drivers/hwmon/adt7462.c
···179179 *180180 * Some, but not all, of these voltages have low/high limits.181181 */182182-#define ADT7462_VOLT_COUNT 12182182+#define ADT7462_VOLT_COUNT 13183183184184#define ADT7462_VENDOR 0x41185185#define ADT7462_DEVICE 0x62
+11-12
drivers/hwmon/lm78.c
···851851static int __init lm78_isa_found(unsigned short address)852852{853853 int val, save, found = 0;854854+ int port;854855855855- /* We have to request the region in two parts because some856856- boards declare base+4 to base+7 as a PNP device */857857- if (!request_region(address, 4, "lm78")) {858858- pr_debug("lm78: Failed to request low part of region\n");859859- return 0;860860- }861861- if (!request_region(address + 4, 4, "lm78")) {862862- pr_debug("lm78: Failed to request high part of region\n");863863- release_region(address, 4);864864- return 0;856856+ /* Some boards declare base+0 to base+7 as a PNP device, some base+4857857+ * to base+7 and some base+5 to base+6. So we better request each port858858+ * individually for the probing phase. */859859+ for (port = address; port < address + LM78_EXTENT; port++) {860860+ if (!request_region(port, 1, "lm78")) {861861+ pr_debug("lm78: Failed to request port 0x%x\n", port);862862+ goto release;863863+ }865864 }866865867866#define REALLY_SLOW_IO···924925 val & 0x80 ? "LM79" : "LM78", (int)address);925926926927 release:927927- release_region(address + 4, 4);928928- release_region(address, 4);928928+ for (port--; port >= address; port--)929929+ release_region(port, 1);929930 return found;930931}931932
+12-12
drivers/hwmon/w83781d.c
···17931793w83781d_isa_found(unsigned short address)17941794{17951795 int val, save, found = 0;17961796+ int port;1796179717971797- /* We have to request the region in two parts because some17981798- boards declare base+4 to base+7 as a PNP device */17991799- if (!request_region(address, 4, "w83781d")) {18001800- pr_debug("w83781d: Failed to request low part of region\n");18011801- return 0;18021802- }18031803- if (!request_region(address + 4, 4, "w83781d")) {18041804- pr_debug("w83781d: Failed to request high part of region\n");18051805- release_region(address, 4);18061806- return 0;17981798+ /* Some boards declare base+0 to base+7 as a PNP device, some base+417991799+ * to base+7 and some base+5 to base+6. So we better request each port18001800+ * individually for the probing phase. */18011801+ for (port = address; port < address + W83781D_EXTENT; port++) {18021802+ if (!request_region(port, 1, "w83781d")) {18031803+ pr_debug("w83781d: Failed to request port 0x%x\n",18041804+ port);18051805+ goto release;18061806+ }18071807 }1808180818091809#define REALLY_SLOW_IO···18771877 val == 0x30 ? "W83782D" : "W83781D", (int)address);1878187818791879 release:18801880- release_region(address + 4, 4);18811881- release_region(address, 4);18801880+ for (port--; port >= address; port--)18811881+ release_region(port, 1);18821882 return found;18831883}18841884
+17
drivers/pci/quirks.c
···338338DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_868, quirk_s3_64M);339339DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_968, quirk_s3_64M);340340341341+/*342342+ * Some CS5536 BIOSes (for example, the Soekris NET5501 board w/ comBIOS343343+ * ver. 1.33 20070103) don't set the correct ISA PCI region header info.344344+ * BAR0 should be 8 bytes; instead, it may be set to something like 8k345345+ * (which conflicts w/ BAR1's memory range).346346+ */347347+static void __devinit quirk_cs5536_vsa(struct pci_dev *dev)348348+{349349+ if (pci_resource_len(dev, 0) != 8) {350350+ struct resource *res = &dev->resource[0];351351+ res->end = res->start + 8 - 1;352352+ dev_info(&dev->dev, "CS5536 ISA bridge bug detected "353353+ "(incorrect header); workaround applied.\n");354354+ }355355+}356356+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA, quirk_cs5536_vsa);357357+341358static void __devinit quirk_io_region(struct pci_dev *dev, unsigned region,342359 unsigned size, int nr, const char *name)343360{
···16811681 * before we start the transaction. It limits the amount of btree16821682 * reads required while inside the transaction.16831683 */16841684-static noinline void reada_csum(struct btrfs_root *root,16851685- struct btrfs_path *path,16861686- struct btrfs_ordered_extent *ordered_extent)16871687-{16881688- struct btrfs_ordered_sum *sum;16891689- u64 bytenr;16901690-16911691- sum = list_entry(ordered_extent->list.next, struct btrfs_ordered_sum,16921692- list);16931693- bytenr = sum->sums[0].bytenr;16941694-16951695- /*16961696- * we don't care about the results, the point of this search is16971697- * just to get the btree leaves into ram16981698- */16991699- btrfs_lookup_csum(NULL, root->fs_info->csum_root, path, bytenr, 0);17001700-}17011701-17021684/* as ordered data IO finishes, this gets called so we can finish17031685 * an ordered extent if the range of bytes in the file it covers are17041686 * fully written.···16911709 struct btrfs_trans_handle *trans;16921710 struct btrfs_ordered_extent *ordered_extent = NULL;16931711 struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;16941694- struct btrfs_path *path;16951712 int compressed = 0;16961713 int ret;16971714···16981717 if (!ret)16991718 return 0;1700171917011701- /*17021702- * before we join the transaction, try to do some of our IO.17031703- * This will limit the amount of IO that we have to do with17041704- * the transaction running. We're unlikely to need to do any17051705- * IO if the file extents are new, the disk_i_size checks17061706- * covers the most common case.17071707- */17081708- if (start < BTRFS_I(inode)->disk_i_size) {17091709- path = btrfs_alloc_path();17101710- if (path) {17111711- ret = btrfs_lookup_file_extent(NULL, root, path,17121712- inode->i_ino,17131713- start, 0);17141714- ordered_extent = btrfs_lookup_ordered_extent(inode,17151715- start);17161716- if (!list_empty(&ordered_extent->list)) {17171717- btrfs_release_path(root, path);17181718- reada_csum(root, path, ordered_extent);17191719- }17201720- btrfs_free_path(path);17211721- }17221722- }17231723-17241724- if (!ordered_extent)17251725- ordered_extent = btrfs_lookup_ordered_extent(inode, start);17201720+ ordered_extent = btrfs_lookup_ordered_extent(inode, start);17261721 BUG_ON(!ordered_extent);17221722+17271723 if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) {17281724 BUG_ON(!list_empty(&ordered_extent->list));17291725 ret = btrfs_ordered_update_i_size(inode, 0, ordered_extent);···57995841 inode->i_ctime = CURRENT_TIME;58005842 BTRFS_I(inode)->flags |= BTRFS_INODE_PREALLOC;58015843 if (!(mode & FALLOC_FL_KEEP_SIZE) &&58025802- cur_offset > inode->i_size) {58445844+ (actual_len > inode->i_size) &&58455845+ (cur_offset > inode->i_size)) {58465846+58035847 if (cur_offset > actual_len)58045848 i_size = actual_len;58055849 else
···1717extern int ima_bprm_check(struct linux_binprm *bprm);1818extern int ima_inode_alloc(struct inode *inode);1919extern void ima_inode_free(struct inode *inode);2020-extern int ima_path_check(struct path *path, int mask);2020+extern int ima_file_check(struct file *file, int mask);2121extern void ima_file_free(struct file *file);2222extern int ima_file_mmap(struct file *file, unsigned long prot);2323extern void ima_counts_get(struct file *file);···3838 return;3939}40404141-static inline int ima_path_check(struct path *path, int mask)4141+static inline int ima_file_check(struct file *file, int mask)4242{4343 return 0;4444}
···1414 *1515 * File: ima_main.c1616 * implements the IMA hooks: ima_bprm_check, ima_file_mmap,1717- * and ima_path_check.1717+ * and ima_file_check.1818 */1919#include <linux/module.h>2020#include <linux/file.h>···8484 return found;8585}86868787+/* ima_read_write_check - reflect possible reading/writing errors in the PCR.8888+ *8989+ * When opening a file for read, if the file is already open for write,9090+ * the file could change, resulting in a file measurement error.9191+ *9292+ * Opening a file for write, if the file is already open for read, results9393+ * in a time of measure, time of use (ToMToU) error.9494+ *9595+ * In either case invalidate the PCR.9696+ */9797+enum iint_pcr_error { TOMTOU, OPEN_WRITERS };9898+static void ima_read_write_check(enum iint_pcr_error error,9999+ struct ima_iint_cache *iint,100100+ struct inode *inode,101101+ const unsigned char *filename)102102+{103103+ switch (error) {104104+ case TOMTOU:105105+ if (iint->readcount > 0)106106+ ima_add_violation(inode, filename, "invalid_pcr",107107+ "ToMToU");108108+ break;109109+ case OPEN_WRITERS:110110+ if (iint->writecount > 0)111111+ ima_add_violation(inode, filename, "invalid_pcr",112112+ "open_writers");113113+ break;114114+ }115115+}116116+87117/*88118 * Update the counts given an fmode_t89119 */···12696 iint->readcount++;12797 if (mode & FMODE_WRITE)12898 iint->writecount++;9999+}100100+101101+/*102102+ * ima_counts_get - increment file counts103103+ *104104+ * Maintain read/write counters for all files, but only105105+ * invalidate the PCR for measured files:106106+ * - Opening a file for write when already open for read,107107+ * results in a time of measure, time of use (ToMToU) error.108108+ * - Opening a file for read when already open for write,109109+ * could result in a file measurement error.110110+ *111111+ */112112+void ima_counts_get(struct file *file)113113+{114114+ struct dentry *dentry = file->f_path.dentry;115115+ struct inode *inode = dentry->d_inode;116116+ fmode_t mode = file->f_mode;117117+ struct ima_iint_cache *iint;118118+ int rc;119119+120120+ if (!ima_initialized || !S_ISREG(inode->i_mode))121121+ return;122122+ iint = ima_iint_find_get(inode);123123+ if (!iint)124124+ return;125125+ mutex_lock(&iint->mutex);126126+ rc = ima_must_measure(iint, inode, MAY_READ, FILE_CHECK);127127+ if (rc < 0)128128+ goto out;129129+130130+ if (mode & FMODE_WRITE) {131131+ ima_read_write_check(TOMTOU, iint, inode, dentry->d_name.name);132132+ goto out;133133+ }134134+ ima_read_write_check(OPEN_WRITERS, iint, inode, dentry->d_name.name);135135+out:136136+ ima_inc_counts(iint, file->f_mode);137137+ mutex_unlock(&iint->mutex);138138+139139+ kref_put(&iint->refcount, iint_free);129140}130141131142/*···224153 kref_put(&iint->refcount, iint_free);225154}226155227227-/* ima_read_write_check - reflect possible reading/writing errors in the PCR.228228- *229229- * When opening a file for read, if the file is already open for write,230230- * the file could change, resulting in a file measurement error.231231- *232232- * Opening a file for write, if the file is already open for read, results233233- * in a time of measure, time of use (ToMToU) error.234234- *235235- * In either case invalidate the PCR.236236- */237237-enum iint_pcr_error { TOMTOU, OPEN_WRITERS };238238-static void ima_read_write_check(enum iint_pcr_error error,239239- struct ima_iint_cache *iint,240240- struct inode *inode,241241- const unsigned char *filename)242242-{243243- switch (error) {244244- case TOMTOU:245245- if (iint->readcount > 0)246246- ima_add_violation(inode, filename, "invalid_pcr",247247- "ToMToU");248248- break;249249- case OPEN_WRITERS:250250- if (iint->writecount > 0)251251- ima_add_violation(inode, filename, "invalid_pcr",252252- "open_writers");253253- break;254254- }255255-}256256-257257-static int get_path_measurement(struct ima_iint_cache *iint, struct file *file,258258- const unsigned char *filename)259259-{260260- int rc = 0;261261-262262- ima_inc_counts(iint, file->f_mode);263263-264264- rc = ima_collect_measurement(iint, file);265265- if (!rc)266266- ima_store_measurement(iint, file, filename);267267- return rc;268268-}269269-270270-/**271271- * ima_path_check - based on policy, collect/store measurement.272272- * @path: contains a pointer to the path to be measured273273- * @mask: contains MAY_READ, MAY_WRITE or MAY_EXECUTE274274- *275275- * Measure the file being open for readonly, based on the276276- * ima_must_measure() policy decision.277277- *278278- * Keep read/write counters for all files, but only279279- * invalidate the PCR for measured files:280280- * - Opening a file for write when already open for read,281281- * results in a time of measure, time of use (ToMToU) error.282282- * - Opening a file for read when already open for write,283283- * could result in a file measurement error.284284- *285285- * Always return 0 and audit dentry_open failures.286286- * (Return code will be based upon measurement appraisal.)287287- */288288-int ima_path_check(struct path *path, int mask)289289-{290290- struct inode *inode = path->dentry->d_inode;291291- struct ima_iint_cache *iint;292292- struct file *file = NULL;293293- int rc;294294-295295- if (!ima_initialized || !S_ISREG(inode->i_mode))296296- return 0;297297- iint = ima_iint_find_get(inode);298298- if (!iint)299299- return 0;300300-301301- mutex_lock(&iint->mutex);302302-303303- rc = ima_must_measure(iint, inode, MAY_READ, PATH_CHECK);304304- if (rc < 0)305305- goto out;306306-307307- if ((mask & MAY_WRITE) || (mask == 0))308308- ima_read_write_check(TOMTOU, iint, inode,309309- path->dentry->d_name.name);310310-311311- if ((mask & (MAY_WRITE | MAY_READ | MAY_EXEC)) != MAY_READ)312312- goto out;313313-314314- ima_read_write_check(OPEN_WRITERS, iint, inode,315315- path->dentry->d_name.name);316316- if (!(iint->flags & IMA_MEASURED)) {317317- struct dentry *dentry = dget(path->dentry);318318- struct vfsmount *mnt = mntget(path->mnt);319319-320320- file = dentry_open(dentry, mnt, O_RDONLY | O_LARGEFILE,321321- current_cred());322322- if (IS_ERR(file)) {323323- int audit_info = 0;324324-325325- integrity_audit_msg(AUDIT_INTEGRITY_PCR, inode,326326- dentry->d_name.name,327327- "add_measurement",328328- "dentry_open failed",329329- 1, audit_info);330330- file = NULL;331331- goto out;332332- }333333- rc = get_path_measurement(iint, file, dentry->d_name.name);334334- }335335-out:336336- mutex_unlock(&iint->mutex);337337- if (file)338338- fput(file);339339- kref_put(&iint->refcount, iint_free);340340- return 0;341341-}342342-EXPORT_SYMBOL_GPL(ima_path_check);343343-344156static int process_measurement(struct file *file, const unsigned char *filename,345157 int mask, int function)346158{···250296 kref_put(&iint->refcount, iint_free);251297 return rc;252298}253253-254254-/*255255- * ima_counts_get - increment file counts256256- *257257- * - for IPC shm and shmat file.258258- * - for nfsd exported files.259259- *260260- * Increment the counts for these files to prevent unnecessary261261- * imbalance messages.262262- */263263-void ima_counts_get(struct file *file)264264-{265265- struct inode *inode = file->f_dentry->d_inode;266266- struct ima_iint_cache *iint;267267-268268- if (!ima_initialized || !S_ISREG(inode->i_mode))269269- return;270270- iint = ima_iint_find_get(inode);271271- if (!iint)272272- return;273273- mutex_lock(&iint->mutex);274274- ima_inc_counts(iint, file->f_mode);275275- mutex_unlock(&iint->mutex);276276-277277- kref_put(&iint->refcount, iint_free);278278-}279279-EXPORT_SYMBOL_GPL(ima_counts_get);280299281300/**282301 * ima_file_mmap - based on policy, collect/store measurement.···296369 return 0;297370}298371372372+/**373373+ * ima_path_check - based on policy, collect/store measurement.374374+ * @file: pointer to the file to be measured375375+ * @mask: contains MAY_READ, MAY_WRITE or MAY_EXECUTE376376+ *377377+ * Measure files based on the ima_must_measure() policy decision.378378+ *379379+ * Always return 0 and audit dentry_open failures.380380+ * (Return code will be based upon measurement appraisal.)381381+ */382382+int ima_file_check(struct file *file, int mask)383383+{384384+ int rc;385385+386386+ rc = process_measurement(file, file->f_dentry->d_name.name,387387+ mask & (MAY_READ | MAY_WRITE | MAY_EXEC),388388+ FILE_CHECK);389389+ return 0;390390+}391391+EXPORT_SYMBOL_GPL(ima_file_check);392392+299393static int __init init_ima(void)300394{301395 int error;302396303303- ima_iintcache_init();304397 error = ima_init();305398 ima_initialized = 1;306399 return error;