summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/ncr53c8xx.c
AgeCommit message (Expand)Author
2020-03-11scsi: docs: convert ncr53c8xx.txt to ReSTMauro Carvalho Chehab
2019-10-24scsi: Fix various misspellings of "connect"Geert Uytterhoeven
2019-08-07scsi: ncr53c8xx: Mark expected switch fall-throughHelge Deller
2019-05-24treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61Thomas Gleixner
2018-12-18scsi: flip the default on use_clusteringChristoph Hellwig
2018-07-10scsi: ncr53c8xx: remove ScsiResult macroJohannes Thumshirn
2017-11-21treewide: setup_timer() -> timer_setup()Kees Cook
2017-11-21treewide: init_timer() -> setup_timer()Kees Cook
2014-11-24scsi: drop reason argument from ->change_queue_depthChristoph Hellwig
2014-11-12scsi: don't set tagging state from scsi_adjust_queue_depthChristoph Hellwig
2014-07-17scsi: use 64-bit LUNsHannes Reinecke
2013-10-14treewide: Fix common typo in "identify"Maxime Jayat
2012-03-28Remove all #inclusions of asm/system.hDavid Howells
2011-05-01[SCSI] remove cmd->serial_number litterChristoph Hellwig
2011-03-31Fix common misspellingsLucas De Marchi
2010-11-16SCSI host lock push-downJeff Garzik
2010-03-30include cleanup: Update gfp.h and slab.h includes to prepare for breaking imp...Tejun Heo
2009-12-04tree-wide: fix assorted typos all over the placeAndré Goddard Rosa
2009-06-15[SCSI] ncr53c8xx: div reaches -1Roel Kluin
2008-10-09block: unify request timeout handlingJens Axboe
2008-05-01drivers/scsi/ncr53c8xx.c: fix warningAndrew Morton
2008-04-28scsi: fix integer as NULL pointer warningsHarvey Harrison
2008-04-19SCSI: convert struct class_device to struct deviceTony Jones
2008-01-30[SCSI] ncr53c8xx: fix sense_buffer access bugFUJITA Tomonori
2008-01-23[SCSI] replace sizeof sense_buffer with SCSI_SENSE_BUFFERSIZEFUJITA Tomonori
2007-10-12[SCSI] Remove ->pid field from scsi_cmndMatthew Wilcox
2007-10-12[SCSI] ncr53c8xx: Call scsi_host_put in releaseMatthew Wilcox
2007-07-15[SCSI] ncr53c8xx: convert to use the data buffer accessorsFUJITA Tomonori
2006-12-05Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6Linus Torvalds
2006-11-30Fix misc .c/.h comment typosMatt LaPlante
2006-11-15[SCSI] minor bug fixes and cleanupsJeff Garzik
2006-10-05IRQ: Maintain regs pointer globally rather than passing to IRQ handlersDavid Howells
2006-06-26[PATCH] drivers: use list_move()Akinobu Mita
2006-06-06[SCSI] fix up request buffer reference in various scsi driversChristoph Hellwig
2006-02-27[SCSI] Add spi_populate_*_msg functionsMatthew Wilcox
2006-02-27[SCSI] ncr53c8xx updateMatthew Wilcox
2005-12-16[SCSI] Merge sym53c8xx_comm.h and sym53c8xx_defs.h into ncr driverMatthew Wilcox
2005-12-16[SCSI] Use spi_print_msg in ncr53c8xx driverMatthew Wilcox
2005-10-28[SCSI] use scmd_id(), scmd_channel() throughout codeJeff Garzik
2005-10-26[SCSI] ncr53c8xx: Cleanup namespace collision with ktimersMatthew Wilcox
2005-06-26[SCSI] remove scsi_set_deviceChristoph Hellwig
2005-04-18[PATCH] scsi: remove meaningless scsi_cmnd->serial_number_at_timeout field
2005-04-16Linux-2.6.12-rc2Linus Torvalds
*/ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*
 *   linux/mm/fremap.c
 * 
 * Explicit pagetable population and nonlinear (random) mappings support.
 *
 * started by Ingo Molnar, Copyright (C) 2002, 2003
 */

#include <linux/mm.h>
#include <linux/swap.h>
#include <linux/file.h>
#include <linux/mman.h>
#include <linux/pagemap.h>
#include <linux/swapops.h>
#include <linux/rmap.h>
#include <linux/module.h>
#include <linux/syscalls.h>

#include <asm/mmu_context.h>
#include <asm/cacheflush.h>
#include <asm/tlbflush.h>

static int zap_pte(struct mm_struct *mm, struct vm_area_struct *vma,
			unsigned long addr, pte_t *ptep)
{
	pte_t pte = *ptep;
	struct page *page = NULL;

	if (pte_present(pte)) {
		flush_cache_page(vma, addr, pte_pfn(pte));
		pte = ptep_clear_flush(vma, addr, ptep);
		page = vm_normal_page(vma, addr, pte);
		if (page) {
			if (pte_dirty(pte))
				set_page_dirty(page);
			page_remove_rmap(page);
			page_cache_release(page);
		}
	} else {
		if (!pte_file(pte))
			free_swap_and_cache(pte_to_swp_entry(pte));
		pte_clear(mm, addr, ptep);
	}
	return !!page;
}

/*
 * Install a file page to a given virtual memory address, release any
 * previously existing mapping.
 */
int install_page(struct mm_struct *mm, struct vm_area_struct *vma,
		unsigned long addr, struct page *page, pgprot_t prot)
{
	struct inode *inode;
	pgoff_t size;
	int err = -ENOMEM;
	pte_t *pte;
	pte_t pte_val;
	spinlock_t *ptl;

	pte = get_locked_pte(mm, addr, &ptl);
	if (!pte)
		goto out;

	/*
	 * This page may have been truncated. Tell the
	 * caller about it.
	 */
	err = -EINVAL;
	inode = vma->vm_file->f_mapping->host;
	size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
	if (!page->mapping || page->index >= size)
		goto unlock;
	err = -ENOMEM;
	if (page_mapcount(page) > INT_MAX/2)
		goto unlock;

	if (pte_none(*pte) || !zap_pte(mm, vma, addr, pte))
		inc_mm_counter(mm, file_rss);

	flush_icache_page(vma, page);
	set_pte_at(mm, addr, pte, mk_pte(page, prot));
	page_add_file_rmap(page);
	pte_val = *pte;
	update_mmu_cache(vma, addr, pte_val);
	lazy_mmu_prot_update(pte_val);
	err = 0;
unlock:
	pte_unmap_unlock(pte, ptl);
out:
	return err;
}
EXPORT_SYMBOL(install_page);

/*
 * Install a file pte to a given virtual memory address, release any
 * previously existing mapping.
 */
int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma,
		unsigned long addr, unsigned long pgoff, pgprot_t prot)
{
	int err = -ENOMEM;
	pte_t *pte;
	pte_t pte_val;
	spinlock_t *ptl;

	pte = get_locked_pte(mm, addr, &ptl);
	if (!pte)
		goto out;

	if (!pte_none(*pte) && zap_pte(mm, vma, addr, pte)) {
		update_hiwater_rss(mm);
		dec_mm_counter(mm, file_rss);
	}

	set_pte_at(mm, addr, pte, pgoff_to_pte(pgoff));
	pte_val = *pte;
	/*
	 * We don't need to run update_mmu_cache() here because the "file pte"
	 * being installed by install_file_pte() is not a real pte - it's a
	 * non-present entry (like a swap entry), noting what file offset should
	 * be mapped there when there's a fault (in a non-linear vma where
	 * that's not obvious).
	 */
	pte_unmap_unlock(pte, ptl);
	err = 0;
out:
	return err;
}

/***
 * sys_remap_file_pages - remap arbitrary pages of a shared backing store
 *                        file within an existing vma.
 * @start: start of the remapped virtual memory range
 * @size: size of the remapped virtual memory range
 * @prot: new protection bits of the range
 * @pgoff: to be mapped page of the backing store file
 * @flags: 0 or MAP_NONBLOCKED - the later will cause no IO.
 *
 * this syscall works purely via pagetables, so it's the most efficient
 * way to map the same (large) file into a given virtual window. Unlike
 * mmap()/mremap() it does not create any new vmas. The new mappings are
 * also safe across swapout.
 *
 * NOTE: the 'prot' parameter right now is ignored, and the vma's default
 * protection is used. Arbitrary protections might be implemented in the
 * future.
 */
asmlinkage long sys_remap_file_pages(unsigned long start, unsigned long size,
	unsigned long __prot, unsigned long pgoff, unsigned long flags)
{
	struct mm_struct *mm = current->mm;
	struct address_space *mapping;
	unsigned long end = start + size;
	struct vm_area_struct *vma;
	int err = -EINVAL;
	int has_write_lock = 0;

	if (__prot)
		return err;
	/*
	 * Sanitize the syscall parameters:
	 */
	start = start & PAGE_MASK;
	size = size & PAGE_MASK;

	/* Does the address range wrap, or is the span zero-sized? */
	if (start + size <= start)
		return err;

	/* Can we represent this offset inside this architecture's pte's? */
#if PTE_FILE_MAX_BITS < BITS_PER_LONG
	if (pgoff + (size >> PAGE_SHIFT) >= (1UL << PTE_FILE_MAX_BITS))
		return err;
#endif

	/* We need down_write() to change vma->vm_flags. */
	down_read(&mm->mmap_sem);
 retry:
	vma = find_vma(mm, start);

	/*
	 * Make sure the vma is shared, that it supports prefaulting,
	 * and that the remapped range is valid and fully within
	 * the single existing vma.  vm_private_data is used as a
	 * swapout cursor in a VM_NONLINEAR vma.
	 */
	if (vma && (vma->vm_flags & VM_SHARED) &&
		(!vma->vm_private_data || (vma->vm_flags & VM_NONLINEAR)) &&
		vma->vm_ops && vma->vm_ops->populate &&
			end > start && start >= vma->vm_start &&
				end <= vma->vm_end) {

		/* Must set VM_NONLINEAR before any pages are populated. */
		if (pgoff != linear_page_index(vma, start) &&
		    !(vma->vm_flags & VM_NONLINEAR)) {
			if (!has_write_lock) {
				up_read(&mm->mmap_sem);
				down_write(&mm->mmap_sem);
				has_write_lock = 1;
				goto retry;
			}
			mapping = vma->vm_file->f_mapping;
			spin_lock(&mapping->i_mmap_lock);
			flush_dcache_mmap_lock(mapping);
			vma->vm_flags |= VM_NONLINEAR;
			vma_prio_tree_remove(vma, &mapping->i_mmap);
			vma_nonlinear_insert(vma, &mapping->i_mmap_nonlinear);
			flush_dcache_mmap_unlock(mapping);
			spin_unlock(&mapping->i_mmap_lock);
		}

		err = vma->vm_ops->populate(vma, start, size,
					    vma->vm_page_prot,
					    pgoff, flags & MAP_NONBLOCK);

		/*
		 * We can't clear VM_NONLINEAR because we'd have to do
		 * it after ->populate completes, and that would prevent
		 * downgrading the lock.  (Locks can't be upgraded).
		 */
	}
	if (likely(!has_write_lock))
		up_read(&mm->mmap_sem);
	else
		up_write(&mm->mmap_sem);

	return err;
}